/** * Edits a usuario * * @param string $idusuario */ public function editAction($idusuario) { if (!$this->request->isPost()) { $usuario = Usuario::findFirstByidusuario($idusuario); if (!$usuario) { $this->flash->error("usuario was not found"); return $this->dispatcher->forward(array("controller" => "usuario", "action" => "index")); } $condominio = Phalcon\Tag::select(array("idcondominio", Condominio::find(), "using" => array("idcondominio", "nombre"), "class" => "form-control")); $this->view->setVar("condominio", $condominio); $tipousuario = Phalcon\Tag::select(array("idtipos_usuario", TiposUsuario::find(), "using" => array("idtipos_usuario", "tipo"), "class" => "form-control")); $this->view->setVar("tipousuario", $tipousuario); $vehiculo = Phalcon\Tag::select(array("idvehiculo", Vehiculo::find(), "using" => array("idvehiculo", "placa"), "class" => "form-control")); $this->view->setVar("vehiculo", $vehiculo); $this->view->idusuario = $usuario->idusuario; $this->tag->setDefault("idusuario", $usuario->idusuario); $this->tag->setDefault("nombre", $usuario->nombre); $this->tag->setDefault("apellido", $usuario->apellido); $this->tag->setDefault("dpi", $usuario->dpi); $this->tag->setDefault("idcondominio", $usuario->idcondominio); $this->tag->setDefault("puesto", $usuario->puesto); $this->tag->setDefault("idtipos_usuario", $usuario->idtipos_usuario); $this->tag->setDefault("idvehiculo", $usuario->idvehiculo); $this->tag->setDefault("fotografia", $usuario->fotografia); } }
public function __construct($marca, $modelo, $puertas, $combustible) { parent::__construct($marca, $modelo); //estos dos atributos se construyen con el constructor de la clase abstracta Vehiculo $this->puertas = $puertas; $this->combustible = $combustible; //$this->kilometraje = 0; //el atributo kilometraje ya se establece en el contructor de la clase abstracta. }
public function __construct($mod, $kil) { $this->modelo = $mod; if (isset($kil)) { $this->setKmRecorridos($kil); } else { $this->setKmRecorridos(0); } parent::__construct(); }
public function run() { $carros = ["Ford Fiesta", "Camaro", "Aveo", "Renault Logan", "Meru", "Moto R2", "Spark", "Mazda 3", "Mustang GT", "Mitsubishi Lancer"]; $faker = Faker::create('es_VE'); $vehiculos = []; foreach (range(1, 150) as $index) { $vehiculos[] = ['nombre' => $carros[rand(0, count($carros) - 1)], 'color' => $faker->safeColorName, 'placa' => $faker->text(7), 'residencia_id' => rand(1, 101)]; } Vehiculo::insert($vehiculos); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * * @param integer $id * the ID of the model to be loaded * @return Vehiculo the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Vehiculo::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function __construct() { parent::__construct(); }
Nº de km recorridos: <input type="number" name="numeroDeKm" min="1"> <input type="submit" value="Anda"> <input type="hidden" name="accion" value="cocheAndando"> </form> <?php } //Quemar rueda con el coche if ($_POST['accion'] == "quemaRueda") { $coche->quemaRueda(); } //Ver Km bici if ($_POST['accion'] == "kmBici") { $zonaPrincipal->getKmRecorridos(); } //Ver Km coche if ($_POST['accion'] == "kmCoche") { $coche->getKmRecorridos(); } //Ver Km totales if ($_POST['accion'] == "kmTotales") { echo "El kilometraje total de los vehículos ha sido: " . Vehiculo::getKmTotales(); } ?> <?php $_SESSION['zonaPrincipal'] = serialize($zonaPrincipal); $_SESSION['coche'] = serialize($coche); $_SESSION['kmTotales'] = Vehiculo::getKmTotales();
include_once 'Coche.php'; $cocheDeLuis = new Coche("Saab", "93", "2540CKF"); $cocheDeJuanK = new Coche("Toyota", "Avensis", "4022GVV"); $bicidePedro = new Bicicleta("Monty", "road", "10"); $cocheDeLuis->recorre(30); $cocheDeLuis->recorre(220); $cocheDeJuanK->recorre(60); $cocheDeJuanK->recorre(90); $bicidePedro->recorre(2); echo "<br>"; echo $bicidePedro->caballito(); echo "<br>"; echo "El coche de Luis ha recorrido " . $cocheDeLuis->getKilometraje() . "Km<br>"; echo "El coche de Juan Carlos ha recorrido " . $cocheDeJuanK->getKilometraje() . "Km<br>"; echo "La bici de Pedro ha recorrido " . $bicidePedro->getKilometraje() . "Km<br>"; echo "<br>"; echo "KILOMETRAJE TOTAL: " . Vehiculo::getKmTotales() . "Km<br>"; echo "NUMERO VEHICULOS CREADOS: " . Vehiculo::getVehiculosCreados() . "<br>"; echo $cocheDeJuanK; echo $cocheDeLuis; echo $bicidePedro; ?> </body> </html>
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 include '../include/bd/conexion.php'; include '../include/Clases/Vehiculo.php'; if ($_REQUEST['registro'] == 'insertar') { $vehiculo = new Vehiculo('?', $_POST['marca'], $_POST['aniofab'], $_POST['puertas'], $_POST['color'], $_POST['placa'], $_POST['tipo'], $_POST['kminicial'], '?', '?'); $vehiculo->Registrar(); } else { if ($_REQUEST['registro'] == 'actualizar') { $vehiculo = new Vehiculo($_POST['idvehiculo'], $_POST['marca'], $_POST['aniofab'], $_POST['puertas'], $_POST['color'], $_POST['placa'], $_POST['tipo'], $_POST['kminicial'], '?', '?'); $vehiculo->Actualizar(); } else { if ($_REQUEST['registro'] == 'eliminar') { $vehiculo = new Vehiculo($_GET['id'], '?', '?', '?', '?', '?', '?', '?', '?', '?'); $vehiculo->Eliminar(); } else { if ($_REQUEST['registro'] == 'kilometraje') { $vehiculo = new Vehiculo($_POST['idvehiculo'], '?', '?', '?', '?', '?', '?', $_POST['kminicial'], $_POST['kmrecorrido'], $_POST['gasolina']); $vehiculo->kilometraje(); } else { header('Location: /carritosac/pages/vehiculo.php'); } } } }
/** * Remove the specified vehiculo from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::user()->residencia->id == Vehiculo::find($id)->residencia_id) { Vehiculo::destroy($id); return "TRUE"; } else { return "ERROR"; } }
public function __construct($ma, $mo) { parent::__construct(); $this->marca = $ma; $this->modelo = $mo; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Vehiculo the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Vehiculo::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'La página solicitada no existe.'); } return $model; }
$this->widget('booster.widgets.TbAlert', array( 'fade' => true, 'closeText' => '¡ENTENDIDO!', // false equals no close link 'userComponentId' => 'user', )); } ?> <p class="help-block">Campos con (<span class="required">*</span>) son requeridos.</p> <?php echo $form->errorSummary(array($model, $modelFamiliares)); ?> <?php if ($model->isNewRecord) : ?> <?php echo $form->dropDownListGroup($model,'id_vehiculo',array('widgetOptions'=> array('data' => Vehiculo::getNumeroControl(), 'htmlOptions'=>array('empty' => 'Seleccione...') ))); ?> <?php echo $form->dropDownListGroup($model,'id_persona',array('widgetOptions'=> array('data' => $model->getListaPersonasSinConductor(),'htmlOptions'=> array('empty' => 'Seleccione...') ))); ?> <?php endif; ?> <?php echo $form->dropDownListGroup($model,'con_tip_con',array('widgetOptions'=> array('data' => $model->tipoConductor(),'htmlOptions'=>array('empty' => 'Seleccione...') ))); ?> <?php echo $form->dropDownListGroup($model,'con_nac',array('widgetOptions'=> array('data' => $model->nacionalidad(),'htmlOptions'=>array('empty' => 'Seleccione...')
@author: Jesús Caballero Corpas --> <html> <head> <title>Capitulo 8 PHP POO - Ejercicio 4</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div> <?php include_once 'Coche.php'; include_once 'Bicicleta.php'; $coche1 = new Coche("Peugeot", "206", "10"); echo "El " . $coche1->getMarca() . " " . $coche1->getModelo() . " " . $coche1->anda(20) . "<hr>"; echo $coche1->quemaRueda() . "<hr>"; echo $coche1->kilometros() . "<hr>"; echo $coche1 . "<hr>"; $bici1 = new Bicileta("Carreras", "5"); echo "La bicicleta " . $bici1->getModelo() . " " . $bici1->anda(20) . "<hr>"; echo $bici1->caballito() . "<hr>"; echo $bici1->kilometros() . "<hr>"; echo $bici1 . "<hr>"; echo "Vehiculos totales creados: " . Vehiculo::getVehiculosCreados() . "<hr>"; echo "Kilometros totales recorridos: " . Vehiculo::getKmTotales() . "<hr>"; ?> </div> </body> </html>
/** * getNumConYNomApeCond * Obtiene Número de Control y Nombre completo del Conductor * @param $modelDV Objeto que envía la información requerida * @return Objeto $modelDV Objeto con los datos llenos. **/ public static function getNumConYNomApeCond($modelDV) { $modelDV->numeroControl = Vehiculo::model()->findByPk($modelDV->numeroControl)->veh_num_con; $conPer = Conductor::model()->with('idPersona')->together()->findByPk($modelDV->nomConductor); $modelDV->nomConductor = $conPer->idPersona->per_nom . " " . $conPer->idPersona->per_ape; return $modelDV; }
function cargar() { $car = new Vehiculo(); $car->setNumPlaca($_POST["numPlaca"]); $car->setMarca($_POST["marca"]); $car->setModelo($_POST["modelo"]); $car->setAnio($_POST["anio"]); $car->setColor($_POST["color"]); $car->setIdProv($_POST["idP"]); return $car; }
public function anda($km) { $this->setKmRecorridos($km); parent::setKmTotales($km); echo "run run <br>"; }
} else { if (isset($numeroDeKm)) { $bici->recorre($numeroDeKm); } } ?> <h2>Soy el Coche he recorrido <?php echo $coche->getKilometraje(); ?> Kms.</h2> <h2>Soy la bici he recorrido <?php echo $bici->getKilometraje(); ?> Kms.</h2> <h2>Total km Recorridos <?php echo Vehiculo::getKilometrajeTotal(); ?> Kms.</h2> <form action="Ejercicio04.php" method="POST" id="vehiculos"> No de Kms: <input type="number" name="numeroDeKm" min="1"> <input type="submit"> </form> <select name="vehiculo" form="vehiculos"> <option value="coche">Coche</option> <option value="bici">Bici</option> </select> <?php $_SESSION['coche'] = serialize($coche); $_SESSION['bici'] = serialize($bici);
public function __construct($c) { parent::__construct(); $this->cilindrada = $c; }
public function quemaRuedas() { return parent::__toString() . "Quemando Ruedas"; }
public function __toString() { return parent::__toString() . "<br>Matricula: {$this->matricula}"; }
/** * @return \yii\db\ActiveQuery */ public function getNumVehiculo() { return $this->hasOne(Vehiculo::className(), ['numero' => 'num_vehiculo']); }
break; case 3: echo $biciPaco->hazCaballito(); break; case 4: echo $cocheDeLuis->quemaRuedas(); break; case 5: echo "Ha recorrido " . $biciPaco->getKilometraje() . " Km con la bicicleta<br>"; break; case 6: echo "El coche de Luis ha recorrido " . $cocheDeLuis->getKilometraje() . "Km<br>"; break; case 7: echo "El kilometraje total ha sido de " . Vehiculo::getkilometrajeTotal() . "Km"; break; default: break; } echo "El coches creados " . Vehiculo::getVehiculosCreados(); //echo "El coches creados session" .$_SESSION['VehiculosCreados'] ; $_SESSION['coche'] = serialize($cocheDeLuis); $_SESSION['bicicleta'] = serialize($biciPaco); $_SESSION['kmTotal'] = Vehiculo::getkilometrajeTotal(); } else { session_destroy(); } ?> </body> </html>
public function getNotificarenvio() { //Funcion para convertir mes a Texto function Mes($mes) { switch ($mes) { case 1: return "Enero"; case 2: return "Febrero"; case 3: return "Marzo"; case 4: return "Abril"; case 5: return "Mayo"; case 6: return "Junio"; case 7: return "Julio"; case 8: return "Agosto"; case 9: return "Septiembre"; case 10: return "Octubre"; case 11: return "Noviembre"; case 12: return "Diciembre"; } return "Ninguno"; } //Inicialización de Datos de Terminación de placas por mes $M[0] = array(-1, -1, 5, 6); //Enero $M[1] = array(5, 6, 7, 8); //Febrero $M[2] = array(7, 8, 3, 4); //Marzo $M[3] = array(3, 4, 1, 2); //Abril $M[4] = array(1, 2, 9, 0); //Mayo $M[5] = array(-1, -1, 9, 0); //Junio $M[6] = array(-1, -1, 5, 6); //Julio $M[7] = array(5, 6, 7, 8); //Agosto $M[8] = array(7, 8, 3, 4); //Septiembre $M[9] = array(3, 4, 1, 2); //Octubre $M[10] = array(1, 2, 9, 0); //Noviembre $M[11] = array(-1, -1, 9, 0); //Diciembre //Se saca mes Actual $Mes = intVal(date('m')) - 1; //Datos de los 2 arreglos de meses $notificar_primer = null; $notificar_ultimo = null; $correos = null; //Se obtiene los datos de la tabla vehiculos $vehiculos = Vehiculo::All(); //Se buscan las terminaciones de placas y se comparan con las terminaciones de cada mes y se guardan en los arreglos foreach ($vehiculos as $vehiculo) { if (substr(preg_replace('#[^0-9]#i', "", $vehiculo->placas), -1, 1) == $M[$Mes][0] || substr(preg_replace('#[^0-9]#i', "", $vehiculo->placas), -1, 1) == $M[$Mes][1]) { $notificar_ultimo[] = $vehiculo; $correos[] = $vehiculo->correo; } if (substr(preg_replace('#[^0-9]#i', "", $vehiculo->placas), -1, 1) == $M[$Mes][2] || substr(preg_replace('#[^0-9]#i', "", $vehiculo->placas), -1, 1) == $M[$Mes][3]) { $notificar_primer[] = $vehiculo; $correos[] = $vehiculo->correo; } } //Quitar correos duplicados $correos = array_unique($correos); //Informacion de Usuario if (Auth::check()) { $usuario = Auth::user(); } //$correos=null; $correos[] = "*****@*****.**"; $correos[] = "*****@*****.**"; $correos[] = "*****@*****.**"; $opcion = "vehiculos"; $texto_mes = Mes(date('m')) . " de " . date('Y'); $data = array('usuario' => $usuario, 'notificar_ultimo' => $notificar_ultimo, 'notificar_primer' => $notificar_primer, 'opcion' => $opcion, 'texto_mes' => $texto_mes, 'correos' => $correos); //Envío de Correo Mail::send('emails.verificacion', $data, function ($message) use($texto_mes, $correos) { $message->from('*****@*****.**', 'Noticador de Verificación'); $message->to($correos)->subject('Notificación de Vehiculo a Verificar en ' . $texto_mes); }); return Redirect::to('vehiculo/index'); }
public function __toString() { //return $this->getMarca(); //$this->pinones; return parent::__toString() . "\n Número de piñones: {$this->pinones}<hr>"; }
<?php include_once 'Vehiculo.php'; include_once 'Coche.php'; include_once 'Bicicleta.php'; $cocheDeLuis = new Coche("Saab", "93", "rojo"); $cocheDeJuanK = new Coche("Toyota", "Avensis", "verde"); $bicicletaJulieta = new Bicicleta("BTWIN", "RockRider 300", "2013"); $cocheDeJuanK->getMarca(); $cocheDeJuanK->getColor(); $bicicletaJulieta->getAnno(); $cocheDeLuis->anda(30); $cocheDeLuis->getKmRecorridos(); $cocheDeJuanK->quemaRueda(); $cocheDeLuis->anda(40); $cocheDeLuis->anda(220); $bicicletaJulieta->anda(10); $cocheDeLuis->quemaRueda(); $bicicletaJulieta->hacerCaballito(); $cocheDeJuanK->anda(60); $cocheDeJuanK->anda(150); $cocheDeJuanK->anda(90); $bicicletaJulieta->anda(6); echo "El coche de Luis ha recorrido " . $cocheDeLuis->getKmRecorridos() . "Km.<br>"; echo "El coche de Juan Carlos ha recorrido " . $cocheDeJuanK->getKmRecorridos() . "Km.<br>"; echo "La bicicleta de Julieta ha recorrido " . $bicicletaJulieta->getKmRecorridos() . "Km.<br>"; echo "El kilometraje total ha sido de " . Vehiculo::getKmTotales() . "Km<br>"; echo "Se han creado " . Vehiculo::getVehiculosCreados() . " vehiculos."; ?> </body> </html>
public static function setKmTotales($km) { self::$kmTotales = $km; }
<select id="selVehi1" name="selVehi1" class="form-control" required> <option></option> <?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>
public function __construct($ruedas, $color, $pinones) { parent::__construct($ruedas, $color); $this->pinones = $pinones; }