<?php
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

  <table  border="0" cellspacing="0" cellpadding="0" class="tableList"  style="margin-left:20px; ">
<tr class="heading">
    <td width="20">No</td>    
    <td width="150">Package Code</td>
	<td>Quantity</td>
    <td>Box</td>    
    <td>Date</td>    
    <td align="center">Delete</td>
  </tr>
<?php

$saletype ='';
$fromdate='';
$todate='';

if(isset($_REQUEST['fromdate'])){
$fromdate=$_REQUEST['fromdate'];
$fromdate1 = date('Y-m-d', strtotime($fromdate));
}

if(isset($_REQUEST['todate'])){
$todate=$_REQUEST['todate'];
$todate1 = date('Y-m-d', strtotime($todate));
}
$i=1;
$sq_arr="select * from cf_package where 1  ";

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


/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by package_id desc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
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){
$pagecnt=$start;
while($res=mysql_fetch_array($array))
{
//------------get the clientname-----------------------//
$pagecnt++;

  ?> 
<tr>
    <td><?php echo $pagecnt;?></td>
    <td><a href="#login-box" class="login-window" data-id=<?php echo $res['package_id'];?> data-chk=<?php echo $res['package_code'];?> style="color:#AA2D58">PK-<?php echo $res['package_code'];?></a></td>
    <td><?php echo $res['package_qty'];?></td>    
	 <?php 
		$packageid = $res['package_id'];	
        $sq_pack=mysql_query("select sum(pack_box) as pack_box from cf_package_sub where pack_id = '$packageid'");
    	$respack=mysql_fetch_array($sq_pack);
    ?>	
	 
    <td><?php echo $respack['pack_box'];?></td>     
    <td><?php echo date(('d-m-Y'),strtotime($res['package_date']));?></td>     
    <td align="center" class="tr_td_r" ><a href="package-list.php?pur_del=<?=$res['package_id']?>&del=delete" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
  </tr>
  <?php 
    }}else{?>
	 <tr>
    <td class="errorMessage"  style="border-right:0px;border-bottom:0px; "><font color="#FF0000">No Records Found</font></td></tr>
	<? }
  ?>
 
  
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>