<?php
$page=1;
$txt='';
$sdate='';
$singdate='';
$frmdate11='';
$todate_11='';
$sdate_12='';
$frmdate1='';
$todate_1='';
$todate_12='';
$from='';
$to='';
$sdate='';
$page=1;
$source='';
$destination='';
/*
if(isset($_REQUEST['frmdate1'])){
$frmdate11=$_REQUEST['frmdate1'];
$frmdate1=explode("-",$frmdate11);
$from=$frmdate1[2].'-'.$frmdate1[1].'-'.$frmdate1[0];
}
if(isset($_REQUEST['todate_1'])){
$todate_11=$_REQUEST['todate_1'];
$todate_1=explode("-",$todate_11);
$to  =$todate_1[2].'-'.$todate_1[1].'-'.$todate_1[0];
}
if(isset($_REQUEST['todate_12'])){
$sdate_12=$_REQUEST['todate_12'];
$todate_12=explode("-",$sdate_12);
$sdate=$todate_12[2].'-'.$todate_12[1].'-'.$todate_12[0];
}
*/
include("../include/config.php");
require_once "../include/Database_functions.php";
?>
<table width="88%" border="0" cellspacing="0" cellpadding="0">
   
   
    <tr>
	  <th width="15%" align="center" valign="middle">Ref No</th>  
      <th width="30%" align="center" valign="middle">STARTING POINT </th>
      <th width="27%" align="center" valign="middle"> END DESTINATION</th>
	  <th width="16%" align="center" valign="middle">Delivery Cost</th>
	  <th width="16%" align="center" valign="middle">Driver Cost</th>
	  <th width="16%" align="center" valign="middle">Cleaner Cost</th>
      <th width="12%" align="center" valign="middle">OPTION</th>
    </tr>
<?php
$sum_sql='';
$adjacents = 3;
if(isset($_REQUEST['singdate'])){
$singdate=$_REQUEST['singdate'];
$todate_12=explode("-",$singdate);
$sdate=$todate_12[2].'-'.$todate_12[1].'-'.$todate_12[0];
}
if(isset($_REQUEST['txtfrom'])){
$source=$_REQUEST['txtfrom'];
}

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

$i=1;
$sq_arr="select * from tbl_deliveryarea where 1 ";

if(($source!='') &&($destination!='')){
$sq_arr.=" and (from_location='".$source."' and to_location ='".$destination."') ";
}

/*if(($source=='') &&($destination=='')){
$sq_arr.=" ";
}*/

/*if($destination!=''){
$sq_arr.=" and (container_num='".$txt."' or name like '%".$txt."%') ";
}*/

$sq_arr.=" order by delivery_id desc ";

$query=$sq_arr;
$function="getcontainerdet";
/*$i=1;
$sq_arr="select * from tbl_container where 1";
$sq_arr.=" order by id desc ";
$query=$sq_arr;
$function="getcontainerdet";*/


include("../paging.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){
		while($deliveryres=mysql_fetch_array($array))
		 {
?>
   <tr>
      <td class="tr_td" align="center"><?php echo $deliveryres['ref_no']; ?></td>
      <td class="tr_td" align="center"><?php echo $deliveryres['from_location']; ?></td>
      <td class="tr_td" align="center"><?php echo $deliveryres['to_location']; ?></td>
      <td align="center" class="tr_td tr_td_r"><?php echo $deliveryres['delivery_cost']; ?></td>
	  <td align="center" class="tr_td tr_td_r"><?php echo $deliveryres['driver_cost']; ?></td>
	  <td align="center" class="tr_td tr_td_r"><?php echo $deliveryres['cleaner_cost']; ?></td>
      <td class="tr_td tr_td_r" align="center"><img src="images/icon2.jpg" width="18" height="18" onclick="javascript:location.href='add-deliveryarea.php?tid=<?php echo $deliveryres['delivery_id']; ?>'"/> <a href="javascript:if(confirm('Do you want to delete this record?')){location.href='view_delivery.php?page=<?=$page?>&del_id=<?php echo $deliveryres['delivery_id']; ?>'}">
	   <img src="images/icon1.jpg" width="21" height="21" /></a></td>
  </tr>
<?php
}
}
else{?>
 <tr>
      <td class="tr_td tr_td_r" colspan="6">No Results Found!!	  </td></tr>
<? }
?>
</table>
  <div align="right" style="padding-top:10px;"><?=$pagination?></div>