<? 
	session_start();
	include("test.php");
	include("opendb.php");
	include("includes/function.php");


		if(strlen($user)<=0)
		{
 	 	print "<script> alert('Invalid User'); document.location='inde.php' </script>";
 		 return;
		}
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>World Wide Automotive Center</title>
<link rel="stylesheet" href="cal1/jquery-ui.css" />
    <script src="cal1/jquery-1.9.1.js"></script>
    <script src="cal1/jquery-ui1.js"></script>
   
    <style>


     $(document).ready(function(){

        $("#svbttn").click(function(){

           $("#msgbox").html('<small>Loading...</small>');
      
      
  /*  	     var values1 = $("#jforms").serialize();

 	
  	  $.ajax({
   	   url: "sv_lub_pur.php",
    	  type: "POST",
   	  data:   values1,
     	  success: function(msg){

           if(parseInt(msg)!=0)    
                 {
                 $('#msgbox').html(msg);
                 }
           	},
      error:function(){
          alert("failure");
          $("#msgbox").html('there is error while submit');
      }   
   	 }); 
*/
	 }); 
	 }); 




    .ui-datepicker {font-size:11px;}
    </style>
    <script>
    $(function() {
    $( "#from" ).datepicker({
  });
    });
    $(function() {
    $( "#to" ).datepicker({
  });
    });
    </script>

<script>

var ptnm=[];
var ptcd=[];
var ndpcost=[];
var cnvr=[];
var unity=[];

var count=1;
var count1;

var convr=[];

  	var rawTags;
   	var inputField;
   	var  initInputFieldValue;
   	var dataList;
       var initNbVirgules ;




 	 function xx(str,event,this1)
  {


  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

          if (keyCode == 37){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                     document.getElementById('myTable').rows[row-1].cells[5].getElementsByTagName("input")[0].focus();

	 }

     
 	if (keyCode == 38){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                     //document.getElementById('myTable').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();

	 }

       
 	if (keyCode == 40){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                     //document.getElementById('myTable').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();

	 }
 
              if (keyCode == 46){
			  var i=this1.parentNode.parentNode.rowIndex;
			  
                       var r=confirm("Do you want to delete the row?");
			  if (r==true)
 				 {
 					//document.getElementById('myTable').deleteRow(i);
					delrow(this1);
                                  document.getElementById('myTable').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 }
			   
                       }


 inputField = document.getElementById(str);

 initInputFieldValue = inputField.value;
 dataList = document.getElementById('htmlListTags');

		if(keyCode!='40')
              {
                if(keyCode!='38')
              {
         

yy(str,event,this1); 


}
 


     }
 
 }
  function yy(str,event,this1)
    {


     initNbVirgules = (initInputFieldValue.match(/,/g)||[]).length;
fillDatalist("",str,event,this1);
    } 
  
function fillDatalist(prefix,str,event,this1) {



	var nbRawList = rawTags.length;
       
	while(dataList.childNodes.length > 0) {
		dataList.removeChild(dataList.childNodes[0]);
	}
	
	for (i=0; i < nbRawList; i++ ) {
		var nOpt = document.createElement("option");
		nOpt.value = prefix+rawTags[i];
		dataList.appendChild(nOpt);
	}

   var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

  
   var itemval=document.getElementById(str).value;


    if((keyCode=='13') &&(itemval!='')) {
             
         
         var i=this1.parentNode.parentNode.rowIndex;
         var tbl = document.getElementById('myTable');
         var id1=tbl.rows[i].cells[0].innerHTML;
         var pid='partcode'+id1;
         var ptval= document.getElementById('partname'+id1).value;

         var a;
         for(a=1; a<count; a++){
            
            if(ptval==ptnm[a]){
              document.getElementById(pid).value=ptcd[a];
              document.getElementById('unitprice'+id1).value=ndpcost[a];
            }
         }

   	  handleEnter(this1, event);
     }  
}

//mainLoop();




 function xx2(str,event,this1)
  {
	var ledval=this1.value;

	if(ledval!='')
	{
		if (window.XMLHttpRequest)
		{// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		}
		else
		{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
			{
			
			document.getElementById("htmlListTags").innerHTML=xmlhttp.responseText;
    			}
  		}
	      var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if((keyCode>=33) && (keyCode<=40))
		{
		return false;
		}
		else
		{
		xmlhttp.open("GET","suggestion4.php?ledg="+ledval,true);
		xmlhttp.send();
		}
	}
  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

          if (keyCode == 37)
				{
                   		 var row=this1.parentNode.parentNode.rowIndex;
			 	 var col  =this1.parentNode.cellIndex ;
			 
                    		 document.getElementById('myTable').rows[row-1].cells[5].getElementsByTagName("input")[0].focus();

	 			 }

     
 	  if (keyCode == 38)
				{
                    		var row=this1.parentNode.parentNode.rowIndex;
				 var col  =this1.parentNode.cellIndex ;
			 
                     //document.getElementById('myTable').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();

	 			}

       
 	if (keyCode == 40)
			   {
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                     //document.getElementById('myTable').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();

	 		   }
 
              if (keyCode == 46)
					{
			  		var i=this1.parentNode.parentNode.rowIndex;
			  
                      		var r=confirm("Do you want to delete the row?");
					  if (r==true)
 				 		{
 					//document.getElementById('myTable').deleteRow(i);
					delrow(this1);
                                  document.getElementById('myTable').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 		}
			   
                      		 }


 inputField = document.getElementById(str);

 initInputFieldValue = inputField.value;
 dataList = document.getElementById('htmlListTags');

		if(keyCode!='40')
              {
                if(keyCode!='38')
              {
         

yy2(str,event,this1); 


}
 


     }
 
 }
  function yy2(str,event,this1)
    {


     initNbVirgules = (initInputFieldValue.match(/,/g)||[]).length;
fillDatalist2("",str,event,this1);
    } 
  
function fillDatalist2(prefix,str,event,this1) {

    var rawTags2=str;

	var nbRawList = rawTags2.length;
       
	while(dataList.childNodes.length > 0) {
		dataList.removeChild(dataList.childNodes[0]);
	}
	
	for (i=0; i < nbRawList; i++ ) {
		var nOpt = document.createElement("option");
		nOpt.value = prefix+rawTags2[i];
		dataList.appendChild(nOpt);
	}

   var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

  
   var itemval=document.getElementById(str).value;


    if((keyCode=='13') &&(itemval!='')){
              

        var i=this1.parentNode.parentNode.rowIndex;
        var tbl = document.getElementById('myTable');
        var id1=tbl.rows[i].cells[0].innerHTML;
        var pid='partname'+id1;
        var ptval= document.getElementById('partcode'+id1).value;

        var a;
         for(a=1; a<count; a++){
            
            if(ptval==ptcd[a]){
              document.getElementById(pid).value=ptnm[a];
              document.getElementById('unitprice'+id1).value=ndpcost[a];
            }
         }

           handleEnter(this1, event);
              
    }  
}

//mainLoop();





</script>



<style>


	#mask 
	{
	display: none;
	background:url(images/bgimg1.gif) repeat;
	//background: #000; 
	position: fixed; left: 0; top: 0; 
	z-index: 10;
	width: 100%; height: 100%;
	opacity: 0.8;
	z-index: 999;
	}

	.login-popup{

		display:none;
	background:white;
	padding: 10px; 	
	border: 2px solid #ddd;
	float: left;
	font-size: 1.2em;
	position: fixed;
	top: 4%; left: 45%;
	z-index: 99999;
	box-shadow: 0px 0px 20px #999;
	-moz-box-shadow: 0px 0px 20px #999; /* Firefox */
    -webkit-box-shadow: 0px 0px 20px #999; /* Safari, Chrome */
	border-radius:3px 3px 3px 3px;
    -moz-border-radius: 3px; /* Firefox */
    -webkit-border-radius: 3px; /* Safari, Chrome */
}
}

	img.btn_close 
	{
	float: right; 
	margin: -28px -28px 0 0;
	}

	fieldset 
	{ 
	border:none; 
	}

	form.signin .textbox label 
	{ 
	display:block; 
	padding-bottom:7px; 
	}

	form.signin .textbox span
	 { 
	display:block;
	}

	form.signin p, form.signin span
	 { 
	color:white; 
	font-size:11px; 
	line-height:18px;
	} 

	form.signin .textbox input 
	{ 
		background:#666666; 
		border-bottom:1px solid #333;
		border-left:1px solid #000;
		border-right:1px solid #333;
		border-top:1px solid #000;
		color:white; 
		border-radius: 3px 3px 3px 3px;
		-moz-border-radius: 3px;
   		 -webkit-border-radius: 3px;
		font:13px Arial, Helvetica, sans-serif;
		padding:6px 6px 4px;
		width:200px;
	}

	form.signin input:-moz-placeholder { color:white; text-shadow:0 0 2px #000; }
	form.signin input::-webkit-input-placeholder { color:hwite; text-shadow:0 0 2px #000;  }

	.submit button
	 { 
	background: -moz-linear-gradient(center top, #f3f3f3, #dddddd);
	background: -webkit-gradient(linear, left top, left bottom, from(#f3f3f3), to(#dddddd));
	background:  -o-linear-gradient(top, #f3f3f3, #dddddd);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f3f3f3', EndColorStr='#dddddd');
	border-color:#000; 
	border-width:1px;
	border-radius:4px 4px 4px 4px;
	-moz-border-radius: 4px;
    -webkit-border-radius: 4px;
	color:#333;
	cursor:pointer;
	display:inline-block;
	padding:6px 6px 4px;
	margin-top:10px;
	font:12px; 
	width:100px;
}

.button:hover { background:#ddd; }



.pop-up2 {position:absolute; top:10px; left:50px;padding-left:180px;}
.pop-up2:target {position:static; left:0;}

.popBox2 {
  background:#ffffff;

 
  width:75%;
  min-height:100%;



   z-index:1;

  border:1px solid #3a3a3a;


  -moz-border-radius:12px;
  border-radius:12px;
  -webkit-box-shadow:2px 2px 4px #3a3a3a;
  -moz-box-shadow:2px 2px 4px #3a3a3a;
  box-shadow:2px 2px 4px #3a3a3a;
  opacity:0;
 -webkit-transition: opacity 0.5s ease-in-out;
  -moz-transition: opacity 0.5s ease-in-out;
  -o-transition: opacity 0.5s ease-in-out;
  -ms-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;  
}
:target .popBox2 {position:fixed; opacity:1;}

.popBox2:hover {box-shadow:3px 3px 6px #5a5a5a;}



.lightbox {display:none; text-indent:0em; background:#000; opacity:0.0; width:100%; height:100%; position:fixed; top:0; left:0; bottom:0; right:0;}
:target .lightbox {display:block}



  


/* .popScroll {max-height:99%; overflow-y:scroll;} removed 17/07/2012 */
.popScroll2 {position:absolute; top:9%; left:3%; right:3%; bottom:9%; overflow-y:auto; *overflow-y:scroll; padding-right:0.5em}


</style>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="functions_pur.js"></script>



                
<script>   


var cur=1;
var partcode=[];
var partname=[];
var unitprice=[];
var qty=[];
var pt=[];
var tot=[];
var typ=[];
var convr=[];
var cnt=1;

function insRow(event,i1,id2)
{
count1=1;
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

var cur_val=i1.value;


switch(keyCode)
{
case 38:
   var row=i1.parentNode.parentNode.rowIndex;
   var col  =i1.parentNode.cellIndex ;
			 
   document.getElementById('myTable').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();
  break;
case 40:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
   document.getElementById('myTable').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();
			
  break;
case 37:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
  document.getElementById('myTable').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();
	
}



if(id2!="insrowbttn")
  {
   var i2=i1.parentNode.parentNode.rowIndex;
   var i3=parseFloat(i2)+parseFloat(1);
   var rowCounts = document.getElementById('myTable').rows.length;
   var rowCounts1= rowCounts-1;
   
  
  }
else
  {
   var i2=0;
   var rowCounts1=0;
  }
//alert(cur);



		if(((keyCode == 13) && (i2==rowCounts1))||(cnt==1))
 {
var rowCount = document.getElementById('myTable').rows.length;
var rowcount1=parseFloat(rowCount)+parseFloat(1);
//alert(rowCount);
var x=document.getElementById('myTable').insertRow(rowCount);


if(rowCount>=1)
 {
  document.getElementById('insrowbttn').type='hidden';
 }

var a=x.insertCell(0)
var b=x.insertCell(1)
var y=x.insertCell(2)
var pt=x.insertCell(3)
var u=x.insertCell(4)
var z=x.insertCell(5)	
var z1=x.insertCell(6);
var dis=x.insertCell(7);
var t=x.insertCell(8);

var dd=x.insertCell(9);
var k;//=this.rowIndex;
var k1;
a.innerHTML=cur;
b.innerHTML="<input type=text name=partcode[] id=partcode"+cur+" size=20 class='partcode' onkeyup='xx2(this.id,event,this)'  autocomplete='off' list='htmlListTags'>"
y.innerHTML="<input type=text   name=partname[] id=partname"+cur+"  class='partname' size=20   onkeyup='xx(this.id,event,this)'  autocomplete='off' list='htmlListTags'   >";

var xw="";
xw="<select name='unit[]' id=unit"+cur+" onchange='qutychecking(this)' onKeydown='return handleEnter(this, event)'> ";

<?
$k=1;
 $qry2=mysqli_query($db,"select * from unit");
 while($qry21=mysqli_fetch_row($qry2))
{
print "xw=xw+'<option>$qry21[0]</option>' \n";
print "cnvr[$k]='$qry21[2]'; ";
print "unity[$k]='$qry21[0]'; ";
$k++;
print "count1++;";
}
?>
u.innerHTML=xw+"</select> ";
z.innerHTML="<input type=text name='qty[]' class='xx' id=qty"+cur+" size=2 value='0' onKeydown='return handleEnter(this, event)'  onKeyup='qutychecking(this)'>";
z1.innerHTML="<input type=text name=unitprice[] id=unitprice"+cur+" size=3 class='unitprice' onKeyup='qutychecking(this)' onKeydown='return handleEnter(this, event)'>";
t.innerHTML="<input type=text  id='tot"+cur+"' name=tot[] readonly size=5 class='tot'  value='0' onKeyup='insRow(event,this,this.id)'><input type=hidden  id='typ"+cur+"' name=typ[]  readonly size=3 class='typ'   ><input type=hidden  id='conv"+cur+"' name=conv[]   readonly size=3 class='conv'   >";
dis.innerHTML="<input type=text  id='dis"+cur+"' name=dis[] value='0' size=5 class='dis'   onKeyup='qutychecking(this)' onKeydown='return handleEnter(this, event)'  >";
var xv="";
xv="<select name='part_type[]' id=part_type"+cur+" onKeydown='return handleEnter(this, event)' style='width:80px;'><option>Orignial</option><option>Commercial</option><option>Used</option>\n";


pt.innerHTML=xv+"</select> ";
dd.innerHTML="<input onClick='delrow(this)' type='button' class='del' >";


document.getElementById("partcode"+cur).focus();
  cur++; 

cnt++;



var table = document.getElementById("myTable");
var row = table.rows[index];
console.log(secondRow.id);
}

if(keyCode == 13)
{

var tbl = document.getElementById('myTable');
   var id3=tbl.rows[i3].cells[0].innerHTML;
document.getElementById("partcode"+id3).focus();
} 




}// end function insrow


 

</script>

	<style>
	.cont
		{
		background-color:#3b5998;

		//background:url(images/bg-inner.jpg) #e9e0c3 repeat-x;
  			width: 100%;position: absolute ;
			height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
    }
</style>
<style>
.tble1 input {
background-color:transparent;
border: 0px solid;
height:20px;
//width:160px;
color:black;
}
.tble1
{
border-collapse:collapse;
border:1px solid silver;
margin-top:20px;
}	
.tble1 td, th
{
border-collapse:collapse;
border:1px solid silver;
}


#tbl1{
 margin-top:40px;
min-width:65%;
 text-align:center;
}

#tbltd1{
vertical-align: top;
margin-top:20px;
 height:400px;
background-color:white;
-moz-box-shadow: 0 0 5px -1px #000;
-webkit-box-shadow: 0 0 5px -1px #000;
box-shadow: 0 0 5px -1px #000;

}
#tbl1 td{
 text-align:left;

}
#tbl2{
 margin:50px 20px 10px 20px;
 min-width:95%;
}
.del{
      border: none;
     background: url("images/delete.png") no-repeat scroll 0 0 transparent;
}

</style>


<link type="text/css" href="includes/style1.css" rel="stylesheet" />
      <link type="text/css" href="css/form1.css" rel="stylesheet" />


<?php include('includes/top.php'); ?>
<body style="text-align: center;"  >
        

<div id="pop2" class="pop-up2" >
  <div class="popBox2">

    <div class="popScroll2" id='popScroll2' >

    </div>
 
  </div>


  <a href="#links" class="lightbox"></a>
</div>    

         <table class='tbl1' id='tbl1'  align='center'><tr><td align='left' colspan='6'>
		<h1 style="font-size:20px;font-weight:bold;font-family:verdana;color:#FFFFFD;margin:0px; padding:0px;">
		Lubricant Purchase </h1></td></tr>
		
		<tr>
		<td> <a href="#pop2" id="links" onclick='showHint()' style="text-decoration:none;"><input value="View"  style="height:32px;width:110px;" type="submit"></a></td>

               <td><input value="Print" onClick="window.open('printlub1.php')" style="height:32px;width:110px;" type="submit"></td>
         
               <!--<td> <input style="height:32px;width:110px;" value="PDF"  type="submit" onClick="window.open('pdfinv.php')"></td>-->
 
               <!-- <td><input style="height:32px;width:110px;" value="Excel"  type="submit" onClick="window.open('excelinv1.php')"></td>-->

                <td>  <input style="height:32px;width:110px;" value="Edit"  type="submit" onClick="window.open('edit_lub_pur1.php')"></td>

                
           <td style="text-align:right; width:250px; height:45px;"><a href="#login-box" class="login-window" style="text-decoration:none;"> <input  style="height:32px;width:110px;" value="Save" type="button" id='svbttn'></a></td></tr>
	
<tr><td id='tbltd1' colspan='4'>
<div>
 <fieldset style="border:2px solid grey; border-style:dotted;">
            <legend style="text-align:center;">Lubricant Purchase </legend>
 <form id="jforms" name="invoice_form" >

    <table class='tbl2' id='tbl2' >


<?php
  $re=mysqli_query($db,"select max(prno) from lubricant_purmast where brcode='$brcode' ");
//print "select max(invno) from invoice where brcode='$brcode' ";
     if(mysqli_num_rows($re)<1)
       {
           $inv=1; 
       }
       else
       {
        $row=mysqli_fetch_array($re);
         $inv=$row[0]+1;
        }
?>




 <td align='left' width='15%'>
                        Purchase Bill #                    </td>

<td align='left' >  <input id="invoice_number"  style="outline:none;border:1px solid black; width:141px; padding-left:0px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" name="prbil"  value="" type="text" >
</td>
 <td align='left' width='15%'>
                        Purchase Id #                 </td>
<td align='right' width='15%'>  <input id="invoice_number" name='prno' style="outline:none;border:1px solid black; width:141px; padding-left:0px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" name="invoice_number"  value="<? echo $inv;?>" type="text" readonly>

                 
</td></tr>
 <tr><td align='left' >
                        Purchase Bill Date
                    </td>
<td align='left' >  <input readonly   id="invoice_date" style="outline:none;border:1px solid black; width:141px; padding-left:0px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;"  type=text name="prbldt" value="<? echo date('Y-m-d'); ?>">

			
 <td align='left'>
                        Purchase Date
                    </td>
			
                    <td  align='right'>

	<input readonly  id="payment_due_date" style="outline:none;border:1px solid black; width:141px; padding-left:0px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;"  type=text name="prdt" value="<? echo date('Y-m-d'); ?>">
                                </td></tr>
<tr><td align='left'>Supplier </td><td align='left'><select name='sup' style="width:150px;">

<?
$re=mysqli_query($db,"select supname from sup_master where branch='$brcode'");
while($row=mysqli_fetch_row($re))
{
 print "<option>$row[0]</option> ";
}
 print "</select>  </td></tr>";
?>
 <tr><td colspan='4'>  
<input type="button" id='insrowbttn' onclick="insRow(event,this,this.id)" style="color:#6B6B6B;font-weight:bold;font-size:15px;" value="+">
<br>
<table border=1 id="myTable" class='tble1' width=100%>
<th>No.<th>Part Code<th>Part Name <th>Part Type<th>Unit<th>Quantity<th >Unit Price<th>Disc<th>Amount<th>Del

 </table>
<datalist id="htmlListTags"></datalist>
<script>
var cnt=1;
</script>
<br>
<input type='hidden' name='brcode' id='brcode' value='<? print $brcode;?>'>
<input type='hidden' name='curqty' id='curqty' value='0'>
<input type='hidden' name='prtname' id='prtname' value='0'>
<input type='hidden' name='savecount' id='savecount' value='0'>
<div id='txtHint'></div>
<div id='convr'></div>


<div id='partvalid'></div>


<!--div below for popup window-->

 <div id="login-box" class="login-popup">
        <a href="#" class="close"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
          <div id='msgbox'></div>
		</div>



    </td></tr>
<tr><td></td><td></td><td colspan='2' style="text-align:right;">
            
     Total
                 <input onclick="alert('The total is calculated automatically as soon as you have entered something into both the unit price and the quantity field in the lines above.\n\nExample: If you wish to invoice a service for $100.00, you should enter 100.00 in the unit price field and 1.00 in the quantity field.')" style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="sum_total" id="sum_total" value="0.00" type="text">
</td></tr>
<tr><td colspan='4'><hr></hr></td></tr>
            
        
<?
$res=mysqli_query($db,"select * from payment_mode  where brcode='$brcode' and status='yes' order by mode");


?>
<tr><td></td><td></td><td style="text-align:right;"><b>Payment Mode:</b></td><td style="text-align:right;"><select name='pmode' onchange="showtype(this.value)"><option>-select-</option>
<?
while($row=mysqli_fetch_array($res))
{
PRINT "<option >$row[1]</option>";
}
?>
</select>

 </form>
   </td></tr>
</table>
   
</fieldset> 
</div>
</td></tr></table>

<?
$qry=mysqli_query($db,"select * from newpartmaster");
$n=1;

while($qry1=mysqli_fetch_array($qry))
{
  $qry2=mysqli_query($db,"select * from spareprmast where partcode='$qry1[0]' and brcode='$brcode' ");
  $qry3=mysqli_fetch_array($qry2);
  print "<script> ptnm[$n]='$qry1[1]';  </script>";
  print "<script> ptcd[$n]='$qry1[0]'; </script>";
  print "<script> ndpcost[$n]='$qry3[3]'; </script>";
  
$n++;
print "<script> count++;</script>";
}
?>
<?
$re=mysqli_query($db,"select * from jcardparts where brcode='$brcode'")or die('prt err:'.mysqli_error($db));
$i=1;

while($row=mysqli_fetch_array($re))
{
 

 print "\n<script> partname[$i]='$row[3]';</script> ";
 
 $i++;
}
?>
