<?php include "layouts/menu.php"; ?>
<style> 
input[type=text] {
    width: 100%;
   
    box-sizing: border-box;
    border: 1px solid #555;
    outline: Gray;
	
}
input[type=text]:focus {
    background-color: #d1e0e3;
}
label {
  
  color: black;
  font-weight: bold;
  
}
td,th{
  
  color: black;
  font-weight: bold;
  
}
</style>
	<?php $vt=$_REQUEST['vt']; if($vt == 'Payment') {?>	
<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#5bc0de;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#5bc0de;
    border: 4px solid #376ca1;
	float:right;
}
	</style> <?php } elseif($vt == 'Receipt') { ?>
<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#f149449c;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#f149449c;
    border: 4px solid #376ca1;
	float:right;
}
</style> <?php } elseif($vt == 'Contra') { ?>
<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#26b99a;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#26b99a;
    border: 4px solid #376ca1;
	float:right;
}
</style> <?php } elseif($vt == 'Journal') { ?>
<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#337ab7ba;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#337ab7ba;
    border: 4px solid #376ca1;
	float:right;
}
</style> <?php } elseif($vt == 'Memo') { ?>
<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#dddddd;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#dddddd;
    border: 4px solid #376ca1;
	float:right;
}
</style>  <?php } elseif($vt == 'Sales') { ?>
<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#999;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#999;
    border: 4px solid #376ca1;
	float:right;
}
</style> <?php } else { ?>

<style> 
.div1 {
    width: 100%;
    height: 100%;
    border: 4px solid #376ca1;
	background-color:#f0ad4e;
	float:left;
}

.div2 {
    width: 380px;
    height: 240px;    
background-color:#f0ad4e;
    border: 4px solid #376ca1;
	float:right;
}
</style> <?php }  ?>
 <script>
	function autocomplet() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#zxcv').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_refreshvcc.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#qwerty').show();
				$('#qwerty').html(data);
			}
		});
	} else {
		$('#qwerty').hide();
	}
}
// set_item : this function will be executed when we select an item
function set_itemmm(item) {
	// change input value
	$('#zxcv').val(item);
	// hide proposition list
	$('#qwerty').hide();
}
	</script>
	 <script>
	function autocomplett() {
	var min_length = 0; // min caracters to display the autocomplete
	var keyword = $('#zxcvb').val();
	if (keyword.length >= min_length) {
		$.ajax({
			url: 'ajax_refreshvc.php',
			type: 'POST',
			data: {keyword:keyword},
			success:function(data){
				$('#qwertyu').show();
				$('#qwertyu').html(data);
			}
		});
	} else {
		$('#qwertyu').hide();
	}
}
// set_item : this function will be executed when we select an item
function set_item(item) {
	// change input value
	$('#zxcvb').val(item);
	// hide proposition list
	$('#qwertyu').hide();
}
	</script>
	 <script>
function add()
{
var x = document.getElementById("abc").value;

document.getElementById("abcd").value =(x*1);
}
</script>
  <!--  page-wrapper -->
         <div class="right_col" role="main">
         
            <div class="row">
                <div class="col-lg-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Voucher Entry
                        </div>
                        <div class="panel-body">
                            <div class="row">
  <div class="col-xs-12 col-md-12"> 
    <form name="form1" class="form-horizontal" method="post" action="" enctype="multipart/form-data">

<?php
$qry=mysqli_query($conn, "select * from voucher where mfin='$mfin' && vtype='$vt' order by id desc");
$n = mysqli_num_rows($qry);
$row=mysqli_fetch_array($qry);
if($n>0){
	$dd = $row['vno'];
	$rrno = $dd + 1;
}
else {
	$rrno  = 1;
}
	?>


<div class="col-md-12">
	<div class="col-md-4">
   <div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Vch Type</label>
    <div class="col-sm-4">
 <input readonly type="text" class="form-control" style="width:170px; height:29px " id="inputPassword3" name="vtype" width="48" value="<?php echo $vt; ?>" placeholder=""  required>  

  </div>
   </div>
 </div>
 	<div class="col-md-4">
   <div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Vch NO </label>
    <div class="col-sm-4">
     <input type="text" class="form-control" style="width:170px; height:29px " id="inputPassword3" name="vno" value="<?php echo $rrno; ?>" placeholder=""  required>  
    </div>
   </div>
 </div>

 	<div class="col-md-4">
   <div class="form-group">
<label for="inputPassword3" class="col-sm-3 control-label">Date </label>
    <div class="col-sm-4">
     <input type="date" class="form-control"  style="width:170px; height:29px " id="inputPassword3" name="date" value="<?php echo date("Y-m-d");?>" placeholder=""  required>  
    </div>
   </div>
 </div>
 </div>

<div> &nbsp;</div>

<?php if(($vt=='Payment') || ($vt=='Journal') || ($vt=='Sales')) { ?>

<div class="col-md-12">
<div class="col-md-12 div1">
<table class="table" style="width:100%">
<tr>
<th style="width:10%">Type</th><th style="width:50%">Particulars</th><th style="width:20%">Credit </th><th style="width:20%">Debit</th></tr>
<tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type1" width="10" value="Dr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px "  name="par1" width="10" value=""  placeholder=""  required >  
<option><option>
<?php $sql12 = mysqli_query($conn, "select * from ledger where mfin='$mfin'");
while($row12 = mysqli_fetch_array($sql12)) { ?><option><?php echo $row12['ledger']; ?></option>
<?php } ?> </select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly id="inputPassword3" name="cr1" width="10" value="" placeholder=""  >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " onkeyup="add()" id="abc" name="dr1" width="10" value="" placeholder=""  required>  
</td>
</tr><tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type2" width="10" value="Cr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px " id="gy" name="par2" width="10" value=""  placeholder="" required >
	  <option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Bank Accounts'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Cash in Hand'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?></select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px "  id="abcd" name="cr2" width="10" value="" placeholder="" required >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly id="inputPassword3" name="dr2" width="10" value="" placeholder=""  >  
</td>
</tr>
<tr><td colspan="4">Narration
 <textarea  type="text" class="form-control"   id="inputPassword3" name="remark" width="10" value="" placeholder="" required > </textarea> </td>
</tr>
<tr><td colspan="4">
 <button type="submit" class="btn btn-warning btn-block" name="s1">Register Voucher</button></td>
</tr>
</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</table>
 </div> 
<?php }
elseif($vt=='Contra') { ?>


<div class="col-md-12">
<div class="col-md-12 div1">
<table class="table" style="width:100%">
<tr>
<th style="width:10%">Type</th><th style="width:50%">Particulars</th><th style="width:20%">Credit </th><th style="width:20%">Debit</th></tr>
<tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type1" width="10" value="Cr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px "  name="par1" width="10" value=""  placeholder=""  required >  
<option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Bank Accounts'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Cash in Hand'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?></select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " onkeyup="add()"   id="abc" name="cr1" width="10" value="" placeholder=""  >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly id="inputPassword3" name="dr1" width="10" value="" placeholder=""  required>  
</td>
</tr><tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type2" width="10" value="Dr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px " id="gy" name="par2" width="10" value=""  placeholder="" required >
	  <option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Bank Accounts'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Cash in Hand'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
 </select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly  id="inputPassword3" name="cr2" width="10" value="" placeholder="" required >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px "  id="abcd" name="dr2" width="10" value="" placeholder=""  >  
</td>
</tr>
<tr><td colspan="4">Narration
 <textarea  type="text" class="form-control"   id="inputPassword3" name="remark" width="10" value="" placeholder="" required > </textarea> </td>
</tr>
<tr><td colspan="4">
 <button type="submit" class="btn btn-warning btn-block" name="s1">Register Voucher</button></td>
</tr>
</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</table>
 </div> 
 
<?php }
elseif($vt=='Receipt') { ?>


<div class="col-md-12">
<div class="col-md-12 div1">
<table class="table" style="width:100%">
<tr>
<th style="width:10%">Type</th><th style="width:50%">Particulars</th><th style="width:20%">Credit </th><th style="width:20%">Debit</th></tr>
<tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type1" width="10" value="Cr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px "  name="par1" width="10" value=""  placeholder=""  required >  
<option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?> </select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " onkeyup="add()"   id="abc" name="cr1" width="10" value="" placeholder=""  >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly id="inputPassword3" name="dr1" width="10" value="" placeholder=""  required>  
</td>
</tr><tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type2" width="10" value="Dr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px " id="gy" name="par2" width="10" value=""  placeholder="" required >
	  <option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Bank Accounts'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Cash in Hand'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
 </select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly  id="inputPassword3" name="cr2" width="10" value="" placeholder="" required >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px "  id="abcd" name="dr2" width="10" value="" placeholder=""  >  
</td>
</tr>
<tr><td colspan="4">Narration
 <textarea  type="text" class="form-control"   id="inputPassword3" name="remark" width="10" value="" placeholder="" required > </textarea> </td>
</tr>
<tr><td colspan="4">
 <button type="submit" class="btn btn-warning btn-block" name="s1">Register Voucher</button></td>
</tr>
</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</table>
 </div> 
 
<?php }
else { ?>


<div class="col-md-12">
<div class="col-md-12 div1">
<table class="table" style="width:100%">
<tr>
<th style="width:10%">Type</th><th style="width:50%">Particulars</th><th style="width:20%">Credit </th><th style="width:20%">Debit</th></tr>
<tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type1" width="10" value="Cr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px "  name="par1" width="10" value=""  placeholder=""  required >  
<option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?> </select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " onkeyup="add()"   id="abc" name="cr1" width="10" value="" placeholder=""  >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly id="inputPassword3" name="dr1" width="10" value="" placeholder=""  required>  
</td>
</tr><tr>
<td><input type="text" class="form-control" style="width:100px; height:39px " id="inputPassword3" name="type2" width="10" value="Dr" placeholder=""  >  
</td>
<td><select type="text" class="form-control" style="width:360px; height:39px " id="gy" name="par2" width="10" value=""  placeholder="" required >
	  <option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Bank Accounts'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' && under='Cash in Hand'");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?>
 </select>
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px " readonly  id="inputPassword3" name="cr2" width="10" value="" placeholder="" required >  
</td>
<td><input type="text" class="form-control" style="width:230px; height:39px "  id="abcd" name="dr2" width="10" value="" placeholder=""  >  
</td>
</tr>
<tr><td colspan="4">Narration
 <textarea  type="text" class="form-control"   id="inputPassword3" name="remark" width="10" value="" placeholder="" required > </textarea> </td>
</tr>
<tr><td colspan="4">
 <button type="submit" class="btn btn-warning btn-block" name="s1">Register Voucher</button></td>
</tr>
</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</table>
 </div> 
 
<?php }
 ?>
 
 
 
   </div> <div> &nbsp;</div><div>
       </div>
       <div>
	<?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
	$insert=mysqli_query($conn, "insert into voucher(mfin,scode,vtype,vno,date,par,cr,dr)
								 values('$mfin','$scode','$vtype','$vno','$date','$par1','$cr1','$dr1')");
								 if($insert){
								     
								     	$insert2=mysqli_query($conn, "insert into voucher(mfin,scode,vtype,vno,par,cr,dr,date)
								 values('$mfin','$scode','$vtype','$vno','$par2','$cr2','$dr2','$date')");
								 
								 if($insert2) {
								  	$insert3=mysqli_query($conn, "insert into voucher(mfin,scode,vtype,vno,remark,date)
								 values('$mfin','$scode','$vtype','$vno','$remark','$date')");   
								 }
								 	 if($insert3) {
								  	$insert4=mysqli_query($conn, "insert into voucher(mfin,scode,date,vtype,vno)
								 values('$mfin','$scode','$date','$vtype','$vno')");   
								 }
								 }
									header("Location:voucher.php?vt=$vtype");	

			
							
							}
?>
	  </div>
</form>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

	<a href="voucher.php?vt=Payment"><button class="btn btn-info btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Payment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="voucher.php?vt=Receipt"><button class="btn btn-danger btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receipt&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<a href="voucher.php?vt=Contra"><button class="btn btn-success btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Contra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="voucher.php?vt=Journal"><button class="btn btn-primary btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Journal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="voucher.php?vt=Sales"><button class="btn btn-dark btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sales&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="voucher.php?vt=Purchase"><button class="btn btn-warning btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Purchase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="voucher.php?vt=Memo"><button class="btn btn-secondary btn-lg">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button></a>
	
</div>
</div></div>
</div></div></div> <?php include "layouts/footer.php"; ?> </body></html>