<html>
 <head>
  <script>

     var  cnt;
     var flg=[];
     var typ=[];

    function check_receipt(str,id1){

      var k;
      for(k=1;k<cnt;k++){

        if(str==typ[k]){

           if(flg[k]=='bank'){
        
               document.getElementById('csh_rec'+id1).type='button';
               document.getElementById('bnk_rec'+id1).type='submit'; 

  
      
           }  

            if(flg[k]=='cash'){

               document.getElementById('csh_rec'+id1).type='submit';
               document.getElementById('bnk_rec'+id1).type='button';              

           } 

       }      
    }

   }

   </script>

  </head>
 <?
 session_start();
 include("opendb.php");
 include("test.php");
 if(strlen($user)<=0)
	{
  	print "<script> alert('Invalid User'); document.location='inde.php'; </script>";
  	return;
	}

 ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Xpress</title>
             
 		
	</head>

 		<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" />
		<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<link rel="stylesheet" href="cal/jquery-ui.css" />
  <script src="cal/jquery-1.9.1.js"></script>
  <script src="cal/jquery-ui1.js"></script>
  
  <script>


  $(function() {
    $( ".datepicker" ).datepicker();
    
  });



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



		<script type="text/javascript">

    			$(document).ready(function() {
       		 		var cont_left = $("#container").position().left;
       		 		$("a img").hover(function() {
          
           			 	$(this).animate({
               		 	height: "110",
               	 		width: "110",
              
            				}, "fast");
                    			}, function() {
            
                    			$(this).animate({
                    			height: "80",
                    			width: "80",
                
                    			}, "fast");
        	     	 });
        
        	      	$(".img").each(function(index) {

            				var left = (index * 160) + cont_left;
            				$(this).css("left", left + "px");
        	        });

                   });


	             (function($){

    					$.fn.enterNext = function(){
       				var _i =0;
       				$('input[type=text], select',this)
            				.each(function(index){
           				 _i = index;
            			 	$(this)
                			.addClass('tab'+index)
                			.keydown(function(event){
                    			if(event.keyCode==13){

                        			$('.tab'+(index+1)).focus();
                        			event.preventDefault();
                    			}
                	  });

             		})

     			$( "input[type=submit]",this ).addClass('tab'+(_i+1));

              	}})(jQuery);

            </script>



		<style>
th{background-color:steelblue;color:white}

.tbl1{
box-shadow: 0px 0px 10px 4px rgba(13, 68, 131, 0.75);
-moz-box-shadow: 0px 0px 10px 4px rgba(13, 68, 131, 0.75);
-webkit-box-shadow: 0px 0px 10px 4px rgba(13, 68, 131, 0.75);
}

.tbl{
box-shadow: 0px 0px 10px 4px rgba(13, 68, 131, 0.75);
-moz-box-shadow: 0px 0px 10px 4px rgba(13, 68, 131, 0.75);
-webkit-box-shadow: 0px 0px 10px 4px rgba(13, 68, 131, 0.75);
}			
</style>



<body bgcolor="#0033FF">
<div class='cont'>

<?php include('includes/top.php'); ?>
<br><br><br>
<center>
<form name='f1' action='<?print $PHP_SELF;?>' method='post'>
<table   align='center' width='50%' border='1' bgcolor='white' class='tbl1'>
<tr><th>PAYMENT MARKER</th></tr>
<tr><td align='center'><select name='ins' style='background:white;'><option value=''>-Select Insurance Company-</option>
<?
$xx=mysqli_query($db,"select distinct(inscomp) from jcardinvoice where brcode='$brcode' and  pmode='CREDIT' and marked_amt='0' order by inscomp ");
while($xx1=mysqli_fetch_array($xx))
{
 print "\n<option >$xx1[0]</option>";

}
?>
</select>
</td></tr>
<tr><td align='center'><input type='submit' name='show' value='Show' ></td></tr>
<tr><th height='20'></th></tr>
</table>
</form>
<br><br>
<?

if($show){

print "<table class='tbl' id='tbl'  align='center' width='100%' border='1' bgcolor='white' style='border-collapse:collapse;'>";
print "<form action='updpayment_marker.php' method='post' name='f2'>";
print "<tr><th>JCNO</th><th>Inv.No</th><th>Date</th><th>CR</th><th>DR</th><th>Net Total</th><th>Credit Note Amt</th><th>Net Amount</th><th>Marked Amount</th><th colspan=2>Action</th></tr>";
$i=1;

 

$qry=mysqli_query($db,"select (sum(amt)-depamt),sum(amt),invno,date,depamt,marked_amt,inscomp,jcno,regno from jcardinvoice  where inscomp='$ins' and pmode='CREDIT' and marked_amt='0' and brcode='$brcode' group by invno");

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

$r1="select * from gateentry where brcode='$brcode' and jcno='$row[7]'";
 $res1=mysqli_fetch_row($r1);
 $owner=$res1[15];
print "<input type='hidden' name='jcno[$i]' value='$row[7]'>";
print "<input type='hidden' name='regno[$i]' value='$row[8]'>";
print "<input type='hidden' name='cus[$i]' value='$owner'>";
print "<tr><td>$row[7]</td>";
print "<td><input type='text' name='invno[$i]' value='$row[2]' size=4  readonly></td>";
print "<td><input type='text' class='datepicker' name='date[$i]' value='$row[3]'  readonly size=9 ></td>";
print "<td><input type='text' name='cr[$i]' value='$row[6]' size=30></td>";
print "<td><select  name='dr[$i]' style='width:250px' onchange='check_receipt(this.value,".$i.")'>";

$j=1;
print"<script> cnt=1;</script>";
$dr_qry=mysqli_query($db,"select led from ledger where grp like '%bank%'");
$dr_qry1=mysqli_query($db,"select distinct(led) from ledger where led like '%cash%'");
   print "<option>-Select-</option>"; 
   print "<optgroup label='Bank'>";
   while($dr_res=mysqli_fetch_array($dr_qry)){

      print "<option>$dr_res[0]</option>";
      print"<script>flg[$j]='bank';typ[$j]='$dr_res[0]';cnt++;</script>";
      $j++;
   }
  print "</optgroup>";

     print "<optgroup label='Cash'>";
   while($dr_res1=mysqli_fetch_array($dr_qry1)){

      print "<option>$dr_res1[0]</option>";
      print"<script>flg[$j]='cash';typ[$j]='$dr_res1[0]';cnt++;</script>";
      $j++;


   }
  print "</optgroup>";


print"</select></td>";

$net=$row[1]-$row[4];
print "<td><input type='text' name='net_total[$i]' value='".$net."' size=6  readonly></td>";

print "<td><input type='text' name='cr_note_amt[$i]' value='$row[4]' size=6  readonly></td>";

print "<td><input type='text' name='net_amt[$i]'  size=6  value='$row[1]'  readonly></td>";

print "<td><input type='text' name='marked_amt[$i]' value='0' size=6></td>";

print "<td><input type=submit value='Cash' name='csh_rec' id='csh_rec$i' onClick='position_fix(".$i.")'/> </td><td><input type=submit value='Bank' id='bnk_rec$i' name='bnk_rec' onClick='position_fix(".$i.")'/></td></tr>";
$i++;
}
 print "<input type='hidden' name='pos' value='' id='pos'/>";
 print "<input type='hidden' name='pos1' value='$i' id='pos1'/>";
//print "<tr><th colspan='6' align='center'><input type='submit' name='upd1' value='Update All' ></th></tr></table></form>";
}
?>


<script>
function position_fix(str){
document.getElementById('pos').value=str;
}
</script>
