<?php 	include_once('../../config.php'); 
		 

			if(isset($_POST['submit']))
			{   
				$newDate = date("d-M-Y", strtotime($_POST['dateselect'])); 
				$stmt=$conn->prepare("update pw__exclationtbl1 set priority=:priority,commodity=:commodity ,dateselect=:dateselect ,center=:center ,indexval=:indexval where  id=:id"); 
                $stmt->bindValue(':priority',$_POST['priority'], PDO::PARAM_STR); 
                $stmt->bindValue(':commodity',$_POST['commodity'], PDO::PARAM_STR); 
                $stmt->bindValue(':dateselect', $newDate, PDO::PARAM_STR); 
                $stmt->bindValue(':center', $_POST['center'], PDO::PARAM_STR);  
                $stmt->bindValue(':indexval', $_POST['index'], PDO::PARAM_STR);  
                 
                $stmt->bindValue(':id', $_REQUEST['id'], PDO::PARAM_STR);  
                $stmt->execute();    
				header("Location: labor.php ");  
				die;
			}   
			

		$stmt=$conn->prepare("select  * from    pw__exclationtbl1 where id=:id ");
		$stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR); 			
		$stmt->execute(); 
		$AllUCity = $stmt->fetch(PDO::FETCH_OBJ);
		 
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  


 <script>
	$(function() 
	{
		 
		
		  $( "#dateselect" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: "1930:2050"
			});
			
	}); 
  
	$(document).ready(function()
	{   

	
	$("#product_frm").validate({
		
		errorElement:'div',
		rules:{ 
			city:{
				required:true				 
			} 
			
			
			
		},
		messages:{				
			 
			 city:{
				required:"Enter city name"				 
			} 
		}
	});


	});
 


</script>
		 
		 <div class="col-md-10">

	  			<div class="row">
	  				<div class="col-md-12">
	  					<div class="content-box-large">
							<div class="panel-heading">
								<div class="panel-title"> <h3> Add New Record </h3></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='labor.php';" />
								  
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm" autocomplete="off">    
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Commodity</label>
								    <div class="col-sm-3">
								       
									  <select  class="form-control" name="commodity"  >
									  <option value="">Select </option>
									  <option value="1" <?php if($AllUCity->commodity=='1') echo "selected";?> >LABOUR</option>
									  <option value="2"  <?php if($AllUCity->commodity=='2') echo "selected";?> >MATERIAL</option>
									  <option value="3"  <?php if($AllUCity->commodity=='3') echo "selected";?> >POL</option>
									  <option value="4" <?php if($AllUCity->commodity=='4') echo "selected";?>>BITUMEN</option> 
									  <option value="5" <?php if($AllUCity->commodity=='5') echo "selected";?>>Cement Lime</option> 
									  <option value="6" <?php if($AllUCity->commodity=='6') echo "selected";?>>Cement OPC</option>  
									  <option value="7" <?php if($AllUCity->commodity=='7') echo "selected";?>>Steel. Long</option>  
									  <option value="8" <?php if($AllUCity->commodity=='8') echo "selected";?>>STEEL. Metallic Iron</option>  
									  </select>
									  
								    </div>
								 </div>
								 <hr>
								 
								 	 
								  <!--div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Source</label>
								    <div class="col-sm-3" > 
									  <select  class="form-control"  name="source">
									  <option value="">Select</option>
									  <option value="1" <?php if($AllUCity->source=='1') echo "selected";?>>GOVT</option>
									  <option value="2" <?php if($AllUCity->source=='2') echo "selected";?>>RBI</option> 
									  <option value="3" <?php if($AllUCity->source=='3') echo "selected";?>>Xrefinery</option> 
									  </select>
									  </select>
								    </div>
								 </div>
								 <hr-->
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Date</label>
								    <div class="col-sm-3" name="year"> 
									  <input name="dateselect" id="dateselect" class="form-control"   value="<?php echo $AllUCity->dateselect; ?>" placeholder="Date"   required>
								    </div>
								 </div>
								 <hr>
								  
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Center</label>
								    <div class="col-sm-3">
								       
								    <select  class="form-control" name="center"  >
								    <option value="">Select</option> 
									<?php    
										$stmt=$conn->prepare("select  * from    pw__cities order by name ");  
										$stmt->execute(); 
										$AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
										$sr = 1; 

										foreach($AllUsers as $users)
										{  
									?> 
										<option value="<?php echo $users->id;?>" <?php if($AllUCity->center==$users->id) echo "selected";?> ><?php echo $users->name;?></option>
									<?php } ?> 
									</select>
									  
								    </div>
								 </div>
								 <hr>
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Index</label>
								    <div class="col-sm-3">
								      <input name="index" class="form-control"   placeholder="Index"  value="<?php echo $AllUCity->indexval; ?>"   required>
								    </div>
								 </div>
								 <hr>
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Priority</label>
								    <div class="col-sm-3">
								      <input name="priority" class="form-control"   placeholder="priority"  value="<?php echo $AllUCity->priority; ?>"   required>
								    </div>
								 </div>
								 <hr>
							
								   
								  
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Add User</label>
										<div class="col-sm-10">
										  <input type="submit"    class="btn btn-primary"  name="submit" value="update Record">
										</div>
								  </div>   
								</form>
								
								
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


	  		<!--  Page content -->
		  </div>
		</div>
    </div>

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