<?php
  $page_title = 'Editar Maquinaria';
  require_once('../../includes/load.php');
  // Checkin What level user has permission to view this page
  page_require_level(4);
?>
<?php
  $vehiculo = find_by_id('vehiculo',(int)$_GET['id']);
  if(!$vehiculo){
  $session->msg("d","Error: No se encontró id del vehiculo.");
  redirect('listado_vehiculo.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> Produccion</span>
                  </strong> 
                </div>
                 <div class="card-body">
		              <div class="form-group">
		                <div class="row">
		                	  <div class="col-md-3">
		                      <label for="vehiculo" class="control-label">IdVehiculo:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input class="form-control" id="vehiculo" name="vehiculo" value="<?php echo (int)$vehiculo['id'];?>" readonly>                                            
		                      </div>               
		                    </div>
		                    <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 =$vehiculo['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="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($vehiculo['NombreVehiculo']); ?>">                                            
		                      </div>               
		                    </div>
                            <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($vehiculo['CodigoPatrimonialVehiculo']); ?>">                                           
		                      </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($vehiculo['MarcaVehiculo']); ?>">                             
		                        </div>               
		                    </div>
		                    <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($vehiculo['ModeloVehiculo']); ?>">                            
		                        </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($vehiculo['PlacaVehiculo']); ?>">                                                                      
		                        </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($vehiculo['ColorVehiculo']); ?>">                                      
		                        </div>               
		                    </div>                
		                </div>
		              </div>


		              <div class="form-group">
		                <div class="row">
		                	<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($vehiculo['PotenciaVehiculo']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="cilindro" class="control-label">Clindro:</label>
		                      <div class="input-group">  
		                              <input type="text" id="cilindro" name="cilindro" class="form-control" value="<?php echo remove_junk($vehiculo['CilindroVehiculo']); ?>">                            
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="traccion" class="control-label">Traccion:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                             <input type="text" id="traccion" name="traccion" class="form-control" value="<?php echo remove_junk($vehiculo['TraccionVehiculo']); ?>">		                                                                        
		                        </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($vehiculo['AccesoriosVehiculo']); ?>">	                                                                        
		                        </div>               
		                    </div>                    
		                </div>
		              </div>
              
		              <div class="form-group">
		                <div class="row">
		                	<div class="col-md-3">
		                      <label for="anio_produccion" class="control-label">Año 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($vehiculo['AñoProduccionVehiculo']); ?>">                                      
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="anio_compra" class="control-label">Año Compra:</label>
		                      <div class="input-group">   
		                              <input type="text" id="anio_compra" name="anio_compra" class="form-control" value="<?php echo remove_junk($vehiculo['AñoCompraVehiculo']); ?>">                              
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="pre_compra" class="control-label">Precio Compra:</label>
		                      <div class="input-group">  
		                              <input type="text" id="pre_compra" name="pre_compra" class="form-control" value="<?php echo remove_junk($vehiculo['PrecioCompraVehiculo']); ?>">                            
		                        </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 =$vehiculo['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>

		               <div class="form-group">
		                <div class="row">
		                	<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 =$vehiculo['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="estado" class="control-label">Estado:</label>
		                      <div class="input-group">   
		                              <select id="estado" name="estado" class="form-control">
		                                 <option value="Activo" <?php if ($vehiculo['EstadoActivoMI']=='Activo'){echo 'selected';} ?>>Activo</option>
				                         		 <option value="Inactivo" <?php if ($vehiculo['EstadoActivoMI']=='Inactivo'){echo 'selected';} ?>>Inactivo</option>
		                              </select>                           
		                        </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($vehiculo['ObservacionesVehiculo']); ?>">                             
		                        </div>               
		                    </div>
		                    <div class="col-md-3">
		                      <label for="transmision" class="control-label">Tansmision:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="transmision" name="transmision" class="form-control" value="<?php echo remove_junk($vehiculo['TrasmisionActivoVehiculo']); ?>">	                                                                        
		                        </div>               
		                    </div>		                   		                    
		                </div>
		              </div>

		              <div class="form-group">
		                <div class="row">
		                	<div class="col-md-3">
		                      <label for="motor" class="control-label">Motor:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="motor" name="motor" class="form-control" value="<?php echo remove_junk($vehiculo['SerieMotorActivoVehiculo']); ?>">                                      
		                        </div>               
		                    </div>			                    

		                    
		                    <div class="col-md-3">
		                      <label for="chasis" class="control-label">Chasis:</label>
		                      <div class="input-group"> 
		                        <span class="input-group-addon">
		                          <i class="fi fi-sr-interlining"></i>
		                        </span>  
		                              <input type="text" id="chasis" name="chasis" class="form-control" value="<?php echo remove_junk($vehiculo['SerieChasisVehiculo']); ?>">                                       
		                        </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($vehiculo['FechaCompraVehiculo']); ?>" required>                            
		                        </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_vehiculo.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_vehiculo.js"></script>


