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

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

.div2 {
    width: 380px;
    height: 240px;    
background-color:#f4f6df;
    border: 4px solid #376ca1;
	float:right;
}
label {
  
  color: black;
  font-weight: bold;
  
}
td,th{
  
  color: black;
  font-weight: bold;
  
}

</style>
 <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>
	
  <!--  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">
                            Ledger
                        </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">

<div class="col-md-12">
<div class="col-md-12 div1">
<table class="table" style="width:100%">
<tr><td><center><h4><b>Ledger View</b></h4></center></td>
<td><select type="text" class="form-control" style="width:560px; height:39px "  name="led"  value=""  placeholder=""  required >  
<option><option>
<?php $sql1 = mysqli_query($conn, "select * from ledger where mfin='$mfin' order by ledger asc");
while($row1 = mysqli_fetch_array($sql1)) { ?><option><?php echo $row1['ledger']; ?></option>
<?php } ?> </select>
</td><td>
 <button type="submit" class="btn btn-warning btn-block" style="width:360px; height:39px " name="s1">Show It</button></td>
</tr>
</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
</table>
 </div> 
   </div> <div> &nbsp;</div><div>
       </div>
       <div>
	<?php
							if(isset($_POST['s1']))
							{
								extract($_POST);
								?>
  <div class="table-responsive">
   <table  class="table table-striped table-bordered"><thead>
					<font size="1">
					    <?php 
					    	$sqll44 = mysqli_query($conn, "select * from abc where mfin='$mfin'");
	$rowww = mysqli_fetch_array($sqll44);
											$fdate77 =  $rowww['date1']; 
										$tdate77 =  $rowww['date2']; ?>
					<tr class="danger" style="color:purple;">
						<th colspan="5"><font size="2"><center><b>Ledger : <?php echo $led; ?>  <?php echo date("d-m-Y", strtotime($fdate77)); ?> To <?php echo date("d-m-Y", strtotime($tdate77)); ?> <b></center></font></th></tr>
						
						<tr class="danger" style="color:purple;">
						<th><font size="2">Date</font></th>
						<th><font size="2">Particulars</font></th>
				<th><font size="2">Vch Type</font></th>
									<th><font size="2">Debit</font></th>			<th><font size="2">Credit</font></th>
						</tr></thead>
						<?php $e=0;  $s=0;  $r=0;  $t=0; $d=0; $d1=0; $i=1; $totd = 0; $totc = 0;
							
								//$fdate5 =  date("Y-m-d", strtotime("1999-01-01")); 
									 
									//	$fdate5 =  date("Y-m-d", strtotime("2018-03-31")); 
						$obal = 0;
	$qcre =  0;
$qdeb =  0; $totd = 0; $totc = 0;

										
$sqll = mysqli_query($conn, "select * from ledger where ledger='$led' && mfin='$mfin'");
    $roww = mysqli_fetch_array($sqll);
	$led = $roww['ledger'];
	$opening = $roww['openbal']; $tot = ($opening * (-1)); $obal = $tot; $totd = $totd + $opening; ?>
		<tr>
<td><font size="2"><b></b></font></td>
					<td><font size="2"><b>Opening Balance</b></font></td>
						<td><font size="2"><b></b></font></td>
						<td><font size="2"><?php echo $opening; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
						</tr>
	<?php
$cdoc2=mysqli_query($conn, "select * from voucher where mfin='$mfin' && par='$led' && vtype='Payment' && date between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) {
$idd = $cdoc12['id']; 
$iddd = $idd + 1;
$cdoc23=mysqli_query($conn, "select * from voucher where id='$iddd'");
$cdoc123 = mysqli_fetch_array($cdoc23);
$iddd = $idd + 2;
$cdoc234=mysqli_query($conn, "select * from voucher where id='$iddd'");
$cdoc1234 = mysqli_fetch_array($cdoc234);
	?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="2"><b><?php echo $cdoc123['par']; ?></br><?php echo $cdoc1234['remark']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
				
						<td><font size="2"><b><?php echo $cdoc12['dr']; ?></b></font></td>
									<td><font size="2"><b><?php echo $cdoc12['cr']; ?></b></font></td>
					
						
						</tr>
<?php $totc = $totc + $cdoc12['cr'];  $totd = $totd + $cdoc12['dr']; }
$cdoc2=mysqli_query($conn, "select * from voucher where mfin='$mfin' && par='$led' && vtype='Receipt' && date between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { 
$idd = $cdoc12['id']; 
$iddd = $idd + 1;
$cdoc23=mysqli_query($conn, "select * from voucher where id='$iddd'");
$cdoc123 = mysqli_fetch_array($cdoc23);
?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="2"><b><?php echo $cdoc123['par']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
				     <td><font size="2"><b><?php echo $cdoc12['dr']; ?></b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['cr']; ?></b></font></td>
					</tr>
<?php $totc = $totc + $cdoc12['cr'];  $totd = $totd + $cdoc12['dr']; }
$cdoc2=mysqli_query($conn, "select * from voucher where mfin='$mfin' && par='$led' && vtype='Contra' && date between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { 
$idd = $cdoc12['id']; 
$iddd = $idd + 1;
$cdoc23=mysqli_query($conn, "select * from voucher where id='$iddd'");
$cdoc123 = mysqli_fetch_array($cdoc23);
$iddd = $idd + 2;
$cdoc234=mysqli_query($conn, "select * from voucher where id='$iddd'");
$cdoc1234 = mysqli_fetch_array($cdoc234);
?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="2"><b><?php echo $cdoc123['par']; ?></br><?php echo $cdoc1234['remark']; ?></b></font></td>
						<td><font size="2"><b>Contra</b></font></td>
				     <td><font size="2"><b><?php echo $cdoc12['dr']; ?></b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['cr']; ?></b></font></td>
					</tr>
<?php $totc = $totc + $cdoc12['cr'];
$totd = $totd + $cdoc12['dr'];
 }
 
 
 
 //////////////////////////////////////////////////////////////////////////////
 
 $cdoc2=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && pmode='$led' && hpdate5 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="2"><b>HP-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
						<td><font size="2"><b></b></font></td>
						<td><font size="2"><b><?php 
						$led55 = $cdoc12['pmode2']; $chq = $cdoc12['chqamt']; $hpamtt = $cdoc12['hpamount'];
						$hppp = $hpamtt - $chq;
						echo $hppp; ?></b></font></td>
						
						</tr>
<?php $totc = $totc + $hppp; } 
$cdoc2=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && pmode2='$led' && hpdate5 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="2"><b>HP-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
						<td><font size="2"><b></b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['chqamt']; ?></b></font></td>
						
						</tr>
<?php $totc = $totc + $cdoc12['chqamt']; }

$cdoc2=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && pmode='$led' && dealeramt>0 && hpdate5 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="2"><b>Dealer Amt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['dealeramt']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['dealeramt']; }
$cdoc2=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && pmode='$led' && document>0 && hpdate5 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="2"><b>Document Income-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['document']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['document']; }
$cdoc2=mysqli_query($conn, "select * from user where mfin='$mfin' && mode='$led' && paydate2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="2"><b>Rcpt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['urname']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['urname']; }
$cdoc2=mysqli_query($conn, "select * from net where mfin='$mfin' && mode='$led' && paydate2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="2"><b>Settle-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
							<td><font size="2"><b><?php echo $cdoc12['tot']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
					
						
						</tr>
<?php $totd = $totd + $cdoc12['tot']; }
$cdoc2=mysqli_query($conn, "select * from hloan where mfin='$mfin' && mode='$led' && date2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="2"><b>HL-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
						
						<td><font size="2"><b></b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['actamt2']; ?></b></font></td>
						
						</tr>
<?php $totc = $totc + $cdoc12['actamt2']; }

$cdoc2=mysqli_query($conn, "select * from fincust where mfin='$mfin' && pmode='$led' && hpdate5 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="2"><b>FInloan-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
						
						<td><font size="2"><b><?php echo $cdoc12['hpamount']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
						
						</tr>
<?php $totd = $totd + $cdoc12['hpamount']; }
$cdoc2=mysqli_query($conn, "select * from finuser where mfin='$mfin' && mode='$led' && paydate2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="2"><b>FinloanRcpt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
						
						<td><font size="2"><b></b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['urname']; ?></b></font></td>
						
						
						</tr>
<?php $totc = $totc + $cdoc12['urname']; }
$cdoc2=mysqli_query($conn, "select * from finnet where mfin='$mfin' && mode='$led' && paydate2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="2"><b>FinloanSettle-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
					
						<td><font size="2"><b></b></font></td>
								<td><font size="2"><b><?php echo $cdoc12['tot']; ?></b></font></td>
					
						
						</tr>
<?php  $totc = $totc + $cdoc12['tot']; }
$cdoc2=mysqli_query($conn, "select * from moncust where mfin='$mfin' && pmode='$led' && hpdate5 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="2"><b>Monloan-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Payment</b></font></td>
						
						
						<td><font size="2"><b></b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['hpamount']; ?></b></font></td>
						
						</tr>
<?php   $totc = $totc + $cdoc12['hpamount']; }
$cdoc2=mysqli_query($conn, "select * from monuser where mfin='$mfin' && mode='$led' && paydate2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="2"><b>MonRcpt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
						<td><font size="2"><b><?php echo $cdoc12['urname']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['urname']; }
$cdoc2=mysqli_query($conn, "select * from monnet where mfin='$mfin' && mode='$led' && paydate2 between '$fdate77' and '$tdate77'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="2"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="2"><b>MonSettle-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="2"><b>Receipt</b></font></td>
							<td><font size="2"><b><?php echo $cdoc12['tot']; ?></b></font></td>
						<td><font size="2"><b></b></font></td>
					
						
						</tr>
						<?php $totd = $totd + $cdoc12['tot']; }
?>
<tr>
<td><font size="3"><b>Total</b></font></td>
					<td><font size="3"><b></b></font></td>
						<td><font size="3"><b></b></font></td>
						<td><font size="3"><b><?php echo $totd; ?></b></font></td>
						<td><font size="3"><b><?php echo $totc; ?></b></font></td>
				
						</tr>
		<?php $tottot = $totd - $totc;	?>	
	<tr>
	<td><font size="3"><b></b></font></td>
<td><font size="3"><b>Closing Balalnce</b></font></td>
					
						<td><font size="3"><b></b></font></td>
						<?php if($tottot >0) { ?>
						<td><font size="3"><b><?php echo $tottot; ?></b></font></td>
						<td><font size="3"><b></b></font></td>
						<?php } else { ?>
						<td><font size="3"><b></b></font></td>
						<td><font size="3"><b><?php echo abs($tottot); ?></b></font></td>
						<?php } ?>
						</tr>				 
					
					</tbody></table>
					<?php
	}
?>
	  </div>
</form>

</div>
</div></div>
</div></div></div>   <!-- footer content --> 
        <footer>
          <div class="pull-right">
             <a href="https://infossel.com">Infossel Soft Solution</a>
          </div>
          <div class="clearfix"></div>
        </footer>
        <!-- /footer content -->
      </div>
    </div>

    <!-- jQuery -->
    <script src="vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="vendors/nprogress/nprogress.js"></script>
    <!-- iCheck -->
    <script src="vendors/iCheck/icheck.min.js"></script>
    <!-- Datatables -->
    <script src="vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
    <script src="vendors/jszip/dist/jszip.min.js"></script>
    <script src="vendors/pdfmake/build/pdfmake.min.js"></script>
    <script src="vendors/pdfmake/build/vfs_fonts.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="build/js/custom.min.js"></script>

  </body>
</html>