<?php
ini_set('display_errors', 0);
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

session_start();
ob_start();

require_once('configuration/server_connect.php');
require_once('configuration/all_function.php');
$active_id=$_REQUEST['active_id'];
$menu_id=$_REQUEST['menu_id'];
$page_title="Quarterly Profit &amp; Loss Statement";



?>


<!DOCTYPE html>
<html lang="en">


<!-- ======= <head> ======= -->
 <?php require_once('inc_files/inc_head.php'); ?>
<!-- ======= </head> ======= -->

<?php
  do_calander('#fdate');
  do_calander('#tdate');

  ?>
  

<body>

  <!-- ======= Header ======= -->
 
  
  <?php 
  require_once('inc_files/inc_header.php');
  ?>
  
  <!-- End Header -->

  <!-- ======= Sidebar ======= -->
   <?php  require_once('inc_files/inc_menu.php'); ?><!-- End Sidebar-->

  <main id="main" class="main">

    <div class="pagetitle">
      <h1><?php echo $page_title?></h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="home.php">Home</a></li>
		  <li class="breadcrumb-item"> Reports</li>    
          <li class="breadcrumb-item active"><?php echo $page_title?></li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section">
      <div class="row">
	  
	
		<div class="col-lg-12"> 

          <div class="card">
            <div class="card-body">
            <p class="card-title" style="font-size:14px; margin-bottom:0; padding-bottom:0;"><a href="61_reports_all.php?active_id=901&menu_id=9">< Back To Report List </a></p>

              <!-- No Labels Form -->
           <form class="row g-3" action="" method="post" name="codz" id="codz">
   		       
			
	<table width="80%" border="0" align="center">
      
      
      <tr height="50">
        <td width="30%" align="right">Date Interval:&nbsp;&nbsp;</td>
        <td width="20%"  align="center"><strong>
          <input type="text" name="fdate" id="fdate" class="form-control" style="width:150px;" value="<?php echo isset($_REQUEST['fdate'])?$_REQUEST['fdate']:date('Y-01-01');?>" />
        </strong></td>
        <td width="5%" align="center" ><strong> -to- </strong></td>
        <td width="20%"  align="center" ><strong>
          <input type="text" name="tdate" id="tdate" class="form-control" style="width:150px;" value="<?php echo isset($_REQUEST['tdate'])?$_REQUEST['tdate']:date('Y-12-31');?>" />
        </strong></td>
        <td width="25%" rowspan="3" align="center" ><strong>
          &nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-success rounded-pill btn-sm">&nbsp;<i class="bi bi-filter me-1"></i> Run Report&nbsp;&nbsp;</button>
        </strong></td>
      </tr>
      
      
    </table>
               
  </form><!-- End No Labels Form -->

            </div>
          </div>
		
		</div>
		
		
	  
	  
        <div class="col-lg-12"> 

          <div class="card">
            <div class="card-body">
			<br>
			
<?php
				
if($_REQUEST['fdate']==''){
$_REQUEST['fdate']=date('Y-01-01');
}

if($_REQUEST['tdate']==''){
$_REQUEST['tdate']=date('Y-12-31');
}

//if($_POST['fdate']!=''&&$_POST['tdate']!='')
$date_con .= ' and m.jv_date between "'.$_REQUEST['fdate'].'" and "'.$_REQUEST['tdate'].'"';

//$py_fdate =  date('Y-m-d', strtotime($_REQUEST['fdate'].' - 1 year'));
//$py_tdate =  date('Y-m-d', strtotime($_REQUEST['tdate'].' - 1 year'));

$YR = date('Y',strtotime($_REQUEST['fdate']));

$fdate_q1=$YR.'-01-01';
$tdate_q1=$YR.'-03-31';

$fdate_q2=$YR.'-04-01';
$tdate_q2=$YR.'-06-30';

$fdate_q3=$YR.'-07-01';
$tdate_q3=$YR.'-09-30';

$fdate_q4=$YR.'-10-01';
$tdate_q4=$YR.'-12-31';
      
	?>		
			 
             

              <!-- Table with stripped rows -->
              <table width="36%" class="table table-sm" style="font-size:12px;">
                <thead>
                  <tr style="text-transform:uppercase; font-size:12px; color:#012970; background:#EAEAEA; border-top: 1px solid #CCCCCC;">
                    <th width="7%"  scope="col"> Code</th>
                    <th width="17%"  scope="col"> Account </th>
               
                    <th width="20%" scope="col"><div style="text-align:right;"><?php echo date('d M',strtotime($fdate_q1));?> - <?php echo date('d M, y',strtotime($tdate_q1));?></div></th>
                    <th width="20%" scope="col"><div style="text-align:right;"><?php echo date('d M',strtotime($fdate_q2));?> - <?php echo date('d M, y',strtotime($tdate_q2));?></div></th>
                    <th width="18%" scope="col"><div style="text-align:right;"><?php echo date('d M',strtotime($fdate_q3));?> - <?php echo date('d M, y',strtotime($tdate_q3));?></div></th>
                    <th width="18%" scope="col"><div style="text-align:right;"><?php echo date('d M',strtotime($fdate_q4));?> - <?php echo date('d M, y',strtotime($tdate_q4));?></div></th>
                  </tr>
                </thead>
                <tbody>
<?php
				

		 
		 $sql = "select a.ledger_group_id,  sum(j.cr_amt-j.dr_amt) as q1_income_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q1."' and '".$tdate_q1."' and g.acc_class in (3) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q1_income_amt[$info->ledger_group_id]=$info->q1_income_amt;
		 }
		 
		  $sql = "select a.ledger_group_id,  sum(j.dr_amt-j.cr_amt) as q1_expense_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q1."' and '".$tdate_q1."' and g.acc_class in (4) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q1_expense_amt[$info->ledger_group_id]=$info->q1_expense_amt;
		 }
		 
		 
		 
		 $sql = "select a.ledger_group_id,  sum(j.cr_amt-j.dr_amt) as q2_income_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q2."' and '".$tdate_q2."' and g.acc_class in (3) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q2_income_amt[$info->ledger_group_id]=$info->q2_income_amt;
		 }
		 
		  $sql = "select a.ledger_group_id,  sum(j.dr_amt-j.cr_amt) as q2_expense_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q2."' and '".$tdate_q2."' and g.acc_class in (4) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q2_expense_amt[$info->ledger_group_id]=$info->q2_expense_amt;
		 }
		 
	
		 $sql = "select a.ledger_group_id,  sum(j.cr_amt-j.dr_amt) as q3_income_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q3."' and '".$tdate_q3."' and g.acc_class in (3) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q3_income_amt[$info->ledger_group_id]=$info->q3_income_amt;
		 }
		 
		  $sql = "select a.ledger_group_id,  sum(j.dr_amt-j.cr_amt) as q3_expense_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q3."' and '".$tdate_q3."' and g.acc_class in (4) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q3_expense_amt[$info->ledger_group_id]=$info->q3_expense_amt;
		 }
		 
		 
		 $sql = "select a.ledger_group_id,  sum(j.cr_amt-j.dr_amt) as q4_income_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q4."' and '".$tdate_q4."' and g.acc_class in (3) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q4_income_amt[$info->ledger_group_id]=$info->q4_income_amt;
		 }
		 
		  $sql = "select a.ledger_group_id,  sum(j.dr_amt-j.cr_amt) as q4_expense_amt from ledger_group g, accounts_ledger a, journal j 
		 where  g.group_id=a.ledger_group_id and a.ledger_id=j.ledger_id and  j.jv_date between '".$fdate_q4."' and '".$tdate_q4."' and g.acc_class in (4) group by a.ledger_group_id";
		 $query = mysqli_query($conn,$sql);
		 while($info=mysqli_fetch_object($query)){
  		 $q4_expense_amt[$info->ledger_group_id]=$info->q4_expense_amt;
		 }	
		 
		 		
		?>
				
				<?php
						$sql_grp = 'select g.acc_sub_class, c.sub_class_name from acc_sub_class c, ledger_group g, accounts_ledger a where c.id=g.acc_sub_class and g.group_id=a.ledger_group_id  
						and c.acc_class in (3) '.$group_con.'
						group by g.acc_sub_class order by c.id';
						$query_grp = mysqli_query($conn,$sql_grp);
						while ($data_grp = mysqli_fetch_object($query_grp)) {
				
				?>
				
				
                  <tr style="text-transform:uppercase; font-size:12px; color:#012970; background:#f6f9ff;; font-weight:700; border-top: 1px solid #CCCCCC;">
                    <th width="7%" scope="col" >&nbsp;</th>
                    <th width="17%" scope="col" ><?php echo $data_grp->sub_class_name; ?> </th>
                    <th width="20%" scope="col" ><div style="text-align:right">&nbsp;</div> </th>
                    <th width="20%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                    <th width="18%" scope="col" >&nbsp;</th>
                    <th width="18%" scope="col" >&nbsp;</th>
                  </tr>
               
				
		
				
				
				
				<?php			
					
						$sql = 'select g.* from ledger_group g, accounts_ledger a where g.group_id=a.ledger_group_id and g.acc_sub_class="'.$data_grp->acc_sub_class.'"
						 group by g.group_id order by g.group_id';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
		
                 
                 <tr>
                   <td><?php echo $data->group_id;?></td>
                   <td><?php echo $data->group_name;?></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q1?>&tdate=<?=$tdate_q1?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; "><?php  echo number_format($q1_income_amt[$data->group_id],2); $sub_tot_q1_income_amt +=$q1_income_amt[$data->group_id]; ?></a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q2?>&tdate=<?=$tdate_q2?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q2_income_amt[$data->group_id],2); $sub_tot_q2_income_amt +=$q2_income_amt[$data->group_id]; ?>
                   </a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q3?>&tdate=<?=$tdate_q3?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q3_income_amt[$data->group_id],2); $sub_tot_q3_income_amt +=$q3_income_amt[$data->group_id]; ?>
                   </a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q4?>&tdate=<?=$tdate_q4?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q4_income_amt[$data->group_id],2); $sub_tot_q4_income_amt +=$q4_income_amt[$data->group_id]; ?>
                   </a></td>
                 </tr>
				  <?php }?>
	
                 <tr>
                   <td>&nbsp;</td>
                   <td align="center"><strong>SUB TOTAL</strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q1_income_amt,2); $grand_tot_q1_income_amt +=$sub_tot_q1_income_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q2_income_amt,2); $grand_tot_q2_income_amt +=$sub_tot_q2_income_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q3_income_amt,2); $grand_tot_q3_income_amt +=$sub_tot_q3_income_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q4_income_amt,2); $grand_tot_q4_income_amt +=$sub_tot_q4_income_amt;?></strong></td>
                 </tr>
				 <?php 
				 $sub_tot_q1_income_amt = 0;
				 $sub_tot_q2_income_amt = 0;
				 $sub_tot_q3_income_amt = 0;
				 $sub_tot_q4_income_amt = 0;
				 }?>
				 
				 
				 <tr style="background:#f6f9ff;">
                   <td>&nbsp;</td>
                   <td align="center"><strong>TOTAL INCOME</strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q1_income_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q2_income_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q3_income_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q4_income_amt,2);?></strong></td>
				 </tr>
				  
				  
				  
				  <?php
						$sql_grp = 'select g.acc_sub_class, c.sub_class_name from acc_sub_class c, ledger_group g, accounts_ledger a where c.id=g.acc_sub_class and g.group_id=a.ledger_group_id  
						and c.id in (41) '.$group_con.'
						group by g.acc_sub_class order by c.id';
						$query_grp = mysqli_query($conn,$sql_grp);
						while ($data_grp = mysqli_fetch_object($query_grp)) {
				
				?>
				
				
                  <tr style="text-transform:uppercase; font-size:12px; color:#012970; background:#f6f9ff;; font-weight:700; border-top: 1px solid #CCCCCC;">
                    <th width="7%" scope="col" >&nbsp;</th>
                    <th width="17%" scope="col" ><?php echo $data_grp->sub_class_name; ?> </th>
                    <th width="20%" scope="col" ><div style="text-align:right">&nbsp;</div> </th>
                    <th width="20%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                    <th width="18%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                    <th width="18%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                  </tr>
               
				
		
				
				
				
				<?php			
					
						$sql = 'select g.* from ledger_group g, accounts_ledger a where g.group_id=a.ledger_group_id and g.acc_sub_class="'.$data_grp->acc_sub_class.'"
						 group by g.group_id order by g.group_id';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
		
                 
                 <tr>
                   <td><?php echo $data->group_id;?></td>
                   <td><?php echo $data->group_name;?></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q1?>&tdate=<?=$tdate_q1?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; "><?php  echo number_format($q1_expense_amt[$data->group_id],2); $sub_tot_cogs_q1_expense_amt +=$q1_expense_amt[$data->group_id]; ?></a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q2?>&tdate=<?=$tdate_q2?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q2_expense_amt[$data->group_id],2); $sub_tot_cogs_q2_expense_amt +=$q2_expense_amt[$data->group_id]; ?>
                   </a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q3?>&tdate=<?=$tdate_q3?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q3_expense_amt[$data->group_id],2); $sub_tot_cogs_q3_expense_amt +=$q3_expense_amt[$data->group_id]; ?>
                   </a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q4?>&tdate=<?=$tdate_q4?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q4_expense_amt[$data->group_id],2); $sub_tot_cogs_q4_expense_amt +=$q4_expense_amt[$data->group_id]; ?>
                   </a></td>
                 </tr>
				  <?php }?>
	
                 <tr>
                   <td>&nbsp;</td>
                   <td align="center"><strong>TOTAL COST OF SALES</strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_cogs_q1_expense_amt,2); $grand_tot_cogs_q1_expense_amt +=$sub_tot_cogs_q1_expense_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_cogs_q2_expense_amt,2); $grand_tot_cogs_q2_expense_amt +=$sub_tot_cogs_q2_expense_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_cogs_q3_expense_amt,2); $grand_tot_cogs_q3_expense_amt +=$sub_tot_cogs_q3_expense_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_cogs_q4_expense_amt,2); $grand_tot_cogs_q4_expense_amt +=$sub_tot_cogs_q4_expense_amt;?></strong></td>
                 </tr>
				 <?php 
				 $sub_tot_cogs_q1_expense_amt = 0;
				 $sub_tot_cogs_q2_expense_amt = 0;
				 $sub_tot_cogs_q3_expense_amt = 0;
				 $sub_tot_cogs_q4_expense_amt = 0;
				 }?>
				 
				 
				 <tr style="background:#f6f9ff;">
                   <td>&nbsp;</td>
                   <td align="center"><strong>GROSS PROFIT</strong></td>
                   <td align="right"><strong><?php echo number_format($q1_gross_profit_amt=$grand_tot_q1_income_amt-$grand_tot_cogs_q1_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($q2_gross_profit_amt=$grand_tot_q2_income_amt-$grand_tot_cogs_q2_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($q3_gross_profit_amt=$grand_tot_q3_income_amt-$grand_tot_cogs_q3_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($q4_gross_profit_amt=$grand_tot_q4_income_amt-$grand_tot_cogs_q4_expense_amt,2);?></strong></td>
				 </tr>
				  
				  
				  
				  <?php
						$sql_grp = 'select g.acc_sub_class, c.sub_class_name from acc_sub_class c, ledger_group g, accounts_ledger a where c.id=g.acc_sub_class and g.group_id=a.ledger_group_id  
						and c.acc_class in (4) and c.id not in (41) '.$group_con.'
						group by g.acc_sub_class order by c.id';
						$query_grp = mysqli_query($conn,$sql_grp);
						while ($data_grp = mysqli_fetch_object($query_grp)) {
				
				?>
				
				
                  <tr style="text-transform:uppercase; font-size:12px; color:#012970; background:#f6f9ff;; font-weight:700; border-top: 1px solid #CCCCCC;">
                    <th width="7%" scope="col" >&nbsp;</th>
                    <th width="17%" scope="col" ><?php echo $data_grp->sub_class_name; ?> </th>
                    <th width="20%" scope="col" ><div style="text-align:right">&nbsp;</div> </th>
                    <th width="20%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                    <th width="18%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                    <th width="18%" scope="col" ><div style="text-align:right">&nbsp;</div></th>
                  </tr>
               
				
		
				
				
				
				<?php			
					
						$sql = 'select g.* from ledger_group g, accounts_ledger a where g.group_id=a.ledger_group_id and g.acc_sub_class="'.$data_grp->acc_sub_class.'"
						 group by g.group_id order by g.group_id';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
		
                 
                 <tr>
                   <td><?php echo $data->group_id;?></td>
                   <td><?php echo $data->group_name;?></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q1?>&tdate=<?=$tdate_q1?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; "><?php  echo number_format($q1_expense_amt[$data->group_id],2); $sub_tot_q1_expense_amt +=$q1_expense_amt[$data->group_id]; ?></a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q2?>&tdate=<?=$tdate_q2?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q2_expense_amt[$data->group_id],2); $sub_tot_q2_expense_amt +=$q2_expense_amt[$data->group_id]; ?>
                   </a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q3?>&tdate=<?=$tdate_q3?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q3_expense_amt[$data->group_id],2); $sub_tot_q3_expense_amt +=$q3_expense_amt[$data->group_id]; ?>
                   </a></td>
                   <td align="right"><a href="61_account_03.php?show=show&fdate=<?=$fdate_q4?>&tdate=<?=$tdate_q4?>&gl_group=<?=$data->group_id.' :: '.$data->group_name;?>" target="_blank" style="text-decoration:none; ">
                     <?php  echo number_format($q4_expense_amt[$data->group_id],2); $sub_tot_q4_expense_amt +=$q4_expense_amt[$data->group_id]; ?>
                   </a></td>
                 </tr>
				  <?php }?>
	
                 <tr>
                   <td>&nbsp;</td>
                   <td align="center"><strong>SUB TOTAL</strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q1_expense_amt,2); $grand_tot_q1_expense_amt +=$sub_tot_q1_expense_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q2_expense_amt,2); $grand_tot_q2_expense_amt +=$sub_tot_q2_expense_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q3_expense_amt,2); $grand_tot_q3_expense_amt +=$sub_tot_q3_expense_amt;?></strong></td>
                   <td align="right"><strong><?php echo number_format($sub_tot_q4_expense_amt,2); $grand_tot_q4_expense_amt +=$sub_tot_q4_expense_amt;?></strong></td>
                 </tr>
				 <?php 
				 $sub_tot_q1_expense_amt = 0;
				 $sub_tot_q2_expense_amt = 0;
				 $sub_tot_q3_expense_amt = 0;
				 $sub_tot_q4_expense_amt = 0;
				 }?>
				 
				 
				 <tr style="background:#f6f9ff;">
                   <td>&nbsp;</td>
                   <td align="center"><strong>TOTAL EXPENSES</strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q1_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q2_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q3_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($grand_tot_q4_expense_amt,2);?></strong></td>
				 </tr>
				  
				  
				  <tr style="background:#f6f9ff;">
                   <td>&nbsp;</td>
                   <td align="center"><strong>NET PROFIT/LOSS</strong></td>
                   <td align="right"><strong><?php echo number_format($q1_net_profit_loss=$q1_gross_profit_amt-$grand_tot_q1_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($q2_net_profit_loss=$q2_gross_profit_amt-$grand_tot_q2_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($q3_net_profit_loss=$q3_gross_profit_amt-$grand_tot_q3_expense_amt,2);?></strong></td>
                   <td align="right"><strong><?php echo number_format($q4_net_profit_loss=$q4_gross_profit_amt-$grand_tot_q4_expense_amt,2);?></strong></td>
				  </tr>
				  
				  <tr style="background:#f6f9ff;">
                   <td>&nbsp; <?php  $net_earnings=($q1_net_profit_loss+$q2_net_profit_loss+$q3_net_profit_loss+$q4_net_profit_loss);?></td>
                   <td align="center"><strong>NET EARNINGS (%)</strong></td>
                   <td align="right"><strong><?php echo number_format($q1_net_earnings=($q1_net_profit_loss/$net_earnings)*100,0);?> %</strong></td>
                   <td align="right"><strong><?php echo number_format($q2_net_earnings=($q2_net_profit_loss/$net_earnings)*100,0);?> %</strong></td>
                   <td align="right"><strong><?php echo number_format($q3_net_earnings=($q3_net_profit_loss/$net_earnings)*100,0);?> %</strong></td>
                   <td align="right"><strong><?php echo number_format($q4_net_earnings=($q4_net_profit_loss/$net_earnings)*100,0);?> %</strong></td>
				  </tr>
                </tbody>
              </table>
			  
			
              <!-- End Table with stripped rows -->

            </div>
          </div>

        </div>

        
      </div>
    </section>

  </main><!-- End #main -->

  
 <!-- ======= Footer ======= -->
 <?php require_once('inc_files/inc_footer.php'); ?>
<!-- ======= End Footer ======= -->

</body>

</html>