<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">

    <title></title>
    <style type="text/css">
      .no-border{ border:none; }
      .no-border td{border: none;}
	  .table td, .table th{ padding:0.20rem;}
    </style>
  </head>
  <body>
  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>  
<script>


					$(document).ready(function()
					{ 
						var Total = 0;
						if(!isNaN(parseFloat($("#ecVal1Fetch").val())))
							Total +=parseFloat($("#ecVal1Fetch").val());
 
						if(!isNaN(parseFloat($("#ecVal2Fetch").val())))
							Total +=parseFloat($("#ecVal2Fetch").val());
 

						if(!isNaN(parseFloat($("#ecVal3Fetch").val())))
							Total +=parseFloat($("#ecVal3Fetch").val());
 
 
						if(!isNaN(parseFloat($("#ecVal4Fetch").val())))
							Total +=parseFloat($("#ecVal4Fetch").val());
 
 
						if(!isNaN(parseFloat($("#ecVal5Fetch").val())))
							Total +=parseFloat($("#ecVal5Fetch").val());
 
 
						if(!isNaN(parseFloat($("#ecVal6Fetch").val())))
							Total +=parseFloat($("#ecVal6Fetch").val());
						
						
						 
					
					    
					   $("#ecVal1Rec").html($("#ecVal1Fetch").val());
					   $("#ecVal2Rec").html($("#ecVal2Fetch").val());
					   $("#ecVal3Rec").html($("#ecVal3Fetch").val());
					   $("#ecVal4Rec").html($("#ecVal4Fetch").val());
					   $("#ecVal5Rec").html($("#ecVal5Fetch").val());
					   $("#ecVal6Rec").html($("#ecVal6Fetch").val()); 
					   $("#GrabTotal").html((Total.toFixed(2)));
					   $("#prePaidbef").val((Total.toFixed(2)));  
					   
					});

				  function prepaid()
				  {
						var prePaidbef = parseFloat($("#prePaidbef").val());
						var prePaid = parseFloat($("#prePaid").val()); 
						$("#prePaidnext").val(prePaidbef-prePaid); 
				  }
</script>
	  
<div class="container">

    <h5 class="text-center">PRICE   ESCALATION BILL <span style="float:right;"><?php echo date("d-M-Y");?><span></h5>
	<hr/>
	<h6 class="text-center">WORK PROFILE</h6> 
  <div class="table_data">

  <div class="row">
   <label class="col-sm-3"><b>Name of Agency:</b></label>
   <label class="col-sm-9"><?php echo $pw__newage->name;?></label>
  </div>
  <div class="row">
   <label class="col-sm-3"><b>Name of Work:</b></label>
   <label class="col-sm-9"><?php echo $FinalResult->workN;?></label>
  </div>


  <div class="row">
   <label class="col-sm-3"><b>Agreement No:</b></label>
   <label class="col-sm-9"><?php echo $FinalResult->AggNo;?></label>   
  </div>

<div class="row">
   <label class="col-sm-3"><b>Work Order No:</b></label>
   <label class="col-sm-3"> <?php echo $FinalResult->workorderNo;?> </label>
   <label class="col-sm-3 text-right"><b>Work Order Date:</b></label>
   <label class="col-sm-3"><?php echo $FinalResult->workOrderdate;?></label>
  </div>
  <div class="row">
   <label class="col-sm-3"><b>Time Limit:</b></label>
   <label class="col-sm-3"><?php echo $FinalResult->timeLimit;?></label>
   <label class="col-sm-3 text-right"><b>Extension:</b></label>
   <label class="col-sm-3"><?php echo $FinalResult->extention;?></label>
  </div>
<div class="row">
   <label class="col-sm-3"><b>Date of Receipt of Tender:</b></label>
   <label class="col-sm-9"><?php echo $FinalResult->recDate;?></label>
  </div>
  <div class="row">
   <label class="col-sm-3"><b>Basic Indices Otr before:</b></label>
   <label class="col-sm-9"><?php echo  date("M-Y", strtotime($FinalResult->basicIndices));?></label>
  </div>
  <div class="row">
   <label class="col-sm-3"><b>The receipt of Tender:</b></label>
   <label class="col-sm-9"></label>
  </div>
 <h5 style="font-size:17px;">TENDER ACCEPTED @ <?php echo $FinalResult->TenderAccAt;?>% <?php if($FinalResult->TenderAccAtStats==1) echo "Above"; else if($FinalResult->TenderAccAtStats==2) echo "Below"; else echo "Atpar"; ?></h5>
</div>
<h5>Date of Levy of Compensation/Fine:</h5>

<?php    
$stmt=$conn->prepare("select  * from    pw__comdtdata    where  agId=:id   and  randumNo=:randumNo   ");  
$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	
$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  	  					  
$stmt->execute(); 
$AllUsers = $stmt->fetch(PDO::FETCH_OBJ);    
$rnd = $AllUsers->randumNo;

?>

<table class="table table-bordered">
 <thead>
  <tr>
   <th>Commodity</th> 
   <th>Grade</th>
   <th><?php echo $AllUsers->dat1;?></th>
   <th><?php echo $AllUsers->dat2;?></th>
   <th><?php echo $AllUsers->dat3;?></th>
   <th>Average</th>
   <th>Center</th>
   <th>Percentage %</th>
   <th>Source</th>
   <th>CSR</th>
  </tr> 
 </thead>
 <tbody>
 
 <?php    
					$stmt=$conn->prepare("select  * from    pw__comdtdata    where  agId=:id     and  randumNo=:randumNo "); 
					$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  	  					  					
					$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);    
					$stmt->execute(); 
					$AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
					$sr = 1; 

					foreach($AllUsers as $users)
					{  
						
						if($users->cmdt==1)	 {
							$cmdt = "LABOUR";
							$avgLbr = $users->avgdta;
							$perLbr = $users->perc;
						}
						else if($users->cmdt==2)	 
						{
							$cmdt = "MATERIAL";
							$avgmat = $users->avgdta;
							$permat = $users->perc;
						}
						else if($users->cmdt==3)	 {
							$cmdt = "POL";
							$avpol = $users->avgdta;
							$perpol = $users->perc;
						}
						else if($users->cmdt==4)	
							$cmdt = "BITUMEN VG-30";
						else if($users->cmdt==5)	
							$cmdt = "BITUMEN VG-10";
						else if($users->cmdt==6)	
							$cmdt = "CEMENT LINE"; 
						else if($users->cmdt==7)	
							$cmdt = "CEMENT";
						else if($users->cmdt==8)	
							$cmdt = "STEEL";
						else if($users->cmdt==9)	
							$cmdt = "STEEL LONG";
						
						
						$stmt=$conn->prepare("select  * from    pw__cities where id=:id ");
						$stmt->bindValue(':id',  $users->center, PDO::PARAM_STR);  						
						$stmt->execute(); 
						$city = $stmt->fetch(PDO::FETCH_OBJ); 
						
						if($users->grade==1)
							$grade = "Vg 30(60/70)";
						else if($users->grade==2)
							$grade = "Vg 10(80/100)";
						else if($users->grade==3) 
							$grade = "TMT";
						else
							$grade = "";	 
					?>   
   <tr> 
					 
					<th scope="row"><?php  echo $cmdt;?></th>
					<td><?php  echo $grade;?></td>
					<td><?php  echo number_format($users->index1,2);?></td>
					<td><?php  echo number_format($users->index2,2);?></td>
					<td><?php  echo number_format($users->index3,2);?></td>
					<td><?php  echo $users->avgdta;?></td>
					<td><?php  echo $city->name;?></td>
					<td><?php  if($users->perc!='') { echo $users->perc;  echo " %"; }  else echo "Actual";?></td>
					<td><?php  echo $users->source;?></td> 
					<td><?php  echo $users->csr;?></td> 
					 
					</tr>
					<?php  	$sr++;} ?> 

 </tbody>
</table>








<div class="row">
<div class="col-sm-9">
  <table class="table table-bordered">
    <thead>
   
   <tr>
    <th colspan="4" class="text-center"><h4>Escalation Bill-Summary</h4></th>     
   </tr>   
	
	<tr>
    <th>Commodity</th>  
    <th>Escalation Amount</th>
   </tr>
   </thead>
   <tbody>
   
    <?php 
			$stmt=$conn->prepare("select  * from    pw__comdtdata    where  agId=:id    and  randumNo=:randumNo");  
			$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  	  					  
			$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);    
			$stmt->execute(); 
			$AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
			$sr = 1; 

			foreach($AllUsers as $users)
			{  
						
						if($users->cmdt==1)	 {
							$cmdt = "LABOUR";
							$avgLbr = $users->avgdta;
							$perLbr = $users->perc;
							$ccc = $ecAmt1;
						}
						else if($users->cmdt==2)	 
						{
							$cmdt = "MATERIAL";
							$avgmat = $users->avgdta;
							$permat = $users->perc;
							$ccc = $ecAmt2;
						}
						else if($users->cmdt==3)	 {
							$cmdt = "POL";
							$avpol = $users->avgdta;
							$perpol = $users->perc;
							$ccc = $ecAmt3;
						}
						else if($users->cmdt==4)	 {
							$cmdt = "BITUMEN VG-30";
							$ccc = $ecAmt4;
						}
						else if($users->cmdt==5)	 {
							$cmdt = "BITUMEN VG-10";
							$ccc = $ecAmt4;
						}
						else if($users->cmdt==6) {	 
							$cmdt = "CEMENT LINE";
							$ccc = $ecAmt5;
						}			
						else if($users->cmdt==7) {	
							$cmdt = "CEMENT";
							$ccc = $ecAmt5;
						}
						else if($users->cmdt==8) {	
							$cmdt = "STEEL";
							$ccc = $ecAmt6;
						}
						else if($users->cmdt==9) {
							$cmdt = "STEEL LONG";
							$ccc = $ecAmt6;
						} 
						
					$mtt +=$ccc; 	 
							
   ?>
   <tr>
		<?php 
			if($users->cmdt==1) 
			{
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal1Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==2) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal2Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==3) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal3Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==4) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal4Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==5) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal4Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==6) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal5Rec"/> </span> </td>
		<?php 
			}
		?>
		
		
		<?php 
			if($users->cmdt==7) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal5Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==8) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal6Rec"/> </span> </td>
		<?php 
			}
		?>
		
		<?php 
			if($users->cmdt==9) {
		?>
		<td><?php echo $cmdt ;?></td> 
		<td><span  id="ecVal6Rec"/> </span> </td>
		<?php 
			}
		?>
		
	</tr>
   
	<?php } ?>
                  
   <tr>
      
     <td><b>Total</b></td>
      
     <th><span id="GrabTotal"></span><input type="hidden" id="prePaidbef" value="0"> </th>
   </tr>
   <tr>
      
     <td><b>Previously Paid Amount</b></td>
     <td><b><input type="text" id="prePaid" onchange="prepaid();"></b></td>
   </tr>
   <tr>
      
     <td><b>Now to Pay</b></td>
     <td><b><input id="prePaidnext"></b></td>
   </tr>
   
    <tr>
      
     <td>PRINT SECTION</td>
     <td><button onclick="window.print()">Print Report</button></td>
   </tr> 
</tbody>  
  </table>
</div> 
</div>  
<br/>  



<div class="container">
<div class="row">

<div class="col-sm-6">
<h5>UNDERTAKING</h5>
<p>During audit Scrutiny if excess payment noticed.
We will refund the same amount immediately in cash or from any dues payable us by Govt.</p>
</div>
<div class="col-sm-6">
  <br/>
<p>Work have not been delayed by the contractor
& compensation for delay has not been levied, the quality of work is satisfactory in accordance with contract</p>
</div>
  </div>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>



<!--page 2 starts here -->
 <h5>R. A. Bill Details</h5>
 <table class="table table-bordered">
 <thead>
  <tr>
   <th>Date of Recording</th> 
   <th>R.A. Bill.No & V.No</th>
   <th>Date of Payment</th>
   <th>Amount work Done i.e. G.B.</th>
   <th>Cost of Bitumen/ Cement/Steel</th>
   <th>Royalty</th>
   <th>Clause38</th>
   <th>Net Payment</th>
   <th>85% of Work Done Amount</th>   
  </tr> 
 </thead>
<tbody>
    
<?php      			 
					$stmt=$conn->prepare("select  * from    pw__rabills where custId=:custId and randNo=:randNo order by id ");  
					$stmt->bindValue(':custId',  $_SESSION['custId'], PDO::PARAM_STR);  			
					$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
					$stmt->execute(); 
					$AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
					$sr = 1;   
				 
					foreach($AllUsers as $users)
					{    	

						$originalDate = $users->recordingD;
						$newDate = date("m/y", strtotime($originalDate));  
						//$eightFive = $users->eightPer;
						$eightFive[] = $users->eightPer;
						
						$amtworkT +=$users->amtwork;
						$costofBitT +=$users->costofBit;
						$royaltyT +=$users->royalty;
						$clause38T +=$users->clause38;
						$netpaymentT +=$users->netpayment;
						$eightPerT +=$users->eightPer;

					?> 
					<tr>  
		 
					<td><?php echo $newDate;?></td>
					<td><?php echo $users->RaBillNO." ".$users->vourchar;?></td>
					<td><?php echo $users->dpayment;?></td>
					<td><?php echo $users->amtwork;?></td>
					<td><?php echo $users->costofBit;?></td> 
					<td><?php echo $users->royalty;?></td> 
					<td><?php echo $users->clause38;?></td> 
					<td><?php echo $users->netpayment;?></td> 
					<td><?php echo $users->eightPer;?></td>   
					</tr>
					<?php  	$sr++;} ?> 
					
					
					<tr>  
		 
					
					<td> </td>
					<td> </td>
					<th>Total</th>
					<td><?php echo $amtworkT;?></td>
					<td><?php echo $costofBitT;?></td> 
					<td><?php echo $royaltyT;?></td> 
					<td><?php echo $clause38T;?></td> 
					<td><?php echo $netpaymentT;?></td> 
					<td><?php echo $eightPerT;?></td>   
					</tr>
					 
					

 </tbody>
</table>

<div class="row">
  <div class="col-sm-10">
    <h5>Consumption Detail</h5>
 <table class="table table-bordered">
 <thead>
  <tr>
   <th>R.A. Bill No.</th> 
   <th>Commodity</th>
   <th>Grade</th>
   <th>Quantity Per Unit</th>
   <th>Amount</th>    
  </tr> 
 </thead>
 <tbody>
   
   
   
   <?php    
					$stmt=$conn->prepare("select  RaBillNO1 from    pw__comp where custId=:custId and randNo=:randNo group by RaBillNO1");  
					$stmt->bindValue(':custId',  $_SESSION['custId'], PDO::PARAM_STR);  			
					$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
					$stmt->execute(); 
					$AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
					 
					$sr = 1;    
					foreach($AllUsers as $mpp)
					{ 		  
					
						$stmt=$conn->prepare("select  * from    pw__comp where custId=:custId and randNo=:randNo and RaBillNO1=:RaBillNO1");  
						$stmt->bindValue(':custId',  $_SESSION['custId'], PDO::PARAM_STR);  			
						$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
						$stmt->bindValue(':RaBillNO1',  $mpp->RaBillNO1, PDO::PARAM_STR);  	 
						$stmt->execute(); 
						$AllUsersUswer = $stmt->fetchAll(PDO::FETCH_OBJ); 
					
						$whtotal = 0;
						foreach($AllUsersUswer as $users)
						{
						
						if($users->commodity==1)	 {
							$cmdt = "LABOUR";
							 
						}
						else if($users->commodity==2)	 
						{
							$cmdt = "MATERIAL";
							 
						}
						else if($users->commodity==3)	 {
							$cmdt = "POL";
							 
						}
						else if($users->commodity==4)	
							$cmdt = "BITUMEN VG-30";
						else if($users->commodity==5)	
							$cmdt = "BITUMEN VG-10";
						else if($users->commodity==6)	
							$cmdt = "CEMENT LINE"; 
						else if($users->commodity==7)	
							$cmdt = "CEMENT";
						else if($users->commodity==8)	
							$cmdt = "STEEL";
						else if($users->commodity==9)	
							$cmdt = "STEEL LONG";
						
						
						if($users->grade==1)
							$grade = "Vg 30(60/70)";
						else if($users->grade==2)
							$grade = "Vg 10(80/100)";
						else if($users->grade==3) 
							$grade = "TMT";
						else
							$grade = "";	
						   
						$whtotal += $users->qtyamt;   
						
						
					?> 
					<tr>  
					<td><?php echo $users->RaBillNO1;?></td>
					<td><?php echo $cmdt;?></td>
					<td><?php echo $grade;?></td>
					<td><?php echo $users->qtyperunit1."MT@".$users->qtyperunit2;?></td>
					<td><?php echo $users->qtyamt;?></td> 
					</tr>
					
					<?php 
						}
						
						$mtotal +=$whtotal;
					?>
					<tr>  
					<td> </td>
					<td> </td>
					<td> </td>
					<th>Total </th>
					<th> <?php echo $whtotal;?> </th>
					 
					</tr>
					
					<?php  	
						$sr++;
						} 
					?> 
					 
					 
   <tr>
    <td colspan="4" class="text-right"><b>Total</b></td>   
    <td class="text-right"><b><?php echo $mtotal;?></b></td>          
   </tr>  
 </tbody>
</table>
  </div>
</div>





<!--div class="row">
  
   <label class="col-sm-3"><b>Basic Index:</b>37998.33</label>
   <label class="col-sm-3"><b>Basic Index:</b>37998.33</label>
   <label class="col-sm-3"><b>Basic Index:</b>37998.33</label>
   <label class="col-sm-3"><b>Basic Index:</b>37998.33</label>

</div-->  
 <div class="row">
<div class="col-sm-8">
 <table class="table table-bordered">
 
	<tr>
    <td class="text-right align-bottom">Months</td>
    <td class="p-0">
      <table class="table mb-0">
        <tr>
          <thead>
            <th class="text-center">LABOUR</th>
            <th class="text-center">MATERIAL</th>
            <th class="text-center">POL</th>           
          </thead>
        </tr>
        <tr>
          <td width="40%" class="text-right">Index</td>
          <td width="30%" class="text-right">Index</td>
          <td width="30%" class="text-right">Index</td>          
        </tr>

      </table>


    </td>
   </tr>

<?php 
				
	$stmt=$conn->prepare("select  * from    pw__rabills where  randNo=:randNo  ");   
	$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
	$stmt->execute(); 
	if($stmt->rowCount() > 0) 
	{   

	  $RaBillNo = $stmt->fetchAll(PDO::FETCH_OBJ);   
	  foreach($RaBillNo as $RaRecordKey=>$abcd)
	  {    					
					
?>

		<?php    
					
					$stmt=$conn->prepare("select  * from    pw__comdtdata    where  agId=:id and  randumNo=:randumNo  ");  
					$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
					$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  	  
					$stmt->execute(); 
					$racmdFetch = $stmt->fetchAll(PDO::FETCH_OBJ);
					
					foreach($racmdFetch as $mppp)
					{
							if($mppp->cmdt==1) 
								$lbrCenrt = $mppp->center;
							else if($mppp->cmdt==2) 
								$matCenrt = $mppp->center;
							else if($mppp->cmdt==3) 
								$polCenrt = $mppp->center; 
					}
					
					$stmt=$conn->prepare("select  workOrderdate from    MyWorks  where randNo=:randNo  ");  
					$stmt->bindValue(':randNo', $rnd , PDO::PARAM_STR);  			 
					$stmt->execute(); 
					$MyWorks = $stmt->fetch(PDO::FETCH_OBJ); 

					 
					if($abcd->RaBillNO==1) 
					{
					 
							$originalDate = $MyWorks->workOrderdate;
							$WorkOrder = date("M-Y", strtotime($originalDate));  
							$WorkOrder1 = date("M-Y", strtotime($originalDate));  
							 
							  
							 
							$stmt=$conn->prepare("select  * from  pw__rabills  where randNo=:randNo  and RaBillNO=:RaBillNO ");  
							$stmt->bindValue(':RaBillNO', $abcd->RaBillNO , PDO::PARAM_STR);  			  
							$stmt->bindValue(':randNo', $rnd , PDO::PARAM_STR);  			  
							$stmt->execute(); 
							$pw__rabills = $stmt->fetch(PDO::FETCH_OBJ);  
							 
							 
							$FirstBill = $pw__rabills->recordingD; 
							$originalDate = $pw__rabills->recordingD;
							$newDate = date("M-Y", strtotime($originalDate)); 

								
							
						  
							$ts1 = strtotime($WorkOrder);
							$ts2 = strtotime($newDate);

							$year1 = date('Y', $ts1);
							$year2 = date('Y', $ts2);

							$month1 = date('m', $ts1);
							$month2 = date('m', $ts2);  
							$invtDts = (($year2 - $year1) * 12) + ($month2 - $month1);
							$invtDts +=1; 
					}else
					{  	  	
							
							$Temp = date("Y-m-d", strtotime($FirstBill));   
							$Expdata = explode("-",$Temp);   
							
							if($Expdata[1]>11)
								$originalDate = strval(($Expdata[0]+1)."-01-20");  
							else	 
								$originalDate = strval($Expdata[0]."-".($Expdata[1]+1)."-20");  
							 
							
							$WorkOrder = date("M-Y", strtotime($originalDate));     
							$WorkOrder1 = date("M-Y", strtotime($originalDate));     
							      
							
							 
							$stmt=$conn->prepare("select  * from  pw__rabills  where randNo=:randNo  and RaBillNO=:RaBillNO ");  
							$stmt->bindValue(':RaBillNO', $abcd->RaBillNO , PDO::PARAM_STR);  			  
							$stmt->bindValue(':randNo', $rnd , PDO::PARAM_STR);  			  
							$stmt->execute(); 
							$pw__rabills = $stmt->fetch(PDO::FETCH_OBJ);    
						 
							 
							$originalDate = $pw__rabills->recordingD; 
							$FirstBill = $originalDate;
							$newDate = date("M-Y", strtotime($originalDate));     
							
						  
							$ts1 = strtotime($WorkOrder);
							$ts2 = strtotime($newDate);

							$year1 = date('Y', $ts1);
							$year2 = date('Y', $ts2);

							$month1 = date('m', $ts1);
							$month2 = date('m', $ts2);  
							$invtDts = (($year2 - $year1) * 12) + ($month2 - $month1);
							$invtDts +=1; 
					}
					
					
					 
					$i = 1;     
					$avg1 = 0;
					$avg2 = 0;
					$avg3 = 0;
					do 
					{    	
 
					 
					 
					$stmt=$conn->prepare("select   indexval from  pw__exclationtbl1  where commodity=1  and center=$lbrCenrt  and dateselect like '%$WorkOrder1%' ");   
					$stmt->execute(); 
					
					if($stmt->rowCount() >0)
					{
							$pw_indexval1 = $stmt->fetchAll(PDO::FETCH_OBJ);  
							$sr=0;  
							$v1 = 0;
							foreach($pw_indexval1 as $mpp)
							{	   
								$v1 +=$mpp->indexval;
								$sr++;
							} 
							$v1 = $v1/$sr;
							$lastLaberI = $v1;	
					}else
						$v1 = $lastLaberI;
					  
					
					$stmt=$conn->prepare("select   indexval from  pw__exclationtbl1  where commodity=2  and center=$matCenrt  and dateselect like '%$WorkOrder1%' ");   
					$stmt->execute(); 
					if($stmt->rowCount() >0)
					{						
						$pw_indexval2 = $stmt->fetchAll(PDO::FETCH_OBJ); 
						$sr=0;  
						$v2 = 0;
						foreach($pw_indexval2 as $mpp)
						{	    

							$v2 +=$mpp->indexval;
							$sr++;
						} 
						$v2 = $v2/$sr;  
						$lastMatI = $v2;	
						
					}else
						$v2 = $lastMatI; 
						
						 


					$stmt=$conn->prepare("select   indexval from  pw__exclationtbl1  where commodity=3   and center=$polCenrt and dateselect like '%$WorkOrder1%' ");   
					$stmt->execute(); 
					if($stmt->rowCount() >0)
					{
						$pw_indexval3 = $stmt->fetchAll(PDO::FETCH_OBJ);  
						
						$sr=0;
						$v3 = 0;					
						foreach($pw_indexval3 as $mpp)
						{	    

						$v3 +=$mpp->indexval;
						$sr++;
						} 
						$v3 = $v3/$sr;
						$lastPolI = $v3;
					}else
						$v3 = $lastPolI;      
					
					$avg1 += $v1;	
					$avg2 += $v2;	
					$avg3 += $v3;	

?> 
					
					
 <tr>
    <td class="text-right align-bottom"><b> <?php echo $WorkOrder1;?> </b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>
          <td width="40%" class="text-right">  <?php echo $v1;?> </td>
          <td width="30%" class="text-right"> <?php echo $v2;?></td>
          <td width="30%" class="text-right"> <?php echo $v3;?></td>          
        </tr>  
      </table>  
    </td>
</tr>
<?php 
							
							$WorkOrder1 = date('M-Y', strtotime($WorkOrder .'+'.$i.' months'));   
							$i++;  
							
					}while ($i<=($invtDts)); 
?> 


  <tr>
    <td class="text-right align-bottom"><b>Avg </b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>   
			<td width="40%" class="text-right">  <?php echo number_format($avg1/($invtDts), 2);?> </td>
			<td width="30%" class="text-right"><?php echo number_format($avg2/($invtDts), 2);?></td>
			<td width="30%" class="text-right"> <?php echo number_format($avg3/($invtDts), 2);?></td> 
		  
        </tr>  
      </table>  
    </td>
</tr>

 <tr>
    <td class="text-right align-bottom"><b>Diff of basic & Avg</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>   
			<td width="40%" class="text-right"><?php $avgdata1 = number_format((number_format($avg1/($invtDts), 2)-$avgLbr),2); echo  $avgdata1;?> </td>
			<td width="30%" class="text-right"><?php $avgdata2 = number_format((number_format($avg2/($invtDts), 2)-$avgmat),2); echo $avgdata2 ;?></td>
			<td width="30%" class="text-right"> <?php $avgdata3 =   number_format((number_format($avg3/($invtDts), 2)-$avpol),2); echo  $avgdata3 ;?></td> 
		  
        </tr>  
      </table>  
    </td>
</tr>

<tr>
    <td class="text-right align-bottom"><b> 85% of Work Done</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>   
			<td width="40%" class="text-right"><?php echo $eightFive[$RaRecordKey];?></td>
			<td width="30%" class="text-right"><?php echo $eightFive[$RaRecordKey];?></td>
			<td width="30%" class="text-right"> <?php echo $eightFive[$RaRecordKey];?></td> 
		  
        </tr>  
      </table>  
    </td>
</tr>



<tr>
    <td class="text-right align-bottom"><b>Esclation Amont</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>   
			<th width="40%" class="text-right"><?php 
					$l1 = number_format((($eightFive[$RaRecordKey])*($perLbr/100)),2); 
					$l1 =  str_replace(",","",$l1);	
					$tmp = number_format((($l1*$avgdata1)/$avgLbr),2);
					$tmp = str_replace(",","",$tmp); 
					$ecAmt1 += $tmp;
					echo number_format((($l1*$avgdata1)/$avgLbr),2);  
						
					?></th>
			<th width="30%" class="text-right"><?php    
						$l2 = number_format((($eightFive[$RaRecordKey])*($permat/100)),2); 
						$l2 =  str_replace(",","",$l2);	
						$tmp =  number_format((($l2*$avgdata2)/$avgmat),2);  
						$tmp = str_replace(",","",$tmp); 
						$ecAmt2 += $tmp; 
						echo number_format((($l2*$avgdata2)/$avgmat),2);  
						
					?></th>
			<th width="30%" class="text-right"><?php 
						$l3 = number_format((($eightFive[$RaRecordKey])*($perpol/100)),2); 
						$l3 =  str_replace(",","",$l3);	 
						$tmp =  number_format((($l3*$avgdata3)/$avpol),2);  
						$tmp = str_replace(",","",$tmp); 
						$ecAmt3 += $tmp; 
						
						echo number_format((($l3*$avgdata3)/$avpol),2);  
					?></th> 
		  
        </tr>  
      </table>  
    </td>
</tr>     

<?php 

}
?> 
 
 
<?php 
} 
	?> 

<tr>
    <td class="text-right"><b>Total Amount</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>
          <td width="40%" class="text-right"><b><?php echo $ecAmt1;?></b></td>
          <td width="30%" class="text-right"><b><?php echo $ecAmt2;?></b></td>
          <td width="30%" class="text-right"><b><?php echo $ecAmt3;?></b></td>          
        </tr>  
      </table>  
    </td>
</tr>





<!--  COMSUMPTION  --->





 <table class="table table-bordered">     
<?php    
		
		$stmt=$conn->prepare("select  cmdt from    pw__comdtdata    where  agId=:id  and randumNo=:randumNo  ");  
		$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
		$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  	  
		$stmt->execute(); 
		
		$pw__comdtdataData = $stmt->fetchAll(PDO::FETCH_ASSOC);
		
		foreach($pw__comdtdataData as $mpp)
		$people[] = $mpp['cmdt'];    
		
		 
		 
		$bt1=0; 
		$bt2=0; 
		$bt3=0;    
		 
?> 
	 
	 					
 <tr>
    <td class="text-right align-bottom"><b> Months</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>  
			<?php if(in_array(4, $people))  {  $bt1=4;   ?> 
				<th width="40%" class="text-right">  BITUMEN VG-30</th> 
			<?php } ?>   
			
			<?php if(in_array(5, $people))  {  $bt1=5;   ?> 
				<th width="40%" class="text-right"> BITUMEN VG-10</th> 
			<?php } ?>  
			
			<?php if(in_array(6, $people))  {  $bt2=6;   ?> 
				<th width="40%" class="text-right"> CEMENT LINE</th> 
			<?php } ?> 
			
			<?php if(in_array(7, $people))  {  $bt2=7;   ?> 
				<th width="40%" class="text-right"> CEMENT</th> 
			<?php } ?> 
			
			<?php if(in_array(8, $people))  {  $bt3=8;   ?> 
				<th width="40%" class="text-right"> STEELL</th> 
			<?php } ?> 
			
			<?php if(in_array(9, $people))  {  $bt3=9;   ?> 
				<th width="40%" class="text-right"> STEEL </th> 
			<?php } ?> 
			
			
        </tr>  
		
		<tr>  
			<?php if(in_array(4, $people))  {    ?> 
				<td width="40%" class="text-right"> Index</td> 
			<?php } ?> 
			
			<?php if(in_array(5, $people)) {    ?> 
				<td width="40%" class="text-right"> Index</td> 
			<?php } ?> 
			
			<?php if(in_array(6, $people))  {   ?> 
				<td width="40%" class="text-right"> Index</td> 
			<?php } ?>   
			
			 <?php if(in_array(7, $people)) {    ?> 
				<td width="40%" class="text-right"> Index</td> 
			<?php } ?> 
			
			<?php if(in_array(8, $people)) {    ?> 
				<td width="40%" class="text-right"> Index</td> 
			<?php } ?> 
			
			<?php if(in_array(9, $people)) {    ?> 
				<td width="40%" class="text-right"> Index</td> 
			<?php } ?> 
			
        </tr>  
      </table>  
	  
    </td>
</tr>


<?php   
				
		$stmt=$conn->prepare("select  * from    pw__rabills where  randNo=:randNo  ");   
		$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
		$stmt->execute(); 
		if($stmt->rowCount() > 0) 
		{   

		$RaBillNo = $stmt->fetchAll(PDO::FETCH_OBJ);   
		foreach($RaBillNo as $RaRecordKey=>$abcd)
		{       						
				
			$stmt=$conn->prepare("select  workOrderdate from    MyWorks  where randNo=:randNo  ");  
			$stmt->bindValue(':randNo', $rnd , PDO::PARAM_STR);  			 
			$stmt->execute(); 
			$MyWorks = $stmt->fetch(PDO::FETCH_OBJ); 

					 
					if($abcd->RaBillNO==1) 
					{
					 
							$originalDate = $MyWorks->workOrderdate;
							$WorkOrder = date("M-Y", strtotime($originalDate));  
							$WorkOrder1 = date("M-Y", strtotime($originalDate));   
							  
							 
							$stmt=$conn->prepare("select  * from  pw__rabills  where randNo=:randNo  and RaBillNO=:RaBillNO ");  
							$stmt->bindValue(':RaBillNO', $abcd->RaBillNO , PDO::PARAM_STR);  			  
							$stmt->bindValue(':randNo', $rnd , PDO::PARAM_STR);  			  
							$stmt->execute(); 
							$pw__rabills = $stmt->fetch(PDO::FETCH_OBJ);  
							 
							 
							$FirstBill = $pw__rabills->recordingD; 
							$originalDate = $pw__rabills->recordingD;
							$newDate = date("M-Y", strtotime($originalDate)); 

								
							
						  
							$ts1 = strtotime($WorkOrder);
							$ts2 = strtotime($newDate);

							$year1 = date('Y', $ts1);
							$year2 = date('Y', $ts2);

							$month1 = date('m', $ts1);
							$month2 = date('m', $ts2);  
							$invtDts = (($year2 - $year1) * 12) + ($month2 - $month1);
							$invtDts +=1; 
					}else
					{
						  	
							
							
							
							$Temp = date("Y-m-d", strtotime($FirstBill));   
							$Expdata = explode("-",$Temp);   
							
							if($Expdata[1]>11)
								$originalDate = strval(($Expdata[0]+1)."-01-20");  
							else	 
								$originalDate = strval($Expdata[0]."-".($Expdata[1]+1)."-20");  
							 
							
							$WorkOrder = date("M-Y", strtotime($originalDate));     
							$WorkOrder1 = date("M-Y", strtotime($originalDate));     
							  
							  
							 
							$stmt=$conn->prepare("select  * from  pw__rabills  where randNo=:randNo  and RaBillNO=:RaBillNO ");  
							$stmt->bindValue(':RaBillNO', $abcd->RaBillNO , PDO::PARAM_STR);  			  
							$stmt->bindValue(':randNo', $rnd , PDO::PARAM_STR);  			  
							$stmt->execute(); 
							$pw__rabills = $stmt->fetch(PDO::FETCH_OBJ);    
						 
							 
							$originalDate = $pw__rabills->recordingD; 
							$FirstBill = $originalDate;
							$newDate = date("M-Y", strtotime($originalDate));     
							
						  
							$ts1 = strtotime($WorkOrder);
							$ts2 = strtotime($newDate);

							$year1 = date('Y', $ts1);
							$year2 = date('Y', $ts2);

							$month1 = date('m', $ts1);
							$month2 = date('m', $ts2);  
							$invtDts = (($year2 - $year1) * 12) + ($month2 - $month1);
							$invtDts +=1;  
					}
					
					
					  
					$i = 1;     
					$avg1 = 0;
					$avg2 = 0;
					$avg3 = 0;
					do 
					{    	
 
					  
					if($bt1!=0) 
						{
							$stmt=$conn->prepare("select   indexval from  pw__exclationtbl1  where commodity=:commodity  and dateselect like '%$WorkOrder1%' "); 
							$stmt->bindValue(':commodity', $bt1, PDO::PARAM_STR);  						
							$stmt->execute(); 
							
							if($stmt->rowCount() >0)
							{
									$pw_indexval1 = $stmt->fetchAll(PDO::FETCH_OBJ);  
									$sr=0;  
									$v1 = 0;
									foreach($pw_indexval1 as $mpp)
									{	   
										$v1 +=$mpp->indexval;
										$sr++;
									} 
									$v1 = $v1/$sr;
									$lastLaberI = $v1;	 
							}else 
								$v1 = $lastLaberI;
							
							$indices1[] = $v1;
									
							$avg1 += $v1; 
						}
						
						if($bt2!=0) 
						{ 		 
							$stmt=$conn->prepare("select   indexval from  pw__exclationtbl1  where commodity=:commodity  and dateselect like '%$WorkOrder1%' "); 
							$stmt->bindValue(':commodity', $bt2, PDO::PARAM_STR);  						
							$stmt->execute(); 
							
							if($stmt->rowCount() >0)
							{						
								$pw_indexval2 = $stmt->fetchAll(PDO::FETCH_OBJ); 
								$sr=0;  
								$v2 = 0;
								foreach($pw_indexval2 as $mpp)
								{	     
									$v2 +=$mpp->indexval;
									$sr++;
								} 
								$v2 = $v2/$sr;  
								$lastMatI = $v2;	  
							}else
								$v2 = $lastMatI;  
							
							$indices2[] = $v2;

							$avg2 += $v2;			
						}
						
						
						if($bt3!=0) 
						{
							$stmt=$conn->prepare("select   indexval from  pw__exclationtbl1  where commodity=:commodity  and dateselect like '%$WorkOrder1%' "); 
							$stmt->bindValue(':commodity', $bt3, PDO::PARAM_STR);  						
							$stmt->execute();  		
							if($stmt->rowCount() >0)
							{
								$pw_indexval3 = $stmt->fetchAll(PDO::FETCH_OBJ);   
								$sr=0;
								$v3 = 0;					
								foreach($pw_indexval3 as $mpp)
								{	 
								$v3 +=$mpp->indexval;
								$sr++;
								} 
								$v3 = $v3/$sr;
								$lastPolI = $v3;
							}else
								$v3 = $lastPolI;    
							
							$indices3[] = $v3;		
							
							$avg3 += $v3;	
						} 
					?>  
					
 <tr>
    <td class="text-right align-bottom"><b> <?php echo $WorkOrder1;?> </b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>  
			<?php 
			if($bt1!=0) 
			{ 
			?>
				<td width="40%" class="text-right"><?php echo $v1;?></td> 
			<?php } ?>

          <?php 
			if($bt2!=0) 
			{ 
			?>
				<td width="40%" class="text-right"><?php echo $v2;?></td> 
			<?php } ?>
          <?php 
			if($bt3!=0) 
			{ 
			?>
				<td width="40%" class="text-right"><?php echo $v3;?></td> 
			<?php } ?>
        </tr>  
      </table>  
	  
    </td>
</tr>
<?php   
	$WorkOrder1 = date('M-Y', strtotime($WorkOrder .'+'.$i.' months'));   
	$i++;   
	}while ($i<=($invtDts)); 
?> 



	<?php   
							
						$manSet = 0;
						$stmt=$conn->prepare("select   id  from pw__comp  where commodity=:commodity  and randNo=:randNo and RaBillNO1=:RaBillNO1 "); 
						$stmt->bindValue(':commodity', $bt1, PDO::PARAM_STR);  						
						$stmt->bindValue(':randNo', $_REQUEST['randNo'] , PDO::PARAM_STR);  						
						$stmt->bindValue(':RaBillNO1', $abcd->RaBillNO , PDO::PARAM_STR);  						
						$stmt->execute(); 
						 
						if($stmt->rowCount() > 0)
							$manSet = 1;	

						$manSet2 = 0;
						$stmt=$conn->prepare("select   id  from pw__comp  where commodity=:commodity  and randNo=:randNo and RaBillNO1=:RaBillNO1 "); 
						$stmt->bindValue(':commodity', $bt2, PDO::PARAM_STR);  						
						$stmt->bindValue(':randNo', $_REQUEST['randNo'] , PDO::PARAM_STR);  						
						$stmt->bindValue(':RaBillNO1', $abcd->RaBillNO , PDO::PARAM_STR);  						
						$stmt->execute(); 
						 
						if($stmt->rowCount() > 0)
							$manSet2 = 1;		
						
						$manSet3 = 0;
						$stmt=$conn->prepare("select   id  from pw__comp  where commodity=:commodity  and randNo=:randNo and RaBillNO1=:RaBillNO1 "); 
						$stmt->bindValue(':commodity', $bt3, PDO::PARAM_STR);  						
						$stmt->bindValue(':randNo', $_REQUEST['randNo'] , PDO::PARAM_STR);  						
						$stmt->bindValue(':RaBillNO1', $abcd->RaBillNO , PDO::PARAM_STR);  						
						$stmt->execute(); 
						 
						if($stmt->rowCount() > 0)
							$manSet3 = 1;    
						 						
	?>				
  <tr>
    <td class="text-right align-bottom"><b>Avg </b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>     	
			<?php 
				if($bt1!=0) 
				{
				if(($bt1!=0) && ($manSet==1)) 
				{ 
						$avgn  = 0;
							foreach($indices1 as $axn)
								$avgn +=$axn;  
							
							$firstAvg =  $avgn/count($indices1);//($invtDts);//number_format($avg1/($invtDts), 2)
			?>	 
					<td width="40%" class="text-right">
					<?php 
						echo number_format($firstAvg, 2);  
						$indices1 = null;
					?>
					</td>
			<?php 
				}
						else 
					{
					?>
						<td width="40%" class="text-right"> </td>
					<?php 
					} 
				}  
				
				
				if($bt2!=0) 
				{
				if(($bt2!=0) && ($manSet2==1)) 
				{ 
						$avgm  = 0;
							foreach($indices2 as $axn)
								$avgm +=$axn;  
							
							$srcondAvg =  $avgm/count($indices2);//($invtDts);//number_format($avg1/($invtDts), 2) 
			?>	 
					<td width="40%" class="text-right">
					<?php 
						echo number_format($srcondAvg, 2);  
						$indices2 = null;
					?>
					</td>
			<?php 
				}
						else 
					{
					?>
						<td width="40%" class="text-right"> </td>
					<?php 
					} 
				}  
				
				
				if($bt3!=0) 
				{
				if(($bt3!=0) && ($manSet3==1)) 
				{ 
						$avgx  = 0;
							foreach($indices3 as $axn)
								$avgx +=$axn;  
							
							$thirdAvg =  $avgx/count($indices3);//($invtDts);//number_format($avg1/($invtDts), 2)
			?>	 
					<td width="40%" class="text-right">
					<?php 
						echo number_format($thirdAvg, 2);  
						$indices3 = null;
					?>
					</td>
			<?php 
				}
						else 
					{
					?>
						<td width="40%" class="text-right"> </td>
					<?php 
					} 
				}  
			?> 
        </tr>  
      </table>  
    </td>
</tr>

 <tr>
    <td class="text-right align-bottom"><b>Comsumption Quantity</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>    
						<?php    
						if($bt1!=0)  
						{
						if( ($bt1!=0) && ($manSet==1)) 
						{ 
					
						$stmt=$conn->prepare("select  qtyperunit1 from    pw__comp where custId=:custId and randNo=:randNo and commodity=:commodity and RaBillNO1=:RaBillNO1 order by id ");  
						$stmt->bindValue(':custId',  $_SESSION['custId'], PDO::PARAM_STR);  			
						$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
						$stmt->bindValue(':commodity',  $bt1 , PDO::PARAM_STR);  	 
						$stmt->bindValue(':RaBillNO1',  $abcd->RaBillNO , PDO::PARAM_STR);  	 
						$stmt->execute(); 
						$dateOfra1 = $stmt->fetch(PDO::FETCH_OBJ); 
					
					?>	
					<td width="40%" class="text-right"><?php  echo $dateOfra1->qtyperunit1;?></td>
					<?php 
						} else 
						{
						?>
						<td width="40%" class="text-right"> </td>
					  <?php }
						}					  
						if($bt2!=0) 
						{
						if( ($bt2!=0) && ($manSet2==1)) 
						{
						$stmt=$conn->prepare("select  qtyperunit1 from    pw__comp where custId=:custId and randNo=:randNo and commodity=:commodity and RaBillNO1=:RaBillNO1 order by id ");  
						$stmt->bindValue(':custId',  $_SESSION['custId'], PDO::PARAM_STR);  			
						$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
						$stmt->bindValue(':commodity',  $bt2 , PDO::PARAM_STR);  
						$stmt->bindValue(':RaBillNO1',  $abcd->RaBillNO , PDO::PARAM_STR); 						
						$stmt->execute(); 
						$dateOfra2 = $stmt->fetch(PDO::FETCH_OBJ);   
					?>	
					<td width="40%" class="text-right"><?php  echo $dateOfra2->qtyperunit1;?></td>
					<?php }  else {
					?>
						<td width="40%" class="text-right"> </td>
						<?php }	
						}						
						if($bt3!=0) 
						{
						if( ($bt3!=0) && ($manSet3==1)) 
						{
						$stmt=$conn->prepare("select  qtyperunit1 from    pw__comp where custId=:custId and randNo=:randNo and commodity=:commodity and RaBillNO1=:RaBillNO1  order by id ");  
						$stmt->bindValue(':custId',  $_SESSION['custId'], PDO::PARAM_STR);  			
						$stmt->bindValue(':randNo',  $rnd, PDO::PARAM_STR);  	 
						$stmt->bindValue(':commodity',  $bt3 , PDO::PARAM_STR); 
						$stmt->bindValue(':RaBillNO1',  $abcd->RaBillNO , PDO::PARAM_STR); 						
						$stmt->execute(); 
						$dateOfra3 = $stmt->fetch(PDO::FETCH_OBJ);   
					?>	
					<td width="40%" class="text-right"><?php  echo $dateOfra3->qtyperunit1;?></td>
					<?php 
						} 
					else  {  
				?>
					<td width="40%" class="text-right"> </td>
				<?php 
					}
				}
				?> 
        </tr>  
      </table>  
    </td>
</tr>

 
 
 
 <tr>
    <td class="text-right align-bottom"><b>Basic or CSR Index</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>    
					<?php     
						if($bt1!=0)  
						{ 	
						if( ($bt1!=0) && ($manSet==1)) 
						{   
 
							$stmt=$conn->prepare("select  csr,avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt and  randumNo=:randumNo    ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt1  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_ASSOC); 
							$firstCsr = $pw__comdtdataData['csr'];	
					
					?>	
						<td width="40%" class="text-right"><?php    
								if($pw__comdtdataData['avgdta']>$firstCsr) 
								{ 	$higer = $pw__comdtdataData['avgdta'];;
									echo  $pw__comdtdataData['avgdta'];
								}
								else  {
									echo  $firstCsr;
										$higer = $firstCsr;
								}
						?></td>
					<?php
							}else {
					?>	
						<td width="40%" class="text-right"> </td>
						<?php 	
						} 
						} 
						
						if($bt2!=0) 
						{
							if( ($bt2!=0) && ($manSet2==1)) 
							{
						
						$stmt=$conn->prepare("select  csr from    pw__comdtdata    where  agId=:id and cmdt=:cmdt  and  randumNo=:randumNo  ");  
						$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
						$stmt->bindValue(':cmdt', $bt2  , PDO::PARAM_STR);  
						$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   
						$stmt->execute();  
						$pw__comdtdataData = $stmt->fetch(PDO::FETCH_ASSOC); 
						$secondCsr = $pw__comdtdataData['csr'];		
					?>	
					<td width="40%" class="text-right"><?php  echo $pw__comdtdataData['csr'] ;?></td>
					<?php 
						}
						else
						{
					?>	
						<td width="30%" class="text-right"> </td>
						<?php 	
							} 
						} 
						if($bt3!=0) 
						{
						if( ($bt3!=0) && ($manSet3==1)) 
						{
							$stmt=$conn->prepare("select  csr from    pw__comdtdata    where  agId=:id and cmdt=:cmdt   and  randumNo=:randumNo  ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt3  , PDO::PARAM_STR);  	
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   							
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_ASSOC); 
							$thirdCsr = $pw__comdtdataData['csr'];		   
					?>	
					<td width="40%" class="text-right"><?php  echo $pw__comdtdataData['csr'] ;?></td>
					<?php 
						} else { 
						?>
						<td width="40%" class="text-right"> </td>
					<?php 
					   }  
					 } 
					?> 
        </tr>  
      </table>  
    </td>
</tr>



		
		
		

 
 <tr>
    <td class="text-right align-bottom"><b>Diff of basic & Avg</b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>    
					<?php   
						if($bt1!=0)  
						{
						if( ($bt1!=0) && ($manSet==1)) 
						{ 
							$stmt=$conn->prepare("select  avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt and  randumNo=:randumNo   ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt2  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   							
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_OBJ);
					
					?>	
					<td width="40%" class="text-right">
					<?php 
								$idiif1 = ($firstAvg-$higer);
						echo    number_format((($firstAvg-$higer)),2);
					?></td>
					<?php }  else {
						?>
							<td width="40%" class="text-right"> </td> 
					<?php }
						} 
						if($bt2!=0) 
						{
						if( ($bt2!=0) && ($manSet2==1)) 
						{
						
							$stmt=$conn->prepare("select  avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt and  randumNo=:randumNo    ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt2  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_OBJ); 
							
					?>	
					<td width="40%" class="text-right"><?php 
					
								$idiif2 = number_format((($srcondAvg-$pw__comdtdataData->avgdta)),2);
						echo   number_format((($srcondAvg-$pw__comdtdataData->avgdta)),2); 
					?></td>
					<?php } 
					   else 
					   { 
					?>
					<td width="40%" class="text-right"> </td>  
					<?php 
						}
					  }
						
					if($bt3!=0) 
					{
					if( ($bt3!=0) && ($manSet3==1)) 
					{
							$stmt=$conn->prepare("select  avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt and  randumNo=:randumNo   ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt3  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_OBJ);  
					?>	
					<td width="40%" class="text-right"><?php 
								$idiif3 = number_format((($thirdAvg-$pw__comdtdataData->avgdta)),2);
						echo   number_format((($thirdAvg-$pw__comdtdataData->avgdta)),2); 
					?></td>
					<?php 
						}  else 
						{?>
					<td width="40%" class="text-right"> </td>  
						<?php 
							}
					}
					?>
					
        </tr>  
      </table>  
    </td>
</tr>			
 
 
 <tr>
    <td class="text-right align-bottom"><b>Esclation Amont </b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>    
					<?php   
						if($bt1!=0)
						{							
						if( ($bt1!=0) && ($manSet==1)) 
						{ 	
					
							$stmt=$conn->prepare("select  avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt  and  randumNo=:randumNo  ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt2  , PDO::PARAM_STR); 
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   							
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_OBJ);  
							
							$tmp = number_format(($dateOfra1->qtyperunit1*$idiif1),2);
							$tmp = str_replace(",","",$tmp); 
							$ecAmt4 += $tmp; 	
					
					?>	
					<th width="40%" class="text-right">
					<?php  echo  number_format(($dateOfra1->qtyperunit1*$idiif1),2); ?> </th>
					<?php 
							}else {
						?>
						<td width="40%" class="text-right"> </td>
					<?php }		
					 }					
						if($bt2!=0) 
						{
						if( ($bt2!=0) && ($manSet2==1)) 
						{ 
							$stmt=$conn->prepare("select  avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt and  randumNo=:randumNo   ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt2  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_OBJ);  
							
							$tmp = number_format((($secondCsr * (($idiif2)/$pw__comdtdataData->avgdta))*$dateOfra2->qtyperunit1),2);
							$tmp = str_replace(",","",$tmp); 
							$ecAmt5 += $tmp; 	
							
					?>	
					<th width="40%" class="text-right"><?php  echo  number_format((($secondCsr * (($idiif2)/$pw__comdtdataData->avgdta))*$dateOfra2->qtyperunit1),2);
					 
					?></th>
					<?php 
						}else {
						?>
						<td width="40%" class="text-right"> </td>
					<?php }	
						} 
						if($bt3!=0) 
						{
						if(($bt3!=0) && ($manSet3==1)) 
						{
							$stmt=$conn->prepare("select  avgdta from    pw__comdtdata    where  agId=:id and cmdt=:cmdt  and  randumNo=:randumNo   ");  
							$stmt->bindValue(':id', $_REQUEST['AgId']  , PDO::PARAM_STR);  	  
							$stmt->bindValue(':cmdt', $bt3  , PDO::PARAM_STR);  
							$stmt->bindValue(':randumNo', $_REQUEST['randNo']  , PDO::PARAM_STR);   						
							$stmt->execute();  
							$pw__comdtdataData = $stmt->fetch(PDO::FETCH_OBJ);  
							
							$tmp = number_format((($thirdCsr * (($idiif3)/$pw__comdtdataData->avgdta))*$dateOfra3->qtyperunit1),2);
							$tmp = str_replace(",","",$tmp); 
							$ecAmt6 += $tmp;
					?>	
					<th width="40%" class="text-right"><?php  echo  number_format((($thirdCsr * (($idiif3)/$pw__comdtdataData->avgdta))*$dateOfra3->qtyperunit1),2);?></th>
					<?php 
						}else {
						?>
						<td width="40%" class="text-right"> </td>
					<?php }	
						}   
					?> 
        </tr>  
      </table>  
    </td>
</tr>		


                 
<?php  
}
?>  
 
<?php 
} 
?> 
 
 
 
<td class="text-right align-bottom"><b> Total Amount </b></td>
    <td class="p-0">
      <table class="table mb-0">        
        <tr>    
					<?php   
						if($bt1!=0) 
						{ 	
					
							   
					
					?>	
					<th width="40%" class="text-right">
					<?php  echo $ecAmt4; ?> </th>
					<?php } ?>
					<?php 
						if($bt2!=0) 
						{  
					?>	
					<th width="40%" class="text-right"><?php  echo  $ecAmt5;?></th>
					<?php } ?>
					<?php 
						if($bt3!=0) 
						{ 
					?>	
					<th width="40%" class="text-right"><?php  echo  $ecAmt6;?></th>
					<?php } ?>
					
        </tr>  
      </table>  
    </td>
</tr>		
</div>
</div>
     

<input type="hidden"  value="<?php echo $ecAmt1;?>"  id="ecVal1Fetch"/> 
<input type="hidden"  value="<?php echo $ecAmt2;?>"  id="ecVal2Fetch"/> 
<input type="hidden"  value="<?php echo $ecAmt3;?>"  id="ecVal3Fetch"/> 
<input type="hidden"  value="<?php echo $ecAmt4;?>"  id="ecVal4Fetch"/> 
<input type="hidden"  value="<?php echo $ecAmt5;?>"  id="ecVal5Fetch"/> 
<input type="hidden"  value="<?php echo $ecAmt6;?>"  id="ecVal6Fetch"/> 


 
</div><!-- container ends here --->
<!-- page 4 starts here -->

</body>
</html>