<?php include "layouts/menu.php"; ?>    
  <!--  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">
                             Details
                        </div>
                        <div class="panel-body">
                            <div class="row">
    <?php				
			$led=$_REQUEST['led'];
$fdate=$_REQUEST['fdate'];
$tdate=$_REQUEST['tdate'];			
									$tr1 = 0; $tr2= 0;$tr3 = 0; $tr4= 0;$tr5 = 0; $tr6= 0;$tr7 = 0; $tr8= 0; ?>
									<div class="table-responsive">
									     <input type="button" class="btn btn-primary" value="Print" onclick="PrintElem('#mydiv')"  style="margin:20px;"> 				<div class="table-responsive my div" id="mydiv">
  <table class="table table-bordered table-hover" border="1"><thead>
						 <tr class="danger" style="color:purple;">
					
						<th colspan="5"><font color="blue" size="3"><b><center><?php echo $led; ?> Book <?php echo date("d-m-Y", strtotime($fdate)); ?> To <?php echo date("d-m-Y", strtotime($tdate)); ?></b></font></center></th>
						
					
						
					</tr>				

					<font size="1">
						<tr class="danger" style="color:purple;">
						<th><font size="3">Date</font></th>
						<th><font size="3">Particulars</font></th>
				<th><font size="3">Vch Type</font></th>
									<th><font size="3">Debit</font></th>			<th><font size="3">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;
$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="3"><b></b></font></td>
					<td><font size="4"><b>Opening Balance</b></font></td>
						<td><font size="4"><b></b></font></td>
						<td><font size="4"><?php echo $opening; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
						
						
						</tr>
	<?php
								//	   $fdate = $fdate;  $tdate = $tdate;
							
//$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && pmode='$led' && hpdate5 between '$fdate5' and '$tdate5'");
//$row15 = mysqli_fetch_array($qry15);
//$qry45=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' && mode='$led' &&  paydate2 between '$fdate5' and '$tdate5'");
//$row45 = mysqli_fetch_array($qry45);
//$qry445=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' && mode='$led' &&  paydate2 between '$fdate5' and '$tdate5'");
//$row445 = mysqli_fetch_array($qry445);
//$qry145=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' && par='$led' &&  date between '$fdate5' and '$tdate5'");
//$row145 = mysqli_fetch_array($qry145);
//$qry1455=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && par='$led' &&  date between '$fdate5' and '$tdate5'");
//$row1455 = mysqli_fetch_array($qry1455);						$n=mysqli_num_rows($qry);
//$c1 = $row45[0];	$c2 = $row145[0];  $c3 = $row445[0]; 	$d1 = $row1455[0];	$d2 = $row15[0]; 
//$qry15=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && pmode='$led' && hpdate5 between '$fdate5' and '$tdate5'");
//$row15 = mysqli_fetch_array($qry15);
//$qry45=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' && mode='$led' &&  paydate2 between '$fdate5' and '$tdate5'");
//$row45 = mysqli_fetch_array($qry45);
//$qry445=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' && mode='$led' &&  paydate2 between '$fdate5' and '$tdate5'");
//$row445 = mysqli_fetch_array($qry445);
//$c11 = $row45[0];  $c31 = $row445[0]; 		$d21 = $row15[0]; 
	//	$obal = $c1 + $c2 - $d1 - $d2 + $c3 + $c11 - $d21;

$cdoc2=mysqli_query($conn, "select * from customerdetails where mfin='$mfin' && pmode='$led' && hpdate5 between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="4"><b>HP-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
						<td><font size="4"><b></b></font></td>
						<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="4"><b>HP-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
						<td><font size="4"><b></b></font></td>
						<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="4"><b>Dealer Amt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
						<td><font size="4"><b><?php echo $cdoc12['dealeramt']; ?></b></font></td>
						<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="4"><b>Document Income-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
						<td><font size="4"><b><?php echo $cdoc12['document']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['document']; }
$cdoc2=mysqli_query($conn, "select * from user where mfin='$mfin' && mode='$led' && paydate2 between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="4"><b>Rcpt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
						<td><font size="4"><b><?php echo $cdoc12['urname']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['urname']; }
$cdoc2=mysqli_query($conn, "select * from net where mfin='$mfin' && mode='$led' && paydate2 between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="4"><b>Settle-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
							<td><font size="4"><b><?php echo $cdoc12['tot']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
					
						
						</tr>
<?php $totd = $totd + $cdoc12['tot']; }
$cdoc2=mysqli_query($conn, "select * from hloan where mfin='$mfin' && mode='$led' && date2 between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="4"><b>HL-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
						
						<td><font size="4"><b></b></font></td>
						<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="4"><b>FInloan-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
						
						<td><font size="4"><b><?php echo $cdoc12['hpamount']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
						
						</tr>
<?php $totd = $totd + $cdoc12['hpamount']; }
$cdoc2=mysqli_query($conn, "select * from finuser where mfin='$mfin' && mode='$led' && paydate2 between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="4"><b>FinloanRcpt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
						
						<td><font size="4"><b></b></font></td>
						<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="4"><b>FinloanSettle-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
					
						<td><font size="4"><b></b></font></td>
								<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['hpdate']; ?></b></font></td>
					<td><font size="4"><b>Monloan-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
						
						
						<td><font size="4"><b></b></font></td>
						<td><font size="4"><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 '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="4"><b>MonRcpt-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
						<td><font size="4"><b><?php echo $cdoc12['urname']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
						
						
						</tr>
<?php $totd = $totd + $cdoc12['urname']; }
$cdoc2=mysqli_query($conn, "select * from monnet where mfin='$mfin' && mode='$led' && paydate2 between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['paydate']; ?></b></font></td>
					<td><font size="4"><b>MonSettle-<?php echo $cdoc12['name']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
							<td><font size="4"><b><?php echo $cdoc12['tot']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
					
						
						</tr>
<?php $totd = $totd + $cdoc12['tot']; }
$cdoc2=mysqli_query($conn, "select * from voucher where mfin='$mfin' && par='$led' && vtype='Payment' &&  date between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="4"><b><?php echo $cdoc12['par']; ?></b></font></td>
						<td><font size="4"><b>Payment</b></font></td>
				
						<td><font size="4"><b></b></font></td>
									<td><font size="4"><b><?php echo $cdoc12['cr']; ?></b></font></td>
					
						
						</tr>
<?php $totc = $totc + $cdoc12['cr']; }
$cdoc2=mysqli_query($conn, "select * from voucher where mfin='$mfin' && par='$led' && vtype='Receipt' &&  date between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="4"><b><?php echo $cdoc12['par']; ?></b></font></td>
						<td><font size="4"><b>Receipt</b></font></td>
				     <td><font size="4"><b><?php echo $cdoc12['dr']; ?></b></font></td>
						<td><font size="4"><b></b></font></td>
					</tr>
<?php $totd = $totd + $cdoc12['dr']; }
$cdoc2=mysqli_query($conn, "select * from voucher where mfin='$mfin' && par='$led' && vtype='Contra' &&  date between '$fdate' and '$tdate'");
while($cdoc12 = mysqli_fetch_array($cdoc2)) { ?>
	<tr>
<td><font size="3"><b><?php echo $cdoc12['date']; ?></b></font></td>
					<td><font size="4"><b><?php echo $cdoc12['par']; ?></b></font></td>
						<td><font size="4"><b>Contra</b></font></td>
				     <td><font size="4"><b><?php echo $cdoc12['dr']; ?></b></font></td>
						<td><font size="4"><b><?php echo $cdoc12['cr']; ?></b></font></td>
					</tr>
<?php $totc = $totc + $cdoc12['cr'];
$totd = $totd + $cdoc12['dr'];
 }


?>

	</p>
						
			
		
						<?php 
						
			?>
					<tr>
<td><font size="5"><b>Total</b></font></td>
					<td><font size="5"><b></b></font></td>
						<td><font size="5"><b></b></font></td>
						<td><font size="5"><b><?php echo $totd; ?></b></font></td>
						<td><font size="5"><b><?php echo $totc; ?></b></font></td>
				
						</tr>
					 
					
					</tbody></table>	</form>
					
</div>
</div></div>
</div></div></div><?php include "layouts/footer.php"; ?></body></html>
