<?php include("../../include/dbconnect.php");?>
<?php 
$tempr = "Inv Date & No Amt : ";
$id = count($invno);
if ($submit == "Submit")
{
$i = 0;
while ($i < $id) 
{ $query1=  mysql_query("select dbamt, invno, date, bcode, cramt from custledger where record ='$invno[$i]'") or die(mysql_error());
  $row1=mysql_fetch_row($query1);
  $dba = $row1[0];
  $inv = $row1[1];
  $dt = $row1[2];
  $bcode = $row1[3];
  $camt = $row1[4];
  $cdt = substr($sdt,6,4).'/'.substr($sdt,3,2).'/'.substr($sdt,0,2);
  $amt = $camt + $crnoteamt;
  if ($amt == $dba)
  {
  $query= "update custledger set crnoteno = '$crnoteno', crnotedt = '$cdt', crnoteamt = '$crnoteamt', paystatus='Yes' where record='$invno[$i]'";
  }
  else
  {
  $query= "update custledger set crnoteno = '$crnoteno', crnotedt = '$cdt', crnoteamt = '$crnoteamt' where record='$invno[$i]'";
  }
  mysql_query($query) or die ("Error in query: $query");
  if (empty($bcode))
  {
    $bcode=$bcd;
  }  
  
$insertquery ="insert into crnote (bcode, crnoteno, crnotedt, crnoteamt, invno, invdt, invamt, narration, account_year, record) values('$bcode' , '$crnoteno', '$cdt', '$crnoteamt', '$inv', '$dt', '$dba', '$narration', '$acct_yr', NULL)"; 
mysql_query($insertquery) or  die (mysql_error());
$i = $i + 1;
}
}
?>

<br>
<br><br><font size=1><center><a href= "crnoteinput.php">Make another Entry</a></center></font>
<br><font size=1><center><a href= "http://192.168.1.2/wilson/index.html">Return to index page</a></center></font>
</body></form>

