<?php
$this->load->view('company/script',$this->templates->getData());
$this->load->view('company/modal',$this->templates->getData());
$started = isProjectStarted();
$stopped = isProjectStopped();
?>
<div class="content-wrapper">
	<!-- Content Header (Page header) -->
	<section class="content-header">
			<h1 style="font-family:roboto">
					<b><?php echo $this->lang->line('company'); ?></b>
			</h1>
			<ol class="breadcrumb">
					<li style="color:#0C0"><a href="#"><i class="fa fa-home"></i> <?php echo $this->lang->line('home'); ?></a></li>
					<li style="color:#0C0"><a href="#"><?php echo $this->lang->line('company'); ?></a></li>
					<li class="active" style="color:#0C0"><?php echo $this->lang->line('companyList'); ?></li>
			</ol>
	</section>

	<!-- Main content -->
	<section class="content">
	
		<div class="section-title p-5-x text-center">
			<h1 class="m-0-t font-weight-bold"><?php echo ($l = $this->lang->line('company')) ? ucwords(strtolower($l)) : $this->lang->line('entity'); ?></h1>
			<p class="m-0-b"><?php echo $this->lang->line('listof'); ?></p>
		</div>
		
		<div class="row p-5-x m-1-b text-center">
			<div class="flex-btn-group m-1-y col-md-4 col-md-offset-4">
				<a href="<?php echo base_url(); ?>voter" class="btn btn-danger"><i class="fa fa-backward"></i>&nbsp;<?php echo $this->lang->line('back'); ?></a>
				<?php
				if(!$started && !$stopped) {
					?>
					<button type="button" class="btn btn-sm btn-success" onclick="showDetail(this)"><i class="fa fa-plus fa-fw"></i> <?php echo $this->lang->line('addNew');?></button>
					<?php
				}
				?>
				<a href="javascript:void(0);" onclick="printcompany()" id="print_btn" target="_blank" class="btn btn-warning btn-sm" title="Print"><span class="glyphicon glyphicon glyphicon-print"></span> <?php echo $this->lang->line('print');?></a>
			</div>
		</div>
		
		<?php
		if($started || $stopped) {
			?>
			<div class="helper helper-center"><?php echo ($started) ? $this->lang->line('helperStart') : $this->lang->line('helperStop'); ?></div>
			<?php
		}
		?>
		
		<div class="table-responsive p-1-x m-1-y" style="overflow: hidden;">
			<table id="datatable_companylist" class="table table-bordered table-striped datatables">
					<thead>
							<tr>
									<th class="text-center col-xs-1"><?php echo $this->lang->line('no'); ?></th>
									<th class="text-left"><?php echo $this->lang->line('companyName'); ?></th>
									<?php
									if(!$started && !$stopped) {
										?>
										<th class="text-center col-xs-2"><?php echo $this->lang->line('action'); ?></th>
										<?php
									}
									?>
							</tr>
					</thead>
					<tbody>
							<?php 
							if($companyList){
									$i = 1;
									foreach ($companyList as $row){
							?>
							<tr>
									<td class="text-center col-xs-1"><?php echo $i++; ?></td>
									<td class="text-left">
									<?php if(!$started && !$stopped) { ?>
										<a href="#" onclick="showDetail2(<?php echo $row->companyID; ?>, '<?php echo $row->companyName; ?>')"><?php echo $row->companyName; ?></a>
									<?php }else{ ?>
										<?php echo $row->companyName; ?>
									<?php } ?>
									</td>
									
									<?php if(!$started && !$stopped) { ?>
										<td class="text-center col-xs-2">
											<button type="button" onclick="deleteConfirm(<?php echo $row->companyID; ?>)" class="btn btn-danger btn-sm" title="Delete" <?php if($row->checkcompany == false)echo "disabled"; ?>><span class="glyphicon glyphicon glyphicon-trash"></span> <?php echo $this->lang->line('delete'); ?></button>
											<?php if($row->checkcompany == false) { ?>
												<div class="helper helper-xs">
													<?php echo $this->lang->line('helperDel'); ?>
												</div>
												<?php } ?>
										</td>
									<?php } ?>
							</tr>
							<?php } } ?>
					</tbody>
			</table>
    </div>                   

	</section>
</div>
