<? 
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
include("test.php");
include("opendb.php");
include("includes/function.php");
if(strlen($user)<=0)
{
  print "<script> alert('Session timed out'); parent.document.location='index.php'; </script>";
  return;
}
$jtype=$_REQUEST[jtype];
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>AMPLC</title>
<style>
#txt{
font-family: Arial, Helvetica;
background-color: #F2F2F2;

}


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

</style>
<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="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>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link type="text/css" href="css/form1.css" rel="stylesheet" />

<?php //include('includes/top.php'); ?>
<script type="text/javascript">
$(function(){

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

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

		$.ajax({
			url: "search13.php",
			dataType: "json",
			data: "key="+$inno.val(),
			success: function( data ) {
				response( $.map( data, function( item ) {
					
					
					return { 
						label: '<span class="la-code">'+item.inno+' </span><span class="la-name">'+  item.partname + '</span><span class="la-stok"> '+ item.stock +'</span><span class="la-rate"> '+item.rate +'</span>'    ,
						value: item.inno,
						name:item.partname,
						tax:item.tax,
						
						stock:item.stock,
						rate:item.rate,
						reduct:item.reduct,
							
						
					}
				}));
			}
		});
	}
	
,
	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('.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>
<body style="text-align: center; height:100%;width:100%;margin: 0 auto !important;">
<br><br><br><br>
 <?
  $qry=mysqli_query($db,"select max(tr_no) from journal2 where brcode='$brcode' and j_type='$jtype' order by tr_no");
$sql="select max(tr_no) from journal2 where brcode='$brcode' and j_type='$jtype' order by tr_no";

$row=mysqli_fetch_array($qry);
 ?>
 
<table align='center'>
<form name='f1' action='print_receipt.php' onsubmit="return validateForm()"  >
           <tr><td> <b>Invoice Number:</b></td><td>
<input type='text' name='inno' id='inno' class='inno' value='<? echo $row[0] ?>'>
<input type='text' name='jtype'  value='<? echo $jtype ?>'>
</td><td ><input type='submit' name='edit' value='Print' ></td></tr>
</table>
</body>