
<?php
global $db;


				?>



<h2></h2>

<form method="post" action="">
	<table width="80%" border="0">
		<tr>
			<th><strong>Branch:</strong></th>
			<td><select name="site">
				<?php 
				$site="select prefix,locationname from locations";
				$siteres=DB_query($site,$db);
				while($siterow=DB_fetch_array($siteres))
				{
					
				
				?>
				<option value="<?php echo $siterow['prefix'];?>"><?php echo $siterow['locationname'];?></option>
				
				<?php 
				}?>
			</select></td>
			<th><strong>From Date:</strong></th>
			<td><input type="text" name="frmdate" class="datepicker" id="frmdate"></td>
			<th><strong>To Date:</strong></th>
			<td><input type="text" name="todate" class="datepicker" id="todate"></td>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td><input name="Search" type="submit"  value="Search"  onclick="return validate();"/></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>
		</table>
		</form>
	
	<?php
	if($_REQUEST['Search'])
	{
		 $prefix=$_REQUEST['site'];
		 $fromdate=FormatDateForSQL($_REQUEST['frmdate']);
		 $todate=FormatDateForSQL($_REQUEST['todate']);
	?>
<h2 align="center"><strong>BANK OF INDIA</strong></h2>
<h3 align="center"><font color="#FF0000">STATEMENT OF BOOK-DEBITS HYPOTHECATED</font></h3>
<div align="center">
<fieldset style="width:650px">
<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
  <tr><th><strong>The Chief Manager/Manager</strong></th>
   <th></th>
    <th><strong>Place:New Delhi</strong></th></tr>
    <tr><th><strong>Bank of India</strong></th>
    	 <th></th>
      <th><strong>Date:</strong></th>
    </tr>
    <tr><th><strong>Okhla,Branch,New Delhi</strong></th>
    	 <th></th>
     <th></th>
  </tr>
  <tr><th></th>
    	 <th></th>
      <th><strong>Re:Our Loan/Cash Credit Account </strong></th></tr>
      <tr><th></th>
    	 <th></th>
      <th><strong>Hypothecation of Book Debts</strong></th></tr>
      <tr><th></th>
    	 <th></th>
      <th><strong>Re:Statement of Book=Debts as on</strong></th></tr>
 </table>
  </fieldset>
</div>
<div>&nbsp;</div>
<p align="right"><a href="report_hypo_exp.php">Export</a>&nbsp;&nbsp;<a href="reporthypo_print.php?prefix=<?php echo $_REQUEST['site'];?>&frmdate=<?php echo $fromdate; ?>&todate=<?php echo $todate; ?>">Print</a></p>
<div>
	<table width="100%">
		<tr>
			<th>Bill No</th>
			<th>Bill Date</th>
			<th>Name & Address of the Party</th>
			<th>Item Supplied</th>
			<th>Value</th>
			</tr>
			<?php  $total_amt=array();
		     $invoicesql="SELECT * FROM invoice A,invoice_details B WHERE A.invoice_id=B.invoiceid 
			 and branch_name='".$prefix."' and invoiceDate between '".$fromdate."' and '".$todate."' GROUP BY B.invoiceid ";
			$_SESSION['data1']=$invoicesql;
		    $invoiceres=DB_query($invoicesql,$db);
			
	        $i=0;
			while($invoicerow=DB_fetch_array($invoiceres))
			{
				
			?>
			<tr>
			<td><?php echo $invoicerow['invoiceNo'];?></td>
			<td><?php echo $invoicerow['invoiceDate'];?></td>
			<td><?php
				echo $s->GetFieldValue('clientmaster',"id='".$invoicerow['client_id']."'"  ,'c_name');
				echo $s->GetFieldValue('clientmaster',"id='".$invoicerow['client_id']."'"  ,'pre_address1');
			 
				 ?></td>
				 <td>
				 <?php
				 echo $s->GetFieldValue('item_master',"StockID='".$invoicerow['ItemCode']."'"  ,'item_name');
				 $itemid=$s->GetFieldValue('item_master',"StockID='".$invoicerow['ItemCode']."'",'StockID');
				 ?>
				 </td>
				 <td>
				 <?php echo $invoicerow['grandTotal'];
				 $total_amt[]=$invoicerow['grandTotal'];
				 //echo $s->GetFieldValue('invoice_details',"ItemCode='". $itemid."'"  ,'Amount');?>
				 	</td>
			
				<?php $i++; }?>
				</tr>
				
				<tr><td></td><td></td><td></td><td align="center">Grand Total</td><td><?php echo array_sum($total_amt); ?></td></tr>
		
		</table>
	</div>
<?php  }?>

<script>
function validate()
{
if(document.getElementById("frmdate").value=='')
{
alert("Must Select From Date First");
return false;
}

if(document.getElementById("todate").value=='')
{
alert("Must Select To Date First");
return false;
}
return true;


}
</script>