<?
session_start();
include("test.php");
include("opendb.php");
include("includes/function.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='ind.php' </script>";
  return;
}



$us=mysqli_query($db,"select level from bruser where username='$user'")or die(mysqli_error($db));
$r=mysqli_fetch_row($us);
$user_level=$r[0];
 //print "User Level:".$user_level;
        
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>World Wide Automotive Center</title>
    <script type="text/javascript" src="scripts/jquery-latest.js"></script>
	<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link type="text/css" href="css/form1.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="js/jquery.js"></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; }


.del{
      border: none;
     background: url("images/delete.png") no-repeat scroll 0 0 transparent;
}

</style>

<script>

var ptnm=[];
var ptcd=[];
var count=1;


      var convr=[];

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


<?


 
	$select=mysqli_query($db,"select newpartmaster.partcode,newpartmaster.partname  from newpartmaster INNER JOIN spareprmast on newpartmaster.partcode=spareprmast.partcode where spareprmast.brcode='$brcode'   ") or die("ERR6:".mysqli_error($db));
  	 $xxx="[";
 		while($row=mysqli_fetch_array($select))
 
  		 {
        		$xxx.='"'.$row[1].'",';

   
    		} 

  
 			  $xxx.="]"; ?>
			rawTags=<?echo $xxx;?>;


 	 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!=''))
              {
          
           
           //closingbal(itemval, this1, 'drcbal', 'myTable');
           
           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;
     
     // get_pcode(pid,ptval,'partcode');
    
          for(var m=1; m<count; m++){
    if(ptval==ptnm[m]){
       document.getElementById(pid).value=ptcd[m];
      
          }
            }
     handleEnter(this1, event);
   	
              }  
}

//mainLoop();


<?


 
	$select=mysqli_query($db,"select newpartmaster.partcode,newpartmaster.partname  from newpartmaster INNER JOIN spareprmast on newpartmaster.partcode=spareprmast.partcode where spareprmast.brcode='$brcode'   ") or die("ERR6:".mysqli_error($db));
  	 $xxx2="[";
 		while($row=mysqli_fetch_array($select))
 
  		 {
        		$xxx2.='"'.$row[0].'",';

   
    		} 

  
 			  $xxx2.="]"; ?>
			rawTags2=<?echo $xxx2;?>;


 	  function xx2(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')
              {
         

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 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!=''))
              {


         //closingbal(itemval, this1, 'drcbal', 'myTable');
        
         
   	 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;
   //get_pcode(pid,ptval,'partname');
    

       for(var m=1; m<count; m++){
    if(ptval==ptcd[m]){
       document.getElementById(pid).value=ptnm[m];
      
          }
            }
       handleEnter(this1, event);
              }  
}

//mainLoop();




/** code below for showing partcode/partname *******/


function get_pcode(pid,ptval,part)
{
//alert (pid);
var xmlhttp;
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(pid).value=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax_purchase_getpart.php?pid="+pid+"&&ptval="+ptval+"&&part="+part,true);
xmlhttp.send();
}


 function check_valid(){
   var val=document.getElementById('round_fig').value;
   var sign=document.getElementById('sign').value;
   
   if(isNaN(val)){

    alert('Invalid Number');

    document.getElementById('round_fig').value='0.00';
    document.getElementById('round_fig').focus();
    document.getElementById('round_total').value=(document.getElementById('spare_total').value)-(document.getElementById('round_fig').value);

  }

  else{
    if(sign=='+'){
     
       document.getElementById('round_total').value=(parseFloat(document.getElementById('spare_total').value)+parseFloat(document.getElementById('round_fig').value)).toFixed(2);
     }
    if(sign=='-'){

      document.getElementById('round_total').value=(parseFloat(document.getElementById('spare_total').value)-parseFloat(document.getElementById('round_fig').value)).toFixed(2);

     }

 }

}
</script>




<script type="text/javascript">
$(document).ready(function() {
	$('a.login-window').click(function() {
		
		// Getting the variable's value from a link 
		var loginBox = $(this).attr('href');

		//Fade in the Popup and add close button
		$(loginBox).fadeIn(300);
		
		//Set the center alignment padding + border
		var popMargTop = ($(loginBox).height() + 24) / 2; 
		var popMargLeft = ($(loginBox).width() + 24) / 2; 
		
		$(loginBox).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		
		// Add the mask to body
		$('body').append('<div id="mask"></div>');
		$('#mask').fadeIn(300);
		
		return false;
	});
	
	// When clicking on the button close or the mask layer the popup closed
	$('a.close, #mask').live('click', function() { 
	  $('#mask , .login-popup').fadeOut(300 , function() {
		$('#mask').remove();  
	}); 
	return false;
	});
});


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

$("#msgbox").html('<small>Loading...</small>');
      

    	// var name= $(this).attr('name');

    	 //$('#type_name').val(name);
   
  	 var values1 = $("#jforms").serialize();
 	// $(".typeselecter").attr("disabled", true);
 	 // $("#td1").html('');

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

 

           	 if(parseInt(msg)!=0)    

          	  {

                $('#msgbox').html(msg);
               // $("#load").html(''); 
                //$(".typeselecter").attr("disabled", false);  
		}
           

      	},
      error:function(){
          alert("failure");
          $("#msgbox").html('there is error while submit');
      }   
   	 }); 

	 }); 
	 }); 



        $(function() {
          if ($.browser.msie && $.browser.version.substr(0,1)<7)
          {
			$('li').has('ul').mouseover(function(){
				$(this).children('ul').show();
				}).mouseout(function(){
				$(this).children('ul').hide();
				})
          }
        });        


    $(document).ready(function() {
        var cont_left = $("#container").position().left;
        $("a img").hover(function() {
            // hover in
            //$(this).parent().parent().css("z-index", 1);
            $(this).animate({
               height: "110",
               width: "110",
              
            }, "fast");
        }, function() {
            // hover out
         //   $(this).parent().parent().css("z-index", 0);
            $(this).animate({
                height: "80",
                width: "80",
                
            }, "fast");
        });
        
        $(".img").each(function(index) {
            var left = (index * 160) + cont_left;
            $(this).css("left", left + "px");
        });
    });


$(document).bind('keydown', 'Alt+n',function (e){
      
    if(e.which==78 && e.altKey){
	 //alert (e.which);
        shortkey_tblopen();
        return false;
    } 
     if(e.which==83 && e.altKey){
	 
         $( "#svbttn" ).click();
        return false;
    } 
   if(e.which==82 && e.altKey){
	 
         window.location.reload(true);
        return false;
    } 
      
    
});

  function shortkey_tblopen(){
               
               var rowCounts = document.getElementById('myTable').rows.length;
		 if(rowCounts<=1){
		          
			document.getElementById('insrowbttn').click(); 
               }		   					
 		 else
			document.getElementById('insrowbttn2').click(); 
 }





/***********************************************
* Disable "Enter" key in Form script
* This notice must stay intact for use
***********************************************/
                

function handleEnter (field, event) {
               
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 


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

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


                    /* var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();*/

                   var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i - 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
			
			 
              }
               
                   	/* if (keyCode == 46){
			  var i=field.parentNode.parentNode.rowIndex;
			  
                       var r=confirm("Do you want to delete the row?");
			  if (r==true)
 				 {
 					//document.getElementById('myTable').deleteRow(i);
					delrow(field);
                                  document.getElementById('myTable').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 }
			  
                       }*/
                   
		else
		return true;
	}      





function handleEnter2 (field, event) {
               
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		if (keyCode == 13) {
			var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i + 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
		} 


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

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


                    /* var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable2').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();*/

                   var i;
			for (i = 0; i < field.form.elements.length; i++)
				if (field == field.form.elements[i])
					break;
			i = (i - 1) % field.form.elements.length;
			field.form.elements[i].focus();
			return false;
			
			 
              }
                     	/*  if (keyCode == 46){
			  var i=field.parentNode.parentNode.rowIndex;
			  
                       var r=confirm("Do you want to delete the row?");
			  if (r==true)
 				 {
 					//document.getElementById('myTable2').deleteRow(i);
					delrow2(field);
                                  document.getElementById('myTable2').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable2').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 }
			   
                       }*/
                   
		else
		return true;
	}    






/**** functions below to calculate total amount  ***/


function unitcal(val,r)
{
var i=r.parentNode.parentNode.rowIndex;


   var tbl = document.getElementById('myTable');
   var id1=tbl.rows[i].cells[0].innerHTML;
var fldid=document.getElementById('rate'+id1).value;
  if(isNaN(fldid))
  {
   alert('enter digit');
  document.getElementById('rate'+id1).value=0;
 
  val=0;
  }


    var qtyval=document.getElementById('qty'+id1).value;
    var disc=document.getElementById('disc'+id1).value;
   var totval=(qtyval)*(fldid);

      if(disc> totval)
        {
        document.getElementById('disc'+id1).value='0';
        
         }
      else
        {
            document.getElementById('gtot'+id1).value=totval-disc;


         




   var p=0;
   var ups1 = document.getElementsByName('gtot[]'), sum1 = 0, p;
    var t1 = document.getElementsByName('typ[]');
   
    for(p = ups1.length; p--;)
        if(ups1[p].value)
     
            sum1 += parseFloat(ups1[p].value, 10);
			document.getElementById('spare_total').value=sum1.toFixed(2);
                    check_valid();
           
                    //document.getElementById('sum_total').value=parseFloat(document.getElementById('spare_total').value)+parseFloat(document.getElementById('labour_total').value);
        
         }


}



function discountcal(val,r)
  {
   

 var i=r.parentNode.parentNode.rowIndex;


   var tbl = document.getElementById('myTable');
   var id1=tbl.rows[i].cells[0].innerHTML;

  var fldid=document.getElementById('disc'+id1).value;
 if(isNaN(fldid))
  {
   alert('enter digit');
  document.getElementById('disc'+id1).value=0;
  val=0;
  }
 



    var qtyval=document.getElementById('qty'+id1).value;
    var uprice=document.getElementById('rate'+id1).value;
   var totval=(qtyval)*(uprice);

      if(val> totval)
        {
        document.getElementById('disc'+id1).value='0';
        
         }
      else
        {
            document.getElementById('gtot'+id1).value=totval-val;





   var p=0;
   var ups1 = document.getElementsByName('gtot[]'), sum1 = 0, p;
    var t1 = document.getElementsByName('typ[]');
   
    for(p = ups1.length; p--;)
        if(ups1[p].value)
     
            sum1 += parseFloat(ups1[p].value, 10);
			document.getElementById('spare_total').value=sum1.toFixed(2);
                    check_valid();
                 // document.getElementById('sum_total').value=(parseFloat(document.getElementById('spare_total').value)+parseFloat(document.getElementById('labour_total').value)).toFixed(2);
        
         }
 }
      
  

function othercal(val,r)
  {
   

 var i=r.parentNode.parentNode.rowIndex;


   var tbl = document.getElementById('myTable');
   var id1=tbl.rows[i].cells[0].innerHTML;

  var fldid=document.getElementById('hnd'+id1).value;
 if(isNaN(fldid))
  {
   alert('enter digit');
  document.getElementById('hnd'+id1).value=0;
  val=0;
  }
  
var qtyval=document.getElementById('qty'+id1).value;
    var uprice=document.getElementById('rate'+id1).value;
   var totval=(qtyval)*(uprice);

          document.getElementById('gtot'+id1).value=parseFloat(document.getElementById('gtot'+id1).value)+parseFloat(val);
            

            



            var p=0;
   var ups1 = document.getElementsByName('gtot[]'), sum1 = 0, p;
    var t1 = document.getElementsByName('typ[]');
   
    for(p = ups1.length; p--;)
        if(ups1[p].value)
     
            sum1 += parseFloat(ups1[p].value, 10);
			document.getElementById('spare_total').value=sum1.toFixed(2);
                     check_valid();
           

     //   document.getElementById('sum_total').value=parseFloat(document.getElementById('spare_total').value)+parseFloat(document.getElementById('labour_total').value);
         


}


function totalcalc(val,r)
{
  
   var i=r.parentNode.parentNode.rowIndex;


   var tbl  =document.getElementById('myTable');
   var id1  =tbl.rows[i].cells[0].innerHTML;

  var fldid =document.getElementById('qty'+id1).value;
  var ordqty=document.getElementById('odr_qty'+id1).value;

  var prd_qty=document.getElementById('prd_qty'+id1).value;
  var bal_qty=ordqty-prd_qty;

  var dis   =document.getElementById('disc'+id1).value;
  var uprice=document.getElementById('rate'+id1).value;
  var hnd   =document.getElementById('hnd'+id1).value;
  
 if(isNaN(fldid))
  {
   alert('enter digit');
   document.getElementById('qty'+id1).value=0;
   document.getElementById('qty'+id1).focus();
  }
 if((bal_qty-val)<0)
   {
    alert('Quantity must be less than or equal to Order quantity.');
    document.getElementById('qty'+id1).value=0;
    document.getElementById('qty'+id1).focus();
   }
    
   var tot= parseFloat((fldid*uprice))+ parseFloat(hnd)- parseFloat(dis);
   document.getElementById('gtot'+id1).value=tot;
    
   var p=0;
   var ups1= document.getElementsByName('gtot[]'), sum1 = 0, p;
   
   for(p = ups1.length; p--;)
       if(ups1[p].value)
          sum1 += parseFloat(ups1[p].value, 10);
			
   document.getElementById('spare_total').value=sum1.toFixed(2);
   check_valid();
           
}
</script>


<script>
var cur=1;
var cnt=1;
var porder=[];
var partcode=[];
var partname=[];
var qty=[];
var rate=[];
var disc=[];
var hnd=[];
var gtot=[];
var exqty=[];
var spareengineer=[];
var day=[];
var month=[];
var year=[];
var odr_qty=[];



function delrow(r)
{


var i=r.parentNode.parentNode.rowIndex;
 document.getElementById('myTable').deleteRow(i);

  var rowCount = document.getElementById('myTable').rows.length;
   var tbl = document.getElementById('myTable');
 if(rowCount<=1)
 {
  document.getElementById('insrowbttn').type='button';
 }
   
  var q;
  var id1;
  var part; 
  var sum2=0;
   var sum3=0;
  var stot;
  var ltot;
   for(q=1;q<rowCount;q++)
    {
     id1=tbl.rows[q].cells[0].innerHTML;
    
    
       ptot = document.getElementById("gtot"+id1).value;
       sum2+= parseFloat(ptot);
     
      
    }
   document.getElementById('spare_total').value=sum2.toFixed(2);
    document.getElementById('round_total').value=Math.round(sum2.toFixed(2));   
 

cnt--;

 }




function insRow(event,i1,id2)
{

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;
  }


		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 yy=x.insertCell(1)
var y=x.insertCell(2)
var z=x.insertCell(3)	
var eng=x.insertCell(4);
var ord=x.insertCell(5)
var ag=x.insertCell(6)

var z1=x.insertCell(7)	
var dis=x.insertCell(8)
var hnd=x.insertCell(9);
var tot=x.insertCell(10);
var qqty=x.insertCell(11);
var dd1=x.insertCell(12);
var mm1=x.insertCell(13);
var yy1=x.insertCell(14);

var dd=x.insertCell(15);

a.innerHTML=cur;

yy.innerHTML="<input type= text name=porder[] id=porder"+cur+" readonly class='porder' size=20 onKeydown='return handleEnter(this, event)'>";
y.innerHTML="<input type= text name=partcode[] id=partcode"+cur+"   class='partcode' onkeyup='xx2(this.id,event,this)'  autocomplete='off' list='htmlListTags'>";
z.innerHTML="<input type=text name=partname[] id=partname"+cur+" size=20 class='partname'  onkeyup='xx(this.id,event,this)'  autocomplete='off' list='htmlListTags'>"
ord.innerHTML="<input type=text name='odr_qty[]' id=odr_qty"+cur+" size=3 onChange=calcamt(cur) onKeydown='return handleEnter(this, event)'>";
ag.innerHTML="<input type=text name='qty[]' id=qty"+cur+" size=3 onKeyup='totalcalc(this.value,this)' onKeydown='return handleEnter(this, event)'>";
z1.innerHTML="<input type=text  id='rate"+cur+"' name=rate[] size=4 class='rate' onchange='unitcal(this.value,this)' onKeydown='return handleEnter(this, event)'>"
dis.innerHTML="<input type=text name='disc[]' id=disc"+cur+" size=3  onchange='discountcal(this.value,this)' onKeydown='return handleEnter(this, event)'>";
hnd.innerHTML="<input type=text value='0.0' name='hnd[]' id=hnd"+cur+" size=3 onchange='othercal(this.value,this)' onKeydown='return handleEnter(this, event)'>";
tot.innerHTML="<input type=text readonly value='total' name='gtot[]' id=gtot"+cur+" size=5 onKeydown='return handleEnter(this, event)'>";
qqty.innerHTML="<input type=text readonly name='exqty[]' id=exqty"+cur+" size=1 class='supqty' onKeydown='return handleEnter(this, event)'>";
var xv="";
xv="<select name='spareengineer[]' id=spareengineer"+cur+"  onKeydown='return handleEnter(this, event)'><option>Orignial</option><option>Commercial</option><option>Used</option>\n";


eng.innerHTML=xv+"</select> ";
dd1.innerHTML="<input type=text value='<?print date('d')?>' name='day[]' id=day"+cur+" size=1 onKeydown='return handleEnter(this, event)'>";
mm1.innerHTML="<input type=text value='<?print date('m')?>' name='month[]' id=month"+cur+" size=1 onKeydown='return handleEnter(this, event)'>";
yy1.innerHTML="<input type=text value='<?print date('Y')?>' name='year[]' id=year"+cur+" size=2 onKeyup='insRow(event,this,this.id)'>";

dd.innerHTML="<input type=button class='del' id=del"+cur+" onClick='delrow(this)'>";

document.getElementById("porder"+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("porder"+id3).focus();
} 

}// end function insrow


var cur2=1;
var cnt2=1;
var service=[];
var servamt=[];
var engineer1=[];
var jobs=[];
var day1=[];
var month1=[];
var year1=[];
 

function insRow2(event,i1,id2)
{

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('myTable2').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('myTable2').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('myTable2').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();
	
}

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


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


if(rowCount>=1)
 {
  document.getElementById('insrowbttn2').type='hidden';
 }
var a=x.insertCell(0)
var y=x.insertCell(1)
var job=x.insertCell(2)
var z=x.insertCell(3)	

var engs=x.insertCell(4)
var dd3=x.insertCell(5);
var mm3=x.insertCell(6)	
var yy3=x.insertCell(7);
var dd2=x.insertCell(8);
a.innerHTML=cur2;
y.innerHTML="<input type=text name=service[] id=service"+cur2+" size=30 class='service' onKeydown='return handleEnter2(this, event)'>"
z.innerHTML="<input type=text name=servamt[] id=servamt"+cur2+" size=8 onChange='calctotal(cur2)' class='servamt' onKeydown='return handleEnter2(this, event)'>"

dd2.innerHTML="<input type=button class='del'  id=del"+cur2+" onClick='delrow2(this)'>";
var v="";
v="<select name='engineer1[]' id=engineer1"+cur2+" style='width:150px;' onKeydown='return handleEnter2(this, event)'><option></option>\n";

<?
 $empre1=mysqli_query($db,"select ename from empprofile where status!='releived' order by ename");
 while($emprow1=mysqli_fetch_row($empre1))
{
print "v=v+'<option>$emprow1[0]</option>' \n";
}
?>
engs.innerHTML=v+"</select> ";

var vx="";
vx="<select name='jobs[]' id=jobs"+cur2+" onKeydown='return handleEnter2(this, event)'><option>Change</option><option>Repair</option>\n";

job.innerHTML=vx+"</select> ";

dd3.innerHTML="<input type=text value='<?print date('d')?>' name='day1[]' id=day"+cur2+" size=2 onKeydown='return handleEnter2(this, event)'>";
mm3.innerHTML="<input type=text value='<?print date('m')?>' name='month1[]' id=month"+cur2+" size=2 onKeydown='return handleEnter2(this, event)'>";
yy3.innerHTML="<input type=text value='<?print date('Y')?>' name='year1[]' id=year"+cur2+" size=4 onKeyup='insRow2(event,this,this.id)'>";


document.getElementById("service"+cur2).focus();
  cur2++; 

cnt2++;



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


if(keyCode == 13)
{

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

}// end function insrow2

</script>
<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;
 width:100%;
}
#tbl3{
 width:100%;
border-collapse:collapse;
}
#myTable{
width:100%;
border-collapse:collapse;
}
#myTable2{
width:100%;
border-collapse:collapse;
}
#myTable td,th{
border:1px solid grey;
}
#myTable th{
font-color:black;
}
#myTable2 td,th{
border:1px solid grey;
}
#tbl3 td,th{
border:1px solid grey;
}
</style>




<?
   $res1=mysqli_query($db,"select * from pjobcard where invno='$invno' and brcode='$brcode'");
   $prow=mysqli_fetch_array($res1);
 $res=mysqli_query($db,"select * from gateentry where jcno='$prow[jcno]' and brcode='$brcode'");
 $jrow=mysqli_fetch_array($res);
?>
<?php include('includes/top.php'); ?>
<body style="text-align: center;"  >


         <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;">
		EDIT PURCHASE</h1></td></tr>


<tr>

             <!-- <input style="height:32px;width:110px;" value="Edit"  type="submit" onClick="window.open('editpurchase1.php')">  
          <input style="height:32px;width:110px;" value="Print"  type="submit" onClick="window.open('printest1.php')">--> 
         <td  style="text-align:right;"><a href="#login-box" class="login-window" style="text-decoration:none;"><input  style="height:32px;width:110px;" value="Save" type="button" id='svbttn'></a>
<!--<a href="#" class='svbttn' id='svbttn2' style="text-decoration:none;"><input type='button' style="height:32px;width:200px;"  value='Update form and Print Bill' name='updprn' style="font-size:15; font-weight:bold"></a>-->
</td></tr>
	
<tr><td id='tbltd1' colspan='6'>

<div>
 <fieldset style="border:2px solid grey; border-style:dotted;">
            <legend style="text-align:center;">Edit Purchase</legend>


<form id="jforms" name="invoice_form" >

<input type='hidden' name='updprint' id='upd_flag' value='2'>
<table  ><tr><td style="text-align: right;">
<a href="purchase.php"   style="text-decoration:none;"><img src='images/back.png'/></a></td></tr></table>
<table class='tbl2' id='tbl2'><tr><td style="width:100%;">
   <table border=1 id='tbl3'>
<tr>PurNo: <input type=text readonly name='invno' size=5 value='<?print $invno?>'>  <input type=hidden name='jcno' size=5 value='<?print $prow[jcno]?>'></tr>
<tr><td>Date </td><td><input type=text readonly name='date' value= '<?print datetohtml($jrow[entrydate])?>' size=8></td>
    <td>RegNo </td><td><input type=text readonly name='msno' value='<?print $jrow[regno]?>' size=12></td>

	<td>Delivery Date</td><td><input type=text readonly name='dcomm' value='<?print datetohtml($jrow[estdate])?>' size=8></td>
	<td>Model </td><td><input type=text readonly name='model' value='<?print $jrow[model]?>' size=8></td>
	<td>Owner </td><td><input type=text readonly name='cname' value='<?print $jrow[owner]?>'></td>
</tr>
<tr>	<td>Make </td><td><input type=text readonly name='stdate' value='<?print $jrow[vehiclename]?>'></td>
	<td>Ins type </td><td><input type=text readonly name='instype' value='<?print $jrow[instype]?>'></td>
	<td>Job Type </td><td><input type=text readonly name='wtstdate' value='<?print $jrow[jobtype]?>' size=8></td>
	<td>ReceivedBy </td><td><input type=text readonly name='wtyenddate' value='<?print $jrow[receivedby]?>' size=8></td>
	<td>KMS </td><td><input type=text name='hmr' size=8 value='<?print $jrow[hmr]?>'></td>

</tr>
<tr>
			<td>User </td><td><input type=text readonly name='user' value='<?print $user?>' size=8></td>
<td>Entry Date </td><td colspan=3>
dd <input type=text readonly name='entrdate1' size=1 value='<?print date('d')?>'>
mm <input type=text readonly name='entrdate2' size=1 value='<?print date('m')?>'>
yy <input type=text readonly name='entrdate3' size=2 value='<?print date('Y')?>'>
</td>
<td>ChasisNO </td><td colspan="3"><input type=text name='chasisno' value='<?print $jrow[chasisno]?>'></td></tr><tr>
<td>Purchase Bill Date </td><td >
dd <input type=text readonly name='pdate1' size=1 value='<?print date('d')?>'>
mm <input type=text readonly name='pdate2' size=1 value='<?print date('m')?>'>
yy <input type=text readonly name='pdate3' size=2 value='<?print date('Y')?>'>
</td>
<td>PurchaseBillNo</td><td><input type=text name='pbillno' size=8 value='<?print $prow[pbillno]?>'></td>

<td >Supplier Account</td>
    <td colspan="5"><select name='supplier' onkeypress="return handleEnter(this, event)" style="width:150px;">

<?
print"<option>$prow[cname]</option>";
$i=1;
$re=mysqli_query($db,"select * from sup_master  order by supname");
while($row=mysqli_fetch_array($re))
{
 print "\n<option value='$row[supname]'>$row[supname]</option>";
 print "\n<script>adr[$i]='$row[addr1] - $row[city] - $row[dist] - $row[stat] - $row[pin] - $row[phone1]' </script>";
 $i++;
}
?>
</select> </td>

</tr>
</table> 

</td></tr>

  <tr><td>
<h4>Parts Request </h4>
<!--<input type="button" id='insrowbttn' onclick="insRow(event,this,this.id)" value=" Add Item ">-->
<table border=1  id="myTable" >


<th> No <th>Order<th>Part Code<th> Part Name<th>Part type <th>Order Qty<th>Purchase<br>Qty<th>Rate<th>Discount<th>Other<br>Charges<th>Total<th>Ref<th colspan=3>OrderDate<th>Delete


<?
$tbl="stockrepdet10".$brcode.$user;
mysqli_query($db,"delete from $tbl where supqty<=0 ");

 $res=mysqli_query($db,"select * from pjcardparts where invno='$invno' and brcode='$brcode'");


 
 $i=1;
 $j=1;
   $partot=0;
 while($jrow=mysqli_fetch_array($res))
  {

  $prd_qty=0;
  $p_res=mysqli_query($db,"select * from pjcardparts   where jcno='$jrow[0]' and invno<> '$invno' and brcode='$brcode' and porder='$jrow[3]'");
  while($prow=mysqli_fetch_array($p_res)){
   
   $prd_qty+=$prow[5];  
  }

  $res1=mysqli_query($db,"select * from prime_jcardparts where jcno='$jrow[0]' and brcode='$brcode' and partname='$jrow[20]' ");
  $row=mysqli_fetch_array($res1);

$edate1=explode('-',$jrow[edate]);

print "<tr><td>".$i."</td>";

print "<td><input type=text  name='porder[]' value='$jrow[porder]' id='porder$j' readonly size=20 onKeydown='return handleEnter(this, event)'></td> ";
  print "<td><input type=text  name='partcode[]' id='partcode$j' value='$jrow[2]' size=20  class='partcode' onkeyup='xx2(this.id,event,this)'  autocomplete='off' list='htmlListTags'></td>";
 print "<td><input type=text size=20 name='partname[]' value='$jrow[3]' id='partname$j'  class='partname' onkeyup='xx(this.id,event,this)'  autocomplete='off' list='htmlListTags'></td>";
 print "<td><select   name='spareengineer[]' id='spareengineer$j'  onKeydown='return handleEnter(this, event)'> <option>$jrow[engineer]</option> <option>Orignial</option><option>Commercial</option><option>Used</option></select></td>";

 
print "<td>";
$res1=mysqli_query($db,"select qty from prime_jcardparts where jcno='$jcno' and brcode='$brcode' and partname='$jrow[porder]'");
$jrow1=mysqli_fetch_row($res1);

print "<input type=text size=3 readonly name='odr_qty[]' id='odr_qty$j' value='$row[5]' onChange=calcamt2($j) onKeydown='return handleEnter(this, event)' onKeyup=validnum(this.id)>";

print "</td>";
 print "<td><input type=text size=3 name='qty[]' id='qty$j' value='$jrow[qty]' onKeyup='totalcalc(this.value,this)' onKeydown='return handleEnter(this, event)' onKeyup=validnum(this.id)></td>";

  print "<td><input type=text size=4  name='rate[]' id='rate$j' value='$jrow[rate]' onchange='unitcal(this.value,this)' onKeydown='return handleEnter(this, event)' > </td>";
   print "<td><input type=text size=3 name='disc[]' id='disc$j' value='$jrow[disc]' onchange='discountcal(this.value,this)' onKeydown='return handleEnter(this, event)' ></td>";


   print "<td><input type=text size=3 name='hnd[]' id='hnd$j' value='$jrow[hnd]' onchange='othercal(this.value,this)' onKeydown='return handleEnter(this, event)'></td>";

   print "<td><input type=text size=5 name='gtot[]' id='gtot$i' value='$jrow[gtot]' onKeydown='return handleEnter(this, event)'></td>";


 $qtres=mysqli_query($db,"select supqty from $tbl where partcode='$jrow[2]'");
 $qtrow=mysqli_fetch_row($qtres);
   $qqty=($qtrow[0]+$jrow[qty]);


   print "<td><input type=text name='exqty[]' id='exqty$j' value='$qqty' size=1  onKeydown='return handleEnter(this, event)'></td>";
      print "<td><input type=text name='day[]' id='day$j' value='$edate1[2]' size=1 onKeydown='return handleEnter(this, event)'></td>";
    print "<td><input type=text name='month[]' id='month$j' value='$edate1[1]' size=1 onKeydown='return handleEnter(this, event)'></td>";
    print "<td><input type=text name='year[]' id='year$j' value='$edate1[0]' size=2 onKeyup='insRow(event,this,this.id)'><input type=hidden size=3 readonly name='prd_qty[]' id='prd_qty$j' value='".$prd_qty."') ></td>";
if($user!='RAJESHTS'||$user!='RAJESHHYD'||$user!='RAJESHMW'|| $user!='nandakumar'|| $user!='anand')
{
   print "<td><input type=button class='del' ></td>";
}
else
{
   print "<td><input type=button value='No' ></td>";
}


$partot+=$jrow[gtot];
   $i++;
   $j++;
print"<script>cur++;</script>";
print"<script>cnt++;</script>";

  }
?>
</table>


<br>

<datalist id="htmlListTags"></datalist>

<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='partvalid'></div>

<div id="view" class="login-popup">

</div>


 <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  colspan='5' style="text-align:right;">
                      
                    Parts Total
                <input  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="spare_total" id="spare_total" value=<? echo $partot; ?> type="text">
</td></tr>
<tr>   
<td  colspan='5' style="text-align:right;">
                      
                    Round Figure

                <select id='sign' style="border:0px solid white;text-align:right; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c; -webkit-appearance: none;-moz-appearance: none;appearance: none;" ><option>+</option><option>-</option></select>
                <input  style="border:0px solid lavendar;text-align:right; width:40px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;"  name="round_fig" id="round_fig" type="text" value='0.00' onkeyup='check_valid()'>
</td></tr>


<td  colspan='5' style="text-align:right;">
                      
                    Net Total
                <input  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='true' name="net_total" id="round_total" type="text" >
</td></tr>
<!--<tr><td colspan='5' style="text-align:right;">
              Service Total
                <input  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="labour_total" id="labour_total" value=<? echo $servtot; ?> type="text">
</td></tr>-->
<!--<tr><td  colspan='5' 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=<? echo $ntot; ?> type="text">

</td></tr>-->

 </form>

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

</td></tr></table>

<?
$qry=mysqli_query($db,"select * from newpartmaster");
$n=1;
while($qry1=mysqli_fetch_array($qry))
{
print "<script> ptnm[$n]='$qry1[1]';  </script>";
print "<script> ptcd[$n]='$qry1[0]'; </script>";
$n++;
print "<script> count++;</script>";
}
?>

