<?php
  $page_title = 'Editar Implemento';
  require_once('../../includes/load.php');
  // Checkin What level user has permission to view this page
  page_require_level(4);
?>
<?php
  $implemento = find_by_id('implemento',(int)$_GET['id']);
  if(!$implemento){
  $session->msg("d","Error: No se encontró id del implemento.");
  redirect('listado_implemento.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</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> Implemento</span>
                  </strong> 
                </div>
                 <div class="card-body">
		              <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="implemento" class="control-label">IdImplemento:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input class="form-control" id="implemento" name="implemento" value="<?php echo (int)$implemento['id'];?>" readonly>                                            
		                      </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="placa" class="control-label">Placa:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="placa" name="placa" class="form-control" value="<?php echo remove_junk($implemento['PlacaImplemento']); ?>">                                                                      
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="anio_produccion" class="control-label">A.Produccion:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="anio_produccion" name="anio_produccion" class="form-control" value="<?php echo remove_junk($implemento['AñoProduccionImplemento']); ?>">                                      
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <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($implemento['ObservacionesImplemento']); ?>">                             
		                        </div>               
		                    </div>	     
		                </div>
		               </div>

		               <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="propietario" class="control-label">Propietario:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <select id="propietario" name="propietario" class="form-control">
		                                <?php
																	        $consulta = $db->query("SELECT * FROM cliente");
																	        $idCli =$implemento['IdCliente'];
																	        while ($cliente = $db->fetch_array($consulta)) {
																	        $def='';
																	        if($cliente['IdCliente']==$idCli){
																	            $def='selected';
																	        }
																	   ?>
																				    <option value="<?php echo $cliente['IdCliente']?>" <?php echo $def?> ><?php echo $cliente['RazonSocial'] ?></option>
																				    <?php
																	        }
																	   ?>
		                              </select>   
		                                                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="color" class="control-label">Color:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>   
		                              <input type="text" id="color" name="color" class="form-control" value="<?php echo remove_junk($implemento['ColorImplemento']); ?>">                                      
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="anio_compra" class="control-label">A.Compra:</label>
		                      <div class="input-group">   
		                              <input type="text" id="anio_compra" name="anio_compra" class="form-control" value="<?php echo remove_junk($implemento['AñoCompraImplemento']); ?>">                              
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="costo" class="control-label">Costo x Hr:</label>
		                      <div class="input-group">   
		                              <input type="text" id="costo" name="costo" class="form-control" value="<?php echo remove_junk($implemento['CostoHoraImplemento']); ?>">                             
		                        </div>               
		                    </div>                 
		                </div>
		              </div>


		              <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="nombre" class="control-label">Nombre:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input class="form-control" id="nombre" name="nombre" value="<?php echo remove_junk($implemento['NombreImplemento']); ?>">                                            
		                      </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="dim_llanta" class="control-label">D.Llanta:</label>
		                      <div class="input-group">   
		                              <input type="text" id="dim_llanta" name="dim_llanta" class="form-control" value="<?php echo remove_junk($implemento['DimencionLlantaImplemento']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="pre_compra" class="control-label">Precio:</label>
		                      <div class="input-group">  
		                              <input type="text" id="pre_compra" name="pre_compra" class="form-control" value="<?php echo remove_junk($implemento['PrecioCompraImplemento']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="estado" class="control-label">Estado:</label>
		                      <div class="input-group">   
		                              <select id="estado" name="estado" class="form-control">
		                               <option value="Operativo" <?php if ($implemento['EstadoActivoMI']=='Operativo'){echo 'selected';} ?>>Operativo</option>
					                         <option value="Inoperativo" <?php if ($implemento['EstadoActivoMI']=='Inoperativo'){echo 'selected';} ?>>Inoperativo</option>
					                         <option value="Baja" <?php if ($implemento['EstadoActivoMI']=='Baja'){echo 'selected';} ?>>Baja</option>
		                              </select>                           
		                        </div>               
		                    </div>		                    
		                </div>
		              </div>
              
		              <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="cod_patrimonial" class="control-label">Patrimonial:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="cod_patrimonial" name="cod_patrimonial" class="form-control" value="<?php echo remove_junk($implemento['CodigoPatrimonialImplemento']); ?>">                                           
		                      </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="peso" class="control-label">Peso:</label>
		                      <div class="input-group">  
		                              <input type="text" id="peso" name="peso" class="form-control" value="<?php echo remove_junk($implemento['PesoImplemento']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="combustible" class="control-label">Combustible:</label>
		                      <div class="input-group">   
		                              <select id="combustible" name="combustible" class="form-control">
		                                <?php
																	        $consulta = $db->query("SELECT * FROM combustible");
																	        $idCom =$implemento['IdCombustible'];
																	        while ($Combustible = $db->fetch_array($consulta)) {
																	        $def='';
																	        if($Combustible['IdCombustible']==$idCom){
																	            $def='selected';
																	        }
																	   ?>
																				    <option value="<?php echo $Combustible['IdCombustible']?>" <?php echo $def?> ><?php echo $Combustible['NombreCombustible'] ?></option>
																				    <?php
																	        }
																	   ?>
		                              </select>                             
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="compra" class="control-label">Compra:</label>
		                      <div class="input-group">  
		                              <input type="date" id="compra" name="compra" class="form-control" value="<?php echo remove_junk($implemento['FechaCompraImplemento']); ?>" required>                            
		                        </div>               
		                    </div>         	                   
		                </div>
		               </div>

		               <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="marca" class="control-label">Marca:</label>
		                      <div class="input-group">   
		                              <input class="form-control" id="marca" name="marca" value="<?php echo remove_junk($implemento['MarcaImplemento']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="tamaño" class="control-label">Tamaño:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="tamaño" name="tamaño" class="form-control" value="<?php echo remove_junk($implemento['TamañoImplemento']); ?>"> 	                                                                        
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <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>   
		                              <select id="responsable" name="responsable" class="form-control">
		                                <?php
									        $consulta = $db->query("SELECT * FROM responsableActivo");
									        $idResposable =$implemento['IdResponsableActivo'];
									        while ($Responsable = $db->fetch_array($consulta)) {
									        $def='';
									        if($Responsable['id']==$idResposable){
									            $def='selected';
									        }
									    ?>
												    <option value="<?php echo $Responsable['id']?>" <?php echo $def?> ><?php echo $Responsable['NombreResponsableActivo'].' '.$Responsable['ApellidoResponsableActivo'] ?></option>
												    <?php
									        }
									    ?>
		                              </select>                                     
		                        </div>               
		                    </div>
		                    
		                    <div class="col-md-3">
		                      <label for="capacidad" class="control-label">Capacidad:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="capacidad" name="capacidad" class="form-control" value="<?php echo remove_junk($implemento['CapacidadImplemento']); ?>">	                                                                        
		                        </div>               
		                    </div>
		                </div>
		              </div>

		              <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="modelo" class="control-label">Modelo:</label>
		                      <div class="input-group">   
		                              <input class="form-control" id="modelo" name="modelo" value="<?php echo remove_junk($implemento['ModeloImplemento']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="accesorio" class="control-label">Accesorios:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="accesorio" name="accesorio" class="form-control" value="<?php echo remove_junk($implemento['AccesoriosImplemento']); ?>">	                                                                        
		                        </div>               
		                    </div> 
		                    <div class="col-md-3">
		                      <label for="potencia" class="control-label">Potencia:</label>
		                      <div class="input-group">   
		                              <input type="text" id="potencia" name="potencia" class="form-control" value="<?php echo remove_junk($implemento['PotenciaImplemento']); ?>">                             
		                        </div>               
		                    </div>                  	
		                </div>
		              </div>
	                   <div class="text-center">
                   		 <button type="submit" class="btn btn-success"><i class="glyphicon glyphicon-floppy-disk"></i>Guardar</button>
	                     		  <a href="listado_implemento.php" class="btn btn-primary"><i class="glyphicon glyphicon-th-list"></i>Listado</a>
                     </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_implemento.js"></script>


