<?php
$this->load->view('vote/script',$this->templates->getData());
$this->load->view('vote/modal',$this->templates->getData());
$started = isProjectStarted();
$stopped = isProjectStopped();
?>

<div class="content-wrapper">

	<section class="content-header">
			<h1 style="font-family:roboto">
					<b><?php echo $this->lang->line('vote'); ?></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('vote'); ?></a></li>
					<li class="active" style="color:#0C0"><?php echo $this->lang->line('voteList'); ?></li>
			</ol>
	</section>
	
  <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('vote')) ? ucwords(strtolower($l)) : 'Vote'; ?></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(); ?>dashboard" class="btn btn-danger"><i class="fa fa-backward"></i>&nbsp;<?php echo $this->lang->line('back'); ?></a>
				<a href="javascript:void(0);" onclick="printvote()" 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>
				<?php if(!$started){ ?>
					<button type="button" onClick="deleteConfirm(this);" class="btn btn-danger btn-sm delete" title="Delete" disabled><span class="glyphicon glyphicon glyphicon-trash"></span> <?php echo $this->lang->line('delete'); ?></button>
				<?php } ?>
			</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_votelist" class="table table-bordered table-striped datatables">
					<thead>
							<tr>
									<th class="text-center"><?php echo $this->lang->line('no'); ?></th>
									<th class="text-center"><?php echo $this->lang->line('voterID'); ?></th>
									<th class="text-center"><?php echo $this->lang->line('entityName'); ?></th>
									<th class="text-center"><?php echo $this->lang->line('companyName'); ?></th>
									<th class="text-center"></th>
									<?php if(!$started){ ?>
										<th><input onchange="select_or_unselect_all(this)" type="checkbox" /></th>
									<?php } ?>
									<th style="display:none"></th>
							</tr>
					</thead>
					<tbody>
							<?php 
							if($voteList){
									$i = 1;
									foreach ($voteList as $row){
							?>
							<tr>
									<td class="text-center"><?php echo $i++; ?></td>
									<td class="text-center"><?php echo $row['noAhli']; ?></td>
									<td class="text-center"><?php echo $row['name']; ?></td>
									<td class="text-center"><?php echo $row['companyName']; ?></td>
									<td class="text-center">
										<a href="javascript:void(0);" onclick="return viewvote(<?php echo $row['userID']; ?>,this)" class="btn btn-info btn-sm"
											title="View Vote"><span class="glyphicon glyphicon glyphicon-edit"></span> <?php echo $this->lang->line('viewvote'); ?></a>
									</td>
									<?php if(!$started){ ?>
										<td class="text-left">
											<input type="checkbox" name="user_id[]" onChange="enabled_or_disabled_delete_btn(this)" value="<?php echo $row['userID']; ?>" />
										</td>
									<?php } ?>
									<td style="display:none"><?php echo $row['userID']; ?></td>
							</tr>
							<?php 
									}
							}
							?>


					</tbody>
			</table>
		</div>
		
	</section>
</div>