<?php 
if(isset($_POST['refs'])){

extract($_POST);
$custid=$refs/253/253;
require 'connection.php';
$bal=0;
$drtotl=0;
$crtotl=0;

// Start Checking Date TODAY
if($dt==1){
$today=date('Y-m-d', strtotime('-0 days'));
$datess=date('Y-m-d', strtotime('-30 days'));
// Account Name
 $qry = "SELECT * from accreg where accid = '$custid'";
  $run_qry = mysqli_query($connect, $qry);
  $row=mysqli_fetch_array($run_qry);
  $accnames=$row['accname'];
        // while ($row=mysqli_fetch_array($run_qry)) {
      $qrylgropning = "SELECT sum(debit)-sum(credit) as opbal from ledger where accid = '$custid' and dated<'$today'";
  $run_qrylgropning = mysqli_query($connect, $qrylgropning);
  $rowlgropning=mysqli_fetch_array($run_qrylgropning);
  $bal=$bal+$rowlgropning['opbal'];
  
?>

<tr>
  <td colspan="5" style=" text-align: center; color: blue; font-size: 16px;">Account Name:</td>
</tr>
<tr>
  <td colspan="5" style=" text-align: center; color: red; font-size: 20px;"><?php echo $accnames; ?></td>
</tr>
<tr>
  <td colspan="4" style=" text-align: center; color: blue;">*******Opening Balance*******</td>
  <td colspan="1" style=" text-align: center; color: blue;"><?php echo $rowlgropning['opbal']; ?></td>
  
</tr>
<tr>
  <td style=" text-align: center; color: white; background-color: #131797;">Dated</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Narration</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Debit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Credit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Balance</td>
</tr>
   <?php
$tdclr='#A3CEF9';

    $qrylgr = "SELECT * from ledger where accid = '$custid' and dated>='$today' and itemid=0 order by dated,trid asc";
  $run_qrylgr = mysqli_query($connect, $qrylgr);
  while ($rowlgr=mysqli_fetch_array($run_qrylgr)) {
       $bal=$bal+$rowlgr['debit']-$rowlgr['credit'];
       $drtotl=$drtotl+$rowlgr['debit'];
       $crtotl=$crtotl+$rowlgr['credit'];

       // TD Color Setting
 if($tdclr=='#FDFEFF'){
 $tdclr='#A3CEF9';
 }
 else{
 $tdclr='#FDFEFF';

 }
?>


    <tr>
  <td colspan="1" style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['dated']; ?></td>

  <td colspan="1" style=" text-align: left; color: black; background-color: <?php echo $tdclr; ?>; "><?php echo $rowlgr['description']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['debit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['credit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $bal; ?></td>
</tr>

 
<?php
}

?>
   <tr>
 <td colspan="2" style=" text-align: center; color: white; background-color: #131797;">
<label style="color: black; background-color: cyan;">Debit </label>
<label>/</label>
<label style="color: black; background-color: yellow;">Credit </label>
<label>/</label>
<label style="color: black; background-color: white;">Balance </label>
  </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
   <label style="color: black; background-color: cyan;"><?php echo $drtotl; ?></label>
    </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: yellow;"><?php echo $crtotl; ?></label>
  </td>
  
  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: white;">
      <?php echo $drtotl-$crtotl; ?></label></td>
</tr>
   <tr>
 <td colspan="4" style=" text-align: center; color: white; background-color: #131797;">*******Current Balance*******</td>
  <td colspan="1" style=" text-align: center; color: white; background-color: #131797;"><?php echo $bal; ?></td>
</tr>
<?php
}
// End Checking Date Option TODAY

// Start Checking Date YESTERDAY
if($dt==2){
$yesterday=date('Y-m-d', strtotime('-1 days'));
$datess=date('Y-m-d', strtotime('-30 days'));
// Account Name
 $qry = "SELECT * from accreg where accid = '$custid'";
  $run_qry = mysqli_query($connect, $qry);
  $row=mysqli_fetch_array($run_qry);
  $accnames=$row['accname'];
        // while ($row=mysqli_fetch_array($run_qry)) {
     $qrylgropning = "SELECT sum(debit)-sum(credit) as opbal from ledger where accid = '$custid' and dated<'$yesterday'";
  $run_qrylgropning = mysqli_query($connect, $qrylgropning);
  $rowlgropning=mysqli_fetch_array($run_qrylgropning);
  $bal=$bal+$rowlgropning['opbal'];
    
?>

<tr>
  <td colspan="5" style=" text-align: center; color: blue; font-size: 16px;">Account Name:</td>
</tr>
<tr>
  <td colspan="5" style=" text-align: center; color: red; font-size: 20px;"><?php echo $accnames; ?></td>
</tr>
</tr>
<tr>
  <td colspan="4" style=" text-align: center; color: blue;">*******Opening Balance*******</td>
  <td colspan="1" style=" text-align: center; color: blue;"><?php echo $rowlgropning['opbal']; ?></td>
  
</tr>
<tr>
  <td style=" text-align: center; color: white; background-color: #131797;">Dated</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Narration</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Debit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Credit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Balance</td>
</tr>
 background-color: cyan;

   <?php
  
    $qrylgr = "SELECT * from ledger where accid = '$custid' and dated>='$yesterday' and itemid=0 order by dated,trid asc";
  $run_qrylgr = mysqli_query($connect, $qrylgr);
  while ($rowlgr=mysqli_fetch_array($run_qrylgr)) {

    $bal=$bal+$rowlgr['debit']-$rowlgr['credit'];
      $drtotl=$drtotl+$rowlgr['debit'];
       $crtotl=$crtotl+$rowlgr['credit'];
    $dateto=$rowlgr['dated'];
      $rundate = $rowlgr['dated'];
         $dat= date_create($rundate);
         $dated=date_format($dat,"d-m-Y");

       // TD Color Setting
 if($tdclr=='#FDFEFF'){
 $tdclr='#A3CEF9';
 }
 else{
 $tdclr='#FDFEFF';

}
    if($dateto1!==$dateto){
      ?>
      <tr>
  </tr>
  <?php
    $dateto1=$rowlgr['dated'];

    }
?>
  

    <tr>
  <td colspan="1" style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $dated; ?></td>

  <td colspan="1" style=" text-align: left; color: black; background-color: <?php echo $tdclr; ?>; "><?php echo $rowlgr['description']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['debit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['credit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $bal; ?></td>
</tr>
<?php
}
?>
  
   <tr>
 <td colspan="2" style=" text-align: center; color: white; background-color: #131797;">
<label style="color: black; background-color: cyan;">Debit </label>
<label>/</label>
<label style="color: black; background-color: yellow;">Credit </label>
<label>/</label>
<label style="color: black; background-color: white;">Balance </label>
  </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
   <label style="color: black; background-color: cyan;"><?php echo $drtotl; ?></label>
    </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: yellow;"><?php echo $crtotl; ?></label>
  </td>
  
  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: white;">
      <?php echo $drtotl-$crtotl; ?></label></td>
</tr>
   <tr>
 <td colspan="4" style=" text-align: center; color: white; background-color: #131797;">*******Current Balance*******</td>
  <td colspan="1" style=" text-align: center; color: white; background-color: #131797;"><?php echo $bal; ?></td>
</tr>
<?php
}
// End Checking Date Option YESTERDAY



// Start Checking Date LAST 7 DAYS
if($dt==3){
$sevenday=date('Y-m-d', strtotime('-7 days'));
$datess=date('Y-m-d', strtotime('-30 days'));
// Account Name
 $qry = "SELECT * from accreg where accid = '$custid'";
  $run_qry = mysqli_query($connect, $qry);
  $row=mysqli_fetch_array($run_qry);
  $accnames=$row['accname'];


   $qrylgropning = "SELECT sum(debit)-sum(credit) as opbal from ledger where accid = '$custid' and dated<'$sevenday'";
  $run_qrylgropning = mysqli_query($connect, $qrylgropning);
  $rowlgropning=mysqli_fetch_array($run_qrylgropning);
  $bal=$bal+$rowlgropning['opbal'];
        // while ($row=mysqli_fetch_array($run_qry)) {
    
?>

<tr>
  <td colspan="5" style=" text-align: center; color: blue; font-size: 16px;">Account Name:</td>
</tr>
<tr>
  <td colspan="5" style=" text-align: center; color: red; font-size: 20px;"><?php echo $accnames; ?></td>
</tr>
<tr>
  <td colspan="4" style=" text-align: center; color: blue;">*******Opening Balance*******</td>
  <td colspan="1" style=" text-align: center; color: blue;"><?php echo $rowlgropning['opbal']; ?></td>
  
</tr>
<tr>
  <td style=" text-align: center; color: white; background-color: #131797;">Dated</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Narration</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Debit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Credit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Balance</td>
</tr>
   <?php
    $qrylgr = "SELECT * from ledger where accid = '$custid' and dated>='$sevenday' and itemid=0 order by dated,trid asc";
  $run_qrylgr = mysqli_query($connect, $qrylgr);
  while ($rowlgr=mysqli_fetch_array($run_qrylgr)) {
       $bal=$bal+$rowlgr['debit']-$rowlgr['credit'];
         $drtotl=$drtotl+$rowlgr['debit'];
       $crtotl=$crtotl+$rowlgr['credit'];
  $rundate = $rowlgr['dated'];
         $dat= date_create($rundate);
         $dated=date_format($dat,"d-m-Y");
                // TD Color Setting
 if($tdclr=='#FDFEFF'){
 $tdclr='#A3CEF9';
 }
 else{
 $tdclr='#FDFEFF';

}
?>

    <tr>
  <td colspan="1" style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $dated; ?></td>

  <td colspan="1" style=" text-align: left; color: black; background-color: <?php echo $tdclr; ?>; "><?php echo $rowlgr['description']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['debit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['credit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $bal; ?></td>
</tr>
<?php
}
?>
   <tr>
 <td colspan="2" style=" text-align: center; color: white; background-color: #131797;">
<label style="color: black; background-color: cyan;">Debit </label>
<label>/</label>
<label style="color: black; background-color: yellow;">Credit </label>
<label>/</label>
<label style="color: black; background-color: white;">Balance </label>
  </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
   <label style="color: black; background-color: cyan;"><?php echo $drtotl; ?></label>
    </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: yellow;"><?php echo $crtotl; ?></label>
  </td>
  
  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: white;">
      <?php echo $drtotl-$crtotl; ?></label></td>
</tr>
   <tr>
  <td colspan="4" style=" text-align: center; color: white; background-color: #131797;">*******Current Balance*******</td>
  <td colspan="1" style=" text-align: center; color: white; background-color: #131797;"><?php echo $bal; ?></td>
</tr>
<?php
}
// End Checking Date Option LAST 7 DAYS



// Start Checking Date THIS MONTH
if($dt==4){
     date_default_timezone_set("Asia/Karachi");

     $d = date("d");
      $m = date('m');
      $y = date("Y");
     $thismonth = $y.'-'.$m.'-1';
// Account Name
 $qry = "SELECT * from accreg where accid = '$custid'";
  $run_qry = mysqli_query($connect, $qry);
  $row=mysqli_fetch_array($run_qry);
  $accnames=$row['accname'];


   $qrylgropning = "SELECT sum(debit)-sum(credit) as opbal from ledger where accid = '$custid' and dated<'$thismonth'";
  $run_qrylgropning = mysqli_query($connect, $qrylgropning);
  $rowlgropning=mysqli_fetch_array($run_qrylgropning);
  $bal=$bal+$rowlgropning['opbal'];
    
?>

<tr>
  <td colspan="5" style=" text-align: center; color: blue; font-size: 16px;">Account Name:</td>
</tr>
<tr>
  <td colspan="5" style=" text-align: center; color: red; font-size: 20px;"><?php echo $accnames; ?></td>
</tr>
<tr>
  <td colspan="4" style=" text-align: center; color: blue;">*******Opening Balance*******</td>
  <td colspan="1" style=" text-align: center; color: blue;"><?php echo $rowlgropning['opbal']; ?></td>
  
</tr>
<tr>
  <td style=" text-align: center; color: white; background-color: #131797;">Dated</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Narration</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Debit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Credit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Balance</td>
</tr>
   <?php
    $qrylgr = "SELECT * from ledger where accid = '$custid' and dated>='$thismonth' and itemid=0 order by dated,trid asc";
  $run_qrylgr = mysqli_query($connect, $qrylgr);
  while ($rowlgr=mysqli_fetch_array($run_qrylgr)) {
       $bal=$bal+$rowlgr['debit']-$rowlgr['credit'];
         $drtotl=$drtotl+$rowlgr['debit'];
       $crtotl=$crtotl+$rowlgr['credit'];
            $rundate = $rowlgr['dated'];
         $dat= date_create($rundate);
         $dated=date_format($dat,"d-m-Y");
                // TD Color Setting
 if($tdclr=='#FDFEFF'){
 $tdclr='#A3CEF9';
 }
 else{
 $tdclr='#FDFEFF';

}
?>


    <tr>
  <td colspan="1" style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $dated; ?></td>

  <td colspan="1" style=" text-align: left; color: black; background-color: <?php echo $tdclr; ?>; "><?php echo $rowlgr['description']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['debit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['credit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $bal; ?></td>
</tr>
<?php
}
?>
   <tr>
 <td colspan="2" style=" text-align: center; color: white; background-color: #131797;">
<label style="color: black; background-color: cyan;">Debit </label>
<label>/</label>
<label style="color: black; background-color: yellow;">Credit </label>
<label>/</label>
<label style="color: black; background-color: white;">Balance </label>
  </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
   <label style="color: black; background-color: cyan;"><?php echo $drtotl; ?></label>
    </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: yellow;"><?php echo $crtotl; ?></label>
  </td>
  
  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: white;">
      <?php echo $drtotl-$crtotl; ?></label></td>
</tr>
   <tr>
  <td colspan="4" style=" text-align: center; color: white; background-color: #131797;">*******Current Balance*******</td>
  <td colspan="1" style=" text-align: center; color: white; background-color: #131797;"><?php echo $bal; ?></td>
</tr>
<?php
}
// End Checking Date Option THIS MONTH



// Start Checking Date THIS MONTH
if($dt==5){
     date_default_timezone_set("Asia/Karachi");
  
     $d = date("d");
      $m = date('m')-1;
      $y = date("Y");
     $thismonth = $y.'-'.$m.'-1';
// Account Name
 $qry = "SELECT * from accreg where accid = '$custid'";
  $run_qry = mysqli_query($connect, $qry);
  $row=mysqli_fetch_array($run_qry);
  $accnames=$row['accname'];


   $qrylgropning = "SELECT sum(debit)-sum(credit) as opbal from ledger where accid = '$custid' and dated<'$thismonth'";
  $run_qrylgropning = mysqli_query($connect, $qrylgropning);
  $rowlgropning=mysqli_fetch_array($run_qrylgropning);
  $bal=$bal+$rowlgropning['opbal'];
    
?>

<tr>
  <td colspan="5" style=" text-align: center; color: blue; font-size: 16px;">Account Name:</td>
</tr>
<tr>
  <td colspan="5" style=" text-align: center; color: red; font-size: 20px;"><?php echo $accnames; ?></td>
</tr>
<tr>
  <td colspan="4" style=" text-align: center; color: blue;">*******Opening Balance*******</td>
  <td colspan="1" style=" text-align: center; color: blue;"><?php echo $rowlgropning['opbal']; ?></td>
  
</tr>
<tr>
  <td style=" text-align: center; color: white; background-color: #131797;">Dated</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Narration</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Debit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Credit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Balance</td>
</tr>
   <?php
    $qrylgr = "SELECT * from ledger where accid = '$custid' and dated>='$thismonth' and itemid=0 order by dated,trid asc";
  $run_qrylgr = mysqli_query($connect, $qrylgr);
  while ($rowlgr=mysqli_fetch_array($run_qrylgr)) {
       $bal=$bal+$rowlgr['debit']-$rowlgr['credit'];
         $drtotl=$drtotl+$rowlgr['debit'];
       $crtotl=$crtotl+$rowlgr['credit'];
        $rundate = $rowlgr['dated'];
         $dat= date_create($rundate);
         $dated=date_format($dat,"d-m-Y");

                // TD Color Setting
 if($tdclr=='#FDFEFF'){
 $tdclr='#A3CEF9';
 }
 else{
 $tdclr='#FDFEFF';

}
?>


    <tr>
  <td colspan="1" style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $dated; ?></td>

  <td colspan="1" style=" text-align: left; color: black; background-color: <?php echo $tdclr; ?>; "><?php echo $rowlgr['description']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['debit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['credit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $bal; ?></td>
</tr>
<?php
}
?>
   <tr>
 <td colspan="2" style=" text-align: center; color: white; background-color: #131797;">
<label style="color: black; background-color: cyan;">Debit </label>
<label>/</label>
<label style="color: black; background-color: yellow;">Credit </label>
<label>/</label>
<label style="color: black; background-color: white;">Balance </label>
  </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
   <label style="color: black; background-color: cyan;"><?php echo $drtotl; ?></label>
    </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: yellow;"><?php echo $crtotl; ?></label>
  </td>
  
  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: white;">
      <?php echo $drtotl-$crtotl; ?></label></td>
</tr>
   <tr>
  <td colspan="4" style=" text-align: center; color: white; background-color: #131797;">*******Current Balance*******</td>
  <td colspan="1" style=" text-align: center; color: white; background-color: #131797;"><?php echo $bal; ?></td>
</tr>
<?php
}
// End Checking Date Option THIS MONTH


// Start Checking single Date Option 
if($dt==10){
  
     $singldate = $dt2;
// Account Name
 $qry = "SELECT * from accreg where accid = '$custid'";
  $run_qry = mysqli_query($connect, $qry);
  $row=mysqli_fetch_array($run_qry);
  $accnames=$row['accname'];


   $qrylgropning = "SELECT sum(debit)-sum(credit) as opbal from ledger where accid = '$custid' and dated<'$singldate'";
  $run_qrylgropning = mysqli_query($connect, $qrylgropning);
  $rowlgropning=mysqli_fetch_array($run_qrylgropning);
  $bal=$bal+$rowlgropning['opbal'];
    
?>

<tr>
  <td colspan="5" style=" text-align: center; color: blue; font-size: 16px;">Account Name:</td>
</tr>
<tr>
  <td colspan="5" style=" text-align: center; color: red; font-size: 20px;"><?php echo $accnames; ?></td>
</tr>

<tr>
  <td style=" text-align: center; color: white; background-color: #131797;">Dated</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Narration</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Debit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Credit</td>
  <td style=" text-align: center; color: white; background-color: #131797;">Balance</td>
</tr>
   <?php
    $qrylgr = "SELECT * from ledger where accid = '$custid' and dated='$singldate' and itemid=0 order by dated,trid asc";
  $run_qrylgr = mysqli_query($connect, $qrylgr);
  while ($rowlgr=mysqli_fetch_array($run_qrylgr)) {
       $bal=$bal+$rowlgr['debit']-$rowlgr['credit'];
         $drtotl=$drtotl+$rowlgr['debit'];
       $crtotl=$crtotl+$rowlgr['credit'];
        $rundate = $rowlgr['dated'];
         $dat= date_create($rundate);
         $dated=date_format($dat,"d-m-Y");

                // TD Color Setting
 if($tdclr=='#FDFEFF'){
 $tdclr='#A3CEF9';
 }
 else{
 $tdclr='#FDFEFF';

}
?>


    <tr>
  <td colspan="1" style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $dated; ?></td>

  <td colspan="1" style=" text-align: left; color: black; background-color: <?php echo $tdclr; ?>; "><?php echo $rowlgr['description']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['debit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $rowlgr['credit']; ?></td>
  <td style=" text-align: center; color: black; background-color: <?php echo $tdclr; ?>;"><?php echo $bal; ?></td>
</tr>
<?php
}
?>
   <tr>
 <td colspan="2" style=" text-align: center; color: white; background-color: #131797;">
<label style="color: black; background-color: cyan;">Debit </label>
<label>/</label>
<label style="color: black; background-color: yellow;">Credit </label>
<label>/</label>
<label style="color: black; background-color: white;">Balance </label>
  </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
   <label style="color: black; background-color: cyan;"><?php echo $drtotl; ?></label>
    </td>

  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: yellow;"><?php echo $crtotl; ?></label>
  </td>
  
  <td colspan="1" style=" text-align: center; color: black; background-color: #131797;">
    <label style="color: black; background-color: white;">
      <?php echo $drtotl-$crtotl; ?></label></td>
</tr>
 
<?php
}
// End Checking single Date Option 




}
// }

?>
