<?php
if(basename($_SERVER['PHP_SELF']) == 'fsalerepo.php') 
  $cm=" class='current'";
include'header.php';
include'connection.php';
$custo=$conde=$condi='';
$dato=$datos=$Date;
$s=$r=$a='';
$gara="ALL";
$year='';
$p=0;

// search for an item to be added to the chart
if(isset($_POST['search']))
		{
			$dato=$_POST['dato'];
			$datos=$_POST['datos'];
			$year=$_POST['year'];
			$gara=$_POST['gara'];
			$p=1;
		}
	
	    if($dato==$datos)
			$mpri="ON $dato";
		else
			$mpri="FROM $dato TO $datos";
			
			if($gara=='ALL')
			    $a='selected';
			elseif($gara=='SALES')
			    $s='selected';
			elseif($gara=='TRANSPORT')
			    $r='selected';
                ?>
                
<div class="container-fluid main-content">
        <div class="page-title hidden-print">
          <h3 style='margin-top:-20px; margin-bottom: 5px; color:#ffcc33'>
         Finance Report
          </h3>
  
    </div>
   <div class="row">
  <div class="col-lg-2 hidden-print">
   
  <ul class="list-group">
                  
			  <li class="list-group-item">
              <a href="paidreport.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Payment Report 1
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="paireport.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Payment Report 2
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="expenserepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Expenses Report 1
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="expereport.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Expenses Report 2
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="purcharepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Purchase Report
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="bankreport.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Bank Report
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="assetreport.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Asset Report
                </p>
              </a></li>
                  
			  <li class="list-group-item active">
              <a href="fsalerepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Finacial Statement
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="finrepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Finacial Position
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="holdrepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Withholding Report
                </p>
              </a></li>
                  
			  <li class="list-group-item">
              <a href="cashrepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Cashbox Report
                </p>
              </a></li>
              
              </ul>
  </div>
                    
           
           
    <form action="" method="post" class="form-horizontal "> 
        <div class="col-lg-10">
                  <div class="row">

            <div class="col-lg-2 hidden-print">
                    </div>
                    
             <div class="col-lg-2 hidden-print">
                 <select class="form-control" name="gara">
			<option value='ALL' <?php echo $a ?>>ALL</option>
			<option value='SALES' <?php echo $s ?>>SALES</option>
			<option value='TRANSPORT' <?php echo $r ?>>TRANSPORT</option>
			</select></div>
                    
                    
                    <div class="col-lg-2 hidden-print">
         <div class="col-lg-11 hidden-print"> 
      <input class="form-control form-center" name="year" type="text" value="<?php echo $year ?>" onkeypress='return isNumberKey(event)' placeholder="Fiscal Year">
			</div><div class="col-lg-1 hidden-print"> </div></div>
							
                       <div class="col-lg-6 hidden-print">
                            
					 
            <div class="col-lg-4"> 
           <div class="input-group date" data-provide="datepicker">
      <input class="form-control form-center" name="dato" type="text" value="<?php echo $dato ?>" onkeypress='return isNumberKey(event)' required>
	  <span class="input-group-addon"><i class="lnr lnr-calendar-full"></i></span>
			</div></div>


		  <div class="col-lg-4"> 
           <div class="input-group date" data-provide="datepicker">	
      <input class="form-control form-center" name="datos" type="text" value="<?php echo $datos ?>" onkeypress='return isNumberKey(event)' required>
	  <span class="input-group-addon"><i class="lnr lnr-calendar-full"></i></span>
              </div></div>                      
                       
                       <div class="col-lg-3">
                        <button class="btn  btn-primary btn-block" type="submit" name="search"><i class="lnr lnr-magnifier"></i> Search</button>
                   
					  </div>
                         </div> 
                      
                     
                  
            </form> 
             
               
            </div>
	<div class="divFooter"><center><u><b>SALES REPORT <?php echo"$mpri"; ?></b></u></center></div>
		 <div class="row">
            <div class="col-lg-12">
             <span> &nbsp;&nbsp; </span>
			 <span class="pull-right hidden-print">
			 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="return window.print()" class="hidden-print" title='Click to print' data-toggle='tooltip' data-placement='top'><i class="lnr lnr-printer"></i></a></span>
			 
            <div class="widget-container fluid-height clearfix">
            <div class="widget-content padded clearfix">
                <ul class="list-group">

					<?php
			if($year){
			    
			    // ***************** Fiscal Year **************************
			    $years=$year-1;
		
		$sda1="$year-01-01";
		$eda1="$year-12-31";
		
		$sda2="$years-01-01";
		$eda2="$years-12-31";
			 
			 
			 echo"<li class='list-group-item active' style='width:100%; text-align:left; font-size:14px; margin-bottom:10px;'> 
<table width='100%'><tr style='height:24px;'><td> </td><td width='20%' align='center'><b> NOTES </b></td><td width='25%' align='right'><b> $year RWF &nbsp; </b></td><td width='25%' align='right'><b> $years RWF &nbsp; </b></td>
</tr></table></li><table width='100%'>";
	
	if($gara=='ALL' OR $gara=='SALES'){
	// ********************** About sales and cost of sales *****************
	   	$sal1=$pur1=$sal2=$pur2=0;
	$doi=mysqli_query($conn, "SELECT `Link_file` FROM `datatable` WHERE `Status`='0' ORDER BY `Number` ASC");
	    while($roi=mysqli_fetch_assoc($doi)){
	        $links=$roi['Link_file'];
	   $cons=mysqli_connect("$serv", "$log", "$pass", "$links");
	    $sale1=mysqli_query($cons, "SELECT SUM(`Quantity`*`Uprice`) AS 'Sale', SUM(`Quantity`*`Costi`) AS 'Purchase' FROM `sales` WHERE `Date` BETWEEN '$sda1' AND '$eda1' AND `Delo`='0' AND `Invoice`!='0'");
                $rale1=mysqli_fetch_assoc($sale1);
                    $sal1+=$rale1['Sale'];
                    $salo1=number_format($sal1, 2);
                    $pur1+=$rale1['Purchase'];
                    $puro1=number_format($pur1, 2);
	    
	    
	    $pri1=$sal1-$pur1;             $prio1=number_format($pri1, 2);
	    
	    $sale2=mysqli_query($cons, "SELECT SUM(`Quantity`*`Uprice`) AS 'Sale', SUM(`Quantity`*`Costi`) AS 'Purchase' FROM `sales` WHERE `Date` BETWEEN '$sda2' AND '$eda2' AND `Delo`='0' AND `Invoice`!='0'");
                $rale2=mysqli_fetch_assoc($sale2);
                    $sal2+=$rale2['Sale'];
                    $salo2=number_format($sal2, 2);
                    $pur2+=$rale2['Purchase'];
                    $puro2=number_format($pur2, 2);
	    }
	    
	    $pri2=$sal2-$pur2;             $prio2=number_format($pri2, 2);
	        
	    // ************************* Sales report ************************
	echo"<tr><td> Sales Revenue </td><td width='20%' align='center'> 3 </td>
	<td width='25%' align='right' style='background-color:#f9f9f9;'> $salo1 </td><td width='25%' align='right'> $salo2 </td></tr>
	
	<tr><td> Cost of Sales </td><td width='20%' align='center'> 4 </td>
	<td width='25%' align='right' style='background-color:#f9f9f9;'> ($puro1) </td><td width='25%' align='right'> ($puro2) </td></tr>
	
	<tr><td><b> Gross Profit </b></td><td width='20%' align='center'> </td>
	<td width='25%' align='right' style='border-top:1px solid #000000; border-right:0px; border-left:0px; border-bottom:3px solid #000000; background-color:#f9f9f9;'><b> $prio1 </b></td>
	<td width='25%' align='right' style='border-top:1px solid #000000; border-right:0px; border-left:0px; border-bottom:3px solid #000000;'><b> $prio2 </b></td></tr>
	
	<tr><td> &nbsp; </td><td width='20%' align='center'> &nbsp; </td>
	<td width='25%' align='right' style='background-color:#f9f9f9;'> &nbsp; </td><td width='25%' align='right'> &nbsp; </td></tr>";
			}
	
	if($gara=='ALL' OR $gara=='TRANSPORT'){
	                $con1=$con2=0;
	// ********************** About transport 1 and its cost *************
	    $seco1=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS `Tra` FROM `income` WHERE `Status`='0' AND `External`='1' AND `Date` BETWEEN '$sda1' AND '$eda1'");
	            $reco1=mysqli_fetch_assoc($seco1);
	       $tra1=$reco1['Tra'];          $trao1=number_format($tra1, 2);
	                
	   // ********************** Search for fuel consumption **************
    $fuel1=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS 'Fuel' FROM `consumption` WHERE `Date` BETWEEN '$sda1' AND '$eda1' AND `Status`='0' AND `External`='1'");
			$ruel1=mysqli_fetch_assoc($fuel1);
				$con1+=$ruel1['Fuel'];
				
	// ************************* Search for repair **********************
    $repai1=mysqli_query($conn, "SELECT `Number`, `Amount` FROM `repair` WHERE `Date` BETWEEN '$sda1' AND '$eda1' AND `Status`='0' AND `External`='1'");
			while($ria1=mysqli_fetch_assoc($repai1)){
				$con1+=$ria1['Amount'];
				$reno1=$ria1['Number'];
				
	// *********************** Search for services **********************
	$stouse1=mysqli_query($conn, "SELECT SUM(`Quantity`*`Price`) AS 'Stou' FROM `stouse` WHERE `Status`!='1' AND `Repair`='$reno1' AND `Action`='USED'");
			$rou1=mysqli_fetch_assoc($stouse1);
				$con1+=$rou1['Stou'];
			}
				
						$cono1=number_format($con1, 2);
	   $gros1=$tra1-$con1;            $groso1=number_format($gros1, 2);
	    
	// ********************** About transport 2 and its cost *************
	    $secos2=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS `Tra` FROM `income` WHERE `Status`='0' AND `External`='1' AND `Date` BETWEEN '$sda2' AND '$eda2'");
	            $reco2=mysqli_fetch_assoc($seco2);
	   $tra2=$reco2['Tra'];          $trao2=number_format($tra2, 2);
	                
	   // ********************** Search for fuel consumption **************
    $fuel2=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS 'Fuel' FROM `consumption` WHERE `Date` BETWEEN '$sda2' AND '$eda2' AND `Status`='0' AND `External`='1'");
			$ruel2=mysqli_fetch_assoc($fuel2);
				$con2+=$ruel2['Fuel'];
				
	// ************************* Search for repair **********************
    $repai2=mysqli_query($conn, "SELECT `Number`, `Amount` FROM `repair` WHERE `Date` BETWEEN '$dato' AND '$datos' AND `Status`='0' AND `External`='1'");
			while($ria2=mysqli_fetch_assoc($repai2)){
				$con2+=$ria2['Amount'];
				$reno2=$ria2['Number'];
				
	// *********************** Search for services **********************
	$stouse2=mysqli_query($conn, "SELECT SUM(`Quantity`*`Price`) AS 'Stou' FROM `stouse` WHERE `Status`!='1' AND `Repair`='$reno2' AND `Action`='USED'");
			$rou2=mysqli_fetch_assoc($stouse2);
				$con2+=$rou2['Stou'];
			}
				
						$cono2=number_format($con2, 2);
	    $gros2=$tra2-$con2;            $groso2=number_format($gros2, 2);
	    
	echo"<tr><td style='color:blue;'> Transport Revenue </td><td style='color:blue;' width='20%' align='center'> 3 </td>
	<td width='25%' align='right' style='background-color:#f9f9f9; color:blue;'> $trao1 </td><td width='25%' align='right'> $trao2 </td></tr>
	
	<tr><td style='color:blue;'> Cost of Transport </td><td width='20%' align='center' style='color:blue;'> 4 </td>
	<td width='25%' align='right' style='background-color:#f9f9f9; color:blue;'> ($cono1) </td><td width='25%' align='right' style='color:blue;'> ($cono2) </td></tr>
	
	<tr><td style='color:blue;'><b> Gross Profit </b></td><td width='20%' align='center' style='color:blue;'> </td>
	<td width='25%' align='right' style='border-top:1px solid #000000; border-right:0px; border-left:0px; border-bottom:3px solid #000000; background-color:#f9f9f9; color:blue;'><b> $groso1 </b></td>
	<td width='25%' align='right' style='border-top:1px solid #000000; border-right:0px; border-left:0px; border-bottom:3px solid #000000; color:blue;'><b> $groso2 </b></td></tr>
	
	<tr><td> &nbsp; </td><td width='20%' align='center'> &nbsp; </td>
	<td width='25%' align='right' style='background-color:#f9f9f9;'> &nbsp; </td><td width='25%' align='right'> &nbsp; </td></tr>";
	}
	
	
	if($gara=='ALL' OR $gara=='SALES'){
	// ************************** Expenses and cost ***********************
	            $n=5;           $texp1=$texp2=0;
	$sety=mysqli_query($conn, "SELECT `Type` FROM `expetype` WHERE `Status` = '0' GROUP BY `Type` ORDER BY `Type` ASC");
	        while($rety=mysqli_fetch_assoc($sety)){
	            $type=$rety['Type'];
	$sexpe1=mysqli_query($conn, "SELECT SUM(`Amount`) AS `Expe` FROM `expenses` INNER JOIN `expetype` ON `expenses`.`Expense` = `expetype`.`Expense` WHERE `expenses`.`Status` = '0' AND `expetype`.`Type` = '$type' AND `expenses`.`Date` BETWEEN '$sda1' AND '$eda1' ORDER BY `expenses`.`Number` ASC");
	        $rexpe1=mysqli_fetch_assoc($sexpe1);
	   $expe1=$rexpe1['Expe'];            $expeo1=number_format($expe1, 2);
	   
	
	$sexpe2=mysqli_query($conn, "SELECT SUM(`Amount`) AS `Expe` FROM `expenses` INNER JOIN `expetype` ON `expenses`.`Expense` = `expetype`.`Expense` WHERE `expenses`.`Status` = '0' AND `expetype`.`Type` = '$type' AND `expenses`.`Date` BETWEEN '$sda2' AND '$eda2' ORDER BY `expenses`.`Number` ASC");
	        $rexpe2=mysqli_fetch_assoc($sexpe2);
	   $expe2=$rexpe2['Expe'];            $expeo2=number_format($expe2, 2);
	
	echo"<tr><td> $type </td><td width='20%' align='center'> $n </td>
	<td width='25%' align='right' style='background-color:#f9f9f9;'> ($expeo1) </td><td width='25%' align='right'> ($expeo2) </td></tr>"; 
	$n++;                 $texp1+=$expe1;                  $texp2+=$expe2;
	        }
	        
	        
	                $texpo1=number_format($texp1, 2);
	                $texpo2=number_format($texp2, 2);
	                
	    echo"<tr><td> </td><td width='20%' align='center'> </td>
	<td width='25%' align='right' style='background-color:#f9f9f9;'>
	<b> ($texpo1) </b></td><td width='25%' align='right'><b> ($texpo2) 
	</b></td></tr>"; 
	}
	                
	                $profit1=$tra1+$pri1-$texp1;
	                $profito1=number_format($profit1, 2);
	                
	                    $corp1=$profit1/100*30;
	                    $corpo1=number_format($corp1, 2);
	                    
	                    $paft1=$profit1-$corp1;
	                    $pafto1=number_format($paft1, 2);
	               
	                $profit2=$tra2+$pri2-$texp2;
	                $profito2=number_format($profit2, 2);
	                
	                    $corp2=$profit2/100*30;
	                    $corpo2=number_format($corp2, 2);
	                    
	                    $paft2=$profit2-$corp2;
	                    $pafto2=number_format($paft2, 2);
	
	echo"<tr><td><b> Profit/Loss Before Tax </b></td><td width='20%' align='center'> </td><td width='25%' align='right' style='border:1px solid #000000; border-right:0px; border-left:0px; border-top:0px; background-color:#f9f9f9;'><b> $profito1 </b></td><td width='25%' align='right' style='border:1px solid #000000; border-right:0px; border-left:0px; border-top:0px;'><b> $profito2 </b></td></tr>"; 
	
		echo"<tr><td> Corporate Income Tax </td><td width='20%' align='center'> 8 </td><td width='25%' align='right' style='background-color:#f9f9f9;'> ($corpo1) </td><td width='25%' align='right'> ($corpo2) </td></tr>";
		
			echo"<tr><td><b> Profit/Loss After Tax </b></td><td width='20%' align='center'> </td><td width='25%' align='right' style='border:2px solid #000000; border-right:0px; border-left:0px; border-top:0px; background-color:#f9f9f9;'><b> $pafto1 </b></td><td width='25%' align='right' style='border:2px solid #000000; border-right:0px; border-left:0px; border-top:0px;'><b> $pafto2 </b></td></tr>";
	
	        echo"</table>";   
			    
			}	
			else{
			    
			    // ************** Period Selection *********************
	echo"<li class='list-group-item active' style='width:100%; text-align:left; font-size:14px; margin-bottom:10px;'> 
<table width='100%'><tr style='height:24px;'><td> </td><td width='20%' align='center'><b> NOTES </b></td><td width='40%' align='right'><b> FROM $dato TO $datos </b></td>
</tr></table></li><table width='100%'>";
	
	        if($gara=='ALL' OR $gara=='SALES'){
	// ********************** About sales and cost of sales *****************
	   	$sal=$pur=$gros=$con=0;
	$doi=mysqli_query($conn, "SELECT `Link_file` FROM `datatable` WHERE `Status`='0' ORDER BY `Number` ASC");
	    while($roi=mysqli_fetch_assoc($doi)){
	        $links=$roi['Link_file'];
	   $cons=mysqli_connect("$serv", "$log", "$pass", "$links");
	    $sale=mysqli_query($cons, "SELECT SUM(`Quantity`*`Uprice`) AS 'Sale', SUM(`Quantity`*`Costi`) AS 'Purchase' FROM `sales` WHERE `Date` BETWEEN '$dato' AND '$datos' AND `Delo`='0' AND `Invoice`!='0'");
                $rale=mysqli_fetch_assoc($sale);
                    $sal+=$rale['Sale'];
                    $salo=number_format($sal, 2);
                    $pur+=$rale['Purchase'];
                    $puro=number_format($pur, 2);
	    }
	    
	    $pri=$sal-$pur;             $prio=number_format($pri, 2);
    
	    // ************************* Sales report ************************
	echo"<tr><td> Sales Revenue </td><td width='20%' align='center'> 3 </td>
	<td width='40%' align='right'> $salo </td></tr>
	
	<tr><td> Cost of Sales </td><td width='20%' align='center'> 4 </td>
	<td width='40%' align='right'> ($puro) </td></tr>
	
	<tr><td><b> Gross Profit (S)</b></td><td width='20%' align='center'> </td>
	<td width='40%' align='right' style='border-top:1px solid #000000; border-right:0px; border-left:0px; border-bottom:3px solid #000000;'><b> $prio </b></td></tr>
	
	<tr><td> &nbsp; </td><td width='20%' align='center'> &nbsp; </td>
	<td width='40%' align='right'> &nbsp; </td></tr>";
	        }
	        
	        
	        if($gara=='ALL' OR $gara=='TRANSPORT'){
	    
	    // ********************** About transport and its cost *************
	    $seco=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS `Tra` FROM `income` WHERE `Status`='0' AND `External`='1' AND `Date` BETWEEN '$dato' AND '$datos'");
	            $reco=mysqli_fetch_assoc($seco);
	                $tra=$reco['Tra'];          $trao=number_format($tra, 2);
	                
	   // ********************** Search for fuel consumption **************
    $fuel=mysqli_query($conn, "SELECT SUM(`Amount`*`Rate`) AS 'Fuel' FROM `consumption` WHERE `Date` BETWEEN '$dato' AND '$datos' AND `Status`='0' AND `External`='1'");
			$ruel=mysqli_fetch_assoc($fuel);
				$con+=$ruel['Fuel'];
				
	// ************************* Search for repair **********************
    $repai=mysqli_query($conn, "SELECT `Number`, `Amount` FROM `repair` WHERE `Date` BETWEEN '$dato' AND '$datos' AND `Status`='0' AND `External`='1'");
			while($ria=mysqli_fetch_assoc($repai)){
				$con+=$ria['Amount'];
				$reno=$ria['Number'];
				
	// *********************** Search for services **********************
	$stouse=mysqli_query($conn, "SELECT SUM(`Quantity`*`Price`) AS 'Stou' FROM `stouse` WHERE `Status`!='1' AND `Repair`='$reno' AND `Action`='USED'");
			$rou=mysqli_fetch_assoc($stouse);
				$con+=$rou['Stou'];
			}
				
						$cono=number_format($con, 2);
	                $gros=$tra-$con;            $groso=number_format($gros, 2);
	        
	// ************************ Transport Amount **************************
	echo"<tr><td style='color:blue;'> Transport Revenue </td>
	<td width='20%' align='center' style='color:blue;'> 3 </td>
	<td width='40%' align='right' style='color:blue;'> $trao </td></tr>
	
	<tr><td style='color:blue;'> Cost of Transport </td>
	<td width='20%' align='center' style='color:blue;'> 4 </td>
	<td width='40%' align='right' style='color:blue;'> ($cono) </td></tr>
	
	<tr><td style='color:blue;'><b> Gross Profit (T)</b></td>
	<td width='20%' align='center' style='color:blue;'> </td>
	<td width='40%' align='right' style='border-top:1px solid #000000; border-right:0px; border-left:0px; border-bottom:3px solid #000000; color:blue;'><b> $groso </b></td></tr>
	
	<tr><td> &nbsp; </td><td width='20%' align='center'> &nbsp; </td>
	<td width='40%' align='right'> &nbsp; </td></tr>";
			}
	
	
	            if($gara=='ALL' OR $gara=='SALES'){
	// ************************** Expenses and cost ***********************
	            $n=5;           $texp=0;
	$sety=mysqli_query($conn, "SELECT `Type` FROM `expetype` WHERE `Status` = '0' GROUP BY `Type` ORDER BY `Type` ASC");
	        while($rety=mysqli_fetch_assoc($sety)){
	            $type=$rety['Type'];
	$sexpe=mysqli_query($conn, "SELECT SUM(`Amount`) AS `Expe` FROM `expenses` INNER JOIN `expetype` ON `expenses`.`Expense` = `expetype`.`Expense` WHERE `expenses`.`Status` = '0' AND `expetype`.`Type` = '$type' AND `expenses`.`Date` BETWEEN '$dato' AND '$datos' ORDER BY `expenses`.`Number` ASC");
	        $rexpe=mysqli_fetch_assoc($sexpe);
	   $expe=$rexpe['Expe'];            $expeo=number_format($expe, 2);
	
	echo"<tr><td> $type </td><td width='20%' align='center'> $n </td>
	<td width='40%' align='right'> ($expeo) </td></tr>"; 
	        $n++;               $texp+=$expe;
	        }
	                $texpo=number_format($texp, 2);
	                
	echo"<tr><td> </td><td width='20%' align='center'> </td>
	<td width='40%' align='right'><b> ($texpo) </b></td></tr>";
	            }
	            
	                $profit=$tra+$pri-$texp;
	                $profito=number_format($profit, 2);
	                
	                    $corp=$profit/100*30;
	                    $corpo=number_format($corp, 2);
	                    
	                    $paft=$profit-$corp;
	                    $pafto=number_format($paft, 2); 
	
	echo"<tr><td><b> Profit/Loss Before Tax </b></td><td width='20%' align='center'> </td><td width='40%' align='right' style='border:1px solid #000000; border-right:0px; border-left:0px; border-top:0px;'><b> $profito </b></td></tr>"; 
	
		echo"<tr><td> Corporate Income Tax </td><td width='20%' align='center'> 8 </td><td width='40%' align='right'> ($corpo) </td></tr>";
		
			echo"<tr><td><b> Profit/Loss After Tax </b></td><td width='20%' align='center'> </td><td width='40%' align='right' style='border:2px solid #000000; border-right:0px; border-left:0px; border-top:0px;'><b> $pafto </b></td></tr>";
			
	
	        echo"</table>";
			}
		?>
                  
                  
                                      
                
              </ul></div>
            </div></div></div>                  
                <span class="pull-right hidden-print">
			 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#" onclick="return window.print()" class="hidden-print" title='Click to print' data-toggle='tooltip' data-placement='top'><i class="lnr lnr-printer"></i></a></span>
      
   </div></div></div>  
   <?php
   include'footer.php';
   ?>