<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<html>


<?
session_start();
include("opendb.php");
include("test.php");
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
?>
<head>
<title>LPO  LIST </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 type="text/css" href="css/form.css" rel="stylesheet" />




<link rel="stylesheet" type="text/css" media="all" href="jsDatePick_ltr.min.css" />
<script type="text/javascript" src="jsDatePick.min.1.3.js"></script>

<script type="text/javascript">
	window.onload = function(){
		new JsDatePick({
			useMode:2,
			target:"inputField1",
			dateFormat:"%Y-%m-%d"
			
		});
		new JsDatePick({
			useMode:2,
			target:"inputField2",
			dateFormat:"%Y-%m-%d"
			
		});
		new JsDatePick({
			useMode:2,
			target:"fromdt",
			dateFormat:"%Y-%m-%d"
			
		});
		new JsDatePick({
			useMode:2,
			target:"todt",
			dateFormat:"%Y-%m-%d"
			
		});
              
	};
</script>


<style>
 th{
  

   // background-color: grey;  
    font-weight: bold;  
    color: white; 
    border:1px solid #D7D7D1;

    border-collapse:collapse;
   

background: rgb(181,189,200); /* 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 */

 }

.ro_settled td
 {
background: #6bba70; /* Old browsers */
background: -moz-linear-gradient(top, #6bba70 0%, #6bba70 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6bba70), color-stop(100%,#6bba70)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #6bba70 0%,#6bba70 100%); /* IE10+ */
background: linear-gradient(to bottom, #6bba70 0%,#6bba70 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6bba70', endColorstr='#6bba70',GradientType=0 ); /* IE6-9 */
color:white;
 }

</style>
<STYLE>

#popup {

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


       background-color:#3b5998;

	//background:url(images/bg-inner.jpg) #e9e0c3 repeat-x;
  	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;
    
	}









        #conf_panel,#csh_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: rgb(181,189,200); /* 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;

}


 </style>





<body background="back_ground.jpg">
<?php //include('logo2.php'); ?>
<?php include('includes/top.php'); ?>
<form action='<?print $PHP_SELF?>' method='post' >

<br>
<table class="container"><tr><td>

<br>

<center>

<!-- below div for the purpose of bank save -->


<div id="popup">
<table height='100%' width='100%' class='report' >

   <tr><td colspan=2 align='right'><input type="button" value='X' id='close'  onclick='close_div1();'/></td></tr>
   <tr> <td>Select Bank:</td><td><select name='bnk_name' id='bnk_name' style='width:150px;'>
 <?
   $select=mysqli_query($db,"select * from ledger where grp='Bank accounts' or grp='Bank O/d' and brcode='$brcode' order by led") or die("ERR6:".mysqli_error($db));
    print "<option></script>";
   while($row=mysqli_fetch_array($select)){

         print "<option>$row[0]</script>";
    }
  ?>
    </select>

  </td> </tr>
  <tr> <td>Date:</td> <td><input type="text" id="inputField1" value="<?echo date('Y-m-d');?>" name="dt" readonly  ></td></tr>
   
    <tr> <th colspan=2><input id="dpr_id" type="hidden"/>

<input type='button' name='add_ban_amt' value='Post' onclick="acc_fun1('bank')" />
   </th></tr>   </table>
</div>



<!-- below div for get cash date-->
<div id="csh_panel" class="alist" style="display:none;">
  
   <form name='form3'>
          <table  border='1' class='conf_tbl' style="border_collpase:collapse;background-color:white;  " width='100%'>
  
         <tr><th colspan=2>Add Date  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &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> JobNo:</td> <td><input type='text' name='id1' id='dpr_id_csh' readonly  size=8/></td></tr>

 	  
         <tr> <td>Date:</td> <td><input type="text" id="inputField2" value="<?echo date('Y-m-d');?>" name="dt" readonly  ></td></tr>

  	 <tr>  <th colspan=2><input type='button' name='add_amt' value='Save' onclick="acc_fun('Cash')"/> </td></tr>

  
  </table>
 </form>

</div>




<table class="form" style="width:auto;" align='center' >
<tr><th style="background:grey;">LPO LIST</th></tr>
<tr><td>Show LPO Report From <input type="text" id="fromdt" value="<?echo date('Y-m-d');?>" name="fromdt" readonly  >
 To <input type="text" id="todt" name="todt" value="<?echo date('Y-m-d');?>" readonly > </td></tr>
<tr><td align='center'>
<input type='submit' name='show' value='Show' ></td></tr></form>
</table>

<br><br>

<?
if($show)
{

         $i=1;
         $qry=mysqli_query($db,"select * from down_payment where brcode='$brcode' and date between '$fromdt' and '$todt' and typ='LPO' order by jcno,date ");


         print "<table class='report' border='1'>";
	  print "<tr><th>SlNo</th><th>Date</th><th>Jc.no</th><th>Regno</th><th>Customer</th><th>DPR Amt</th><th>Acc.Type</th><th>JourNo</th><th>Remark</th><th>Action</tr>";

	  while($row=mysqli_fetch_array($qry))
	  {  

		print "<tr><td>".$i++."</td><td>".datetoHtml($row[5])."</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td align='right'>$row[4]</td><td>$row[9]</td><td >$row[6]</td><td >$row[10]</td>";

              print "<td id='acc_bttn'><input type='hidden' value='".$fromdt."' name='fromdt1' ><input type='hidden' value='".$todt."' name='todt1' > <input type='button' name='bank' value='bank' onclick='showPopup($row[0])'/></td></tr>";
         }	
       

	 print "</table>";

    			
} 

?>
</body>
<script>

   function acc_fun(flag){

 var id=  document.getElementById('dpr_id_csh').value;
 var dt=document.getElementById('inputField2').value;
 var r=confirm("Do you want to save cash receipt");

 if (r==true)
  {

    document.getElementById('acc_bttn').innerHTML="Loading...";

 	 if (window.XMLHttpRequest)
  		{
  		xmlhttp=new XMLHttpRequest();
 		 }
		else
 		 {
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  	 		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	 		{
            			alert(xmlhttp.responseText);

                            window.open('accounts/dpr_voucher.php?id='+id);

                            document.location='lpo_list.php';

       
        		}

      		}
    
 xmlhttp.open("GET","ajaxupd_acc_down_amt.php?id="+id+"&&flag="+flag+"&&dt="+dt,true);
 xmlhttp.send(); 

  }//close confirm box
  
 }//close fun



function acc_fun1(flag){

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

 




if (r==true)
  {
 	document.getElementById("popup").style.display = "none";
 	var id=document.getElementById('dpr_id').value;
	var dat1=document.getElementsByName("fromdt1")[0].value;
	var dat2=document.getElementsByName("todt1")[0].value;
       var bnk_name=document.getElementById('bnk_name').value;
	var dt=document.getElementById('inputField1').value;
	document.getElementById('acc_bttn').innerHTML="Loading...";

 	 if (window.XMLHttpRequest)
  		{
  		xmlhttp=new XMLHttpRequest();
 		 }
		else
 		 {
  			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  		}
		xmlhttp.onreadystatechange=function()
  		{
  	 		if (xmlhttp.readyState==4 && xmlhttp.status==200)
    	 		{
            			 alert(xmlhttp.responseText);
                         
                            window.open('accounts/dpr_voucher.php?id='+id);

                           document.location="lpo_list.php?show='show'&&fromdt="+dat1+"&&todt="+dat2;
                            
                         

       
        		}

      		}




    
xmlhttp.open("GET","ajaxupd_acc_down_amt.php?id="+id+"&&flag="+flag+"&&dr="+bnk_name+"&&fromdt="+dat1+"&&todt="+dat2+"&&dt="+dt,true);
 xmlhttp.send(); 


  }//close confirmation 

}//close fun..





function showPopup(id) {
   document.getElementById("popup").style.display = "block";
     document.getElementById("dpr_id").value=id;
	document.getElementById("fromdt1").value=dat1;
     document.getElementById("todt1").value=dat2;

}
/**  below function for get date while cash savings... ****/
function fun_csh(id1){

    var e = document.getElementById('csh_panel');

    document.getElementById('dpr_id_csh').value=id1;

    if(e.style.display == 'block') {
        e.style.display = 'none';
    } else {
        e.style.display = 'block';
    }
 }




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

 }

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('csh_panel');
   		 if(e.style.display == 'block') {
       		 e.style.display = 'none';
   		 } else {
        	e.style.display = 'none';
              }

 }


</script>

