public function executeAddVehicle(sfWebRequest $request) { $v = new Vehicle(); $v->setUserId($this->getUserIdFromRouteOrSession()); $this->form = new VehicleForm($v); $this->processVehicleForm($request, $this->form); $this->setTemplate('noVehicle'); }
public function getForm($object = null, $options = array()) { if (null === $object) { $object = new Vehicle(); } $object->setUserId($this->getUserId()); return parent::getForm($object, $options); }
public function executeCreate(sfWebRequest $request) { $charge = new Vehicle(); $charge->setUserId($this->getUserIdFromRouteOrSession()); $this->form = $this->configuration->getForm($charge); $this->vehicle = $charge; $this->processForm($request, $this->form); $this->setTemplate('new'); }
public function getAllVehicles() { $db = new Db(); $vehicles = array(); $results = $db->select("select vehicleID as vid, orderOwned, type, modelYear,\n make, model, color, numCyl, transType, purchaseYear, modifiedDate from vehicles;"); foreach ($results as $result) { $vehicle = new Vehicle(); $vehicle->hydrate($result); $vehicles[] = $vehicle; } return $vehicles; }
public function __construct($a, $b, $s, $d, $dest) { $this->destination = $dest; $this->seats = $s; $this->distance = $d; parent::__construct($a, $b); }
function rtipTime($distance) { // время в пути $time = parent::rtipTime($distance) * 1.2; //$time = ($distance / $this->speed)*1.2; // переопределение метода return $time; }
public function __construct($a, $b, $com, $height, $tp) { $this->company = $com; $this->height_meters = $height; $this->ticketPrice = $tp; parent::__construct($a, $b); }
public static function selectByCollection($id) { $connection = Flight::dbMain(); try { $sql = "SELECT * FROM vehicle_collection WHERE collection_id = :collection_id;"; $query = $connection->prepare($sql); $query->bindParam(':collection_id', $id, PDO::PARAM_INT); $query->execute(); $rows = $query->fetchAll(PDO::FETCH_ASSOC); $result = array(); foreach ($rows as $row) { $vehicleCollection = new VehicleCollection(); $vehicleCollection->Id = (int) $row['id']; $vehicleCollection->Vehicle = Vehicle::select($row['vehicle_id']); $vehicleCollection->Collection = Collection::select($row['collection_id']); array_push($result, $vehicleCollection); } return $result; } catch (PDOException $pdoException) { throw $pdoException; } catch (Exception $exception) { throw $exception; } finally { $connection = null; } }
public static function consumption($v) { $vid = Vehicle::getVehicle($v); $users = User::getUserIDs($vid["idvehicle"]); if ($users != NULL) { $uid = array(); //usersIDs foreach ($users as $key => $value) { array_push($uid, intval($users[$key]["iduser"])); } $consumption = array(); //consumption by userID foreach ($uid as $key => $value) { $data = Data::getDataBrowse($value); if ($data != NULL && $data["max"] != NULL && $data["min"] != NULL && $data["fuel"] != NULL) { $avg = intval($data["fuel"]) / (intval($data["max"]) - intval($data["min"])) * 100; array_push($consumption, $avg); } } if (!empty($consumption)) { $avg = round(array_sum($consumption) / count($consumption), 2) . "L/100km"; $min = round(min($consumption), 2) . "L/100km"; $max = round(max($consumption), 2) . "L/100km"; return [$avg, $min, $max]; } } }
public function run() { Vehicle::create(array('id' => 1, 'plate' => 'GNM504', 'color' => 'Rojo', 'brand' => 'Renault', 'model' => 'Twingo 2007', 'capacity' => 4, 'status' => 1, 'type' => 1, 'users_id' => 1)); Vehicle::create(array('id' => 2, 'plate' => 'FKJ324', 'color' => 'Azul', 'brand' => 'Renault', 'model' => 'Clio 2008', 'capacity' => 2, 'status' => 1, 'type' => 1, 'users_id' => 2)); Vehicle::create(array('id' => 3, 'plate' => 'HJJ832', 'color' => 'Verde', 'brand' => 'Renault', 'model' => 'Sandero 2010', 'capacity' => 2, 'status' => 1, 'type' => 1, 'users_id' => 3)); Vehicle::create(array('id' => 4, 'plate' => 'FMJ313', 'color' => 'Negro', 'brand' => 'Ford', 'model' => 'Fordsito 2014', 'capacity' => 3, 'status' => 1, 'type' => 1, 'users_id' => 4)); }
public function __construct($cc, $hp, $noOfDoors, $color, $brand) { echo "<br/>Hi from car constructor"; parent::__construct('Car', $cc, $hp); $this->noOfDoors = $noOfDoors; $this->color = $color; $this->brand = $brand; }
public function move($distance) { $result = parent::move($distance); if ($result == false) { echo 'Nema nafta! Vsichki da slizat.'; $this->passengers = 0; } }
public function __construct($a, $b, $s, $d, $c, $chance) { $this->seats = $s; $this->distance = $d; $this->company = $c; $this->chance = $chance; parent::__construct($a, $b); }
public function destroy() { $datos = Input::all(); $vehicle = Vehicle::find($datos['id']); $vehicle->status = 0; $vehicle->save(); return Redirect::intended('/vehiclelist'); }
public function __construct($doors, $color, $tires, $make, $model) { parent::__construct($doors, $color, $tires); $this->make = $make; $this->model = $model; // $this->tires = $tires; // $this->color = $color; // $this->doors = $doors; }
public function actionIndex() { $criteria = new CDbCriteria(); $pages = new CPagination(Vehicle::model()->count($criteria)); $pages->pageSize = 8; $pages->applyLimit($criteria); $vehicles = Vehicle::model()->findAll($criteria); $this->render('home', array('vehicles' => $vehicles, 'pages' => $pages)); }
public function getCylindersCounts() { $entities = array(); $cylinders = Vehicle::distinct()->select('cylinders')->orderBy('cylinders')->where('cylinders', '>', 0)->get(); foreach ($cylinders as $cylinder) { array_push($entities, (object) ['id' => $cylinder->cylinders, 'cylinders' => $cylinder->cylinders . ' Cylinders']); } return $this->getPropertiesList($entities, 'cylinders'); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $vehicles = Vehicle::where('users_id', '=', Auth::user()->id)->get(); if ($vehicles->count() > 0) { return View::make('chances.create', compact('vehicles')); } else { return View::make('vehicles.create')->withErrors('You must add a vehicle to create a Chance'); } }
public function destroy($id) { $vehicle = Vehicle::find($id); $result = $vehicle->delete(); if ($result) { return $this->index(); } else { return $this->index(); } }
public static function getProcessedVehiclesSum($start, $end) { $processedList = DB::select(DB::raw("SELECT e_v.vehicle_fk, COUNT(*) as quantity\n FROM employees_vehicles AS e_v, invoices AS inv\n WHERE inv.date >= '{$start}'\n AND inv.date <= '{$end}'\n AND inv.id = e_v.invoice_fk\n AND inv.deleted_at IS NULL\n AND e_v.deleted_at IS NULL\n GROUP BY e_v.vehicle_fk")); $totalSum = 0; foreach ($processedList as $process) { $price = Vehicle::getEmployeesCut($process->vehicle_fk); $total = $price * $process->quantity; $totalSum += $total; } return $totalSum; }
public function testCreate() { $vehicle = new Vehicle(); $vehicle->setMPG(25); $vehicle->setUser(new User()); $vehicle->setMake(new Make()); $this->assertSame(25, $vehicle->getMPG()); $this->assertTrue($vehicle->getUser() instanceof User); $this->assertTrue($vehicle->getMake() instanceof Make); }
public function download($id) { $invoiceInfo = Invoice::find($id); $invoiceElements = InvoiceElement::getInvoiceElements($id); $employeeInfo = Employee::withTrashed()->find($invoiceElements[0]->employee_fk); $elementData = []; foreach ($invoiceElements as $element) { $price = Vehicle::withTrashed()->where('id', '=', $element->vehicle_fk)->pluck('price'); $type = Vehicle::withTrashed()->where('id', '=', $element->vehicle_fk)->pluck('type'); $elementData[$element->vehicle_fk] = ['type' => $type, 'price' => $price]; } $pdf = PDF::loadView('invoice.invoice', ['invoiceInfo' => $invoiceInfo, 'invoiceElements' => $invoiceElements, 'elementData' => $elementData, 'employeeInfo' => $employeeInfo]); return $pdf->download($invoiceInfo->date . ' - ' . $invoiceInfo->bill_to . '.pdf'); }
function __construct() { if (empty($_SESSION['user'])) { return null; } $this->companyId = $_SESSION['user']['company']; $this->userId = new User(); $mDeployedVehicleList = $this->userId->getDeployedVehicleList(); //currently running vehicles... $this->activationamount = $this->totalAmount = $this->totalPaidAmount = $this->amountreqfornextcycle = $this->totalRemainingAmount = 0; $this->vehListActivationReq = $this->vehListPayReq = $this->vehList = ""; //calcultaion for deplyoed vehicles.... for ($i = 0; $i < sizeof($mDeployedVehicleList); $i++) { $mVehicle = new Vehicle($mDeployedVehicleList[$i]); $this->vehListPayReq .= $mVehicle->getId() . ", "; $mVehPayments = new Payments($mVehicle->getId(), $this->companyId); if ($mVehPayments->getId() != "") { $this->totalAmount += $mVehPayments->getTotalAmount(); $this->totalPaidAmount += $mVehPayments->getPaidpayment(); $this->totalRemainingAmount += $mVehPayments->getRemainingAmount(); if ($mVehPayments->isDue() != 0) { $this->amountreqfornextcycle += $mVehPayments->isDue(); } } } ///calculate amount with respect to the initate vehicels... $mPreviousVehicleList = $this->userId->getWaitingVehicleList(); //previous used vehicles... for ($i = 0; $i < sizeof($mPreviousVehicleList); $i++) { $mVehicle = new Vehicle($mPreviousVehicleList[$i]); $this->vehListActivationReq .= $mVehicle->getId() . ", "; $mVehPayments = new Payments($mVehicle->getId(), $this->companyId); $this->activationamount += $mVehPayments->getVehicleActivationAmount(); } $this->vehList = $this->vehListPayReq . $this->vehListActivationReq; }
public function postEdit() { $rules = array('vehicleid' => 'required|numeric|exists:vehicles,id', 'playerid' => 'required|numeric|exists:players,playerid', 'reason' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->passes() && Auth::user()->canEditVehicle(Input::get('playerid'))) { $alive = 0; if (Input::get('alive') == 1) { $alive = 1; } $active = 0; if (Input::get('active') == 1) { $active = 1; } $delete = 0; if (Input::get('delete') == 1) { $delete = 1; } if ($delete) { $log = new Adminlog(); $log->type = 'vehicle'; $log->editor = Auth::user()->id; $log->objectid = Input::get('vehicleid'); $log->playerid = DB::table('players')->where('playerid', Input::get('playerid'))->first()->uid; $log->reason = Input::get('reason'); $log->difference = $log->getDifference(array('deleted' => 0), array('deleted' => 1)); $log->save(); DB::table('vehicles')->where('id', Input::get('vehicleid'))->delete(); } else { $vehicle = Vehicle::find(Input::get('vehicleid')); $log = new Adminlog(); $log->type = 'vehicle'; $log->editor = Auth::user()->id; $log->objectid = Input::get('vehicleid'); $log->playerid = DB::table('players')->where('playerid', Input::get('playerid'))->first()->uid; $log->reason = Input::get('reason'); $log->difference = $log->getDifference(array('alive' => $vehicle->alive, 'active' => $vehicle->active), array('alive' => $alive, 'active' => $active)); $log->save(); $vehicle->alive = $alive; $vehicle->active = $active; $vehicle->save(); } return Redirect::to('/vehicles')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success')); } else { return Redirect::to('/vehicles')->with(array('message' => 'Leider ist ein Fehler aufgetreten, die Änderung wurde verworfen.', 'type' => 'danger')); } }
public static function OnPlayerEnterVehicle(Player $player, Vehicle $vehicle, $ispassenger) { if (!$ispassenger && $vehicle->Type() == VEHICLE_SHOP) { $price = VehicleShop::$prices[$vehicle->ID()]; $name = $vehicle->Name(); $capacity = $vehicle->FuelSpace(); $usage = sprintf('%.2f', $vehicle->FuelUsage() * 60); $trunk = $vehicle->TrunkSpace(); $player->Send(COLOR_CARSHOP_HEADER, ''); $player->Send(COLOR_CARSHOP_HEADER, '.:: Vehicle shop ::.'); $player->Send(COLOR_CARSHOP_INFO, "This '{$name}' is for sale for {$price}\$"); $player->Send(COLOR_CARSHOP_INFO, 'If you want to buy it, type /buy'); $player->Send(COLOR_CARSHOP_INFO, 'Vehicle details:'); $player->Send(COLOR_CARSHOP_INFO, "* Gas tank capacity: {$capacity}lt"); $player->Send(COLOR_CARSHOP_INFO, "* Fuel usage: {$usage}lt / minute"); $player->Send(COLOR_CARSHOP_INFO, "* Trunk space: {$trunk} units"); $vehicle->SetHealth(1000); return CALLBACK_BREAK; } return CALLBACK_OK; }
public static function add($type, $model, $vehicle_number, $make_year, $description) { //require_once '../framework/DBConnect.php'; // opening db connection $db = new Connection(); $conn = $db->connect(); if (Vehicle::exists($conn, $vehicle_number)) { return false; } if (!isset($_SESSION)) { session_start(); } $companyId = $_SESSION['user']['company']; $userId = $_SESSION['user']['id']; $sql = "INSERT INTO retvehicle (type, model, vehicle_number, make_year, company_id, added_by, description) VALUES ('{$type}','{$model}','{$vehicle_number}','{$make_year}','{$companyId}','{$userId}','{$description}')"; if (mysqli_query($conn, $sql)) { return true; } else { return false; } }
public function store() { $data = Input::all(); $idchance = $data['chances_id']; $iduser = Auth::user()->id; $data['users_id'] = $iduser; $chance = Chance::find($idchance); $userofchances = UserofChance::where('chances_id', '=', $idchance)->where('users_id', '=', $iduser)->get(); if (empty($userofchances)) { $message = json_encode(array('message', 'You have already taken this chance')); return $message; } $vehicle = Vehicle::find($chance->vehicles_id); if ($vehicle->users_id == $iduser) { $message = json_encode(array('message', 'You created this chance')); } else { UserofChance::create($data); $chance->capacity = $chance->capacity - 1; $chance->save(); return Redirect::intended('/chanceslist/'); } }
public function actionLoadVersionVehicle() { $criteria = new CDbCriteria(); $criteria->order = 'reference'; $criteria->condition = 'id != 32 AND id != 33 AND id != 34 AND id != 36 AND id != 37 AND id != 38 AND id != 39 AND id != 40 AND id != 41 AND id != 42'; $vehicle_version = VehicleVersion::model()->findAllByAttributes(array("vehicle_id" => $_POST['vehicle_id'], "status" => "ACTIVE"), $criteria); $vehicle_image = Picture::model()->findByAttributes(array("vehicle_id" => $_POST['vehicle_id'])); $vehicle_s = Vehicle::model()->findByPk($_POST['vehicle_id']); $return = array(); foreach ($vehicle_version as $z => $vehicle) { $return[$z]['id'] = $vehicle->id; $return[$z]['reference'] = $vehicle->reference; $return[$z]['motor'] = $vehicle->motor; $return[$z]['type'] = $vehicle->type; $return[$z]['transmission'] = $vehicle->transmission; $return[$z]['combustion'] = $vehicle->combustion; $return[$z]['ac'] = $vehicle->ac; $return[$z]['abs'] = $vehicle->abs; } $return['image'] = $vehicle_image->description; $return['name'] = $vehicle_s->name; echo json_encode($return); }
public function index() { $vin = Input::get('vin', ''); $vehicle = Vehicle::where('vin', '=', $vin)->first(); $dealer = Dealer::where('id', '=', $vehicle->dealer)->first(); $click = new Click(); $click->vin = $vehicle->vin; $click->dealer = $dealer->dealer; $click->state = $vehicle->state; $click->datetime = date("Y-m-d H:i:s"); $click->ip = $_SERVER['REMOTE_ADDR']; $click->paid = $vehicle->paid; $click->save(); $dealer->current_clicks = $dealer->current_clicks + 1; if ($vehicle->paid > 0) { $dealer->paid_clicks = $dealer->paid_clicks + 1; } if ($dealer->active == 1 && $dealer->monthly_clicks <= $dealer->paid_clicks) { $dealer->active = 0; DB::table('vehicle')->where('dealer', $dealer->id)->update(array('paid' => 0, 'modified' => 1)); } $dealer->save(); return Redirect::to($vehicle->url); }
public function vehicleHistory($id) { $oldVehicleIds = Vehicle::getVehicleHistory($id); foreach ($oldVehicleIds as $oldVehicleId) { $oldVehicleData[] = Vehicle::withTrashed()->find($oldVehicleId); } $currentVehicle = end($oldVehicleIds); $data = compact('oldVehicleData', 'currentVehicle'); //echo "<pre>"; //print_r($oldVehicleData); return View::make('vehicle.history', $data); }