<?php
$debit="";
$credit="";
$from=$_REQUEST['from'];
$to=$_REQUEST['to'];
$billno=$_REQUEST['billno'];
$i=1;
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

<table width="98%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <th width="8%" align="left" valign="middle">Bill No</th>
      <th width="6%" align="left" valign="middle">Date</th>
      <th width="10%" align="left" valign="middle">Client</th>
      <th width="9%" align="left" valign="middle">Service</th>
      <th width="17%" align="left" valign="middle">Amount Payabale</th>
      <th width="9%" align="left" valign="middle">Received</th>
      <th width="8%" align="left" valign="middle">Pending</th>
      <th width="9%" align="left" valign="middle">Due date</th>
      <th width="4%" align="left" valign="middle">&nbsp;</th>
      <th width="5%">&nbsp;</th>
      <th width="5%">&nbsp;</th>
      <th width="5%">&nbsp;</th>
      <th width="5%">&nbsp;</th>
    </tr>
<?php
if (!empty($billno))
{
$array=mysql_query("select * from tbl_receipt where autonumber='$billno'");
}
else 
{
$array=mysql_query("select * from tbl_receipt where add_date between '$from' and '$to'");
}
$count=mysql_num_rows($array);
if($count != '0')
{
while($result=mysql_fetch_array($array))
{
?>
		    <tr>
      <td class="tr_td"><input type="hidden" id="id<?=$i;?>" value="<?php echo $result['autonumber'];?>" /><?php echo $result['autonumber'];?></td>
      <td class="tr_td"><?php echo $result['add_date'];?></td>
      <td class="tr_td"><?php echo $result['received_from']; ?></td>
      <td class="tr_td"></td>
      <td class="tr_td"><input type="text" name="pay<?=$i?>" id="pay<?=$i?>" value="<?php echo $result['cash']; ?>" readonly="" /></td>
      <td class="tr_td"><input type="text" name="rec<?=$i?>"  id="rec<?=$i?>" onchange="balance('<?=$i?>');"/></td>
      <td class="tr_td"><input type="text" name="pend<?=$i?>" id="pend<?=$i?>" /></td>
      <td class="tr_td tr_td_r"><?=date('Y-m-d');?></td>
      <td align="center" class="tr_td_b"><a href="edit_bills.php?id=<?php echo $result['id']; ?>&ab=<?php echo $i;?>"><img src="images/icon2.jpg" width="18" height="18" /></a></td>
      <td align="center" class="tr_td_b"><img src="images/icon3.jpg" width="17" height="22" /></td>
      <td align="center" class="tr_td_b"><img src="images/icon4.jpg" width="22" height="20" /></td>
      <td align="center" class="tr_td_b"><input type="hidden" name="save" /><input type="image" name="save" src="images/icon5.jpg" width="20" height="20" /></td>
   	  <td align="center" class="tr_td_r" ><a href="delete_bills.php?id=<?php echo $result['id']; ?>" onclick="return confirm('Do you really want to delete this field?');"><img src="images/icon1.jpg" width="21" height="21" /></a></td>
    </tr>
<?php
}
}else
{
?>  
<td colspan="12" align="center" style="color:#660000; font-size:12px;">No Data Listed</td>
<?php
}
?>
  </table>
