<?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>No of Jar </td>  
  <td>Per Jar Rate</td>    
    <td>Amount</td>    
  <!--<td align="center">Edit</td>-->
    <td align="center">Delete</td>
  </tr>
  
  <?php

 $jar_clientid= '';
 $fromdate='';
 $todate='';

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

if(isset($_REQUEST['vendortype'])){
    $jar_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_jar_purchase where jar_purchase_type = 'jar_sales' ";


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

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

$sq_arr.=" order by jar_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['jar_clientid']; 
        
    if($res['jar_purchase_type'] == 'jar_sales')
    {
      $sq_client=mysql_query("select * from cf_client where client_id = '$clientid'");
        $resclt=mysql_fetch_array($sq_client);
      $client_name = $resclt['client_name'];
    }
    
    ?>  
     <td><?php echo $client_name;?></td>
   <td><?php echo date(('d-m-Y'),strtotime($res['date']));?></td>  
   <td><?php echo "Jar Sales";  ?></td>
   <td><?php echo $res['jar_no'];?></td>  
   <td><?php echo $res['jar_per_rate'];?></td>     
     <td><?php echo $res['jar_amount'];?></td>     
     <?php /*?><td align="center" class="tr_td_b"><a href="add-jar-purchase.php?jar_mainid=<?=$res['jar_id']?>"><img src="images/edit.png" title="edit"></a></td><?php */?>
   
   <td align="center" class="tr_td_r" ><a href="jar_sales_list.php?jar_del=<?=$res['jar_id']?>&qty=<?=$res['jar_no']?>&clientids=<?=$res['jar_clientid']?>&amt=<?=$res['jar_amount']?>&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><?=$totjar_no?></td>     
     <td>&nbsp;</td>     
    
     <td><?=$totjar_amount?></td>
     <td></td>
   </tr>
</table>

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