<link rel="stylesheet" href="css/new_mxerp.css">
<style type="text/css">
#amc-tab{}
  #amc-tab table{border:none; border-collapse:collapse; }
  #amc-tab table tr td{border-right:#808080 1px solid; border-bottom:#808080 1px solid;}
  #amc-tab table tr td:last-child{border-right:none;}
  #amc-tab table tr:last-child td{border-bottom:none;}
  #amc-tab table tr td > table tr td{border-right:#808080 1px solid; border-bottom:#808080 1px solid;}
  #amc-tab table tr td > table tr td:last-child{border-right:none;}
  #amc-tab table tr td > table tr:last-child td{border-bottom:none;}
</style>
<div class="body_contain">
<div class="tab_div">
<h1>Fund Summary</h1>
<form action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr class="row1">
<td width="13%" style="text-align:right;">
   <strong>Branch</strong></td>
<td width="32%">
<select name="site" style="width:98%;">
<option value="">All</option>
<?php 
$site_query=$s->GetRecordById('locations','1=1');
while($srow=DB_fetch_array($site_query))
{?>
	<option value="<?php echo $srow['loccode'];?>" <?php if($_REQUEST['site']==$srow['loccode']) { ?> selected="selected" <?php } ?> ><?php echo $srow['locationname'];?></option>
<?php 	
}
?>
</select>
</td>
  <td width="13%" style="text-align:right;">
   <strong>Type</strong></td>
<td>
<select name="type" style="width:98%;">
   <option value="0">All</option>
     <option value="Receipt" <?php if($_REQUEST['type']=='Receipt') { ?> selected="selected" <?php }?> >Receipt</option>
     <option value="Payment" <?php if($_REQUEST['type']=='Payment') { ?> selected="selected" <?php }?>>Payment</option>
</select>
</td>
</tr>
<tr class="row1">
<td style="text-align:right;"><strong>From Date</strong></td>
<td><input name="from" type="text" class="datepicker" style="width:98%;" value="<?php echo $_REQUEST['from'];?>" /></td>
<td style="text-align:right;"><strong>To Date</strong></td>
<td><input name="to" type="text" class="datepicker" style="width:98%;" value="<?php echo $_REQUEST['to']; ?>" /></td>
</tr>
<tr class="row1">
	<td colspan="6" style="text-align:center;"><input type="submit" name="submit" value="View" class="search" /></td>
</tr>

</table>
</form>
<?php 
$filter=array();
      
    if(isset($_REQUEST['submit']))
    { 
       $from_date1=explode("/",$_REQUEST['from']);
       $from_date=$from_date1[2]."-".$from_date1[1]."-".$from_date1[0];

       $to_date1=explode("/",$_REQUEST['to']);
       $to_date=$to_date1[2]."-".$to_date1[1]."-".$to_date1[0];

     if($_REQUEST['from']!='' && $_REQUEST['to']!='')  
        $filter[]="created_date between '".$from_date."' and '".$to_date."' ";
     
       if($_REQUEST['site']!='') 
      $filter[]="branch='".$_REQUEST['site']."'";

    if($_REQUEST['type']!='0') 
      $filter[]="type='".$_REQUEST['type']."'";
    } 
      
    if(!empty($filter))
      $filter1=implode(" and ",$filter);
 
    if(!empty($filter))
    {
      $sql="SELECT * from account_fund_receipt where $filter1 order by id";
    }
    else
    {
      $sql="SELECT * from account_fund_receipt order by id";
    }
    

?>
<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border: solid 1px #808080; border-collapse:collapse;">
  <tr>
    <th width="3%">S.No.</th>
    <th>Branch</th>
    <th width="10%">Voucher No.</th>
    <th width="7%">Voucher Date</th>
    <th width="7%">Bank</th>
    <th width="10%">Funding By</th>
    <th width="10%">Funding Amount</th>
    <th width="10%">Revenue Head</th>
    <th width="10%">Transaction Type</th>
    <th width="100">Category Code</th>
  </tr>
 <?php 
	   
	   $result=DB_query($sql,$db);
	   $i=1;
	   while($rs=DB_fetch_array($result))
	   {
	   	  $sql_dtls="select * from account_fund_receipt_dtls where fund_receipt_dtls_id='".$rs['id']."'";
	   	  $result_dtls=DB_query($sql_dtls,$db);

      ?>
  <tr bgcolor="#FFFFFF">
    <td><?php echo $i; ?></td>
    <td><?php echo $s->getField('locations','loccode',$rs['branch'],'locationname') ;  ?></td>
    <td><?php echo $rs['voucher_no']; ?></td>
    <td><?php echo date('d/m/Y',strtotime($rs['voucher_date'])); ?></td>
    <td><?php  $ledger_id1=$s->getField('account_book','trans_type_id',$rs['id'],'id');

               $sql_ledger="select ledgerid from account_book_details where account_bookid='".$ledger_id1."' and amount_type='DR' ";
               $result_ledger=DB_query($sql_ledger,$db);
               $rs_ledger=DB_fetch_array($result_ledger);
               $ledger_id=$rs_ledger['ledgerid'];
              
              echo $s->getField('accountledger','AccountsID',$ledger_id,'AccountName');

       ?></td>
    <td><?php echo $s->getField('clientmaster','id',$rs['funding_by'],'c_name')  ?></td>
    <td><?php echo $rs['funding_amount'];  ?></td>
    <td><?php echo $s->getField('accountledger','AccountsID',$rs['revenue_head'],'AccountName') ?></td>
    <td><?php echo $rs['type'];  ?></td>
     <td colspan="2" style="padding:0;" valign="top">
       <div id="amc-tab">
       <table border="0" cellpadding="3" cellspacing="0" width="100%"> 
       <?php 
            while($rs_dtls=DB_fetch_array($result_dtls))
            {
         ?> 
        <tr>          	
            <td width="100"><?php echo $s->getField('account_cost_category','id',$rs_dtls['category_id'],'code') ; ?></td>        
        </tr>
    <?php } ?> 
       </table>
      </div>
      </td>      
  </tr>
  <?php $i++;} ?>
   
</table>
</div>
</div>