<?php

session_start();
include('script/condb.php');

if(isset($_POST['search'])){
$PID=$_POST['pid'];
}

?>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Transparent Quantities</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
<div class="dashboardpagewrap">
  <div class="right-frame">
    
  <div class="accordion-wrapper2">

<div class="tablewrapper">
<table>
  <thead>
  </thead>
  <tbody>
    <tr>
	<div class="tableheader3">
		<div class="tableid">Foundation</div>
		<div class="tablebtn1">Calculate</div>
		</div>
		
	<div class="tableheader4"><div class="tableid2">Materials</div>
		<div class="tablebtn2">Done</div>
	   <div class="tablebtn2">Edit</div>	
		<div class="tablebtn2">M & P</div>		
	</div>
      <td width="5%" data-label="Account"><strong></s>Item</strong></td>
      <td width="41%" data-label="Due Date"><strong>Description</strong></td>
      <td width="11%" data-label="Amount"><strong>Quantity</strong></td>
      <td width="8%" data-label="Period"><strong>Extra</strong></td>
      <td width="15%" data-label="Period"><strong>Prize</strong></td>
      <td width="20%" data-label="Period"><strong>Total Amount</strong></td>
    </tr>
    <tr>
		<?php
				
				$query2 = "SELECT * FROM foundation_materials where PID ='$PID' ";
				$result2=mysqli_query($con, $query2);

					while($row2=mysqli_fetch_assoc($result2))
					{
					?>
      <td data-label="Account"></td>
      <td data-label="Due Date"><?php echo $row2['MaterialDescription']; ?></td>
      <td data-label="Amount"><?php echo round($row2['COEQuantity'],2); ?></td>
      <td data-label="Period"><?php echo $row2['Extra']; ?></td>
      <td data-label="Period"><?php echo $row2['Price']; ?></td>
      <td data-label="Period"><?php echo round($row2['CETotalAmount'],2); ?></td>
    </tr>
	<?php
}
?> <?php
	$sqlsu="SELECT SUM(CETotalAmount) FROM foundation_materials WHERE PID='$PID'";
$resultbat =mysqli_query($con, $sqlsu);
//if($resultbat){
while($row21=mysqli_fetch_array($resultbat)){
 $sum = $row21['SUM(CETotalAmount)'];
	$subt =0.05 *$sum;
	$tot1=$sum+$subt;
	/*echo $sum.'<br>';
	echo $subt .'<br>';*/
}//}
 ?>
    <tr>
      <td scope="row" data-label="Account"></td>
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
		<td data-label="Period"><font color="#E7060A"></font></td>
      <td data-label="Period"><font color="#E7060A">Contigency   5%</font></td>
      <td data-label="Period"><font color="#E7060A"><?php echo $subt; ?></font></td>
    </tr>
    <tr>
      <td scope="row" data-label="Account">&nbsp;</td>
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount"></td>
      <td data-label="Period"></td>
      <td data-label="Period">TOTAL:</td>
      <td data-label="Period"><?php echo $tot1; ?></td>
    </tr>
    <!--<tr>
      <td scope="row" data-label="Acount">
		</td>
		
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period"></td>
      <td data-label="Period">TOTAL:</td>
      <td data-label="Period"></td>
    </tr>-->
    <tr>
    </tr>
  </tbody>
</table>
	
<table>
  <thead>
  </thead>
  <tbody>
    <tr>

		
	<div class="tableheader4"><div class="tableid2">Labours</div>
		<div class="tablebtn2">Done</div>
	   <div class="tablebtn2">Edit</div>	
		<div class="tablebtn2">M & P</div>		
	</div>
      <td width="5%" data-label="Account"><strong></s>Item</strong></td>
      <td width="41%" data-label="Due Date"><strong>Description</strong></td>
      <td width="11%" data-label="Amount"><strong>Quantity</strong></td>
      <td width="8%" data-label="Period"><strong>Extra</strong></td>
      <td width="15%" data-label="Period"><strong>Prize</strong></td>
      <td width="20%" data-label="Period"><strong>Total Amount</strong></td>
    </tr>
    <tr><?php
				
				$query3 = "SELECT * FROM foundation_labourer where PID ='$PID' ";
				$result3=mysqli_query($con, $query3);

					while($row3=mysqli_fetch_assoc($result3))
					{
					?>
      <td data-label="Account"></td>
      <td data-label="Due Date"><?php echo $row3['LabourerDescription']; ?></td>
      <td data-label="Amount"><?php echo $row3['COEQuantity']; ?></td>
      <td data-label="Period"><?php echo $row3['Extra']; ?></td>
      <td data-label="Period"><?php echo $row3['Price']; ?></td>
      <td data-label="Period"><?php echo round($row3['COETotal'],2); ?></td>
    </tr>
	<?php
}
?> <?php $sqlsu2="SELECT SUM(COETotal) FROM foundation_labourer WHERE PID='$PID'";
$resultbat2 =mysqli_query($con, $sqlsu2);
//if($resultbat){
while($row22=mysqli_fetch_array($resultbat2)){
 $sum2 = round($row22['SUM(COETotal)'],2);
	$subt2 =round((0.05 *$sum2),2);
	$tot=$sum2 +$subt2;
	
	/*echo $sum2.'<br>';
	echo $tot;*/
}//}
     ?>
    <tr>
      <td scope="row" data-label="Account"></td>
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
    </tr>
    <tr>
      <td scope="row" data-label="Account">&nbsp;</td>
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
      <td data-label="Period"><font color="#E7060A">Contigency   5%</font></td>
      <td data-label="Period"><font color="#E7060A"><?php echo $subt2; ?></font></td>
    </tr>
    <tr>
      <td scope="row" data-label="Acount">
		</td>
		
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period"></td>
      <td data-label="Period">TOTAL:</td>
      <td data-label="Period"><?php echo $tot; ?></td>
    </tr>
    <tr>

    </tr>
  </tbody>
</table>

<table>
  <thead>
  </thead>
  <tbody>
    <tr>

		
	<div class="tableheader4"><div class="tableid2">Equipments</div>
		<div class="tablebtn2">Done</div>
	   <div class="tablebtn2">Edit</div>	
		<div class="tablebtn2">M & P</div>		
	</div>
      <td width="5%" data-label="Account"><strong></s>Item</strong></td>
      <td width="41%" data-label="Due Date"><strong>Description</strong></td>
      <td width="11%" data-label="Amount"><strong>Quantity</strong></td>
      <td width="8%" data-label="Period"><strong>Extra</strong></td>
      <td width="15%" data-label="Period"><strong>Prize</strong></td>
      <td width="20%" data-label="Period"><strong>Total Amount</strong></td>
    </tr>
    <tr>
		<?php
				
				$query4 = "SELECT * FROM foundation_equipment where PID ='$PID' ";
				$result4=mysqli_query($con, $query4);

					while($row4=mysqli_fetch_assoc($result4))
					{
					?>
      <td data-label="Account"></td>
      <td data-label="Due Date"><?php echo $row4['EquipmentDescription']; ?></td>
      <td data-label="Amount"><?php echo round($row4['Quantity'],2); ?></td>
      <td data-label="Period"><?php echo $row4['Extra']; ?></td>
      <td data-label="Period"><?php echo $row4['Price']; ?></td>
      <td data-label="Period"><?php echo round($row4['Total'],2); ?></td>
    </tr>
<?php
}
?><?php 
$sqlsu3="SELECT SUM(Total) FROM foundation_equipment WHERE PID='$PID'";
$resultbat3 =mysqli_query($con, $sqlsu3);
//if($resultbat){
while($row23=mysqli_fetch_array($resultbat3)){
 $sum3 = round($row23['SUM(Total)'],2);
	$bat3 =round((0.05 *$sum3),2);
	$tot2=$sum3 +$bat3;
	
	/*echo $sum2.'<br>';
	echo $tot;*/
}//}
     ?>
    <tr>
      <td scope="row" data-label="Account"></td>
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
    </tr>
    <tr>
      <td scope="row" data-label="Account">&nbsp;</td>
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period">&nbsp;</td>
      <td data-label="Period"><font color="#E7060A">Contigency   5%</font></td>
      <td data-label="Period"><font color="#E7060A"><?php echo $bat3; ?></font></td>
    </tr>
    <tr>
      <td scope="row" data-label="Acount">
		</td>
		
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period"></td>
      <td data-label="Period">TOTAL :</td>
      <td data-label="Period"><?php echo $tot2; ?></td>
    </tr>
    <tr>
	<td scope="row" data-label="Acount">
		</td>
		
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period"></td>
      <td data-label="Period"></td>
      <td data-label="Period"></td>
    </tr>
	<tr>
	<td scope="row" data-label="Acount">
		</td>
		
      <td data-label="Due Date">&nbsp;</td>
      <td data-label="Amount">&nbsp;</td>
      <td data-label="Period"></td>
		<td data-label="Period" bgcolor="#1B04CE"><font color="#ffffff">FOUDATION TOTAL :</font></td>
      <td data-label="Period" bgcolor="#1B04CE"><font color="#ffffff"><?php $finsum=$tot2 + $tot2 +$tot; echo 'NGN'.''.$finsum; ?></font></td>
    </tr>
  </tbody>
</table>
</div>

<!--<button id="export">Export to PDF</button>
<input type="button" class="submit_btn" onClick="window.print()" value="Print &#8250&#8250;">
<input type="button" class="submit_btn" onClick="window.print()" value="Export &#8250&#8250;">-->



</div>
<div class="chat-bubble">   <span tooltip="Live Chat"><img src="images/livechat-ico.png" width="128" height="128" alt=""/></span></div>
</div>
</div>
</body>
</html>