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


 $clientid= '';
 $fromdate='';
 $todate='';

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

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

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

$i=1;
$sq_arr="select * from cf_tin_purchase where tin_purchase_type = 'tin_sales' ";



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

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


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

 $tottin_no ='';
 $tottin_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['tin_clientid']; 
        
    if($res['tin_purchase_type'] == 'tin_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 "Tin Sales";  ?></td>
   <td><?php echo $res['tin_no'];?></td>  
   <td><?php echo $res['tin_per_rate'];?></td>     
     <td><?php echo $res['tin_amount'];?></td>     
     <?php /*?><td align="center" class="tr_td_b"><a href="add-tin-purchase.php?tin_mainid=<?=$res['tin_id']?>"><img src="images/edit.png" title="edit"></a></td><?php */?>
   
   <?php /*?><td align="center" class="tr_td_r" ><a href="tin_sales_list.php?tin_del=<?=$res['tin_id']?>&qty=<?=$res['tin_no']?>&del=delete" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td><?php */?>
  </tr>
  <?php 
  $tottin_no += $res['tin_no'];//
  $tottin_amount += $res['tin_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><?=$tottin_no?></td> 
     <td></td>    
     <td><?=$tottin_amount?></td>    
    
     <td></td>
   </tr>
</table>

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