<?php  
	/*$originalDate = "2021-12-30";
	$WorkOrder = date("M-Y", strtotime($originalDate));    
	echo $WorkOrder.'<br>';
	die;*/
	include_once("header-footer/header.php");
?>

<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>

 

 <script>
  
  
  function deleteDate(val)
  {
	  
			$.ajax({	
			type: "POST",
			url: "ajax.php",
			data: {deletecomm:1,val:val},	
			beforeSend: function(){ 
					 
			},
			success: function(val)
			{ 
			     location.reload();
			     //window.location.href=URL;
			}
		});	
	  
  }
  function agChnagege(val)
  {
		 
		location.href = "MyWorks.php?AgId="+val;
  }
  
  $( function() 
  {
    $( "#datepicker" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
    $( "#datepicker1" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
    $( "#Extention" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
    $( "#timeLimit" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
    $( "#basicIndices" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
    $( "#dateOFcompetition" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
  } );
  
  
  function DeleteRa(val)
  {
	  
			 
			$.ajax({	
			type: "POST",
			url: "ajax.php",
			data: {deletRaBill:1,id:val},
			beforeSend: function(){ 
			},
			success: function(data)
			{   
				 
				location.reload(); 
			}
			});
	  
  }
  
  </script>
<script>
        $(document).ready(function()
        {   
             //// if( ($(window).width()) > 599) 
             //window.location.href  = URL+'/error/default.php';
          
		 
		 
		  
			$("#datepicker").change(function()
			{ 	  
						
						var text = $("#datepicker").val();
						var myArray = text.split("/");

						var mydate = new Date($("#datepicker").val());
						var month = ["January", "February", "March", "April", "May", "June",
						"July", "August", "September", "October", "November", "December"][mydate.getMonth()];
						var str = month + ' ' + mydate.getFullYear();
						
						var basicIndices = month+" "+myArray[2];
						$("#basicIndices").val(basicIndices); 
					
			}); 

			
        	$("#_frm").validate({
        		
        		errorElement:'div',
        		rules:{ 
        		    
        		    
        		    Title:{
        				required:true,
        				maxlength:300,
        				minlength:3 
        			}, 
        			AggNo:{
        				required:true 
        			},
        			workOrder:{
        				required:true 
        			}, 
        			workcomm:{
        				required:true 
        			},
        			cost:{
        				required:true,
        				maxlength:10,
        			} 
        			
        		},
        		messages:{
                   
        			Title:{
        				required:"Enter project title",
        				maxlength:"Maximum  300 charaters allow",
        				minlength:"Minimum 3 charaters required"  
        			},
        			AggNo:{
        				required:"Enter agreement no "
        			},
        			workOrder:{
        				required:"Select date of work order "
        			},
        			workcomm:{
        				required:"Select date : order of commencement  "
        			},
        			cost:{
        				required:"Enter project cost",
    					maxlength:"Maximum  19 digits allow",
        			}      
        			 
        		}
        	}); 
        }); 
        </script>
        
        <style>
          .FormRegister
          {
              border: 1px solid #c2c2c2;
              margin: 1px;
              border-radius: 3px;
          }
        </style>
        
    	<link href="<?php echo ROOTPATH;?>/view/css/screen-600.css" rel="stylesheet" type="text/css">
               <?php 
	    include_once(ABS_PATH."/menu.php");
	?> 
               
                <div class="container mt-35">
                    <div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                     
									
                            </div>    
                                  <form method="post" autocomplete="off" id="_frm">   
                                            <div class="row">   
													
													 
                                                    
													
													<div class="col-md-12 text-center"> 
														Name of Work
        										    	<input  name="workN"  class="form-control mb-1" "Name of Work" value="<?php echo $FinalResult->workN;?>"/>
        										    </div>
													
                                                     <div class="col-md-12 text-center"> 
														Agreement No
        										    	<input  name="AggNo"  class="form-control mb-1" "Agreement No" value="<?php echo $FinalResult->AggNo;?>"/>
        										    </div>
													
													 <div class="col-md-12 text-center"> 
													 randNo
        										    	<input  name="randNo" readonly value="<?php echo $FinalResult->randNo;?>" class="form-control mb-1" "Random No"/>
        										    </div>
													
													 <div class="col-md-12 text-center"> 
														Short Name Of Work
        										    	<input  name="shortName"  readonly class="form-control mb-1"  value="<?php echo $FinalResult->shortName;?>" "Short Name Of Work"/>
        										    </div>
													
													 <div class="col-md-12 text-center"> 
														Work Order No
        										    	<input  name="workorderNo"  class="form-control mb-1"  value="<?php echo $FinalResult->workorderNo;?>"   "Work Order No"/>
        										    </div>
        										    
													
													<div class="col-md-12 text-center"> 
														Work Order Date
        										    <input    value="<?php echo $FinalResult->workOrderdate;?>"  class="form-control mb-1" id="datepicker1" name="workOrderdate"   "Work Order Date"/>
        										    </div>

													
													<div class="col-md-12 text-center"> 
														Time Limit
        										    <input     value="<?php echo $FinalResult->timeLimit;?>" class="form-control mb-1" id="timeLimit" name="timeLimit"   "Time Limit"/>
        										    </div>
													
													<div class="col-md-12 text-center"> 
														Extension
        										    <input    value="<?php echo $FinalResult->extention;?>"  class="form-control mb-1" id="Extention" name="extention"   "Extention"/>
        										    </div>
													
													<div class="col-md-6 text-center"> 
														Tender Accepted @
        										    	<input  value="<?php echo $FinalResult->TenderAccAt;?>"  class="form-control mb-1"  name="TenderAccAt"   "Tender Accepted @"/>
        										    </div>
													
													<div class="col-md-6 text-center"> 
															Select
														 <select  class="form-control"  name="TenderAccAtStats">
                                                            <option value="">Select </option> 
                                                            <option value="1" <?php if($FinalResult->TenderAccAtStats==1) echo "selected";?>>Above</option>  
                                                            <option value="2" <?php if($FinalResult->TenderAccAtStats==2) echo "selected";?>>Below</option>  
                                                            <option value="3" <?php if($FinalResult->TenderAccAtStats==3) echo "selected";?>>Atpar</option>  
                                                        </select> 	
        										    	 
        										    </div>
                                                       
                                                     <div class="col-md-12 text-center"> 
														Date of Receipient of Tender
        										    	<input  class="form-control mb-1" id="datepicker"  name="recDate"  value="<?php echo $FinalResult->recDate;?>"  "Date of Receipient of Tender"/>
        										    </div>
													
													<div class="col-md-12 text-center"> 
														Basic Indices Qtr Before
        										    	<input  class="form-control mb-1" id="basicIndices"  value="<?php echo $FinalResult->basicIndices;?>"  name="basicIndices"  readonly  "Basic Indices Qtr Before"/>
        										    </div> 
													
                                                    <!--div class="col-md-12 mb-1"> 
                                                        <select  class="form-control"  name="Division">
                                                            <option value="">Select Division</option>
                                                            <option value="1">PWD East Nashik</option> 
                                                            <option value="2">ZP</option>
                                                            <option value="3">Public Works Devision Beed</option>
                                                        </select> 
                                                    </div-->
                                                    
                                                   
													
													<div class="col-md-12 text-center"> 
														Date of Levy of Compensation / Fine
        										    	<input  name="dateOFcompetition"    class="form-control mb-1"   "Date of Levy of Compensation / Fine "/>
        										    </div>
												 
                                                    
                                                    <div class="col-md-12 text-center">
        										    	<input  type="submit" class="btn btn-primary mb-2" name="submitLogin" value="Update Record" > 
														<a  class="btn btn-danger mb-2" href="Mywokexp.php">   GO BACK </a>
        										    </div> 
													 
        										    
                                            </div>  
                                    </form>  
                    </div>       
                </div>
				
				
					<div class="container mt-35">  
						<div class="row justify-content-center FormRegister">
					<?php 
					if($_REQUEST['AgId']!='') 
					{
					?>
					<a  class="btn btn-danger mb-2" href="#"> <marquee>  AGENCY DETAILS OF   : <?php echo $pw__newage->name.", Agg No : ".$FinalResult->AggNo.", Short Name :".$FinalResult->shortName;;?>   </marquee>  </a>
					<?php } ?>
				
						</div>
					</div>
				
				<div class="container mt-35">  
					 <div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h5 class="card-title"> Agency Details </h5>     
                            </div>
					</div>
							
                    <div class="row  FormRegister">
					
					<table class="table">
					<thead class="thead-light">
					<tr>
					
					<th scope="col">Sr No</th>
					<th scope="col">Agency Name</th>
					<th scope="col">Short Name</th>
					<th scope="col">Agg No</th>     
					</tr> 
					
					</thead>
					<tbody> 
					<?php 
						$stmt=$conn->prepare("select * from MyWorks  where randNo=:randNo ");   
						$stmt->bindValue(':randNo', $_REQUEST['randNo']  , PDO::PARAM_STR);  
						$stmt->execute();    
						$neAgen = $stmt->fetchAll(PDO::FETCH_OBJ);

						 

						$sr = 1;
						foreach($neAgen as $asmm)
						{   
						
							$stmt=$conn->prepare("select  name from    pw__newage where id=:id "); 
							$stmt->bindValue(':id', $asmm->agency  , PDO::PARAM_STR);  							
							$stmt->execute(); 
							$agencyD = $stmt->fetch(PDO::FETCH_OBJ); 
							 
						?>
					<tr>   
						<th scope="row"> <?php echo $sr;?></th>
						<td><?php echo $agencyD->name;?></td> 
						<td><?php echo $asmm->shortName;?></td> 
						<td><?php echo $asmm->AggNo;?></td> 
						 
						<?php  } ?> 
					</tr> 
					</tbody>
					</table>   
                  </div>   
				  
					<div class="row justify-content-center FormRegister">
						<div class="col-md-12 text-center">
						<a   class="btn btn-primary mb-2"  target="_blank" href="addcomodity.php?randNo=<?php echo $asmm->randNo;?>&agency=<?php echo $_REQUEST['AgId'];?>"> Add Commodity </a>
						</div> 
					</div> 
                </div>
				
				<div class="container mt-35">
				
					<div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h5 class="card-title"> Commodity Details </h5>     
                            </div>
					</div>
					
                    <div class="row  FormRegister"> 
					<?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">
					<thead class="thead-light">
					<tr>
					<th scope="col">Sr</th>
					<th scope="col">Commodity</th>
					<th scope="col">Grade</th>
					<th scope="col"><?php echo $AllUsers->dat1;?></th>
					<th scope="col"><?php echo $AllUsers->dat2;?></th>
					<th scope="col"><?php echo $AllUsers->dat3;?></th>
					 <th scope="col">Average</th>
					<th scope="col">Center</th>
					<th scope="col">Source</th>
					<th scope="col">CSR</th> 
					<th scope="col">Per%</th> 
					<th scope="col">Action</th>
					</tr>
					</thead>
					<tbody>
					
					<?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->fetchAll(PDO::FETCH_OBJ); 
					$sr = 1; 
					
					 $userPer = 0;

					foreach($AllUsers as $users)
					{  
						
						if($users->cmdt==1)	 {
							$cmdt = "LABOUR";
							$avgLbr = number_format($users->avgdta,2);
							$perLbr = $users->perc;
							  
						}
						else if($users->cmdt==2)	 
						{
							$cmdt = "MATERIAL";
							$avgmat = number_format($users->avgdta,2);
							$permat = $users->perc;
						}
						else if($users->cmdt==3)	 {
							$cmdt = "POL";
							$avpol = number_format($users->avgdta,2);
							$perpol = $users->perc;
						}
						else if($users->cmdt==4) 
						{	
							$cmdt = "BITUMEN VG-30";
							$avbtmvg30 = number_format($users->avgdta,2);
						}
						else if($users->cmdt==5) {
							$cmdt = "BITUMEN VG-10";
							$avbtmvg10 = number_format($users->avgdta,2);
						}
						else if($users->cmdt==6) { 
							$cmdt = "CEMENT LINE";
							$avgcementLine = number_format($users->avgdta,2);
						}							
						else if($users->cmdt==7) {
							$cmdt = "CEMENT OPC";
							$avgcementopc = number_format($users->avgdta,2);
						}
						else if($users->cmdt==8) {	
							$cmdt = "STEELLMETALIC IRON";
							$avgsteel = number_format($users->avgdta,2);
						}
						else if($users->cmdt==9) {
							$cmdt = "STEEL LONG"; 
							$avglong = number_format($users->avgdta,2);
						}
						
						$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 = "";	
						
						$userPer +=(float)($users->perc);
							
					?> 
					<tr> 
					<th scope="row"><?php  echo $sr;?></th>
					<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 number_format($users->avgdta,2);?></td>
					<td><?php  echo $city->name;?></td>
					<td><?php  echo $users->source;?></td> 
					<td><?php  echo $users->csr;?></td>
					<td><?php  echo $users->perc;?>%</td>  
					<td> <a href="edit-addcomodity.php?id=<?php echo $users->id;?>&randNo=<?php echo $_REQUEST['randNo'];?>" target="_blank">Edit</a>/ <a href="javascript:void(0);" onclick="deleteDate(<?php echo $users->id;?>)"> Delete </a></td>  
					</tr>
					<?php  	$sr++;} ?> 
					 
					 
					<tr> 
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   </th>
					<th scope="row">   
						<?php
							if($userPer!=100) 
							{ 
						?> 
							<span style="color:red;"><?php echo $userPer;?>%</span> 
						<?php  }else { ?>
							<?php echo $userPer;?>%
						<?php  }  ?>  
					</th>
					  
					</tr>
					
					</tbody>
					</table>   
                  </div>  
				  
					<div class="row justify-content-center FormRegister">
						<div class="col-md-12 text-center">
						<a   class="btn btn-primary mb-2"  target="_blank" href="addRabill.php?randNo=<?php echo $rnd;?>&agency=<?php echo $_REQUEST['AgId'];?>"  >  Add  RA Bill </a>
						</div> 
					</div>

                </div>    
				
				
				<div class="container mt-35">
				
					<div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h5 class="card-title"> RA Bill Details</h5>     
                            </div>
					</div>
					
                    <div class="row  FormRegister">    
					<table class="table">
					<thead class="thead-light">
					<tr> 
					<th scope="col">Date Of Recroding</th>
					<th scope="col">RA Bill No & V.No</th>
					<th scope="col"> Date Of Payment</th>
					<th scope="col"> Amount Work Done in GB</th>
					<th scope="col"> Cost Of Bitimen Cement</th>
					<th scope="col"> Royalty </th>
					<th scope="col"> Clause 38 </th>
					<th scope="col"> Net Payment</th>
					<th scope="col">  85% of Work Done Amount</th> 
					<th scope="col">  Action </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;

					?> 
					<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> 
					<td>  <a href="editRa.php?id=<?php echo $users->id;?>&randNo=<?php echo $_REQUEST['randNo'];?>" target="_blank"> Edit </a> / <a href="javascript:void(0);" onclick="DeleteRa(<?php echo  $users->id;?>)">   Delete </a>  </td>   
					</tr>
					<?php  	$sr++;} ?> 
					 
					</tbody>
					</table>   
                  </div>  
				 

                </div>    
				
				
				<div class="container mt-35">
				
					<div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h5 class="card-title"> Consumption Details  </h5>     
                            </div>
					</div>
					
                    <div class="row  FormRegister"> 
					 
					
					<table class="table">
					<thead class="thead-light">
					<tr>
		 
					<th scope="col">RA Bill No</th>
					<th scope="col">Commodity</th>
					<th scope="col">Grade</th>
					<th scope="col">Quantity Per Unit</th>
					<th scope="col">Amount</th>
					<th scope="col">Action</th>
		 
					</tr>
					</thead>
					<tbody>
					    
					<?php    
					$stmt=$conn->prepare("select  * from    pw__comp 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)
					{ 		
					
						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 OPC";
						else if($users->commodity==8)	
							$cmdt = "STEELLMETALIC IRON";
						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 = "Steel TMT";
						else
							$grade = "";	
						
						 
				
					?> 
					<tr>  
					<td><?php echo $users->RaBillNO1;?></td>
					<td><?php echo $cmdt;?></td>
					<td><?php echo $grade;?></td>
					<td><?php echo $users->qtyperunit1."@".$users->qtyperunit2;?></td>
					<td><?php echo $users->qtyamt;?></td> 
					<td>    
							<a href="editComsuption.php?id=<?php echo $users->id;?>" target="_blank"> Edit </a>  
					</td> 
					</tr>
					<?php  	$sr++;} ?> 
					 
					</tbody>
					</table>   
                  </div>    
                </div>          
				
				<?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)
					  {    					
					
				?>
				<div class="container mt-35">  
					<div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h5 class="card-title"> 2nd page  RaBill No  <?php echo $abcd->RaBillNO;?> </h5>     
                            </div>
					</div> 
					
                    <div class="row  FormRegister">       
					<table class="table">
					<thead class="thead-light">  
					
					<tr> 
					<th scope="col">Month</th>
					<th scope="col">LABOUR</th>
					<th scope="col">MATERIAL</th>
					<th scope="col">POL </th>  
					</tr>
					</thead>
					
					<tbody>  
					
					<?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><?php echo $WorkOrder1;?></td>
					<td><?php echo $v1;?></td>
					<td><?php echo $v2;?></td>
					<td><?php echo $v3;?></td> 
					</tr>
					<?php 
							
							$WorkOrder1 = date('M-Y', strtotime($WorkOrder .'+'.$i.' months'));   
							$i++;  
							
					}while ($i<=($invtDts)); 
					?> 
					
					<tr>  
					<td>AVG</td>
					<td><?php echo number_format($avg1/($invtDts), 2);?></td>
					<td><?php echo number_format($avg2/($invtDts), 2);?></td>
					<td><?php echo number_format($avg3/($invtDts), 2);?></td> 
					</tr>
					
					
					 <tr>  
					<td>Diff of basic & Avg</td>
					<td><?php $avgdata1 = number_format((number_format($avg1/($invtDts), 2)-$avgLbr),2); echo  $avgdata1;?></td>
					<td><?php $avgdata2 = number_format((number_format($avg2/($invtDts), 2)-$avgmat),2); echo $avgdata2 ;?></td>
					<td><?php $avgdata3 =   number_format((number_format($avg3/($invtDts), 2)-$avpol),2); echo  $avgdata3 ;?></td> 
					</tr> 
					
					
					<tr>  
					<td>85% of work done </td>
					<td><?php echo $eightFive[$RaRecordKey];?></td>
					<td><?php echo $eightFive[$RaRecordKey];?></td>
					<td><?php echo $eightFive[$RaRecordKey];?></td>  
					</tr>  
					
					  
					<tr>  
					<td>Calculations  of Esclation Amont </td>
					<td>
					
					<?php 
					$l1 = number_format((($eightFive[$RaRecordKey])*($perLbr/100)),2); 
					$l1 =  str_replace(",","",$l1);	
					echo number_format((($l1*$avgdata1)/$avgLbr),2);  
					?>
					
					</td>
					 
					<td>
					<?php    
						$l2 = number_format((($eightFive[$RaRecordKey])*($permat/100)),2); 
						$l2 =  str_replace(",","",$l2);	
						echo number_format((($l2*$avgdata2)/$avgmat),2);  
						
					?>
					</td>
					
					<td> 
					<?php 
						$l3 = number_format((($eightFive[$RaRecordKey])*($perpol/100)),2); 
						$l3 =  str_replace(",","",$l3);	
						echo number_format((($l3*$avgdata3)/$avpol),2);  
					?>
					</td>

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

				  
                </div>      
				
				<?php 
						} 
					} 
				?>
				 
				
				<?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  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; 

						 
				?>
				<div class="container mt-35">  
					<div class="row justify-content-center FormRegister">
                            <div class="col-12 p-3 text-center"> 
                                    <h5 class="card-title"> 3rd page    <?php echo $abcd->RaBillNO;?> </h5>     
                            </div>
					</div> 
					
                    <div class="row  FormRegister">       
					<table class="table">
					<thead class="thead-light">  
					
					<tr> 
					<th scope="col">Month</th>
					<th scope="col"><?php if(in_array(4, $people)) { $bt1=4;  echo "BITUMEN VG-30";} ?></th>
					<th scope="col"><?php if(in_array(5, $people)) { $bt1=5; echo "BITUMEN VG-10"; } ?></th>
					<th scope="col"><?php if(in_array(6, $people)) { $bt2=6;  echo "CEMENT LINE"; } ?></th>
					<th scope="col"><?php if(in_array(7, $people)) { $bt2=7;   echo "CEMENT OPC"; } ?></th>
					<th scope="col"><?php if(in_array(8, $people)) { $bt3=8;  echo "STEELLMETALIC IRON"; } ?></th>
					<th scope="col"><?php if(in_array(9, $people)) { $bt3=9; echo "STEEL LONG"; } ?></th> 
					</tr>
					</thead>
					
					<tbody>  
					
					<?php    
					$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><?php echo $WorkOrder1;?></td>
						<?php 
							if($bt1!=0) 
							{ 
						?>
					<td><?php echo $v1;?></td> 
					<?php } ?>
						<?php 
						if($bt2!=0) 
						{ 
					?>
					<td><?php echo $v2;?></td> 	
					<?php } ?>
						<?php 
						if($bt3!=0) { 
					?>
					<td><?php echo $v3;?></td> 
					<?php } ?> 
					</tr>
					<?php 
							
							$WorkOrder1 = date('M-Y', strtotime($WorkOrder .'+'.$i.' months'));   
							$i++;  
							
					}while ($i<=($invtDts)); 
					?> 
					
					<tr>  
					<td>AVG</td>
					<?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;		
						  
						  
						if( ($bt1!=0) && ($manSet==1)) 
						{   
							$avgn  = 0;
							foreach($indices1 as $axn)
								$avgn +=$axn;  
							
							
							$firstAvg =  $avgn/count($indices1);//($invtDts);//number_format($avg1/($invtDts), 2)
					?>	 
					<td>
							<?php echo number_format($firstAvg, 2);  
								$indices1 = null;
							?>
					</td>
					<?php  
						} else {
					?>
						<td> </td>
					<?php  	
						}
							
						if( ($bt2!=0) && ($manSet2==1)) 
						{   
							
							$avgm  = 0;
							foreach($indices2 as $axn)
								$avgm +=$axn;  
						 	 
							  
							$srcondAvg =  $avgm/count($indices2);//($invtDts);//number_format($avg1/($invtDts), 2)  
					?>
					<td>
							<?php 
								echo number_format($srcondAvg, 2);  
								$indices2 = null;
							?>
					</td>
						<?php } else {
					?>
						<td> </td>
					<?php  	
						}	
						if( ($bt3!=0) && ($manSet3==1)) 
						{
							$avgx  = 0;
							foreach($indices3 as $axn)
								$avgx +=$axn;  
							
							$thirdAvg =  $avgx/count($indices3);//($invtDts);//number_format($avg1/($invtDts), 2)   
					?>	
					<td>
						<?php 
								echo number_format($thirdAvg, 2);  
								$indices3 = null;
							?>
					</td> 
						<?php } else {
					?>
						<td> </td>
					<?php  	
						}	
					?>
					</tr>  
					 
					<tr>  
					<td>Comsumption Quantity</td>
					<?php    
						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><?php  echo $dateOfra1->qtyperunit1;?></td>
					<?php } else {  ?>
					<td> </td>
					<?php }  
						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><?php  echo $dateOfra2->qtyperunit1;?></td>
					<?php } else {
					?>
						<td> </td>
					<?php  	
						}	
						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><?php  echo $dateOfra3->qtyperunit1;?></td>
					<?php } else {
					?>
						<td> </td>
					<?php  	
						}	
					?>
					</tr>   
					
					 
					 
					<tr>  
					<td>Basic or CSR Index</td>
					<?php 
						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><?php    
								if($pw__comdtdataData['avgdta']>$firstCsr) 
								{ 	$higer = $pw__comdtdataData['avgdta'];;
									echo  $pw__comdtdataData['avgdta'];
								}
								else  {
									echo  $firstCsr;
										$higer = $firstCsr;
								}
						?></td>
					<?php  } else {  ?>
					<td> </td>
					<?php } 
						 
						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><?php  echo $pw__comdtdataData['csr'] ;?></td>
					<?php } else {  ?>
					<td> </td>
					<?php } 
						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><?php  echo $pw__comdtdataData['csr'] ;?></td>
					<?php } else {  ?>
					<td> </td>
					<?php } 
					?>
					</tr>    
					
					<tr>  
					<td>Diff of basic & Avg</td> 
					<?php 
						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><?php 
								$idiif1 = ($firstAvg-$higer);
						echo    number_format((($firstAvg-$higer)),2);
					?></td>
					<?php  } else {  ?>
					<td> </td>
					<?php } 
					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><?php 
					
								$idiif2 = number_format((($srcondAvg-$pw__comdtdataData->avgdta)),2);
						echo   number_format((($srcondAvg-$pw__comdtdataData->avgdta)),2); 
					?></td>
					 
					<?php } else {  ?>
					<td> </td>
					<?php } 
						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><?php 
								$idiif3 = number_format((($thirdAvg-$pw__comdtdataData->avgdta)),2);
						echo   number_format((($thirdAvg-$pw__comdtdataData->avgdta)),2); 
					?></td>
					<?php } else {  ?>
					<td> </td>
					<?php } ?>
					</tr>  


					 
					<tr>   
					<td>Calculations  of Esclation Amont </td>
					<?php 
						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><?php  echo  number_format(($dateOfra1->qtyperunit1*$idiif1),2); ?> </td>
					<?php  } else {  ?>
					<td> </td>
					<?php } 
						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><?php  echo    number_format((($secondCsr * (($idiif2)/$pw__comdtdataData->avgdta))*$dateOfra2->qtyperunit1),2);
					 
					?></td>
					 
					<?php }  else {  ?>
					<td> </td>
					<?php } 
						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>
						<?php  echo  number_format((($thirdCsr * (($idiif3)/$pw__comdtdataData->avgdta))*$dateOfra3->qtyperunit1),2);		?>
					</td>
					<?php }  else {  ?>
					<td> </td>
					<?php } ?>
					</tr>        
					</tbody>
					</table>   
                  </div>

				  
                </div>      
				
				<?php 
						} 
					} 
				?>
				 
       
<?php 
unset($_SESSION['tenderSdd']);
include_once("header-footer/footer.php");

?> 