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

include("test.php");
include("opendb.php");
$taxtype=$_REQUEST[taxtype];
$intr=$taxtype;
$sea = $_REQUEST['sea'];
$exphd = $_REQUEST['exphd'];
if($sea)
{
    $customer = $exphd;
    $duetot=0;
    $invtot=0;
    $rcvdtot=0;
    $customer1 = substr($customer,0,strpos($customer,"(")-1);
    $sql="select invno,invdate,sum(tot),customer as tot from spareinvoice where (customer='$customer' or customer like '%$customer1%') and brcode='$brcode' group by invno";
    $re1=mysqli_query($db,$sql);
    print "<center><table><tr><br><br><h1>Customerwise Billwise Outstanding</h1></tr><tr><th>Customer</th><th>Invoice No.</th><th>Invoice Date</th><th>Invoice Amount</th><th>Payment Received</th><th>Balance Due";
    while($row=mysqli_fetch_array($re1))
    {
        $dinv=implode('-', array_reverse(explode('-', $row[1])));
        print "<tr><td>$row[3]</td><td>$row[invno]</td><td align=right>$dinv</td><td align=right>$row[2]</td>";
        $quer="select sum(amtreceived) amtreceeved from paymentreceipt where invno ='$row[0]' and brcode='$brcode' ";
        $res2=mysqli_query($db,$quer)or die('jour err:'.mysqli_error($db));
        $r2=mysqli_fetch_row($res2);
        $amtrcvd = $r2[0];
        $bal = round($row[2]-$amtrcvd,2);
        print "<td align='right'>$amtrcvd</td><td align='right'>$bal</td></tr>";
        $duetot+=$bal;
        $invtot+=$row[2];
        $rcvdtot+=$amtrcvd;
    }
    print "<tr><td colspan='3' align=center><b>T O T A L</td><td align='right'><b>$invtot</td><td align='right'><b>$rcvdtot</td><td align='right'><b>$duetot</td><td>";
    print "</table></center>";
}
?>
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>zf</title>
<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>
<link type="text/css" href="jquery/jquery-ui.min.css" rel="stylesheet" />	
<link rel="stylesheet" href="css/form.css" type="text/css" />
<script>
  $(function() {
    $( "#leddt" ).datepicker({ dateFormat: 'yy-mm-dd' });

  });
  
  $(function() {
    $( "#supdt" ).datepicker({ dateFormat: 'yy-mm-dd' });

  });
</script>
<script type="text/javascript">
$(function(){
  $(".exphd").live("keydown.autocomplete",function(){
  $led = $(this);
  $row = $led.parent().parent();
  $(this).autocomplete({
    source: function( request, response ) {
    $.ajax({
      url: "searchcustomer.php",
      dataType: "json",
      data: "key="+$led.val(),
      success: function( data ) {
        response( $.map( data, function( item ) {
          return {
            label: '<span class="la-code">'+item.led+' </span><span class="la-name">'+  item.partname + '</span>',
            value: item.led,
            name:item.partname,
            tax:item.tax,
            stock:item.stock,
            rate:item.rate,
            reduct:item.reduct,
            }
        }));
      }
    });
  }
  ,
  minLength: 2,
  select: function( event, ui ) {
  $row.find('.led').val(ui.item.value);
  $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>

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

 var count1=0;
 var empname=[];

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


</script>
<style>
#txt{
font-family: Arial, Helvetica;
background-color:#F2F2F2;

}
.la-code {
    display: inline-block;
    width: 300px;
}
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>
<style>


body {
    

  }


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

	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; 

	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;
 
	width:100px;
}

.button:hover { background:#ddd; }


#outPopUp{
     //position:absolute;
     width:800px;
     text-align:center;
    // height:300px;
    // z-index:15;
     //top:50%;
     //left:50%;
    // margin:-150px 0 0 -150px;
     //background:red;
}

</style>

   

<script>
$(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;
	});
});

 /* ********* below function is to get other values from vehmast as per regno or chasisno ********* */
</script>
<style>
.cont
	{
      

	
  	width: 100%;position: absolute ;
	height:99%;
    	/* Optional - just for DIV)*/
    	//border: solid 1px #000000;
	-moz-box-shadow: 0px 5px 5px #888;
	-webkit-box-shadow: 0px 5px 5px #888;
	box-shadow: 0px 5px 10px #888;
}
#pg{
       text-decoration:none;
       text-align: center;
       vertical-align: top;
}
.pgbtn{
      float:left;
margin-left: 10px;
height: 20px;
line-height: 22px;
text-align:center;
background-color:#fbfbfb;
border:1px solid #b7b7b7;
color:#606060;
cursor:pointer;
display:inline-block;
font:bold 100% Arial,sans-serif;
       
}
#msg {
    height:80px auto;
    background-color:grey;
    padding:2px;
    margin-top:0px;
    border-bottom:5px solid white;
    border:5px solid #F8F8FF;
    width:150px auto;
    text_align:center;
    display: none;
    position: fixed; left: 600px; top: 0; 
    z-index: 10;
    opacity: 0.8;
    z-index: 999;
    color:white;
     }
 
  .show_hide {
    display:none;
    }


/*  code below for search button* /


/* reset webkit search input browser style */
input[type=search] {
	outline: none;
}
input[type=search] {
	-webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;
}
input[type=search]::-webkit-search-decoration,
input[type=search]::-webkit-search-cancel-button {
	display: none; /* remove the search and cancel icon */
}

/* search input field */
input[type=search] {
	background: #ededed url(images/search-icon.png) no-repeat 9px center;
	border: solid 1px #ccc;
	padding: 9px 10px 9px 32px;
	width: 35px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
}
input[type=search]:focus {
	width: 130px;
	background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
}

/* placeholder */
input[type=search]:-moz-placeholder {
	color: #999;
}
input[type=search]::-webkit-input-placeholder {
	color: #999;
}

#reg_sea_bttn{

       background-color: #fff;
	border-color: #6dcff6;
	
	-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5);
	-moz-box-shadow: 0 0 5px rgba(109,207,246,.5);
	box-shadow: 0 0 5px rgba(109,207,246,.5);
      border: solid 1px #ccc;
	padding: 9px 10px 9px 2px;
	width: 30px;
	
	-webkit-border-radius: 10em;
	-moz-border-radius: 10em;
	border-radius: 10em;
	
	-webkit-transition: all .5s;
	-moz-transition: all .5s;
	transition: all .5s;
       outline: none;
        -webkit-appearance: textfield;
	-webkit-box-sizing: content-box;
	font-family: inherit;
	font-size: 100%;

 }
.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;
}	
</style>
<body background="back_ground.jpg" onload=shortkey_tblopen()><center>
<div class='cont'>
<table class="container"><tr><td>
<form name='f1' id='jforms' action='<?print $PHP_SELF?>'  method='post'> 
<br>
<table class="container" ><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;"> </font>
<br>
<center>


<center>
<form action="" method="POST" name='f2' >
<h1 style="  color: blue;" align=center>Customer Billwise Outstanding</h1>
<table border=1 class='tble1' width=70%>
<tr><td>Customer</td><td><input type=text size=60 name='exphd' id=exphd class=exphd></td><td><input type=submit value='Show' name='sea'></td></tr></table>
<br>  

</form>
</center>

<br><br>

</body>
</html>
</td></tr></table>

<style>
.comp{
  width:250px;
  }
</style>