public function rows($id, $vehicle_id) { if (!($vehicle = Vehicle::find($vehicle_id))) { return $this->try_($vehicle); } $config = Grids::make($id)->toRowDatasetConfig($id); $filters = $config['source']->custom_filters(); $config['source']->custom_filters($filters + ['test' => 'consumptions.vehicle_id = ' . $vehicle_id]); return $this->dataset($config); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // return Input::all(); $datacase = new DataCase(); $datacase->fill(Input::except(["weapon", "vehicle"])); $datacase->save(); $data_vehicle = Input::get('vehicle'); $data_weapon = Input::get('weapon'); foreach ($data_vehicle as $datavehicle) { $vechicle = new Vehicle(); $vechicle->fill($datavehicle); $vechicle->datacase()->associate($datacase); $vechicle->save(); } foreach ($data_weapon as $dataweapon) { $weapom = new Weapon(); $weapom->fill($dataweapon); $weapom->datacase()->associate($datacase); $weapom->save(); } return $datacase; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Vehicle::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'year' => $this->year]); $query->andFilterWhere(['like', 'make', $this->make])->andFilterWhere(['like', 'model', $this->model]); return $dataProvider; }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // return Input::all(); $name_father = Input::get('datafather.father_name'); $surname_father = Input::get('datafather.father_surname'); $name_mother = Input::get('datamother.mother_name'); $surname_mother = Input::get('datamother.mother_surname'); $name_spouse = Input::get('dataspouse.spouse_name'); $surname_spouse = Input::get('dataspouse.spouse_surname'); $present_address = Input::get('addresspresent.present_address'); $original_address = Input::get('addressoriginal.original_address'); if (Auth::check()) { $IdPolice = Auth::user()->id; } if ($present_address != null) { $addresspresent = new AddressPresent(); $addresspresent->fill(Input::get('addresspresent')); $addresspresent->save(); } if ($original_address != null) { $addressoriginal = new AddressOriginal(); $addressoriginal->fill(Input::get('addressoriginal')); $addressoriginal->save(); } if ($name_mother != null || $surname_mother != null) { $datamother = new DataMother(); $datamother->fill(Input::get('datamother')); $datamother->save(); } if ($name_father != null || $surname_father != null) { $datafather = new DataFather(); $datafather->fill(Input::get('datafather')); $datafather->save(); } if ($name_spouse != null || $surname_spouse != null) { $dataspouse = new DataSpouse(); $dataspouse->fill(Input::get('dataspouse')); $dataspouse->save(); } $guesthistory = new GuestHistory(); $guesthistory->fill(Input::except(["addressoffice", "child", "employee", "family", "vehicle", "datamother", "dataspouse", "addressoriginal", "addresspresent", "datafather"])); if ($datamother != null) { $guesthistory->datamother()->associate($datamother); } if ($datafather != null) { $guesthistory->datafather()->associate($datafather); } if ($dataspouse != null) { $guesthistory->dataspouse()->associate($dataspouse); } if ($addressoriginal != null) { $guesthistory->addressoriginal()->associate($addressoriginal); } if ($addresspresent != null) { $guesthistory->addresspresent()->associate($addresspresent); } if ($IdPolice != null) { $police = Policeimmigration::find($IdPolice); $guesthistory->policeimmigration()->associate($police); } $guesthistory->save(); $address_office = Input::get('addressoffice'); $data_child = Input::get('datachild'); $data_employee = Input::get('employee'); $person_family = Input::get('personfamily'); $data_vehicle = Input::get('vehicle'); foreach ($data_employee as $dataemployee) { $employee = new \App\Models\Employee(); $employee->fill($dataemployee); $employee->guesthistory()->associate($guesthistory); $employee->save(); } foreach ($person_family as $datafamily) { $personfamily = new PersonFamily(); $personfamily->fill($datafamily); $personfamily->guesthistory()->associate($guesthistory); $personfamily->save(); } foreach ($data_vehicle as $datavehicle) { $vechicle = new \App\Models\Vehicle(); $vechicle->fill($datavehicle); $vechicle->guesthistory()->associate($guesthistory); $vechicle->save(); } foreach ($data_child as $child) { $datachild = new DataChild(); $datachild->fill($child); $datachild->guesthistory()->associate($guesthistory); $datachild->save(); } foreach ($address_office as $data_office) { $addressoffice = new AddressOffice(); $addressoffice->fill($data_office); $addressoffice->guesthistory()->associate($guesthistory); $addressoffice->save(); } Event::fire(new AddDataPersonGeneralEvent($guesthistory)); return $guesthistory; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $guesthistory = GuestHistory::find($id); Event::fire(new DeleteDataPersonGeneralEvent($guesthistory)); $dataspouse = $guesthistory->dataspouse; $datamother = $guesthistory->datamother; $datafather = $guesthistory->datafather; $datapresentaddress = $guesthistory->addresspresent; $dataoriginaladdress = $guesthistory->addressoriginal; foreach ($guesthistory->vehicle as $vehicle) { $vehicleId = $vehicle->id; Vehicle::find($vehicleId)->delete(); } foreach ($guesthistory->datachild as $datachild) { $datachildId = $datachild->id; DataChild::find($datachildId)->delete(); } foreach ($guesthistory->employee as $employee) { $employeeId = $employee->id; Employee::find($employeeId)->delete(); } foreach ($guesthistory->personfamily as $personfamily) { $personfamilyId = $personfamily->id; PersonFamily::find($personfamilyId)->delete(); } if ($guesthistory) { GuestHistory::find($id)->delete(); } if ($dataspouse) { $spouseId = $dataspouse->id; DataSpouse::find($spouseId)->delete(); } if ($datamother) { $motherId = $datamother->id; DataMother::find($motherId)->delete(); } if ($datafather) { $fatherId = $datafather->id; DataFather::find($fatherId)->delete(); } if ($datapresentaddress) { $presentId = $datapresentaddress->id; AddressPresent::find($presentId)->delete(); } if ($dataoriginaladdress) { $original = $dataoriginaladdress->id; AddressOriginal::find($original)->delete(); } return $guesthistory; }
?> <?php echo $form->field($model, 'zip_code')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'email')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'phone')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'vehicle_id')->dropDownList(Vehicle::getVehicleList()); ?> <?php echo $form->field($model, 'vehicle_year')->textInput(['maxlength' => 4]); ?> <?php echo $form->field($model, 'vehicle_color_id')->dropDownList(VehicleColors::listData()); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($personId, $vehicleId) { $person = GuestHistory::find($personId); if ($vehicleId) { $vehicle = Vehicle::find($vehicleId)->delete(); return $person; } else { return null; } }
/** * @return \yii\db\ActiveQuery */ public function getVehicle() { return $this->hasOne(Vehicle::className(), ['id' => 'vehicle_id']); }
/** * Deletes an existing Vehicle model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $this->findModel(Vehicle::className(), $id)->delete(); return $this->redirect(['index']); }
protected function addControls() { $this->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.comboboxes.combobox')->name('fleet_type')->caption('Tip Flota Auto')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('fleet_type')->controltype('combobox')->options(\App\Models\Vehicle::fleet()))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('vehicle_type')->caption('Tip Vehicol')->class('form-control data-source')->controlsource('vehicle_type')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('license_plate_number')->caption('Numar De Inmatriculare')->class('form-control data-source')->controlsource('license_plate_number')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.comboboxes.combobox')->name('property_type')->caption('Tip Propietate')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('property_type')->controltype('combobox')->options(\App\Models\Vehicle::property()))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.comboboxes.combobox')->name('fuel_type')->caption('Tip Combustibil Utilizat')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('fuel_type')->controltype('combobox')->options(\App\Models\Vehicle::fuel()))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('capacity_cm3')->caption('Capacitate Cilindrica Cm3')->class('form-control data-source')->controlsource('capacity_cm3')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('year_of_manufacture')->caption('An Fabricatie')->class('form-control data-source')->controlsource('year_of_manufacture')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.comboboxes.combobox')->name('function_type')->caption('Tip Functiune')->class('form-control data-source input-group form-select init-on-update-delete')->controlsource('function_type')->controltype('combobox')->options(\App\Models\Vehicle::functions()))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('internal_consumption')->caption('Consum Mediu Intern')->class('form-control data-source')->controlsource('internal_consumption')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('external_consumption')->caption('Consum Mediu Extern')->class('form-control data-source')->controlsource('external_consumption')->controltype('textbox')->maxlength(255))->addControl(\Easy\Form\Textbox::make('~layouts.form.controls.textboxes.textbox')->name('mixed_consumption')->caption('Consum Mediu Mixt')->class('form-control data-source')->controlsource('mixed_consumption')->controltype('textbox')->maxlength(255)); }
/** * Finds the Vehicle model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Vehicle the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Vehicle::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { // return Input::all(); $caseFile = Input::get('caseFile'); $person = Input::get('person'); $name_father = Input::get('person.datafather.father_name'); $surname_father = Input::get('person.datafather.father_surname'); $name_mother = Input::get('person.datamother.mother_name'); $surname_mother = Input::get('person.datamother.mother_surname'); $name_spouse = Input::get('person.dataspouse.spouse_name'); $surname_spouse = Input::get('person.dataspouse.spouse_surname'); $present_address = Input::get('person.addresspresent.present_address'); $original_address = Input::get('person.addressoriginal.original_address'); if ($present_address != null) { $addresspresent = new AddressPresent(); $addresspresent->fill(Input::get('person.addresspresent')); $addresspresent->save(); } if ($original_address != null) { $addressoriginal = new AddressOriginal(); $addressoriginal->fill(Input::get('person.addressoriginal')); $addressoriginal->save(); } if ($name_mother != null || $surname_mother != null) { $datamother = new DataMother(); $datamother->fill(Input::get('person.datamother')); $datamother->save(); } if ($name_father != null || $surname_father != null) { $datafather = new DataFather(); $datafather->fill(Input::get('person.datafather')); $datafather->save(); } if ($name_spouse != null || $surname_spouse != null) { $dataspouse = new DataSpouse(); $dataspouse->fill(Input::get('person.dataspouse')); if (Input::has('person.dataspouse.nametitle.id')) { $nametitle = NameTitle::find(Input::get('person.dataspouse.nametitle.id')); $dataspouse->nametitle()->associate($nametitle); } $dataspouse->save(); } $criminalhistory = new CriminalHistory(); //$criminalhistory->fill(Input::except(["person.data_casefile","person.addressoffice","person.datachild"])); $criminalhistory->fill($person); if ($datamother != null) { $criminalhistory->datamother()->associate($datamother); } if ($datafather != null) { $criminalhistory->datafather()->associate($datafather); } if ($dataspouse != null) { $criminalhistory->dataspouse()->associate($dataspouse); } if ($addressoriginal != null) { $criminalhistory->addressoriginal()->associate($addressoriginal); } if ($addresspresent != null) { $criminalhistory->addresspresent()->associate($addresspresent); } if (Input::has('person.nametitle.id')) { $nametitle = NameTitle::find(Input::get('person.nametitle.id')); $criminalhistory->nametitle()->associate($nametitle); } $criminalhistory->save(); $addressoffice = Input::get('person.addressoffice'); $datachild = Input::get('person.datachild'); foreach ($addressoffice as $data_office) { $office = new AddressOffice(); $office->fill($data_office); $office->criminalhistory()->associate($criminalhistory); $office->save(); } foreach ($datachild as $data_child) { $child = new DataChild(); $child->fill($data_child); $child->criminalhistory()->associate($criminalhistory); $child->save(); } $name_case = Input::get('caseFile.name_case'); $circumstances_case = Input::get('caseFile.circumstances_case'); if ($name_case != null || $circumstances_case != null) { $datacase = new DataCase(); $datacase->fill($caseFile); $datacase->save(); $datacase->criminalhistory()->attach($criminalhistory); $data_vehicle = Input::get('caseFile.vehicle'); $data_weapon = Input::get('caseFile.weapon'); foreach ($data_vehicle as $datavehicle) { $vechicle = new Vehicle(); $vechicle->fill($datavehicle); $vechicle->datacase()->associate($datacase); $vechicle->save(); } foreach ($data_weapon as $dataweapon) { $weapom = new Weapon(); $weapom->fill($dataweapon); $weapom->datacase()->associate($datacase); $weapom->save(); } } Event::fire(new AddDataPersonCrimeEvent($criminalhistory)); return $criminalhistory; }
/** * Creates a new Bill model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Bill(); if (Yii::$app->session['carPartTotal'] <= 0.0) { return; } if (isset($_POST['mode'], $_POST['discount'])) { $result = []; if ($_POST['mode'] == 0 || $_POST['mode'] == 1) { $transaction = $model->getDb()->beginTransaction(); try { $discount = (double) $_POST['discount']; if ($discount > Yii::$app->session['carPartTotal']) { $discount = 0.0; } $modelPrice = new Price(); $modelPrice->price = (double) Yii::$app->session['carPartTotal'] - (double) $discount; $modelPrice->calculate(); if (!$modelPrice->save(false)) { throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($modelPrice->tableName())), 'msj' => print_r($modelPrice->getErrors(), true)]), 500); } $model->price_id = $modelPrice->id; $model->discount = $discount; if (isset($_POST['draft']) && !empty($_POST['draft'])) { $model->draft = 1; } if (isset($_POST['Vehicle'])) { $vehicle = new Vehicle(); $vehicle->attributes = $_POST['Vehicle']; if (!empty($vehicle->brand) || !empty($vehicle->model) || !empty($vehicle->color) || !empty($vehicle->plaque)) { if (!$vehicle->save(false)) { throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($vehicle->tableName())), 'msj' => print_r($vehicle->getErrors(), true)]), 500); } $model->vehicle_id = $vehicle->id; } } if (isset($_POST['Customer'])) { $customer = new Customer(); $customer->attributes = $_POST['Customer']; if (!empty($customer->name) || !empty($customer->serial)) { if (!$customer->save(false)) { throw new Exception(Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($customer->tableName())), 'msj' => print_r($customer->getErrors(), true)]), 500); } $model->customer_id = $customer->id; } } if ($model->save()) { $result['message'] = Yii::t('app', '{modelClass} saved', ['modelClass' => Yii::t('app', ucfirst($model->tableName()))]); } else { $result['message'] = Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($model->tableName())), 'msj' => print_r($model->errors, true)]); } $transaction->commit(); } catch (\Exception $e) { $transaction->rollBack(); $result['message'] = Yii::t('app', 'Error saving {model}: {msj}', ['model' => Yii::t('app', ucfirst($model->tableName())), 'msj' => $e]); } } echo json_encode($result); } else { if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($caseId, $vehicleId) { $datacase = DataCase::find($caseId); if ($vehicleId) { $vehicle = Vehicle::find($vehicleId)->delete(); return $datacase; } else { return null; } }