<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$pono = $_REQUEST['pono'];
$taxtype = $_REQUEST['taxtype'];
$vatorcst = $_REQUEST['vatorcst'];
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>amplcnew</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_work_sale1.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">
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,
						reduct:item.reduct,
							
						
					}
				}));
			}
		});
	}
	
,
	minLength: 2,
	select: function( event, ui ) {


	
	$row.find('.stok').val(ui.item.stock);
         if($row.find(".itmtyp").val()=='D')
            {
                $row.find('.partname').val(ui.item.name);
                $row.find('.stok').val(ui.item.stock);
                $row.find('.unitprice').val(ui.item.rate);
                $row.find('.tax').val(ui.item.tax);
                $row.find('.itmvl').val(ui.item.reduct);
                $row.find('.qty').focus();
            }
            else
                {
	
	
	/*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,
						rate2:item.rate2,
						reduct:item.reduct,	
						
						
					}
	
				}));
			}
		});
	}
	
,
	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);
	$row.find('.pur_rate').val(ui.item.rate2);
	$row.find('.tax').val(ui.item.tax);
	$row.find('.itmvl').val(ui.item.reduct);
	$row.find('.qty').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);
     };

					
});
});

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

function showHint1()
{
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","delete_invoice_sale1.php", true);
xmlhttp.send();
}

function viewinv1(str)
{
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","delete_invoice_sale.php?inno="+str,true);
xmlhttp.send();
}

</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 focq=x.insertCell(5);
var e1=x.insertCell(6);
var f1=x.insertCell(7);
var w1=x.insertCell(8);
var q1=x.insertCell(9);
var g1=x.insertCell(10);
var h1=x.insertCell(11);
var j1=x.insertCell(12);
var l1=x.insertCell(13);
var m1=x.insertCell(14);
var n1=x.insertCell(15);
var r1=x.insertCell(16);
var o1=x.insertCell(17);
var p1=x.insertCell(18);
var k;//=this.rowIndex;
var k1;
a.innerHTML=cur;
b1.innerHTML="<input type=text name=partcode[] id=partcode"+cur+"  class='partcode' size=3 autocomplete='off' list='partcodelist' onkeypress='handleEnter(this, event)'>";
c1.innerHTML="<input type=text name=partname[] id=partname"+cur+"  class='partname' size=8  autocomplete='off' list='partlist' onkeypress='handleEnter3(this, event)' >"; 
var v="";
v="<select name='itmtyp[]' id=itmtyp"+cur+" class='itmtyp' onchange='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[] class=itmvl value='0' size=1 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)' onKeyup='reductioncheck(this.value,this,this.id)' onfocus='sel(this.id)'  > ";
d1.innerHTML="<input type=text name='qty[]' class='qty' id=qty"+cur+" size=1 onKeyup='qtycheck(this.value,this,this.id)' onKeydown='insRow(event,this,this.id)' onkeypress='handleEnter(this, event)'>";

focq.innerHTML="<input type=text name='focqt[]' class='focqt' id=focqt"+cur+" size=1 onKeyup='qtycheck(this.value,this,this.id)' onKeydown='insRow(event,this,this.id)' onkeypress='handleEnter(this, event)'>";


e1.innerHTML="<input type=text name=unitprice[] readonly id=unitprice"+cur+" size=3 class='unitprice' 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)'>";
w1.innerHTML="<input type=text id='stfdisc"+cur+"' name=stfdisc[] value='0' 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;' class='stfdisc' onKeyup='stfdischeck(this.value,this,this.id)' onKeydown='insRow(event,this,this.id)' onkeypress='handleEnter(this, event)'><input type=text id='stfdiscvl"+cur+"' name=stfdiscvl[] value='0' style='outline:none;border:1px solid grey;width:50px; padding-left:7px; font-weight:normal;border-style:dotted; font-family:verdana;font-size:13px;visibility:hidden;' class='stfdiscvl'  readonly onKeydown='insRow(event,this,this.id)' onkeypress='handleEnter(this, event)'>";
q1.innerHTML="<input type=text id='rdctpr"+cur+"' name=rdctpr[] value='0' size=3 readonly class='rdctpr' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' >";
g1.innerHTML="<input type=text id='redct"+cur+"' name=redct[] readonly size=5 value='0' class='redct' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' >";
h1.innerHTML="<input type=text id='rebat"+cur+"' name=rebat[] readonly value='0' size=3 class='rebat' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' >";
j1.innerHTML="<input type=text id='kvic"+cur+"' name=kvic[] readonly value='0' size=3 class='kvic' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' >";
l1.innerHTML="<input type=text id='kvicspl"+cur+"' name=kvicspl[] readonly value='0' size=3 class='kvicspl' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'  >";
m1.innerHTML="<input type=text id='befrtx"+cur+"' name=befrtx[] readonly value='0' size=3 class='beftx' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' >";
n1.innerHTML="<input type=text id='tax"+cur+"' name=tax[] readonly value='0' size=3 class='tax' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'>";
r1.innerHTML="<input type=text id='taxamt"+cur+"' name=taxamt[] readonly value='0' size=3 class='taxamt' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'>"; 
o1.innerHTML="<input type=text id='ntamt"+cur+"' name=ntamt[] readonly value='0' size=3 class='ntamt'  onKeydown='return handleEnter(this, event)'>";
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

</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>

<script type="text/javascript">
			/*$(function() {
		
                                    $.datepicker.setDefaults( $.datepicker.regional[ "" ] );
                				$('#invoice_date').datepicker({ dateFormat: 'yy/mm/dd' } );
				$( "#customization_date_format" ).change(function() {
					$( "#invoice_date" ).datepicker( "option", "dateFormat", $( this ).val() );
				});
				$('#payment_due_date').datepicker({ dateFormat: 'yy/mm/dd' } );
				$( "#customization_date_format" ).change(function() {
					$( "#payment_due_date" ).datepicker( "option", "dateFormat", $( this ).val() );
				});
			});*/
var cal2 = new CalendarPopup();
cal2.showYearNavigation();

var cal3 = new CalendarPopup();
cal3.showYearNavigation();

var cal4 = new CalendarPopup();
cal4.showYearNavigation();

</script>


<style>
.tble1 input {
background-color:transparent;
border: 0px solid;


color:black;
font-size: 12px;
}
.tble1
{

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

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

}	
.tble1 td, th
{
border-collapse:collapse;
border:1px solid silver;
}
.tble1 tr
{
height:30px;
}
#tbl1{
 //margin-top:40px;
min-width:65%;
 text-align:center;
}

#tbltd1{
vertical-align: top;
margin-top:20px;
font-family:calibri;
 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:0px 20px 10px 20px;
 min-width:95%;
}
#conf_panel{  

        width:250px;
        margin-top:200px;
        position:fixed; 
        top: 1px;  
        left: 450px;  
        text_align:center;
        
        -moz-box-shadow: 0 0 2px 2px #888;
        -webkit-box-shadow: 0 0 2px 2px#888;
         box-shadow: 0 0 2px 2px #888;
     
        background-color: white;  
      
        color: black;  
        display: none; 
        border:1px solid #C2DFFF; 

    }  

.conf_tbl th{
  
    font-weight: bold;  
    color: white; 
    border:1px solid #D7D7D1;
    height:45px;
    border-collapse:collapse;

   

background: steelblue; /* Old browsers */
//background: -moz-linear-gradient(top, rgba(181,189,200,1) 0%, rgba(130,140,149,1) 36%, rgba(40,52,59,1) 100%); /* FF3.6+ */
//background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,189,200,1)), color-stop(36%,rgba(130,140,149,1)), //color-stop(100%,rgba(40,52,59,1))); /* Chrome,Safari4+ */
//background: -webkit-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Chrome10+,Safari5.1+ */
//background: -o-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* Opera 11.10+ */
//background: -ms-linear-gradient(top, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* IE10+ */
//background: linear-gradient(to bottom, rgba(181,189,200,1) 0%,rgba(130,140,149,1) 36%,rgba(40,52,59,1) 100%); /* W3C */
//filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b5bdc8', endColorstr='#28343b',GradientType=0 ); /* IE6-9 */

 }




.conf_tbl td{

    height:32px;
    border: 1px solid #A9A9A9;
  
  //text-align:left;
    // font-size:4 px;  
    color: black; 
background: -moz-linear-gradient(top, rgba(246,248,249,1) 0%, rgba(229,235,238,0.94) 50%, rgba(215,222,227,0.94) 51%, rgba(233,237,240,0.91) 81%, rgba(245,247,249,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(246,248,249,1)), color-stop(50%,rgba(229,235,238,0.94)), color-stop(51%,rgba(215,222,227,0.94)), color-stop(81%,rgba(233,237,240,0.91)), color-stop(100%,rgba(245,247,249,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,0.94) 50%,rgba(215,222,227,0.94) 51%,rgba(233,237,240,0.91) 81%,rgba(245,247,249,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,0.94) 50%,rgba(215,222,227,0.94) 51%,rgba(233,237,240,0.91) 81%,rgba(245,247,249,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(246,248,249,1) 0%,rgba(229,235,238,0.94) 50%,rgba(215,222,227,0.94) 51%,rgba(233,237,240,0.91) 81%,rgba(245,247,249,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(246,248,249,1) 0%,rgba(229,235,238,0.94) 50%,rgba(215,222,227,0.94) 51%,rgba(233,237,240,0.91) 81%,rgba(245,247,249,1) 100%); /* W3C */
//filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 ); /* IE6-9 */



 }

.conf_tbl input[type="text"]  {
   // padding: 0px 5px 0px 5px;
    border-style:none;
    border-color: white;//transparent;
    background-color: transparent;
   // font-size:12px;

}
.conf_tbl input[type="select"]  {
   // padding: 0px 5px 0px 5px;
    border-style:none;
    border-color: white;//transparent;
    background-color: transparent;
   // font-size:12px;
height:25px;
}

</style>
<script>

/** code below for drag the confirmation div */
window.onload = function(){
    //draggable('conf_panel');
};
window.onload = function(){
    //draggable('aditem_panel');
};
var dragObj = null;
function draggable(id)
{
    var obj = document.getElementById(id);
    obj.style.position = "absolute";
	
	//obj.style="left:300px;top:150px;"
    obj.onmousedown = function(){
            dragObj = obj;
    }
}

document.onmouseup = function(e){
    dragObj = null;
};

document.onmousemove = function(e){
    var x = e.pageX;
    var y = e.pageY;

    if(dragObj == null)
        return;

    dragObj.style.left = x +"px";
    dragObj.style.top= y +"px";
};
function showrebtvl(str)
    {
	if(str=='Yes')
            {
                document.getElementById("rbtvl").style.visibility = "visible";
            }
        else
            {
                document.getElementById("rbtvl").style.visibility ="hidden";
       
            }
   
 
}
function chkey(abc)
{
 yy=abc.value
 if(yy.length>35)
 { 
   alert('Name exeeds the limit');
   return;
 }

 if(yy.indexOf('  ')>-1) 
  {
    alert('Multiple space is not allowed');
    abc.value='';
  }
 if(yy.indexOf("'")>-1) 
  {
    alert("\' is not allowed");
    abc.value='';
  }
 if(yy.indexOf('"')>-1) 
  {
    alert("\" is not allowed");
    abc.value='';
  }

}
</script>



<?php

$re=mysqli_query($db,"select max(invno) from spareinvoice where brcode='$brcode'");
if(mysqli_num_rows($re)<1)
{
	$inv='000001'; 
}
else
{
	$row=mysqli_fetch_array($re);

       $inv=substr($row[0],-6)+1;
	$inv=substr('000000'.$inv,-6);

	if($inv==0)
	{
		$inv='000001'; 
	}
	$inv=$inv; 
}

?>

<div align='left'><font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Sale Order>>  invoice</font></div>

<body style="background-image:url(images/bg.jpg);" onload="document.getElementById('to_new_customer').focus();if (document.invoice_form.RadioGroup1[0].checked == true) 
		{shortkey_tblopen();
  		}">
        
<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;">
		sale Order Sale</h1></td></tr>
		
		<tr>
 

                <td><a href='invoicesale_editinv1.php' style="text-decoration:none;"><input style="height:32px;width:110px;" value="Edit"  type="submit" ></a></td>

                <td><a href="#pop2" id="linkss" onclick='showHint1()' style="text-decoration:none;"><input value="Delete"  style="height:32px;width:110px;" type="submit" ></a></td>
			
			
		<td><a href='accounts/payrec/prncshrec.php?no=' target='blank' style="text-decoration:none;"><input style="height:32px;width:110px;" value="Print"  type="submit" ></a></td>
		<td><input style="height:32px;width:110px;" type="button" onclick="myFunction()" value="Reset"></td>
		 <td><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>
<td align='right'></td>
		 <td align='right'></td><td><?php include('help_window.php'); ?></td>
           </tr>
	
<tr><td id='tbltd1' colspan='7'>


<div>
<fieldset style="border:2px solid grey; border-style:dotted;">
<legend style="text-align:center;">SPARE INVOICE 8B-VAT</legend>
<form id="jforms" name="invoice_form" method='post'>
<table class='tbl2' id='tbl2' > 				                    
<tr>
<td align='center' colspan='4'>Tax Type
<select name='vatorcst'>
<option>VAT</option>
<option>CST</option>
</select>

Type
<select name='taxtype'>
<option>8B</option>
<option>8</option>
</select>
<?
$sq=mysqli_query($db,"select distinct orderno from saleorder_spare where brcode='$brcode' and sqty>sup_qty and closed ='N' order by orderno desc")or die (mysqli_error($db));
print "Sale Order No";
print "<select name='pono'>";
print "<option>--select--</option>";
while($pn=mysqli_fetch_array($sq))
{
print "<option>$pn[orderno]</option>";
}
print "</select>";

?>
<input type=submit value="Next->" name="sv"></td>
</tr>	
<?
include("exqty.php");
//include ("calcsparestock.php");
$result=mysqli_query($db,"select * from saleorder_spare where orderno='$pono' and brcode='$brcode' and closed='N'");
$row=mysqli_fetch_array($result);

$cusres=mysqli_query($db,"select * from customer where acname='$row[orderto]'");
$cusrow=mysqli_fetch_array($cusres);
?>

<tr>	
<td align='left' style="width:110px;">
Customer name</td>
<td  id="to_new_customerTD">
<select name='customer'><option value='<?echo $row[orderto]; ?>'><?echo $row[orderto]; ?>
</option></select>
     
</td>
  <td >
  </td>                  
<td style="text-align:right;">
 Sale Bill No.# 
   <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 $inv;?>" type="text" readonly onKeydown="return handleEnter(this, event)">

</td></tr>
<tr><td align='left'>               
    Sale Order No </td>
<td id="to_new_registerTD">       
      <input value='<? echo $row[orderno];?>' name='saleordno' 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="Sale order no" type="text" onKeydown="return handleEnter(this, event)">
             
</td><td >   

   </td>
  <td style="text-align:right;"  id="invoice_dateTD">     Entry Date          
<input id="invoice_date" name="invdate" style="width:141px;outline:none;border:1px solid grey; border-style:dotted; cursor:pointer;background: url(img/cal.gif) 120px 2px no-repeat; padding-left:7px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" onClick="cal2.select(document.forms[0].invdt,'anchor1','yyyy-MM-dd'); return false;"  readonly  type=text  value="<? echo date('Y-m-d'); ?>" onKeydown="return handleEnter(this, event)">
<A HREF="#"  TITLE="Click for Calander" NAME="anchor1" ID="anchor1"></A>

  </td></tr>

<tr><td align='left'>Sale Order Date  
</td>
<td> 

 <input  value='<? echo $row[date];?>' 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;"  type="text" onKeydown="return handleEnter(this, event)">               
</td>
  
<td >
</td> 
<td align="right">
    MSNO# 
   <input  name='msno' 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 $row[msno];?>" type="text" readonly onKeydown="return handleEnter(this, event)">
  </td>  
 </tr>




<tr><td align='left'>Engineer </td><td>
<select name='engineer' 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;">
<option>Counter Sale</option>
<?
$enres=mysqli_query($db,"select * from empmaster where design like '%eng%' order by empname");
while($enrow=mysqli_fetch_array($enres))
{
 print "<option>$enrow[empname]</option>";
}
?>
</select>
</td>
<td>
</td>
<td align="right">
<font color=red>Payment Type

<select name='paytype' 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;">
<option></option>
<option>Credit</option>
<option>Cash</option>
</select>
</td>
</tr>
<tr>
<td>Address</td>
<td><input  name='addr' 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="textarea" ></td>
<td></td>
<td align="right">Tin No<input  name='tin' 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" ></td>
</tr>
<tr>
<td>Ref</td><td><input  name='ref' 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="textarea" ></td>
</tr>
<tr><td colspan='4'>      

<table border=1 id="myTable" class='tble1' width=100%>
<tr class='trcls'><td>No.</td><td>Part Code</td><td>Part Name</td><td>Ord Qty</td><td>Sale QTY</td><td>Mrp</td><td>Price</td><td>Disc%</td><td>A Price</td><td>Hand Charge</td><td>Vat%</td><td>Tax Amt</td><td>Cess%</td><td>Cess Amt</td><td>Total</td><td>Del</td></tr>

<?
if(isset($_POST[sv]))
{

    $taxres=mysqli_query($db,"select tax from taxmaster where type='$taxtype'");
    $taxrow=mysqli_fetch_row($taxres);
    $tax=$taxrow[0];
$i=1;
$result=mysqli_query($db,"select * from saleorder_spare where orderno='$pono' and brcode='$brcode' and sqty>sup_qty and closed='N'");
while($row=mysqli_fetch_array($result))
{
 $itmres=mysqli_query($db,"select * from partmaster where partcode='$row[0]'");
 $prtrow=mysqli_fetch_array($itmres);

 $prres=mysqli_query($db,"select * from spareprmast where partcode='$row[0]' order by effectfrom desc");
 $prrow=mysqli_fetch_array($prres);
 if(mysqli_num_rows($prres)<=0)
 {
  print "<tr><td colspan=10 align=center><font color=red>$row[0] - Price could not be found</font></td></tr>";
 }
      
$availqty=exqty1($row[0],$brcode,$user);        
print "\n<input type=hidden   name='availqty[]' id='availqty$i' value='$availqty'>";
 
    
?>
      <tr><td><? echo $i ?></td>
      <?
      print "<td><input type=text name='partcode[]' value='$row[0]' id='partcode$i' class='partcode' autocomplete='off' list='partcodelist'></td>";
      print "<td><input type=text name='partname[]' value='$row[1]' id='partname$i' class='partname' autocomplete='off' list='partlist'></td>";
      print "<td><input type=text name='qty[]' class='qty' id='qty$i' size=2 value='$row[sqty]' onKeydown='return handleEnter(this, event)' onKeyup='qtycheck(this)'></td>";
      print "<td><input type=text name='supqty[]' id='supqty$i' size=3 value='$row[sqty]'  onKeydown='return handleEnter(this, event)' onKeyup='qtycheck(this)'></td>";
if ($brcode=='PSN980' || $brcode=='PSN470')
	$mprice = $row[rate];
else
	$mprice = $prrow[lstprice];

if($prrow[mrp]==0)
{
      print "<td><input type=text name='mrp[]' id='mrp$i' size=3 value='0' onfocus='sel(this.id)' onKeydown='return handleEnter(this, event)'></td>";
}
else
{
      print "<td><input type=text name='mrp[]' id='mrp$i' size=3 value='$prrow[mrp]' onfocus='sel(this.id)' onKeydown='return handleEnter(this, event)' onKeyup='qtycheck(this)'></td>";
}   
      print "<td><input type=text name='price[]' id='price$i' readonly value='$mprice' size=3 onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>";
if($level =='5')
      print "<td><input type=text name='disc[]' id='dis$i' readonly size=3 value='0' onChange=calc(this.id) onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>";
else
  print "<td><input type=text name='disc[]' id='dis$i' readonly size=3 value='0' onChange=calc(this.id) onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>";

if ($brcode=='PSN980' || $brcode=='PSN470')
	$maprice = $row[rate]*$row[sqty];
else
	$maprice =  $prrow[lstprice]*$row[sqty];

      print "<td><input type=text name='aprice[]' value = '$maprice' id='aprice$i' readonly size=3 onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' onKeyup='insRow(event,this,this.id)'></td>";
      print "<td><input type=text name='hand[]' id='hand$i' size=3 value='0.00' readonly size=3 class='tot' onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)'></td>";
if($vatorcst=='CST')     
      print "<td><input type=text name='tax[]' id='tax$i' readonly value='3' size=3 onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' ></td>";
else
      print "<td><input type=text name='tax[]' id='tax$i' readonly value='14.50' size=3 onKeydown='return handleEnter(this, event)' onChange=calc($i)></td>";
$mtaxamt = round($maprice * 14.5/100,2);

      print "<td><input type=text name='taxamt[]' id='taxamt$i' value='$mtaxamt' readonly  size=3 onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' ></td>";

if($vatorcst=='CST')
      print "<td><input type=text name='cessp[]' id='cessp$i' value='$prtrow[cessonvat]' readonly  size=3 onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' ></td>";
else
      print "<td><input type=text value='0.00' name='cessp[]' id='cessp$i' readonly  size=3 onKeydown='return handleEnter(this, event)' onfocus='sel(this.id)' ></td>";
$mcessamt = round($mtaxamt * 0/100,2);    
      print "<td><input type=text name='cessamt[]' id='cessamt$i' value='$mcessamt' readonly  size=3 class='ntamt'  onKeydown='return handleEnter(this, event)'></td>";
$mtot = $maprice + $mtaxamt + $mcessamt;
      print "<td><input type=text name='tot[]' id='tot$i' value='$mtot' readonly size=3 class='ntamt'  onKeydown='return handleEnter(this, event)'></td>";
      print "<td><input type='button' onClick='delrow(this)' class='del' id='del$i'></td> </tr>";

         
         $i++;
}
}
?>
</table>

<script>
var cnt=1;
</script>

<div id="livesearch" style="display: inline-block;"></div>

<input type='hidden' name='savecount' id='savecount' value='0'>

<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='2' style="text-align:right;">
                      
                    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="0.00" type="text">
</td></tr>

<tr><td></td><td></td><td colspan='2' style="text-align:right;">                  
              Net 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>

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

</body></html>


<script type="text/javascript">
 function delfun(x)
 {
 	if (confirm('do you want to delete '+x+' ?'))
		{
			document.location='delinvoicesale.php?code='+x;
		}
 
 }
  
</script>





