<?
session_start();
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
//$br=$_SESSION['branch'];
include_once("includes/function.php");

if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='inde.php'; </script>";
 return;
}
$rs=mysqli_query($db,"select max(crno) from cshrec where brcode='$brcode'");
$cr_row=mysqli_fetch_row($rs);
 if($cr_row[0]<=0)
   $crno=1;
 else   
   $crno=$cr_row[0]+1;
?>
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>World Wide Automotive Center</title>
<script type="text/javascript">

  var rawTags;
   var inputField;
   var  initInputFieldValue;
   var dataList;
    var initNbVirgules ;




<?



$select=mysqli_query($db,"select * from ledger where grp != 'Cash in hand' and grp!='Sundry Debtors' and brcode='$brcode' order by led asc ") or die("ERR6:".mysqli_error($db));
$select1=mysqli_query($db,"select distinct led from ledger where grp ='Sundry Debtors' and brcode='$brcode' order by led asc") or die("ERR6:".mysqli_error($db));
   $xxx="[";
 while($row=mysqli_fetch_array($select))
 
   {
        $xxx.='"'.$row[0].'",';

   
    }
 while($row1=mysqli_fetch_array($select1))
 
   {
        $xxx.='"'.$row1[0].'",';

   
    }  

  
   $xxx.="]"; ?>
rawTags=<?echo $xxx;?>;

 //rawTags = ["alf", "alfred", "alphonse", "bart", "batman", "calimero", "dora", "einstein", "jimmy", "joe dalton", "timo", "trollface", "william dalton", "pikachu"];


  function xx(str,event,this1)
  {


  var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;


 	if (keyCode == 37){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                     document.getElementById('myTable2').rows[row-1].cells[5].getElementsByTagName("input")[0].focus();

	 }

     
 	if (keyCode == 38){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                    // document.getElementById('myTable2').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();

	 }

       
 	if (keyCode == 40){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                     //document.getElementById('myTable2').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();

	 }

         if (keyCode == 46){
			  var i=this1.parentNode.parentNode.rowIndex;
			  
                       var r=confirm("Do you want to delete the row?");
			  if (r==true)
 				 {
 					//document.getElementById('myTable2').deleteRow(i);
					delRow2(this1);
                                  document.getElementById('myTable2').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable2').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 }
			  
        }

 inputField = document.getElementById(str);

 initInputFieldValue = inputField.value;
 dataList = document.getElementById('htmlListTags');

		if(keyCode!='40')
              {
                if(keyCode!='38')
              {
         

yy(str,event,this1); 


}
 


     }
 
 }

  function yy(str,event,this1)
    {


     initNbVirgules = (initInputFieldValue.match(/,/g)||[]).length;
fillDatalist("",str,event,this1);

    } 
  
function fillDatalist(prefix,str,event,this1) {



	var nbRawList = rawTags.length;
       
	while(dataList.childNodes.length > 0) {
		dataList.removeChild(dataList.childNodes[0]);
	}
	
	for (i=0; i < nbRawList; i++ ) {
		var nOpt = document.createElement("option");
		nOpt.value = prefix+rawTags[i];
		dataList.appendChild(nOpt);
	}

   var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

  
   var itemval=document.getElementById(str).value;


    if((keyCode=='13') &&(itemval!=''))
              {


         closingbal(itemval,this1);
         handleEnter(this1, event);
         
   	
              }  

        if (keyCode == 40){
                    var row=this1.parentNode.parentNode.rowIndex;
			 var col  =this1.parentNode.cellIndex ;
			 
                    document.getElementById('myTable2').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();

	 }




}

//mainLoop();






function closingbal(str,r)
{


var i=r.parentNode.parentNode.rowIndex;


   var tbl = document.getElementById('myTable2');
   var id1=tbl.rows[i].cells[0].innerHTML;



 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("clb").innerHTML=xmlhttp.responseText;
    var  clbal= document.getElementById("clbal").value;
    document.getElementById('cbal'+id1).value=clbal;
    }
  }


xmlhttp.open("GET","getclbal_crec.php?led="+str+"&& id="+id1,true);
xmlhttp.send();
}





function showHint()
{
document.getElementById("popScroll2").innerHTML="<img src='images/loader.GIF' />";

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("popScroll2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","cshrec/view_cshrec1.php", true);
xmlhttp.send();
}



function viewinv()
{
 var str=document.getElementById('jvno').value;
document.getElementById("popScroll2").innerHTML="<img src='images/loader.GIF' />";


if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("popScroll2").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","cshrec/view_cshrec.php?jvno="+str,true);
xmlhttp.send();
}


</script>









<style>


#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;
	font-size: 1.2em;
	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; 
	font-size:11px; 
	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;
	font:12px; 
	width:100px;
}

.button:hover { background:#ddd; }

.del{
      border: none;
     background: url("images/delete.png") no-repeat scroll 0 0 transparent;
}




.pop-up2 {position:absolute; top:10px; left:50px;padding-left:180px;}
.pop-up2:target {position:static; left:0;}

.popBox2 {
  background:#ffffff;

 
  width:75%;
  min-height:100%;



   z-index:1;

  border:1px solid #3a3a3a;


  -moz-border-radius:12px;
  border-radius:12px;
  -webkit-box-shadow:2px 2px 4px #3a3a3a;
  -moz-box-shadow:2px 2px 4px #3a3a3a;
  box-shadow:2px 2px 4px #3a3a3a;
  opacity:0;
 -webkit-transition: opacity 0.5s ease-in-out;
  -moz-transition: opacity 0.5s ease-in-out;
  -o-transition: opacity 0.5s ease-in-out;
  -ms-transition: opacity 0.5s ease-in-out;
  transition: opacity 0.5s ease-in-out;  
}
:target .popBox2 {position:fixed; opacity:1;}

.popBox2:hover {box-shadow:3px 3px 6px #5a5a5a;}



.lightbox {display:none; text-indent:0em; background:#000; opacity:0.0; width:100%; height:100%; position:fixed; top:0; left:0; bottom:0; right:0;}
:target .lightbox {display:block}



  


/* .popScroll {max-height:99%; overflow-y:scroll;} removed 17/07/2012 */
.popScroll2 {position:absolute; top:9%; left:3%; right:3%; bottom:9%; overflow-y:auto; *overflow-y:scroll; padding-right:0.5em}
</style>

<script type="text/javascript" src="js/jquery.js"></script>




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


 $(document).ready(function(){
  $("#svbttn").click(function(){

$("#msgbox").html('<small>Loading...</small>');
      

    	// var name= $(this).attr('name');

    	 //$('#type_name').val(name);
   
  	 var values1 = $("#jforms").serialize();
 	// $(".typeselecter").attr("disabled", true);
 	 // $("#td1").html('');

  	  $.ajax({
   	   url: "svcshrec.php",
    	  type: "POST",
   	  data:   values1,
     	  success: function(msg){

 
        
           	 if(parseInt(msg)!=0)    

          	  {

                $('#msgbox').html(msg);
             
                //$(".typeselecter").attr("disabled", false);  
		}
           

      	},
      error:function(){
          alert("failure");
          $("#msgbox").html('there is error while submit');
      }   
   	 }); 

	 }); 
	 });
 

</script>


<script>

$(document).bind('keydown', 'Alt+n',function (e){
      
    if(e.which==78 && e.altKey){
	 //alert (e.which);
        shortkey_tblopen();
        return false;
    } 
     if(e.which==83 && e.altKey){
	 
         $( "#svbttn" ).click();
        return false;
    } 
   if(e.which==82 && e.altKey){
	 
         window.location.reload(true);
        return false;
    } 
      
    
});



</script>







<script type="text/javascript">



  function shortkey_tblopen(){
               
               var rowCounts = document.getElementById('myTable2').rows.length;
		 if(rowCounts<=1){
		          
			document.getElementById('insrowbttn2').click(); 
               }		   					
 		 
 }




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;
		}
                 if (keyCode == 38){
                    var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable2').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();
			
			 
              }

                  if (keyCode == 40){
                    var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable2').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();
			
			 
              }
                     if (keyCode == 37){


                    /* var row=field.parentNode.parentNode.rowIndex;
			 var col  =field.parentNode.cellIndex ;
			 
                     document.getElementById('myTable2').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();*/

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

                   if (keyCode == 46){
			  var i=field.parentNode.parentNode.rowIndex;
			  
                       var r=confirm("Do you want to delete the row?");
			  if (r==true)
 				 {
 					//document.getElementById('myTable2').deleteRow(i);
					delRow2(field);
                                  document.getElementById('myTable2').rows[i].cells[1].getElementsByTagName("input")[0].focus();
                                  
					//var nxt =document.getElementById('myTable2').rows[i].cells[0].innerHTML;
					//alert(nxt);
  				 }
			  
        }
                   
		else
		return true; 
}

function countcrtot(r,val)
{
var i=r.parentNode.parentNode.rowIndex;
var str1=0;

   var tbl = document.getElementById('myTable2');
   var id1=tbl.rows[i].cells[0].innerHTML;

if(isNaN(val))
  {
  alert('Enter Digit');
 document.getElementById("cr_amt"+id1).value=0;
  document.getElementById("cr_amt"+id1).focus();
  }
else
 {
var n=document.getElementById('myTable2').rows.length-1;
var m;
for(m=1;m<=n;m++)	
    {
     var tbl1 = document.getElementById('myTable2');
     var id2=tbl1.rows[m].cells[0].innerHTML;
    var itemval = document.getElementById("cr_amt"+id2).value;
    
         str1=parseFloat(str1)+parseFloat(itemval); 
        
     }
  document.getElementById("crtot").value= str1.toFixed(2);
}
}




function calcdr()
{
var tq=0;
for(i=1;i<cur;i++)
{
 var ele='dr'+i; //alert(ele);
 if(document.getElementById(ele).value>0)
  {
   amount=document.getElementById(ele).value;
   tq+=parseFloat(amount);
  }
 }
//document.f1.tdamt.value=tq;
}

function calccr()
{
var tq2=0;
for(i=1;i<cur2;i++)
{
 var ele2='cr'+i; //alert(ele);
 if(document.getElementById(ele2).value>0)
  {
   amount=document.getElementById(ele2).value;
   tq2+=parseFloat(amount);
  }
 }
document.f1.tcamt.value=tq2;
}




var cur2=1;
var cnt2=1;
var cr=[];
var drs=[];
var crs=[];
var cr_amt=[];
var cr_narr=[];
var cragain=[];
var cragval=[];
function insRow2(event,i1,id2)
{
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

var cur_val=i1.value;


switch(keyCode)
{
case 38:
   var row=i1.parentNode.parentNode.rowIndex;
   var col  =i1.parentNode.cellIndex ;
			 
   document.getElementById('myTable2').rows[row-1].cells[col].getElementsByTagName("input")[0].focus();
  break;
case 40:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
   document.getElementById('myTable2').rows[row+1].cells[col].getElementsByTagName("input")[0].focus();
			
  break;
case 37:
  var row=field.parentNode.parentNode.rowIndex;
  var col  =field.parentNode.cellIndex ;
			 
  document.getElementById('myTable2').rows[row].cells[col-1].getElementsByTagName("input")[0].focus();
	
}



if(id2!="insrowbttn2")
  {
   var i2=i1.parentNode.parentNode.rowIndex;
   var i3=parseFloat(i2)+parseFloat(1);
   var rowCounts = document.getElementById('myTable2').rows.length;
   var rowCounts1= rowCounts-1;
   
  
  }
else
  {
   var i2=0;
   var rowCounts1=0;
  }




		if(((keyCode == 13) && (i2==rowCounts1))||(cnt2==1)) 
 {

var rowCount = document.getElementById('myTable2').rows.length;
var rowcount1=parseFloat(rowCount)+parseFloat(1);
//alert(rowCount);
var x=document.getElementById('myTable2').insertRow(rowCount);


if(rowCount>=1)
 {
  document.getElementById('insrowbttn2').type='hidden';
 }
var k;
var a=x.insertCell(0)

var y=x.insertCell(1)

var z=x.insertCell(2)	
var z1=x.insertCell(3)	


var op=x.insertCell(4)
var dd=x.insertCell(5);

a.innerHTML=cur2;

y.innerHTML="<input type=text name='cr[]' id=cr"+cur2+"  size=35    onkeyup='xx(this.id,event,this)'   autocomplete='off' list='htmlListTags'  >";

z.innerHTML="<input type=text name='cr_amt[]' id=cr_amt"+cur2+" class='cr_amt' size=10  onchange='countcrtot(this,this.value)' onKeydown='return handleEnter(this, event)'>";
 z1.innerHTML="<input type=text name='cr_narr[]' id=cr_narr"+cur2+" class='cr_narr' size=30 value='Amount Received' onKeydown='return handleEnter(this, event)'>";

op.innerHTML="<input type=text readonly id='cbal"+cur2+"' onKeyup='insRow2(event,this,this.id)' >";
dd.innerHTML="<input type='button'  onClick='delRow2(this)' class='del' >";
document.getElementById("cr"+cur2).focus();
  cur2++; 

cnt2++;



var table = document.getElementById("myTable2");
var row = table.rows[index];
console.log(secondRow.id);
}



if(keyCode == 13)
{

var tbl = document.getElementById('myTable2');
   var id3=tbl.rows[i3].cells[0].innerHTML;
document.getElementById("cr"+id3).focus();
} 
}






function delRow2(r)
{
//alert (r);

var i=r.parentNode.parentNode.rowIndex;
document.getElementById('myTable2').deleteRow(i);

  var rowCount = document.getElementById('myTable2').rows.length;
   var tbl = document.getElementById('myTable2');

 if(rowCount<=1)
 {
  document.getElementById('insrowbttn2').type='button';
 }
   
var str1=0;
var n=document.getElementById('myTable2').rows.length-1;
var m;
for(m=1;m<=n;m++)	
    {
     var tbl1 = document.getElementById('myTable2');
     var id2=tbl1.rows[m].cells[0].innerHTML;
    var itemval = document.getElementById("cr_amt"+id2).value;
    
         str1=parseFloat(str1)+parseFloat(itemval); 
        
     }
  document.getElementById("crtot").value= str1.toFixed(2);

cnt2--;
     
 }



</script>


<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;
    }
.tble1 input {
background-color:transparent;
border: 0px solid;
height:20px;
//width:160px;
color:black;
}
.tble1
{
border-collapse:collapse;
border:1px solid silver;
margin-top:20px;
}	
.tble1 td, th
{
border-collapse:collapse;
border:1px solid silver;
}


#tbl1{
 margin-top:40px;
min-width:65%;
 text-align:center;
}

#tbltd1{
vertical-align: top;
margin-top:20px;
 height:400px;
background-color:white;
-moz-box-shadow: 0 0 5px -1px #000;
-webkit-box-shadow: 0 0 5px -1px #000;
box-shadow: 0 0 5px -1px #000;

}
#tbl1 td{
 text-align:left;

}
#tbl2{
 margin:50px 20px 10px 20px;
 min-width:95%;
}


</style>


<link type="text/css" href="includes/style1.css" rel="stylesheet" />
      <link type="text/css" href="css/form1.css" rel="stylesheet" />


<?php include_once('help_window.php'); ?>
<body style="text-align: center;" onload="document.getElementById('insrowbttn2').focus();">
    
<div id="pop2" class="pop-up2" >
  <div class="popBox2">

    <div class="popScroll2" id='popScroll2' >

    </div>
 
  </div>


  <a href="#links" class="lightbox"></a>
</div>        

           <table class='tbl1' id='tbl1'  align='center'><tr><td align='left' colspan='6'>
		<h1 style="font-size:20px;font-weight:bold;font-family:verdana;color:#FFFFFD;margin:0px; padding:0px;">
		Cash Receipt Number:<?print $crno?></h1></td></tr>
		
		<tr>
		<td><a href="#pop2" id="links" onclick=' showHint()' style="text-decoration:none;"><input value="View"  style="height:32px;width:110px;" type="submit" ></a></td>

               <td><input value="Print" onClick="window.open('accounts/print_cshrec1.php')" style="height:32px;width:110px;" type="submit"></td>
         

                <td><a href='edit_cshrec1.php' style="text-decoration:none;"><input style="height:32px;width:110px;" value="Edit"  type="submit" ></td>
    
     <td style="text-align:right; width:250px; height:45px;"><a href="#login-box" class="login-window" style="text-decoration:none;"> <input  style="height:32px;width:110px;" value="Save" type="button" id='svbttn'></a></td></tr>
	
<tr><td id='tbltd1' colspan='6'>
<div>
 <fieldset style="border:2px solid grey; border-style:dotted;">
            <legend style="text-align:center;">Cash Receipt</legend>
 <form id="jforms" name="invoice_form" >
       
 <table class='tbl2' id='tbl2' >
<tr><td  style="align:center;">
<?
$re11=mysqli_query($db,"select login_date from branch where brcode='$brcode'");
$row11=mysqli_fetch_array($re11);
$mlogin_date = $row11[0];
?>

Date:dd<select name='d'  >
<option><?print substr($mlogin_date,8,2);?></option>
<?
for($i=1;$i<=31;$i++)
{
if($i<'10')
{
$i='0'.$i;
}
print "<option>".$i."</option>";
}
?>
</select>
mm <select name='m'  >
<option><?print substr($mlogin_date,5,2);?></option>
<?
for($i=1;$i<=12;$i++)
{
if($i<'10')
{
$i='0'.$i;
}
print "<option>".$i."</option>";
}
?>
</select>
yy <select name='y'  >
<option><?print substr($mlogin_date,0,4);?></option>
<?
for($i=2000;$i<=2020;$i++)
{
print "<option>".$i."</option>";
}
?>
</select>
</td></tr>
<tr><td colspan='4'>   
Credit <input type="button" id='insrowbttn2' onclick="insRow2(event,this,this.id)" style="color:#6B6B6B;font-weight:bold;font-size:15px;" value="+">

<table id="myTable2" border="1" class='tble1' width=100%>
<th>No.<th>Cr <th>Amt <th>Narr<th>Cl.Bal <th>Delete
</table>
<datalist id="htmlListTags"></datalist>
<br><br>
<div id='clb'></div>

<input type='hidden' name='sv_flag' value='0'>

<input type='hidden' name='savecount' id='savecount' value='0'>


</div>


<div id="login-box" class="login-popup">
        <a href="#" class="close"><img src="images/close_pop.png" class="btn_close" title="Close Window" alt="Close" /></a>
          <div id='msgbox'></div>
		</div>



</td></tr>

  <tr><td></td><td></td><td colspan='2' style="text-align:right;">

                    Total Credit Amount
                
<input onclick="alert('The total is calculated automatically as soon as you have entered something into amount field.')" style="border:0px solid white;text-align:right; width:100px; padding-right:5px; font-weight:normal; font-family:verdana;font-size:13px;color:#3c3c3c;" readonly="readonly" name='tcamt' id='crtot' type="text">
</td></tr>
 </form>
   </td></tr>
</table>
   
</fieldset> 
</div>
</td></tr></table>
		


<?

$re=mysqli_query($db,"select * from ledger where grp != 'Cash in hand' and grp!='Sundry Debtors' and brcode='$brcode' order by led") or die(mysqli_error($db));
$i=0;
while($row=mysqli_fetch_row($re))
{
 print "\n<script>crs[$i]='$row[0]' </script>";
 $i++;
}
$re11=mysqli_query($db,"select distinct led from ledger where grp = 'Sundry Debtors' order by led") or die(mysqli_error($db));
while($row=mysqli_fetch_row($re11))
{
 print "\n<script>crs[$i]='$row[0]' </script>";
 $i++;
}




?>