<?php
  $page_title = 'Editar Actividad';
  require_once('../../includes/load.php');
  // Checkin What level user has permission to view this page
  page_require_level(5);
?>
<?php
  $actividad = find_by_id('detalleoperacion',(int)$_GET['id']);
  if(!$actividad){
  $session->msg("d","Error: No se encontró id del actividad.");
  redirect('actividad.php');
}
?>
<?php include_once('../../layouts/header.php'); ?>
<div class="row">
  <div class="col-md-12">
    <?php echo display_msg($msg); ?>
  </div>
</div>
  <div class="row">
  <div class="col-md-16">
      <div class="panel panel-default">
        <div class="panel-heading">
          <strong>
            <span class="glyphicon glyphicon-edit"></span>
            <span>Editar Actividad</span>
         </strong>
        </div> 
 <!-- FORMULARIO PARA GUARDAR EL PROGRAMA-->
       <form  enctype="multipart/form-data" autocomplete="off" id="form" onSubmit="Edit()">
          <div class="panel-body">
            <div class="col-md-12">
        		<div class="card-header">
                  <strong>
                     <span>Actividad</span>
                  </strong> 
                </div>

                 <div class="card-body">
		              <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-3">
		                      <label for="detalle" class="control-label">Id Actividad:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" name="detalle" id="detalle" class="form-control" value="<?php echo (int)$actividad['id'];?>" readonly>
		                                                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="actividad" class="control-label">Actividad:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>       
		                              <select id="actividad" name="actividad" class="form-control">
		                                <?php
																		        $consulta = $db->query("SELECT * FROM actividad");
																		        $idActivi =$actividad['IdActividad'];
																		        while ($actividadA = $db->fetch_array($consulta)) {
																		        $def='';
																		        if($actividadA['IdActividad']==$idActivi){
																		            $def='selected';
																		        }
																		?>
																			    <option value="<?php echo $actividadA['IdActividad']?>" <?php echo $def?> ><?php echo $actividadA['ANombre'] ?></option>
																		<?php
																		        }
																		?>
		                              </select>                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="he_operario" class="control-label">H.e. Operario:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="he_operario" name="he_operario" class="form-control" value="<?php echo remove_junk($actividad['HorasExtras']); ?>">                           
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="cant_tractor" class="control-label">Cantidad Tractor:</label>
		                      <div class="input-group">  
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span> 
		                              <input type="text" id="cant_tractor" name="cant_tractor" class="form-control" value="<?php echo remove_junk($actividad['CantidadTractor']); ?>">                           
		                        </div>               
		                    </div>
		                </div>
		               </div>

		               <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-3">
		                      <label for="supervisor" class="control-label">Supervisor:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="supervisor" name="supervisor" class="form-control">
		                                <?php
																		        $consulta = $db->query("SELECT * FROM supervisor");
																		        $idSupervisor =$actividad['IdSupervisor'];
																		        while ($Supervidor = $db->fetch_array($consulta)) {
																		        $def='';
																		        if($Supervidor['IdSupervisor']==$idSupervisor){
																		            $def='selected';
																		        }
																		?>
																			    <option value="<?php echo $Supervidor['IdSupervisor']?>" <?php echo $def?> ><?php echo $Supervidor['SNombre'] ?></option>
																		<?php
																		        }
																		?>
		                              </select>   
		                                                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="fecha" class="control-label">Fecha:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="date" id="fecha" name="fecha" class="form-control" required value="<?php echo remove_junk($actividad['FechaActividad']); ?>">                                            
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="tractorista" class="control-label">Tractorista:</label>
		                      <div class="input-group">  
		                      	<span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>
		                              <input type="text" id="tractorista" name="tractorista" class="form-control" value="<?php echo remove_junk($actividad['JornalTractorista']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="h_maquinas" class="control-label">Horas Maquinas:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span> 
		                              <input type="text" id="h_maquinas" name="h_maquinas" class="form-control" value="<?php echo remove_junk($actividad['HorasMaquina']); ?>">                            
		                        </div>               
		                    </div>
		                </div>
		              </div>


		              <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-3">
		                      <label for="grupo" class="control-label">Grupo:</label>
		                      <div class="input-group">   
		                              <select id="grupo" name="grupo" class="form-control">
		                                <?php
																		        $consulta = $db->query("SELECT * FROM grupo");
																		        $idGrupo =$actividad['IdGrupo'];
																		        while ($Grupo = $db->fetch_array($consulta)) {
																		        $def='';
																		        if($Grupo['IdGrupo']==$idGrupo){
																		            $def='selected';
																		        }
																		?>
																			    <option value="<?php echo $Grupo['IdGrupo']?>" <?php echo $def?> ><?php echo $Grupo['GNombre'] ?></option>
																		<?php
																		        }
																		?>
		                              </select>                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="operario" class="control-label">Operario:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                             <input type="text" id="operario" name="operario" class="form-control" value="<?php echo remove_junk($actividad['Jornal']); ?>">                                         
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="he_tractorista" class="control-label">H.e. Tractorista:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="he_tractorista" name="he_tractorista" class="form-control" value="<?php echo remove_junk($actividad['HorasExtrasTractorista']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="he_maquina" class="control-label">H.e. Maquina:</label>
		                      <div class="input-group">
		                         <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="he_maquina" name="he_maquina" class="form-control" value="<?php echo remove_junk($actividad['HorasExtrasMaquina']); ?>">                        
		                        </div>               
		                    </div>
		                </div>
		              </div>
		              <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-12">
		                      <label for="observacion" class="control-label">Observaciones:</label>
		                      <div class="input-group">   
		                              <input type="text" id="observacion" name="observacion" class="form-control" value="<?php echo remove_junk($actividad['ObservacionDetalleOperacion']); ?>">                                            
		                        </div>               
		                    </div>
		                </div>
		              </div>
			               <div class="text-center">
	                     		 <button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-floppy-disk"></i>Guardar</button>
	                       </div>
          			  </div>
	          	    </div>
	             </div>
	           </div>   
            </div>
          </div>           
        </form>
     </div>
    </div>
  </div>
</div>
</div>

<?php include_once('../../layouts/footer.php'); ?>
<script type="text/javascript" src="js/edit_actividad.js"></script>



