<?php
$this->load->view('position/script',$this->templates->getData());
$this->load->view('position/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('designation'); ?></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('designation'); ?></a></li>
					<li class="active" style="color:#0C0"><?php echo $this->lang->line('designationList'); ?></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('designation')) ? ucwords(strtolower($l)) : ucfirst($this->lang->line('position')); ?></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>
				<?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="printposition()" 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_positionlist" 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 col-xs-6"><?php echo $this->lang->line('designationName'); ?></th>
									<th class="text-center col-xs-2"><?php echo $this->lang->line('noOfCandidate'); ?></th>
									<th class="text-center col-xs-2"><?php echo $this->lang->line('designationRank'); ?></th>
									<th class="text-center col-xs-1"></th>
							</tr>
					</thead>
					<tbody>
							<?php 
							if($positionList){
									$i = 1;
									foreach ($positionList as $row){
							?>
							<tr>
									<td class="text-center"><?php echo $i++; ?></td>
									<td class="text-left">
									<?php if($started || $stopped) { ?>
										<?php echo $row->positionName; ?>
									<?php } else { ?>
										<a href="javascript:void(0);" onclick="showDetail2(<?php echo $row->positionID; ?>, '<?php echo $row->positionName; ?>', <?php echo $row->elected; ?>, <?php echo $row->ordering; ?>)">
											<?php echo $row->positionName; ?>
										</a>
									<?php } ?>
									</td>
									<td class="text-center"><?php echo $row->elected; ?></td>
									<td class="text-center"><?php echo $row->ordering; ?></td>
									<td class="text-center">
									<!--<button type="button" onclick="showDetail(<?php //echo $row->fldid; ?>, '<?php //echo $row->email; ?>', '<?php //if(date("Y-m-d") < $row->nextExpiracy){echo date("d-m-Y", strtotime($row->nextExpiracy . "+1 days"));}else{echo date("d-m-Y");} ?>')" class="btn btn-primary btn-sm" title="Renewal"><span class="glyphicon glyphicon glyphicon-edit"></span></button>-->
									<button type="button" onclick="deleteConfirm(<?php echo $row->positionID; ?>)" class="btn btn-danger btn-sm" title="Delete" <?php if($row->checkStatus == 0){ echo "disabled"; }?>><span class="glyphicon glyphicon glyphicon-trash"></span> <?php echo $this->lang->line('delete'); ?></button>
									</td>
							</tr>
							<?php 
									}
							}
							?>


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