File manager - Edit - /home/autoph/public_html/tasks/Controllers.tar
Back
CompanyController.php 0000644 00000001024 15025116253 0010724 0 ustar 00 <?php namespace App\Controllers; use App\Core\Controller; use App\Core\Sms; use App\Utilities\Session; use App\Utilities\Uuid; use App\Utilities\Utility; class CompanyController extends Controller { private $company; function __construct() { $this->company = new \App\Models\Company; } public function userCompanies() { $ids = implode(",", Session::get('company_permissions')); $response = $this->company->getUserAccessCompany($ids); response()->json($response); } } LtoController.php 0000644 00000127050 15025116253 0010064 0 ustar 00 <?php namespace App\Controllers; use App\Core\Controller; use App\Core\Sms; use App\Utilities\Session; use App\Utilities\Uuid; use App\Utilities\Utility; class LtoController extends Controller { private $lto; function __construct() { $this->lto = new \App\Models\Lto; } public function ltoIndex() { response()->redirect(url('lto.orcr.plate')); } public function OrcrPlateIndex() { // if (!(isset($global_action_permissions['7']['33']) && // in_array("1", $global_action_permissions['7']['33']))) { // header('location:signin.php'); // } // print_r(Session::get('action_permissions')); if (!in_array("1", Session::get('action_permissions')['10'])) { response()->redirect("/index.php"); } $page_title = "OR/CR & Plate Update"; include('resources/views/lto/orcr_plate_update/list.php'); } public function orcrPlateList() { $array_data['search_keyword'] = Utility::removeNotAlphaNumeric(input('search')); // $array_data['search_keyword_name'] = input('search'); $array_data['search_type'] = input('search_type'); $array_data['search_type'] = json_decode($array_data['search_type'], true)[0]; $array_data['offset'] = input('offset'); $array_data['limit'] = input('limit'); $array_data['sort'] = input('sort'); $array_data['user_id'] = Session::get('user')['id']; switch ($array_data['sort']) { case "date": $array_data['sort'] = " ORDER BY vops.date_added " . input('order'); break; case "date_received": $array_data['sort'] = " ORDER BY vops.date_received " . input('order'); break; case "type": $array_data['sort'] = " ORDER BY vops.type " . input('order'); break; case "status": $array_data['sort'] = " ORDER BY vops.sms_response " . input('order') . " ,vops.sms_date " . input('order') . ""; break; default: $array_data['sort'] = " ORDER BY vops.date_added DESC"; } // start search using keywords switch ($array_data['search_type']) { case "Customer": $array_data['search'] = " AND CONCAT(c.first_name,' ',c.last_name,' ',c.corporation_name) LIKE ? "; $array_data['search_keyword'] = "%" . input('search') . "%"; break; case "Conduction Sticker": $array_data['search'] = " AND v.conduction_sticker = ? "; break; case "Plate Number": $array_data['search'] = " AND v.plate_number = ? "; break; case "MV File": $array_data['search'] = " AND v.mv_file = ? "; break; case "Engine Number": $array_data['search'] = " AND v.engine_number = ? "; break; case "Chassis Number": $array_data['search'] = " AND v.chassis_number = ? "; break; } if (empty($array_data['search_keyword'])) { $array_data['search_keyword'] = "1"; $array_data['search'] = " AND ? "; } //end search using keywords // start date filter if (empty(input('start_date_add'))) { $array_data['date_added'] = ""; } else { $array_data['date_added'] = " AND DATE_FORMAT(vops.date_added,'%Y-%m-%d') BETWEEN '" . input('start_date_add') . "' AND '" . input('end_date_add') . "' "; } if (empty(input('start_date_receive'))) { $array_data['date_received'] = ""; } else { $array_data['date_received'] = " AND DATE_FORMAT(vops.date_received,'%Y-%m-%d') BETWEEN '" . input('start_date_receive') . "' AND '" . input('end_date_receive') . "' "; } //sms status filter switch (input('sms_status')) { case "Sent": $array_data['sms_status'] = " AND (vops.sms_date IS NOT NULL AND vops.sms_response IS NOT NULL)"; break; case "Pending": $array_data['sms_status'] = " AND (vops.sms_date IS NULL AND vops.sms_response IS NULL)"; break; case "Error": $array_data['sms_status'] = " AND (vops.sms_date IS NULL AND vops.sms_response IS NOT NULL)"; break; default: $array_data['sms_status'] = ""; } $array_data['company_access'] = input('company_id') ? input('company_id') : implode(",", Session::get('company_permissions')); $array_data['dealer_access'] = input('dealer_id'); $result = $this->lto->getOrcrPlateList($array_data); $response['rows'] = array(); $response['total'] = $this->lto->getOrcrPlateListCount($array_data); foreach ($result as $row) { if ($row['sms_date'] && $row['sms_response'] != NULL) { $status = '<span class="right text-sm badge font-weight-normal badge-success">SMS Sent</span>'; } else if (!$row['sms_date'] && $row['sms_response'] != NULL) { // $status = '<span class="right text-sm badge font-weight-normal badge-danger">Error: ' . $row['sms_response'] . '</span>'; $smsResponse = json_decode($row['sms_response'], true); if(!$smsResponse['Error'] && $smsResponse['Failed'] == 0 && $smsResponse['Accepted']==1 ) { $status = '<span class="right text-sm badge font-weight-normal badge-success">SMS Sent</span>'; } else { $status = '<span class="right text-sm badge font-weight-normal badge-danger">Error: ' . $row['sms_response'] . '</span> '; } } else if (!$row['sms_date'] && $row['sms_response'] == NULL) { $status = '<span class="right text-sm badge font-weight-normal badge-warning">Pending</span>'; } if ($row['vops_type'] == "orcr_plate") { $type = "ORCR & Plate"; } else if ($row['vops_type'] == "orcr") { $type = "ORCR"; } else if ($row['vops_type'] == "plate") { $type = "Plate"; } if ($row['pickup_date']) { $pickupdate = date('F d, Y', strtotime($row['pickup_date'])); } else { $pickupdate = '<span data-action-pickup class=" right text-sm badge font-weight-normal badge-primary">Pick up</span>'; } $response['rows'] = array_merge( $response['rows'], array(array( 'vops_id' => $row['vops_id'], 'date' => date('F d, Y', strtotime($row['date_added'])), 'customer' => $row['type'] == "1" ? $row['first_name'] . ' ' . $row['last_name'] : $row['corporation_name'], // 'released_date' => '', 'vehicle' => $row['model_variant'], 'conduction_sticker' => $row['conduction_sticker'], 'plate' => $row['plate_number'], 'mv_file' => $row['mv_file'], 'engine_number' => $row['engine_number'], 'chassis_number' => $row['chassis_number'], 'type' => $type, 'date_received' => date('F d, Y', strtotime($row['date_received'])), 'status' => $status, 'pickup_date' => $pickupdate, 'notes' => $row['notes'], 'company_dealer' => $row['company_code'] . ' - ' . $row['dealer_code'], )) ); } response()->json($response); } public function resendAll() { $not_sent = 0; $sent = 0; $sms_model = new \App\Models\Sms; $sms_module_id = 1; //orcr_plate if ($sms_model->getSmsModuleStatus($sms_module_id)) { $response = $this->lto->getAllError(); foreach ($response as $row) { $lto_dealer_contact = $this->lto->getLtoDealerContacts($row['dealer_id']); if (count($lto_dealer_contact) <= 0) { $not_sent++; continue; } if (empty($lto_dealer_contact[0]['contact_person']) || empty($lto_dealer_contact[0]['contact_phone'])) { $not_sent++; continue; } $vehicle = new \App\Models\Vehicle; $vehicle_data = $vehicle->getVehicleDataByCS($row['conduction_sticker']); //get message template if ($row['type'] == "orcr_plate") { $sms_data['message'] = $sms_model->getSmsTemplate(3); } else if ($row['type'] == "orcr") { $sms_data['message'] = $sms_model->getSmsTemplate(1); } else if ($row['type'] == "plate") { $sms_data['message'] = $sms_model->getSmsTemplate(2); } $replace_parameter = array( '[plate]' => $vehicle_data[0]['plate_number'], '[cs]' => $vehicle_data[0]['conduction_sticker'], '[brand]' => $vehicle_data[0]['brand'], '[model]' => $vehicle_data[0]['model'], '[variant]' => $vehicle_data[0]['model_variant'], '[company]' => $vehicle_data[0]['company'], '[dealer]' => $vehicle_data[0]['dealer'], '[contact_person]' => $lto_dealer_contact[0]['contact_person'], '[contact_email]' => $lto_dealer_contact[0]['contact_email'], '[contact_phone]' => $lto_dealer_contact[0]['contact_phone'], ); $sms_data['message'] = strtr($sms_data['message'], $replace_parameter); $sms_data['mobile'] = $vehicle_data[0]['mobile_phone_1']; $array_data['record_id'] = $row["id"]; //send sms to customer $excluded_year_below = 2021; if (date('Y', strtotime($row['date_received'])) <= $excluded_year_below) { $array_data['sms_date'] = date("Y-m-d h:i:s"); $array_data['sms_response'] = $excluded_year_below; $not_sent++; } else { $sms_response = Sms::sendSms($sms_data); $array_data['sms_date'] = $sms_response == SMS_SUCCESS ? date("Y-m-d h:i:s") : NULL; $array_data['sms_response'] = $sms_response; if ($sms_response == SMS_SUCCESS) { $sent++; } else { $not_sent++; } } $this->lto->updateOrcrPlateSms($array_data); } } else { response()->json(array("status" => 0, "message" => "SMS API Disabled")); } response()->json(array("sent" => $sent, "not_sent" => $not_sent, "status" => 1, "message" => "Sent")); } public function orcrPlateCreate() { // echo (input('chk_send_sms')); // exit; // print_r(input()); $is_orcr = input('chk_orcr'); $is_plate = input('chk_plate'); $is_add_anyway = input('add_anyway'); $cs = strtoupper(input('txt_cs')); $plate = strtoupper(input('txt_plate')); $or = strtoupper(input('txt_or')); $cr = strtoupper(input('txt_cr')); $mv = strtoupper(input('txt_mv')); $date_received = strtoupper(input('txt_received_date')); $engine_no = strtoupper(input('txt_en')); $chassis_no = strtoupper(input('txt_cn')); $notes = strtoupper(input('txt_notes')); $vehicle = new \App\Models\Vehicle; //check if cs is exist $vehicle_data = $vehicle->getVehicleDataByCS($cs); if (count($vehicle_data) <= 0) { $response['message'] = "Conduction sticker is not exist."; $response['status'] = 0; response()->json($response); } //VALIDATE LTO CONTACT PERSON $lto_dealer_contact = $this->lto->getLtoDealerContacts($vehicle_data[0]['dealer_id']); if (count($lto_dealer_contact) <= 0) { $response['message'] = "No LTO dealer contact information. contact system admin."; $response['status'] = 0; response()->json($response); } if (empty($lto_dealer_contact[0]['contact_person']) || empty($lto_dealer_contact[0]['contact_phone'])) { $response['message'] = "Incomplete LTO dealer contact information. contact system admin."; $response['status'] = 0; response()->json($response); } $array_data['vehicle_id'] = $vehicle_data[0]['id']; $array_data['user_id'] = Session::get('user')['id']; $array_data['plate'] = Utility::removeNotAlphaNumeric($plate); $array_data['or'] = Utility::removeNotAlphaNumeric($or); $array_data['cr'] = Utility::removeNotAlphaNumeric($cr); $array_data['mv'] = Utility::removeNotAlphaNumeric($mv); $array_data['engine_no'] = Utility::removeNotAlphaNumeric($engine_no); $array_data['chassis_no'] = Utility::removeNotAlphaNumeric($chassis_no); $array_data['notes'] = $notes; $array_data['date_received'] = date("Y-m-d", strtotime($date_received)); $array_data['status'] = "1"; if ($is_orcr && $is_plate) { $array_data['type'] = "orcr_plate"; } else if ($is_orcr) { $array_data['type'] = "orcr"; } else if ($is_plate) { $array_data['type'] = "plate"; } //check if data recently added if (!input('record_id')) { if ($is_add_anyway == '0') { $existing_data = $this->lto->checkorcrPlateExisting($array_data); if (count($existing_data) > 0) { $response['status'] = 2; response()->json($response); } } } //update vehicle or cr plate if ($plate) { //check plate exist in other vehicle $vehicle->updateVehiclePlate($array_data); } if ($or) { $vehicle->updateVehicleOr($array_data); } if ($cr) { $vehicle->updateVehicleCr($array_data); } if ($mv) { $vehicle->updateVehicleMv($array_data); } if ($engine_no) { $vehicle->updateVehicleEngineNo($array_data); } if ($chassis_no) { $vehicle->updateVehicleChassisNo($array_data); } if (!input('record_id') || input('chk_send_sms')) { $sms_model = new \App\Models\Sms; //get message template if ($array_data['type'] == "orcr_plate") { $sms_data['message'] = $sms_model->getSmsTemplate(3); } else if ($array_data['type'] == "orcr") { $sms_data['message'] = $sms_model->getSmsTemplate(1); } else if ($array_data['type'] == "plate") { $sms_data['message'] = $sms_model->getSmsTemplate(2); } $replace_parameter = array( '[plate]' => $vehicle_data[0]['plate_number'], '[cs]' => $vehicle_data[0]['conduction_sticker'], '[brand]' => $vehicle_data[0]['brand'], '[model]' => $vehicle_data[0]['model'], '[variant]' => $vehicle_data[0]['model_variant'], '[company]' => $vehicle_data[0]['company'], '[dealer]' => $vehicle_data[0]['dealer'], '[contact_person]' => $lto_dealer_contact[0]['contact_person'], '[contact_email]' => $lto_dealer_contact[0]['contact_email'], '[contact_phone]' => $lto_dealer_contact[0]['contact_phone'], ); $sms_data['message'] = strtr($sms_data['message'], $replace_parameter); $sms_data['mobile'] = $vehicle_data[0]['mobile_phone_1']; // if ($sms_data['mobile'] == '+639399064816') { // $sms_data['mobile'] = "+639176331398"; //debug // } //check if sms module is enabled $sms_module_id = 1; //orcr_plate if ($sms_model->getSmsModuleStatus($sms_module_id)) { //send sms to customer $excluded_year_below = 2021; if (!input('record_id') && date('Y', strtotime($date_received)) <= $excluded_year_below) { $array_data['sms_date'] = date("Y-m-d h:i:s"); $array_data['sms_response'] = $excluded_year_below; } else { $sms_response = Sms::sendSms($sms_data); if (empty($sms_response)) { $sms_response = SMS_SUCCESS; } $array_data['sms_date'] = $sms_response == SMS_SUCCESS ? date("Y-m-d h:i:s") : NULL; $array_data['sms_response'] = $sms_response; } } else { $array_data['sms_date'] = NULL; $array_data['sms_response'] = NULL; } } //update data to database if (input('record_id')) { $array_data['record_id'] = input('record_id'); if (input('chk_send_sms')) { $this->lto->updateOrcrPlateSms($array_data); } $this->lto->updateOrcrPlate($array_data); } else { $this->lto->createOrcrPlateWithSMS($array_data); } //insert data to database $response['message'] = "Data successfully created."; $response['status'] = 1; response()->json($response); } public function orcrPlatePickup() { // echo (input('chk_send_sms')); // exit; // print_r(input()); $this->lto->updateOrcrPlatePickup(array(input('id'))); $response['message'] = "Data successfully saved."; $response['status'] = 1; response()->json($response); } function orcrImportFields() { $import = new \App\Models\Import; $result = $import->getImportFields(2); $response = array(); foreach ($result as $row) { $response[$row['id']] = $row; } response()->json($response); } public function orcrImport() { $disk_dir = APP_DISK . input('dir'); if (!file_exists($disk_dir)) { mkdir($disk_dir, 0777, true); } $log_dir = APP_DISK . input('log_dir'); if (!file_exists($log_dir)) { mkdir($log_dir, 0777, true); } $import = new \App\Models\Import; $import_fields = json_decode(input('import_fields'), true); foreach ($import_fields as $key => $value) { $import->updateImportFields(array( 'key' => $key, 'value' => $value, )); } // $destinationFilname = sprintf('%s.%s', uniqid(), $image->getExtension()); // $image->move(sprintf('/uploads/%s', $destinationFilename)); $object = input()->file('file', $defaultValue = null); if ($object->getSize() <= 0) { $response['message'] = "File is empty"; $response['status'] = 0; response()->json($response); } else { //check extension $valid_ext = array('xls', 'csv', 'xlsx'); if (!in_array($object->getExtension(), $valid_ext)) { $response['message'] = "Invalid file extension"; $response['status'] = 0; response()->json($response); } //gen filename $destinationFilename = sprintf('%s.%s', Uuid::long(), $object->getExtension()); //move file $full_dir = $disk_dir . '/' . $destinationFilename; $object->move($full_dir); // start import process $GLOBALS['total_data_count'] = 0; $GLOBALS['not_inserted_data_count'] = 0; $GLOBALS['inserted_data_count'] = 0; $GLOBALS['not_inserted_list_v2'] = array(); $GLOBALS['data_count_list_v2'] = array(); $file_type = \PhpOffice\PhpSpreadsheet\IOFactory::identify($full_dir); $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($file_type); try { $spreadsheet = $reader->load($full_dir); //remove excel after store to phpspreadsheet unlink($full_dir); $data = $spreadsheet->getActiveSheet()->toArray(); $highestRow = $spreadsheet->getActiveSheet()->getHighestRow(); $highestColumn = $spreadsheet->getActiveSheet()->getHighestColumn(); $ColumnNumber = \PhpOffice\PhpSpreadsheet\Cell\Coordinate::columnIndexFromString($highestColumn); $data = array_map(array(new Utility(), 'upperCaseNestedArray'), $data); $header_column_found = false; foreach ($data as $row) { if (!empty(array_filter($row))) { // echo 'Not empty row'; } else { continue; } $row = array_filter($row); if (!$header_column_found) { // get matched field from database and excel globals $issue_summary_index = $import->getSummaryIndex('SUMMARY', $ColumnNumber, $row); $GLOBALS['conduction_sticker'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[11])); $GLOBALS['plate_number'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[12])); $GLOBALS['mv_file'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[13])); $GLOBALS['date'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[14])); $GLOBALS['notes'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[15])); $GLOBALS['engine_number'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[16])); $GLOBALS['chassis_number'] = $import->getFieldName($row, $ColumnNumber, array($import_fields[17])); // check required fields if ( !empty($GLOBALS['conduction_sticker']) && !empty($GLOBALS['plate_number']) && !empty($GLOBALS['mv_file']) && !empty($GLOBALS['date']) && !empty($GLOBALS['notes']) && !empty($GLOBALS['engine_number']) && !empty($GLOBALS['chassis_number']) ) { $header_column_found = true; $GLOBALS['row_headers'] = $row; continue; } } else { $GLOBALS['total_data_count']++; $data_conduction_sticker = $import->checkExist($row, $GLOBALS['conduction_sticker'], $GLOBALS['row_headers']); $data_plate_number = $import->checkExist($row, $GLOBALS['plate_number'], $GLOBALS['row_headers']); $data_plate_number = Utility::removeNotAlphaNumeric($data_plate_number); $data_mv_file = $import->checkExist($row, $GLOBALS['mv_file'], $GLOBALS['row_headers']); $data_mv_file = Utility::removeNotAlphaNumeric($data_mv_file); $data_date = $import->checkExist($row, $GLOBALS['date'], $GLOBALS['row_headers']); $data_date = date('Y-m-d', strtotime($data_date)); $data_notes = $import->checkExist($row, $GLOBALS['notes'], $GLOBALS['row_headers']); $data_engine_number = $import->checkExist($row, $GLOBALS['engine_number'], $GLOBALS['row_headers']); $data_engine_number = Utility::removeNotAlphaNumeric($data_engine_number); $data_chassis_number = $import->checkExist($row, $GLOBALS['chassis_number'], $GLOBALS['row_headers']); $data_chassis_number = Utility::removeNotAlphaNumeric($data_chassis_number); //Validations if (empty($data_conduction_sticker)) { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("NO CONDUCTION STICKER"), $row); $GLOBALS['not_inserted_data_count']++; continue; } if ($data_date == "1970-01-01") { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("NO DATE"), $row); $GLOBALS['not_inserted_data_count']++; continue; } if (strtotime($data_date) > strtotime(date('Y-m-d'))) { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("INVALID DATE"), $row); $GLOBALS['not_inserted_data_count']++; continue; } if ($data_date == "1970-01-01") { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("NO DATE"), $row); $GLOBALS['not_inserted_data_count']++; continue; } $vehicle = new \App\Models\Vehicle; $vehicle_data = $vehicle->getVehicleDataByCS($data_conduction_sticker); if (count($vehicle_data) <= 0) { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("VEHICLE DATA NOT EXIST IN SYSTEM"), $row); $GLOBALS['not_inserted_data_count']++; continue; } $lto_dealer_contact = $this->lto->getLtoDealerContacts($vehicle_data[0]['dealer_id']); if (count($lto_dealer_contact) <= 0) { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("NO LTO DEALER CONTACT INFO"), $row); $GLOBALS['not_inserted_data_count']++; continue; } if (empty($lto_dealer_contact[0]['contact_person']) || empty($lto_dealer_contact[0]['contact_phone'])) { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("INCOMPLETE LTO DEALER CONTACT INFO"), $row); $GLOBALS['not_inserted_data_count']++; continue; } $array_data['vehicle_id'] = $vehicle_data[0]['id']; $array_data['user_id'] = Session::get('user')['id']; $array_data['plate'] = $data_plate_number; $array_data['mv'] = $data_mv_file; $array_data['date_received'] = $data_date; $array_data['notes'] = $data_notes; $array_data['engine_no'] = $data_engine_number; $array_data['chassis_no'] = $data_chassis_number; $array_data['status'] = "1"; //identify the type if ($data_mv_file && $data_plate_number) { $array_data['type'] = "orcr_plate"; $vehicle->updateVehiclePlate($array_data); $vehicle->updateVehicleMv($array_data); } else if ($data_mv_file) { $array_data['type'] = "orcr"; $vehicle->updateVehicleMv($array_data); } else if ($data_plate_number) { $array_data['type'] = "plate"; $vehicle->updateVehiclePlate($array_data); } else { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("NO MV FILE OR PLATE"), $row); $GLOBALS['not_inserted_data_count']++; continue; } $existing_data = $this->lto->checkorcrPlateExisting($array_data); if (count($existing_data) > 0) { $GLOBALS['not_inserted_list_v2'][] = array_merge(array("ALREADY UPLOADED IN SYSTEM"), $row); $GLOBALS['not_inserted_data_count']++; continue; } if ($data_engine_number) { $vehicle->updateVehicleEngineNo($array_data); } if ($data_chassis_number) { $vehicle->updateVehicleChassisNo($array_data); } $array_data['record_id'] = $this->lto->createOrcrPlate($array_data); //for 2021 records fill the sms $excluded_year_below = 2021; if (date('Y', strtotime($data_date)) <= $excluded_year_below) { $array_data['sms_date'] = date("Y-m-d h:i:s"); $array_data['sms_response'] = $excluded_year_below; $this->lto->updateOrcrPlateSms($array_data); } $GLOBALS['not_inserted_list_v2'][] = array_merge(array("SUCCESS IMPORT"), $row); $GLOBALS['inserted_data_count']++; } } if (!$header_column_found) { $return_arr["status"] = 2; $return_arr["message"] = " Header not found."; response()->json($return_arr); } else { $return_arr["status"] = 1; $return_arr["gen_file"] = $destinationFilename; $return_arr["orig_file"] = $object->getFilename(); $return_arr["total"] = $GLOBALS['total_data_count']; $return_arr["inserted"] = $GLOBALS['inserted_data_count']; $return_arr["not_inserted"] = $GLOBALS['not_inserted_data_count']; $return_arr["message"] = " File Uploaded."; ///START GEN LOG $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $GLOBALS['data_count_list_v2'][] = array("Total Data", (string) ($GLOBALS['total_data_count'])); $GLOBALS['data_count_list_v2'][] = array("Inserted Data", (string) ($GLOBALS['inserted_data_count'])); $GLOBALS['data_count_list_v2'][] = array("Not Inserted Data", (string) ($GLOBALS['not_inserted_data_count'])); $GLOBALS['data_count_list_v2'][] = array("Import By", (string) Session::get('user')['first_name'] . ' ' . Session::get('user')['last_name']); $GLOBALS['data_count_list_v2'][] = array("Import Date", (string) date('F d, Y')); $data_count_list_v2_count = count($GLOBALS['data_count_list_v2']); $spreadsheet ->getActiveSheet() ->getStyle('B' . ($data_count_list_v2_count + 1) . ':' . (string) $highestColumn . ($data_count_list_v2_count + 1)) ->getFill() ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID) ->getStartColor() ->setARGB('FFFF00'); $spreadsheet ->getActiveSheet() ->getStyle('A' . ($data_count_list_v2_count + 1) . '') ->getFill() ->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID) ->getStartColor() ->setARGB('FF0000'); $spreadsheet->getActiveSheet()->getStyle('A' . ($data_count_list_v2_count + 1)) ->getFont()->getColor()->setARGB(\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_WHITE); $sheet = $spreadsheet->getActiveSheet(); for ($i = 'A'; $i != $highestColumn; $i++) { $sheet->getColumnDimension($i)->setAutoSize(true); } foreach ($GLOBALS['not_inserted_list_v2'] as $key => $subArr) { unset($subArr[intval($issue_summary_index) + 1]); $GLOBALS['not_inserted_list_v2'][$key] = $subArr; } unset($GLOBALS['row_headers'][intval($issue_summary_index)]); usort($GLOBALS['not_inserted_list_v2'], function ($a, $b) { return $a[0] <=> $b[0]; }); $GLOBALS['not_inserted_list_v2'] = array_merge(array(array_map("strtoupper", array_merge(array('SUMMARY'), $GLOBALS['row_headers']))), $GLOBALS['not_inserted_list_v2']); if ($data_count_list_v2_count > 0) { $GLOBALS['not_inserted_list_v2'] = array_merge($GLOBALS['data_count_list_v2'], $GLOBALS['not_inserted_list_v2']); } $sheet->fromArray($GLOBALS['not_inserted_list_v2'], NULL, 'A1'); $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); $writer->save($log_dir . '/' . $destinationFilename); //END GEN LOG // echo json_encode($return_arr); response()->json($return_arr); } } catch (\Exception $e) { $response['message'] = "Error has occured " . $e; $response['status'] = 0; response()->json($response); } } } public function orcrImportSummaryDownload() { $log_dir = APP_DISK . "import/orcr_plate/logs/"; $file = $log_dir . input('file'); $fp = fopen($file, 'rb'); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=" . escape(input('name')) . ""); header("Content-Length: " . filesize($file)); fpassthru($fp); } public function orcrPlateSmsUpdateCron() { // curl -H "App-Dev-Id: 626ca81708a1f" https://localhost/cron/lto/orcr_plate/sms --insecure // curl -H "App-Dev-Id: 626ca81708a1f" https://connect.autohub.ph/cron/lto/orcr_plate/sms $headers = apache_request_headers(); if (!isset($headers['App-Dev-Id'])) { echo "Access Denied"; exit; } if ($headers['App-Dev-Id'] != "626ca81708a1f") { echo "Invalid Key"; exit; } $array_data['company_access'] = ""; $array_data['search'] = ""; $array_data['date_added'] = ""; $array_data['date_received'] = ""; $array_data['company_access'] = ""; $array_data['dealer_access'] = ""; $array_data['sort'] = ""; $array_data['sms_status'] = " AND (vops.sms_date IS NULL AND vops.sms_response IS NULL)"; $response = $this->lto->getNoSmsOrcrPlateList($array_data); $sms_model = new \App\Models\Sms; //get templates $template['orcr_plate'] = $sms_model->getSmsTemplate(3); $template['plate'] = $sms_model->getSmsTemplate(2); $template['orcr'] = $sms_model->getSmsTemplate(1); foreach ($response as $row) { if ($row['vops_type'] == "orcr_plate") { $sms_data['message'] = $template['orcr_plate']; } else if ($row['vops_type'] == "orcr") { $sms_data['message'] = $template['orcr']; } else if ($row['vops_type'] == "plate") { $sms_data['message'] = $template['plate']; } $array_data['record_id'] = $row['vops_id']; $replace_parameter = array( '[plate]' => $row['plate_number'], '[cs]' => $row['conduction_sticker'], '[brand]' => $row['brand'], '[model]' => $row['model'], '[variant]' => $row['model_variant'], '[company]' => $row['company'], '[dealer]' => $row['dealer'], '[contact_person]' => $row['contact_person'], '[contact_email]' => $row['contact_email'], '[contact_phone]' => $row['contact_phone'], ); $sms_data['message'] = strtr($sms_data['message'], $replace_parameter); $sms_data['mobile'] = $row['mobile_phone_1']; // $sms_data['mobile'] = "+639389592854"; //debug //check if sms module is enabled $sms_module_id = 1; //orcr_plate if ($sms_model->getSmsModuleStatus($sms_module_id)) { if (empty($row['contact_person']) || empty($row['contact_phone'])) { $array_data['sms_date'] = NULL; $array_data['sms_response'] = "No LTO Dealer contact"; } else { //send sms to customer $sms_response = Sms::sendSms($sms_data); $array_data['sms_date'] = $sms_response == SMS_SUCCESS ? date("Y-m-d h:i:s") : NULL; $array_data['sms_response'] = $sms_response; } } else { $array_data['sms_date'] = NULL; $array_data['sms_response'] = NULL; } $this->lto->updateOrcrPlateSms($array_data); } } public function orcrStatusByCSMobile() { if (!input('mobile') && !input('cs') && !input('email')) { $response['message'] = "Insufficient parameters."; $response['status'] = 0; response()->json($response); } $array_data['mobile'] = \App\Utilities\MobileFormatter::format(Utility::removeNotAlphaNumeric(input('mobile'))); $array_data['cs'] = Utility::removeNotAlphaNumeric(input('cs')); $array_data['email'] = input('email'); // if (!empty($array_data['mobile']) && empty($array_data['cs'])) { // $array_data['search'] = " AND cc.mobile_phone_1 LIKE ? AND ?"; // $array_data['search_keyword'][0] = "%" . $array_data['mobile'] . "%"; // $array_data['search_keyword'][1] = "1"; // } else if (empty($array_data['mobile']) && !empty($array_data['cs'])) { // $array_data['search'] = " AND v.conduction_sticker = ? AND ? "; // $array_data['search_keyword'][0] = $array_data['cs']; // $array_data['search_keyword'][1] = "1"; // } else { // $array_data['search'] = " AND ( // cc.mobile_phone_1 LIKE ? // OR v.conduction_sticker = ? // ) // "; // $array_data['search_keyword'][0] = "%" . $array_data['mobile'] . "%"; // $array_data['search_keyword'][1] = $array_data['cs']; // } if (!empty($array_data['mobile']) && !empty($array_data['cs'])) { $array_data['search'] = " AND (REPLACE(cc.mobile_phone_1, '+63', '' ) = ? OR v.conduction_sticker = ?) "; $array_data['search_keyword'][0] = $array_data['mobile']; $array_data['search_keyword'][1] = $array_data['cs']; } else if (!empty($array_data['mobile'])) { $array_data['search'] = " AND REPLACE(cc.mobile_phone_1, '+63', '' ) = ? AND ?"; $array_data['search_keyword'][0] = $array_data['mobile']; $array_data['search_keyword'][1] = "1"; } else if (!empty($array_data['cs'])) { $array_data['search'] = " AND v.conduction_sticker = ? AND ? "; $array_data['search_keyword'][0] = $array_data['cs']; $array_data['search_keyword'][1] = "1"; } else if (!empty($array_data['email'])) { $array_data['search'] = " AND cc.email_1 = ? AND ? "; $array_data['search_keyword'][0] = $array_data['email']; $array_data['search_keyword'][1] = "1"; } $result = $this->lto->getOrcrPlateStatusList($array_data); $response['data'] = array(); foreach ($result as $row) { if ($row['sms_date'] && $row['sms_response'] != NULL) { $status = 'SMS Sent'; //'<span class="right text-sm badge font-weight-normal badge-success">SMS Sent</span>'; } else if (!$row['sms_date'] && $row['sms_response'] != NULL) { $status = 'Error'; //'<span class="right text-sm badge font-weight-normal badge-danger">Error: ' . $row['sms_response'] . '</span>'; } else if (!$row['sms_date'] && $row['sms_response'] == NULL) { $status = 'Pending'; //'<span class="right text-sm badge font-weight-normal badge-warning">Pending</span>'; } if ($row['vops_type'] == "orcr_plate") { $type = "ORCR & Plate"; } else if ($row['vops_type'] == "orcr") { $type = "ORCR"; } else if ($row['vops_type'] == "plate") { $type = "Plate"; } $response['data'] = array_merge( $response['data'], array(array( 'id' => $row['vehicle_id'], 'date_add' => date('F d, Y', strtotime($row['date_added'])), 'customer' => $row['type'] == "1" ? $row['first_name'] . ' ' . $row['last_name'] : $row['corporation_name'], 'firstname' => $row['type'] == "1" ? $row['first_name'] : '', 'lastname' => $row['type'] == "1" ? $row['last_name'] : '', 'mobile' => $row['mobile_phone_1'], 'brand' => $row['brand'], 'model' => $row['model'], // 'released_date' => '', 'vehicle' => $row['model_variant'], 'conduction_sticker' => $row['conduction_sticker'], 'plate' => $row['plate_number'], 'mv_file' => $row['mv_file'], 'engine_number' => $row['engine_number'], 'chassis_number' => $row['chassis_number'], 'type' => $type, 'date_received' => date('F d, Y', strtotime($row['date_received'])), 'date_pickup' => $row['pickup_date'] ? date('F d, Y', strtotime($row['pickup_date'])) : '', 'sms_status' => $status, 'plate_status' => $row['pickup_date'] ? 'Picked-up' : ($this->lto->getPlateStatus(array($row['vehicle_id'])) ? 'Available' : 'Not Available'), 'orcr_status' => $row['pickup_date'] ? 'Picked-up' : ($this->lto->getORCRStatus(array($row['vehicle_id'])) ? 'Available' : 'Not Available'), 'notes' => $row['notes'], 'company_dealer' => $row['company_code'] . ' - ' . $row['dealer_code'], 'sales_person' => $row['sales_person'], 'sc_id' => $row['asa_sales_person'], )) ); } $response['message'] = count($response['data']) ? 'Success' : 'No data fetched.'; $response['status'] = count($response['data']) ? 1 : 0; response()->json($response); } } TestController.php 0000644 00000000443 15025116253 0010241 0 ustar 00 <?php namespace App\Controllers; class TestController { public function profile() { echo "FUNC"; } public function homeAction($id) { echo $id; exit; print_r($_REQUEST); echo "<br>"; print_r(get_defined_vars()); } } UserController.php 0000644 00000000400 15025116253 0010231 0 ustar 00 <?php namespace App\Controllers; class UserController { public function profile() { echo "FUNC"; } public function homeAction() { print_r($_REQUEST); echo "<br>"; print_r(get_defined_vars()); } } IndustryController.php 0000644 00000000651 15025116253 0011144 0 ustar 00 <?php namespace App\Controllers; use App\Core\Controller; use App\Core\Sms; use App\Utilities\Session; use App\Utilities\Uuid; use App\Utilities\Utility; class IndustryController extends Controller { private $industry; function __construct() { $this->industry = new \App\Models\Industry; } public function industryIndex() { include('resources/views/industry/industry.php'); } } FileController.php 0000644 00000005006 15025116253 0010201 0 ustar 00 <?php namespace App\Controllers\Admin; use App\Core\View; use App\Core\Controller; use App\Utilities\Uuid; use Gumlet\ImageResize; use App\Utilities\Session; class FileController extends Controller { private $file; // Image files private $imageQuality = 80; //percent function __construct() { $this->file = new \App\Models\File; } public function upload() { $dir = input('dir'); $disk_dir = APP_DISK . '/' . $dir; if (!file_exists($disk_dir)) { mkdir($disk_dir, 0777, true); } $destinationFilename = ""; $object = input()->file('file', $defaultValue = null); // .pdf, .doc, .docx, .txt, .html, .htm, .ppt, .pptx, .xls, .csv, .xlsx, .png, .jpeg, .jpg, .mp4, .mkv, .mov, .avi, .wmv //check file if empty if ($object->getSize() <= 0) { $response['message'] = "File is empty"; $response['status'] = 0; } else { if ($object->getMime() === 'image/jpeg' || $object->getMime() === 'image/png' || $object->getMime() === 'image/gif') { //resize the file $image = new ImageResize($object->getTmpName()); $image->scale($this->imageQuality); //generate filename $destinationFilename = $dir . '/' . sprintf('%s.%s', Uuid::long(), $object->getExtension()); //save the file to disk $image->save(APP_DISK . '/' . $destinationFilename); } else { // echo "Modify me"; } //other file formats //insert file information to database $array_data['disk'] = APP_DISK; $array_data['user'] = Session::get('user')['id']; $array_data['filename'] = $object->getFilename(); $array_data['path'] = $destinationFilename; $array_data['mime'] = $object->getMime(); $array_data['extension'] = $object->getExtension(); $array_data['size'] = $object->getSize(); $file_id = $this->file->createFile($array_data); if ($file_id) { $response['id'] = $file_id; $response['path'] = $destinationFilename; $response['message'] = "Database upload successful"; $response['status'] = 1; } else { $response['message'] = "Database upload failed"; $response['status'] = 0; } } response()->json($response); } } PageController05-06-24.php 0000644 00000012055 15025116253 0011013 0 ustar 00 <?php namespace App\Controllers; class PageController { public function error404() { echo "Error 404 file not found."; } public function error403() { echo "Error 403 forbidden."; } function activate() { include('resources/views/employees/activate.php'); } function auto_sms_service() { include('resources/views/sms_service/auto_sms_service.php'); } function car_club() { $page_title = "Car Clubs"; include('resources/views/car_club/list.php'); } function car_club_view($id) { $page_title = "Car Club Profile"; include('resources/views/car_club/view.php'); } function car_club_affiliation() { $page_title = "Car Clubs (Affiliation)"; include('resources/views/car_club_affiliation/list.php'); } function car_club_affiliation_view($id) { $page_title = "Car Club Profile"; include('resources/views/car_club_affiliation/view.php'); } function car_club_view1($id, $plate, $date) { include('resources/views/test1.php'); } function compliance() { include('resources/views/sc_compliance/compliance.php'); } function compliance_clients() { include('resources/views/sc_compliance/compliance_clients.php'); } function compliancestatus() { include('resources/views/sc_compliance/compliancestatus.php'); } function customer() { include('resources/views/customers/customer.php'); } function customer_view() { include('resources/views/customers/customer_view.php'); } //CUSTOMER UPDATE function customer_update_view() { include('resources/views/customer_update/customer_view.php'); } function customer_update_dealer_view() { include('resources/views/customer_update/assign_dealer_view.php'); } function customer_update() { include('resources/views/customer_update/customer_update.php'); } function dealer_assign() { include('resources/views/customer_update/dealer_assignment.php'); } function user_assignment() { include('resources/views/customer_update/dealer_assignment_user.php'); } function dealer_assinged_user() { include('resources/views/customer_update/dealer_assigned_user_list.php'); } function customer_update_assinged() { include('resources/views/customer_update/customer_update_assigned.php'); } function u_customer_update_assinged() { include('resources/views/customer_update/u_customer_update_assigned.php'); } function dashboard1() { include('resources/views/dashboard/dashboard.php'); } function employee() { include('resources/views/employees/employee.php'); } function finance_list() { include('resources/views/finance/financelist.php'); } function finance_information($plate_cs_number) { include('resources/views/finance/finance_information.php'); } function finance_dashboard() { include('resources/views/finance/financedashboard.php'); } function finance_pdc_information($pdc_plate_cs_number) { include('resources/views/finance_pdc/finance_pdc_information.php'); } function finance_pdc_list() { include('resources/views/finance_pdc/finance_pdc_list.php'); } function forgot() { include('resources/views/employees/forgot.php'); } function gen_key() { include('resources/views/misc/key.php'); } function home() { header('location:home.php'); } function menu() { include('resources/views/home/home.php'); } function profile() { include('resources/views/employees/profile.php'); } function profile_home() { include('resources/views/employees/profile_home.php'); } function recover() { include('resources/views/employees/recover.php'); } function sale() { include('resources/views/sales/sales.php'); } function sc_compliance() { include('resources/views/sc_compliance/sc_compliance.php'); } function sc_compliance_clients() { include('resources/views/sc_compliance/sc_compliance_clients.php'); } function sc_compliance_client() { include('resources/views/sc_compliance/sc_compliance_client.php'); } function service() { include('resources/views/services/service.php'); } function service_view() { include('resources/views/services/service_view.php'); } function signin() { include('resources/views/employees/signin.php'); } function signup() { include('resources/views/employees/signup.php'); } function vehicle() { include('resources/views/vehicles/vehicle.php'); } function vehicle_view() { include('resources/views/vehicles/vehicle_view.php'); } } NatureOfBusinessController.php 0000644 00000017027 15025116253 0012567 0 ustar 00 <?php namespace App\Controllers; use App\Core\Controller; use App\Core\Sms; use App\Utilities\Session; use App\Utilities\Uuid; use App\Utilities\Utility; class NatureOfBusinessController extends Controller { private $nob; private $nob_perm = array(); function __construct() { $this->nob = new \App\Models\NatureOfBusiness; //access if (isset(Session::get('action_permissions')['5']['53']['25'])) { $this->nob_perm = Session::get('action_permissions')['5']['53']['25']; } if (isset(Session::get('action_permissions')['5']['53']['27'])) { $this->nob_perm = Session::get('action_permissions')['5']['53']['27']; } } public function topNatureOfBusinessIndex() { //access if (!in_array("1", $this->nob_perm)) { response()->redirect("/index.php"); } $page_title = "Top Nature of Business"; //get the attributes $attribute_list = $this->nob->getNatureOfBusinessCategories(); $nob_cat_options = ""; foreach ($attribute_list as $row) { $nob_cat_options .= '<option value="' . $row['id'] . '">' . $row['name'] . '</option>'; } include('resources/views/nature_of_business/top/list.php'); } public function summaryReport() { //access if (!in_array("1", $this->nob_perm)) { response()->redirect("/index.php"); } $page_title = "NoB Summary Report"; include('resources/views/nature_of_business/top/summary_report.php'); } public function topNatureOfBusinessList($cat_id) { if (!in_array("1", $this->nob_perm)) { response()->redirect("/index.php"); } $page_title = $this->nob->getNatureOfBusinessInfo($cat_id)[0]['name']; $attribute_list = $this->nob->getNatureOfBusinessCategories(); $nob_cat_options = ""; foreach ($attribute_list as $row) { if ($cat_id == $row['id']) { $nob_cat_options .= '<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>'; } else { $nob_cat_options .= '<option value="' . $row['id'] . '">' . $row['name'] . '</option>'; } } include('resources/views/nature_of_business/top/data.php'); } public function natureOfBusinessData(){ $array_data['offset'] = input('offset'); $array_data['limit'] = input('limit'); $array_data['offset_limit'] = " LIMIT " . $array_data['offset'] . "," . $array_data['limit'] . ""; $array_data['sort'] = empty(input('sort')) ? " ORDER BY date DESC" : " ORDER BY " . input('sort') . " " . input('order'); $array_data['category'] = !empty(input('nob_id')) ? " AND snob.id = " . input('nob_id') . "" : ""; // start date filter if (empty(input('start_sales_date'))) { $array_data['sales_date'] = ""; } else { $array_data['sales_date'] = " AND DATE_FORMAT(s.activity_date,'%Y-%m-%d') BETWEEN '" . input('start_sales_date') . "' AND '" . input('end_sales_date') . "' "; } $array_data['company_access'] = input('company_id') ? input('company_id') : implode(",", Session::get('company_permissions')); $array_data['dealer_access'] = input('dealer_id'); $array_data['company_access'] = " AND sc.id IN (" . $array_data['company_access'] . ")"; if ($array_data['dealer_access']) { $array_data['dealer_access'] = " AND sd.id IN (" . $array_data['dealer_access'] . ")"; } $result = $this->nob->getNatureOfBusinessData($array_data); $response['rows'] = array(); $response['total'] = $this->nob->getNatureOfBusinessDataCount($array_data); // $nob_perm = Session::get('action_permissions')['5']['53']['25']; foreach ($result AS $row) { $response['rows'] = array_merge( $response['rows'], array(array( 'id' => $row['id'], 'sales_id' => $row['sales_id'], 'date' => date('F d, Y', strtotime($row['date'])), 'customer' => $row['customer'], 'mobile' => (!in_array("2", $this->nob_perm)) ? Utility::maskString($row['mobile']) : "<a href='tel:" . $row['mobile'] . "'>" . $row['mobile'] . "</a>", 'mobile_var' => $row['mobile'], 'email' => (!in_array("3", $this->nob_perm)) ? Utility::maskEmail($row['email']) : "<a href='mailto:" . $row['email'] . "'>" . $row['email'] . "</a>", 'company' => $row['company'] . ' - ' . $row['dealer'], 'nob' => $row['nob'], 'sales_id' => $row['sales_id'], 'sms' => $row['sms'] != NULL ? '<span><i class="fas fa-check-circle" style="color: green;"></i></span>' : '<span><i class="fas fa-times-circle" style="color: #b22222;"></i></span>', 'called' => $row['called'] != NULL ? '<span><i class="fas fa-check-circle" style="color: green;"></i></span>' : '<span><i class="fas fa-times-circle" style="color: #b22222;"></i></span>', 'sms_var' => $row['sms'], 'called_var' => $row['called'] )) ); } response()->json($response); } public function natureOfBusinessCategoryCount() { $array_data['company_access'] = input('company_id') ? input('company_id') : implode(",", Session::get('company_permissions')); $array_data['dealer_access'] = input('dealer_id'); $array_data['category'] = input('category'); $array_data['company_access'] = " AND sc.id IN (" . $array_data['company_access'] . ")"; if ($array_data['dealer_access']) { $array_data['dealer_access'] = " AND sd.id IN (" . $array_data['dealer_access'] . ")"; } if ($array_data['category']) { $array_data['category'] = " AND snob.id IN (" . $array_data['category'] . ")"; } if (empty(input('start_sales_date'))) { $array_data['sales_date'] = ""; } else { $array_data['sales_date'] = " AND DATE_FORMAT(s.activity_date,'%Y-%m-%d') BETWEEN '" . input('start_sales_date') . "' AND '" . input('end_sales_date') . "' "; } $response = $this->nob->getNatureOfBusinessCategoryCount($array_data); response()->json($response); } public function tableListAction() { $array_data['offset'] = input('offset'); $array_data['limit'] = input('limit'); $array_data['offset_limit'] = " LIMIT " . $array_data['offset'] . "," . $array_data['limit'] . ""; $array_data['sales_id'] = input('sales_id'); $action_list = $this->nob->tableAction($array_data); response()->json($action_list); } public function makeSmsCall() { $array_data['type'] = input('type'); $array_data['sales_id'] = input('sales_id'); $array_data['phone'] = input('phone'); $sms_call = $this->nob->smsCall($array_data); response()->json($sms_call); } public function remarks() { $array_data['remarks'] = input('remarks'); $array_data['sales_id'] = input('sales_id'); $remarks = $this->nob->remarks($array_data); response()->json($remarks); } public function loadRemarks() { $array_data['sales_id'] = input('sales_id'); $remarks = $this->nob->loadRemarks($array_data); response()->json($remarks); } } DashboardController.php 0000644 00000000362 15025116253 0011211 0 ustar 00 <?php namespace App\Controllers; class DashboardController { function test() { require_once(__DIR__ . '/../Classes/dashboard.class.php'); $dashboard_class = new Dashboard(); $dashboard_class->test(); } } Customer_update.php 0000644 00000161373 15025116253 0010433 0 ustar 00 <?php namespace App\Controllers; use App\Core\Controller; use App\Core\Database; // use App\Core\Sms; // use App\Utilities\Session; // use App\Utilities\Uuid; use App\Utilities\Utility; // use App\Controllers\Customer; // include_once("Customer.php"); // include_once("../../api/controllers/customer.php"); // token =b0JCRy9CcUZEOFhrV1ErSE9CTW5IVmR2YkZZNDJaeS8xSU9jNkJjczJMWT0= // Utility::str_encrypt('28D4DE7C6AFD6'); // Utility::str_decrypt('b0JCRy9CcUZEOFhrV1ErSE9CTW5IVmR2YkZZNDJaeS8xSU9jNkJjczJMWT0='); define('API_TOKEN', 'b0JCRy9CcUZEOFhrV1ErSE9CTW5IVmR2YkZZNDJaeS8xSU9jNkJjczJMWT0='); // Check if token is provided and valid if (!isset($_REQUEST['token']) || $_REQUEST['token'] !== API_TOKEN) { http_response_code(401); // Unauthorized echo json_encode(array("error" => "Unauthorized")); exit; } class Customer_update extends Controller { private $customer; public function test() { echo Utility::str_encrypt('autohubgroupAppDev0406224'); } function __construct() { // $this->lto = new \App\Models\Lto; // include_once(__DIR__ . '/Customer.php'); // $this->customer = new Customer; // $this->dealer = new \App\Models\Dealer; } public function cu_profile() { $customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : '-1'; // $customer_profile = $this->customer->read_customer_profile_display($customer_id, $granted_company_ids, Database::connectDB()); // var_dump($customer_profile); $query_customer_info = "SELECT DATE_FORMAT(ci.date_modified, '%M %d, %Y - %h:%i:%s %p') AS date_modified, em.first_name AS emfname, em.middle_name AS emmname, em.last_name AS emlname, ci.id, ci.corporation_id,snob.name as profession ,sr.name as religion, ci.corporation_name,ci.first_name, ci.middle_name, ci.last_name, g.gender_name, DATE_FORMAT(ci.date_created, '%M %d, %Y') AS date_created, cc.email_1, cc.email_2, cc.email_3, cc.mobile_phone_1, cc.mobile_phone_2,cc.mobile_phone_3, cc.residential_phone, cc.fax_phone, cc.business_phone, cc.landline, sx.suffix_name AS suffix, ac.nationality, ci.no_of_children, ci.occupation, ams.name AS marital_status, DATE_FORMAT(ci.date_of_birth, '%M %d, %Y') AS birthdate,ci.contact_person, ci.time_created, cc.address_1, cc.address_2, acity1.citymunDesc AS address_1_city, sc.code AS source_company, sd.code AS source_dealer, sdms.name AS source_dms, acity2.citymunDesc AS address_2_city, cc.address_1_postal, cc.address_2_postal, ci.photo, ci.spouse_name, DATE_FORMAT(ci.date_uploaded, '%M %d, %Y - %h:%i:%s %p') AS date_uploaded, e.first_name AS efname, e.middle_name AS emname, e.last_name AS elname, TIMESTAMPDIFF(YEAR,ci.date_of_birth, CURDATE()) as age_number , ci.type, cc.viber, cc.facebook, cc.instagram, cc.whatsapp, cc.telegram, cc.website,snb.name as nature_of_business, ( IF( ci.category_id <> 0,ccat.name, IF( COUNT(se.id) > 0 && COUNT(s.id) < 1, 'SVO', IF( COUNT(se.id) < 1 && COUNT(s.id) > 0, 'SAO', IF( COUNT(v.id) = 1 && COUNT(se.id) > 0 && COUNT(s.id) > 0, 'LYL', IF( COUNT(v.id) > 1 && COUNT(v.id) < 4, 'SLY', IF( COUNT(v.id) > 3, 'VIP','None'/*VVIP*/ ) ) ) ) ) ) ) as customer_category, IF( (SELECT DATEDIFF(NOW(),se.start_date_of_service) <= 365) || (SELECT DATEDIFF(NOW(),s.activity_date) <= 365) , '1','2' ) as isActive, smoc.name as mode_of_contact, sct.name as customer_type, ci.aha_status FROM inactive_customer ci LEFT OUTER JOIN customer_category ccat ON ci.category_id = ccat.id LEFT OUTER JOIN source_profession snob ON ci.profession_id=snob.id LEFT OUTER JOIN source_nature_of_business snb ON ci.nature_of_business_id=snb.id LEFT OUTER JOIN source_religion sr ON ci.religion_id = sr.id LEFT OUTER JOIN all_gender g ON ci.gender_id=g.id LEFT OUTER JOIN customer_contact cc ON ci.id=cc.customer_id LEFT OUTER JOIN all_suffix sx ON ci.suffix_id=sx.id LEFT OUTER JOIN all_countries ac ON ci.nationality_id=ac.num_code LEFT OUTER JOIN all_marital_status ams ON ci.marital_status_id=ams.id LEFT OUTER JOIN employee e ON ci.upload_by=e.id LEFT OUTER JOIN employee em ON ci.modified_by=em.id LEFT OUTER JOIN customer_dms cd ON ci.id=cd.customer_record_id LEFT OUTER JOIN source_company_dealer scd ON cd.company_dealer_id=scd.id LEFT OUTER JOIN source_company sc ON scd.company_id=sc.id LEFT OUTER JOIN source_dms sdms ON sc.dms_id=sdms.id LEFT OUTER JOIN source_dealer sd ON scd.dealer_id=sd.id LEFT OUTER JOIN all_city acity1 ON cc.address_1_city=acity1.id LEFT OUTER JOIN all_city acity2 ON cc.address_2_city=acity2.id LEFT OUTER JOIN source_customer_type sct ON ci.type=sct.id LEFT OUTER JOIN vehicle v ON ci.id = v.customer_record_id LEFT OUTER JOIN sales s ON v.id = s.vehicle_id LEFT OUTER JOIN service se ON v.id = se.vehicle_id LEFT OUTER JOIN source_mode_of_contact smoc ON cc.mode_of_contact_id = smoc.id WHERE ci.id='$customer_id' ORDER BY ci.id ASC LIMIT 1"; //echo $query_customer_info; return; $involvements = "SELECT sd.name AS dms, sc.code AS company, sdr.code AS dealer FROM `customer_dms` cd LEFT OUTER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id LEFT OUTER JOIN source_company sc ON sc.id = scd.company_id LEFT OUTER JOIN source_dms sd ON sc.`dms_id` = sd.id LEFT OUTER JOIN source_dealer sdr ON sdr.id = scd.dealer_id WHERE `customer_record_id` IN ('$customer_id')";//" AND sc.id IN (" . $granted_company_ids . ") "; // echo $query_customer_info; // return; $customer_info = Database::return_result($query_customer_info); $suffix = ""; $in = Database::return_result($involvements); //echo $involvements; return; $dms = array(); $company = array(); $dealer = array(); foreach ($in as $data1) { $dms = array_merge($dms, array($data1['dms'])); $company = array_merge($company, array($data1['company'])); $dealer = array_merge($dealer, array($data1['dealer'])); } $dms_new = array_unique($dms); $company_new = array_unique($company); $dealer_new = array_unique($dealer); $list_dms = implode(', ', $dms_new); $list_company = implode(', ', $company_new); $list_dealer = implode(', ', $dealer_new); foreach ($customer_info as $data) { if (intval($data['corporation_id']) <= 0) { $customer_corporation_name = ''; } else { $customer_corporation_name = Database::connectDB()->select("SELECT corporation_name FROM customer WHERE id = '" . $data['corporation_id'] . "' AND status = 1"); } if ($data['suffix'] == "None") { $suffix = ""; } else { $suffix = " " . $data['suffix']; } $get_image_query = "SELECT vi.name FROM vehicle v INNER JOIN vehicle_images vi ON v.id = vi.vehicle_id INNER JOIN source_company_dealer scd ON v.company_dealer_id = scd.id WHERE 1 AND v.customer_record_id ='" . $data['id'] . "' AND scd.company_id IN (" . $granted_company_ids . ") AND vi.name <> 'default.png' AND vi.status <> 0 AND v.status <> 0 ORDER BY v.id DESC LIMIT 1"; // echo $get_image_query; $get_image_name = Database::select2($get_image_query); if ($get_image_name <> '') { $data['photo'] = $get_image_name; } $arr['photo'] = $data['photo']; if (intval($data['type']) === 1) { $arr['main_corporation_name'] = ''; $arr['full_name'] = $data['first_name'] . " " . $data['middle_name'] . " " . $data['last_name'] . " " . $suffix; $arr['main_first_name'] = $data['first_name']; $arr['main_middle_name'] = $data['middle_name']; $arr['main_last_name'] = $data['last_name']; $arr['suffix'] = $suffix; } else { $arr['main_corporation_name'] = $data['corporation_name']; $arr['full_name'] = ''; $arr['main_first_name'] = ''; $arr['main_middle_name'] = ''; $arr['main_last_name'] = ''; $arr['suffix'] = ''; } $arr['customer_record_id'] = $data['id']; $arr['main_email'] = $data['email_1']; $arr['main_customer_email_2'] = $data['email_2'] .(strlen($data['email_3'])>0 ? ', '.$data['email_3'] : ''); // $arr['main_customer_email_3'] = $data['email_3']; $arr['information_religion'] = $data['religion']; $arr['main_customer_mobile'] = $data['mobile_phone_1']; $arr['main_customer_landline'] = $data['landline']; $arr['main_customer_mobile_2'] = $data['mobile_phone_2'].(strlen($data['mobile_phone_3'])>0 ? ', '.$data['mobile_phone_3'] : ''); // $arr['main_customer_mobile_3'] = $data['mobile_phone_3']; $arr['main_customer_home_mobile'] = $data['residential_phone']; $arr['fax_phone'] = $data['fax_phone']; $arr['main_customer_business_mobile'] = $data['business_phone']; $arr['information_gender'] = $data['gender_name']; $arr['information_date_created'] = $data['date_created']; // $arr['information_dob'] = $data['birthdate']; // $arr['information_nationality'] = $data['nationality']; $arr['no_of_children'] = $data['no_of_children']; $arr['information_age'] = $data['age_number']; $arr['information_position'] = $data['occupation']; $arr['information_marital_status'] = $data['marital_status']; $arr['information_spouse'] = $data['spouse_name']; $arr['contact_person'] = $data['contact_person']; $arr['time_created'] = $data['time_created']; $arr['information_source_company'] = $data['source_company']; $arr['information_source_dealer'] = $data['source_dealer']; $arr['information_source_dms'] = $data['source_dms']; $arr['main_address_1'] = $data['address_1']; $arr['main_address_2'] = $data['address_2']; $arr['main_city_1'] = $data['address_1_city']; $arr['main_city_2'] = $data['address_2_city']; $arr['main_postal_1'] = $data['address_1_postal']; $arr['main_postal_2'] = $data['address_2_postal']; $arr['main_customer_address_1'] = $arr['main_address_1'] . ' ' . $arr['main_city_1'] . ' ' . $arr['main_postal_1']; $arr['main_customer_address_2'] = $arr['main_address_2'] . ' ' . $arr['main_city_2'] . ' ' . $arr['main_postal_2']; $arr['information_uploaded_by'] = $data['efname'] . " " . $data['elname']; $arr['information_date_uploaded'] = $data['date_uploaded']; $arr['information_modified_by'] = $data['emfname'] . " " . $data['emlname']; $arr['information_date_modified'] = $data['date_modified']; $arr['customer_type'] = (intval($data['type']) === 1) ? 'Individual' : 'Corporation'; $arr['main_customer_type'] = $data['customer_type']; $arr['customer_type_id'] = $data['type']; $arr['main_category'] = $data['customer_category']; $arr['main_customer_status'] = (intval($data['isActive']) == 1 ? 'Active' : 'Inactive'); $arr['main_customer_aha_status'] = (intval($data['aha_status']) == 1 ? 'Registered' : 'Not Registered'); $arr['main_customer_moc'] = $data['mode_of_contact']; $arr['main_facebook'] = $data['facebook']; $arr['main_instagram'] = $data['instagram']; $arr['main_viber'] = $data['viber']; $arr['main_telegram'] = $data['telegram']; $arr['main_whatsapp'] = $data['whatsapp']; $arr['main_website_link'] = $data['website']; $arr['information_business_company_name'] = $customer_corporation_name; $arr['information_profession'] = $data['profession']; $arr['information_nature_of_work_business'] = $data['nature_of_business']; } $get_image_query = "SELECT si.name FROM sales s INNER JOIN vehicle_images si ON s.id = si.sales_id INNER JOIN vehicle v ON s.vehicle_id = v.id INNER JOIN source_company_dealer scd ON s.company_dealer_id = scd.id WHERE 1 AND v.customer_record_id ='$customer_id' AND si.name <> 'default.png' AND vi.status <> 0 ORDER BY s.date_uploaded DESC LIMIT 1"; // echo $get_image_query; $get_image_name = Database::select2($get_image_query); if ($get_image_name <> '') { $arr['photo'] = $get_image_name; } $arr['information_dms_list'] = $list_dms; $arr['information_company_list'] = $list_company; $arr['information_dealer_list'] = $list_dealer; return response()->json($arr); } function isNotEmpty($data) { return preg_match('/\S/', $data); } public function index(){ $user_dealer_id = $_REQUEST['dealer_id']; $user_employee_id = $_REQUEST['employee_id']; $search = $_REQUEST['search']; $type = (isset($_REQUEST['type']) && $_REQUEST['type'] != '0') ? " AND t1.type = '".$_REQUEST['type']."' " : "" ; if($this->isNotEmpty($search)){ $filter_email = " OR cc.email_1 = '".$search."' "; }else{ $filter_email = ""; } $type =($this->isNotEmpty($search) ? " AND t1.type ='".$search."' " :''); $gender=''; // $dms=''; $age=''; $complete_data=''; $incomplete_data=''; $mobile_phone_1=''; $address_1=''; $date_of_birth=''; $company=''; $my_record =''; $group_by=''; $customer_actions = "" ; if(isset($_REQUEST['customer_actions']) && $_REQUEST['customer_actions'] != '0'){ switch($_REQUEST['customer_actions']){ case "all": $customer_actions = ""; break; case "new": $customer_actions = " AND t1.date_uploaded > DATE_SUB(NOW(), INTERVAL 1 WEEK) "; break; case "updated": $customer_actions = " AND t1.date_modified > DATE_SUB(NOW(), INTERVAL 1 WEEK) "; break; case "added": $customer_actions = " AND t1.date_uploaded > DATE_SUB(NOW(), INTERVAL 1 DAY) "; break; } } // $my_record =($this->isNotEmpty($search) ? " AND t1.type ='".$search."' " :'') $group_by =''; $offset_limit ='';//" LIMIT 100" $query = " SELECT DISTINCT %s FROM inactive_customer t1 /*INNER JOIN cu_assign ON t1.id =cu_assign.customer_id INNER JOIN cu_dealer_users_assign cdua ON t1.id = cdua.customer_id */ RIGHT JOIN cu_dealer_users_assign cdua ON t1.id = cdua.customer_id INNER JOIN customer_contact cc ON t1.id = cc.customer_id INNER JOIN customer_dms cd ON t1.id = cd.customer_record_id INNER JOIN source_company_dealer scd ON cd.company_dealer_id = scd.id INNER JOIN source_company sc ON scd.company_id = sc.id INNER JOIN source_dms sd ON sc.dms_id = sd.id LEFT OUTER JOIN all_suffix ass ON t1.suffix_id = ass.id LEFT OUTER JOIN vehicle v ON t1.id = v.customer_record_id LEFT OUTER JOIN sales s ON v.id = s.vehicle_id LEFT OUTER JOIN service se ON v.id = se.vehicle_id WHERE cdua.user_id='$user_employee_id' AND cdua.dealer_id ='$user_dealer_id' AND cdua.is_removed=0 AND ( (CONCAT('', CONCAT( t1.corporation_name, ' ', t1.first_name, ' ', t1.last_name , ' ', t1.first_name, ' ', t1.middle_name, ' ', t1.last_name ),' ', CONCAT('0',SUBSTRING(cc.mobile_phone_1, 4) ), ' ', cc.mobile_phone_1,' ',cd.customer_dms_id) LIKE '%%%s%%' /* 1 search */ ) %s /* email */ %s /* 3 gender */ ) %s /* 2 type */ ORDER BY t1.id DESC "; // } $fields = " t1.id, t1.photo, IF(t1.type = 1, concat(t1.first_name,' ',t1.middle_name,' ',t1.last_name) ,t1.corporation_name ) as name, t1.gender_id, (SELECT gender_name FROM all_gender WHERE id=t1.gender_id) as gender_name, t1.date_of_birth, t1.date_uploaded, t1.date_created, TIMESTAMPDIFF(YEAR,t1.date_of_birth, CURDATE()) as age_number, cc.mobile_phone_1, cc.landline, cc.email_1, cc.address_1, CASE WHEN t1.type =1 THEN 'Corporation' WHEN t1.type =2 THEN 'Individual' END as type, t1.date_modified, t1.is_active, (SELECT DATEDIFF(NOW(),t1.date_modified)) as last_date_modified"; $count = " 1 "; $final_query = sprintf( $query, $fields, $search, $filter_email, $gender, $type, );//." $offset_limit"; $exec_query = Database::connect()->runBaseQuery($final_query);//Database::connect()->query($final_query); // echo $final_query;exit; // http_response_code(200); return response()->json($exec_query); } public function setStatus(){ $customer_id = $_REQUEST['customer_id']; $set_active_status = $_REQUEST['status']; // echo $customer_id.' '.$set_active_status;exit; $new_status = ($set_active_status == 1 ? 'Active' : 'Inactive'); $query_old = "SELECT is_active,first_name,middle_name,last_name FROM inactive_customer WHERE id=".$customer_id; $result = Database::connectDB()->query($query_old); // var_dump($result->num_rows); $full_name =''; if($result->num_rows == 1) { foreach($result as $row) { $is_active_status = $row['is_active']; $old_status = ($row['is_active'] == 0 ? 'Inactive' : 'Active'); $full_name = $row['first_name'].(strlen($row['middle_name'])>0 ? ' '.$row['middle_name'].' ' :' ').$row['last_name']; } unset($row); $log_set_active_customer = ($is_active_status == $set_active_status) ? '' : "[Customer status: " . $old_status . " to " . $new_status."]\n"; $log_desc = "Update customer: [ID:" . $customer_id . ", " . $full_name . "]".$log_set_active_customer."\n"; $id = $_SESSION['user']['id']; $code ='update_customer'; // echo $full_name;exit; try{ // ); Database::connectDB()->begin_transaction(); $update = Database::connectDB()->query("UPDATE inactive_customer SET is_active =".$set_active_status." WHERE id=".$customer_id); if(Database::connectDB()->query("INSERT INTO `all_activity_log`(`description`,`owner_id`,`target_id`,`code`) VALUES ('$log_desc',NULLIF('$id',''),'$customer_id','$code')") && $update){ Database::connectDB()->commit(); http_response_code(201); return response()->json(['msg'=>'Record successfully updated.','status'=>201]); // echo '{"msg" :"Record successfully updated.","status":1}'; }else{ // http_response_code(304); Database::connectDB()->rollback(); return response()->json(['msg'=>'Unable to create logs','status'=>304]); // echo '{"msg" :"Unable to create logs ","status":0}';exit; } }catch (\Throwable $e) { Database::connectDB()->rollback(); // http_response_code(304); return response()->json(['msg'=>'Unable to create logs'. $e ,'status'=>304]); // '{"msg" :"Unable to create logs "'.$e.',"status":0}';exit; } } } public function update() { if(isset($_REQUEST['customer_id']) && strlen($_REQUEST['customer_id'])>0) { $customer_id = $_REQUEST['customer_id']; $find_query = $this->read_customer_info_and_contact($customer_id); // var_dump($find_query);exit; // $find_query = $this->read_customer_profile_edit($customer_id); // $customer_info = json_decode($find_query,true); $customer_info =$find_query; // var_dump($customer_info);exit; $old_info_array=[]; $now = date('Y-m-d h:i:s'); if($customer_info->num_rows ===1) // if(is_array($customer_info) && count($customer_info)===1) { foreach ($customer_info as $old_info) { $old_info_array = $old_info; }unset($old_info); // echo'<pre>';print_r($old_info_array);echo'</pre>';exit; //customer info in customer and incative customer table $corporation_name = (isset($_REQUEST['corporation_name']) ? $_REQUEST['corporation_name'] : $old_info_array['corporation_name']); $first_name = (isset($_REQUEST['first_name']) ? $_REQUEST['first_name'] : $old_info_array['first_name']); $middle_name = (isset($_REQUEST['middle_name']) ? $_REQUEST['middle_name'] : $old_info_array['middle_name']); $last_name = (isset($_REQUEST['last_name']) ? $_REQUEST['last_name'] : $old_info_array['last_name']); $suffix_id = (isset($_REQUEST['suffix_id']) ? $_REQUEST['suffix_id'] : $old_info_array['suffix_id']); $gender_id = (isset($_REQUEST['gender_id']) ? $_REQUEST['gender_id'] : $old_info_array['gender_id']); $nationality_id = (isset($_REQUEST['nationality_id']) ? $_REQUEST['nationality_id'] : $old_info_array['nationality_id'] ); $date_of_birth = $_REQUEST['date_of_birth']; $marital_status_id = (isset($_REQUEST['marital_status_id']) ? $_REQUEST['marital_status_id'] : $old_info_array['marital_status_id']); $source_id = (isset($_REQUEST['source_id']) ? $_REQUEST['source_id'] : $old_info_array['source_id']); $mode_of_contact_id = (isset($_REQUEST['mode_of_contact_id']) ? $_REQUEST['mode_of_contact_id'] : $old_info_array['mode_of_contact_id']); $spouse_name = (isset($_REQUEST['spouse_name']) ? $_REQUEST['spouse_name'] : $old_info_array['spouse_name']); $no_of_children = (isset($_REQUEST['no_of_children']) ? $_REQUEST['no_of_children'] : $old_info_array['no_of_children']); $occupation = (isset($_REQUEST['occupation']) ? $_REQUEST['occupation'] : $old_info_array['occupation']); $contact_person = (isset($_REQUEST['contact_person']) ? $_REQUEST['contact_person'] : $old_info_array['contact_person']); $modified_by = (isset($_REQUEST['modified_by']) ? $_REQUEST['modified_by'] : $old_info_array['modified_by']); //employee id in employee id autoph_db $date_modified = $now; $customer_type = (isset($_REQUEST['type']) ? $_REQUEST['type'] : $old_info_array['type']); $category_id = (isset($_REQUEST['category_id']) ? $_REQUEST['category_id'] : $old_info_array['category_id']); $religion_id = (isset($_REQUEST['religion_id']) ? $_REQUEST['religion_id'] : $old_info_array['religion_id']); $corporation_id = (isset($_REQUEST['corporation_id']) ? $_REQUEST['corporation_id'] : $old_info_array['corporation_id']); $profession_id = (isset($_REQUEST['profession_id']) ? $_REQUEST['profession_id'] : $old_info_array['profession_id']); $nature_of_business_id = (isset($_REQUEST['nature_of_business_id']) ? $_REQUEST['nature_of_business_id'] : $old_info_array['nature_of_business_id']); $aha_status = (isset($_REQUEST['aha_status']) && $_REQUEST['aha_status']!=NULL && strlen($_REQUEST['aha_status'])>0 ? $_REQUEST['aha_status'] : $old_info_array['aha_status']); $status= (isset($_REQUEST['status']) ? $_REQUEST['status'] : $old_info_array['status']); //customer contact info $address_1 = (isset($_REQUEST['address_1']) ? $_REQUEST['address_1'] : $old_info_array['address_1']); $address_2 = (isset($_REQUEST['address_2']) ? $_REQUEST['address_2'] : $old_info_array['address_2']); $address_1_city= (isset($_REQUEST['address_1_city']) ? $_REQUEST['address_1_city'] : $old_info_array['address_1_city']); $address_2_city= (isset($_REQUEST['address_2_city']) ? $_REQUEST['address_2_city'] : $old_info_array['address_2_city']); $address_1_postal =(isset($_REQUEST['address_1_postal']) ? $_REQUEST['address_1_postal'] : $old_info_array['address_1_postal']) ; $address_2_postal = (isset($_REQUEST['address_2_postal']) ? $_REQUEST['address_2_postal'] : $old_info_array['address_2_postal']); $email_1 = (isset($_REQUEST['email_1']) ? $_REQUEST['email_1'] : $old_info_array['email_1']); $email_2 = (isset($_REQUEST['email_2']) ? $_REQUEST['email_2'] : $old_info_array['email_2']); $email_3 = (isset($_REQUEST['email_3']) ? $_REQUEST['email_3'] : $old_info_array['email_3']); $viber = (isset($_REQUEST['viber']) ? $_REQUEST['viber'] : $old_info_array['viber']); $facebook = (isset($_REQUEST['facebook']) ? $_REQUEST['facebook'] : $old_info_array['facebook']); $instagram = (isset($_REQUEST['instagram']) ? $_REQUEST['instagram'] : $old_info_array['instagram']); $telegram = (isset($_REQUEST['telegram']) ? $_REQUEST['telegram'] : $old_info_array['telegram']); $whatsapp = (isset($_REQUEST['whatsapp']) ? $_REQUEST['whatsapp'] : $old_info_array['whatsapp']); // $other_social = (isset($_REQUEST['other_social']) ? $_REQUEST['other_social'] : $old_info_array['other_social']); $business_phone = (isset($_REQUEST['business_phone']) ? $_REQUEST['business_phone'] : $old_info_array['business_phone']); $website = (isset($_REQUEST['website']) ? $_REQUEST['website'] : $old_info_array['website']); // $mobile_phone_1 = (isset($_REQUEST['mobile_phone_1']) ? $_REQUEST['mobile_phone_1'] : $old_info_array['mobile_phone_1']); $mobile_phone_2 =(isset($_REQUEST['mobile_phone_2']) && !empty($_REQUEST['mobile_phone_2']) ? $this->transform_mobile($_REQUEST['mobile_phone_2']) : $old_info_array['mobile_phone_2']); $mobile_phone_3 = (isset($_REQUEST['mobile_phone_3']) && !empty($_REQUEST['mobile_phone_2']) ? $this->transform_mobile($_REQUEST['mobile_phone_3']) : $old_info_array['mobile_phone_3']); $landline = (isset($_REQUEST['landline']) ? $_REQUEST['landline'] : $old_info_array['landline']); $residential_phone = (isset($_REQUEST['residential_phone']) ? $_REQUEST['residential_phone'] : $old_info_array['residential_phone']); // if(strlen($mobile_phone_2) ==11 && substr($mobile_phone_2, 0,1) ==0) // { // $ten_digits = substr($mobile_phone_2, 1,10); // $transform_zero = str_replace("0","+63",substr($mobile_phone_2, 0,1)); // $mobile_phone_2 = $transform_zero.$ten_digits; // } ///Customer interest //category id - customer_interest table //customer_interest_content sub table //customer_interest_list - main table $query_interest = "select id,interest_id from customer_interest_list where customer_id=".$customer_id; $categoryID =null; $customer_interest_list_id = null; $n=Database::connectDB()->query($query_interest); if($n->num_rows > 0) { foreach($n as $introw){ $customer_interest_list_id = $introw['id']; $interest_content = Database::connectDB()->query("SELECT id,interest_id,name FROM customer_interest_content WHERE id =".$introw['interest_id']); foreach($interest_content as $content) { $category_id = $content['interest_id']; $cu_interest = Database::connectDB()->query("SELECT id,name FROM customer_interest WHERE id=".$category_id); if($cu_interest->num_rows ===1) { foreach($cu_interest as $category) { $categoryID = $category['id']; } } } } } //CONTACT PERSON //customer_contact_person - main table $query_contact_info = "UPDATE `customer_contact` SET `customer_id`='$customer_id', `address_1`='$address_1', `address_2`='$address_2', `address_1_state`='$address_1_state', `address_2_state`='$address_2_state', `address_1_city`='$address_1_city', `address_2_city`='$address_2_city', `address_1_postal`='$address_1_postal', `address_2_postal`='$address_2_postal', -- `email_1`='$email_1', `email_2`='$email_2', `email_3`='$email_3', `viber`='$viber', `facebook`='$facebook', `instagram`='$instagram', `telegram`='$telegram', `whatsapp`='$whatsapp', -- `other_social`='$other_social', `website`='$website', `business_phone`='$business_phone', -- `fax_phone`='$fax_phone', -- `mobile_phone_1`='$mobile_phone_1', `mobile_phone_2`='$mobile_phone_2', `mobile_phone_3`='$mobile_phone_3', `landline`= '$landline', `residential_phone`='$residential_phone', `date_modified`='$now', `mode_of_contact_id`='$mode_of_contact_id' -- `status`='$status' WHERE `customer_id` = '$customer_id' "; $query_main = "UPDATE `customer` SET `corporation_name`='$corporation_name', `salutation_id`='$salutation_id', `first_name`='$first_name', `middle_name`='$middle_name', `last_name`='$last_name', `suffix_id`='$suffix_id', `gender_id`='$gender_id', `nationality_id`='$nationality_id', `date_of_birth`='$date_of_birth', `marital_status_id`='$marital_status_id', -- `source_id`='$source_id', `mode_of_contact_id`='$mode_of_contact_id', `spouse_name`='$spouse_name', `no_of_children`='', `occupation`='$occupation', `contact_person`='', `modified_by`='$modified_by', `date_modified`= '$now', `type`='$customer_type', `category_id`='$category_id', `religion_id`='$religion_id', `corporation_id`='$corporation_id', `profession_id`='$profession_id', `nature_of_business_id`='$nature_of_business_id', `aha_status` = '$aha_status', `status`='$status' WHERE id = '$customer_id' "; //CUSTOMER UPDATE- INACTIVE TABLE $query_cu = "UPDATE `inactive_customer` SET `id`='$customer_id', `corporation_name`='$corporation_name', `salutation_id`='$salutation_id', `first_name`='$first_name', `middle_name`='$middle_name', `last_name`='$last_name', `suffix_id`='$suffix_id', `gender_id`='$gender_id', `nationality_id`='$nationality_id', `date_of_birth`='$date_of_birth', `marital_status_id`='$marital_status_id', -- `source_id`='$source_id', `mode_of_contact_id`='$mode_of_contact_id', `spouse_name`='$spouse_name', `no_of_children`='', `occupation`='$occupation', `contact_person`='', `modified_by`='$modified_by', `date_modified`= NOW(), `type`='$customer_type', `category_id`='$category_id', `religion_id`='$religion_id', `corporation_id`='$corporation_id', `profession_id`='$profession_id', `nature_of_business_id`='$nature_of_business_id', `aha_status` = '$aha_status', `status`='$status' WHERE id = '$customer_id' "; // var_dump($mobile_phone_1); // $mobile_phone_1 = (($this->isNotEmpty($mobile_phone_1)) ? '+63'.$mobile_phone_1 : ''); // var_dump($mobile_phone_1); $mobile_phone_2 = (($this->isNotEmpty($mobile_phone_2)) ? '+63'.$mobile_phone_2 : ''); $mobile_phone_3 = (($this->isNotEmpty($mobile_phone_3)) ? '+63'.$mobile_phone_3 : ''); $mobile_info_array = [ $old_info_array['$mobile_phone_1'],$old_info_array['mobile_phone_2'], $old_info_array['$mobile_phone_3']]; $new_mobile_info_array[] =[$mobile_phone_1,$mobile_phone_2,$mobile_phone_3]; // echo'<pre>';print_r($new_mobile_info_array);echo'<pre>';return; if ($customer_type == 1) { // $old_info_array['mobile_phone_1'] <> $mobile_phone_1 // if(strlen($mobile_phone_1)>0) // { // if($old_info_array['mobile_phone_1'] <> $mobile_phone_1) // { // if ($this->read_customer_mobile_if_exist($mobile_phone_1) > 0) { // return response()->json(['msg'=>'Mobile already registered.' ,'status'=>304]); // } // } // } if(strlen($mobile_phone_2)>0) { if($old_info_array['mobile_phone_2'] <> $mobile_phone_2) { if ($this->read_customer_mobile_if_exist( $mobile_phone_2) > 0) { return response()->json(['msg'=>'Mobile already registered.' ,'status'=>304]); } } } if(strlen($mobile_phone_3)>0) { if($old_info_array['mobile_phone_3'] <> $mobile_phone_3) { if ($this->read_customer_mobile_if_exist($mobile_phone_3) > 0) { return response()->json(['msg'=>'Mobile already registered.' ,'status'=>304]); } } } // if (!in_array($mobile_phone_1,$mobile_info_array) && !in_array($mobile_phone_2,$mobile_info_array) && !in_array($mobile_phone_3,$mobile_info_array)) { // $i=0; // foreach($new_mobile_info_array as $mobile) // { // if ($this->read_customer_mobile_if_exist($new_customer_number) > 0) { // return response()->json(['msg'=>'Mobile already registered.' ,'status'=>304]); // } // } // } if ($this->isNotEmpty($email_1)) { if (strtolower($old_info_array['email_1']) <> strtolower($email_1)) { if ($this->read_customer_email_if_exist($email_1) > 0) { return response()->json(['msg'=>'Email already registered.' ,'status'=>304]); } } } if ($this->isNotEmpty($email_3)) { if (strtolower($old_info_array['email_3']) <> strtolower($email_1)) { if ($this->read_customer_email_if_exist($email_3) > 0) { return response()->json(['msg'=>'Email already registered.' ,'status'=>304]); } } } if ($this->isNotEmpty($email2)) { if (strtolower($old_info_array['email_2']) <> strtolower($email_1)) { if ($this->read_customer_email_if_exist($email_2) > 0) { return response()->json(['msg'=>'Email already registered.' ,'status'=>304]); } } } } if ($customer_type == 1) { $old_name = $old_info_array['first_name'] . ' ' . $old_info_array['middle_name'] . ' ' . $old_info_array['last_name']; $new_name = $first_name . ' ' . $middle_name. ' ' . $last_name; } else if ($customer_type == 2) { $old_name = $old_info_array['corporation_name']; $new_name = $corporation_name; } // echo'<pre>';print_r($old_info_array['first_name']);echo'</pre>'; // var_dump($old_name);var_dump($new_name);exit; $log_desc = "Update customer: "; //modify $log_customer_id ="[ID:" . $customer_id . ", " . $new_name . "]\n"; $log_name = ($old_name == $new_name) ? '' : "[Name: " . $old_name . " to " . $new_name . "]\n"; // $log_mobile = ($old_info_array["mobile_phone_1"] == $mobile_phone_1) ? '' : "[Mobile: " . $old_info_array["mobile_phone_1"] . " to " . $mobile_phone_1 . "]\n"; $log_mobile2 = ($old_info_array['mobile_phone_2'] == $mobile_phone_2 ? '' : '[Other Mobile 1 :'. $old_info_array['mobile_phone_2'].' to '.$mobile_phone_2.']\n'); $log_mobile3 =($old_info_array['mobile_phone_3'] == $mobile_phone_3 ? '' : '[Other Mobile 2 :'. $old_info_array['mobile_phone_3'].' to '.$mobile_phone_3.']\n'); $log_email = ($old_info_array["email_1"] == $email_1) ? '' : "[Email: " . $old_info_array["email_1"] . " to " . $email_1."]\n"; $log_email2 =(strlen($email_2) >0 ? ($old_info_array["email_2"] == $email_2) ? '' : "[Email: " . $old_info_array["email_2"] . " to " . $email_2 . "]\n" :''); $log_email3 =(strlen($email_3) > 0 ? ($old_info_array["email_3"] == $email_3) ? '' : "[Email: " . $old_info_array["email_3"] . " to " . $email_3 . "]\n" : ''); $log_address = ($old_info_array["address_1"] == $address_1) ? '' : "[Address: " . $old_info_array["address_1"] . " to " . $address_1. "]\n"; $log_address2 = ($old_info_array["address_2"] == $address_2) ? '' : "[Other address: " . $old_info_array["address_2"] . " to " . $address_2 . "]\n"; $log_bday = ($old_info_array["date_of_birth"] == date('Y-m-d',strtotime($date_of_birth))) ? '' : "[Birthday: " . $old_info_array["date_of_birth"] . " to " . date('Y-m-d',strtotime($date_of_birth)) . "]\n"; $log_gender = ($old_info_array["gender_id"] == $gender_id) ? '' : "[Gender: " . ($old_info_array["gender_id"]==1 ? 'Male' : 'Female') . " to " . ($gender_id==1 ? 'Male' : 'Female') . "]\n"; $query_log=''; if( strlen($log_name)>0 || strlen($log_mobile)>0 || strlen($log_mobile2)>0 || strlen($log_mobile3)>0 || strlen($log_email)>0 || strlen($log_email2)>0 || strlen($log_email3)>0 || strlen($log_address)>0 || strlen($log_address2)>0 || strlen($log_bday)>0 || strlen($log_gender)>0 ){ //create logs // $employee_id = $_SESSION['user']['id']; $employee_id = 1; $log_description = $log_desc. $log_name. $log_gender. $log_bday. $log_mobile. $log_mobile2. $log_mobile3. $log_email. $log_email2. $log_email3. $log_address. $log_address2; // $create_log =$this->createLog($employee_id,$log_description,$customer_id,'update_customer','api-customer-update'); $query_log ="INSERT INTO `all_activity_log`(`description`,`owner_id`,`target_id`,`code`) VALUES ('$log_description',NULLIF('$employee_id',''),'$customer_id','api-customer-update')"; } // echo $query_log;exit; try{ $this->dbTransaction($query_main,'customer'); $this->dbTransaction($query_cu,'inactive_customer'); $this->dbTransaction($query_contact_info,'customer_contact'); $this->dbTransaction($query_log,'all_activity_log'); // Database::connectDB()->begin_transaction(); // if( Database::connectDB()->query($query_main) && Database::connectDB()->query($query_cu) && Database::connectDB()->query($query_contact_info) && $create_log) // { Database::connectDB()->commit(); return response()->json(['msg'=>'Record successfully updated.' ,'status'=>201]); // } // else // { // Database::connectDB()->rollback(); // return response()->json(['msg'=>'Unable to update record. Please contact system administrator' ,'status'=>304]); // } } catch (\Throwable $e) { Database::connectDB()->rollback(); return response()->json(['msg'=>'Unable to update record. Please contacty system administrator' ,'status'=>304]); } } else { return response()->json(['msg' => 'No data found.','status'=>204]); } } else { // http_response_code(204); return response()->json(['msg' => 'No data found.','status'=>204]); } } private function read_customer_info_and_contact($id) { $customer_info =Database::connectDB()->query("SELECT * FROM `customer` c INNER JOIN customer_contact cc ON c.`id` = cc.customer_id WHERE 1 AND c.id = $id LIMIT 1"); return $customer_info; } private function read_customer_mobile_if_exist($mobile) { $query = "SELECT 1 FROM `customer_contact` cc INNER JOIN customer c ON cc.customer_id = c.id WHERE 1 AND `mobile_phone_1` = '$mobile' OR `mobile_phone_2` = '$mobile' OR `mobile_phone_3` = '$mobile' AND c.type = 1 AND c.status = 1"; return Database::connectDB()->query($query)->num_rows; } private function read_customer_email_if_exist($email) { $query = "SELECT 1 FROM `customer_contact` cc INNER JOIN customer c ON cc.customer_id = c.id WHERE 1 AND cc.`email_1` = '$email' AND c.type = 1 AND c.status = 1"; return Database::connectDB()->query($query)->num_rows; } private function createLog($id,$description,$target_id,$code,$db){ Database::connectDB()->query("INSERT INTO `all_activity_log`(`description`,`owner_id`,`target_id`,`code`) VALUES ('$description',NULLIF('$id',''),'$target_id','$code')"); } private function dbTransaction($query,$table) { if(strlen($query)>0) { if(Database::connectDB()->query($query)) { Database::connectDB()->commit(); } else { return response()->json(['msg'=>'Unable to update record. Please contact system administrator' ,'source table'=>$table,'status'=>304]); Database::connectDB()->rollback(); } } } private function compareValues($value1, $value2) { // Convert both values to strings for comparison $stringValue1 = strval($value1); $stringValue2 = strval($value2); // Compare the string representations of the values if ($stringValue1 === $stringValue2) { return false; // Values are equal } else { return tue; } } private function read_customer_profile_edit($id) { $query_info= Database::connectDB()->query("SELECT c.*,snob.name as nature_of_business_name,sp.name as profession_name FROM `customer` c LEFT OUTER JOIN source_nature_of_business snob ON c.nature_of_business_id = snob.id LEFT OUTER JOIN source_profession sp ON c.profession_id = sp.id WHERE c.`id` = '$id' "); // return $query_info;// json_encode($query); $data=[]; if($query_info->num_rows ===1) { foreach($query_info as $row) { $data[] = $row; } } return json_encode($data); } // private function transform_mobile($mobile_number) // { // // if(strlen($mobile_number) ==11 && substr($mobile_number, 0,1) ==0) // { // $ten_digits = substr($mobile_number, 1,10); // $transform_zero = str_replace("0","+63",substr($mobile_number, 0,1)); // $mobile_number = $transform_zero.$ten_digits; // return $mobile_number; // else // { // return response()->json(['msg'=>'Invalid mobile number.' ,'status'=>304]); // } // } //api collection dropdow public function customer_interest_list(){ $cu_interest = Database::connectDB()->query("SELECT id,name FROM customer_interest WHERE status =1"); $interest_category=[]; foreach($cu_interest as $row) { $interest_category[] = $row; } return response()->json($interest_category); } public function customer_interest_content(){ $cu_interest = Database::connectDB()->query("SELECT id,name FROM customer_interest_content WHERE status =1"); $interest_subcategory=[]; foreach($cu_interest as $row) { $interest_subcategory[] = $row; } return response()->json($interest_subcategory); } public function all_city(){ $all_city = Database::connectDB()->query("SELECT id,citymunDesc FROM all_city WHERE status =1"); $all_citys=[]; foreach($all_city as $row) { $all_citys[] = $row; } return response()->json($all_citys); } public function all_suffix(){ $all_suffix = Database::connectDB()->query("SELECT id,suffix_name FROM all_suffix WHERE 1"); $all_suffixs=[]; foreach($all_suffix as $row) { $all_suffixs[] = $row; } return response()->json($all_suffixs); } public function all_gender(){ $all_suffix = Database::connectDB()->query("SELECT id,gender_name FROM all_gender WHERE 1"); $all_suffixs=[]; foreach($all_suffix as $row) { $all_suffixs[] = $row; } return response()->json($all_suffixs); } public function all_marital_status(){ $all_marital = Database::connectDB()->query("SELECT id,name FROM all_marital_status WHERE 1"); $all_marital_status=[]; foreach($all_marital as $row) { $all_marital_status[] = $row; } return response()->json( $all_marital_status); } public function source_mode_contact(){ $moc = Database::connectDB()->query("SELECT id,name FROM source_mode_of_contact WHERE status =1"); $mocs=[]; foreach($moc as $row) { $mocs[] = $row; } return response()->json($mocs); } public function source_customer_type(){ $ctype = Database::connectDB()->query("SELECT id,name FROM source_customer_type WHERE 1"); $types=[]; foreach($ctype as $row) { $types[] = $row; } return response()->json($types); } public function customer_category(){ $cu_category = Database::connectDB()->query("SELECT id,name FROM customer_category WHERE status =1"); $customer_categories=[]; foreach($cu_category as $row) { $customer_categories[] = $row; } return response()->json($customer_categories); } public function source_religion(){ $religion = Database::connectDB()->query("SELECT id,name FROM source_religion WHERE status =1"); $religions=[]; foreach($religion as $row) { $religions[] = $row; } return response()->json($religions); } public function source_profession(){ $profession = Database::connectDB()->query("SELECT id,name FROM source_profession WHERE status =1"); $professions=[]; foreach($profession as $row) { $professions[] = $row; } return response()->json($professions); } public function source_nature_business(){ $nature_business = Database::connectDB()->query("SELECT id,name FROM source_nature_of_business WHERE status =1"); $nature_businesses=[]; foreach($nature_business as $row) { $nature_businesses[] = $row; } return response()->json($nature_businesses); } public function cu_affiliation_category(){ $affilications_category = Database::connectDB()->query("SELECT id,name FROM customer_affiliations_category WHERE status =1"); $category_affilications=[]; foreach( $affilications_category as $row) { $category_affilications[] = $row; } return response()->json($category_affilications); } public function cu_affiliation_content(){ $affilications_content = Database::connectDB()->query("SELECT id,name FROM customer_affiliations_content WHERE status =1"); $content_affilications=[]; foreach($affilications_content as $row) { $content_affilications[] = $row; } return response()->json($content_affilications); } public function corporation_name(){ $corporation = Database::connectDB()->query("SELECT id,corporation_name FROM customer WHERE corporation_name !=''"); $corporation_name=[]; foreach($corporation as $row) { $corporation_name[] = $row; } return response()->json( $corporation_name); } } Customer/ActivityController.php 0000644 00000013121 15025116253 0012714 0 ustar 00 <?php namespace App\Controllers\Customer; use Pecee\Http\Middleware\IMiddleware; use Pecee\Http\Request; use App\Utilities\Auth; use App\Utilities\Utility; class ActivityController { private $customerActivity; private $validator; function __construct() { $this->customerActivity = new \App\Models\Customer\Activity; // $this->validator = new \Rakit\Validation\Validator(); $this->validator = new \Rakit\Validation\Validator(); } public function storeValidate() { // make it $validation = $this->validator->make($_REQUEST, [ 'activity' => 'required', // 'source' => 'required_with:source_id', // 'source_id' => 'required_with:source', // 'user_id' => 'required_without:source,source_id', // 'password' => 'required|min:6', // 'confirm_password' => 'required|same:password', // 'postcode' => 'numeric', // 'avatar' => 'required|uploaded_file:0,500K,png,jpeg', // 'skills' => 'array', // 'skills.*.id' => 'required|numeric', // 'skills.*.percentage' => 'required|numeric' ]); $validation->setAliases([ 'activity' => 'activity description', 'source' => 'source', 'source_id' => 'source_id', ]); // $validation->setMessages([ // 'required' => ':attribute is required', // 'email' => ':email is not valid', // // etc // ]); // then validate $validation->validate(); if ($validation->fails()) { // handling errors $errors = $validation->errors(); $response['message'] = implode("<br>", $errors->firstOfAll()); $response['status'] = 0; response()->json($response); } else { return true; } } public function store() { $_REQUEST = sanitize($_REQUEST); $this->storeValidate(); $id = $this->customerActivity->store(Utility::nullEmptyArray(array( $_REQUEST['id'], $_REQUEST['customer_id'], $_REQUEST['vehicle_id'], Auth::user()->id, $_REQUEST['activity'], 1, ))); $response['message'] = "Success."; $response['status'] = 1; $response['id'] = $id; response()->json($response); } public function storeInsuranceValidate() { // make it $validation = $this->validator->make($_REQUEST, [ 'insurance_company' => 'required', // 'source' => 'required_with:source_id', // 'source_id' => 'required_with:source', // 'user_id' => 'required_without:source,source_id', // 'password' => 'required|min:6', // 'confirm_password' => 'required|same:password', // 'postcode' => 'numeric', // 'avatar' => 'required|uploaded_file:0,500K,png,jpeg', // 'skills' => 'array', // 'skills.*.id' => 'required|numeric', // 'skills.*.percentage' => 'required|numeric' ]); $validation->setAliases([ 'activity' => 'activity description', 'source' => 'source', 'source_id' => 'source_id', ]); // $validation->setMessages([ // 'required' => ':attribute is required', // 'email' => ':email is not valid', // // etc // ]); // then validate $validation->validate(); if ($validation->fails()) { // handling errors $errors = $validation->errors(); $response['message'] = implode("<br>", $errors->firstOfAll()); $response['status'] = 0; response()->json($response); } else { return true; } } public function storeInsurance() { $_REQUEST = sanitize($_REQUEST); $this->storeInsuranceValidate(); // print_r($_REQUEST); // exit; $id = $this->customerActivity->storeInsurance(Utility::nullEmptyArray(array( $_REQUEST['id'], $_REQUEST['customer_id'], Auth::user()->id, strtoupper(Utility::removeNotAlphaNumeric($_REQUEST['plate_number']) ?? ''), strtoupper(Utility::removeNotAlphaNumeric($_REQUEST['conduction_sticker']) ?? ''), $_REQUEST['insurance_company'], $_REQUEST['policy_number'], Utility::toSqlDate($_REQUEST['issue_date']), Utility::toSqlDate($_REQUEST['start_date']), Utility::toSqlDate($_REQUEST['end_date']), NULL, 1, ))); if (is_numeric($id)) { $response['message'] = "Success."; $response['status'] = 1; //update insurance $template = $this->customerActivity->template([1]); $id = $this->customerActivity->store(Utility::nullEmptyArray(array( $_REQUEST['id'], $_REQUEST['customer_id'], $_REQUEST['vehicle_id'], Auth::user()->id, $template['activity'], 1, ))); } else { $response['message'] = $id; $response['status'] = 0; } response()->json($response); } } DealerController.php 0000644 00000000576 15025116253 0010525 0 ustar 00 <?php namespace App\Controllers; use App\Core\Controller; class DealerController extends Controller { private $dealer; function __construct() { $this->dealer = new \App\Models\Dealer; } public function companyDealers($company_id) { $response = $this->dealer->getCompanyDealers($company_id); response()->json($response); } } CarClubController.php 0000644 00000000533 15025116253 0010635 0 ustar 00 <?php namespace App\Controllers; class CarClubController { public function error404() { echo "Error 404 file not found."; } function load() { $page_title = "Car Clubs"; include('resources/views/car_club/list.php'); } function view($id) { echo "Car Club Viewer ID:" . $id; } } PageController.php 0000644 00000016227 15025116253 0010205 0 ustar 00 <?php namespace App\Controllers; class PageController { public function error404() { echo "Error 404 file not found."; } public function error403() { echo "Error 403 forbidden."; } function activate() { include('resources/views/employees/activate.php'); } function auto_sms_service() { include('resources/views/sms_service/auto_sms_service.php'); } function car_club() { $page_title = "Car Clubs"; include('resources/views/car_club/list.php'); } function car_club_view($id) { $page_title = "Car Club Profile"; include('resources/views/car_club/view.php'); } function car_club_affiliation() { $page_title = "Car Clubs (Affiliation)"; include('resources/views/car_club_affiliation/list.php'); } function car_club_affiliation_view($id) { $page_title = "Car Club Profile"; include('resources/views/car_club_affiliation/view.php'); } function car_club_view1($id, $plate, $date) { include('resources/views/test1.php'); } function compliance() { include('resources/views/sc_compliance/compliance.php'); } function compliance_clients() { include('resources/views/sc_compliance/compliance_clients.php'); } function compliancestatus() { include('resources/views/sc_compliance/compliancestatus.php'); } function customer() { include('resources/views/customers/customer.php'); } function customer_view() { include('resources/views/customers/customer_view.php'); } //CUSTOMER UPDATE function customer_update_view() { include('resources/views/customer_update/customer_view.php'); } function customer_update_dealer_view() { include('resources/views/customer_update/assign_dealer_view.php'); } function sm_dealer_view() { include('resources/views/customer_update/sm_assign_dealer_view.php'); } function customer_update() { include('resources/views/customer_update/customer_update.php'); } function dealer_assign() { include('resources/views/customer_update/dealer_assignment.php'); } function user_assignment() { include('resources/views/customer_update/dealer_assignment_user.php'); } function user_managment() { include('resources/views/customer_update/dealer_user_management.php'); } function dealer_assinged_user() { include('resources/views/customer_update/dealer_assigned_user_list.php'); } function customer_update_assinged() { include('resources/views/customer_update/customer_update_assigned.php'); } function assigned_customer_update() { include('resources/views/customer_update/assigned_customer_update.php'); } function u_customer_update_assinged() { include('resources/views/customer_update/u_customer_update_assigned.php'); } function user_manual() { if(isset($_REQUEST['user']) && base64_decode($_REQUEST['user']) ==='3695340036334700') { // $filePath = file_get_contents("public/storage/app/Customer Update Manual.pdf"); $filePath = realpath(__DIR__ . '/../../public/storage/app/Customer Update Manual.pdf'); $handle = fopen($filePath, 'rb'); if (!$handle) { header('HTTP/1.0 404 Not Found'); echo 'File not found'; exit; } // Set appropriate headers for streaming header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="' . basename($filePath) . '"'); header('Accept-Ranges: bytes'); header('Content-Length: ' . filesize($filePath)); // Read the file content in chunks and echo directly $chunkSize = 1024 * 1024; // 1 MB chunk size while (!feof($handle)) { echo fread($handle, $chunkSize); flush(); // Flush output to avoid buffering issues } fclose($handle); exit(); } } function assigned_cu_customer() { include('api/customer_update/assigned_cu_customer.php'); } function dashboard1() { include('resources/views/dashboard/dashboard.php'); } function employee() { include('resources/views/employees/employee.php'); } function finance_list() { include('resources/views/finance/financelist.php'); } function finance_information($plate_cs_number) { include('resources/views/finance/finance_information.php'); } function finance_dashboard() { include('resources/views/finance/financedashboard.php'); } function finance_pdc_information($pdc_plate_cs_number) { include('resources/views/finance_pdc/finance_pdc_information.php'); } function finance_pdc_list() { include('resources/views/finance_pdc/finance_pdc_list.php'); } function forgot() { include('resources/views/employees/forgot.php'); } function gen_key() { include('resources/views/misc/key.php'); } function home() { header('location:home.php'); } function menu() { include('resources/views/home/home.php'); } function profile() { include('resources/views/employees/profile.php'); } function profile_home() { include('resources/views/employees/profile_home.php'); } function recover() { include('resources/views/employees/recover.php'); } function sale() { include('resources/views/sales/sales.php'); } function sc_compliance() { include('resources/views/sc_compliance/sc_compliance.php'); } function sc_compliance_clients() { include('resources/views/sc_compliance/sc_compliance_clients.php'); } function sc_compliance_client() { include('resources/views/sc_compliance/sc_compliance_client.php'); } function service() { include('resources/views/services/service.php'); } function service_view() { include('resources/views/services/service_view.php'); } function signin() { include('resources/views/employees/signin.php'); } function signup() { include('resources/views/employees/signup.php'); } function vehicle() { include('resources/views/vehicles/vehicle.php'); } function vehicle_view() { include('resources/views/vehicles/vehicle_view.php'); } function ltms_upload() { include('resources/views/ltms/ltms_view.php'); } function asa_download() { include('resources/views/asa_v1/asav1download.php'); } }
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings