<?php 
include("../../include/dbconnect.php");
?>
<table border="0" cellspacing="1" cellpadding="4" align="center" width="529" >
<form name="form1" method="POST"  action="update.php?record=<?echo($record);?>">
<?php 
$result = mysql_query("select bcode, crnoteno, crnotedt, crnoteamt,  invno, invdt, invamt, narration, account_year, record, drnoteno, drnotedt, drnoteamt, crdr from crnote where record = '$record' ") or die(mysql_error());
$row1=mysql_fetch_row($result);
$bcd = $row1[0];
$result1 = mysql_query("select bcode, name, unit from buy where bcode='$bcd'") or die(mysql_error());
$row2=mysql_fetch_row($result1);

?>
<tr>
<td nowrap> <font class="sbd"><b>Customer Name<b></font></td>
<td><input name="name" type="text" onKeyPress="return event.keyCode!=13" size="30" maxlength="30" value = <? echo("'$row2[1]'" . "'$row2[2]'");?> ></td></tr>
 
<?
if ($row1[13]=='Credit')
{
?>
<tr>
<td nowrap> <font class="sbd"><b>Credit Note No</b></font></td>
<td><input name="crnoteno" type="text" onKeyPress="return event.keyCode!=13" size="10" maxlength="10" value = <? echo "$row1[1]" ?> ></td></tr>

<SCRIPT LANGUAGE="JavaScript" src="../../include/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>
<tr class="small_site_font_black">
<td nowrap> <font class="sbd"><b>Credit Note No</b></font></td>
<? // echo $sdt;
if(empty($sdt))
{
  $sdt=substr($row1[2],8,2).'/'.substr($row1[2],5,2).'/'.substr($row1[2],0,4);
//  $sdt=strftime ("%d/%m/%Y", mktime (0,0,0,substr($sdt,5,2), substr($sdt,8,2), substr($sdt,0,4))); 
  
}?>
<td><INPUT NAME="sdt" TYPE="text" class="text_box_button" VALUE="<?=$sdt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.sdt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>


<tr>
<td nowrap> <font class="sbd"><b>Credit Note Amount</b></font></td>
<td><input name="crnoteamt" type="text" onKeyPress="return event.keyCode!=13"value= <? echo ($row1[3]) ?> size="10" maxlength="10"></td></tr>

<?
}
if ($row1[13]=='Debit')
{
?>

<tr>
<td nowrap> <font class="sbd"><b>Debit Note No</b></font></td>
<td><input name="drnoteno" type="text" onKeyPress="return event.keyCode!=13" size="10" maxlength="10" value = <? echo "$row1[10]" ?> ></td></tr>

<SCRIPT LANGUAGE="JavaScript" src="../../include/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</SCRIPT>
<tr class="small_site_font_black">
<td nowrap> <font class="sbd"><b>Debit Note No</b></font></td>
<? // echo $sdt;
if(empty($sdt))
{
  $sdt=substr($row1[11],8,2).'/'.substr($row1[11],5,2).'/'.substr($row1[11],0,4);
//  $sdt=strftime ("%d/%m/%Y", mktime (0,0,0,substr($sdt,5,2), substr($sdt,8,2), substr($sdt,0,4))); 
  
}?>
<td><INPUT NAME="sdt" TYPE="text" class="text_box_button" VALUE="<?=$sdt?>" SIZE="15" readonly  >
 <A HREF="#" onClick="cal.select(document.form1.sdt,'anchor1','dd/MM/yyyy'); return false;"NAME="anchor1" ID="anchor1"><img  src="../../images/cal.gif" border="0"></A> <BR>
 </td>
</tr>


<tr>
<td nowrap> <font class="sbd"><b>Debit Note Amount</b></font></td>
<td><input name="drnoteamt" type="text" onKeyPress="return event.keyCode!=13"value= <? echo ($row1[12]) ?> size="10" maxlength="10"></td></tr>
<?
}
?>

<tr>
<td nowrap> <font class="sbd"><b>Invoice No</b></font></td>
<td><input name="invno" type="text" onKeyPress="return event.keyCode!=13"value= <? echo ($row1[4]) ?> size="10" maxlength="10"></td></tr>

<tr>
<td nowrap> <font class="sbd"><b>Invoice Date</b></font></td>
<td><input name="invdt" type="text" onKeyPress="return event.keyCode!=13"value= <? echo ($row1[5]) ?> size="10" maxlength="10"></td></tr>

<tr>
<td nowrap> <font class="sbd"><b>Invoice Amount</b></font></td>
<td><input name="invamt" type="text" onKeyPress="return event.keyCode!=13"value= <? echo ($row1[6]) ?> size="10" maxlength="10"></td></tr>


<tr>
<td nowrap> <font class="sbd"><b>Description </b></font></td>
<td><textarea name="narration" cols="50" onKeyPress="return event.keyCode!=13"> <? echo ($row1[7]) ?></textarea></td></tr>
<table align="center" >
<tr>
<td> <input type =submit name="submit" value = "Submit" ></td>
<td>  <input type =submit name="submit" value = "Delete" ></td>
</tr>

</table>
