<?php     
$action=$_REQUEST['action'];
$daction=$_REQUEST['daction'];
$msgErr='';
$status=true;
if($_REQUEST['Submit']=='Submit')
{
for($str=1;$str<$_REQUEST['count'];$str++)
{	
	if($_REQUEST['adjustment'][$str]!='')
	{
		echo "<br>1--".$_SESSION['billno'] =$_REQUEST['billno'][$str];
		echo "<br>2--".$_SESSION['billbookid'] =$_REQUEST['billbookid'][$str];
		echo "<br>3--".$_SESSION['adjustment'] =$_REQUEST['adjustment'][$str]; 
		echo "<br>4--".$_SESSION['pending'] =$_REQUEST['pending'][$str];
		echo "<br>5--".$_SESSION['ID'] =$_REQUEST['ID'][$str];
	}
}
//exit;
if($_REQUEST['VPrefix']!='' && $_REQUEST['voucherId']!='')
$s->pageLocation("index.php?route=Payments&VPrefix=".$_REQUEST['VPrefix']."&TransId=".$_REQUEST['TransId']."&voucherId=".$_REQUEST['voucherId']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
else
$s->pageLocation("index.php?route=Payments&VPrefix=".$_REQUEST['VPrefix']."&modid=".$_REQUEST['modid']."&frmid=".$_REQUEST['frmid']);
}
if($_REQUEST['action']=='Edit')
{
	$GetRecord1 = "Select id from cashbank_adjustment where TransId   ='".$_REQUEST['TransId']."' ";
	 $ResultData1 = DB_query($GetRecord1,$db);
	  while($RowData1 = DB_fetch_array($ResultData1))
	  {
	   $adjustmentid[]=$RowData1['id'];
	  }}
 ?>
<form action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td ><div align="right"><A HREF="javascript:history.go(-1)"> [Go Back]</A> </div></td>
  </tr>
</table>

<table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<th scope="col"><strong>Bill NO </strong></th>
<!-- <th scope="col">AccountsType</th>-->
<th scope="col"><strong>Bill date </strong></th>
<th scope="col"><strong>Bill Amount </strong></th>
<th scope="col"><strong>Pending </strong></th>
<th scope="col"><strong>Cur </strong></th>
<th scope="col"><strong>Dr/Cr</strong></th>
<th scope="col"><strong>Adjust Now </strong></th>
<th scope="col"><strong>Remark</strong></th>
<!--	    <th scope="col">Edit</th>
    <th scope="col">Delete</th>
-->  </tr>
    <tr>
   <?php 
   //$GetRecord = "Select * from invoice A   where A.invoice_status='Y' and  A.client_id ='".$_SESSION['clientid']."'  ";
   
   if(isset($_SESSION['vendorid']))
   { echo "Vendor";
   $GetRecord = "select * from purchase_billbook where vendor='".$_SESSION['vendorid']."' and bill_status='Pending' ";
   $ResultData = DB_query($GetRecord,$db);
   $i=1;
   $j=0;
    // echo DB_num_rows($ResultData);
   if(DB_num_rows($ResultData)==0)
   echo "<td colspan='3'>--No Record--</td>";
   else
   {
		   while($RowData = DB_fetch_array($ResultData))
		   {
			  ?> 
		   <td><div align="center"><?php echo $RowData['bill']; ?></div>
		   <input type="hidden" name="billno[<?php echo $i;?>]" value="<?php echo $RowData['bill'];?>" />
		   <input type="hidden" name="billbookid[<?php echo $i;?>]" value="<?php echo $RowData['id'];?>" />
		   <input type="hidden" name="ID[<?php echo $i;?>]" value="<?php echo $i;?>" />
		   </td>
			<td><?php echo ConvertSQLDate($RowData['bill_date']);?></td>	 
			<td><?php echo $RowData['grand_total'];?>
			<input name="pending[<?php echo $i;?>]" type="hidden" value="<?php echo $RowData['grand_total'];?>" />	  </td>
			  <td><?php echo $RowData['pending_amount']; ?>	  </td>
			  <td>Indian Rupee </td>
			  <td> </td>
			  <td align="center"><input name="adjustment[<?php echo $i;?>]" type="text"  value="<?php  echo $adjustment1;?>"/>   </td>
			  <td align="center">&nbsp;</td> 
    </tr>
		   
			<?php $i++;$j++; 
			}
	}  
   ?>  
   <input type="hidden" name="count" id="" value="<?php echo $i;?>" />
   
 <?php } 
 else if(isset($_SESSION['clientid']))
 { echo "client";
 	
	echo $GetRecord = "select * from invoice where client_code='".$_SESSION['clientid']."' and invoice_status='Pending' ";
   $ResultData = DB_query($GetRecord,$db);
   $i=1;
   $j=0;
    // echo DB_num_rows($ResultData);
   if(DB_num_rows($ResultData)==0)
   echo "<td colspan='3'>--No Record--</td>";
   else
   {
		   while($RowData = DB_fetch_array($ResultData))
		   {
			  ?> 
		   <td><div align="center"><?php echo $RowData['bill']; ?></div>
		   <input type="hidden" name="billno[<?php echo $i;?>]" value="<?php echo $RowData['bill'];?>" />
		   <input type="text" name="billbookid[<?php echo $i;?>]" value="<?php echo $RowData['invoice_id'];?>" />
		   <input type="hidden" name="ID[<?php echo $i;?>]" value="<?php echo $i;?>" />
		   </td>
			<td><?php echo ConvertSQLDate($RowData['invoice_date']);?></td>	 
			<td><?php echo $RowData['grand_total'];?>
			<input name="pending[<?php echo $i;?>]" type="hidden" value="<?php echo $RowData['grand_total'];?>" />	  </td>
			  <td><?php echo $RowData['pending_amount']; ?>	  </td>
			  <td>Indian Rupee </td>
			  <td> </td>
			  <td align="center"><input name="adjustment[<?php echo $i;?>]" type="text"  value="<?php  echo $adjustment1;?>"/>   </td>
			  <td align="center">&nbsp;</td> 
    </tr>
		   
			<?php $i++;$j++; 
			}
	}  
   ?>  
   <input type="hidden" name="count" id="" value="<?php echo $i;?>" />
   
 <?php 
	
 }
 ?>
 
 
 
 
 
 
 
   <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Submit" /></td>
      <td></td>
      <td>&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;</td>
    </tr>
</table>
</form>