Beispiel #1
0
 /**
  * Creates a new session
  *
  * @return boolean
  */
 public function create()
 {
     // reset the data containers
     $this->reset();
     // and create a new session
     return $this->driver->create();
 }
Beispiel #2
0
 public function adddriver()
 {
     $input = Input::json();
     $authorized_license_no = $input->get('dlic');
     $authorized_status = Driver::where('drivers_license_no', $authorized_license_no)->count();
     //print_r($input);
     if ($authorized_status == NULL) {
         $country_id = DB::table('countries')->where('country_name', $input->get('country'))->first()->id;
         $status_id = DB::table('driving_status')->where('driving_status_name', $input->get('status'))->first()->id;
         $authorized_info['drivers_fname'] = $input->get('fname');
         $authorized_info['drivers_mname'] = $input->get('mname');
         $authorized_info['drivers_lname'] = $input->get('lname');
         $authorized_info['drivers_nin'] = $input->get('nin');
         $authorized_info['drivers_license_no'] = $input->get('dlic');
         $authorized_info['drivers_street'] = $input->get('street');
         $authorized_info['drivers_city'] = $input->get('city');
         $authorized_info['drivers_po_box'] = $input->get('po');
         $authorized_info['drivers_country'] = $country_id;
         $authorized_info['drivers_cell1'] = $input->get('cell1');
         $authorized_info['drivers_cell2'] = $input->get('cell2');
         $authorized_info['drivers_email'] = $input->get('email');
         $authorized_info['drivers_driving_status'] = $status_id;
         $insert_authorized_into_driver_table = Driver::create($authorized_info);
         $authorized_ids = $insert_authorized_into_driver_table->id;
         $driver_name = $insert_authorized_into_driver_table->drivers_fname . ' ' . $insert_authorized_into_driver_table->drivers_lname;
     } else {
         $driver = Driver::where('drivers_license_no', $authorized_license_no)->first();
         $authorized_ids = $driver->id;
         $driver_name = $driver->drivers_fname . ' ' . $driver->drivers_lname;
     }
     $info = array('driver_id' => $authorized_ids, 'name' => $driver_name);
     //send driver id in response
     Helpers::response_data('200', 'success', $info);
 }
Beispiel #3
0
 public function changeOwnerUpdate($id)
 {
     // FIND OLD VEHICLE AND CREATE RESPECTIVE LOGS
     $oldVehicle = Vehicle::find($id);
     /*
     	// IF VEHICLE STATUS IS CHANGED, ADD OLD STATUS IN LOG AND UPDATE DATA
     	if($oldVehiclesStatus != $newVehiclesStatus){
     		LogVehicleStatus::create(['log_vehicle_status_vehicle_id' => $id, 'log_vehicle_status_vehicle_status_id' => $oldVehiclesStatus]);
     	}
     
     	// IF VEHICLE COLOR IS CHANGED, ADD OLD COLOR IN LOG AND UPDATE DATA
     	if($oldvehicleColor != $newVehicleColor){
     		LogVehicleColor::create(['log_vehicle_color_vehicle_id' => $id, 'log_vehicle_color_color_id' => $oldvehicleColor]);
     	}
     
     	// IF VEHICLE USE TYPE IS CHANGED, ADD OLD USE TYPE IN LOG AND UPDATE DATA
     	if($oldVehicleUseType != $newVehicleUseType){
     		$oldRegistrations_no = $oldVehicle->registration->registrations_no;
     		LogVehicleUseType::create(['log_vehicle_use_type_vehicle_id' => $id, 'log_vehicle_use_type_use_type' => $oldVehicleUseType, 'log_vehicle_use_type_registration_no' => $oldRegistrations_no]);
     	}
     
     *
     	// TAKE LOG OF ODOMETER
     	$vehicles_odometer = trim(Input::get('vehicles_odometer'));
     	$oldOdometer = Vehicle::find($id)->vehicles_odometer;
     	LogVehicleOdometer::create(['log_vehicle_odometer_vehicle_id' => $id, 'log_vehicle_odometer_old_odometer' => $oldOdometer]);
     */
     //VEHICLE DATA
     $vehicles_year = trim(Input::get('vehicles_year'));
     $vehicles_make_id = trim(Input::get('vehicles_make_id'));
     $vehicles_name_trim = trim(Input::get('vehicles_name_trim'));
     $vehicles_name_trim_ar = explode(',', $vehicles_name_trim);
     $model_name = trim($vehicles_name_trim_ar[0]);
     if (count($vehicles_name_trim_ar) > 1) {
         $model_trim = trim($vehicles_name_trim_ar[1]);
     } else {
         $model_trim = "";
     }
     $vehicles_body = trim(Input::get('vehicles_body'));
     if ($vehicles_body == -1) {
         $vehicles_body = "";
     }
     $vehicles_weight_kg = trim(Input::get('vehicles_weight_kg'));
     // BEGIN VEHICLE
     // IF VEHICLE BODY IS NOT BLANK THEN ADD BODY, ELSE IGNORE IT TO MAKE IT NULL
     if ($vehicles_body != "") {
         $vehicle = Input::only(['vehicles_vin', 'vehicles_year', 'vehicles_make_id', 'vehicles_name_trim', 'vehicles_body', 'vehicles_weight_kg', 'vehicles_use_type', 'vehicles_use_type', 'vehicles_class', 'vehicles_color', 'vehicles_status', 'vehicles_odometer']);
     } else {
         $vehicle = Input::only(['vehicles_vin', 'vehicles_year', 'vehicles_make_id', 'vehicles_name_trim', 'vehicles_weight_kg', 'vehicles_use_type', 'vehicles_use_type', 'vehicles_class', 'vehicles_color', 'vehicles_status', 'vehicles_odometer']);
     }
     //$validator_vehicle = Validator::make($vehicle, Vehicle::$rules);
     //if($validator_vehicle->passes()){
     // GETTING AND ADDING MODEL ID
     // IF BODY IS NULL
     if ($vehicles_body == "") {
         // GETTING MODEL
         $vehicle['vehicles_model_id'] = Model::where('model_year', $vehicles_year)->where('model_make_id', $vehicles_make_id)->where('model_name', $model_name)->where('model_trim', $model_trim)->whereNull('model_body')->first()->id;
     } else {
         $vehicle['vehicles_model_id'] = Model::where('model_year', $vehicles_year)->where('model_make_id', $vehicles_make_id)->where('model_name', $model_name)->where('model_trim', $model_trim)->where('model_body', $vehicles_body)->first()->id;
     }
     // INSERT VEHICLE DATA AND GET ID
     $vehicle_inserted_id = Vehicle::create($vehicle)->id;
     //}else
     //	return Redirect::route('vehicle.create')->withErrors($validator_vehicle)->withInput();
     // END VEHICLE
     // ASSOCTIATE NEW VEHICLE AND THEN DELETE OLD VEHICLE DATA
     $old_vehicle = Vehicle::find($id);
     // ASSOCIATE NEW VEHICLE WITH OLD VEHICLE
     $old_vehicle->update(['vehicles_transfer' => $vehicle_inserted_id]);
     // DELETE INSURANCE
     if ($old_vehicle->insurance) {
         $old_vehicle->insurance->delete();
     }
     // DELETE LIEN
     if ($old_vehicle->lien) {
         $old_vehicle->lien->delete();
     }
     // DELETE REGISTRATION
     $old_vehicle->registration->delete();
     // DELETE VEHICLE
     $old_vehicle->delete();
     // BEGIN OWNERS
     $owners_index = Input::get('owners_index');
     $owners_index_arr = array_filter(explode(',', $owners_index));
     // LOOP THROUGH EACH OWNER AND ASSOCIATE WITH DRIVERS
     foreach ($owners_index_arr as $owners_index_id) {
         $drivers_license_no = Input::get('drivers_license_no' . $owners_index_id);
         if (trim($drivers_license_no) != "") {
             $drivers_status = Driver::where('drivers_license_no', $drivers_license_no)->first();
             // IF DRIVER DOESN'T EXISTS, CREATE DRIVER
             if ($drivers_status == NULL) {
                 $owner_info['drivers_fname'] = Input::get('drivers_fname' . $owners_index_id);
                 $owner_info['drivers_mname'] = Input::get('drivers_mname' . $owners_index_id);
                 $owner_info['drivers_lname'] = Input::get('drivers_lname' . $owners_index_id);
                 $owner_info['drivers_nin'] = Input::get('drivers_nin' . $owners_index_id);
                 $owner_info['drivers_license_no'] = Input::get('drivers_license_no' . $owners_index_id);
                 $owner_info['drivers_street'] = Input::get('drivers_street' . $owners_index_id);
                 $owner_info['drivers_city'] = Input::get('drivers_city' . $owners_index_id);
                 $owner_info['drivers_po_box'] = Input::get('drivers_po_box' . $owners_index_id);
                 $owner_info['drivers_country'] = Input::get('drivers_country' . $owners_index_id);
                 $owner_info['drivers_cell1'] = Input::get('drivers_cell1' . $owners_index_id);
                 $owner_info['drivers_cell2'] = Input::get('drivers_cell2' . $owners_index_id);
                 $owner_info['drivers_email'] = Input::get('drivers_email' . $owners_index_id);
                 $owner_info['drivers_driving_status'] = Input::get('drivers_driving_status' . $owners_index_id);
                 $insert_owner_into_driver_table = Driver::create($owner_info);
                 $owner_ids[] = $insert_owner_into_driver_table->id;
             } else {
                 $owner_ids[] = Driver::where('drivers_license_no', $drivers_license_no)->first()->id;
             }
         }
     }
     // LINK VEHICLE WITH OWNERS
     if (!empty($owner_ids)) {
         foreach ($owner_ids as $owner_ids_fet) {
             $owner_ids_fet = (int) $owner_ids_fet;
             //VehicleDriverOwner::create(['vehicle_driver_owners_vehicle_id' => $vehicle_inserted_id, 'vehicle_driver_owners_driver_id' => $owner_ids_fet]);
             Vehicle::find($vehicle_inserted_id)->owners()->attach($owner_ids_fet);
         }
     }
     // END OWNERS
     //BEGIN AUTHORIZED DRIVERS
     $authorized_index = Input::get('authorized_index');
     // IF AUTHORIZED DRIVERS EXIST, ASSOCIATE WITH DRIVERS.(CHECKING USING LICENSE)
     if ($authorized_index != "") {
         $authorized_index_arr = explode(',', $authorized_index);
         foreach ($authorized_index_arr as $authorized_index_id) {
             $authorized_license_no = Input::get('authorized_license_no' . $authorized_index_id);
             $authorized_status = Driver::where('drivers_license_no', $authorized_license_no)->first();
             //IF DRIVER DOESN'T EXISTS, CREATE DRIVER
             if ($authorized_status == NULL) {
                 $authorized_info['drivers_fname'] = Input::get('authorized_fname' . $authorized_index_id);
                 $authorized_info['drivers_mname'] = Input::get('authorized_mname' . $authorized_index_id);
                 $authorized_info['drivers_lname'] = Input::get('authorized_lname' . $authorized_index_id);
                 $authorized_info['drivers_nin'] = Input::get('authorized_nin' . $authorized_index_id);
                 $authorized_info['drivers_license_no'] = Input::get('authorized_license_no' . $authorized_index_id);
                 $authorized_info['drivers_street'] = Input::get('authorized_street' . $authorized_index_id);
                 $authorized_info['drivers_city'] = Input::get('authorized_city' . $authorized_index_id);
                 $authorized_info['drivers_po_box'] = Input::get('authorized_po_box' . $authorized_index_id);
                 $authorized_info['drivers_country'] = Input::get('authorized_country' . $authorized_index_id);
                 $authorized_info['drivers_cell1'] = Input::get('authorized_cell1' . $authorized_index_id);
                 $authorized_info['drivers_cell2'] = Input::get('authorized_cell2' . $authorized_index_id);
                 $authorized_info['drivers_email'] = Input::get('authorized_email' . $authorized_index_id);
                 $authorized_info['drivers_driving_status'] = Input::get('authorized_driving_status' . $authorized_index_id);
                 $insert_authorized_into_driver_table = Driver::create($authorized_info);
                 $authorized_ids[] = $insert_authorized_into_driver_table->id;
             } else {
                 $authorized_ids[] = Driver::where('drivers_license_no', $authorized_license_no)->first()->id;
             }
         }
         // LINK VEHICLE WITH AUTHORIZED DRIVERS
         foreach ($authorized_ids as $authorized_ids_fet) {
             $authorized_ids_fet = (int) $authorized_ids_fet;
             //VehicleDriverAuthorized::create(['vehicle_driver_authorized_vehicle_id' => $vehicle_inserted_id, 'vehicle_driver_authorized_driver_id' => $authorized_ids_fet]);
             Vehicle::find($vehicle_inserted_id)->authorizedDrivers()->attach($authorized_ids_fet);
         }
     }
     // END AUTHORIZED DRIVERS
     // BEGIN INSURANCE
     if (Input::get('insurances_company') != "") {
         $insurance_arr = new Insurance(Input::only('insurances_company', 'insurances_policy_no', 'insurances_exp_date', 'insurances_agent_fname', 'insurances_agent_lname', 'insurances_agent_cell', 'insurances_agent_city', 'insurances_agent_email'));
         //$insurance_arr['insurances_vehicle_id'] = $vehicle_inserted_id;
         //Insurance::create($insurance_arr);
         Vehicle::find($vehicle_inserted_id)->insurance()->save($insurance_arr);
     }
     // END INSURANCE
     // BEGIN LIEN HOLDER
     if (Input::get('lien_index')) {
         $lien_arr = new Lien(Input::only('liens_collateral_id', 'liens_collateral_value', 'liens_bank_name', 'liens_bank_branch', 'liens_bank_street', 'liens_bank_city'));
         //$lien_arr['liens_vehicle_id'] = $vehicle_inserted_id;
         //Lien::create($lien_arr);
         Vehicle::find($vehicle_inserted_id)->lien()->save($lien_arr);
     }
     // END LIEN HOLDER
     // BEGIN FILES
     $files_col = Input::file();
     $files_count = count(array_filter($files_col['files']));
     // IF FILES EXISTS
     if ($files_count) {
         foreach ($files_col['files'] as $files) {
             $filename_ar = explode('.', $files->getClientOriginalName());
             $document_ext = end($filename_ar);
             $path = public_path() . '/vehicledata/documents';
             // GENERATE RANDOM FILE NAME AND ADD EXTENSION
             $randName = md5(rand() * time());
             $document_name = $randName . '.' . $document_ext;
             // MOVE FILE AND ENTRY INTO DATABASE
             if ($files->move($path, $document_name)) {
                 //Document::create(['documents_vehicle_id' => $vehicle_inserted_id, 'documents_name' => $document_name]);
                 Vehicle::find($vehicle_inserted_id)->documents()->save(new Document(['documents_name' => $document_name]));
             }
         }
     }
     // END FILES
     // BEGIN REGISTRATION
     if (isset($vehicle_inserted_id) && $vehicle_inserted_id != "") {
         $registrations_vehicle_id = $vehicle_inserted_id;
         $registrations_no = Input::get('registrations_no');
         $registrations_licence_plate_no = Input::get('registrations_licence_plate_no');
         if ($registrations_no != "" && $registrations_licence_plate_no != "" && $registrations_vehicle_id != "") {
             $vehicles_use_type = Input::get('vehicles_use_type');
             $vehicles_class = Input::get('vehicles_class');
             if ($vehicles_use_type != "" && $vehicles_class != "") {
                 $vehicles_use_type_table_name = VehicleUseType::find($vehicles_use_type)->vehicle_use_types_table_name;
                 //REGISTRATION FEES
                 $vehicles_class_col_name = $vehicles_use_type_table_name . '_total';
                 $registrations_fees = DB::table($vehicles_use_type_table_name)->find($vehicles_class)->{$vehicles_class_col_name};
                 // INCREMENT REGISTRATION SEQUENCE
                 $vehicles_sequence_col_name = $vehicles_use_type_table_name . '_sequence';
                 $currentSequence = DB::table($vehicles_use_type_table_name)->find($vehicles_class)->{$vehicles_sequence_col_name};
                 $newSequence = $currentSequence + 1;
                 DB::table($vehicles_use_type_table_name)->where('id', $vehicles_class)->update([$vehicles_sequence_col_name => $newSequence]);
                 $registration_ar = compact('registrations_vehicle_id', 'registrations_no', 'registrations_licence_plate_no', 'registrations_fees');
                 //Registration::create($registration_ar);
                 Vehicle::find($vehicle_inserted_id)->registration()->save(new Registration($registration_ar));
                 // TAKE LOGS
                 $newVehiclesStatus = Input::get('vehicles_status');
                 $newVehicleColor = Input::get('vehicles_color');
                 $newVehicleUseType = Input::get('vehicles_use_type');
                 $newVehiclesRegistrationNo = Input::get('registrations_no');
                 $vehicles_odometer = Input::get('vehicles_odometer');
                 LogVehicleStatus::create(['log_vehicle_status_vehicle_id' => $registrations_vehicle_id, 'log_vehicle_status_vehicle_status_id' => $newVehiclesStatus]);
                 LogVehicleColor::create(['log_vehicle_color_vehicle_id' => $registrations_vehicle_id, 'log_vehicle_color_color_id' => $newVehicleColor]);
                 LogVehicleUseType::create(['log_vehicle_use_type_vehicle_id' => $registrations_vehicle_id, 'log_vehicle_use_type_use_type' => $newVehicleUseType, 'log_vehicle_use_type_registration_no' => $newVehiclesRegistrationNo]);
                 LogVehicleOdometer::create(['log_vehicle_odometer_vehicle_id' => $registrations_vehicle_id, 'log_vehicle_odometer_old_odometer' => $vehicles_odometer, 'log_vehicle_odometer_status' => 1]);
                 return Redirect::route('vehicle.print', [$registrations_vehicle_id]);
             }
         }
     } else {
         echo "Nothing is saved because fields are not filled";
         die;
     }
     // END REGISTRATION
 }
Beispiel #4
0
 /**
  * create a new driver instance for current task
  * @return null|static
  * @throws TaskBalancerException
  */
 public function driver()
 {
     $args = func_get_args();
     if (!count($args)) {
         throw new TaskBalancerException('Please give task`s method `driver` some args');
     }
     extract($this->parseDriverArgs($args));
     if (!$name) {
         throw new TaskBalancerException('Please give the new driver a unique name!');
     }
     $driver = $this->getDriver($name);
     if (!$driver) {
         $this->callHookHandler('beforeCreateDriver');
         $driver = Driver::create($this, $name, $weight, $isBackup, $work);
         $this->drivers[$name] = $driver;
         if ($isBackup) {
             $this->backupDrivers[] = $name;
         }
         $this->callHookHandler('afterCreateDriver');
     }
     return $driver;
 }