<?php
$this->load->view('candidate/script',$this->templates->getData());
$this->load->view('candidate/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('candidate'); ?></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('candidate'); ?></a></li>
					<li class="active" style="color:#0C0"><?php echo $this->lang->line('candidateList'); ?></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('candidate')) ? ucwords(strtolower($l)) : $this->lang->line('candidate'); ?></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="addCandidate(this)"><i class="fa fa-plus fa-fw"></i> <?php echo $this->lang->line('addNew');?></button>
				<?php } ?>
				<a href="javascript:void(0);" onclick="printcandidate()" 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-2-t" style="overflow:hidden;">
			<table id="datatable_candidateList" 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('candidateName'); ?></th>
									<th class="text-center"><?php echo $this->lang->line('designation'); ?></th>
									<th class="text-center"><?php echo $this->lang->line('companyName'); ?></th>
									<th class="text-center"><?php echo $this->lang->line('picture'); ?></th>
									<th></th>
							</tr>
					</thead>
					<tbody>
							<?php 
							$abso = str_replace("\\","/", FCPATH);
							$virt = str_replace("\\","/", base_url());
							if($candidateList){
									$i = 1;
									foreach ($candidateList as $row){
							?>
							<tr class="item">
									<td class="text-center">
										<?php echo $i++; ?>
										<input type="hidden" class="item_candidateID" value="<?php echo $row->candidateID; ?>" />
										<input type="hidden" class="item_candidateName" value="<?php echo $row->candidateName; ?>" />
										<input type="hidden" class="item_positionID" value="<?php echo $row->positionID; ?>" />
										<input type="hidden" class="item_companyID" value="<?php echo $row->companyID; ?>" />
										<input type="hidden" class="item_candidate_picture" value="<?php echo $row->candidate_picture; ?>" />
									</td>
									<td class="text-center">
										<?php if($started || $stopped) { ?>
											<?php echo $row->candidateName; ?>
										<?php } else { ?>
											<a href="javascript:void(0);" onclick="showDetail(this)"><?php echo $row->candidateName; ?></a>
										<?php } ?>
									</td>
									<td class="text-center"><?php echo $row->positionName; ?></td>
									<td class="text-center"><?php echo $row->companyName; ?></td>
									<td class="text-center">
										<?php							
										$image = $virt."dist/img/_sys/user.png";
										if($row->candidate_picture && file_exists($abso."img/candidate/".$row->candidate_picture)) {
											$image = $virt."img/candidate/".$row->candidate_picture;
										}
										?>
										<img src="<?php echo $image; ?>" width="50px"/>
									</td>
									<td class="text-center">
										<button type="button" onclick="deleteConfirm(<?php echo $row->candidateID; ?>)" class="btn btn-danger btn-sm" title="Delete" <?php if($started){ echo "disabled"; }?>><span class="glyphicon glyphicon glyphicon-trash"></span> <?php echo $this->lang->line('delete'); ?></button>
									</td>
							</tr>
							<?php 
									}
							}
							?>


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