<link href="css/form.css" type="text/css" rel="stylesheet" media="screen"  />
<html>
<body >
<?
include_once('includes/top.php');
include_once('opendb.php');
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
if(strlen($user)<=0)
{
  print "<script> alert('Invalid User'); document.location='inde.php' </script>";
  return;
}
if(isset($_POST['save']))
	{
		foreach ($chqno as $id => $value) 
			{
            			$chqnos = ($chqno[$id]);
            			$chqdts = ($chqdt[$id]);
				$chqamts = ($chqamt[$id]);
            			if (!empty($chqnos)) 
					{
						$chqdts=implode('-', array_reverse(explode('-', $chqdts)));
						$query="insert into chequecollection(date,partic,brcode,bnknm,chqno,bnkact,chqamt) values ('$chqdts','$custnm','$brcode','$bnknm','$chqnos','$gr_tax','$chqamts')";
						mysqli_query($db,$query);
					}
        		}


		//$query = "INSERT INTO chequecollection('chqno','date','chqamt','partic','bnknm','bnkact','brcode') VALUES ";
    		//$query_parts = array();
		
			//echo count(!empty($_POST['chqno']));
			//echo count(array_filter($_POST['chqno']));
		//if (!empty($_POST['chqno']))
			//{
			
				//for($i=0;$i<count(array_filter($_POST['chqno']));$i++)   
					//{   
						//$chqno=$_POST['chqno'];
	
						//$query="insert into chequecollection(date,partic,brcode,bnknm,chqno,bnkact,chqamt) values ('".$chqdt[$i]."','$custnm','$brcode','$bnknm','".$chqno[$i]."','$gr_tax','".$chqamt[$i]."')";
						//echo $query;
					//}

			//}

		//if($chqno!='')
			//{
    				//for($x=0; $x<count($chqno); $x++)
					//{
       					//$query_parts[] = "('" . $chqno[$x] . "', '" . $chqdt[$x] . "', '" . $chqamt[$x] . "', '" . $custnm . "', '" . $bnknm . "', '" . $gr_tax. "', '" . $brcode. "')";
    					//}
			
    				//echo $query .= implode(',', $query_parts);
			//}
	
		//print "<script> document.location='chqcrdtcust.php'</script>";
		//return;
	}
?>
<title>Demo</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" href="cal/jquery-ui.css" />
  <script src="cal/jquery-1.9.1.js"></script>
  <script src="cal/jquery-ui1.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    $( ".chqdat" ).datepicker({
      dateFormat: "dd-mm-yy" 
    });
    
  });

  </script>
<script>
function valid()
{
}
</script>
<style>
th{background-color:steelblue;color:white}
table.form{
font-weight: normal;border:1px;
font-family: Tahoma,Verdana,Geneva,sans-serif !important;
    font-size: 14px;
} 
</style>
<style>
#txt{
font-family: Tahoma,Verdana,Geneva,sans-serif !important;
background-color: #F2F2F2;

}
</style>
<body>
<form name='f1' action='<?print $PHP_SELF?>' onSubmit="return valid()" method='post'> 
<table class="container"><tr><td>
<font style="font-family: 'Trebuchet MS',Verdana,Helvetica,sans-serif; font-size:15px;">  &nbsp;&nbsp;Accounts >> Credit Customer</font>
<br>

<center>
<table cellspacing=1 cellpadding=1 class=form>
<tr><td align=center bgcolor='white'>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return valid()">
<table cellspacing=1 cellpadding=3 width='450'>
<th colspan=6><font size=3>CREDIT CUSTOMER</th>
<?
$sql="select * from customer where brcode='$brcode'";
$rs=mysqli_query($db,$sql);
?>
<tr><td>Customer Name</td><td>
<select name='custnm'>
<?
while($row=mysqli_fetch_array($rs))
{
?>
<option><? echo $row[3] ?></option>
<?
}
?>
</select>
</td><td></td>
<? $query="select * from bankmaster where brcode='$brcode'";
$rw=mysqli_query($db,$query);
?>	
<td>Bank Name</td><td><select name='bnknm'>
<?
while($row1=mysqli_fetch_array($rw))
{
?>
<option><? echo $row1[2] ?></option>
<?
}
?>
</select></td>
</tr>

<tr><td>Sl No:</td><td>Cheque No:</td><td>Cheque Dt:</td><td>Amount:</td>
</tr>
<tr><td>1</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td>
</tr>
<tr><td>2</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td>
</tr>
<tr><td>3</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td>
</tr>
<tr><td>4</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td>
</tr>
<tr><td>5</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td>
</tr>
<tr><td>6</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<tr><td>7</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<tr><td>8</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<tr><td>9</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<tr><td>10</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<tr><td>11</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<tr><td>12</td><td><input type='text' name='chqno[]'></td><td><input type='text' name='chqdt[]' class='chqdat'></td><td><input type='text' name='chqamt[]'></td></tr>
<?
$sl="select * from ledger where grp='Bank Accounts' and brcode='$brcode'";
$rs1=mysqli_query($db,$sl);
?>
<tr><td>Khadi Bank A/c</td><td><select name='gr_tax'>
<?
while($row=mysqli_fetch_array($rs1))
{
?>
<option><? echo $row[0] ?></option>
<?
}
?>
</select></td>
</tr>
<th colspan=6><input type=submit value='Save' name='save'></td></tr>
</table>
</form>
</td></tr>
</table>
<br>
<table cellspacing=1 cellpadding=5 class=report>
<?
$i=1;
//$res=mysqli_query($db,"select * from groupmaster order by gname");
while($row=mysqli_fetch_array($res))
{
?>
<form name='form2' id='form2' method='POST'>
<?
 print "<tr bgcolor='white' onMouseOver=bgColor='b8d7b4'; onMouseOut=bgColor='white'>";
 print "<td>".$i++."</td><td>".$row[gname]."</td><td>".$row[grp_tax]."</td><td>".$row[stat_rbt]."</td><td>".$row[grp_kvic]."</td><td>".$row[reduct]."</td><td>".$row[grp_kvicspl]."</td>";
  print "<td><input type=button value='Edit' name='ed' onClick=edtfun('$row[code]')></td>";
  print "<td><input type=button value='Del' name='del' onClick=delfun('$row[code]')></td></tr>";
}
?>
</form>
</table>
<script>
 function edtfun(x)
 {
   document.location='editcrcustomer.php?code='+x;
 }
 function delfun(x)
 {
  if (confirm('do you want to delete '+x+' ?'))
   document.location='delcrcustomer.php?code='+x;
 }
  
</script>
