<?php $this->load->view('header_frontinner'); 
 $this->load->view('security_front'); 
foreach($footer_data1 as $val_profile)
{
$can_image=$val_profile->image;
}

$can_id=$this->session->userdata('user_id');
$tbl_name="njobn_jobdetails";	
$adjacents = 10;
$date_get_from=$this->input->post('fromdate');
$datearray_from=explode("-", $date_get_from);
$month=$datearray_from[0];
$day=$datearray_from[1];
$year=$datearray_from[2];
$date_from=$year."/".$month."/".$day;
//todate
$date_get_to=$this->input->post('todate');
$datearray_to=explode("-", $date_get_to);
$monthto=$datearray_to[0];
$dayto=$datearray_to[1];
$yearto=$datearray_to[2];
$date_to=$yearto."/".$monthto."/".$dayto;
if($this->input->post('job_title')!='' && $this->input->post('search_filter')!='')
{
$criteria=$this->input->post('job_title');
/*$seect_jobs=mysql_query("select * from njobn_jobdetails where `job_title` LIKE '%$criteria%'");
$fethc_jobs=mysql_fetch_array($seect_jobs);
$job_id=$fethc_jobs['job_id'];*/
$query = mysql_query("SELECT  * FROM $tbl_name where created_by='".$can_id."' AND `job_title` LIKE '%$criteria%'");
}
else if($this->input->post('fromdate')!='' && $this->input->post('todate')!='' && $this->input->post('search_filter')!='')
{
$query = mysql_query("SELECT  * FROM $tbl_name where created_by='".$can_id."' AND date BETWEEN '".$date_from."' AND '".$date_to."'");
}
else
{
$query = mysql_query("SELECT  * FROM $tbl_name where created_by='".$can_id."'");
}
$total_pages = mysql_num_rows($query);
$targetpage = "recruiters"; 	//your file name  (the name of this file)
$limit = 30; 
if(isset($_GET['page'])!='')
{								//how many items to show per page
$page = $_GET['page'];
}
else
{
$page = 0;
}
if($page) 
{
$start = ($page - 1) * $limit; 			//first item to display on this page
}
else
{
$start = 0;								//if no page var is given, set start to 0
}
if($this->input->post('job_title')!='' && $this->input->post('search_filter')!='')
{
$criteria=$this->input->post('job_title');
/*$seect_jobs=mysql_query("select * from njobn_jobdetails where `job_title` LIKE '%$criteria%'");
$fethc_jobs=mysql_fetch_array($seect_jobs);
$job_id=$fethc_jobs['job_id'];*/
$sql = "SELECT * FROM $tbl_name where created_by='".$can_id."' AND `job_title` LIKE '%$criteria%' LIMIT $start, $limit";
}
else if($this->input->post('fromdate')!='' && $this->input->post('todate')!='' && $this->input->post('search_filter')!='')
{
$sql = "SELECT * FROM $tbl_name where created_by='".$can_id."' AND date BETWEEN '".$date_from."' AND '".$date_to."' LIMIT $start, $limit";
}
else
{
$sql = "SELECT * FROM $tbl_name where created_by='".$can_id."' LIMIT $start, $limit";
}

$result = mysql_query($sql);
if ($page == 0) $page = 1;					//if no page var is given, default to 1.
$prev = $page - 1;							//previous page is page - 1
$next = $page + 1;							//next page is page + 1
$lastpage = ceil($total_pages/$limit);		//lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1;						//last page minus 1
$pagination = "";
if($lastpage > 1)
{	
$pagination .= "<div class=\"pagination\">";
if ($page > 1) 
$pagination.= "<ul>
                    	<li><a href=\"$targetpage?page=$prev\"> Previous</a></li>";
else
$pagination.= "<li><a href=\"$targetpage?page=$prev\">Previous</a></li>";	
if ($lastpage < 7 + ($adjacents * 2))	//not enough pages to bother breaking it up
{	
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";
else
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";					
}
}
elseif($lastpage > 5 + ($adjacents * 2))	//enough pages to hide some
{
if($page < 1 + ($adjacents * 2))		
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";
else
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";					
}
$pagination.= "<li><a href=\"$targetpage?page=$lpm1\">$lpm1</a><li>";
$pagination.= "<li><a href=\"$targetpage?page=$lastpage\">$lastpage</a></li>";		
}
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<li><a href=\"$targetpage?page=1\">1</a></li>";
$pagination.= "<li><a href=\"$targetpage?page=2\">2</a></li>";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</li></a>";
else
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";					
}
$pagination.= "<li><a href=\"$targetpage?page=$lpm1\">$lpm1</a>";
$pagination.= "<li><a href=\"$targetpage?page=$lastpage\">$lastpage</a></li>";		
}
else
{
$pagination.= "<li><a href=\"$targetpage?page=1\">1</a></li>";
$pagination.= "<li><a href=\"$targetpage?page=2\">2</a></li>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";
else
$pagination.= "<li><a href=\"$targetpage?page=$counter\">$counter</a></li>";					
}
}
}
if ($page < $counter - 1) 
$pagination.= "<li><a href=\"$targetpage?page=$next\">Next</a></li>";
else
$pagination.= "<li><a href=\"$targetpage?page=$next\">Next</a></li>";
$pagination.= "</ul></div>\n";		
}
$number_wew=mysql_num_rows($result);
?>

<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>assets/css/tcal.css" />
<script type="text/javascript" src="<?php echo base_url();?>assets/js/tcal.js"></script>
  <div class="reports-section margin-top-30">
  <div class="section-welcome">
            	<div class="container">
				 <div class="nav-welcome">
                 <ol class="breadcrumb">
                      <li><a href="<?php echo base_url();?>front_end/employee_dashboard">Dashboard</a></li>
                      <li><a href="<?php echo base_url();?>front_end/recruiters">Recruiters</a></li>
                    </ol>
                    <a class="menubtn" href="#"><i class="fa fa-bars"></i></a>
                </div>
                	<div class="activity-reports-section recruiters" style="margin-bottom:8px;">
                    	<h3>Job Posts</h3>
                        <span>
                            <input type="button" value="Add Job Post"  onclick="window.location='<?php echo base_url();?>front_end/addjob';">
                        </span>
                    </div>
                    <div class="row">
					 <form id="demo-form2" data-parsley-validate class="form-horizontal form-label-left" action="<?php echo base_url();?>front_end/recruiters" method="post" name="loginform"   enctype="multipart/form-data">
                        	<ul class="recruiters-section margin-top-30">
                            	<li class="col-sm-3" id="postfields">
                                	<label>Filter By:</label>
                                    <input placeholder="e.g.jop title(web Developer)" name="job_title" id="job_titlerec" type="text">
                                </li>
                                <!--<li class="col-sm-2">
                                	<label>Show me</label>
                                    <select>
                                    	<option>Live jobs</option>
                                        <option>Live jobs</option>
                                        <option>Live jobs</option>
                                    </select>
                                </li>-->
                                <li class="col-sm-3" id="postfields">
                                	<label>Posted Between:</label>
                                    <input placeholder="mm-dd-yyyy" name="fromdate" class="tcal" id="fromdate" type="text" style="border-radius:none;">
                                     
                                </li>
                                <li class="col-sm-3 filds" id="postfields">
                                
                                   <input placeholder="mm-dd-yyyy" name="todate" class="tcal" id="todate"  type="text" style="border-radius:none;margin-top:4px;">
                                </li>
                                <!--<li class="col-sm-2">
                                	<label>Posted By:</label>
                                     <select>
                                    	<option>All Users</option>
                                        <option>All Users</option>
                                        <option>All Users</option>
                                    </select>
                                </li>-->
                                 <li class="col-sm-3 fild">
                                    <input type="submit" value="Filter Job Posts" name="search_filter" id="search_filter" class="filds_button">
                                    <!--<input class="rights" type="reset" value="Reset Filters">-->
                                </li>
                            </ul>
							</form>
                        </div>
                        <!--<div class="col-sm-12 boder-buttem-section">
                        </div>-->
                        <div class="reports-contan">
                           
                           <!--<ul class="summary-section recruiters-bg margin-top-15">
                           
                            	<li><h4>Posted job ads<span>19</span></h4></li>
                                <li><h5>Standerd<span>19</span></h5></li>
                                <li><h5>Featured<span>0</span></h5></li>
                                <li><h5>Premium<span>0</span></h5></li>
                                <li><h4>views<span>4612</span></h4></li>
                                <li><h4>Application<span>444</span></h4></li>
                           </ul>-->
                          <div class="cvdownloads-section margin-top-30">
					<p style="color:#FF0000;"> <?php echo $this->session->flashdata('mesagejobpost');?></p> 
                            <!--<h5>Bulk actions</h5>
                            <div class="right-dropdon recruiter-cont">
                                <label>SHighlight jobs available to:</label>
                                <select>
                                    <option>25</option>
                                    <option>22</option>
                                    <option>20</option>
                                    <option>19</option>
                                </select>
                            </div>-->
                        
            
                        <div class="tab-recruiter margin-top-45 mobile-space">
                            <table width="100%" class="table">
                                  <thead>
                                    <tr>
                                      <th>Job Title</th>
                                      <th>Job Information</th>
                                      <th>Posted Date</th>
                                      <th>Expiry Date</th>
                                      <th>Views</th>
                                      <th>Applications</th>
                                      <th>Actions</th>
                                     
                                      
                                      
                                    </tr>
                                  </thead>
                                  <tbody>
								  	 <?php
if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_array($result))
{	

/*$sle_jobs=mysql_query("select * from njobn_jobdetails where job_id='".$row['job_id']."'");
$fetch_jobs_data=mysql_fetch_array($sle_jobs);	*/
	?>
                                    <tr>
                                      <td>
                                      	 <a style="color:#cd0329" href="<?php echo base_url();?>front_end/viewjobreport?id=<?php echo $row['job_id'];?>"><?php echo $row['job_title'];?></a></br>
                                         <span><?php
	$sel_countries=mysql_query("select * from countries where id='".$row['job_location_id']."'");
	$fethch_counries=mysql_fetch_array($sel_countries);
	echo $fethch_counries['name']
	?></span>
                                      </td>
                                      <td><?php echo $row['telephone'];?><br> <?php echo $row['job_contact_email'];?></td>
                                      <td>
									  <?php  $post_date=date('F d Y',strtotime($row['date'])); 
											echo $post_date;
									  ?>
									  </td>
                                      <td><?php  $exp_date=date('F d Y',strtotime($row['exp_date'])); 
											echo $exp_date;
									  ?></td>
                                      <td>
									  
									  <?php
									  //echo "select * from jobview_counters where job_id='".$row['job_id']."'";
									  $sel_jobviews_count=mysql_query("select * from jobview_counters where job_id='".$row['job_id']."'");
									  $number_jobviewcouners=mysql_num_rows($sel_jobviews_count);
									  echo $number_jobviewcouners;
									  ?></td>
                                      <td>
									  <a style="color: #ce0229;" href="<?php echo base_url();?>front_end/viewapplication?job_id=<?php echo $row['job_id'];?>">	
									  <?php
									  $sel_apllicatons_count=mysql_query("select * from candidate_listjobs where job_id='".$row['job_id']."'");
									  $number_applciations=mysql_num_rows($sel_apllicatons_count);
									  echo $number_applciations;
									  ?>
									  </a></td>
                                      <td>
                                      	<ol class="breadcrumb">
                                         <li><a href="<?php echo base_url();?>front_end/editjob?id=<?php echo $row['job_id'];?>">Edit</a></li>
									     <li><a href="<?php echo base_url();?>front_end/delete_jobpost?id=<?php echo $row['job_id'];?>" class="link" onclick="return confirm('Are you sure?');">Delete</a></li>
                                           <!-- <li><a href="#">Copy</a></li>
                                            <li><a class="repost" href="#">Repost</a></li>
                                            <li><a href="#">Expire</a></li>-->
                                        </ol>
                                      </td>
                                    </tr>     
									  <?php }
	 }
	 else
	 {?>
	 <tr>
	  <td style="font-size:11px; font-family:Segoe UI;width: 23%;">
	  <h3 style="color:#aeaeae;    font-size: 18px;">No jobs found.</h3></td>
	  <td></td>
	  <td></td>
	<td></td>
		   </tr>
	 <?php }
	 ?>
                                  </tbody>
                            </table>
                          
                        </div>
                        <div class="pagenations">
						<?=$pagination?>
                            <!--<ul class="pagination">
                                <li><a href="#"><i class="fa fa-angle-left" aria-hidden="true"></i></a></li>
                                <li class="active"><a href="#">1</a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li><a href="#">6</a></li>
                                <li><a href="#">7</a></li>
                                <li><a href="#">8</a></li>
                                <li><a href="#"><i class="fa fa-angle-right" aria-hidden="true"></i></a></li>
                            </ul>-->
                        </div>
                     </div> 
                  </div>
              </div>
			  </div>
           </div>
            </div></br>
<?php $this->load->view('footer_front'); ?>