<link href="../css/printline.css" type="text/css" rel="stylesheet" media="print,screen"  />

<?
session_start();
include("../opendb.php");
include("../test.php");
$ker=mysqli_query($db,"select brstate from branch where brcode='$brcode'");
$kar=mysqli_fetch_array($ker);

?>
<BASE TARGET=main22>
<link rel="stylesheet" href="../style.css" type="text/css" />
<style>
	tr{background-color:white}
	th{background-color:steelblue;color:white}
</style>
<script>
var pna=[];
var hand=[];
var price=[];
var disc=[];
function getname()
{
 if(document.f1.partcode.selectedIndex<=0)
 {
 document.f1.prtname.value="";
 document.f1.price.value="";
 //document.f1.discount.value="";
 document.f1.hand.value="";
 }
 else{
 //document.f1.prtname.value=pna[document.f1.partcode.selectedIndex];
 //document.f1.price.value=price[document.f1.partcode.selectedIndex];
 //document.f1.discount.value=disc[document.f1.partcode.selectedIndex];
 //document.f1.hand.value=hand[document.f1.partcode.selectedIndex];

var act=parseFloat(document.f1.price.value)*parseFloat(document.f1.qty.value);
 var hnd=parseFloat(act)*document.f1.hand.value/100;

 var act1=act*parseFloat(document.f1.discount.value)/100;

 document.f1.aprice.value=parseFloat(act+hnd-act1).toFixed(2);
 act=document.f1.aprice.value;

 var act2=parseFloat(document.f1.aprice.value);
  var cst=parseFloat(act2)*document.f1.cst.value/100;
  var gtot=parseFloat(act2+cst).toFixed(2);
  document.f1.tot.value=gtot;
 }
}
function calcamt()
{
var act=parseFloat(document.f1.price.value)*parseFloat(document.f1.qty.value);
 var hnd=parseFloat(act)*document.f1.hand.value/100;

 var act1=act*parseFloat(document.f1.discount.value)/100;

 document.f1.aprice.value=parseFloat(act+hnd-act1).toFixed(2);
 act=document.f1.aprice.value;

 var act2=parseFloat(document.f1.aprice.value);
  var cst=parseFloat(act2)*document.f1.cst.value/100;
  var gtot=parseFloat(act2+cst).toFixed(2);
  document.f1.tot.value=gtot;
}
function valid()
{
 if(document.f1.partcode.selectedIndex<=0)
 {
  alert('Invalid Item code');
  return false;
 }
/*
var x=document.getElementById("mselect")
 document.f1.partcode1.value=x.options[x.selectedIndex].text
x.remove(x.selectedIndex)
*/
}
</script>
<body bgcolor='ivory'>
<center>
<form name='f1' action='linktbl.php' onSubmit='return valid()'>
<input type=hidden name='partcode1'>
<table>
<th colspan=10><h3>Ledger linking (<?print $ordnumber?>)</h3></th>
<tr>
<td>Employee</td><td><select name='employee' id='mselect' onChange=getname();><option></option>
<?
$i=1;
$re=mysqli_query($db,"select empname,empid from empmaster where brcode='$brcode' and doret='0000-00-00' order by empname");
while($row=mysqli_fetch_array($re))
{
 print "<option value='$row[1]'>$row[0]</option>";

}
?>
</select></td><td>Ledger</td><td><select name='ledger' id='mselect' onChange=getname();><option></option>
<?
$i=1;
$re=mysqli_query($db,"select led from ledger where brcode='$brcode' order by led");
while($row=mysqli_fetch_array($re))
{
 print "<option value='$row[0]'>$row[0]</option>";

}
?>
</select></td></tr>
<tr><td colspan=6 align=center bgcolor='steelblue'><input type=submit value='Add' name='add'><input type=submit value='View' name='view'></td></tr>
</table>
</form>
