<body background="i.jpg">
<?php include("../../include/dbconnect.php");?>

<title>Credit / Debit  Note View</title>
<body background = 'blater01.gif'  topmargin=0>
<center>
<table cellpadding=0 cellspacing=4 width=590>
<tr> 
<td style="padding:3px;" colspan=2 bgcolor="#93BEE2"><font face="Verdana, Arial, Helvetica, sans-serif"><b><b>Edit Credit Note</b></font>
</td>
</tr>
<tr valign="top"> 
<td colspan=2> <font >&nbsp;</font> </td>
</tr>
</table>

<?php 
foreach($_POST as $p=>$t)
{
	$_POST[$p] = trim($t);
}
$myCustomer = $_POST['Customer'];
?>
<table border=0 cellpadding=3 cellspacing=4 width="590">
<form name='myForm02' method='POST' action='<?=$_SERVER[PHP_SELF]?>'>
<tr><td >
<font class="sbd"><b>Select  Company</b></font>
</td>
	<td colspan=2>
	<select name= seller>
	<?php $query="select distinct compcode,name from company order by name ";
		  $query=stripslashes($query);
		  $result=mysql_query($query) or
		  die( mysql_error() );
		  
		  while ( $row= mysql_fetch_row($result))
		  {
			  echo "<option value='$row[0]'>";
		  echo $row[1];
		  echo "\n";
		  }
	?>
	</select>
	</td></tr>
<?php
//$result=mysql_query("select bcode,name,unit from buy order by name") or die(mysql_error());
$result = mysql_query("select distinct crnote.bcode, buy.name, buy.unit from crnote, buy  where crnote.bcode = buy.bcode order by buy.name")or die( mysql_error() );


?> 
  <tr> 
    <td nowrap ><font class="sbd"><b>Cusomter Name </b></font></td>
    <td width="418">   <SELECT name='Customer' onChange="javascript:submit();">
<?php	
while($row = mysql_fetch_row($result))
{
if(isset($myCustomer) && eregi("$myCustomer", $row[0]))
  {
    $temp = $row[1].'&nbsp; '.$row[2];
	echo "<option selected value=\"$row[0]\">$temp";
  }
  else
  {
       $temp = $row[1].'&nbsp; '.$row[2];
       echo "<option value=\"$row[0]\">$temp";      
  }
}
echo "</select>";
?>

</SELECT>
</td>
</form>

<input type="hidden" name="bcd" value=<? echo($myCustomer);?> >

<?
$result = mysql_query("select record, crnoteno, crnotedt, crnoteamt, drnoteno, drnotedt, drnoteamt, crdr, invno, invamt, narration, account_year from crnote where bcode = '$myCustomer' ") or die(mysql_error());

$number_cols=mysql_num_fields($result);
echo "<table border=1> \n";
echo "<tr align=center> \n";
for($i=0;$i<$number_cols;$i++)
{
echo "<th>" . mysql_field_name($result,$i).   "</th>\n";
}
echo "<tr>\n";

//layout table

while($row = mysql_fetch_row($result))
{
echo "<tr align=left> \n";
echo "<td>";
if(!isset($row[0])) //test for null value
{
echo "NULL";
}
else
{
?>

<a href = "editview.php?record=<?echo($row[0]);?>"><?echo($row[0]);?></a>
<?

}

for($i=1;$i<$number_cols;$i++)
{
echo "<td>";
if(!isset($row[$i])) //test for null value
{
echo "NULL";
}
else
{
echo $row[$i];
}
echo "</td>\n";
}
echo "</tr> \n";
}
echo"</table>";

?>
</tr>
</form>



<br><br><font size=1><center><a href= "index.html">Return to index page</a></center></font>
</body></form>


