<?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>Date</td>
	<td>Reference No</td>
    <td>Amount</td>
	<td>Purpose</td>
	<td>Delete</td>
  </tr>
<?php

$ledger_name ='';
$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 *,(select sum(amount) from cf_journal as b where b.journal_reference=a.journal_reference and debit=0) as sum_amount
    FROM cf_journal as a where 1";
	


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

/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" group by journal_reference order by journal_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 date('d-m-Y',strtotime($res['pay_date']));?></td>
	<td><?php echo $res['ref_no'];?></td>
    <td><?php echo $res['sum_amount'];?></td>
	
	 <td><a href="#login-box" class="login-window" style="font-weight:bold;" data-type='id'><?php echo $res['purpose'];?><input type="hidden" name="journalid" id="journalid<?php echo $res['journal_reference'];?>" value="<?php echo $res['journal_reference'];?>" /></a></td>
   <td class="tr_td_r" ><a href="journal-list.php?del=delete&id=<?php echo $res['journal_reference']; ?>" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></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>