<?php
  $page_title = 'Editar Programacion';
  require_once('../../includes/load.php');
  // Checkin What level user has permission to view this page
  page_require_level(5);
?>
<?php
  $programa = find_by_id('programa',(int)$_GET['id']);
  if(!$programa){
  $session->msg("d","Error: No se encontró id del programa.");
  redirect('programa.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 Programa</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>Programa</span>
                  </strong> 
                </div>
                 <div class="card-body">
                 	<div class="form-group">
		                <div class="row">
		                  	<div class="col-md-2">
		                      <label for="programa" class="control-label">Programa:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" name="programa" id="programa" class="form-control" value="<?php echo (int)$programa['id'];?>" readonly>		                                                                        
		                      </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="destino" class="control-label">Destino:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="destino" name="destino" class="form-control">
		                                <option value="Mercado" <?php if ($programa['TipoGranja']=='Mercado'){echo 'selected';} ?>>Mercado</option>
					                          <option value="Camal" <?php if ($programa['TipoGranja']=='Camal'){echo 'selected';} ?>>Camal</option>
		                              </select>                                            
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ult_venta" class="control-label">Ultima Venta:</label>
		                      <div class="input-group">   
		                              <input type="date" id="ult_venta" name="ult_venta" class="form-control" value="<?php echo remove_junk($programa['ProFechaUltimaVenta']); ?>" required>                           
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ter_recepcion" class="control-label">Termino de Recepción:</label>
		                      <div class="input-group">   
		                              <input type="date" id="ter_recepcion" name="ter_recepcion" class="form-control" value="<?php echo remove_junk($programa['ProFechaTerminoRecepcion']); ?>">                           
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ter_limpieza" class="control-label">Termino Limpieza:</label>
		                      <div class="input-group">   
		                              <input type="date" id="ter_limpieza" name="ter_limpieza" class="form-control" value="<?php echo remove_junk($programa['ProFechaTerminoLimpiezaInicial']); ?>">                           
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="red_dragon" class="control-label">Red Dragon:</label>
		                      <div class="input-group">   
		                              <input type="date" id="red_dragon" name="red_dragon" class="form-control" value="<?php echo remove_junk($programa['ProFechaRedDragon']); ?>">                           
		                        </div>               
		                    </div>
		                </div>
		               </div>
		              <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-2">
		                      <label for="area" class="control-label">Area:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="area" name="area" class="form-control">
		                                <?php
																	        $consulta = $db->query("SELECT * FROM areagerenciaoperaciones");
																	        $idPro =$programa['IdAreaGerenciaOperaciones'];
																	        while ($area = $db->fetch_array($consulta)) {
																	        $def='';
																	        if($area['IdAreaGerenciaOperaciones']==$idPro){
																	            $def='selected';
																	        }
																	   ?>
																				    <option value="<?php echo $area['IdAreaGerenciaOperaciones']?>" <?php echo $def?> ><?php echo $area['CodigoGO'] ?></option>
																				    <?php
																	        }
																	   ?>
		                              </select> 		                                                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="servicio" class="control-label">Servicio:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="servicio" name="servicio" class="form-control">
																		<?php
																	        $consulta = $db->query("SELECT * FROM tiposervicio");
																	        $idPro =$programa['IdTipoServicio'];
																	        while ($area = $db->fetch_array($consulta)) {
																	        $def='';
																	        if($area['IdTipoServicio']==$idPro){
																	            $def='selected';
																	        }
																	   ?>
																				    <option value="<?php echo $area['IdTipoServicio']?>" <?php echo $def?> ><?php echo $area['TSNombre'] ?></option>
																				    <?php
																	        }
																	   ?>
		                              </select>                                            
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ini_limpieza" class="control-label">Inicio de Limpieza:</label>
		                      <div class="input-group">  
		                              <input type="date" id="ini_limpieza" name="ini_limpieza" class="form-control" value="<?php echo remove_junk($programa['ProFechaInicioLimpieza']); ?>" required>                            
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ini_compost" class="control-label">Inicio Compost:</label>
		                      <div class="input-group">  
		                              <input type="date" id="ini_compost" name="ini_compost" class="form-control" value="<?php echo remove_junk($programa['ProFechaInicioCompost']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ini_tumbado" class="control-label">Inicio Tumbado:</label>
		                      <div class="input-group">  
		                              <input type="date" id="ini_tumbado" name="ini_tumbado" class="form-control" value="<?php echo remove_junk($programa['ProFechaInicioTumbadoCompost']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ent_granja" class="control-label">Entrega Granja:</label>
		                      <div class="input-group">  
		                              <input type="date" id="ent_granja" name="ent_granja" class="form-control" value="<?php echo remove_junk($programa['ProFechaEntregaGranja']); ?>">                            
		                        </div>               
		                    </div>		                    
		                </div>
		               </div>

		               <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-2">
		                      <label for="campana" class="control-label">Campaña:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="campana" name="campana" class="form-control">
		                               <option value="1" <?php if ($programa['Campana']=='1'){echo 'selected';} ?>>1</option>
					                         <option value="2" <?php if ($programa['Campana']=='2'){echo 'selected';} ?>>2</option>
					                         <option value="3" <?php if ($programa['Campana']=='3'){echo 'selected';} ?>>3</option>
					                         <option value="4" <?php if ($programa['Campana']=='4'){echo 'selected';} ?>>4</option>
					                         <option value="5" <?php if ($programa['Campana']=='5'){echo 'selected';} ?>>5</option>
					                         <option value="6" <?php if ($programa['Campana']=='6'){echo 'selected';} ?>>6</option>
					                         <option value="7" <?php if ($programa['Campana']=='7'){echo 'selected';} ?>>7</option>
		                              </select>                                             
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="responsable" class="control-label">Responsable:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="responsable" name="responsable" class="form-control" value="<?php echo $user['name'];?>" readonly>                                         
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ini_recepcion" class="control-label">Inicio de Recepción:</label>
		                      <div class="input-group">   
		                              <input type="date" id="ini_recepcion" name="ini_recepcion" class="form-control" value="<?php echo remove_junk($programa['ProFechaInicioRecepcion']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ter_compost" class="control-label">Termino Compost:</label>
		                      <div class="input-group">   
		                              <input type="date" id="ter_compost" name="ter_compost" class="form-control" value="<?php echo remove_junk($programa['ProFechaTerminoCompost']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="ter_tumbado" class="control-label">Termino Tumbado:</label>
		                      <div class="input-group">   
		                              <input type="date" id="ter_tumbado" name="ter_tumbado" class="form-control" value="<?php echo remove_junk($programa['ProFechaTerminoTumbadoCompost']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-2">
		                      <label for="pollo" class="control-label">Pollo BB:</label>
		                      <div class="input-group">   
		                              <input type="date" id="pollo" name="pollo" class="form-control" value="<?php echo remove_junk($programa['ProFechaIngresoPollosBB']); ?>">                                            
		                        </div>
		                    </div>		                    
		                </div>
		              </div>


		              <div class="form-group">
		                <div class="row">
		                  	<div class="col-md-2">
		                      <label for="granja" class="control-label">Granja:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="granja" name="granja" class="form-control">
																		<?php
																	        $consulta = $db->query("SELECT * FROM granja");
																	        $idPro =$programa['IdGranja'];
																	        while ($area = $db->fetch_array($consulta)) {
																	        $def='';
																	        if($area['IdGranja']==$idPro){
																	            $def='selected';
																	        }
																	   ?>
																				    <option value="<?php echo $area['IdGranja']?>" <?php echo $def?> ><?php echo $area['GNombre'] ?></option>
																				    <?php
																	        }
																	   ?>
		                              </select> 
		                                                                        
		                        </div>               
		                    </div>
		                </div>
		              </div>
			               <div class="text-center">
	                     		 <button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-floppy-disk"></i>Actualizar</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_programa.js"></script>


