<?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'];			
									$tr1 = 0; $tr2= 0;$tr3 = 0; $tr4= 0;$tr5 = 0; $tr6= 0;$tr7 = 0; $tr8= 0; ?>
									<div class="table-responsive">
  <table class="table table-bordered table-hover" border="1"><thead>
										

					<font size="1">
						<tr class="danger" style="color:purple;">
						<th><font size="3">Month</font></th>
						<th><font size="3">Particulars</font></th>
				
						
						<th><font size="3">Credit</font></th> <th><font size="3">Debit</font></th>  <th><font size="3">Closing</font></th>
						</tr></thead>
									
									<?php $e=0;  $s=0;  $r=0;  $t=0; $d=0; $d1=0; $i=1;
								//$fdate = "1990-04-31";
										$fdate =  $_REQUEST['fdate']; 
										$tdate1 = $_REQUEST['tdate']; 
										$tdate = date("Y-m-t", strtotime("$fdate")); 
						$obal = 0;
	$qcre =  0;
$qdeb =  0;

								//	   $fdate = $fdate;  $tdate = $tdate;
								while(strtotime($fdate)<=strtotime($tdate1)) {
					$monthh = date('F, Y', strtotime($fdate));

$bdealc = 0; $bdeald = 0; $bdealo = 0;
$sqlu = mysqli_query($conn, "select * from ledger where under='Broker' && mfin='$mfin'");   $capvccdr =0; $capvcccr =0; $fir++;
while($rowu = mysqli_fetch_array($sqlu)){
	$ledgername = $rowu['ledger'];
$openbal = $rowu['openbal'];	
$yn = $rowu['yn'];
$cass11=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && par='$ledgername' && date between '$fdate' and '$tdate'");
$cass1 = mysqli_fetch_array($cass11); $casss2 = 0;
$cass22=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' &&  par='$ledgername' && date between '$fdate' and '$tdate'");
$cass23 = mysqli_fetch_array($cass22);

$crasdr = $cass1[0];
$crascr = $cass23[0];
$bdealo = $bdealo + $openbal;
$bdeald = $bdeald + $crasdr;
$bdealc = $bdealc + $crascr;
}
$ff = NULL;
$clsdcdoc=mysqli_query($conn, "select sum(bcommission) from customerdetails where mfin='$mfin' && dealeramt<='0' && hpdate5 between '$fdate' and '$tdate'");
$clsdcdoc1 = mysqli_fetch_array($clsdcdoc);
$bclsdcdoc11 = $clsdcdoc1[0];
$brkbb = $bdealo  + $bdeald - $bdealc - $bclsdcdoc11; 
$bdealc = $bdealc + $bclsdcdoc11;
	$tot = $obal + $bdealc - $bdeald;
$obal = $tot;
						?></p>
						
				<tr>
<td><a href="ledvled3.php?led=<?php echo $led; ?>&&fdate=<?php echo $fdate; ?>&&tdate=<?php echo $tdate; ?>"><font size="3"><b><?php echo $monthh; ?></a></b></font></td>
					<td><a href="ledvled3.php?led=<?php echo $led; ?>&&fdate=<?php echo $fdate; ?>&&tdate=<?php echo $tdate; ?>"><font size="4"><b><?php echo $fdate; ?>-<?php echo $tdate; ?></a></b></font></td>
						
						
					
						<td><font size="4"><b><?php echo $bdealc; ?></font></b></td>
						
						<td><font size="4"><b><?php echo abs($bdeald); ?></font></b></td>
							<?php if($tot > 0) { ?>
						<td><font color="red" size="4"><b><?php echo $tot; ?> Cr</font></b></td>
						<?php } else { ?>
						<td><font size="4"><b><?php echo abs($tot); ?> Dr</font></b></td>
						<?php } ?>
						
						</tr>
		
						<?php 
							 $fdate =  date("Y-m-d", strtotime("$fdate + " . 1 . " month"));

						$tdate = date("Y-m-t", strtotime("$fdate")); }
				$qdeb = $qdeb + + $opening;		?>
				





				<tr>
<td><font size="5"><b>Total</b></font></td>
					<td><font size="5"><b></b></font></td>
						
						<td><font size="5"><b><?php echo $qcre; ?></b></font></td>
						<td><font size="5"><b><?php echo $qdeb; ?></b></font></td>
					<?php $qtot = $qcre - $qdeb; ?>
						<?php if($qtot > 0) { ?>
						<td><font color="red" size="5"><b><?php echo $qtot; ?> Cr</font></b></td>
						<?php } else { ?>
						<td><font size="5"><b><?php echo abs($qtot); ?> Dr</font></b></td>
						<?php } ?>
						</tr>
					 
					
					</tbody></table>	</form>
					
</div>
</div></div>
</div></div></div><?php include "layouts/footer.php"; ?></body></html>
