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

<div id="list">
   <table  border="0" cellspacing="0" cellpadding="0" class="tableList"  style="margin-left:20px; ">
  <tr class="heading">
    <td>No</td>    
    <td>Client Name</td>
	<td>Date</td>
	<td>Type</td>
	<td>Liter</td>
	<td>No of Box </td>  
	<td>Per Box Rate</td>    
    <td>Amount</td>    
	<!--<td align="center">Edit</td>-->
    <td align="center">Delete</td>
  </tr>
  
  <?php

$master = '';
$notification = '';
$trip = '';
$accounting = '';
$accpay = '';
$report = '';

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

  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_sales_box where sales_box_type = 'box_sales' ";


if($sale_clientid!=""){
$sq_arr.=" and sales_box_clientid = '$sale_clientid' ";
}

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

$sq_arr.=" order by sales_box_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=1;
}

 $totjar_no ='';
 $totjar_amount ='';


$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>
       
    <?php 
	    $vendor_name='';
		$client_name='';
		$clientid = $res['sales_box_clientid'];	
        
		if($res['sales_box_type'] == 'box_sales')
		{
			$sq_client=mysql_query("select * from cf_client where client_id = '$clientid'");
    		$resclt=mysql_fetch_array($sq_client);
			$client_name = $resclt['client_name'];
		}
		
	if($res['sales_box_ltr'] == 1)
		{
			$ltr = '1 Lt';
		}
		else
		{
			$ltr = '1/2 Lt';
		}	
		
    ?>	
     <td><?php echo $client_name;?></td>
	 <td><?php echo date(('d-m-Y'),strtotime($res['sales_box_date']));?></td>  
	 <td><?php echo "Box Sales";  ?></td>
	 <td><?php echo $ltr;?></td>
	 <td><?php echo $res['sales_box_no'];?></td>  
	 <td><?php echo $res['sales_box_perate'];?></td>     
     <td><?php echo $res['sales_box_tot'];?></td>     
     <?php /*?><td align="center" class="tr_td_b"><a href="add-box-purchase.php?box_mainid=<?=$res['box_id']?>"><img src="images/edit.png" title="edit"></a></td><?php */?>
   
   <td align="center" class="tr_td_r" ><a href="box_sales_list.php?box_del=<?=$res['sales_box_id']?>&amount=<?=$res['sales_box_tot']?>&qty=<?=$res['sales_box_no']?>&clientids=<?=$res['clientid']?>&ltr=<?=$res['sales_box_ltr']?>&del=delete" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
  </tr>
  <?php 
 // $totjar_no += $res['jar_no'];
 // $totjar_amount += $res['jar_amount'];
 
    }}else{?>
   <tr>
    <td class="errorMessage"  style="border-right:0px;border-bottom:0px; "><font color="#FF0000">No Records Found</font></td></tr>
  <? }
  ?>
  
  <tr class="heading">
     <td>Total</td>
   <td></td>
   <td></td>
   <td></td>
     <td><?php //$totjar_no?></td>     
     <td>&nbsp;</td>     
    
     <td><?php  //$totjar_amount?></td>
     <td></td>
   </tr>
</table>

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