<?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">

									<div class="table-responsive">
   <table  class="table table-striped table-bordered"><thead>
										

					<font size="1">
						<tr class="danger" style="color:purple;">
						<th colspan="2"><font size="3">Particulars</font></th>
						
				
						<th><font size="3">Debit</font></th> <th><font size="3">Credit</font></th>
						
						</tr></thead> <tbody>
									
									<?php $e=0;  $s=0;  $r=0;  $t=0; $d=0; $d1=0; $i=1;
										$fdate =  date("Y-m-d", strtotime("2018-04-01")); 
										$tdate =  date("Y-m-d", strtotime("2019-03-31"));



//Capital Account Part
$fir = 0;
$sqluu = mysqli_query($conn, "select * from ledgerg where under='Current Assets'");  
while($rowuu = mysqli_fetch_array($sqluu)){
		$ledg = $rowuu['ledger']; $rrf = 0;
 

$sqlu = mysqli_query($conn, "select * from ledger where under='$ledg'");   $capvccdr =0; $capvcccr =0; $fir++;
while($rowu = mysqli_fetch_array($sqlu)){
	$ledgername = $rowu['ledger'];
$openbal = $rowu['openbal'];	
$yn = $rowu['yn'];
if($ledgername == 'Cash A/c') {
$cass11=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' && vtype='Payment' && par='Cash A/c' && date between '$fdate' and '$tdate'");
$cass1 = mysqli_fetch_array($cass11); $casss2 = 0;
$cass22=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && vtype='Receipt' && par='Cash A/c' && date between '$fdate' and '$tdate'");
$cass23 = mysqli_fetch_array($cass22);
$crascr = $cass1[0];
$crasdr = $cass23[0];

$cdoc=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && pmode='Cash A/c' && hpdate5 between '$fdate' and '$tdate'");
$cdoc1 = mysqli_fetch_array($cdoc);
$cdoc11 = $cdoc1[0];
$crcpt=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' && mode='Cash A/c' && paydate2 between '$fdate' and '$tdate'");
$crcpt1 = mysqli_fetch_array($crcpt);
$crcpt11 = $crcpt1[0];
$cnet=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' && mode='Cash A/c' && paydate2 between '$fdate' and '$tdate'");
$cnet1 = mysqli_fetch_array($cnet);
$cnet11 = $cnet1[0];

$captot = $openbal - $crascr + $crasdr - $cdoc11 + $crcpt11 + $cnet11;

if($rrf == 0) {
?>
<tr><td colspan="4"><b><?php echo $ledg; ?></b></td></tr> <?php } $rrf++; ?>
	<tr>
<td colspan="2"><font size="3"><b><?php echo  $ledgername ?></b></font></td>
<?php if($yn == 'Cr') { ?>
					<td><font size="3"><b><?php echo  $captot ?></b></font></td>
						<td><font size="3"></b></font></td></tr>
<?php } else { ?>
<td><font size="3"></b></font></td>
<td><font size="3"><b><?php echo  $captot ?></b></font></td></tr>
						
<?php } 

}

elseif($ledgername == 'Hp Party(s)') {

$sdcdoc=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && hpdate5 between '$fdate' and '$tdate'");
$sdcdoc1 = mysqli_fetch_array($sdcdoc);
$sdcdoc11 = $sdcdoc1[0];
$crcpt=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' && mode='Cash A/c' && paydate2 between '$fdate' and '$tdate'");
$crcpt1 = mysqli_fetch_array($crcpt);
$crcpt11 = $crcpt1[0];
$cnet=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' && mode='Cash A/c' && paydate2 between '$fdate' and '$tdate'");
$cnet1 = mysqli_fetch_array($cnet);
$cnet11 = $cnet1[0];

$captot = $sdcdoc11;

if($rrf == 0) {
?>
<tr><td colspan="4"><b><?php echo $ledg; ?></b></td></tr>
 <?php } $rrf++; ?>
	<tr>
<td colspan="2"><font size="3"><b><?php echo  $ledgername ?></b></font></td>

<td><font size="3"></b></font></td>
<td><font size="3"><b><?php echo  $captot ?></b></font></td></tr>
						
<?php  

}

elseif($ledg == 'Bank Accounts') {
$bcass11=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' && vtype='Payment' && par='$ledgername' && date between '$fdate' and '$tdate'");
$bcass1 = mysqli_fetch_array($bcass11); $bcasss2 = 0;
$bcass22=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && vtype='Receipt' && par='$ledgername' && date between '$fdate' and '$tdate'");
$bcass23 = mysqli_fetch_array($bcass22);
$bcrascr = $bcass1[0];
$bcrasdr = $bcass23[0];

$bcdoc=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && pmode='$ledgername' && hpdate5 between '$fdate' and '$tdate'");
$bcdoc1 = mysqli_fetch_array($bcdoc);
$bcdoc11 = $bcdoc1[0];
$bcrcpt=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' && mode='$ledgername' && paydate2 between '$fdate' and '$tdate'");
$bcrcpt1 = mysqli_fetch_array($crcpt);
$bcrcpt11 = $bcrcpt1[0];
$bcnet=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' && mode='$ledgername' && paydate2 between '$fdate' and '$tdate'");
$bcnet1 = mysqli_fetch_array($bcnet);
$bcnet11 = $bcnet1[0];

$captot = $openbal - $bcrascr + $bcrasdr - $cdoc11 + $crcpt11 + $cnet11;	

if($rrf == 0) {
?>
<tr><td colspan="4"><b><?php echo $ledg; ?></b></td></tr> <?php } $rrf++; ?>
	<tr>
<td colspan="2"><font size="3"><b><?php echo  $ledgername ?></b></font></td>
<?php if($yn == 'Cr') { ?>
					<td><font size="3"><b><?php echo  $captot ?></b></font></td>
						<td><font size="3"></b></font></td></tr>
<?php } else { ?>
<td><font size="3"></b></font></td>
<td><font size="3"><b><?php echo  $captot ?></b></font></td> </tr>
						
<?php } 

}
else {	
$qrya145=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && vtype='Payment' && par='$ledgername' && date between '$fdate' and '$tdate'");
$rowa145 = mysqli_fetch_array($qrya145);
$qryb145=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' && vtype='Receipt' && par='$ledgername' && date between '$fdate' and '$tdate'");
$rowb145 = mysqli_fetch_array($qryb145);

$capvccdr = $rowa145[0];
$capvcccr = $rowb145[0];
$captot = $openbal - $capvccdr + $capvcccr;

if($rrf == 0) {
?>
<tr><td colspan="4"><b><?php echo $ledg; ?></b></td></tr> <?php } $rrf++; ?>
	<tr>
<td colspan="2"><font size="3"><b><?php echo  $ledgername ?></b></font></td>
<?php if($yn == 'Cr') { ?>
					<td><font size="3"><b><?php echo  $captot ?></b></font></td>
						<td><font size="3"></b></font></td>
<?php } else { ?>
<td><font size="3"></b></font></td>
<td><font size="3"><b><?php echo  $captot ?></b></font></td>
						
<?php } 

} ?>

						
						</tr>
<?php
}
 }

$sqlu = mysqli_query($conn, "select * from ledger where under='Current Assets'");   $capvccdr =0; $capvcccr =0; $fir++;
while($rowu = mysqli_fetch_array($sqlu)){
	$ledgername = $rowu['ledger'];
$openbal = $rowu['openbal'];	
$yn = $rowu['yn'];


if($ledgername == 'Hp Party(s)') {

$sdcdoc=mysqli_query($conn, "select sum(hpamount) from customerdetails where mfin='$mfin' && hpdate5 between '$fdate' and '$tdate'");
$sdcdoc1 = mysqli_fetch_array($sdcdoc);
$sdcdoc11 = $sdcdoc1[0];
$crcpt=mysqli_query($conn, "select sum(urname) from user where mfin='$mfin' && mode='Cash A/c' && paydate2 between '$fdate' and '$tdate'");
$crcpt1 = mysqli_fetch_array($crcpt);
$crcpt11 = $crcpt1[0];
$cnet=mysqli_query($conn, "select sum(tot) from net where mfin='$mfin' && mode='Cash A/c' && paydate2 between '$fdate' and '$tdate'");
$cnet1 = mysqli_fetch_array($cnet);
$cnet11 = $cnet1[0];

$captot = $sdcdoc11;

if($rrf == 0) {
?>
<tr><td colspan="4"><b><?php echo $ledg; ?></b></td></tr>
 <?php } $rrf++; ?>
	<tr>
<td colspan="2"><font size="3"><b><?php echo  $ledgername ?></b></font></td>

<td><font size="3"></b></font></td>
<td><font size="3"><b><?php echo  $captot ?></b></font></td></tr>
						
<?php  

}

else {	
$qrya145=mysqli_query($conn, "select sum(dr) from voucher where mfin='$mfin' && vtype='Payment' && par='$ledgername' && date between '$fdate' and '$tdate'");
$rowa145 = mysqli_fetch_array($qrya145);
$qryb145=mysqli_query($conn, "select sum(cr) from voucher where mfin='$mfin' && vtype='Receipt' && par='$ledgername' && date between '$fdate' and '$tdate'");
$rowb145 = mysqli_fetch_array($qryb145);

$capvccdr = $rowa145[0];
$capvcccr = $rowb145[0];
$captot = $openbal - $capvccdr + $capvcccr;

if($rrf == 0) {
?>
<tr><td colspan="4"><b><?php echo $ledg; ?></b></td></tr> <?php } $rrf++; ?>
	<tr>
<td colspan="2"><font size="3"><b><?php echo  $ledgername ?></b></font></td>
<?php if($yn == 'Cr') { ?>
					<td><font size="3"><b><?php echo  $captot ?></b></font></td>
						<td><font size="3"></b></font></td>
<?php } else { ?>
<td><font size="3"></b></font></td>
<td><font size="3"><b><?php echo  $captot ?></b></font></td>
						
<?php } 

} ?>

						
						</tr>
<?php
}



$cpp = $cpp1 - $cpp2 - $capvccdr + $capvcccr;
////	//Capital Account Part
						?></p>
						
			
						
						

					
					</tbody></table>	</form>
					
</div>
</div></div>
</div></div></div><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>