<?php

$i=1;
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

  <table  border="0" cellspacing="0" cellpadding="0" class="tableList">
  <tr class="heading">
    <td>No</td>   
    <td>Trip No</td> 
    <td>Trip Date</td>
    <td>Vehicle No</td>
    <td>Driver Name</td>
    <td>Trip Route</td>
    <td>Advance Amount</td> 
    <td>Trip Status</td> 
    <td>Edit</td>
    <td>Delete</td>
  </tr>
  
  <?php

$vechicle_no ='';
$tripdate ='';
$fromdate='';
$todate='';

if(isset($_REQUEST['vechicle_no'])){
$vechicle_no=$_REQUEST['vechicle_no'];
}

if(isset($_REQUEST['tripdate'])){
$tripdate=$_REQUEST['tripdate'];
}

if(isset($_REQUEST['fromdate'])){
$fromdate=$_REQUEST['fromdate'];
}

if(isset($_REQUEST['todate'])){
$todate=$_REQUEST['todate'];
}

$i=1;
$sq_arr="select * from cf_tripsheet where 1 ";
if($vechicle_no!=''){
$sq_arr.=" and trip_vechno = '".$vechicle_no."' ";
}

if($tripdate!=''){
$sq_arr.=" and 	trip_date = '".$tripdate."' ";
}

if($fromdate!="" && $todate!=""){
$sq_arr.=" and trip_addate between '$fromdate' and '$todate'";
}

/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by trip_id desc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
include("../pagingserch.php");
$sq_arr.=" LIMIT $start, $limit";

if(isset($_REQUEST['page'])){
$page=$_REQUEST['page'];
}else{
$page=10;
}

$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
$pagecnt=$start;
while($res=mysql_fetch_array($array))
{
$pagecnt++;
  ?> 
  <tr>
    <td><?php echo $pagecnt;?></td>
    <td><?php echo $res['trip_newsrno'];?></td>
    <td><a href="#login-box" class="login-window"><?php echo $res['trip_date'];?></a></td>
    <td><a href="#login-box" class="login-window" data-id=<?php echo $res['trip_id'];?>><?php echo $res['trip_vechno'];?></a></td>
    <td><?php if($res['trip_driver']!='')echo $res['trip_driver'];else echo '--'; ?></td>
    <?php 
		$triprouteid = $res['trip_route_id'];
    	$sq_route=mysql_query("select * from cf_route where route_id = '$triprouteid'  ");
		$row2 = mysql_fetch_array($sq_route);
		$routename = $row2['route_name'];
	?>	
    
    
    <td><?php if($routename!='')echo $routename;else echo '--'; ?></td>
    <?php 
		$locationid = $res['trip_location'];
		$sq_arr=mysql_query("select * from cf_district where district_id = '$locationid'  ");
		$row = mysql_fetch_array($sq_arr);
    ?>    
   
    <td><?php if($res['advt_amt']!='')echo $res['advt_amt'];else echo '--'; ?></td>
          
     <td class="tr_td_b">
     <?php if($res['trip_status']=='1') {?>
     <a href="add-hirepayment.php?trip_id=<?php echo $res['trip_id']; ?>" style="color:#009999" >Finished </a><?php } else { ?>
     <a href="add-tripsheet.php?page=<?php echo $page; ?>&tripid=<?php echo $res['trip_id']; ?>&ab=<?php echo $i;?>" style="color:#FF9900">Pending </a> <?php } ?>
     </td>    
   <?php 
   //if($res['trip_status']!='1')
   //{
   ?>
   <td class="tr_td_b"><a href="add-tripsheet.php?page=<?php echo $page; ?>&tripid=<?php echo $res['trip_id']; ?>&ab=<?php echo $i;?>"><img src="images/edit.png" title="edit"></a></td>
   <?php /*?><?php } else { ?>
   <td class="tr_td_b"><img src="images/no-edit.png" title="Can't Edit"></td>
   <?php } ?><?php */?>
   
  <?php /*?> <?php 
   if($res['trip_status']!='1')
   {
   ?><?php */?>
   <td class="tr_td_r" ><a href="tripsheet-list.php?del=delete&id=<?php echo $res['trip_id']; ?>" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="Delete"></a></td>
   <?php /*?> <?php } else { ?>
   <td class="tr_td_r" ><img src="images/no-delete.png" title="Can't Delete"></td>
    <?php } ?><?php */?>
  </tr>
  <?php 
    }}
  ?>
 
  <!--<tr>
    <td><input type="checkbox">2</td>
    <td>2323d</td>
    <td>jinesh</td>
    <td>jose</td>
    <td>9443274636</td>
    <td>email@gmail.com</td>
    <td>design</td>
    <td>designer</td>
    <td>23/4/11</td>
    <td><div class="deletedStat"></div></td>
    <td><a href="#">
      <div class="actEdit"></div><div class="actDelete"></div>
    </a></td>
  </tr>-->

   
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>