<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='index.php' </script>";
  return;
}

?>
<title>AMPL</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="scripts/jquery-latest.js"></script>
<link type="text/css" href="includes/style1.css" rel="stylesheet" />
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script type="text/javascript">
        $(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();
				})
          }
        });        
</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color:#F2F2F2;

}
th{background-color:steelblue;color:white}
table.form{
font-weight: normal;border:1px;
} 
</style>
<STYLE>

#popup 
{
position: fixed; top: 60%; left: 60%; width: 200px; height: 100px; margin-left: -300px; margin-top: -200px;
  display:none;
}
</STYLE>
<body>

<?php //include('includes/top.php'); ?>

<table class="container" style="background-color:#F6E3CE" ><tr><td>
<div id="popup" class="alist" style="display:none;">
<form name='form1'>
<table height='100%' width='100%' class='report' id='tbl'>
    <?
  
    $select=mysqli_query($db,"select * from itemsale where id='$invno' and brcode='$brcode'") or die("ERR6:".mysqli_error($db));
    ?>
  <tr><th colspan=2>Add Customer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value='X' id='close' onclick='close_div();'/></th></tr>
   <tr> <td>Select Customer:</td><td><select name='cst_name' id='cst_name'>
 <?
   while($row1=mysqli_fetch_array($select)){

         print "<option>$row1[customer]</option>";
    }
  ?>
    </select>
    </td> </tr>
    <tr> <td>Date:</td> <td><input type="text" id="inputField1" value="<?echo date('Y-m-d');?>" name="dt" ></td></tr>
    <tr> <td>Narration:</td> <td><input type="text" id="narrt" name="narrt"><input type='text' id='dpr_id' ></td></tr>
    <tr> <th colspan=2>
	<input type='button' name='btbnk' value='Post' onclick="acc_fun1('bank')">
    </th></tr>   </table>
     </form>
     </div>

<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px; color:black;">  &nbsp;&nbsp;REPORT >> Invoice Report</font>
<br>
<link rel="stylesheet" href="style.css" type="text/css" />
<script>
function valid()
{ 
 subOK="false";
 x=confirm("Do you want to save?");
 if(x)
  subOK="true";
   if(subOK=="true")
     return true;
   else
     return false;
} 

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>
<script type="text/javascript">

/***********************************************
* Disable "Enter" key in Form script- By Nurul Fadilah(nurul@REMOVETHISvolmedia.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
                
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;
		} 
		else
		return true;
	}      

</script>

<center>
<table cellspacing=1 cellpadding=2 class='form'>
<tr height=21><td colspan=2 align=center bgcolor='steelblue'><FONT COLOR=white><B>INVOICE REPORT</td></tr>
</td></tr>

<table cellspacing=1 cellpadding=3 class='report' >
<th>No.<th>InvoiceNo <th>Date<th>Supplier/Customer<th>BillNo <th>BillDate<th>Spares 5%<th>Spares 5.50%<th>spares 14.50%<th>lubetax<th>servicetx<th>sbc<th>kkcs<th>others <th>roundof<th>Total<th>Action
<?
$re=mysqli_query($db,"select * from itemsale where brcode='$brcode' order by invdate asc")or die(mysqli_error($db));
$i=1;
while($row=mysqli_fetch_array($re))
{
 print "<form action='' name='form' method='POST'>\n<input type=hidden name='code' value='$row[0]'><input type=hidden name='cname' value='$row[0]'>";
 print "\n<tr ><td>".$i++."</td><td>$row[invno]</td><td>$row[invdate]</td><td>$row[customer]</td><td>$row[vehno]</td><td>$row[bildt]</td><td>$row[sprfivetax]</td><td>$row[sprfvpnt]</td><td>$row[sprfrtntx]</td><td>$row[lubtx]</td><td>$row[servtx]</td><td>$row[sbc]</td><td>$row[kkcs]</td><td>$row[others]</td><td>$row[roundof]</td><td>$row[total]</td>";
$tsno=intval($row[invno]); 
$loanno=intval($row[invno]); 

//print "<td>\n<input type=submit value='POST' name='edit'></td>";
if($row[jrstus]==0)
{

print "<td id='acc_bttn'><input type='button' name='bank' value='POST' onclick='showPopup($row[id])'/></td>";
}
else
{


print "<td style='color: red;'>Already Posted</td>";


}
print "</tr></form>";
}
?>
</table>

</td></tr></table>
<script>
function emichrt(lnno)
{
//window.open('chart.php?loanno='+lnno);
document.location="chartnew.php?loanno="+lnno,true;
}
function view_files(lnno)
{
window.open('view_uploaded_files.php?lnno='+lnno,'popup','width=1000,height=700,toolbar=no,status=yes,location=yes,                                               menubar=no,directories=yes,scrollbars=yes,resizable=yes');
}
function showPopup(id) 
{
   
   document.getElementById("popup").style.display = "block";
   document.getElementById("dpr_id").value=id;
}

function acc_fun1(flag,r){

 var r=confirm("Do you want to save bank receipt");

 if (r==true)
  {
 	//var i=r.parentNode.parentNode.rowIndex;
        
   	var id=document.getElementById('dpr_id').value;
    var bnk_name=document.getElementById('bnk_name').value;
	var dt=document.getElementById('inputField1').value;
	var narrat=document.getElementById('narrt').value;

	//alert(id);
      //document.location="ajaxupd_acc_down_amt.php?id="+id+"&&flag="+flag+"&&dr="+bnk_name+"&&dt="+dt+"&&narratn="+narrat,true;

   }
		 

}//close fun..

function close_div(){
   var list = document.getElementsByClassName("alist");
             for (var i = 0; i < list.length; i++) {
               list[i].style.display = 'none';
             }
    		var e = document.getElementById('conf_panel');
   		 if(e.style.display == 'block') {
       		 e.style.display = 'none';
   		 } else {
        	e.style.display = 'none';
              }

 }

</script>