<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  

<script>

$(function() {
		$( "#dateselect" ).datepicker(); 
});
	
function del_record(val)
{

	var r = confirm("Do you really want to delete record !");
	if (r == true) {    
	$.ajax({
	type: 'POST',
	url: "../ajax/default.php",
	//async: false,			 
	data: {dellabor:1,val:val},	  
	success: function(ajaxresult){	     
		location.reload();	 	
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) { 
	alert('Error');
	}
	});
	
	}	
	
}

</script>
		 
		<div class="col-md-10">  
  			<div class="content-box-large">
  				<div class="panel-heading">
					<div class="panel-title"><h3>Escalation List </h3></div>
					
					
					 
					 
					 
					
					
					<div align="left"> 
					 <form method="post" autocomplete="off">
					<div class="col-sm-2">
						<select  class="form-control" name="commodity"  >
									<option value="">Select </option>
									  <option value="1">LABOUR</option>
									  <option value="2">MATERIAL</option>
									  <option value="3">POL</option> 
									  <option value="4">BITUMEN VG-30</option>  
									  <option value="5">BITUMEN VG-10</option>  
									  <option value="6">CEMENT LINE </option> 
									  <option value="7">CEMENT OPC</option>  
									  <option value="8">STEELLMETALIC IRON</option>  
									  <option value="9">STEEL LONG</option>     
					  </select>
					</div>
					
					<div class="col-sm-2">
						 <select class="form-control" name="source">
						   <option value="">Select Source 	 </option>
						  <option value="1">GOVT</option>
						  <option value="2">RBI</option> 
						  <option value="3">Xrefinery</option> 
						 </select>   
					</div>
					
					<div class="col-sm-2">
						<input name="dateselect" id="dateselect" class="form-control"   placeholder="Date"  > 
					</div>
					
					 
					<input   class="btn btn-warning"  type="submit" value="Apply" name="filterSub"/>
					
					</form>
						
					</div>
					
					<div align="right"> 
					<input type="button"    class="btn btn-warning" name="btnback" id="btnback" value=" Add Record " onClick="javascript:location.href='addLabor.php';" />
					<input type="button"    class="btn btn-warning" name="btnback" id="btnback" value=" Reset " onClick="javascript:location.href='labor.php';" />
					</div>
					
					
					
				</div>
				
  				<div class="panel-body">
  					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
								<th>Sr</th>
								<th>Commodity</th>   
								<th>Source</th> 
								<th>Date</th>  
								<th>Center</th>  
								<th>Index</th> 
								<th>Priority</th> 
								<th>Action</th> 
							</tr>
						</thead>
						<tbody>
							<?php
									$a = 1;
									if(isset($_POST['filterSub']))
									{   
								
										 
										$dateselect = date("d-M-Y", strtotime($_POST['dateselect'])); 
										
										if($_POST['commodity']!='') 
											$a = "commodity=".$_POST['commodity'];
										
										if($_POST['source']!='')  {
											$a .= " and source=".$_POST['source']; 
											 
										}
										
										if($_POST['dateselect']!='') 
											$a .= " and dateselect='".$dateselect."'";    
										
									}
                                    $stmt=$conn->prepare("select  * from    pw__exclationtbl1 where $a  order  by priority , id  ");  
                                    $stmt->execute(); 
                                    $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                    $sr = 1; 
                                   
								    
									  foreach($AllUsers as $users)
								     {  
								   ?>
									   
									   
									 <tr class="odd gradeX">
								<td><?php echo $sr++; ?> </td>
								<td>
									<?php 
										if($users->commodity==1) 
										echo "LABOUR"; 
										else  if($users->commodity==2) 
										echo "MATERIAL"; 
										else  if($users->commodity==3) 
										echo "POL"; 
										else  if($users->commodity==4) 
										echo "BITUMEN VG-30"; 
										else  if($users->commodity==5) 
										echo "BITUMEN VG-10"; 
										else  if($users->commodity==6) 
										echo "CEMENT LINE"; 
										else  if($users->commodity==7) 
										echo "CEMENT OPC"; 
										else  if($users->commodity==8) 
										echo "STEELLMETALIC IRON";  
										else  if($users->commodity==9) 
										echo "STEEL LONG";  
									?>
								</td>
								<td><?php if($users->source==1) echo "Govt"; else if($users->source==2)  echo "RBI"; else echo "Xrefinery";?> </td> 
								<td><?php echo $users->dateselect;?>  </td>  
								<td>
									<?php 
										$stmt=$conn->prepare("select  * from    pw__cities where id=:id ");
										$stmt->bindValue(':id',$users->center, PDO::PARAM_STR); 			
										$stmt->execute(); 
										$AllUCity = $stmt->fetch(PDO::FETCH_OBJ);  
										echo $AllUCity->name;
									?>   
								</td>   
								<td><?php echo $users->indexval;?>  </td>    
								<td><?php echo $users->priority;?>  </td>    
								<td><a href="edit-labor.php?id=<?php echo $users->id;?>">  Edit </a>/<a href="javascript:void(0);" onclick="del_record(<?php echo $users->id;?>)">  Delete </a></td> 
							</tr>    
									   
									   
								 <?php 
								     
							    }
							?>
						</tbody>
					</table>
  				</div>
  			</div>



		  </div>
		</div>
    </div>

<?php  include ABS_PATH.'/admin/footer.php';	?>    