public function edit_help($user)
 {
     switch ($user->type) {
         case 'customer':
             Customer::where('id', '=', $user->id)->delete();
             break;
         case 'driver':
             Driver::where('id', '=', $user->id)->delete();
             break;
         case 'business':
             Business::where('id', '=', $user->id)->delete();
             break;
         default:
             break;
     }
     $user->type = Input::get('type');
     $user->save();
     switch (Input::get('type')) {
         case 'driver':
             $driver = new Driver();
             $driver->id = $user->id;
             $driver->first_name = Input::get('first_name');
             $driver->last_name = Input::get('last_name');
             $driver->phone = Input::get('phone');
             $driver->home_address = Input::get('address');
             $driver->credit_card = Input::get('credit_card');
             $driver->cvv = Input::get('cvv');
             $driver->expiry_date = Input::get('expiry_date');
             $driver->car_type = Input::get('car_type');
             $driver->cab_no = Input::get('cab_no');
             $driver->flag = Input::get('flag');
             $driver->rate = Input::get('rate');
             $driver->hour = Input::get('hour');
             $driver->save();
             break;
         case 'customer':
             $customer = new Customer();
             $customer->id = $user->id;
             $customer->first_name = Input::get('first_name');
             $customer->last_name = Input::get('last_name');
             $customer->phone = Input::get('phone');
             $customer->home_address = Input::get('address');
             $customer->credit_card = Input::get('credit_card');
             $customer->cvv = Input::get('cvv');
             $customer->expiry_date = Input::get('expiry_date');
             $customer->save();
             break;
         case 'business':
             $business = new Business();
             $business->id = $user->id;
             $business->business_name = Input::get('business_name');
             $business->phone = Input::get('phone');
             $business->home_address = Input::get('address');
             $business->credit_card = Input::get('credit_card');
             $business->cvv = Input::get('cvv');
             $business->expiry_date = Input::get('expiry_date');
             $business->save();
             break;
     }
 }
示例#2
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
 }
 public function getPayments()
 {
     $to = Input::get('to');
     $from = Input::get('from');
     if ($from == null || $to == null) {
         $today = LocationController::getTime();
         $todayFrom = $today['date'] . ' 00:00:00';
         $todayTo = $today['date'] . ' 23:59:59';
     } else {
         $todayFrom = $from . ' 00:00:00';
         $todayTo = $to . ' 23:59:59';
     }
     try {
         $results = Payment::where('created_at', '>', $todayFrom)->where('created_at', '<', $todayTo)->get()->toArray();
         if (!is_null($results)) {
             foreach ($results as $key => $payment) {
                 $driver = Driver::where('id', '=', $payment['driver_id'])->first()->toArray();
                 $currency = Currency::find($payment['currency'])->pluck('currency');
                 $results[$key]['driver_name'] = $driver['first'] . ' ' . $driver['last'];
                 $results[$key]['currency'] = $currency;
             }
         }
         $queries = DB::getQueryLog();
         $last_query = end($queries);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
     }
     //\Log::info(__METHOD__.print_r($results, 1));
     return json_encode($results);
 }
示例#4
0
 public function get_getDriver()
 {
     $q = Input::get('query');
     $driver = Driver::where('driver_status', '=', 1)->where('pool_id', '=', Auth::user()->pool_id)->where('nip', 'like', '%' . $q . '%')->or_where('name', 'like', '%' . $q . '%')->get();
     $data = array();
     foreach ($driver as $k) {
         $data[] = array('id' => $k->id, 'nip' => $k->nip, 'name' => $k->name);
     }
     return json_encode($data);
 }
示例#5
0
 public function issueFine()
 {
     $input = Input::json();
     //latitude and longitude details
     $latitude = $input->get('latitude');
     $longitude = $input->get('longitude');
     $signature = $input->get('signature');
     if ($signature) {
         $signature_path = $this->saveimage($signature);
     }
     //fined by user
     $officer_data = $input->get('finedby');
     $finedata = $input->get('fine');
     $fines_name = $finedata['fines'];
     $info = $finedata['info'];
     $vehicle_vin = $info['vehiclevin'];
     $driver_id = $info['driver']['driver_id'];
     //GROUP ALL FINES NAME ACCORDING TO USER TYPE
     foreach ($fines_name as $names) {
         $data[$names['type']][] = $names['name']['id'];
         $fine_names[$names['type']][] = $names['name']['name'];
     }
     $today = date('mdY');
     //save vehicle and get its ID
     $sequence = VehicleTemp::orderBy('id', 'DESC')->first();
     $sequence_id = $sequence->id + 1001;
     $temp_no = "TEMP-" . $today . "-" . $sequence_id;
     $vehicletemp['vehicles_vin'] = $vehicle_vin;
     $vehicletemp['temp_registration_num'] = $temp_no;
     $vehicle = VehicleTemp::create($vehicletemp);
     $vehicle_id = $vehicle->id;
     //fine to vehicle
     $registartion_num = $vehicle->temp_registration_num;
     if (array_key_exists('vehicle', $data)) {
         $vehiclefine_ids = $data['vehicle'];
         $vehiclefine = $fine_names['vehicle'];
         //check if we have vehicle violations names
         $fine_id = $vehiclefine_ids;
         $fines_all = VehicleFine::whereIn('id', $fine_id)->get();
         $fine = VehicleFine::find($fine_id[0]);
         $sequence = ViolateVehicleTemp::orderBy('id', 'DESC')->first();
         $sequence_id = $sequence->id + 1001;
         //citation number
         $citaion_number = "TEMP-" . $fine->vehicle_violation_code . '-' . $today . '-' . $officer_data['badge_id_number'] . '-' . $sequence_id;
         //SAVE FINES FOR DRIVERS
         foreach ($fine_id as $id) {
             //echo $id;
             $fineinfo['driver_id'] = $driver_id;
             $fineinfo['temp_vehicle_id'] = $vehicle_id;
             $fineinfo['vehicle_fine_id'] = $id;
             $fineinfo['vehicle_fine_unique_id'] = $citaion_number;
             $fineinfo['officer_id'] = $officer_data['badge_id_number'];
             $fineinfo['longitude'] = $longitude;
             $fineinfo['latitude'] = $latitude;
             $fineinfo['status'] = '2';
             $saved_fine = ViolateVehicleTemp::create($fineinfo);
         }
         if ($signature) {
             //type 1 for vehicle signature type fine
             $data_signature['fine_id'] = $saved_fine->id;
             $data_signature['type'] = 'temp_1';
             $data_signature['signature'] = $signature;
             $data_signature['path'] = $signature_path;
             DB::table('signature')->insert($data_signature);
         }
         //SEND EMAIL HERE
         $title = "New traffic citation: non-registered vehicle";
         $temp_registartion_id = $vehicle->temp_registration_num;
         $amount = array_sum(VehicleFine::whereIn('id', $fine_id)->lists('vehicle_fine_ammount'));
         $drivers_email = Driver::where('id', $driver_id)->lists('drivers_email');
         $driver = Driver::where('id', $driver_id)->first()->toArray();
         $sender = array_unique($drivers_email);
         $data_array = array('registration_number' => $temp_registartion_id, 'fine_descp' => $vehiclefine, 'citation_num' => $citaion_number, 'amount' => $amount, 'driver' => $driver);
         if (array_key_exists('vehicle', $data) and array_key_exists('driver', $data)) {
             //check if both fines are issued
             $email_data_both['sender'] = $sender;
             $email_data_both['data_vehicle'] = $data_array;
             $email_data_both['sms_vehicle'] = "New traffic fine Citation#:" . $citaion_number . " Driver: " . $driver['drivers_fname'] . " " . $driver['drivers_lname'] . " Reg#:" . $temp_registartion_id . " Amount:" . $amount . " Pay fines at GRA location.";
         } else {
             $sent = Mail::send('emails.temp', $data_array, function ($message) use($title, $sender, $signature_path) {
                 $message->to($sender)->subject($title);
                 $message->attach($signature_path);
             });
             $template = "New traffic fine Citation#:" . $citaion_number . " Driver: " . $driver['drivers_fname'] . " " . $driver['drivers_lname'] . " Reg#:" . $temp_registartion_id . " Amount:" . $amount . " Pay fines at GRA location.";
             $to = $driver['drivers_isd1'] . $driver['drivers_cell1'];
             Helpers::SendSms($to, $template);
         }
         $vehicle_fine_amount = $amount;
         $printer_data_vehicle['citation_number'] = $citaion_number;
         $printer_data_vehicle['fines'] = $fines_all;
         $printer_data_vehicle['offender'] = $driver;
     }
     //fine to driver
     if (array_key_exists('driver', $data)) {
         $driverfines_id = $data['driver'];
         $fine_id = $driverfines_id;
         $fines_all = DriverFine::whereIn('id', $fine_id)->get();
         $fine = DriverFine::find($fine_id[0]);
         $sequence = ViolateDriverTemp::orderBy('id', 'DESC')->first();
         $sequence_id = $sequence->id + 1001;
         //citation number
         $citaion_number = "TEMP-" . $fine->driver_violation_code . '-' . $today . '-' . $officer_data['badge_id_number'] . '-' . $sequence_id;
         //SAVE FINES FOR DRIVERS
         foreach ($fine_id as $id) {
             $fineinfo['driver_id'] = $driver_id;
             $fineinfo['temp_vehicle_id'] = $vehicle_id;
             $fineinfo['driver_fine_id'] = $id;
             $fineinfo['driver_fine_unique_id'] = $citaion_number;
             $fineinfo['officer_id'] = $officer_data['badge_id_number'];
             $fineinfo['longitude'] = $longitude;
             $fineinfo['latitude'] = $latitude;
             $fineinfo['status'] = '2';
             $saved_fine = ViolateDriverTemp::create($fineinfo);
         }
         if ($signature) {
             //type 0 for driver signature type fine
             $data_signature['fine_id'] = $saved_fine->id;
             $data_signature['type'] = 'temp_0';
             $data_signature['signature'] = $signature;
             $data_signature['path'] = $signature_path;
             DB::table('signature')->insert($data_signature);
         }
         //email here
         $title = "New traffic citation: non-registered vehicle";
         $registration_number = $vehicle->temp_registration_num;
         $driverfines = $fine_names['driver'];
         $amount = array_sum(DriverFine::whereIn('id', $fine_id)->lists('driver_fine_ammount'));
         $drivers_email = Driver::where('id', $driver_id)->lists('drivers_email');
         $driver = Driver::where('id', $driver_id)->first();
         $sender = array_unique($drivers_email);
         $data_email_array = array('registration_number' => $registration_number, 'fine_descp' => $driverfines, 'citation_num' => $citaion_number, 'amount' => $amount, 'driver' => $driver);
         if (array_key_exists('vehicle', $data) and array_key_exists('driver', $data)) {
             //check if both  fine type issued
             $email_data_both['driver_data'] = $data_email_array;
             $email_data_both['sms_driver'] = "New traffic fine Citation#:" . $citaion_number . " Driver: " . $driver->drivers_fname . " " . $driver->drivers_lname . " Reg#:" . $registration_number . " Amount:" . $amount . " Pay fines at GRA location.";
         } else {
             $sent = Mail::send('emails.temp', $data_email_array, function ($message) use($title, $sender, $signature_path) {
                 $message->to($sender)->subject($title);
                 $message->attach($signature_path);
             });
             $template = "New traffic fine Citation#:" . $citaion_number . " Driver: " . $driver->drivers_fname . " " . $driver->drivers_lname . " Reg#:" . $registration_number . " Amount:" . $amount . " Pay fines at GRA location.";
             $to = $driver->drivers_isd1 . $driver->drivers_cell1;
             Helpers::SendSms($to, $template);
         }
         $driver_fine_amount = $amount;
         $printer_data_driver['citation_number'] = $citaion_number;
         $printer_data_driver['fines'] = $fines_all;
         $printer_data_driver['offender'] = $driver;
     } else {
         $printer_data_driver = null;
     }
     if (isset($email_data_both)) {
         //print_r($email_data_both);
         Helpers::smsemailTemp($driver->drivers_cell1, $email_data_both, $signature_path);
     }
     //error handling for fines
     if (!isset($driver_fine_amount)) {
         $driver_fine_amount = 0;
     }
     if (!isset($vehicle_fine_amount)) {
         $vehicle_fine_amount = 0;
     }
     $total_amount = $vehicle_fine_amount + $driver_fine_amount;
     $success = array('driver' => $printer_data_driver, 'vehicle' => $printer_data_vehicle, 'reg' => $registartion_num, 'amount' => $total_amount);
     Helpers::response_data('200', 'Success', $success);
 }
示例#6
0
 public function post_otorisasipusat()
 {
     $nip = Input::get('nip');
     $this->data['drivers'] = Driver::where('nip', 'LIKE', '%' . $nip . '%')->where('fg_super_blocked', '=', 1)->order_by('nip', 'asc')->paginate(20);
     return View::make('themes.modul.' . $this->views . '.otorisasipusat', $this->data);
 }
 public function replaceCar()
 {
     $newCarId = Input::get('new_car_id');
     try {
         $userId = Session::get('user_id');
         $driver = Driver::where('user_id', '=', $userId)->firstOrFail();
         $driver->car_id = $newCarId;
         $driver->save();
         Session::set('car_id', $newCarId);
         $newCar = Cars::find($newCarId);
         $results = array('success' => true, 'message' => 'New Car assigned.', 'new_car' => $newCar);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
         $results = array('success' => false, 'message' => 'an error occurred');
     }
     return $results;
 }