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

   <table  border="0" cellspacing="0" cellpadding="0" class="tableList">
  <tr class="heading">
    <td>No</td>    
    <td>Ledger Name</td>    
    <td>Amount</td>
	<td>Date</td>
	<td>Purpose</td>
    <td>Transaction Type</td>
    <td>Edit</td>
	<td>Delete</td>
  </tr>
<?php

$ledger_name ='';
$fromdate='';
$todate='';


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

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 a.*,b.ledgername as ledgername
    FROM cf_reciept a
        LEFT JOIN cf_ledger b
            ON b.ledgerid = a.from where 1";
if($ledger_name!=''){
$sq_arr.=" and   b.ledgername like '%".$ledger_name."%'";
}



if(isset($fromdate) && $fromdate!=''){
$from_date=date('Y-m-d',strtotime($fromdate));
$sq_arr.=" and   a.pay_date >= '$from_date'";
}
if(isset($todate) && $todate!=''){
$to_date=date('Y-m-d',strtotime($todate));
$sq_arr.=" and   a.pay_date <= '$to_date'";
}

/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by a.reciept_id asc ";
$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))
{

$pagecnt++;


  ?> 
  <tr>
    <td><?php echo $pagecnt;?></td>
    <td><?php echo $res['ledgername'];?></td>
    <td><?php echo $res['amount'];?></td>
     <td><?php echo date('d-m-Y',strtotime($res['pay_date']));?></td>
	 <td><?php echo $res['purpose'];?></td>
	 <td><?php if($res['cashed']==1)
	 echo "Cash";
	 elseif($res['cashed']==2)
	 echo "Bank";
	 ?></td>
   
   	<td class="tr_td_b"> <a href="reciept-form.php?edit=update&id=<?php echo $res['reciept_id']; ?>" ><img src="images/edit.png" title="edit"></a></td>
   
    <td class="tr_td_r" ><a href="reciept-list.php?del=delete&id=<?php echo $res['reciept_id']; ?>" onClick="return confirm('Do you really want to delete this field?');">
	<?php if($res['pay_date'] >= '2014-11-25'){?>  <img src="images/delete.png" title="delete">  <?php }?>
	</a></td>
    
   
  </tr>
  <?php 
    }}
  ?>
 
  <!--<tr>
    <td><input type="checkbox">2</td>
    <td>2323d</td>
    <td>jinesh</td>
    <td>jose</td>
    <td>9443274636</td>
    <td>email@gmail.com</td>
    <td>design</td>
    <td>designer</td>
    <td>23/4/11</td>
    <td><div class="deletedStat"></div></td>
    <td><a href="#">
      <div class="actEdit"></div><div class="actDelete"></div>
    </a></td>
  </tr>-->

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