<?php
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
$inno=$_REQUEST['inno'];
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>Kerala Khadi & Village Industries Board</title>
<link type="text/css" href="jquery/jquery-ui.min.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="functions_brrcptedit.js"></script>
<script src="cal/jquery-ui1.js"></script>
<script type="text/javascript" src="functions_brtrnsfin.js"></script>
<script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jquery/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery/jquery.jqEasyCharCounter.min.js"></script>
<script type="text/javascript">

$(function() {

    $("#invoice_date").datepicker({
	dateFormat: "yy-mm-dd"
   });
 $("#ref_date").datepicker({
	dateFormat: "yy-mm-dd"
   });



 });
  </script>
<script type="text/javascript">
var count1=1;
var count2=1;
var count3=1;
var pname=[];
var pcode=[];
var pname1=[];
var pcode1=[];
var empname=[];
var ndpcost=[];
$(function(){
$(".partcode").live("keydown.autocomplete",function(){
$partcode = $(this);
$row = $partcode.parent().parent();
$(this).autocomplete({
		source: function( request, response ) {

		$.ajax({
			url: "search5.php",
			dataType: "json",
			data: "key="+$partcode.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					
					
					return { 
						label: '<span class="la-code">'+item.partcode+' </span><span class="la-name">'+  item.partname + '</span><span class="la-stok"> '+ item.stock +'</span><span class="la-rate"> '+item.rate +'</span>'    ,
						value: item.partcode,
						name:item.partname,
						tax:item.tax,
						
						stock:item.stock,
						rate:item.rate,						
					}
				}));
			}
		});
	}
	
,
	minLength: 2,
	select: function( event, ui ) {
	$row.find('.partname').val(ui.item.name);
	$row.find('.stok').val(ui.item.stock);
	$row.find('.unitprice').val(ui.item.rate);	
	
	
	
	$row.find('.itmtyp').show().focus();
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	}).data("ui-autocomplete")._renderItem = function (ul, item) {
         return $("<li></li>")
             .data("item.autocomplete", item)
             .append( item.label )
             .appendTo(ul);
     };

					
});

$(".partname").live("keydown.autocomplete",function(){
$partname = $(this);

$row = $partname.parent().parent();
$(this).autocomplete({
		source: function( request, response ) {

		$.ajax({
			url: "search5.php?type=name",
			dataType: "json",
			data: "key="+$partname.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					return { 
						label: '<span class="la-code">'+item.partcode+' </span><span class="la-name">'+  item.partname + '</span><span class="la-stok"> '+ item.stock +'</span><span class="la-rate"> '+item.rate +'</span>'    ,
						code: item.partcode,
						value:item.partname,
						tax:item.tax,
						
						stock:item.stock,
						rate:item.rate,	
						
						
					}
	
				}));
			}
		});
	}
	
,
	minLength: 2,
	select: function( event, ui ) {

	$row.find('.partcode').val(ui.item.code);
	$row.find('.stok').val(ui.item.stock);
	$row.find('.unitprice').val(ui.item.rate);		
		
	/*log( ui.item ?
	"Selected: " + ui.item.label :
	"Nothing selected, input was " + this.value);
	*/
	 }
	
	}).data("ui-autocomplete")._renderItem = function (ul, item) {
         return $("<li></li>")
             .data("item.autocomplete", item)
             .append( item.label )
             .appendTo(ul);
     };

					
});



});


function sel(id1)
{

   document.getElementById(id1).select();
  
}

function showHint()
{
document.getElementById("popScroll2").innerHTML="<img src='images/loader.GIF' />";

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("popScroll2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","brtransfview1.php", true);
xmlhttp.send();
}

function viewinv()
{
 var str=document.getElementById('cid').value;
document.getElementById("popScroll2").innerHTML="<img src='images/loader.GIF' />";


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("popScroll2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","brtransfview.php?inno="+str,true);
xmlhttp.send();
}


/** code below for close popup div **/
function close_div(){
   var list = document.getElementsByClassName("pop-up2");
             for (var i = 0; i < list.length; i++) {
               list[i].style.display = 'none';
             }
    		var e = document.getElementById('pop2');
   		 if(e.style.display == 'block') {
       		 e.style.display = 'none';
   		 } else {
        	e.style.display = 'none';
              }

 }



 function check_empname(str,id1){

   var flg=0;
   for(var j=0;j<count1;j++){
alert(empname[j]);
       if(str==empname[j]){

         flg++;

       }//close of if cond.
  

   }//close of for loop.

   var len=str.length;

   if((!isNaN(str))&&len<=1){

   flg++;
   }
 
   if(flg<1){
    alert('Invalid employee');
    document.getElementById(id1).value='';
    document.getElementById(id1).focus();
    
   }
   
 }//function closed.
</script>
<style>
#txt{
font-family: Tahoma,Verdana,Geneva,sans-serif !important;
background-color: #F2F2F2;

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




.pop-up2 {position:absolute; top:2px; 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:60%; 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:2%; left:3%; right:3%; bottom:9%; overflow-y:auto; *overflow-y:scroll; padding-right:0.5em}


</style>

<script type="text/javascript">

$(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.ctrlKey) {
e.preventDefault()
 $( "#svbttn" ).click();
        return false;
} 
   if(e.which==82 && e.altKey){
	 
         window.location.reload(true);
        return false;
    } 
      
    
});
</script>

<script type="text/javascript">
function shortkey_tblopen(){
               
               var rowCounts = document.getElementById('myTable').rows.length;
		 if(rowCounts<=1){
		          
			document.getElementById('insrowbttn').click(); 
               }		   					
 		 
 }

</script>
<script type="text/javascript">
 var count1=0;
 var empname=[];

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

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;
  }
//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 b1=x.insertCell(1);
var c1=x.insertCell(2);
var z1=x.insertCell(3);
var d1=x.insertCell(4);	
var e1=x.insertCell(5);
var f1=x.insertCell(6);



var p1=x.insertCell(7);
var k;//=this.rowIndex;
var k1;
a.innerHTML=cur;


b1.innerHTML="<input type=text name=partcode[] id=partcode"+cur+"  class='partcode' size=15 autocomplete='off' list='partcodelist' >";
c1.innerHTML="<input type=text name=partname[] id=partname"+cur+"  class='partname' size=35  autocomplete='off' list='partlist' onKeydown='return handleEnter(this, event)' >"; 
var v="";
v="<select name='itmtyp[]' id=itmtyp"+cur+" class='itmtyp'  onkeypress='showitmtype(this.value,this,this.id)'  >";
v=v+'<option>N</option>';
v=v+'<option>D</option>';
v=v+'<option>S</option>';
v=v+'<option>C</option>';

z1.innerHTML=v+"</select><input type=text id='itmvl"+cur+"' name=itmvl[] value='0' size=3 style='outline:none;border:1px solid grey;width:30px; padding-left:7px; font-weight:normal;border-style:dotted; font-family:verdana;font-size:13px;visibility:hidden;' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'  > "; 
d1.innerHTML="<input type=text name='qty[]' class='xx' id=qty"+cur+" size=2 onKeydown='return handleEnter(this, event)' onKeyup='qtycheck(this.value,this,this.id)'>";//onKeyup=validnum(this.id)
e1.innerHTML="<input type=text name=unitprice[] id=unitprice"+cur+" size=6 class='unitprice' readonly onfocus='sel(this.id)' onKeydown='return handleEnter(this, event)' onKeyup='unitcal(this.value,this,this.id)'>";
f1.innerHTML="<input type=text id='tot"+cur+"' name=tot[] readonly value='0' size=3 class='tot' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup='insRow(event,this,this.id)'  >";
p1.innerHTML="<input type='button' onClick='delrow(this)' class='del' id=del"+cur+">";
document.getElementById("partcode"+cur).focus();
cur++; 

cnt++;
var table = document.getElementById("myTable");
var row = table.rows[index];
console.log(secondRow.id);
}
if(keyCode == 40)
{
return handleEnter(this, event);
}
if(keyCode == 13)
{

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

}// end function insrow
function newcustomer()
{
document.getElementById("to_new_customerTD").innerHTML=" <input id='to_new_customer' name='cus' style='outline:none;border:1px solid grey; border-style:dotted;width:150px; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;'   placeholder='Customer name' type='text'>";

 document.getElementById("to_new_registerTD").innerHTML=" <input id='to_new_register' name='reg' style='outline:none;border:1px solid grey;width:150px; padding-left:7px; font-weight:normal;border-style:dotted; font-family:verdana;font-size:13px;'  placeholder='Customer id' type='text'>"
 document.getElementById("show").innerHTML="<a href='#' style='text-decoration:none; color:black;' onclick='showcustomer()'>Click Here to Show Existing Customer</a>";
document.getElementById("pmode").value='CASH';
}
function showcustomer()
{

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("to_new_customerTD").innerHTML=xmlhttp.responseText;
    document.getElementById("show").innerHTML="<a href='#' style='text-decoration:none; color:black;' onclick='newcustomer()'>Click Here for Cash Invoice</a>";
    }
  }
document.getElementById("pmode").value='CREDIT';
xmlhttp.open("GET","showcus.php",true);
xmlhttp.send();
}

function showregister(str)
{
//var str="hello";
//alert (str);
if (str=="")
  {
  document.getElementById("to_new_registerTD").innerHTML="";
  return;
  }
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("to_new_registerTD").innerHTML=xmlhttp.responseText;
        
    }
  }
xmlhttp.open("GET","showreg1.php?cname="+str,true);
xmlhttp.send();

}

function showinfo(str)
{
//var str="hello";


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("to_new_model").innerHTML=xmlhttp.responseText;
    var  mod= document.getElementById("mod").value;
    document.getElementById('to_new_model').value=mod;
    document.getElementById("chno").innerHTML=xmlhttp.responseText;
    var  chasis= document.getElementById("chasis").value;
    document.getElementById('chno').value=chasis;
    
    }
  }
xmlhttp.open("GET","showinfo.php?reg="+str,true);
xmlhttp.send();

}
</script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link type="text/css" href="css/form1.css" rel="stylesheet" />
<SCRIPT LANGUAGE="JavaScript" SRC="util/PopupWindow.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/AnchorPosition.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="util/date.js"></SCRIPT>
<style>
.tble1 input {
background-color:transparent;
border: 0px solid;
height:20px;
//width:160px;
color:black;
}
.tble1
{

font-family: Tahoma,Verdana,Geneva,sans-serif !important;
    font-size: 14px;
border:1px solid silver;
margin-top:20px;
}
.trcls
{

background-color:#BDBDBD;
border:1px solid silver;

}	
.tble1 td, th
{
border-collapse:collapse;
border:1px solid silver;
}

#tbl1{

font-family: Tahoma,Verdana,Geneva,sans-serif !important;
    font-size: 14px;
 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%;
}
.tble2
{

font-family: Tahoma,Verdana,Geneva,sans-serif !important;
    font-size: 14px;
border:0px solid silver;

}
</style>

<?php //include('includes/top.php'); ?>
<?php include('help_window.php'); ?>
<div align='left'><font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Branch Receipt</font></div>
<body style="background-image:url(images/bg.jpg);" onload="document.getElementById('to_new_customer').focus();" >
      <?
       $re=mysqli_query($db,"select * from brtransferin where invno='$inno' and brcode='$brcode'");
	$irow=mysqli_fetch_array($re);
        ?>        
<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:blue;margin:0px; padding:0px;">
		Branch Receipt Edit</h1></td></tr>
		
		<tr>
           <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='6'>
<div>
 <fieldset style="border:2px solid grey; border-style:dotted;">
            <legend style="text-align:center;">Invoice</legend>
 <form id="jforms" name="invoice_form" >

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


<tr>
<td align='left'>
Branch name</td>
<td id="to_new_customerTD">
<?
$slqry="SELECT brtype from branch where brcode='$brcode'";
$slrs=mysqli_query($db,$slqry);
$slrw=mysqli_fetch_array($slrs);
if($slrw[0]=='HO')
{
$sql="SELECT brname,brcode,brtype from branch where brgroup=(select brgroup FROM branch where brcode='$brcode')";
}
if($slrw[0]=='BR')
{
$sql="SELECT brname,brcode from branch where brgroup=(select brgroup FROM branch where brcode='$brcode') and brtype='HO'";
}
$result = mysqli_query($db,$sql);
?>
<select name='cus' id="to_new_customer" style='width:160px;border:1px solid grey; border-style:dotted;' onchange='showregister(this.value)' onkeypress='return handleEnter(this, event)'><option>-select-</option>	
<?
while($row=mysqli_fetch_array($result))
{
?>
<option value="<? echo $row['brname'] ?>"<? if($irow[28]==$row['brname']) echo 'selected="selected"';?>><? echo $row['brname'] ?></option>
<?
}
?>
</select>
 
    
 </td>
<td></td><td></td>
<td style="text-align:right;">
   GRS No# </td>
<td style="text-align:right;">
   <input id="invoice_number" name='invno' style="outline:none;border:1px solid grey; border-style:dotted; width:141px; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" value="<? echo $irow[0];?>" type="text" readonly onKeydown="return handleEnter(this, event)" onfocus='sel(this.id)'>

</td></tr>
<tr><td align='left'>               
    Brach Id </td>
<td id="to_new_registerTD">       
      <input id="to_new_register" name='reg' style="outline:none;border:1px solid grey; border-style:dotted; width:150px; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:black;" placeholder="Branch Id" type="text" onKeydown="return handleEnter(this, event)" onfocus='sel(this.id)'>
             
</td>
<td></td><td></td>
<td style="text-align:right;">   

   GRS Date</td>
  <td style="text-align:right;" class="invoiceForm_fromNameTD" id="invoice_dateTD">                
<input id="invoice_date" name="invdt" style="width:141px;outline:none;border:1px solid grey; border-style:dotted; cursor:pointer; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;"  type=text  value="<? echo $irow[1];?>" onKeydown="return handleEnter(this, event)">


  </td></tr>
<tr><td align='left'>Sales Person
</td>
<td>
<select name="slsengnr" id="slsengnr" onKeyPress='return handleEnter(this, event)' style="width:160px;border:1px solid grey; border-style:dotted;" onfocus='sel(this.id)'  ><option>-NA-</option>

<?
$re=mysqli_query($db,"select empname from empmaster where doret='0000-00-00' and brcode='$brcode'");
while($rows=mysqli_fetch_row($re))
{
?>
<option><? echo $rows[0] ?></option>
<?
}
?>
</select>



</td> <td></td><td></td>
<td style="text-align:right;"> 

   Godown Invoice No:</td>
  <td style="text-align:right;" class="invoiceForm_fromNameTD" id="invoice_dateTD">
<input id="refno" name='refno' style="outline:none;border:1px solid grey; border-style:dotted; width:141px; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" type="text" value="<? echo $irow[31];?>" onKeydown="return handleEnter(this, event)" onfocus='sel(this.id)'>


  </td>

</tr>
<tr><td align='left'>
    </td>
<td id="to_new_registerTD">

</td>
<td></td><td></td>
<td style="text-align:right;"> 

   Invoice Date</td>
  <td style="text-align:right;" class="invoiceForm_fromNameTD" id="invoice_dateTD">
<input id="ref_date" name="ref_date" style="width:141px;outline:none;border:1px solid grey; border-style:dotted; cursor:pointer; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" type=text  value="<? echo $irow[32];?>" onKeydown="return handleEnter(this, event)">


  </td></tr>



<tr><td colspan='6'>      
<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%>
<tr class='trcls'><td>No.</td><td>Item Cd</td><td>Item Name</td><td>Item Type</td><td>Qty</td><td>Unit Price</td><td>Total</td><td>Del</td></tr>
<?
 $res=mysqli_query($db,"select * from brtransferin where invno='$inno' and brcode='$brcode'");

 $i=1;
 $l_tot=0;
 $s_tot=0;
 while($jrow=mysqli_fetch_array($res))
  {
?>
<tr><td><? echo $i ?></td>
<td><input type=text size=10 name='partcode[]' id='partcode<? echo $i ?>'  value='<? echo $jrow[5] ?>'  class='partcode'  autocomplete='off' list='partcodelist'  onkeypress='handleEnter(this, event)' ></td>
   <td><input type=text size=15 name='partname[]' value='<? echo $jrow[4] ?>' id='partname<? echo $i ?>'   class='partname' autocomplete='off' list='partlist' onkeypress='handleEnter3(this, event)' ></td>
  <td><select  name=itmtyp[] id='itmtyp<? echo $i ?>'  class='itmtyp' onchange='showitmtype(this.value,this,this.id)' >

<option value="N"<?php if ($jrow[22] == 'N') echo ' selected="selected"'; ?>>N</option>
<option value="D"<?php if ($jrow[22] == 'D') echo ' selected="selected"'; ?>>D</option>
<option value="S"<?php if ($jrow[22] == 'S') echo ' selected="selected"'; ?>>S</option>
<option value="C"<?php if ($jrow[22] == 'C') echo ' selected="selected"'; ?>>C</option>

</select><input type=text  name=itmvl[] id='itmvl<? echo $i ?>' value='<? $jrow[9] ?>' size=3 style='outline:none;border:1px solid grey;width:30px; padding-left:7px; font-weight:normal;border-style:dotted; font-family:verdana;font-size:13px;' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' readonly  >  </td>
<td><input type=text name='qty[]' class='qty' id='qty<? echo $i ?>' size=2 value='<? echo $jrow[7] ?>' onKeydown='return handleEnter(this, event)' onKeyup='qtycheck(this.value,this,this.id)'></td>
<td><input type=text name=unitprice[] id='unitprice<? echo $i ?>' size=3 value='<? echo $jrow[8] ?>' class='unitprice' readonly onfocus='sel(this.id)' onKeydown='return handleEnter(this, event)' onKeyup='qtycheck(this.value,this,this.id)'></td>
<td><input type=text id='tot<? echo $i ?>' name=tot[] readonly value='<? echo $jrow[10] ?>' size=3 class='tot' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup='insRow(event,this,this.id)'></td>
<td><input type='button' onClick='delrow(this)' class='del' id='del<? echo $i ?>'></td>
</tr>
<?
$l_tot+=$jrow[10];
 print"<script>cur++;</script>";
print"<script>cnt++;</script>";
$i++;
}
?>
</table>
<table border=1 class='tble2' width=100%>
<tr>
<td  style="text-align:right;" colspan=3>Net Total:</td>
<td><input style="border:0px solid white; width:70px; padding-right:5px;text-align:right; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="nt_amt" id="nt_amt" value="<? echo $l_tot ?>" type="text"></td>
</tr>
 <tr>
     <td>
<table class='tble2' width=100%>
<tr>
<td>
Less:
</td>
</tr>
<tr>
<td>MDA:</td>
<td><input  style="outline:none;border:1px solid grey; border-style:dotted; width:70px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" name="mba_amt" id="mba_amt" value="<? echo $irow[16] ?>" type="text" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup="calcval()"></td>

</tr>
<tr>
<td>Commission:</td>
<td><input style="outline:none;border:1px solid grey; border-style:dotted; width:70px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" name="cmsn_amt" id="cmsn_amt" value="<? echo $irow[17] ?>" type="text" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup="calcval()"></td>
</tr>
<tr>
<td>Discount:</td>
<td><input style="outline:none;border:1px solid grey; border-style:dotted; width:70px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" name="dscnt_amt" id="dscnt_amt" value="<? echo $irow[19] ?>" type="text" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup="calcval()"></td>

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



<?
$mrgnamt=($l_tot*($irow[23]/100));
$mrgnamt=number_format($mrgnamt, 2, '.', '');

?>
<td colspan="3"><table class='tble2' width=100%>
<tr>
<td>
Add:
</td>
</tr>
<tr>
<td>Margin:<input style="outline:none;border:1px solid grey; border-style:dotted; width:40px; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:black;" name="mrgn" id="mrgn" value="<? echo $irow[23] ?>" type="text" onKeyup="calcval()" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'>%</td>
<td><input style="border:0px solid white; width:50px; padding-right:5px;text-align:right; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="mrgn_amt" id="mrgn_amt" value="<? echo $mrgnamt ?>" type="text" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>


</tr>
<tr>

<td>P&F Charges:</td>
<td><input style="outline:none;border:1px solid grey; border-style:dotted; width:40px;text-align:right; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:black;" name="pfchrgs" id="pfchrgs" value="<? echo $irow[24] ?>" type="text" onKeyup="calcval()" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>
</tr> 
<tr>

<td>Other Charges:</td>
<td><input style="outline:none;border:1px solid grey; border-style:dotted; width:40px;text-align:right; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:black;" name="othrchrgs" id="othrchrgs" value="<? echo $irow[25] ?>" type="text" onKeyup="calcval()" onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>
</tr> 
</table></td>
</tr>  
<tr>
</tr> 
<tr>
<?
$sumtot=$l_tot-($irow[16]+$irow[17]+$irow[19])+$mrgnamt+$irow[24]+$irow[25];
?>

<td colspan=3> Net Amount:</td>
<td>                
<input style="border:0px solid white; width:100px; padding-right:5px; font-weight:normal;text-align:right; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name="sum_total" id="sum_total" value="<? echo $sumtot ?>" type="text">
</td>
</tr>
</table>
<script>
var cnt=1;
</script>
<div id="livesearch" style="display: inline-block;"></div>
<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='6'><hr></hr></td></tr>
<tr><td></td><td></td><td></td><td></td><td style="text-align:right;"><b>Payment Mode:</b></td><td style="text-align:right;"><select name='pmode' id='pmode'>

<option value='CREDIT'>CREDIT</option>
</select>

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

</body></html>
<script type="text/javascript">
function showitmtype(str,r,itid)
{
	var i=r.parentNode.parentNode.rowIndex;
	var tbl = document.getElementById('myTable');
   	var id1=tbl.rows[i].cells[0].innerHTML;
	var stvl;
	stvl=document.getElementById("itmvl"+id1).value;
	if(str=='D')
	{
		document.getElementById("itmvl"+id1).style.visibility = "visible";
  		document.getElementById("itmvl"+id1).focus();
	}
    	else 
	{	
		document.getElementById("itmvl"+id1).style.visibility ="hidden";
		document.getElementById("qty"+id1).focus();       
	}
   
 
}
</script>
