public function vehiculos($action) { if (isset($action)) { if ($action == "create") { $data = Vehiculo::firstOrCreate(Input::all()); return $respuesta = array('Record' => $data, 'Result' => "OK"); } if ($action == "edit") { Vehiculo::where("id", Input::get("id"))->update(Input::except("id")); return $respuesta = array('Record' => Vehiculo::find(Input::get('id')), 'Result' => "OK"); } if ($action == "remove") { Vehiculo::where('id', Input::get("id"))->delete(); return '{"Result":"OK"}'; } if ($action == "list") { $Records = Vehiculo::get(); $respuesta = array('Records' => $Records, 'Result' => "OK"); return json_encode($respuesta); } if ($action == "residencia") { $nulos = DB::table('residencias')->select(DB::raw("'NO POSEE' as DisplayText, NULL as Value")); $respuesta = Residencias::select("nombre as DisplayText", "id as Value")->union($nulos)->orderby('value', 'asc')->distinct()->get(); return "var opciones=" . json_encode($respuesta); } } }
<?php $x = 0; for ($x = 0; $x < $n; $x++) { echo '<option value="' . $elementos[$x]->id . '">' . $elementos[$x]->placa . '</option>'; } ?> </select> <span class="input-group-btn"> <input type="submit" class="btn btn-default" type="button" name="btnSeleccion" value="Seleccionar"/> </span> </div> </form> <?php $modificar = new Vehiculo(); if (isset($_POST['btnSeleccion'])) { $modificar->get($_POST['selVehi1']); } ?> <form method="post" action="adminVehiculos.php"> <input type="hidden" <?php echo 'value="' . $modificar->id . '"'; ?> name="txtId"> <div class="form-group"> <label for="txtPlaca">Placa</label> <input type="text" <?php echo 'value="' . $modificar->placa . '"'; ?> class="form-control" id="txtPlaca" name="txtPlaca1" placeholder="# de Placa" required autofocus> </div> <div class="form‐group">
<div id="divRep" class="col-lg-5" style="display:none;"> <table class="table table-hover"> <tr> <td>Vehículo</td> <td>Promedio</td> </tr> <?php $reporte = array(); $combustible = new Combustible(); $reporte = $combustible->reporte(); $repVehiculo = new Vehiculo(); for ($x = 0; $x < count($reporte); $x++) { $tupla = array(); $tupla = $reporte[$x]; if ($tupla[0] == $tupla[1]) { $repVehiculo->get($tupla[0]); echo '<tr><td>' . $repVehiculo->placa . '</td><td>' . $tupla[2] . '</td></tr>'; } } ?> </table> </div> </div> <?php footer(' $("#addFuel").click(function(){ $("#addForm").css("display","block"); $("#delForm").css("display","none"); $("#updForm").css("display","none"); $("#divRep").css("display","none"); });