From aaf2d9b70c4fe04901ff262fa8ef9b0b3ad0bda3 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 14 Jul 2023 02:27:48 +0800 Subject: [PATCH] Set yokohama branch to mirror copy in live server #yokohama --- config/acl.yaml | 18 - config/api_acl.yaml | 53 - config/menu.yaml | 4 - config/packages/security.yaml | 12 - config/routes/capi.yaml | 10 - config/routes/customer_location.yaml | 35 - config/routes/report.yaml | 20 - config/routes/tapi.yaml | 60 - config/services.yaml | 22 - ...TotalPendingWarrantySerialFilesCommand.php | 54 - .../GenerateBatteryCompatibilityCommand.php | 2 +- src/Command/LoadWarrantySerialCommand.php | 469 ----- src/Command/WarrantySMSCommand.php | 4 +- src/Controller/APIController.php | 114 +- src/Controller/APIUserController.php | 14 +- src/Controller/BatteryController.php | 10 +- .../BatteryManufacturerController.php | 2 +- .../CAPI/CustomerWarrantyController.php | 6 +- src/Controller/CAPI/RiderAppController.php | 2 +- src/Controller/CAPI/TestController.php | 15 - .../CAPI/WarrantySerialController.php | 182 -- src/Controller/CustomerLocationController.php | 253 --- src/Controller/ReportController.php | 321 --- src/Controller/TAPI/BatteryController.php | 94 - src/Controller/TAPI/JobOrderController.php | 1817 ----------------- src/Controller/TAPI/PromoController.php | 45 - src/Controller/TAPI/ServiceController.php | 79 - src/Controller/TAPI/VehicleController.php | 107 - src/Controller/VehicleController.php | 27 +- src/Controller/WarrantyController.php | 25 +- src/Entity/Battery.php | 19 - src/Entity/CustomerLocation.php | 63 - src/Entity/JobOrder.php | 18 - src/Entity/Vehicle.php | 10 - src/Entity/Warranty.php | 109 - src/Entity/WarrantyRaffleLog.php | 295 --- src/Entity/WarrantySerialLoadLog.php | 120 -- src/Entity/WarrantySerialQueue.php | 129 -- src/Entity/WarrantySerialUploadLog.php | 138 -- src/Ramcar/ModeOfPayment.php | 2 - src/Ramcar/TransactionOrigin.php | 16 +- .../InvoiceGenerator/ResqInvoiceGenerator.php | 4 +- .../JobOrderHandler/ResqJobOrderHandler.php | 308 +-- .../RiderAPIHandler/ResqRiderAPIHandler.php | 2 +- src/Service/WarrantyRaffleFilter.php | 36 - src/Service/WarrantyRaffleLogger.php | 41 - src/Service/WarrantySerialLoadLogger.php | 53 - src/Service/WarrantySerialUploadLogger.php | 47 - templates/base.html.twig | 18 - templates/battery/form.html.twig | 14 - templates/battery/list.html.twig | 15 - templates/customer-location/form.html.twig | 142 -- templates/customer-location/list.html.twig | 146 -- templates/job-order/form.html.twig | 126 +- templates/report/jo-raffle/form.html.twig | 82 - .../report/warranty-raffle/form.html.twig | 83 - templates/vehicle/form.html.twig | 4 +- templates/warranty/form.html.twig | 48 - .../insert_customer_locations.sql | 53 - utils/get_warranty_serial/new_get_serials.php | 2 +- .../warranty_serial_load.sh | 10 - 61 files changed, 108 insertions(+), 5921 deletions(-) delete mode 100644 config/routes/customer_location.yaml delete mode 100644 config/routes/tapi.yaml delete mode 100644 src/Command/CountTotalPendingWarrantySerialFilesCommand.php delete mode 100644 src/Command/LoadWarrantySerialCommand.php delete mode 100644 src/Controller/CAPI/WarrantySerialController.php delete mode 100644 src/Controller/CustomerLocationController.php delete mode 100644 src/Controller/TAPI/BatteryController.php delete mode 100644 src/Controller/TAPI/JobOrderController.php delete mode 100644 src/Controller/TAPI/PromoController.php delete mode 100644 src/Controller/TAPI/ServiceController.php delete mode 100644 src/Controller/TAPI/VehicleController.php delete mode 100644 src/Entity/CustomerLocation.php delete mode 100644 src/Entity/WarrantyRaffleLog.php delete mode 100644 src/Entity/WarrantySerialLoadLog.php delete mode 100644 src/Entity/WarrantySerialQueue.php delete mode 100644 src/Entity/WarrantySerialUploadLog.php delete mode 100644 src/Service/WarrantyRaffleFilter.php delete mode 100644 src/Service/WarrantyRaffleLogger.php delete mode 100644 src/Service/WarrantySerialLoadLogger.php delete mode 100644 src/Service/WarrantySerialUploadLogger.php delete mode 100644 templates/customer-location/form.html.twig delete mode 100644 templates/customer-location/list.html.twig delete mode 100644 templates/report/jo-raffle/form.html.twig delete mode 100644 templates/report/warranty-raffle/form.html.twig delete mode 100644 utils/customer_locations/insert_customer_locations.sql delete mode 100755 utils/warranty_serial_load/warranty_serial_load.sh diff --git a/config/acl.yaml b/config/acl.yaml index 0fe347e9..6da5b558 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -348,10 +348,6 @@ access_keys: label: Customer Source Report - id: report.hub.filter label: Hub Filter Report - - id: report.warranty.raffle - label: Warranty Raffle Report - - id: report.jo.raffle - label: JO Raffle Report - id: service label: Other Services @@ -586,17 +582,3 @@ access_keys: label: Update - id: ownership_type.delete label: Delete - - - id: customer_location - label: Customer Location Access - acls: - - id: cust_location.menu - label: Menu - - id: cust_location.list - label: List - - id: cust_location.add - label: Add - - id: cust_location.update - label: Update - - id: cust_location.delete - label: Delete diff --git a/config/api_acl.yaml b/config/api_acl.yaml index 7d16fbf4..ae1a9bfb 100644 --- a/config/api_acl.yaml +++ b/config/api_acl.yaml @@ -69,56 +69,3 @@ access_keys: acls: - id: dealer.list label: List - - id: warrantyserial - label: Warranty Serial - acls: - - id: warrantyserial.upload - label: Upload - - - id: tapi_vmanufacturer - label: Third Party Vehicle Manufacturer Access - acls: - - id: tapi_vmanufacturer.list - label: List Third Party Vehicle Manufacturers - - id: tapi_vehicle - label: Third Party Vehicle Make Access - acls: - - id: tapi_vehicle.list - label: List Third Party Vehicles - - id: tapi_promo - label: Third Party Promo Access - acls: - - id: tapi_promo.list - label: List Third Party Promos - - id: tapi_battery - label: Third Party Battery Access - acls: - - id: tapi_battery_compatible.list - label: List Third Party Compatible Batteries - - id: tapi_jo - label: Third Party Job Order Access - acls: - - id: tapi_jo.request - label: Third Party Request Job Order - - id: tapi_jo.get.estimate - label: Third Party Get Estimate - - id: tapi_jo.get.ongoing - label: Third Party Get Ongoing Job Order - - id: tapi_jo.cancel - label: Third Party Cancel Job Order - - id: tapi_jo.get.invoice - label: Third Party Get Job Order Invoice - - id: tapi_jo.location.support - label: Third Party Check Location Support - - id: tapi_jo.nearest_hub.get - label: Third Party Get Nearest Hub and Slots - - id: tapi_jo.schedule_option.status - label: Third Party Schedule Option Status - - id: tapi_jo.get.info - label: Third Party Get Job Order Info - - id: tapi_service - label: Third Party Service Access - acls: - - id: tapi_service.list - label: List Third Party Services - diff --git a/config/menu.yaml b/config/menu.yaml index b2cccd56..b75a9d38 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -249,7 +249,3 @@ main_menu: acl: ownership_type.menu label: Ownership Types parent: database - - id: customer_location_list - acl: cust_location.menu - label: Customer Locations - parent: database diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 1b0f6824..2eecd1e8 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -43,10 +43,6 @@ security: pattern: ^\/rapi\/ security: false - test_capi: - pattern: ^\/test_capi\/ - security: false - warranty_api: pattern: ^\/capi\/ stateless: true @@ -63,14 +59,6 @@ security: provider: api_key_user_provider user_checker: Catalyst\AuthBundle\Service\UserChecker - third_party_api: - pattern: ^\/tapi\/ - stateless: true - simple_preauth: - authenticator: Catalyst\APIBundle\Security\APIKeyAuthenticator - provider: api_key_user_provider - user_checker: Catalyst\AuthBundle\Service\UserChecker - main: provider: user_provider form_login: diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index 44f57c99..472da5c2 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -3,10 +3,6 @@ capi_test: path: /capi/test controller: App\Controller\CAPI\TestController::test -capi_test_warranty_serial: - path: /test_capi/test/warranty_serial - controller: App\Controller\CAPI\TestController::warrantySerial - # battery api @@ -188,9 +184,3 @@ capi_dealer_list: path: /capi/dealers controller: App\Controller\CAPI\DealerController::getAll methods: [GET] - -# warranty serial api -capi_warranty_serial_upload: - path: /capi/warranty_serial/upload - controller: App\Controller\CAPI\WarrantySerialController::uploadWarrantySerialFile - methods: [POST] diff --git a/config/routes/customer_location.yaml b/config/routes/customer_location.yaml deleted file mode 100644 index 1ab10970..00000000 --- a/config/routes/customer_location.yaml +++ /dev/null @@ -1,35 +0,0 @@ -customer_location_list: - path: /customer-locations - controller: App\Controller\CustomerLocationController::index - methods: [GET] - -customer_location_rows: - path: /customer-locations/rowdata - controller: App\Controller\CustomerLocationController::datatableRows - methods: [POST] - -customer_location_add_form: - path: /customer-locations/newform - controller: App\Controller\CustomerLocationController::addForm - methods: [GET] - -customer_location_add_submit: - path: /customer-locations - controller: App\Controller\CustomerLocationController::addSubmit - methods: [POST] - -customer_location_update_form: - path: /customer-locations/{id} - controller: App\Controller\CustomerLocationController::updateForm - methods: [GET] - -customer_location_update_submit: - path: /customer-locations/{id} - controller: App\Controller\CustomerLocationController::updateSubmit - methods: [POST] - -customer_location_delete: - path: /customer-locations/{id} - controller: App\Controller\CustomerLocationController::deleteSubmit - methods: [DELETE] - diff --git a/config/routes/report.yaml b/config/routes/report.yaml index 0d969f76..bb9096b9 100644 --- a/config/routes/report.yaml +++ b/config/routes/report.yaml @@ -147,23 +147,3 @@ rep_hub_filter_submit: path: /report/hub_filter_report controller: App\Controller\ReportController::hubFilterSubmit methods: [POST] - -rep_warranty_raffle_form: - path: /report/warranty_raffle_report - controller: App\Controller\ReportController::warrantyRaffleForm - methods: [GET] - -rep_warranty_raffle_submit: - path: /report/warranty_raffle_report - controller: App\Controller\ReportController::warrantyRaffleSubmit - methods: [POST] - -rep_jo_raffle_form: - path: /report/jo_raffle_report - controller: App\Controller\ReportController::joRaffleForm - methods: [GET] - -rep_jo_raffle_submit: - path: /report/jo_raffle_report - controller: App\Controller\ReportController::joRaffleSubmit - methods: [POST] diff --git a/config/routes/tapi.yaml b/config/routes/tapi.yaml deleted file mode 100644 index afa2f084..00000000 --- a/config/routes/tapi.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# third party api - -# job order -tapi_jo_request: - path: /tapi/job_order - controller: App\Controller\TAPI\JobOrderController::requestJobOrder - methods: [POST] - -tapi_estimate: - path: /tapi/estimate - controller: App\Controller\TAPI\JobOrderController::getEstimate - methods: [POST] - -tapi_jo_invoice: - path: /tapi/job_order/invoice/{jo_id} - controller: App\Controller\TAPI\JobOrderController:getJOInvoice - methods: [GET] - -tapi_jo_cancel: - path: /tapi/job_order/cancel - controller: App\Controller\TAPI\JobOrderController:cancelJobOrder - methods: [POST] - -tapi_jo_info: - path: /tapi/job_order/{jo_id}/info - controller: App\Controller\TAPI\JobOrderController::getJobOrderInfo - methods: [GET] - -tapi_location_support: - path: /tapi/location_support - controller: App\Controller\TAPI\JobOrderController:locationSupport - methods: [POST] - -tapi_nearest_hub_slots: - path: /tapi/hub_slots - controller: App\Controller\TAPI\JobOrderController::getNearestHubAndSlots - methods: [POST] - -# vehicle manufacturer and vehicle -tapi_vehicle_mfg_list: - path: /tapi/vehicle/mfgs - controller: App\Controller\TAPI\VehicleController::listVehicleManufacturers - methods: [GET] - -tapi_vehicle_make_list: - path: /tapi/vehicle/mfgs/{mfg_id}/makes - controller: App\Controller\TAPI\VehicleController::listVehicleMakes - methods: [GET] - -# battery -tapi_battery_list: - path: /tapi/vehicles/{vid}/compatible_batteries - controller: App\Controller\TAPI\BatteryController::getCompatibleBatteries - methods: [GET] - -# promos -tapi_promo_list: - path: /tapi/promos - controller: App\Controller\TAPI\PromoController::listPromos - methods: [GET] diff --git a/config/services.yaml b/config/services.yaml index a5d7d05f..9d1ee14e 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -111,10 +111,6 @@ services: $cvu_mfg_id: "%env(CVU_MFG_ID)%" $cvu_brand_id: "%env(CVU_BRAND_ID)%" - App\Command\LoadWarrantySerialCommand: - arguments: - $callback_url: "%env(WARRANTY_SERIAL_CALLBACK_URL)%" - # rider tracker service App\Service\RiderTracker: arguments: @@ -277,14 +273,6 @@ services: arguments: $em: "@doctrine.orm.entity_manager" - # warranty logger for raffle - App\Service\WarrantyRaffleLogger: - arguments: - $em: "@doctrine.orm.entity_manager" - - # warranty raffle filter - App\Service\WarrantyRaffleFilter: ~ - # promo logger App\Service\PromoLogger: arguments: @@ -318,13 +306,3 @@ services: App\Service\WarrantyBulkUploader: arguments: $em: "@doctrine.orm.entity_manager" - - # warranty serial file logger - App\Service\WarrantySerialUploadLogger: - arguments: - $em: "@doctrine.orm.entity_manager" - - # warranty serial load logger - App\Service\WarrantySerialLoadLogger: - arguments: - $em: "@doctrine.orm.entity_manager" diff --git a/src/Command/CountTotalPendingWarrantySerialFilesCommand.php b/src/Command/CountTotalPendingWarrantySerialFilesCommand.php deleted file mode 100644 index 2ff96d5b..00000000 --- a/src/Command/CountTotalPendingWarrantySerialFilesCommand.php +++ /dev/null @@ -1,54 +0,0 @@ -em = $em; - - parent::__construct(); - } - - protected function configure() - { - $this->setName('warrantyserial:count') - ->setDescription('Count number of pending warranty serial files.') - ->setHelp('Count number of pending warranty serial files.'); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $em = $this->em; - - $status = 'pending'; - - $db = $em->getConnection(); - - $ws_query_sql = 'SELECT COUNT(*) AS total FROM warranty_serial_queue - WHERE status = :status'; - - $ws_query_stmt = $db->prepare($ws_query_sql); - $ws_query_stmt->bindValue('status', $status); - - $ws_results = $ws_query_stmt->executeQuery(); - - $results = $ws_results->fetchAssociative(); - - $output->write($results['total']); - - return 0; - } -} diff --git a/src/Command/GenerateBatteryCompatibilityCommand.php b/src/Command/GenerateBatteryCompatibilityCommand.php index 8c219f67..e4ca2d6c 100644 --- a/src/Command/GenerateBatteryCompatibilityCommand.php +++ b/src/Command/GenerateBatteryCompatibilityCommand.php @@ -43,7 +43,7 @@ class GenerateBatteryCompatibilityCommand extends Command $vehicles = $vm->getVehicles(); foreach ($vehicles as $vehicle) { - $batteries = $vehicle->getActiveBatteries(); + $batteries = $vehicle->getBatteries(); $comp_batt = []; foreach ($batteries as $battery) { diff --git a/src/Command/LoadWarrantySerialCommand.php b/src/Command/LoadWarrantySerialCommand.php deleted file mode 100644 index f70504e7..00000000 --- a/src/Command/LoadWarrantySerialCommand.php +++ /dev/null @@ -1,469 +0,0 @@ -em = $em; - $this->upload_logger = $upload_logger; - $this->load_logger = $load_logger; - $this->project_dir = $kernel->getProjectDir(); - $this->callback_url = $callback_url; - $this->filesystem = $filesystem; - - parent::__construct(); - } - - protected function configure() - { - $this->setName('warrantyserial:load') - ->setDescription('Load warranty serials from file.') - ->setHelp('Load warranty serials from file.'); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $em = $this->em; - $this->log_data = []; - - $status = 'pending'; - - // get the filenames from the queue table with status pending - $db = $em->getConnection(); - - $ws_query_sql = 'SELECT id, file_serial, file_id, api_user, orig_file_serial FROM warranty_serial_queue - WHERE status = :status ORDER BY id LIMIT 1'; - - $ws_query_stmt = $db->prepare($ws_query_sql); - $ws_query_stmt->bindValue('status', $status); - - $ws_results = $ws_query_stmt->executeQuery(); - - $output_info = []; - while ($row = $ws_results->fetchAssociative()) - { - $filename = $row['file_serial']; - $user_id = $row['api_user']; - $id = $row['id']; - $file_id = $row['file_id']; - $orig_filename = $row['orig_file_serial']; - - $output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename); - - // remove entry from queue table - $this->updateWarrantySerialQueue($id); - - // delete the uploaded csv file and directory - $this->deleteDirectoryAndFile($file_id); - } - - if (count($output_info) > 0) - { - // error_log(print_r($this->log_data, true)); - // load log data into db - $this->load_logger->logWarrantySerialLoadInfo($this->log_data); - - // send results back to third party - $this->sendResults($output_info); - } - - return 0; - } - - protected function processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename) - { - $csv_file = $this->project_dir . '/public/warranty_serial_uploads/' . $filename; - - $output_info = []; - - // attempt to open file - try - { - $fh = fopen($csv_file, "r"); - } - catch (Exception $e) - { - $error = 'The file ' . $csv_file . 'could not be read.'; - $log_data = [ - 'user_id' => $user_id, - 'is_uploaded' => false, - 'error' => $error, - ]; - $this->upload_logger->logWarrantySerialUploadInfo($log_data); - - $output_info = $this->setOutputInfo($filename, $file_id, true, $error, $data, $orig_filename); - - return $output_info; - } - - $data = []; - while(($row = fgetcsv($fh)) !== false) - { - $validation_result = $this->validateRow($row, $user_id); - if (!empty($validation_result)) - { - $data[] = $validation_result; - continue; - } - - // valid entry, we parse and insert - $serial = trim(strtoupper($row[0])); - - // error_log('Processing ' . $serial); - - $sku = trim(strtoupper($row[1])); - $dispatch_status = trim($row[2]); - $str_date_create = trim($row[3]); - $inventory_status = trim($row[4]); - $cat_id = trim($row[5]); - $cat_name = trim(strtoupper($row[6])); - - // we are sure that this is a valid date at this point - $created_date = $this->convertDateCreate($str_date_create); - - $meta_info = [ - 'dispatch_status' => $dispatch_status, - 'inventory_status' => $inventory_status, - 'category_id' => $cat_id, - 'category_name' => $cat_name, - ]; - - $info = json_encode($meta_info); - - // prepare the data - $source = 'motiv'; - if ($sku == 'N/A') - $sku = null; - - // prepared statement - $db = $this->em->getConnection(); - $insert_stmt = $db->prepare('INSERT INTO warranty_serial (id, sku, date_create, source, meta_info) - VALUES (:serial, :sku, :date_create, :source, :meta_info)'); - - $res = $insert_stmt->execute([ - ':serial' => $serial, - ':sku' => $sku, - ':date_create' => $created_date, - ':source' => $source, - ':meta_info' => $info, - ]); - - if (!$res) - { - // log the not successful insert - $err = $insert_stmt->errorInfo(); - $error = $err[2]; - $this->logLoadInfo($user_id, false, $serial, $error); - - $data[] = [ - 'serial' => $serial, - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - } - else - { - // log the successful insert - $this->logLoadInfo($user_id, true, $serial, ''); - - $data[] = [ - 'serial' => $serial, - 'status' => 'success', - 'has_error' => false, - 'error_message' => '', - ]; - } - } - - // form what we output - $output_info = $this->setOutputInfo($filename, $file_id, false, '', $data, $orig_filename, $orig_filename); - - return $output_info; - } - - protected function validateRow($row, $user_id) - { - $data = []; - // possible lines: - // (1) header in csv file - ignore - // SerialNumber,Sku,DispatchStatus,CreatedDate,InventoryStatus,CategoryID,CategoryName - // (2) No available data - ignore - // (3) CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF - valid - // (4) MG2000313690,N/A,1,2021-05-14T23:47:30.6430000+08:00,0,10,GOLD - valid - // (5) Empty line - ignore - // (6) empty sku - log - - // check if empty line - if ($row == array(null)) - { - // no need to log, but send back error - $error = 'Empty line'; - $data = [ - 'serial' => '', - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // check the number of fields - if (count($row) != self::FIELD_COUNT) - { - $error = 'Invalid number of fields.'; - $data = [ - 'serial' => '', - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // check if the line is a header - if ($row[0] == 'SerialNumber') - { - // no need to log, but send back error - $error = 'Invalid information.'; - $data = [ - 'serial' => '', - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // check if empty serial - if (empty($row[0])) - { - // this one, we log - $error = 'Empty serial'; - $this->logLoadInfo($user_id, false, '', $error); - - $data = [ - 'serial' => '', - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // check length of serial - $serial = trim($row[0]); - if (strlen($serial) > SELF::SERIAL_LENGTH) - { - // log - $error = 'Serial length too long'; - $this->logLoadInfo($user_id, false, $serial, $error); - - $data = [ - 'serial' => $serial, - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // validate the date created - $str_date_create = trim($row[3]); - - $date_create = $this->convertDateCreate($str_date_create); - if ($date_create == null) - { - // log - $error = 'Invalid date create.'; - $this->logLoadInfo($user_id, false, $serial, $error); - - $data = [ - 'serial' => $serial, - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // check if serial is a dupe - $existing_serial = $this->em->getRepository(WarrantySerial::class)->find($serial); - if ($existing_serial != null) - { - // log - $error = 'Serial already exists.'; - $this->logLoadInfo($user_id, false, $serial, $error); - - $data = [ - 'serial' => $serial, - 'status' => 'error', - 'has_error' => true, - 'error_message' => $error, - ]; - - return $data; - } - - // valid entry, return empty - return $data; - } - - protected function convertDateCreate($str_date_create) - { - // since some people cannot follow simple instructions... - // check the date format on the string - // try 2021-05-15T08:35:46+08:00 format on str_date_create - $date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_date_create); - - if ($date_create == false) - { - // try this format: 2021-05-15T08:47:20.3330000+08:00 - // get the date, time and timezone from str_date_create - $str_date_time = substr($str_date_create, 0, 19); - $str_timezone = substr($str_date_create, 27); - $str_datetime_tz = $str_date_time . $str_timezone; - - // create DateTime object - // sample: 2021-05-15T12:16:06+08:00 - $date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_datetime_tz); - - // check if datetime object was created - // if not, someone f*cked up and we have no date create - if ($date_create == false) - { - return null; - } - } - - // if you reach this part, then date string is valid. Since we'll be using - // sql to insert the entries, we return the string - $created_date = $date_create->format('Y-m-d H:i:s'); - // $created_date = DateTime::createFromFormat('Y-m-d H:i:s', $str_created_date); - - return $created_date; - } - - protected function logLoadInfo($user_id, $is_loaded, $serial, $error) - { - $date_create = new DateTime(); - $str_date_create = $date_create->format('Y-m-d H:i:s'); - - $this->log_data[] = [ - $str_date_create, - $user_id, - $serial, - $is_loaded, - $error, - ]; - } - - protected function updateWarrantySerialQueue($id) - { - // prepared statement - $db = $this->em->getConnection(); - - // lock the warranty serial queue table - $db->exec('LOCK TABLES warranty_serial_queue WRITE;'); - - $delete_stmt = $db->prepare('DELETE FROM warranty_serial_queue - WHERE id = :id'); - - $res = $delete_stmt->execute([ - ':id' => $id, - ]); - - $db->exec('UNLOCK TABLES;'); - } - - protected function deleteDirectoryAndFile($filedir) - { - $csv_filedir = $this->project_dir . '/public/warranty_serial_uploads/' . $filedir; - - $this->filesystem->remove($csv_filedir); - } - - protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries, $orig_filename) - { - $info = [ - 'id' => $file_id, - 'filename' => $orig_filename, - 'has_error' => $has_error, - 'error_message' => $error_message, - 'data' => $entries, - ]; - - return $info; - } - - protected function sendResults($output_info) - { - $body = json_encode($output_info); - - // error_log(print_r($body, true)); - - // error_log('Sending json output to ' . $this->callback_url); - - $curl = curl_init(); - - $options = [ - CURLOPT_URL => $this->callback_url, - CURLOPT_POST => true, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => $body, - CURLOPT_HTTPHEADER => [ - 'Content-Type: application/json', - ], - ]; - - curl_setopt_array($curl, $options); - $res = curl_exec($curl); - - curl_close($curl); - - // check result - error_log('Result ' . $res); - } - -} diff --git a/src/Command/WarrantySMSCommand.php b/src/Command/WarrantySMSCommand.php index 735dba7b..77868a9b 100644 --- a/src/Command/WarrantySMSCommand.php +++ b/src/Command/WarrantySMSCommand.php @@ -25,7 +25,7 @@ class WarrantySMSCommand extends Command protected function configure() { $this->setName('warranty:sms') - ->setDescription('Sends an SMS message to users whose warranty expired 45 days ago.') + ->setDescription('Sends an SMS message to users whose warranty expired one month ago.') ->setHelp('Sends warranty SMS.') ->addArgument('date', InputArgument::OPTIONAL, 'Date to use as basis of expiration. Defaults to current date.'); } @@ -50,7 +50,7 @@ class WarrantySMSCommand extends Command $date = new DateTime(); // -1 month - $date->modify('-45 day'); + $date->modify('-1 month'); $warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]); diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 05f50243..0df9bffe 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -41,7 +41,6 @@ use App\Service\RiderTracker; use App\Service\MapTools; use App\Service\InventoryManager; use App\Service\RiderAssignmentHandlerInterface; -use App\Service\WarrantyRaffleLogger; use App\Service\WarrantyAPILogger; use App\Service\PromoLogger; use App\Service\HubSelector; @@ -823,8 +822,7 @@ class APIController extends Controller implements LoggedController // batteries $batt_list = []; - // $batts = $vehicle->getBatteries(); - $batts = $vehicle->getActiveBatteries(); + $batts = $vehicle->getBatteries(); foreach ($batts as $batt) { // TODO: Add warranty_tnv to battery information @@ -3357,14 +3355,14 @@ class APIController extends Controller implements LoggedController // remove QR prefix if it exists - // $prefix = substr($clean_serial, 0, 2); - // if ($prefix == 'QR') - // $clean_serial = substr($clean_serial, 2); + $prefix = substr($clean_serial, 0, 2); + if ($prefix == 'QR') + $clean_serial = substr($clean_serial, 2); return $clean_serial; } - public function warrantyCheck($serial, EntityManagerInterface $em, Request $req, WarrantyRaffleLogger $raffle_logger) + public function warrantyCheck($serial, EntityManagerInterface $em, Request $req) { // check required parameters and api key $required_params = []; @@ -3373,7 +3371,7 @@ class APIController extends Controller implements LoggedController return $res->getReturnResponse(); // check if warranty serial is there - $serial = $this->cleanSerial($serial); + $serial = $this->cleanSerial($serial); $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]); $batt = null; @@ -3388,24 +3386,6 @@ class APIController extends Controller implements LoggedController $today = new DateTime(); - $user_id = $req->query->get('api_key'); - $raffle_data = [ - 'user_id' => $user_id, - 'serial' => $serial, - 'warranty_id' => null, - 'action' => '', - 'bmodel_name' => '', - 'bsize_name' => '', - 'first_name' => '', - 'last_name' => '', - 'plate_number' => '', - 'contact_num' => '', - 'email' => '', - 'address' => '', - ]; - - $data_sent = []; - // if we have a warranty entry for the serial already if ($warr != null) { @@ -3465,16 +3445,6 @@ class APIController extends Controller implements LoggedController 'dealer_address' => $warr->getDealerAddress() ?? '', 'branch_code' => $warr->getDealerBranchCode() ?? '', ]; - - // set customer info and action for raffle log - $raffle_data['action'] = 'serial_check_customer'; - $raffle_data['first_name'] = $customer['first_name']; - $raffle_data['last_name'] = $customer['last_name']; - $raffle_data['plate_number'] = $customer['plate_number']; - $raffle_data['email'] = $customer['email']; - $raffle_data['contact_num'] = $customer['contact_num']; - $raffle_data['address'] = $customer['address']; - $raffle_data['warranty_id'] = $warr->getID(); } else { @@ -3497,9 +3467,6 @@ class APIController extends Controller implements LoggedController 'dealer_address' => '', 'branch_code' => '', ]; - - // set action for raffle log - $raffle_data['action'] = 'serial_check_not_customer'; } } else @@ -3523,9 +3490,6 @@ class APIController extends Controller implements LoggedController 'dealer_address' => '', 'branch_code' => '', ]; - - // set action for raffle log - $raffle_data['action'] = 'serial_check_customer'; } $sku = $warr_serial->getSKU(); @@ -3580,13 +3544,6 @@ class APIController extends Controller implements LoggedController $res->setData($data); - // set the rest of the raffle log entry - $raffle_data['bmodel_name'] = $battery['brand']; - $raffle_data['bsize_name'] = $battery['size']; - - // log the raffle log - $raffle_logger->logRaffleInfo($data_sent, $raffle_data); - return $res->getReturnResponse(); } @@ -3621,7 +3578,7 @@ class APIController extends Controller implements LoggedController } public function warrantyRegister($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt, - TranslatorInterface $trans, WarrantyRaffleLogger $raffle_logger, WarrantyAPILogger $logger) + TranslatorInterface $trans, WarrantyAPILogger $logger) { // check required parameters and api key $required_params = [ @@ -3636,7 +3593,7 @@ class APIController extends Controller implements LoggedController $warr_card = $req->files->get('warr_card'); // normalize serial - $serial = $this->cleanSerial($serial); + $serial = $this->cleanSerial($serial); // $serial = trim(strtoupper($serial)); // process picture uploads @@ -3651,7 +3608,7 @@ class APIController extends Controller implements LoggedController 'last_name' => $req->request->get('last_name'), 'date_purchase' => $req->request->get('date_purchase'), ]; - $action = 'create/update'; + $action = 'create'; $source = WarrantySource::MOBILE; $res = $this->checkParamsAndKey($req, $em, $required_params); @@ -3666,7 +3623,7 @@ class APIController extends Controller implements LoggedController // update warranty $res = $this->updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename, $wcard_filename, - $logger, $log_data, $user_id, $action, $source, $raffle_logger); + $logger, $log_data, $user_id, $action, $source); $em->flush(); @@ -3986,24 +3943,9 @@ class APIController extends Controller implements LoggedController } */ - protected function updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null, $logger, $log_data, $user_id, $action, $source, $raffle_logger) + protected function updateWarranty($res, $em, $rt, $trans, $req, $serial, $inv_filename = null, $wcard_filename = null, + $logger, $log_data, $user_id, $action, $source) { - // prepare raffle log entry - $raffle_data = [ - 'user_id' => $user_id, - 'serial' => $serial, - 'warranty_id' => null, - 'action' => '', - 'bmodel_name' => '', - 'bsize_name' => '', - 'first_name' => '', - 'last_name' => '', - 'plate_number' => '', - 'contact_num' => '', - 'email' => '', - 'address' => '', - ]; - // get serial $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); if ($warr_serial == null) @@ -4036,16 +3978,11 @@ class APIController extends Controller implements LoggedController { $res->setError(true) ->setErrorMessage('Warranty registered to a vehicle not in your list of vehicles.'); - // set action to update - $action = 'update'; $logger->logWarrantyInfo($log_data, $res->getErrorMessage(), $user_id, $action, $source); return $res; } $sms_msg = $trans->trans('warranty_update_confirm'); - - // update raffle data action - $raffle_data['action'] = 'warranty_update'; } else { @@ -4054,9 +3991,6 @@ class APIController extends Controller implements LoggedController // set warranty source $warr->setCreateSource($source); - - // update raffle data action - $raffle_data['action'] = 'warranty_create'; } // get sap battery @@ -4154,30 +4088,6 @@ class APIController extends Controller implements LoggedController // error_log('sending sms to - ' . $this->session->getPhoneNumber()); $rt->sendSMS($this->session->getPhoneNumber(), $trans->trans('message.battery_brand_allcaps'), $sms_msg); - // prepare the rest of the raffle log entry - $raffle_data['warranty_id'] = $warr->getID(); - $raffle_data['bmodel_name'] = $sap_bty->getBrand()->getName(); - $raffle_data['bsize_name'] = $sap_bty->getSize()->getName(); - $raffle_data['first_name'] = $req->request->get('first_name', ''); - $raffle_data['last_name'] = $req->request->get('last_name', ''); - $raffle_data['plate_number'] = $plate; - $raffle_data['contact_num'] = $req->request->get('contact_num', ''); - $raffle_data['email'] = $req->request->get('email', ''); - $raffle_data['address'] = $req->request->get('cust_address', ''); - - $data_sent = [ - 'plate_number' => $req->request->get('plate_number'), - 'first_name' => $req->request->get('first_name'), - 'last_name' => $req->request->get('last_name'), - 'date_purchase' => $req->request->get('date_purchase'), - 'address' => $req->request->get('cust_address', ''), - 'email' => $req->request->get('email', ''), - 'contact_num' => $req->request->get('contact_num', ''), - ]; - - // log raffle data - $raffle_logger->logRaffleInfo($data_sent, $raffle_data); - return $res; } diff --git a/src/Controller/APIUserController.php b/src/Controller/APIUserController.php index 122d3830..06f128e9 100644 --- a/src/Controller/APIUserController.php +++ b/src/Controller/APIUserController.php @@ -155,20 +155,18 @@ class APIUserController extends Controller // metadata $rider_id = $req->request->get('rider_id'); $rider = $em->getRepository(Rider::class)->find($rider_id); - if ($rider != null) - { - $meta = ['rider_id' => $rider_id]; + // TODO: check for null rider - // set api user in rider - $rider->setAPIUser($obj); + $meta = ['rider_id' => $rider_id]; - $obj->setRider($rider) - ->setMetadata($meta); - } + // set api user in rider + $rider->setAPIUser($obj); // set and save values $obj->setName($req->request->get('name')) ->setEnabled($req->request->get('enabled') ? true : false) + ->setMetadata($meta) + ->setRider($rider) ->clearRoles(); // set roles diff --git a/src/Controller/BatteryController.php b/src/Controller/BatteryController.php index b63e52e9..e392dd6b 100644 --- a/src/Controller/BatteryController.php +++ b/src/Controller/BatteryController.php @@ -117,7 +117,6 @@ class BatteryController extends Controller $row['height'] = $orow[0]->getHeight(); $row['total_height'] = $orow[0]->getTotalHeight(); $row['image_file'] = $orow[0]->getImageFile(); - $row['flag_active'] = $orow[0]->isActive(); // add row metadata $row['meta'] = [ @@ -183,8 +182,7 @@ class BatteryController extends Controller ->setHeight($req->request->get('height')) ->setTotalHeight($req->request->get('total_height')) ->setSellingPrice($req->request->get('sell_price')) - ->setImageFile($req->request->get('image_file')) - ->setActive($req->request->get('flag_active', false)); + ->setImageFile($req->request->get('image_file')); // initialize error list $error_array = []; @@ -310,7 +308,6 @@ class BatteryController extends Controller ->setTotalHeight($req->request->get('total_height')) ->setSellingPrice($req->request->get('sell_price')) ->setImageFile($req->request->get('image_file')) - ->setActive($req->request->get('flag_active', false)) ->clearVehicles(); // initialize error list @@ -427,7 +424,7 @@ class BatteryController extends Controller $bmodel_id = $req->query->get('model_id'); $bsize_id = $req->query->get('size_id'); - // find the battery using model and size and battery must be active + // find the battery using model and size $em = $this->getDoctrine()->getManager(); $query = $em->createQuery('SELECT b FROM App\Entity\Battery b JOIN b.model bm @@ -435,8 +432,7 @@ class BatteryController extends Controller JOIN b.manufacturer bmfg WHERE bm.id = :bm_id AND bs.id = :bs_id - AND bmfg.id = :bmfg_id - AND b.flag_active = true') + AND bmfg.id = :bmfg_id') ->setParameter('bmfg_id', $bmfg_id) ->setParameter('bm_id', $bmodel_id) ->setParameter('bs_id', $bsize_id); diff --git a/src/Controller/BatteryManufacturerController.php b/src/Controller/BatteryManufacturerController.php index c717a678..ad93d3df 100644 --- a/src/Controller/BatteryManufacturerController.php +++ b/src/Controller/BatteryManufacturerController.php @@ -270,7 +270,7 @@ class BatteryManufacturerController extends Controller // get row data $em = $this->getDoctrine()->getManager(); - $all_batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); + $all_batts = $em->getRepository(Battery::class)->findAll(); foreach ($all_batts as $battery) { diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index c5562d40..9f007ac4 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -102,9 +102,9 @@ class CustomerWarrantyController extends APIController // remove QR prefix if it exists - //$prefix = substr($clean_serial, 0, 2); - //if ($prefix == 'QR') - // $clean_serial = substr($clean_serial, 2); + $prefix = substr($clean_serial, 0, 2); + if ($prefix == 'QR') + $clean_serial = substr($clean_serial, 2); return $clean_serial; } diff --git a/src/Controller/CAPI/RiderAppController.php b/src/Controller/CAPI/RiderAppController.php index 6a6d3d91..1a293058 100644 --- a/src/Controller/CAPI/RiderAppController.php +++ b/src/Controller/CAPI/RiderAppController.php @@ -1043,7 +1043,7 @@ class RiderAppController extends APIController if ($rider == null) return new APIResponse(false, 'No rider found.'); - $batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); + $batts = $em->getRepository(Battery::class)->findAll(); $models = $em->getRepository(BatteryModel::class)->findAll(); $sizes = $em->getRepository(BatterySize::class)->findAll(); diff --git a/src/Controller/CAPI/TestController.php b/src/Controller/CAPI/TestController.php index 9604c056..e1a5ea08 100644 --- a/src/Controller/CAPI/TestController.php +++ b/src/Controller/CAPI/TestController.php @@ -17,19 +17,4 @@ class TestController extends APIController ]; return new APIResponse(true, 'Test successful.', $data); } - - public function warrantySerial(Request $req) - { - error_log('Got request'); - - $res = json_decode($req->getContent(), true); - - // return $res; - - $data = [ - 'result' => $res, - ]; - return new APIResponse(true, 'Test successful.', $data); - } - } diff --git a/src/Controller/CAPI/WarrantySerialController.php b/src/Controller/CAPI/WarrantySerialController.php deleted file mode 100644 index c845e367..00000000 --- a/src/Controller/CAPI/WarrantySerialController.php +++ /dev/null @@ -1,182 +0,0 @@ -acl_gen = $acl_gen; - $this->upload_logger = $upload_logger; - } - - public function uploadWarrantySerialFile(Request $req, EntityManagerInterface $em, KernelInterface $kernel) - { - $this->denyAccessUnlessGranted('warrantyserial.upload', null, 'No access.'); - - $required_params = [ - 'serial_file', - ]; - - $user_id = $_SERVER['HTTP_X_CATA_API_KEY']; - - $res = $this->checkRequiredParamsForFiles($req, $required_params, $user_id); - - if ($res !== true) - return $res; - - // get the csv file - $csv_file = $req->files->get('serial_file'); - - // process file upload - $upload_dir = $kernel->getProjectDir() . '/public/warranty_serial_uploads'; - $serial_filename = $this->handleSerialFileUpload($csv_file, $upload_dir); - - // insert to warranty serial queue - $res = $this->registerWarrantySerialFile($em, $csv_file, $serial_filename, $user_id); - - // flush to db - $em->flush(); - - return $res; - } - - protected function registerWarrantySerialFile($em, $file, $serial_filename, $user_id) - { - // parse the serial filename to get the file id - $parts = explode('/', $serial_filename); - $file_id = $parts[0]; - $orig_filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '.' . $file->getClientOriginalExtension(); - - $ws_file = new WarrantySerialQueue(); - - $ws_file->setFileSerial($serial_filename) - ->setStatus('pending') - ->setOrigFileSerial($orig_filename) - ->setFileID($file_id) - ->setApiUser($user_id); - - $em->persist($ws_file); - - // log upload - $log_data = [ - 'user_id' => $user_id, - 'is_uploaded' => true, - 'orig_file_serial' => $orig_filename, - 'uploaded_file_serial' => $serial_filename, - ]; - - $this->upload_logger->logWarrantySerialUploadInfo($log_data); - - $data = [ - 'id' => $file_id, - ]; - - return new APIResponse(true, 'Warranty serial file uploaded.', $data); - } - - protected function handleSerialFileUpload($file, $target_dir) - { - // create target dir if it doesn't exist - if (!file_exists($target_dir)) - { - if (!mkdir($target_dir, 0744, true)) - { - $log_data = [ - 'user_id' => $user_id, - 'is_uploaded' => false, - 'error' => 'Failed to create folder for warranty serial files.' - ]; - - $this->upload_logger->logWarrantySerialUploadInfo($log_data); - - return null; - } - } - - // get current date - $curr_date = new DateTime(); - $str_curr_date = $curr_date->format('Ymd'); - $file_id = $str_curr_date . uniqid(); - - // move file - $filename = 'warranty_serial' . '.' . $file->getClientOriginalExtension(); - $file->move($target_dir . '/' . $file_id, $filename); - - return $file_id . '/' . $filename; - } - - protected function checkRequiredParamsForFiles(Request $req, $params, $user_id) - { - // check required parameters - $missing = $this->checkMissingParametersForFiles($req, $params); - if (count($missing) > 0) - { - // log the error - $miss_string = implode(', ', $missing); - $log_data = [ - 'user_id' => $user_id, - 'is_uploaded' => false, - 'error' => 'Missing parameter(s): ' . $miss_string - ]; - - $this->upload_logger->logWarrantySerialUploadInfo($log_data); - - return new APIResponse(false, 'Missing parameter(s): ' . $miss_string); - } - - return true; - } - - protected function checkMissingParametersForFiles(Request $req, $params = []) - { - $missing = []; - - // check if parameters are there - foreach ($params as $param) - { - if ($req->getMethod() == 'GET') - { - $check = $req->query->get($param); - if (empty($check)) - $missing[] = $param; - } - else if ($req->getMethod() == 'POST') - { - // get files from request. - $check = $req->files->get($param); - if (empty($check)) - { - $missing[] = $param; - } - } - else - return $params; - } - - return $missing; - } -} diff --git a/src/Controller/CustomerLocationController.php b/src/Controller/CustomerLocationController.php deleted file mode 100644 index f3287543..00000000 --- a/src/Controller/CustomerLocationController.php +++ /dev/null @@ -1,253 +0,0 @@ -render('customer-location/list.html.twig'); - } - - /** - * @IsGranted("cust_location.list") - */ - public function datatableRows(Request $req) - { - // get query builder - $qb = $this->getDoctrine() - ->getRepository(CustomerLocation::class) - ->createQueryBuilder('q'); - - // get datatable params - $datatable = $req->request->get('datatable'); - - // count total records - $tquery = $qb->select('COUNT(q)'); - $this->setQueryFilters($datatable, $tquery); - $total = $tquery->getQuery() - ->getSingleScalarResult(); - - // get current page number - $page = $datatable['pagination']['page'] ?? 1; - - $perpage = $datatable['pagination']['perpage']; - $offset = ($page - 1) * $perpage; - - // add metadata - $meta = [ - 'page' => $page, - 'perpage' => $perpage, - 'pages' => ceil($total / $perpage), - 'total' => $total, - 'sort' => 'asc', - 'field' => 'id' - ]; - - // build query - $query = $qb->select('q'); - $this->setQueryFilters($datatable, $query); - - // check if sorting is present, otherwise use default - if (isset($datatable['sort']['field']) && !empty($datatable['sort']['field'])) { - $order = $datatable['sort']['sort'] ?? 'asc'; - $query->orderBy('q.' . $datatable['sort']['field'], $order); - } else { - $query->orderBy('q.id', 'asc'); - } - - // get rows for this page - $obj_rows = $query->setFirstResult($offset) - ->setMaxResults($perpage) - ->getQuery() - ->getResult(); - - // process rows - $rows = []; - foreach ($obj_rows as $orow) { - // add row data - $row['id'] = $orow->getID(); - $row['name'] = $orow->getName(); - - // add row metadata - $row['meta'] = [ - 'update_url' => '', - 'delete_url' => '' - ]; - - // add crud urls - if ($this->isGranted('cust_location.update')) - $row['meta']['update_url'] = $this->generateUrl('customer_location_update_form', ['id' => $row['id']]); - if ($this->isGranted('cust_location.delete')) - $row['meta']['delete_url'] = $this->generateUrl('customer_location_delete', ['id' => $row['id']]); - - $rows[] = $row; - } - - // response - return $this->json([ - 'meta' => $meta, - 'data' => $rows - ]); - } - - /** - * @Menu(selected="customer_location.list") - * @IsGranted("cust_location.add") - */ - public function addForm() - { - $cust_location = new CustomerLocation(); - $params = [ - 'cust_location' => $cust_location, - 'mode' => 'create', - ]; - - // response - return $this->render('customer-location/form.html.twig', $params); - } - - /** - * @IsGranted("cust_location.add") - */ - public function addSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator) - { - $cust_location = new CustomerLocation(); - - $this->setObject($cust_location, $req); - - // validate - $errors = $validator->validate($cust_location); - - // initialize error list - $error_array = []; - - // add errors to list - foreach ($errors as $error) { - $error_array[$error->getPropertyPath()] = $error->getMessage(); - } - - // check if any errors were found - if (!empty($error_array)) { - // return validation failure response - return $this->json([ - 'success' => false, - 'errors' => $error_array - ], 422); - } - - // validated! save the entity - $em->persist($cust_location); - $em->flush(); - - // return successful response - return $this->json([ - 'success' => 'Changes have been saved!' - ]); - - } - - /** - * @Menu(selected="customer_location_list") - * @ParamConverter("cust_location", class="App\Entity\CustomerLocation") - * @IsGranted("cust_location.update") - */ - public function updateForm($id, EntityManagerInterface $em, CustomerLocation $cust_location) - { - $params = []; - $params['cust_location'] = $cust_location; - $params['mode'] = 'update'; - - // response - return $this->render('customer-location/form.html.twig', $params); - } - - /** - * @ParamConverter("cust_location", class="App\Entity\CustomerLocation") - * @IsGranted("cust_location.update") - */ - public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, CustomerLocation $cust_location) - { - $this->setObject($cust_location, $req); - - // validate - $errors = $validator->validate($cust_location); - - // initialize error list - $error_array = []; - - // add errors to list - foreach ($errors as $error) { - $error_array[$error->getPropertyPath()] = $error->getMessage(); - } - - // check if any errors were found - if (!empty($error_array)) { - // return validation failure response - return $this->json([ - 'success' => false, - 'errors' => $error_array - ], 422); - } - - // validated! save the entity - $em->flush(); - - // return successful response - return $this->json([ - 'success' => 'Changes have been saved!' - ]); - } - - /** - * @ParamConverter("cust_location", class="App\Entity\CustomerLocation") - * @IsGranted("cust_location.update") - */ - public function deleteSubmit(EntityManagerInterface $em, CustomerLocation $cust_location) - { - // delete this object - $em->remove($cust_location); - $em->flush(); - - // response - $response = new Response(); - $response->setStatusCode(Response::HTTP_OK); - $response->send(); - } - - - protected function setObject(CustomerLocation $obj, Request $req) - { - // set and save values - $obj->setName($req->request->get('name')) - ->setCode($req->request->get('code')); - } - - protected function setQueryFilters($datatable, QueryBuilder $query) - { - if (isset($datatable['query']['data-rows-search']) && !empty($datatable['query']['data-rows-search'])) { - $query->where('q.name LIKE :filter') - ->setParameter('filter', '%' . $datatable['query']['data-rows-search'] . '%'); - } - } - -} diff --git a/src/Controller/ReportController.php b/src/Controller/ReportController.php index c9876bd0..51a874de 100644 --- a/src/Controller/ReportController.php +++ b/src/Controller/ReportController.php @@ -22,8 +22,6 @@ use App\Entity\BatterySize; use App\Entity\SMSMessage; use App\Entity\HubFilterLog; -use App\Service\WarrantyRaffleFilter; - use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\EntityManagerInterface; @@ -1224,132 +1222,6 @@ class ReportController extends Controller } - /** - * @Menu(selected="outlet_list") - */ - public function warrantyRaffleForm() - { - $this->denyAccessUnlessGranted('report.warranty.raffle', null, 'No access.'); - - return $this->render('report/warranty-raffle/form.html.twig'); - } - - /** - * @Menu(selected="outlet_list") - */ - public function joRaffleForm() - { - $this->denyAccessUnlessGranted('report.jo.raffle', null, 'No access.'); - - return $this->render('report/jo-raffle/form.html.twig'); - } - - public function warrantyRaffleSubmit(Request $req, EntityManagerInterface $em, WarrantyRaffleFilter $wr_filter) - { - // get dates - $raw_date_start = $req->request->get('date_start'); - $raw_date_end = $req->request->get('date_end'); - - $date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start); - $date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end); - - $wr_data = $this->getWarrantyRaffleData($req, $em, $raw_date_start, $raw_date_end); - - // filter the retrieved warranty raffle data - $filtered_data = []; - foreach ($wr_data as $wr_entry) - { - $valid = $wr_filter->isValidRaffleEntry($wr_entry); - if ($valid) - $filtered_data[] = $wr_entry; - } - - $resp = new StreamedResponse(); - $resp->setCallback(function() use ($filtered_data) { - // csv output - $csv_handle = fopen('php://output', 'w+'); - fputcsv($csv_handle, [ - 'Raffle Number', - 'Serial Number', - 'Product Name', - 'Transaction Number', // Warranty Raffle Log ID - 'Date', - 'Outlet', - 'Plate Number', - 'Warranty Class', - 'First Name', - 'Last Name', - 'Contact Number', - 'Mobile Number', // number with mobile app - 'Address', - 'Email', - 'Action Taken', - ]); - - foreach ($filtered_data as $row) - { - fputcsv($csv_handle, $row); - } - - fclose($csv_handle); - }); - - $filename = 'warranty_raffle_' . $date_start->format('Ymd') . '_' . $date_end->format('Ymd') . '.csv'; - $resp->setStatusCode(200); - $resp->headers->set('Content-Type', 'text/csv; charset=utf-8'); - $resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - - return $resp; - } - - - public function joRaffleSubmit(Request $req, EntityManagerInterface $em) - { - // get dates - $raw_date_start = $req->request->get('date_start'); - $raw_date_end = $req->request->get('date_end'); - - $date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start); - $date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end); - - $data = $this->getJORaffleData($req, $em, $raw_date_start, $raw_date_end); - - $resp = new StreamedResponse(); - $resp->setCallback(function() use ($data) { - // csv output - $csv_handle = fopen('php://output', 'w+'); - fputcsv($csv_handle, [ - 'Raffle Number', - 'Serial Number', - 'Product Name', - 'Transaction Number', // JO ID - 'Date', - 'Outlet', // Hub - 'Plate Number', - 'Warranty Class', - 'First Name', - 'Last Name', - 'Contact Number', - 'Address', - 'Email', - ]); - - foreach ($data as $row) - { - fputcsv($csv_handle, $row); - } - - fclose($csv_handle); - }); - - $filename = 'jo_raffle_' . $date_start->format('Ymd') . '_' . $date_end->format('Ymd') . '.csv'; - $resp->setStatusCode(200); - $resp->headers->set('Content-Type', 'text/csv; charset=utf-8'); - $resp->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"'); - - return $resp; - } - protected function processPopappFile(UploadedFile $csv_file, EntityManagerInterface $em) { // attempt to open file @@ -2726,197 +2598,4 @@ class ReportController extends Controller return $cust_ids; } - protected function getWarrantyRaffleData($req, $em, $raw_date_start, $raw_date_end) - { - $date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start); - $date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end); - - // change to this format: Y-m-d H:i:s - $new_date_start = $date_start->format('Y-m-d') . ' 00:00:00'; - $new_date_end = $date_end->format('Y-m-d') . ' 23:59:59'; - - $db = $em->getConnection(); - - // get the data from warranty_raffle_log - $wrl_sql = 'SELECT wrl.id AS wrl_id, wrl.serial AS serial, wrl.warranty_id AS warranty_id, - wrl.batt_model_name AS model_name, wrl.batt_size_name AS size_name, - wrl.date_create AS date_create, wrl.plate_number AS plate_number, - wrl.first_name AS first_name, wrl.last_name AS last_name, - wrl.contact_num AS contact_num, wrl.address AS address, wrl.email AS email, - wrl.action AS action, wrl.api_user AS api_user_id - FROM warranty_raffle_log wrl - WHERE wrl.date_create >= :date_start - AND wrl.date_create <= :date_end'; - - $wrl_stmt = $db->prepare($wrl_sql); - $wrl_stmt->bindValue('date_start', $new_date_start); - $wrl_stmt->bindValue('date_end', $new_date_end); - - $wrl_result = $wrl_stmt->executeQuery(); - - $wrl_data = []; - // go through rows - while($row = $wrl_result->fetchAssociative()) - { - // check if entry has a warranty id - $w_id = $row['warranty_id']; - $warranty_id = ''; - $warranty_class = ''; - if ($w_id != null) - { - $warranty_id = $w_id; - - // find the warranty to get the warranty class - $w_sql = 'SELECT w.warranty_class AS warranty_class - FROM warranty w - WHERE w.id = :warranty_id'; - - $w_stmt = $db->prepare($w_sql); - $w_stmt->bindValue('warranty_id' , $w_id); - - $w_result = $w_stmt->executeQuery(); - - while ($w_row = $w_result->fetchAssociative()) - { - $warranty_class = $w_row['warranty_class']; - } - } - - // get the mobile number of the api user using api_user_id - $api_user_id = $row['api_user_id']; - $mobile_num = ''; - if ($api_user_id != null) - { - $api_sql = 'SELECT ms.phone_number AS mobile_number - FROM mobile_session ms - WHERE ms.id = :api_user_id'; - - $api_stmt = $db->prepare($api_sql); - $api_stmt->bindValue('api_user_id', $api_user_id); - - $api_result = $api_stmt->executeQuery(); - - while ($api_row = $api_result->fetchAssociative()) - { - $mobile_num = $api_row['mobile_number']; - } - } - - $raffle_number = ''; - $hub = ''; - $battery_name = $row['model_name'] . ' / ' . $row['size_name']; - - // get the date from the date schedule - $date_array = explode(' ' , $row['date_create']); - $date_create = $date_array[0]; - - $wrl_data[] = [ - 'raffle_num' => $raffle_number, - 'serial' => $row['serial'], - 'product_name' => $battery_name, - 'warranty_id' => $row['wrl_id'], - 'date' => $date_create, - 'hub' => $hub, - 'plate_number' => $row['plate_number'], - 'warranty_class' => $warranty_class, - 'first_name' => $row['first_name'], - 'last_name' => $row['last_name'], - 'contact_number' => $row['contact_num'], - 'mobile_number' => $mobile_num, - 'address' => $row['address'], - 'email' => $row['email'], - 'action' => $row['action'], - ]; - } - - return $wrl_data; - } - - protected function getJORaffleData($req, $em, $raw_date_start, $raw_date_end) - { - $date_start = DateTime::createFromFormat('m/d/Y', $raw_date_start); - $date_end = DateTime::createFromFormat('m/d/Y', $raw_date_end); - - // change to this format: Y-m-d H:i:s - $new_date_start = $date_start->format('Y-m-d') . ' 00:00:00'; - $new_date_end = $date_end->format('Y-m-d') . ' 23:59:59'; - - $db = $em->getConnection(); - - // get JOs that have been scheduled within the date range and are fulfilled - // and service type is battery sales - $jo_sql = 'SELECT jo.id AS jo_id, cv.warranty_code AS serial, jo.date_schedule AS date_schedule, - h.name AS hub_name, cv.plate_number AS plate_number, jo.warranty_class AS warranty_class, - c.first_name AS first_name, c.last_name AS last_name, c.phone_mobile AS mobile_number, - c.email AS email - FROM job_order jo, customer_vehicle cv, hub h, customer c - WHERE jo.cvehicle_id = cv.id - AND jo.customer_id = c.id - AND jo.hub_id = h.id - AND jo.status = :fulfilled - AND jo.service_type = :battery_sales - AND jo.date_schedule >= :date_start AND jo.date_schedule <= :date_end'; - $jo_stmt = $db->prepare($jo_sql); - $jo_stmt->bindValue('fulfilled', JOStatus::FULFILLED); - $jo_stmt->bindValue('battery_sales', ServiceType::BATTERY_REPLACEMENT_NEW); - $jo_stmt->bindValue('date_start', $new_date_start); - $jo_stmt->bindValue('date_end', $new_date_end); - - $jo_result = $jo_stmt->executeQuery(); - - $jo_data = []; - // go through rows - while($row = $jo_result->fetchAssociative()) - { - // need to get the battery ordered - $jo_id = $row['jo_id']; - - $b_sql = 'SELECT bmodel.name AS model_name, bsize.name AS size_name - FROM battery_model bmodel, battery_size bsize, battery b, - invoice i, invoice_item ii - WHERE b.model_id = bmodel.id - AND b.size_id = bsize.id - AND ii.invoice_id = i.id - AND ii.battery_id = b.id - AND i.job_order_id = :jo_id'; - - $b_stmt = $db->prepare($b_sql); - $b_stmt->bindValue('jo_id', $jo_id); - - $b_result = $b_stmt->executeQuery(); - - $b_data = []; - - $battery_name = ''; - while ($b_row = $b_result->fetchAssociative()) - { - $battery_name = $b_row['model_name'] . ' / ' . $b_row['size_name']; - } - - // get the date from the date schedule - $date_array = explode(' ' , $row['date_schedule']); - $date_schedule = $date_array[0]; - - $raffle_number = ''; - $address = ''; - - $jo_data[] = [ - 'raffle_num' => $raffle_number, - 'serial' => $row['serial'], - 'product_name' => $battery_name, - 'jo_id' => $jo_id, - 'date' => $date_schedule, - 'hub' => $row['hub_name'], - 'plate_number' => $row['plate_number'], - 'warranty_class' => $row['warranty_class'], - 'first_name' => $row['first_name'], - 'last_name' => $row['last_name'], - 'contact_number' => $row['mobile_number'], - 'address' => $address, - 'email' => $row['email'] - ]; - } - - return $jo_data; - } } diff --git a/src/Controller/TAPI/BatteryController.php b/src/Controller/TAPI/BatteryController.php deleted file mode 100644 index 0874b792..00000000 --- a/src/Controller/TAPI/BatteryController.php +++ /dev/null @@ -1,94 +0,0 @@ -acl_gen = $acl_gen; - } - - public function getCompatibleBatteries(Request $req, $vid, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_battery_compatible.list', null, 'No access.'); - - // check required parameters and api key - $required_params = []; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - // get vehicle - $vehicle = $em->getRepository(Vehicle::class)->find($vid); - if ($vehicle == null) - { - $message = 'Invalid vehicle id.'; - return new APIResponse(false, $message); - } - - // batteries - $batt_list = []; - // $batts = $vehicle->getBatteries(); - $batts = $vehicle->getActiveBatteries(); - foreach ($batts as $batt) - { - // TODO: Add warranty_tnv to battery information - $batt_list[] = [ - 'id' => $batt->getID(), - 'mfg_id' => $batt->getManufacturer()->getID(), - 'mfg_name' => $batt->getManufacturer()->getName(), - 'model_id' => $batt->getModel()->getID(), - 'model_name' => $batt->getModel()->getName(), - 'size_id' => $batt->getSize()->getID(), - 'size_name' => $batt->getSize()->getName(), - 'price' => $batt->getSellingPrice(), - 'wty_private' => $batt->getWarrantyPrivate(), - 'wty_commercial' => $batt->getWarrantyCommercial(), - 'image_url' => $this->getBatteryImageURL($req, $batt), - ]; - } - - // data - $data = [ - 'vehicle' => [ - 'id' => $vehicle->getID(), - 'mfg_id' => $vehicle->getManufacturer()->getID(), - 'mfg_name' => $vehicle->getManufacturer()->getName(), - 'make' => $vehicle->getMake(), - 'model_year_from' => $vehicle->getModelYearFrom(), - 'model_year_to' => $vehicle->getModelYearTo(), - ], - 'batteries' => $batt_list, - ]; - - $message = 'Compatible batteries found.'; - return new APIResponse(true, $message, $data); - } - - // TODO: might have to put this in a common service since JobOrderController also calls this - protected function getBatteryImageURL($req, $batt) - { - // TODO: workaround for now, we get static image of battery based on model name - $filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg'; - $file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename; - - return $file_path; - } -} diff --git a/src/Controller/TAPI/JobOrderController.php b/src/Controller/TAPI/JobOrderController.php deleted file mode 100644 index e70928f8..00000000 --- a/src/Controller/TAPI/JobOrderController.php +++ /dev/null @@ -1,1817 +0,0 @@ -acl_gen = $acl_gen; - } - - // TODO: break this monolithic method down - public function requestJobOrder(Request $req, InvoiceGeneratorInterface $ic, GeofenceTracker $geo, - InventoryManager $im, MQTTClient $mclient, - RiderAssignmentHandlerInterface $rah, PromoLogger $promo_logger, - HubSelector $hub_select, HubDistributor $hub_dist, HubFilterLogger $hub_filter_logger, - HubFilteringGeoChecker $hub_geofence, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_jo.request', null, 'No access.'); - - // check required parameters and api key - $required_params = [ - 'service_type', - 'trade_in_type', - 'longitude', - 'latitude', - 'mode_of_payment', - 'first_name', - 'last_name', - 'mobile_number', - 'vehicle_manufacturer_id', - 'vehicle_model_id', - 'vehicle_model_year', - 'vehicle_color', - 'vehicle_condition', - 'vehicle_fuel_type', - 'plate_number' - ]; - - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - // get data from request - $data = []; - $status = $this->getJobOrderRequestInfo($req, $em, $data); - if ($status != null) - return new APIResponse(false, $status); - - $is_covered = false; - // geofence - $is_covered = $geo->isCovered($data['long'], $data['lat']); - - if (!$is_covered) - { - // TODO: put geofence error message in config file somewhere - $msg = 'Oops! Our service is limited to some areas in Metro Manila, Laguna, and Baguio only. We will update you as soon as we are able to cover your area'; - return new APIResponse(false, $msg); - } - - $jo = new JobOrder(); - $jo->setSource($data['source']) - ->setStatus(JOStatus::PENDING) - ->setServiceType($data['service_type']) - ->setWarrantyClass($data['warranty_class']) - ->setDeliveryInstructions($data['instructions']) - ->setTier1Notes('') - ->setTier2Notes('') - ->setDeliveryAddress($data['address']) - ->setTradeInType($data['trade_in_type']) - ->setDeliveryInstructions($data['instructions']) - ->setModeOfPayment($data['payment_mode']) - ->setAdvanceOrder($data['is_advance_order']) - ->setStatusAutoAssign(AutoAssignStatus::NOT_ASSIGNED) - ->setLandmark($data['landmark']); - - $jo->setCustomer($data['customer']); - $jo->setCustomerVehicle($data['customer_vehicle']); - - // set coordinates - $point = new Point($data['long'], $data['lat']); - $jo->setCoordinates($point); - - // make invoice criteria - $icrit = new InvoiceCriteria(); - $icrit->setServiceType($data['service_type']); - - // TODO add promo to criteria if any - // check promo - // put in criteria - if ($data['promo'] != null) - $icrit->addPromo($data['promo']); - - $icrit->setCustomerVehicle($data['customer_vehicle']); - - $icrit->addEntry($data['batt'], $data['trade_in_type'], 1); - - // send to invoice generator - $invoice = $ic->generateInvoice($icrit); - $jo->setInvoice($invoice); - - // assign hub and rider - // check if hub is null - $hub = $data['hub']; - if ($hub == null) - { - // TODO: need to factor out the setting of HubCriteria fields - $hub_criteria = new HubCriteria(); - $hub_criteria->setPoint($jo->getCoordinates()); - - // get distance limit for mobile from env - // get value of hub_filter_enable from env - $dotenv = new Dotenv(); - $dotenv->loadEnv(__DIR__.'/../../../.env'); - $limit_distance = $_ENV['CUST_DISTANCE_LIMIT']; - $hub_filter_enabled = $_ENV['HUB_FILTER_ENABLE']; - - // set distance limit - $hub_criteria->setLimitDistance($limit_distance); - - // check if hub filter is enabled. If not, use default values - // for the rest of the HubCriteria fields - if ($hub_filter_enabled == 'true') - { - // error_log('hub filter is enabled'); - // check if customer location is in hub filter area - if ($hub_geofence->isCovered($data['long'], $data['lat'])) - { - // if true, set other values for HubCriteria - // TODO: set this properly, since the other flags - // are on default values - // error_log('Area is covered by hub filtering'); - $hub_criteria->setJoType($jo->getServiceType()) - ->setPaymentMethod($jo->getModeOfPayment()) - ->setRoundRobin(true); - } - } - - // check if batt is null - $batt = $data['batt']; - if ($batt != null) - { - // add battery to items - $sku = $batt->getSAPCode(); - if (!empty($sku)) - $hub_criteria->addItem($batt->getSAPCode(), 1); - } - - // get customer id. No JO id at this point - $cust = $data['customer']; - $customer_id = $cust->getID(); - - $hub_criteria->setCustomerId($customer_id); - - // find nearest hubs - $nearest_hubs = $hub_select->find($hub_criteria); - - if (!empty($nearest_hubs)) - { - // go through the hub list, find the nearest hub - // with an available rider - // error_log('found nearest hub ' . $nearest_hub->getID()); - foreach ($nearest_hubs as $nearest_hub) - { - // check if hub can be auto assigned - // if not, move on to the next hub in the list - if (($nearest_hub['hub']->isHubAutoAssign())) - { - // check if hub has riders that can be auto assigned - // if not, move on to the next hub - if (($nearest_hub['hub']->isRiderAutoAssign())) - { - $available_riders = $nearest_hub['hub']->getAvailableRiders(); - if (count($available_riders) >= 1) - { - $assigned_rider = null; - if (count($available_riders) == 1) - { - $assigned_rider = $available_riders[0]; - } - else - { - // TODO: the setting of riders into an array - // will no longer be necessary when the contents - // of randomizeRider changes - $riders = []; - foreach ($available_riders as $rider) - { - $riders[] = $rider; - } - - $assigned_rider = $this->randomizeRider($riders); - } - - $jo->setHub($nearest_hub['hub']); - $jo->setRider($assigned_rider); - $jo->setStatus(JOStatus::ASSIGNED); - $jo->setStatusAutoAssign(AutoAssignStatus::HUB_AND_RIDER_ASSIGNED); - $jo->setDeliveryStatus(DeliveryStatus::RIDER_ASSIGN); - - // set date_assigned for job order - $jo->setDateAssign(new DateTime()); - - $assigned_rider->setAvailable(false); - - // set rider's current job order - $assigned_rider->setCurrentJobOrder($jo); - - // update redis hub_jo_count for hub - $hub_dist->incrementJoCountForHub($nearest_hub['hub']); - - // break out of loop - break; - } - else - { - // we just create the JO and let admin panel handle the hub assignment - // log hub into hub_filter_log - $hub_filter_logger->logFilteredHub($nearest_hub['hub'], 'no_available_rider', null, $cust->getID()); - // continue to go through list to find hub with an available rider - } - } - else - { - // TODO: log hub as cannot be auto rider assigned somewhere - // assign hub - // error_log('Rider cannot be auto assigned ' . $nearest_hub['hub']->getID()); - $jo->setHub($nearest_hub['hub']); - $jo->setStatus(JOStatus::RIDER_ASSIGN); - $jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED); - - // update redis hub_jo_count for hub - $hub_dist->incrementJoCountForHub($nearest_hub['hub']); - - break; - } - } - else - { - // TODO: log hub as cannot be auto assigned somewhere - // move to next hub - error_log('Hub cannot be auto-assigned ' . $nearest_hub['hub']->getID()); - continue; - } - } - } - } - else - { - $jo->setHub($hub); - $jo->setStatus(JOStatus::RIDER_ASSIGN); - $jo->setStatusAutoAssign(AutoAssignStatus::HUB_ASSIGNED); - - if ($data['date_schedule'] != null) - $jo->setDateSchedule($data['date_schedule']); - - // update redis hub_jo_count for hub - $hub_dist->incrementJoCountForHub($hub); - } - - $em->persist($jo); - $em->persist($invoice); - - // add event log for JO - $event = new JOEvent(); - $event->setDateHappen(new DateTime()) - ->setTypeID(JOEventType::CREATE) - ->setJobOrder($jo); - $em->persist($event); - - // check JO status - if ($jo->getStatus() == JOStatus::ASSIGNED) - { - // add event logs for hub and rider assignments - $hub_assign_event = new JOEvent(); - $hub_assign_event->setDateHappen(new DateTime()) - ->setTypeID(JOEventType::HUB_ASSIGN) - ->setJobOrder($jo); - - $em->persist($hub_assign_event); - - $rider_assign_event = new JOEvent(); - $rider_assign_event->setDateHappen(new DateTime()) - ->setTypeID(JOEventType::RIDER_ASSIGN) - ->setJobOrder($jo); - - $em->persist($rider_assign_event); - - // user mqtt event - $payload = [ - 'event' => 'outlet_assign' - ]; - $mclient->sendEvent($jo, $payload); - - $rah->assignJobOrder($jo, $jo->getRider()); - } - - if ($jo->getStatus() == JOStatus::RIDER_ASSIGN) - { - // add event logs for hub assignments - $hub_assign_event = new JOEvent(); - $hub_assign_event->setDateHappen(new DateTime()) - ->setTypeID(JOEventType::HUB_ASSIGN) - ->setJobOrder($jo); - - $em->persist($hub_assign_event); - - // user mqtt event - $payload = [ - 'event' => 'outlet_assign' - ]; - $mclient->sendEvent($jo, $payload); - } - - $em->flush(); - - // make invoice json data - $invoice_data = [ - 'total_price' => number_format($invoice->getTotalPrice(), 2, '.', ''), - 'vat_ex_price' => number_format($invoice->getVATExclusivePrice(), 2, '.', ''), - 'vat' => number_format($invoice->getVAT(), 2, '.', ''), - 'discount' => number_format($invoice->getDiscount(), 2, '.', ''), - 'trade_in' => number_format($invoice->getTradeIn(), 2, '.', ''), - ]; - $items = $invoice->getItems(); - $items_data = []; - foreach ($items as $item) - { - $items_data[] = [ - 'title' => $item->getTitle(), - 'qty' => $item->getQuantity() + 0, - 'price' => number_format($item->getPrice() + 0.0, 2, '.', '') - ]; - } - $invoice_data['items'] = $items_data; - - // make job order data - $data = [ - 'jo_id' => $jo->getID(), - 'invoice' => $invoice_data - ]; - - // set data - $message = 'Job order created.'; - - return new APIResponse(true, $message, $data); - } - - public function getEstimate(Request $req, InvoiceGeneratorInterface $ic, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_jo.get.estimate', null, 'No access.'); - - // check required parameters and api key - $required_params = [ - 'service_type', - 'vehicle_model_id', - ]; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - $data = []; - $msg = $this->validateAndGetEstimateRequest($req, $em, $data); - if ($msg != null) - return new APIResponse(false, $msg); - - // make invoice criteria - $icrit = new InvoiceCriteria(); - $icrit->setServiceType($data['service_type']); - $icrit->setCustomerVehicle($data['customer_vehicle']); - - if ($data['promo'] != null) - $icrit->addPromo($data['promo']); - - $icrit->addEntry($data['battery'], $data['trade_in_type'], 1); - - // send to invoice generator - $invoice = $ic->generateInvoice($icrit); - - // make invoice json data - $data = [ - 'total_price' => (float) $invoice->getTotalPrice(), - 'vat_ex_price' => (float) $invoice->getVATExclusivePrice(), - 'vat' => (float) $invoice->getVAT(), - 'discount' => (float) $invoice->getDiscount(), - 'trade_in' => (float) $invoice->getTradeIn(), - ]; - $items = $invoice->getItems(); - $items_data = []; - foreach ($items as $item) - { - $my_data = [ - 'title' => $item->getTitle(), - 'qty' => (int) $item->getQuantity() + 0, - 'price' => (float) $item->getPrice() + 0.0, - ]; - - $item_batt = $item->getBattery(); - if ($item_batt != null) - { - $my_data['image_url'] = $this->getBatteryImageURL($req, $item_batt); - } - - $items_data[] = $my_data; - } - - $data['items'] = $items_data; - - $message = 'Estimate computed.'; - return new APIResponse(true, $message, $data); - } - - public function getJOInvoice(Request $req, $jo_id, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_jo.get.invoice', null, 'No access.'); - - $required_params = []; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - $jo = $em->getRepository(JobOrder::class)->find($jo_id); - if ($jo == null) - { - $message = 'No job order found'; - return new APIResponse(false, $message); - } - - $invoice = $jo->getInvoice(); - - // make invoice json data - $data = [ - 'total_price' => (float) $invoice->getTotalPrice(), - 'vat_ex_price' => (float) $invoice->getVATExclusivePrice(), - 'vat' => (float) $invoice->getVAT(), - 'discount' => (float) $invoice->getDiscount(), - 'trade_in' => (float) $invoice->getTradeIn(), - ]; - $items = $invoice->getItems(); - $items_data = []; - foreach ($items as $item) - { - $my_data = [ - 'title' => $item->getTitle(), - 'qty' => (int) $item->getQuantity() + 0, - 'price' => (float) $item->getPrice() + 0.0, - ]; - - $item_batt = $item->getBattery(); - if ($item_batt != null) - { - $my_data['image_url'] = $this->getBatteryImageURL($req, $item_batt); - } - - $items_data[] = $my_data; - } - - $data['items'] = $items_data; - - $message = 'JO invoice found.'; - return new APIResponse(true, $message, $data); - } - - public function cancelJobOrder(Request $req, MQTTClient $mclient, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_jo.cancel', null, 'No access.'); - - $required_params = [ - 'jo_id', - 'reason' - ]; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - // get job order - $jo_id = $req->request->get('jo_id'); - $jo = $em->getRepository(JobOrder::class)->find($jo_id); - if ($jo == null) - { - $message = 'No job order found'; - return new APIResponse(false, $message); - } - - // TODO: check job order status, if it's cancellable - $cancel_reason = $req->request->get('reason'); - - $jo->cancel($cancel_reason); - - // add event log - $event = new JOEvent(); - $event->setDateHappen(new DateTime()) - ->setTypeID(JOEventType::CANCEL) - ->setJobOrder($jo); - $em->persist($event); - - $em->flush(); - - // TODO: do we need this? - // send mobile app event - $payload = [ - 'event' => 'cancelled', - 'reason' => $cancel_reason, - 'jo_id' => $jo->getID(), - ]; - $mclient->sendRiderEvent($jo, $payload); - - $data = []; - $message = 'Job order cancelled.'; - - return new APIResponse(true, $message, $data); - } - - // we can't use param converter for now because we want to output the proper 404 - public function getJobOrderInfo($jo_id, Request $req, EntityManagerInterface $em, RiderTracker $rt) - { - $this->denyAccessUnlessGranted('tapi_jo.get.info', null, 'No access.'); - - // check required parameters - $required_params = []; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - // get job order data - $jo = $em->getRepository(JobOrder::class)->find($jo_id); - if ($jo == null) - { - $message = 'No job order information found'; - return new APIResponse(false, $message); - } - - // put into job order data array - $jo_data = $this->generateJobOrderData($req, $jo, $rt, $em); - - $data = [ - 'job_order' => $jo_data - ]; - - $message = 'Job order information found.'; - return new APIResponse(true, $message, $data); - } - - public function locationSupport(Request $req, GeofenceTracker $geo, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_jo.location.support', null, 'No access.'); - - $required_params = [ - 'longitude', - 'latitude', - ]; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - $long = $req->request->get('longitude'); - $lat = $req->request->get('latitude'); - - $is_covered = false; - // geofence - $is_covered = $geo->isCovered($long, $lat); - - $data = [ - 'longitude' => $long, - 'latitude' => $lat, - 'supported' => $is_covered, - ]; - - // check if is_covered is false. If so, we need to modify the message - $message = 'Location is supported.'; - if (!$is_covered) - { - $message = 'Oops! Our service is limited to some areas in Metro Manila, Laguna, and Baguio only. We will update you as soon as we are able to cover your area'; - } - - return new APIResponse(true, $message, $data); - } - - // TODO: should we change to the HubSelector? - public function getNearestHubAndSlots(Request $req, EntityManagerInterface $em, - MapTools $map_tools) - { - $this->denyAccessUnlessGranted('tapi_jo.nearest_hub.get', null, 'No access.'); - - $required_params = [ - 'longitude', - 'latitude', - ]; - - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - $coordinates = new Point($req->request->get('longitude'), $req->request->get('latitude')); - - $nearest_hub_slots = $this->findAdvanceNearestHubAndSlots($coordinates, $em, $map_tools); - - if (empty($nearest_hub_slots['hub'])) - { - $message = 'Thank you for reaching out to us. Please expect a call from us and we will assist you with your request. Thank you and stay safe!'; - return new APIResponse (false, $message); - } - - // make hub data - $data = [ - 'hub_id' => $nearest_hub_slots['hub']->getID(), - 'hub_slots' => $nearest_hub_slots['slots'], - ]; - - $message = 'Nearest hub and slots found.'; - - return new APIResponse(true, $message, $data); - } - - // comment out for now - /* - public function scheduleOptionStatus(Request $req, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_jo.schedule_option.status', null, 'No access.'); - - // check required parameters and api key - $required_params = []; - $res = $this->checkParamsAndKey($req, $em, $required_params); - if ($res->isError()) - return $res->getReturnResponse(); - - $schedule_choice = true; - - // remove the time check after ECQ. This will then always return true - // get current time - $current_datetime = new DateTime(); - //$current_datetime = DateTime::createFromFormat('Y-m-d H:i', '2020-04-30 17:01'); - - // get the hour - $hour = $current_datetime->format('G'); - - // commenting out the time check since we can now book 24/7 - // this will get uncommented out if and when ECQ will kick in - //if (($hour < 8) || ($hour > 16)) - // $schedule_choice = false; - - // add checking if customer has a pre-registered hub - // TODO: modify how we get customer - $cust = $this->session->getCustomer(); - if ($cust == null) - { - $res->setError(true) - ->setErrorMessage('No customer information found'); - return $res->getReturnResponse(); - } - // check if customer has customer tag promo - if (($cust->getCustomerTag('TAG_CAR_CLUB_OFFICER_PROMO')) || - ($cust->getCustomerTag('TAG_CAR_CLUB_MEMBER_PROMO'))) - { - // if has customer tag, customer has not availed of promo, get the hub where customer is pre-registered - $car_club_hub = $cust->getCarClubCustomerHub(); - if ($car_club_hub != null) - { - $schedule_choice = false; - } - } - - // schedule_choice will always be true aka customer can opt to - // Book Now or Schedule Order EXCEPT if customer has customer tag promo - // or ECQ comes back - $data = [ - 'display_schedule_choice' => $schedule_choice, - ]; - $res->setData($data); - - return $res->getReturnResponse(); - } - */ - - protected function generateJobOrderData($req, $jo, $rt, $em) - { - $status = $jo->getStatus(); - - $dest = $jo->getCoordinates(); - - $jo_data = [ - 'id' => $jo->getID(), - 'date_create' => $jo->getDateCreate()->format('M d, Y'), - 'service_type' => $jo->getServiceType(), - 'destination' => [ - 'long' => $dest->getLongitude(), - 'lat' => $dest->getLatitude(), - ], - 'delivery_address' => $jo->getDeliveryAddress(), - 'delivery_instructions' => $jo->getDeliveryInstructions(), - 'jo_status' => $status, - 'status' => $this->generateAPIRiderStatus($status), - ]; - - // customer vehicle and warranty - $cv = $jo->getCustomerVehicle(); - - // get latest warranty using plate number - $warranty = $this->findWarranty($cv->getPlateNumber(), $em); - - $jo_data['customer_vehicle'] = [ - 'id' => $cv->getID(), - 'plate_number' => $cv->getPlateNumber(), - 'warranty' => $warranty, - ]; - - // customer information - $customer = $jo->getCustomer(); - $jo_data['customer'] = [ - 'first_name' => $customer->getFirstName(), - 'last_name' => $customer->getLastName(), - 'mobile_number' => $customer->getPhoneMobile(), - ]; - - // rider - $rider = $jo->getRider(); - if ($rider != null) - { - // default image url - $url_prefix = $req->getSchemeAndHttpHost(); - $image_url = $url_prefix . '/assets/images/user.gif'; - if ($rider->getImageFile() != null) - $image_url = $url_prefix . '/uploads/' . $rider->getImageFile(); - - $coord = $rt->getRiderLocation($rider->getID()); - - $jo_data['rider'] = [ - 'id' => $rider->getID(), - 'name' => $rider->getFullName(), - 'plate_num' => $rider->getPlateNumber(), - 'contact_num' => $rider->getContactNumber(), - 'image_url' => $image_url, - 'location' => [ - 'long' => $coord->getLongitude(), - 'lat' => $coord->getLatitude() - ] - ]; - } - else - { - $jo_data['rider'] = null; - } - - // invoice items - $items = []; - $jo_items = $jo->getInvoice()->getItems(); - foreach ($jo_items as $item) - { - $items[] = [ - 'id' => $item->getID(), - 'title' => $item->getTitle(), - 'qty' => $item->getQuantity(), - 'price' => $item->getPrice(), - ]; - } - - $jo_data['items'] = $items; - - - // dates depending on status - switch ($status) - { - case JOStatus::FULFILLED: - if ($jo->getDateFulfill() == null) - $jo_data['date_fulfilled'] = ''; - else - $jo_data['date_fulfilled'] = $jo->getDateFulfill()->format('M d, Y'); - break; - case JOStatus::CANCELLED: - $date_cancel = $jo->getDateCancel(); - if ($date_cancel == null) - $date_cancel = new DateTime(); - $jo_data['date_cancelled'] = $date_cancel->format('M d, Y'); - break; - } - - return $jo_data; - } - - protected function findWarranty($plate_number, EntityManagerInterface $em) - { - // NOTE: Modify the search for the latest warranty. This seems hacky. - // get latest warranty using plate number - $warranty_results = $em->getRepository(Warranty::class)->findBy(['plate_number' => $plate_number], - ['date_create' => 'desc']); - - $warr = []; - - // check if warranty_results is empty - if (empty($warranty_results)) - { - /* - $res->setError(true) - ->setErrorMessage('No warranty found for plate number'); - return $res->getReturnResponse(); - */ - - return $warr; - } - - // get first entry - $warranty = current($warranty_results); - - // check for null values for battery and date claim and date expire - $batt_model = ''; - $batt_size = ''; - $sap_batt = ''; - $claim_date = ''; - $expiry_date = ''; - - if (!(is_null($warranty->getBatteryModel()))) { - $batt_model = $warranty->getBatteryModel()->getName(); - } - if (!(is_null($warranty->getBatterySize()))) { - $batt_size = $warranty->getBatterySize()->getName(); - } - if (!(is_null($warranty->getSAPBattery()))) { - $sap_batt = $warranty->getSAPBattery()->getID(); - } - if (!(is_null($warranty->getDateClaim()))) { - $claim_date = $warranty->getDateClaim()->format("d M Y"); - } - if (!(is_null($warranty->getDateExpire()))) { - $expiry_date = $warranty->getDateExpire()->format("d M Y"); - } - - $warr[] = [ - 'id' => $warranty->getID(), - 'serial' => $warranty->getSerial(), - 'warranty_class' => $warranty->getWarrantyClass(), - 'plate_number' => $warranty->getPlateNumber(), - 'first_name' => $warranty->getFirstName(), - 'last_name' => $warranty->getLastName(), - 'mobile_number' => $warranty->getMobileNumber(), - 'battery_model' => $batt_model, - 'battery_size' => $batt_size, - 'sap_battery' => $sap_batt, - 'status' => $warranty->getStatus(), - 'date_create' => $warranty->getDateCreate()->format("d M Y g:i A"), - 'date_purchase' => $warranty->getDatePurchase()->format("d M Y"), - 'date_expire' => $expiry_date, - 'date_claim' => $claim_date, - 'claim_from' => $warranty->getClaimedFrom(), - 'is_activated' => $warranty->isActivated() ? 1 : 0, - ]; - - return $warr; - } - - protected function findAdvanceNearestHubAndSlots(Point $coordinates, EntityManagerInterface $em, MapTools $map_tools, $hub=null) - { - $hub_data = []; - - if ($hub != null) - { - // get the slots of hub - $hub_slots = $this->getHubRiderSlots($hub, $em); - - $slots = $hub_slots['slot_data']; - - $hub_data = [ - 'hub' => $hub, - 'slots' => $slots, - ]; - return $hub_data; - } - - // get the nearest 10 hubs - $nearest_hubs_with_distance = []; - $hubs = $map_tools->getClosestOpenHubs($coordinates, 10); - - foreach ($hubs as $hub) - { - $nearest_hubs_with_distance[] = $hub; - // TODO: insert checking for branch code here when inventory manager is up - } - - $nearest = null; - $hub_slots = []; - $slot_found = false; - // find the nearest hub - if (!empty($nearest_hubs_with_distance)) - { - // get slots of nearest hub right after getting nearest hub. - // then check if hub has available slots. If not, get next nearest hub. - foreach ($nearest_hubs_with_distance as $nhd) - { - if (empty($nearest)) - { - // get the slots for the hub to check if hub is available for assignment - $hub_slots = $this->getHubRiderSlots($nhd['hub'], $em); - - $flag_hub_available = $hub_slots['flag_hub_available']; - if ($flag_hub_available == true) - { - $nearest = $nhd; - } - } - else - { - if ($nhd['distance'] < $nearest['distance']) - { - // get the slots for nearest which is nhd right now - $hub_slots = $this->getHubRiderSlots($nhd['hub'], $em); - - $flag_hub_available = $hub_slots['flag_hub_available']; - - // if hub is available, set hub to nearest - if ($flag_hub_available == true) - { - $nearest = $nhd; - } - } - } - } - } - - if ($nearest != null) - { - // set hub data to what is in nearest - $hub_data = [ - 'hub' => $nearest['hub'], - 'slots' => $hub_slots['slot_data'], - ]; - } - - return $hub_data; - - } - - protected function getHubRiderSlots(Hub $hub, EntityManagerInterface $em) - { - // check hub's advance orders for the day - - /* - // get number of advance orders for the next day if request came in before midnight - // or for current day if request came in after midnight - // check request_time - $request_time = time(); - $midnight = strtotime('00:00'); - */ - $start_date = new DateTime(); - $end_date = new DateTime(); - - // to keep things simple, just start on next day regardless of midnight timer - $start_date->add(new DateInterval('P1D')); - $end_date->add(new DateInterval('P3D')); - - /* - if ($request_time < $midnight) - { - // add +1 to start date to get the next day - // add +3 to date to end date to get the advance orders for the next three days - $start_date->add(new DateInterval('P1D')); - $end_date->add(new DateInterval('P1D')); - } - $end_date->add(new DateInterval('P2D')); - */ - - // set time bounds for the start and end date - $start_date->setTime(0, 1); - $end_date->setTime(23, 59); - - // NOTE: get advance orders via query - // get JOs assigned to hub that are advance orders and scheduled for the next three days with - // for hub assignment status - $query = $em->createQuery('select jo from App\Entity\JobOrder jo where jo.hub = :hub and jo.flag_advance = true and - jo.date_schedule >= :date_start and jo.date_schedule <= :date_end and jo.status != :status_cancelled - and jo.status != :status_fulfilled'); - $jos_advance_orders = $query->setParameters([ - 'hub' => $hub, - 'date_start' => $start_date, - 'date_end' => $end_date, - 'status_cancelled' => JOStatus::CANCELLED, - 'status_fulfilled' => JOStatus::FULFILLED, - ]) - ->getResult(); - // check request_time - - // define slots - $slots = [ - '08_09' => '8:00 AM', - '09_10' => '9:00 AM', - '10_11' => '10:00 AM', - '11_12' => '11:00 AM', - '12_13' => '12:00 PM', - '13_14' => '1:00 PM', - '14_15' => '2:00 PM', - '15_16' => '3:00 PM', - '16_17' => '4:00 PM', - ]; - - // get the dates for the next three days - $first_date = $start_date->format('Y-m-d'); - $second_date = $start_date->add(new DateInterval('P1D')); - $sec_date = $second_date->format('Y-m-d'); - $third_date = $end_date->format('Y-m-d'); - - // define days - $days = [ - $first_date => $first_date, - $sec_date => $sec_date, - $third_date => $third_date, - ]; - - // initialize hub rider slots - $hub_rider_slots = []; - foreach ($days as $day) - { - foreach ($slots as $slot_key => $slot) - { - $hub_rider_slots[$day][$slot_key] = $hub->getRiderSlots(); - } - } - - // check each JO's date_schedule, decrement rider_slots if date schedule falls in that slot - foreach ($jos_advance_orders as $jo) - { - // get date key - $date_sched = $jo->getDateSchedule(); - $date_string = $date_sched->format('Y-m-d'); - $hour = $date_sched->format('H'); - $slot_id = sprintf('%02d_%02d', $hour, $hour + 1); - - // error_log("SLOT - $date_string - $slot_id"); - - // decrement rider slot - if (isset($hub_rider_slots[$date_string][$slot_id])) - $hub_rider_slots[$date_string][$slot_id]--; - - // check if it goes through next slot (10 min allowance) - $mins = $date_sched->format('i'); - if ($mins > 10) - { - $next_slot_id = sprintf('%02d_%02d', $hour + 1, $hour + 2); - // error_log("NEXT SLOT - $date_string - $next_slot_id"); - // decrement rider slot - if (isset($hub_rider_slots[$date_string][$next_slot_id])) - $hub_rider_slots[$date_string][$next_slot_id]--; - - } - } - - // error_log(print_r($hub_rider_slots, true)); - - $hub_slots = $this->generateHubSlots($hub_rider_slots, $slots); - - // error_log(print_r($hub_slots, true)); - - return $hub_slots; - } - - protected function generateHubSlots($rider_slots, $slots) - { - $data = []; - $total_rslots = 0; - $total_unavailable_rslots = 0; - foreach ($rider_slots as $day_id => $rslot) - { - $data[$day_id] = []; - - foreach ($rslot as $slot_id => $avail_slots) - { - // increment total rider slots - $total_rslots++; - - $slot_data = [ - 'id' => $slot_id, - 'label' => $slots[$slot_id], - 'available' => true, - ]; - - // mark unavailable ones - if ($avail_slots <= 0) - { // increment total number of unavailable slots - $total_unavailable_rslots++; - $slot_data['available'] = false; - } - - // add to day data - $data[$day_id][] = $slot_data; - } - } - - // check if hub has available slots - $hub_available = true; - // error_log('total rider slots ' . $total_rslots); - // error_log('total unavailable slots ' . $total_unavailable_rslots); - if ($total_rslots == $total_unavailable_rslots) - { - // error_log('hub has no available slots'); - $hub_available = false; - } - - $hs_data = [ - 'flag_hub_available' => $hub_available, - 'slot_data' => $data, - ]; - - return $hs_data; - } - - protected function getTimeFromSlot($slot_id) - { - $time_selected = ''; - - switch($slot_id) { - case '08_09': - $time_selected = AdvanceOrderSlot::_08_09; - break; - case '09_10': - $time_selected = AdvanceOrderSlot::_09_10; - break; - case '10_11': - $time_selected = AdvanceOrderSlot::_10_11; - break; - case '11_12': - $time_selected = AdvanceOrderSlot::_11_12; - break; - case '12_13': - $time_selected = AdvanceOrderSlot::_12_13; - break; - case '13_14': - $time_selected = AdvanceOrderSlot::_13_14; - break; - case '14_15': - $time_selected = AdvanceOrderSlot::_14_15; - break; - case '15_16': - $time_selected = AdvanceOrderSlot::_15_16; - break; - case '16_17': - $time_selected = AdvanceOrderSlot::_16_17; - break; - default: - error_log('Invalid slot id ' . $slot_id); - } - - return $time_selected; - } - - protected function randomizeRider($riders) - { - // TODO: get redis to track the sales per rider per day - // check the time they came in - // for now, randomize the rider - $selected_index = array_rand($riders); - - $selected_rider = $riders[$selected_index]; - - return $selected_rider; - } - - // TODO: might have to put this in a common service since BatteryController also calls this - protected function getBatteryImageURL($req, $batt) - { - // TODO: workaround for now, we get static image of battery based on model name - $filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg'; - $file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename; - - return $file_path; - } - - protected function getJobOrderRequestInfo(Request $req, EntityManagerInterface $em, &$data) - { - $error = $this->validateJORequest($req, $em); - if ($error != null) - { - // there is a validation error - return $error; - } - - $r = $req->request; - - // at this point, the request data has been validated - // trade-in type - $trade_in_type = $this->cleanText($r->get('trade_in_type', '')); - switch ($trade_in_type) - { - case TradeInType::MOTOLITE: - case TradeInType::OTHER: - break; - - default: - $trade_in_type = ''; - break; - } - - // address - $address = $r->get('delivery_address', 'Set by third party API'); - - // instructions - $instructions = $r->get('delivery_instructions', ''); - - // landmark - $landmark = $r->get('landmark', ' '); - - // longitude and latitude - $long = $r->get('longitude'); - $lat = $r->get('latitude'); - - // get service type - $stype = $this->cleanText($r->get('service_type', '')); - - // get mode of payment - $payment_mode = $this->cleanText($r->get('mode_of_payment', '')); - - $advance_order = $r->get('flag_advance_order', 0); - // check for 'false' text - if ($advance_order === false || $advance_order === 0 || $advance_order === '0' || $advance_order == 'false') - $flag_advance_order = false; - else - $flag_advance_order = true; - - $hub = null; - $hub_id = $r->get('hub_id'); - if (strlen($hub_id) > 0) - $hub = $em->getRepository(Hub::class)->find($hub_id); - - $schedule_date = $r->get('date_schedule'); - $slot_id = $r->get('slot_id'); - - // process the jo date schedule - $date_schedule = null; - if ((strlen($schedule_date) > 0) && (strlen($slot_id) > 0)) - { - $time_schedule = $this->getTimeFromSlot($slot_id); - if (!empty($time_schedule)) - { - $s_date = $schedule_date . ' ' . $time_schedule; - $date_schedule = DateTime::createFromFormat('Y-m-d H:i', $s_date); - // error_log($date_schedule->format('Y-m-d H:i')); - } - } - - // get promo - $promo_id = $r->get('promo_id', 0); - $promo = $em->getRepository(Promo::class)->find($promo_id); - - // check battery - $batt_id = $req->request->get('battery_id', 0); - $batt = $em->getRepository(Battery::class)->find($batt_id); - $warranty_class = ''; - if (($batt != null) && ($stype == ServiceType::BATTERY_REPLACEMENT_NEW)) - $warranty_class = WarrantyClass::WTY_PRIVATE; - - // get customer and vehicle info - $fname = trim($r->get('first_name', '')); - $lname = trim($r->get('last_name', '')); - $mobile = $r->get('mobile_number', ''); - - // validate mobile number - $clean_mobile = $this->cleanPhoneNumber($mobile); - - $vmanu_id = $r->get('vehicle_manufacturer_id', 0); - // find vehicle manufacturer - $vmanu = $em->getRepository(VehicleManufacturer::class)->find($vmanu_id); - - $vmodel_id = $r->get('vehicle_model_id', 0); - // find vehicle - $vehicle = $em->getRepository(Vehicle::class)->find($vmodel_id); - - $plate_number = $r->get('plate_number', ''); - - // clean plate number - $clean_plate = $this->cleanPlateNumber($plate_number); - - $v_condition = $this->cleanText($r->get('vehicle_condition', '')); - $fuel_type = $this->cleanText($r->get('vehicle_fuel_type', '')); - $color = trim($r->get('vehicle_color', '')); - $model_year = trim($r->get('vehicle_model_year', 0)); - - $c_data = [ - 'first_name' => $fname, - 'last_name' => $lname, - 'mobile' => $clean_mobile, - 'vmanu' => $vmanu, - 'vehicle' => $vehicle, - 'plate_number' => $clean_plate, - 'model_year' => $model_year, - 'condition' => $v_condition, - 'color' => $color, - 'fuel_type' => $fuel_type, - ]; - - // process customer and vehicle information - $cust_data = $this->processCustomerAndVehicleInformation($c_data, $em); - - $data = [ - 'trade_in_type' => $trade_in_type, - 'service_type' => $stype, - 'long' => $long, - 'lat' => $lat, - 'payment_mode' => $payment_mode, - 'address' => $address, - 'instructions' => $instructions, - 'landmark' => $landmark, - 'is_advance_order' => $flag_advance_order, - 'hub' => $hub, - 'date_schedule' => $date_schedule, - 'promo' => $promo, - 'batt' => $batt, - 'customer' => $cust_data['customer'], - 'customer_vehicle' => $cust_data['customer_vehicle'], - 'source' => TransactionOrigin::THIRD_PARTY, - 'warranty_class' => $warranty_class, - ]; - - return null; - } - - protected function validateJORequest(Request $req, EntityManagerInterface $em) - { - $r = $req->request; - - // validate trade-in type - $trade_in_type = $this->cleanText($r->get('trade_in_type', '')); - if ((!empty($trade_in_type)) && - (!TradeInType::validate($trade_in_type))) - { - $message = 'Invalid trade in type'; - return $message; - } - - // validate service type - $stype = $this->cleanText($r->get('service_type', '')); - if (!ServiceType::validate($stype)) - { - $message = 'Invalid service type'; - return $message; - } - - // validate mode of payment - $payment_mode = $this->cleanText($r->get('mode_of_payment', '')); - if (!ModeOfPayment::validate($payment_mode)) - { - $message = 'Invalid mode of payment'; - return $message; - } - - // check promo - $promo = null; - $promo_id = $r->get('promo_id', 0); - if (!empty($promo_id)) - { - $promo = $em->getRepository(Promo::class)->find($promo_id); - if ($promo == null) - { - $message = 'Invalid promo id'; - return $message; - } - } - - // check battery - $batt = null; - $batt_id = $req->request->get('battery_id', 0); - if (!empty($batt_id)) - { - $batt = $em->getRepository(Battery::class)->find($batt_id); - if ($batt == null) - { - $message = 'Invalid battery id'; - return $message; - } - } - - // check if service type is BATTERY_REPLACEMENT_WARRANTY or - // BATTERY_REPLACEMENT_NEW and if battery_id is empty - if (($stype == ServiceType::BATTERY_REPLACEMENT_NEW) || - ($stype == ServiceType::BATTERY_REPLACEMENT_WARRANTY)) - { - if ($batt == null) - { - $message = 'battery_id cannot be empty for selected service type.'; - return $message; - } - } - - // validate mobile number - $mobile = $r->get('mobile_number', ''); - $clean_mobile = $this->cleanPhoneNumber($mobile); - if ($clean_mobile == false) - { - $message = 'Invalid mobile number.'; - return $message; - } - - $vmanu = null; - $vmanu_id = $r->get('vehicle_manufacturer_id', 0); - // validate the vehicle manufacturer id - // find vehicle manufacturer - $vmanu = $em->getRepository(VehicleManufacturer::class)->find($vmanu_id); - if ($vmanu == null) - { - $message = 'Invalid vehicle manufacturer id.'; - return $message; - } - - $vmodel = null; - $vmodel_id = $r->get('vehicle_model_id', 0); - // validate the vehicle model id - // find vehicle - $vmodel = $em->getRepository(Vehicle::class)->find($vmodel_id); - if ($vmodel == null) - { - $message = 'Invalid vehicle model id.'; - return $message; - } - - // check model year - // (1) if empty - // (2) if numeric - // (2)if it falls between a range of years - $model_year = $r->get('vehicle_model_year'); - if (empty($model_year)) - { - $message = 'Vehicle model year is empty.'; - return $message; - } - if (!is_numeric($model_year)) - { - $message = 'Invalid model year. Not a number.'; - return $message; - } - - $year_options = $this->generateYearOptions(); - // get first and last element - $first_year = $year_options[0]; - $last_year = end($year_options); - if (($model_year < $first_year) || - ($model_year > $last_year)) - { - $message = 'Invalid model year.'; - return $message; - } - - // confirm that vehicle model's manufacturer is the same as the one in vehicle - if ($vmodel->getManufacturer()->getID() != $vmanu_id) - { - $message = 'Invalid vehicle manufacturer id for vehicle model.'; - return $message; - } - - // validate vehicle condition - $v_condition = $this->cleanText($r->get('vehicle_condition', '')); - if (!VehicleStatusCondition::validate($v_condition)) - { - $message = 'Invalid vehicle condition.'; - return $message; - } - - // validate fuel type - $fuel_type = $this->cleanText($r->get('vehicle_fuel_type', '')); - if (!FuelType::validate($fuel_type)) - { - $message = 'Invalid vehicle fuel type.'; - return $message; - } - - return null; - } - - protected function processCustomerAndVehicleInformation($data, EntityManagerInterface $em) - { - $c_data = []; - - // retrieve customer info - $fname = $data['first_name']; - $lname = $data['last_name']; - $vmanu = $data['vmanu']; - $vehicle = $data['vehicle']; - $plate_number = $data['plate_number']; - $mobile = $data['mobile']; - - $cust = null; - $cust_vehicle = null; - - // find customer + customer vehicle combo - $cust_vehicle = $this->findCustomerAndCustomerVehicle($data, $em); - if ($cust_vehicle == null) - { - // find customer given phone number - $cust = $em->getRepository(Customer::class)->findOneBy(['phone_mobile' => $mobile]); - - if ($cust == null) - { - // get the api_user that made the call so that it gets added to the source - // source becomes TAPI_USER_ - $user_id = $_SERVER['HTTP_X_CATA_API_KEY']; - $source = 'TAPI_USER'; - $username = ''; - - if (!empty($user_id)) - { - $api_user = $this->getUser(); - if ($api_user != null) - { - $username = $api_user->getName(); - $source = $source . '_' . $username; - } - } - - // create new customer and customer vehicle - $cust = new Customer(); - - $cust->setFirstName($fname) - ->setLastName($lname) - ->setPhoneMobile($mobile) - ->setCreateSource($source); - - $em->persist($cust); - - // add customer vehicle - $cust_vehicle = $this->createCustomerVehicle($em, $cust, $data); - - } - else - { - // create customer vehicle - $cust_vehicle = $this->createCustomerVehicle($em, $cust, $data); - } - - $em->flush(); - } - - $c_data = [ - 'customer' => $cust_vehicle->getCustomer(), - 'customer_vehicle' => $cust_vehicle, - ]; - - return $c_data; - } - - protected function createCustomerVehicle(EntityManagerInterface $em, Customer $cust, $data) - { - // add customer vehicle - $cust_vehicle = new CustomerVehicle(); - - $cust_vehicle->setCustomer($cust) - ->setPlateNumber($data['plate_number']) - ->setVehicle($data['vehicle']) - ->setModelYear($data['model_year']) - ->setStatusCondition($data['condition']) - ->setColor($data['color']) - ->setHasMotoliteBattery(false) - ->setFuelType($data['fuel_type']); - - $em->persist($cust_vehicle); - - return $cust_vehicle; - } - - protected function findCustomerAndCustomerVehicle($data, EntityManagerInterface $em) - { - $plate_number = $data['plate_number']; - $mobile = $data['mobile']; - - $query = $em->createQuery('SELECT cv, c FROM App\Entity\CustomerVehicle cv - JOIN cv.customer c - WHERE cv.plate_number = :plate_number - AND c.phone_mobile = :phone_mobile'); - $query->setParameter('plate_number', $plate_number) - ->setParameter('phone_mobile', $mobile); - - $cust_results = $query->iterate(); - - $cust_vehicle = null; - foreach ($cust_results as $row) - { - $cust_vehicle = $row[0]; - } - - return $cust_vehicle; - } - - protected function validateAndGetEstimateRequest(Request $req, EntityManagerInterface $em, &$data) - { - $r = $req->request; - - // validate service type - $stype = $this->cleanText($r->get('service_type', '')); - if (!ServiceType::validate($stype)) - { - $message = 'Invalid service type'; - return $message; - } - - $trade_in_type = $this->cleanText($r->get('trade_in_type', '')); - if ((!empty($trade_in_type)) && - (!TradeInType::validate($trade_in_type))) - { - $message = 'Invalid trade in type'; - return $message; - } - - switch ($trade_in_type) - { - case TradeInType::MOTOLITE: - case TradeInType::OTHER: - break; - - default: - $trade_in_type = ''; - break; - } - - // check battery - $batt = null; - $batt_id = $req->request->get('battery_id', 0); - if (!empty($batt_id)) - { - $batt = $em->getRepository(Battery::class)->find($batt_id); - if ($batt == null) - { - $message = 'Invalid battery id'; - return $message; - } - } - - // check if service type is BATTERY_REPLACEMENT_WARRANTY or - // BATTERY_REPLACEMENT_NEW and if battery_id is empty - if (($stype == ServiceType::BATTERY_REPLACEMENT_NEW) || - ($stype == ServiceType::BATTERY_REPLACEMENT_WARRANTY)) - { - if ($batt == null) - { - $message = 'battery_id cannot be empty for selected service type.'; - return $message; - } - } - - $vmodel = null; - $vmodel_id = $r->get('vehicle_model_id', 0); - // validate the vehicle model id - // find vehicle - $vmodel = $em->getRepository(Vehicle::class)->find($vmodel_id); - if ($vmodel == null) - { - $message = 'Invalid vehicle model id.'; - return $message; - } - - // validate fuel type - $fuel_type = $this->cleanText($r->get('vehicle_fuel_type', '')); - if ((!empty($fuel_type)) && - (!FuelType::validate($fuel_type))) - { - $message = 'Invalid vehicle fuel type.'; - return $message; - } - - // validate promo - $promo = null; - $promo_id = $r->get('promo_id', 0); - if (!empty($promo_id)) - { - $promo = $em->getRepository(Promo::class)->find($promo_id); - if ($promo == null) - { - $message = 'Invalid promo id'; - return $message; - } - } - - // invoice criteria needs a customer vehicle object - // with customer set. We create dummy customer vehicle object - // with dummy customer set - $dummy_cv = $this->createDummyCustomerVehicle($vmodel, $fuel_type); - - $data = [ - 'service_type' => $stype, - 'trade_in_type' => $trade_in_type, - 'vehicle' => $vmodel, - 'battery' => $batt, - 'fuel_type' => $fuel_type, - 'promo' => $promo, - 'customer_vehicle' => $dummy_cv, - ]; - - return null; - } - - protected function createDummyCustomerVehicle($vmodel, $fuel_type) - { - $dummy_cv = new CustomerVehicle(); - $dummy_cust = new Customer(); - - $dummy_cv->setCustomer($dummy_cust) - ->setFuelType($fuel_type) - ->setHasMotoliteBattery(false); - - return $dummy_cv; - } - - protected function generateAPIRiderStatus($status) - { - switch ($status) - { - case JOStatus::PENDING: - return APIRiderStatus::OUTLET_ASSIGN; - case JOStatus::RIDER_ASSIGN: - return APIRiderStatus::RIDER_ASSIGN; - case JOStatus::ASSIGNED: - case JOStatus::IN_TRANSIT: - case JOStatus::IN_PROGRESS: - return APIRiderStatus::RIDER_PICK_UP; - } - return 'unknown'; - } - - protected function cleanPhoneNumber($mobile) - { - // remove any non digit character from string - $clean_number = preg_replace('~\D~', '', $mobile); - - // does it fit our 09XXXXXXXXX pattern? - if (preg_match('/^09[0-9]{9}$/', $clean_number)) - { - // strip the 0 - $c_number = substr($clean_number, 1); - return $c_number; - } - // does it fit our 9XXXXXXXXX pattern? - else if (preg_match('/^9[0-9]{9}$/', $clean_number)) - { - return $clean_number; - } - // does it fit our 63XXXXXXXXXX pattern? - else if (preg_match('/^63[0-9]{10}$/', $clean_number)) - { - // strip the 63 since we don't save the country code - $c_number = substr($clean_number, 2); - return $c_number; - } - - return false; - } - - protected function cleanPlateNumber($plate) - { - // remove spaces and make upper case - return strtoupper(str_replace(' ', '', $plate)); - } - - protected function cleanText($name) - { - return strtolower(trim($name)); - } - - protected function generateYearOptions() - { - $start_year = 1950; - return range($start_year, date("Y") + 1); - } -} - diff --git a/src/Controller/TAPI/PromoController.php b/src/Controller/TAPI/PromoController.php deleted file mode 100644 index 90cbaf0a..00000000 --- a/src/Controller/TAPI/PromoController.php +++ /dev/null @@ -1,45 +0,0 @@ -acl_gen = $acl_gen; - } - - public function listPromos(Request $req, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_promo.list', null, 'No access.'); - - // check required parameters and api key - $required_params = []; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - $data = []; - // TODO: add call to get promos here - - $message = 'Promos found.'; - - return new APIResponse(true, $message, $data); - } - -} diff --git a/src/Controller/TAPI/ServiceController.php b/src/Controller/TAPI/ServiceController.php deleted file mode 100644 index 5f468cd8..00000000 --- a/src/Controller/TAPI/ServiceController.php +++ /dev/null @@ -1,79 +0,0 @@ -acl_gen = $acl_gen; - } - - public function listServices(Request $req, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_service.list', null, 'No access.'); - - $required_params = []; - $res = $this->checkParamsAndKey($req, $em, $required_params); - if ($res->isError()) - return $res->getReturnResponse(); - - // services - $results = $em->getRepository(Service::class)->findAll(); - if (empty($results)) - { - $res->setError(true) - ->setErrorMessage('No services available.'); - return $res->getReturnResponse(); - } - - $services = []; - foreach ($results as $result) - { - /* - // get partners - $partners = []; - $service_partners = $result->getPartners(); - foreach($service_partners as $sp) - { - $partners[] = [ - 'id' => $sp->getID(), - 'name' => $sp->getName(), - 'branch' => $sp->getBranch(), - 'address' => $sp->getAddress(), - 'contact_nums' => $sp->getContactNumbers(), - 'time_open' => $sp->getTimeOpen()->format("g:i A"), - 'time_close' => $sp->getTimeClose()->format("g:i A"), - ]; - } - */ - - $services[] = [ - 'id' => $result->getID(), - 'name' => $result->getName(), - // 'partners' => $partners, - ]; - } - - $data['services'] = $services; - - $res->setData($data); - - return $res->getReturnResponse(); - } -} diff --git a/src/Controller/TAPI/VehicleController.php b/src/Controller/TAPI/VehicleController.php deleted file mode 100644 index 5e8bf122..00000000 --- a/src/Controller/TAPI/VehicleController.php +++ /dev/null @@ -1,107 +0,0 @@ -acl_gen = $acl_gen; - } - - public function listVehicleManufacturers(Request $req, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_vmanufacturer.list', null, 'No access.'); - - // check required parameters - $required_params = []; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - // get manufacturer list - $mfgs = $em->getRepository(VehicleManufacturer::class)->findBy(['flag_mobile' => true], ['name' => 'asc']); - $mfg_list = []; - foreach ($mfgs as $mfg) - { - $mfg_list[] = [ - 'id' => $mfg->getID(), - 'name' => $mfg->getName(), - ]; - } - - $data = [ - 'manufacturers' => $mfg_list - ]; - - $message = 'Vehicle manufacturers found.'; - - return new APIResponse(true, $message, $data); - - } - - public function listVehicleMakes(Request $req, $mfg_id, EntityManagerInterface $em) - { - $this->denyAccessUnlessGranted('tapi_vehicle.list', null, 'No access.'); - - // check required parameters and api key - $required_params = []; - $msg = $this->checkRequiredParameters($req, $required_params); - if ($msg) - return new APIResponse(false, $msg); - - // get manufacturer - $mfg = $em->getRepository(VehicleManufacturer::class)->find($mfg_id); - if ($mfg == null) - { - $message = 'Invalid vehicle manufacturer id.'; - return new APIResponse(false, $message); - } - - // get makes - $vehicles = $em->getRepository(Vehicle::class)->findBy( - [ - 'flag_mobile' => true, - 'manufacturer' => $mfg_id, - ], - ['make' => 'asc'] - ); - - $vlist = []; - foreach ($vehicles as $v) - { - $vlist[] = [ - 'id' => $v->getID(), - 'make' => trim($v->getMake() . ' ' . $v->getModelYearFormatted(false)), - ]; - } - - $data = [ - 'manufacturer' => [ - 'id' => $mfg->getID(), - 'name' => $mfg->getName(), - ], - 'makes' => $vlist, - ]; - - $message = 'Vehicle models found.'; - return new APIResponse(true, $message, $data); - - } -} diff --git a/src/Controller/VehicleController.php b/src/Controller/VehicleController.php index afe45fc5..7c388062 100644 --- a/src/Controller/VehicleController.php +++ b/src/Controller/VehicleController.php @@ -485,7 +485,7 @@ class VehicleController extends Controller // get row data $em = $this->getDoctrine()->getManager(); $vobj = $em->getRepository(Vehicle::class)->find($req->request->get('vehicle_id')); - $all_batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]); + $all_batts = $em->getRepository(Battery::class)->findAll(); if (empty($vobj)) throw $this->createNotFoundException('The item does not exist'); @@ -495,20 +495,19 @@ class VehicleController extends Controller $battery_index = []; // get compatible batteries from selected manufacturer - // foreach ($vobj->getBatteries() as $battery) - foreach ($vobj->getActiveBatteries() as $battery) + foreach ($vobj->getBatteries() as $battery) { - $batteries[] = [ - 'id' => $battery->getID(), - 'mfg_name' => $battery->getManufacturer()->getName(), - 'model_name' => $battery->getModel()->getName(), - 'size_name' => $battery->getSize()->getName(), - 'prod_code' => $battery->getProductCode(), - 'sell_price' => $battery->getSellingPrice(), - 'warr_private' => $battery->getWarrantyPrivate(), - 'warr_commercial' => $battery->getWarrantyCommercial(), - ]; - $battery_index[$battery->getID()] = 1; + $batteries[] = [ + 'id' => $battery->getID(), + 'mfg_name' => $battery->getManufacturer()->getName(), + 'model_name' => $battery->getModel()->getName(), + 'size_name' => $battery->getSize()->getName(), + 'prod_code' => $battery->getProductCode(), + 'sell_price' => $battery->getSellingPrice(), + 'warr_private' => $battery->getWarrantyPrivate(), + 'warr_commercial' => $battery->getWarrantyCommercial(), + ]; + $battery_index[$battery->getID()] = 1; } // add all other batteries, because they want options diff --git a/src/Controller/WarrantyController.php b/src/Controller/WarrantyController.php index a0647481..38000a48 100644 --- a/src/Controller/WarrantyController.php +++ b/src/Controller/WarrantyController.php @@ -170,9 +170,6 @@ class WarrantyController extends Controller else $obj->setSerial($req->request->get('serial')); - // get outlet info, sender info - $req->request->get('outlet_name', ''); - // set and save values $obj->setWarrantyClass($req->request->get('warranty_class')) ->setFirstName($req->request->get('first_name')) @@ -181,13 +178,7 @@ class WarrantyController extends Controller ->setDatePurchase($date_purchase) ->setClaimedFrom($req->request->get('claim_from')) ->setStatus($req->request->get('status')) - ->setCreateSource(WarrantySource::ADMIN_PANEL) - ->setOutletName($req->request->get('outlet_name', '')) - ->setOutletContactNumber($req->request->get('outlet_contact_number', '')) - ->setSenderName($req->request->get('sender_name', '')) - ->setSenderContactNumber($req->request->get('sender_contact_number', '')) - ->setOutletAddress($req->request->get('outlet_address', '')) - ->setSalesInvoiceNumber($req->request->get('sales_invoice_number', '')); + ->setCreateSource(WarrantySource::ADMIN_PANEL); if ($date_claim) { @@ -289,12 +280,6 @@ class WarrantyController extends Controller 'battery_size' => $req->request->get('battery_size'), 'sap_battery' => $req->request->get('sap_battery'), 'plate_number' => $req->request->get('plate_number'), - 'outlet_name' => $req->request->get('outlet_name', ''), - 'outlet_contact_number' => $req->request->get('outlet_contact_number', ''), - 'sender_name' => $req->request->get('sender_name', ''), - 'sender_contact_number' => $req->request->get('sender_contact_number', ''), - 'outlet_address' => $req->request->get('outlet_address', ''), - 'sales_invoice_number' => $req->request->get('sales_invoice_number', ''), ]; $logger->logWarrantyInfo($log_data, '', $user_id, $action, $source); @@ -360,13 +345,7 @@ class WarrantyController extends Controller ->setMobileNumber($req->request->get('mobile_number')) ->setDatePurchase($date_purchase) ->setClaimedFrom($req->request->get('claim_from')) - ->setStatus($req->request->get('status')) - ->setOutletName($req->request->get('outlet_name', '')) - ->setOutletContactNumber($req->request->get('outlet_contact_number', '')) - ->setSenderName($req->request->get('sender_name', '')) - ->setSenderContactNumber($req->request->get('sender_contact_number', '')) - ->setOutletAddress($req->request->get('outlet_address', '')) - ->setSalesInvoiceNumber($req->request->get('sales_invoice_number', '')); + ->setStatus($req->request->get('status')); if ($date_claim) { diff --git a/src/Entity/Battery.php b/src/Entity/Battery.php index 89104bcf..8adf4f65 100644 --- a/src/Entity/Battery.php +++ b/src/Entity/Battery.php @@ -147,12 +147,6 @@ class Battery */ protected $image_file; - // flag if battery is active - /** - * @ORM\Column(type="boolean", options={"default": true}) - */ - protected $flag_active; - public function __construct() { $this->vehicles = new ArrayCollection(); @@ -165,8 +159,6 @@ class Battery $this->total_height = 0; $this->date_create = new DateTime(); - - $this->flag_active = true; } public function getID() @@ -390,15 +382,4 @@ class Battery { return $this->image_file; } - - public function isActive() - { - return $this->flag_active; - } - - public function setActive($flag_active = true) - { - $this->flag_active = $flag_active; - return $this; - } } diff --git a/src/Entity/CustomerLocation.php b/src/Entity/CustomerLocation.php deleted file mode 100644 index fd589685..00000000 --- a/src/Entity/CustomerLocation.php +++ /dev/null @@ -1,63 +0,0 @@ -id; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setCode($code) - { - $this->code = $code; - return $this; - } - - public function getCode() - { - return $this->code; - } -} diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index b3b5a62e..f9783568 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -422,13 +422,6 @@ class JobOrder */ protected $ownership_type; - // customer location - /** - * @ORM\ManyToOne(targetEntity="CustomerLocation", inversedBy="job_orders") - * @ORM\JoinColumn(name="cust_location_id", referencedColumnName="id", nullable=true) - */ - protected $cust_location; - public function __construct() { $this->date_create = new DateTime(); @@ -1206,15 +1199,4 @@ class JobOrder { return $this->ownership_type; } - - public function setCustomerLocation(CustomerLocation $cust_location = null) - { - $this->cust_location = $cust_location; - return $this; - } - - public function getCustomerLocation() - { - return $this->cust_location; - } } diff --git a/src/Entity/Vehicle.php b/src/Entity/Vehicle.php index 97a35da4..61fdcec9 100644 --- a/src/Entity/Vehicle.php +++ b/src/Entity/Vehicle.php @@ -4,8 +4,6 @@ namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; -use Doctrine\Common\Collections\Criteria; - use Symfony\Component\Validator\Constraints as Assert; /** @@ -179,12 +177,4 @@ class Vehicle { return $this->cust_vehicles; } - - public function getActiveBatteries() - { - $crit = Criteria::create(); - $crit->where(Criteria::expr()->eq('flag_active', true)); - - return $this->batteries->matching($crit); - } } diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index f9971fb4..9a35b421 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -245,42 +245,6 @@ class Warranty */ protected $dealer_branch_code; - // for non-motiv warranties created via admin panel - /** - * @ORM\Column(type="string", length=80, options={"default": ""}) - */ - protected $outlet_name; - - // for non-motiv warranties created via admin panel - /** - * @ORM\Column(type="string", length=30, options={"default": ""}) - */ - protected $outlet_contact_num; - - // for non-motiv warranties created via admin panel - /** - * @ORM\Column(type="string", length=80, options={"default": ""}) - */ - protected $sender_name; - - // for non-motiv warranties created via admin panel - /** - * @ORM\Column(type="string", length=30, options={"default": ""}) - */ - protected $sender_contact_num; - - // for non-motiv warranties created via admin panel - /** - * @ORM\Column(type="string", length=180, options={"default": ""}) - */ - protected $outlet_address; - - // for non-motiv warranties created via admin panel - /** - * @ORM\Column(type="string", length=30, options={"default": ""}) - */ - protected $sales_invoice_num; - public function __construct() { $this->date_create = new DateTime(); @@ -292,13 +256,6 @@ class Warranty $this->odometer = 0; $this->flag_validated = false; $this->create_source = 'unknown'; - - $this->outlet_name = ''; - $this->outlet_contact_num = ''; - $this->sender_name = ''; - $this->sender_contact_num = ''; - $this->outlet_address = ''; - $this->sales_invoice_num = ''; } public function getID() @@ -737,70 +694,4 @@ class Warranty { return $this->dealer_branch_code; } - - public function setOutletName($outlet_name) - { - $this->outlet_name = $outlet_name; - return $this; - } - - public function getOutletName() - { - return $this->outlet_name; - } - - public function setOutletContactNumber($outlet_contact_num) - { - $this->outlet_contact_num = $outlet_contact_num; - return $this; - } - - public function getOutletContactNumber() - { - return $this->outlet_contact_num; - } - - public function setSenderName($sender_name) - { - $this->sender_name = $sender_name; - return $this; - } - - public function getSenderName() - { - return $this->sender_name; - } - - public function setSenderContactNumber($sender_contact_num) - { - $this->sender_contact_num = $sender_contact_num; - return $this; - } - - public function getSenderContactNumber() - { - return $this->sender_contact_num; - } - - public function setOutletAddress($outlet_address) - { - $this->outlet_address = $outlet_address; - return $this; - } - - public function getOutletAddress() - { - return $this->outlet_address; - } - - public function setSalesInvoiceNumber($sales_invoice_num) - { - $this->sales_invoice_num = $sales_invoice_num; - return $this; - } - - public function getSalesInvoiceNumber() - { - return $this->sales_invoice_num; - } } diff --git a/src/Entity/WarrantyRaffleLog.php b/src/Entity/WarrantyRaffleLog.php deleted file mode 100644 index 00aba6dc..00000000 --- a/src/Entity/WarrantyRaffleLog.php +++ /dev/null @@ -1,295 +0,0 @@ -date_create = new DateTime(); - $this->data_sent = []; - $this->serial = ''; - $this->api_user = ''; - $this->action = ''; - $this->batt_model_name = ''; - $this->batt_size_name = ''; - $this->first_name = ''; - $this->last_name = ''; - $this->plate_number = ''; - $this->contact_num = ''; - $this->email = ''; - $this->address = ''; - } - - public function getID() - { - return $this->id; - } - - public function setDateCreate(DateTime $date_create) - { - $this->date_create = $date_create; - return $this; - } - - public function getDateCreate() - { - return $this->date_create; - } - - public function setApiUser($api_user) - { - $this->api_user = $api_user; - return $this; - } - - public function getApiUser() - { - return $this->api_user; - } - - public function addDataSent($id, $value) - { - $this->data_sent[$id] = $value; - return $this; - } - - public function setDataSent($data_sent) - { - $this->data_sent = $data_sent; - return $this; - } - - public function getDataSent($id) - { - // return null if we don't have it - if (!isset($this->data_sent[$id])) - return null; - - return $this->data_sent[$id]; - } - - public function setSerial($serial) - { - $this->serial = $serial; - return $this; - } - - public function getSerial() - { - return $this->serial; - } - - public function setWarrantyID($warranty_id) - { - $this->warranty_id = $warranty_id; - return $this; - } - - public function getWarrantyID() - { - return $this->warranty_id; - } - - public function setAction($action) - { - $this->action = $action; - return $this; - } - - public function getAction() - { - return $this->action; - } - - public function setBattModelName($batt_model_name) - { - $this->batt_model_name = $batt_model_name; - return $this; - } - - public function getBattModelName() - { - return $this->batt_model_name; - } - - public function setBattSizeName($batt_size_name) - { - $this->batt_size_name = $batt_size_name; - return $this; - } - - public function getBattSizeName() - { - return $this->batt_size_name; - } - - public function setFirstName($first_name) - { - $this->first_name = $first_name; - return $this; - } - - public function getFirstName() - { - return $this->first_name; - } - - public function setLastName($last_name) - { - $this->last_name = $last_name; - return $this; - } - - public function getLastName() - { - return $this->last_name; - } - - public function setPlateNumber($plate_number) - { - $this->plate_number = $plate_number; - return $this; - } - - public function getPlateNumber() - { - return $this->plate_number; - } - - public function setContactNumber($contact_num) - { - $this->contact_num = $contact_num; - return $this; - } - - public function getContactNumber() - { - return $this->contact_num; - } - - public function setEmail($email) - { - $this->email = $email; - return $this; - } - - public function getEmail() - { - return $this->email; - } - - public function setAddress($address) - { - $this->cust_address = $address; - return $this; - } - - public function getAddress() - { - return $this->cust_address; - } -} - diff --git a/src/Entity/WarrantySerialLoadLog.php b/src/Entity/WarrantySerialLoadLog.php deleted file mode 100644 index ece58ffb..00000000 --- a/src/Entity/WarrantySerialLoadLog.php +++ /dev/null @@ -1,120 +0,0 @@ -date_create = new DateTime(); - $this->api_user = ''; - $this->serial = ''; - $this->flag_loaded = false; - $this->error = null; - } - - public function getID() - { - return $this->id; - } - - public function setDateCreate(DateTime $date_create) - { - $this->date_create = $date_create; - return $this; - } - - public function getDateCreate() - { - return $this->date_create; - } - - public function setApiUser($api_user) - { - $this->api_user = $api_user; - return $this; - } - - public function getApiUser() - { - return $this->api_user; - } - - public function setSerial($serial) - { - $this->serial = $serial; - return $this; - } - - public function getSerial() - { - return $this->serial; - } - - public function setLoaded($flag_loaded = true) - { - $this->flag_loaded = $flag_loaded; - return $this; - } - - public function isLoaded() - { - return $this->flag_loaded; - } - - public function setError($error) - { - $this->error = $error; - return $this; - } - - public function getError() - { - return $this->error; - } -} diff --git a/src/Entity/WarrantySerialQueue.php b/src/Entity/WarrantySerialQueue.php deleted file mode 100644 index d139a173..00000000 --- a/src/Entity/WarrantySerialQueue.php +++ /dev/null @@ -1,129 +0,0 @@ -date_create = new DateTime(); - $this->file_serial = null; - $this->orig_file_serial = null; - $this->status = ''; - $this->api_user = ''; - $this->file_id = ''; - } - - public function getID() - { - return $this->id; - } - - public function setFileSerial($file = null) - { - $this->file_serial = $file; - return $this; - } - - public function getFileSerial() - { - return $this->file_serial; - } - - public function setStatus($status) - { - $this->status = $status; - return $this; - } - - public function getStatus() - { - return $this->status; - } - - public function setApiUser($api_user) - { - $this->api_user = $api_user; - return $this; - } - - public function getApiUser() - { - return $this->api_user; - } - - public function setFileID($file_id) - { - $this->file_id = $file_id; - return $this; - } - - public function getFileID() - { - return $this->file_id; - } - - public function setOrigFileSerial($file = null) - { - $this->orig_file_serial = $file; - return $this; - } - - public function getOrigFileSerial() - { - return $this->orig_file_serial; - } -} diff --git a/src/Entity/WarrantySerialUploadLog.php b/src/Entity/WarrantySerialUploadLog.php deleted file mode 100644 index 44f5b16a..00000000 --- a/src/Entity/WarrantySerialUploadLog.php +++ /dev/null @@ -1,138 +0,0 @@ -date_create = new DateTime(); - $this->api_user = ''; - $this->orig_file_serial = ''; - $this->orig_file_serial = ''; - $this->flag_uploaded = false; - $this->error = null; - } - - public function getID() - { - return $this->id; - } - - public function setDateCreate(DateTime $date_create) - { - $this->date_create = $date_create; - return $this; - } - - public function getDateCreate() - { - return $this->date_create; - } - - public function setApiUser($api_user) - { - $this->api_user = $api_user; - return $this; - } - - public function getApiUser() - { - return $this->api_user; - } - - public function setOrigFileSerial($file = null) - { - $this->orig_file_serial = $file; - return $this; - } - - public function getOrigFileSerial() - { - return $this->orig_file_serial; - } - - public function setUploadedFileSerial($file = null) - { - $this->uploaded_file_serial = $file; - return $this; - } - - public function getUploadedFileSerial() - { - return $this->uploaded_file_serial; - } - - public function setUploaded($flag_uploaded = true) - { - $this->flag_uploaded = $flag_uploaded; - return $this; - } - - public function isUploaded() - { - return $this->flag_uploaded; - } - - public function setError($error) - { - $this->error = $error; - return $this; - } - - public function getError() - { - return $this->error; - } -} diff --git a/src/Ramcar/ModeOfPayment.php b/src/Ramcar/ModeOfPayment.php index 139dd18c..1b522dde 100644 --- a/src/Ramcar/ModeOfPayment.php +++ b/src/Ramcar/ModeOfPayment.php @@ -9,7 +9,6 @@ class ModeOfPayment extends NameValue const DEBIT_CARD = 'debit_card'; const INSTALLMENT = 'installment'; const GCASH = 'gcash'; - const CREDIT_CARD_AMEX = 'credit_card_amex'; const COLLECTION = [ 'cash' => 'Cash', @@ -17,6 +16,5 @@ class ModeOfPayment extends NameValue 'debit_card' => 'Debit Card', 'installment' => 'Installment - BDO', 'gcash' => 'GCash', - 'credit_card_amex' => 'Credit Card - AMEX', ]; } diff --git a/src/Ramcar/TransactionOrigin.php b/src/Ramcar/TransactionOrigin.php index fabf2900..4a13075e 100644 --- a/src/Ramcar/TransactionOrigin.php +++ b/src/Ramcar/TransactionOrigin.php @@ -4,14 +4,13 @@ namespace App\Ramcar; class TransactionOrigin extends NameValue { - const CALL = 'call'; - const ONLINE = 'online'; - const FACEBOOK = 'facebook'; - const VIP = 'vip'; - const MOBILE_APP = 'mobile_app'; - const WALK_IN = 'walk_in'; - const LAZADA = 'lazada'; - const THIRD_PARTY = 'third_party'; + const CALL = 'call'; + const ONLINE = 'online'; + const FACEBOOK = 'facebook'; + const VIP = 'vip'; + const MOBILE_APP = 'mobile_app'; + const WALK_IN = 'walk_in'; + const LAZADA = 'lazada'; const YOKOHAMA_OP_FACEBOOK = 'yokohama_op_facebook'; const YOKOHAMA_TWITTER = 'yokohama_twitter'; const YOKOHAMA_INSTAGRAM = 'yokohama_instagram'; @@ -27,7 +26,6 @@ class TransactionOrigin extends NameValue 'mobile_app' => 'Mobile App', 'walk_in' => 'Walk-in', 'lazada' => 'Lazada', - 'third_party' => 'Third Party', 'yokohama_op_facebook' => 'Yokohama OP Facebook', 'yokohama_twitter' => 'Yokohama Twitter', 'yokohama_instagram' => 'Yokohama Instagram', diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index d3a30762..0a1ed4ed 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -36,7 +36,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface const OTHER_SERVICES_FEE = 200; const COOLANT_FEE = 1600; const REFUEL_FEE_GAS = 320; // for 4 liters - const REFUEL_FEE_DIESEL = 320; // for 4 liters + const REFUEL_FEE_DIESEL = 340; // for 4 liters private $security; protected $em; @@ -84,7 +84,7 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface break; case ServiceType::JUMPSTART_WARRANTY: $this->processJumpstartWarranty($total, $invoice); - break; + case ServiceType::BATTERY_REPLACEMENT_NEW: $this->processEntries($total, $criteria, $invoice); /* diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 642f4215..5f88b057 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -28,7 +28,6 @@ use App\Entity\Customer; use App\Entity\CustomerTag; use App\Entity\EmergencyType; use App\Entity\OwnershipType; -use App\Entity\CustomerLocation; use App\Ramcar\InvoiceCriteria; use App\Ramcar\ServiceType; @@ -425,19 +424,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } } - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - // get source of awareness if any $soa_type = $req->request->get('source_of_awareness', ''); @@ -446,13 +432,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -507,8 +489,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setGender($gender) ->setEmergencyType($etype) - ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location); + ->setOwnershipType($owner_type); // check if user is null, meaning call to create came from API if ($user != null) @@ -711,13 +692,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -733,19 +710,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - if (empty($error_array)) { // get current user @@ -780,8 +744,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setGender($gender) ->setEmergencyType($etype) - ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location); + ->setOwnershipType($owner_type); // did they change invoice? $invoice_items = $req->request->get('invoice_items', []); @@ -935,13 +898,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -957,19 +916,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - if (empty($error_array)) { // coordinates @@ -1001,8 +947,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) - ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location); + ->setOwnershipType($owner_type); // validate $errors = $this->validator->validate($obj); @@ -1102,13 +1047,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -1124,19 +1065,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - // get current user $user = $this->security->getUser(); @@ -1170,8 +1098,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setGender($gender) ->setEmergencyType($etype) - ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location); + ->setOwnershipType($owner_type); if ($user != null) { @@ -1260,13 +1187,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -1282,19 +1205,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - if (empty($error_array)) { // coordinates $point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); @@ -1322,8 +1232,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) - ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location); + ->setOwnershipType($owner_type); // validate $errors = $this->validator->validate($obj); @@ -1532,13 +1441,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -1554,19 +1459,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - // get previously assigned hub, if any $old_hub = $obj->getHub(); @@ -1625,7 +1517,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setCallerClassification($caller_class) ->setEmergencyType($etype) ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location) ->clearRider(); if ($user != null) @@ -1769,8 +1660,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // validated! save the entity $em->persist($obj); $em->flush(); - - $this->sendSMSHubRejection($obj, $jo); } return $error_array; @@ -1832,13 +1721,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // get initial concern if any $initial_concern = $req->request->get('initial_concern', ''); - if (empty($initial_concern)) - $error_array['initial_concern'] = 'Initial concern of customer is required.'; // get initial concern notes if any $initial_concern_notes = $req->request->get('initial_concern_notes', ''); - if (empty($initial_concern_notes)) - $error_array['initial_concern_notes'] = 'Notes on initial concern of customer is required.'; // get gender if any $gender = $req->request->get('gender', ''); @@ -1854,19 +1739,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $ownertype_id = $req->request->get('ownership_type', 0); $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); - // check if customer location is set - $cust_location_id = $req->request->get('cust_location', 0); - if ($cust_location_id == 0) - $error_array['cust_location'] = 'Customer location is required.'; - else - { - // get customer location - $cust_location = $em->getRepository(CustomerLocation::class)->find($cust_location_id); - - if ($cust_location == null) - $error_array['cust_location'] = 'Invalid customer location'; - } - if (empty($error_array)) { // rider mqtt event // NOTE: need to send this before saving because rider will be cleared @@ -1919,8 +1791,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) - ->setOwnershipType($owner_type) - ->setCustomerLocation($cust_location); + ->setOwnershipType($owner_type); if ($user != null) { @@ -2492,7 +2363,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT) { // reset distance limit if emergency - //TODO: move to .env the emergency distance limit $hub_criteria->setLimitDistance(500); $hub_criteria->setEmergency(true); } @@ -2534,19 +2404,9 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $hub['distance'] = false; } - // get rider counts - $rider_counts = $this->getHubRiderCounts($hub['hub']); - // counters - // get only the active riders for the total rider count per hub - // $hub['rider_count'] = count($hub['hub']->getAvailableRiders()); - $hub['rider_count'] = count($hub['hub']->getActiveRiders()); + $hub['rider_count'] = count($hub['hub']->getAvailableRiders()); $hub['redis_jo_count'] = $hub['jo_count']; - - $hub['rider_logged_in'] = $rider_counts['logged_in']; - $hub['rider_in_transit'] = $rider_counts['in_transit']; - $hub['rider_available'] = $rider_counts['available']; - //$hub['redis_jo_count'] = 0; // $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); $hub['jo_count'] = $hub['redis_jo_count']; @@ -2693,10 +2553,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $this->fillDropdownParameters($params); $this->fillFormTags($params); - // get the rider data to display for table - $rider_data = $this->getRiderDataForAssignment($obj); - $params['rider_data'] = $rider_data; - // get template to display $params['template'] = $this->getTwigTemplate('jo_assigning_form'); $params['obj'] = $obj; @@ -2822,11 +2678,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface // check if emergency or not $willing_to_wait = $obj->getWillWait(); if ($willing_to_wait == WillingToWaitContent::NOT_WILLING_TO_WAIT) - { - //TODO: move to .env the emergency distance limit - $hub_criteria->setLimitDistance(500); $hub_criteria->setEmergency(true); - } // get JO and customer id for logging purposes $jo_id = $obj->getID(); @@ -2863,20 +2715,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $hub['distance'] = false; } - // get rider counts - $rider_counts = $this->getHubRiderCounts($hub['hub']); - // counters - // get only the active riders for the total rider count per hub - // $hub['rider_count'] = count($hub['hub']->getAvailableRiders()); - $hub['rider_count'] = count($hub['hub']->getActiveRiders()); + $hub['rider_count'] = count($hub['hub']->getAvailableRiders()); // $hub['redis_jo_count'] = $hub['jo_count']; $hub['redis_jo_count'] = 0; - - $hub['rider_logged_in'] = $rider_counts['logged_in']; - $hub['rider_in_transit'] = $rider_counts['in_transit']; - $hub['rider_available'] = $rider_counts['available']; - // $hub['jo_count'] = count($hub['hub']->getForAssignmentJobOrders()); $hub['jo_count'] = $hub['redis_jo_count']; @@ -2976,10 +2818,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $this->fillDropdownParameters($params); $this->fillFormTags($params); - // get the rider data to display for table - $rider_data = $this->getRiderDataForAssignment($obj); - $params['rider_data'] = $rider_data; - $params['obj'] = $obj; $params['status_cancelled'] = JOStatus::CANCELLED; // get template to display @@ -3435,34 +3273,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface return false; } - protected function getHubRiderCounts($hub) - { - $em = $this->em; - - $hub_id = $hub->getID(); - - // get in transit rider count aka flag_available is false AND current_jo_id is not null AND rider is active - $in_transit_query = $em->createQuery('SELECT count(r.id) FROM App\Entity\Rider r JOIN r.hub h WHERE h.id = :hub_id AND r.flag_available = false AND r.current_job_order IS NOT NULL AND r.flag_active = true'); - $in_transit_query->setParameters(['hub_id' => $hub_id]); - $in_transit_count = $in_transit_query->getSingleScalarResult(); - - // get available rider count aka flag_available is true AND current_jo_id is null AND rider is active - $available_query = $em->createQuery('SELECT count(r.id) FROM App\Entity\Rider r JOIN r.hub h WHERE h.id = :hub_id AND r.flag_available = true AND r.current_job_order IS NULL AND r.flag_active = true'); - $available_query->setParameters(['hub_id' => $hub_id]); - $available_count = $available_query->getSingleScalarResult(); - - // on duty count = in transit + available - $logged_in_count = $in_transit_count + $available_count; - - $rider_count = [ - 'logged_in' => $logged_in_count, - 'in_transit' => $in_transit_count, - 'available' => $available_count, - ]; - - return $rider_count; - } - protected function fillDropdownParameters(&$params) { $em = $this->em; @@ -3489,15 +3299,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } $params['ownership_types'] = $ownership_types; - // list of customer locations - $cust_locations = $em->getRepository(CustomerLocation::class)->findBy([], ['name' => 'ASC']); - $c_locations = []; - foreach ($cust_locations as $cust_location) - { - $c_locations[$cust_location->getID()] = $cust_location->getName(); - } - $params['cust_locations'] = $c_locations; - // list of hubs $hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']); $fac_hubs = []; @@ -3694,49 +3495,6 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ]; } - protected function getRiderDataForAssignment($obj) - { - $hub = $obj->getHub(); - - $rider_data = []; - - // get all active riders of hub - $active_riders = $hub->getActiveRiders(); - - // need to get first name, last name, contact number, plate number, status, image file - // status: Online (rider is logged in app), Offline (rider is not logged in app), In transit - - foreach ($active_riders as $rider) - { - // in transit - flag_available = 0 AND current_job_order is not null - // online - flag_available = 1 - // offline - flag_available = 0 AND current_job_order is null - $rider_status = ''; - - if ($rider->isAvailable()) - { - $rider_status = 'Online'; - } - else - { - if ($rider->getCurrentJobOrder() == null) - $rider_status = 'Offline'; - else - $rider_status = 'In transit'; - } - - $rider_data[$rider->getID()] = [ - 'first_name' => $rider->getFirstName(), - 'last_name' => $rider->getLastName(), - 'contact_number' => $rider->getContactNumber(), - 'plate_number' => $rider->getPlateNumber(), - 'image_file' => $rider->getImageFile(), - 'status' => $rider_status, - ]; - } - return $rider_data; - } - // TODO: re-enable search, figure out how to group the orWhere filters into one, so can execute that plus the pending filter // check if datatable filter is present and append to query protected function setQueryFilters($datatable, &$query, $qb, $hubs, $tier, $status) @@ -4151,54 +3909,4 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $message); } - protected function sendSMSHubRejection($rejection, $jo) - { - $hub = $rejection->getHub(); - - // check if JO service type is NOT battery sales - if ($jo->getServiceType() !== ServiceType::BATTERY_REPLACEMENT_NEW) - return null; - - // check if hub has a notification number - $notif_number = $hub->getNotifNumber(); - if (empty($notif_number)) - return null; - - $phone_number = $this->country_code . $notif_number; - - // check if reason is administrative - if ($rejection->getReason() == JORejectionReason::ADMINISTRATIVE) - return null; - - // sms content - // Job Order # - can get from jo - // Order Date and Time - get from jo - // Date and Time Rejected - get from rejection - // Enrollee Name - get from rejection ($hub->getName() . ' - ' . $hub->getBranch()) - // Reason of Rejection - get from rejection - // Remarks - get from rejection - // Type of Service - get from jo - - $jo_id = $jo->getID(); - - // convert to string format the date fields (order date and time and date and time rejected) - $order_date_time = $jo->getDateCreate()->format('d M Y g:i A'); - $reject_date_time = $rejection->getDateCreate()->format('d M Y g:i A'); - - $enrollee = $hub->getName() . ' - ' . $hub->getBranch(); - $reason = JORejectionReason::getName($rejection->getReason()); - $remarks = $rejection->getRemarks(); - - $service_type = ServiceType::getName($jo->getServiceType()); - - $msg = 'Job Order #: ' . $jo_id . "\n" . 'Order Date and Time: ' . $order_date_time . "\n" . - 'Date and Time Rejected: ' . $reject_date_time . "\n" . 'Enrollee Name: ' . $enrollee . "\n" . - 'Reason of Rejection: ' . $reason . "\n" . 'Remarks: ' . $remarks . "\n" . - 'Type of Service: ' . $service_type; - - // error_log($msg); - - $this->rt->sendSMS($phone_number, $this->translator->trans('message.battery_brand_allcaps'), $msg); - } - } diff --git a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php index a543f39d..5cc903c9 100644 --- a/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/ResqRiderAPIHandler.php @@ -714,7 +714,7 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface if (isset($data['error'])) return $data; - $batts = $this->em->getRepository(Battery::class)->findBy(['flag_active' => true]); + $batts = $this->em->getRepository(Battery::class)->findAll(); $models = $this->em->getRepository(BatteryModel::class)->findAll(); $sizes = $this->em->getRepository(BatterySize::class)->findAll(); diff --git a/src/Service/WarrantyRaffleFilter.php b/src/Service/WarrantyRaffleFilter.php deleted file mode 100644 index ac76d5d2..00000000 --- a/src/Service/WarrantyRaffleFilter.php +++ /dev/null @@ -1,36 +0,0 @@ -em = $em; - } - - public function logRaffleInfo($data_sent, $raffle_log_data) - { - $log_entry = new WarrantyRaffleLog(); - - $log_entry->setApiUser($raffle_log_data['user_id']) - ->setDataSent($data_sent) - ->setSerial($raffle_log_data['serial']) - ->setWarrantyID($raffle_log_data['warranty_id']) - ->setAction($raffle_log_data['action']) - ->setBattModelName($raffle_log_data['bmodel_name']) - ->setBattSizename($raffle_log_data['bsize_name']) - ->setFirstName($raffle_log_data['first_name']) - ->setLastName($raffle_log_data['last_name']) - ->setPlateNumber($raffle_log_data['plate_number']) - ->setContactNumber($raffle_log_data['contact_num']) - ->setEmail($raffle_log_data['email']) - ->setAddress($raffle_log_data['address']); - - $this->em->persist($log_entry); - $this->em->flush(); - - } -} - diff --git a/src/Service/WarrantySerialLoadLogger.php b/src/Service/WarrantySerialLoadLogger.php deleted file mode 100644 index b66b4db9..00000000 --- a/src/Service/WarrantySerialLoadLogger.php +++ /dev/null @@ -1,53 +0,0 @@ -em = $em; - } - - public function logWarrantySerialLoadInfo($log_data) - { - // cache directory - $cache_dir = __DIR__ . '/../../var/cache'; - - $file = $cache_dir . '/warranty_serial_load_log.tab'; - // error_log('opening file for warranty serial load log - ' . $file); - - $fp = fopen($file, 'w'); - if ($fp === false) - { - error_log('could not open file for load data infile - ' . $file); - } - else - { - foreach ($log_data as $key => $data) - { - $line = implode('|', $data) . "\r\n"; - fwrite($fp, $line); - } - } - - fclose($fp); - - // prepared statement - $db = $this->em->getConnection(); - $stmt = $db->prepare('LOAD DATA LOCAL INFILE \''. $file . '\' INTO TABLE warranty_serial_load_log FIELDS TERMINATED BY \'|\' LINES TERMINATED BY \'\\r\\n\' (date_create, api_user, serial, flag_loaded, error)'); - - $result = $stmt->execute(); - if (!$result) - error_log('Failed loading data.'); - - // TODO: delete file? - } - -} diff --git a/src/Service/WarrantySerialUploadLogger.php b/src/Service/WarrantySerialUploadLogger.php deleted file mode 100644 index d708792c..00000000 --- a/src/Service/WarrantySerialUploadLogger.php +++ /dev/null @@ -1,47 +0,0 @@ -em = $em; - } - - public function logWarrantySerialUploadInfo($log_data) - { - $log_entry = new WarrantySerialUploadLog(); - - $user_id = $log_data['user_id']; - $is_uploaded = $log_data['is_uploaded']; - - $error = ''; - $orig_file_serial = ''; - $uploaded_file_serial = ''; - - if (isset($log_data['error'])) - $error = $log_data['error']; - if (isset($log_data['orig_file_serial'])) - $orig_file_serial = $log_data['orig_file_serial']; - if (isset($log_data['uploaded_file_serial'])) - $uploaded_file_serial = $log_data['uploaded_file_serial']; - - $log_entry->setApiUser($user_id) - ->setUploaded($is_uploaded) - ->setOrigFileSerial($orig_file_serial) - ->setUploadedFileSerial($uploaded_file_serial) - ->setError($error); - - $this->em->persist($log_entry); - $this->em->flush(); - - } - -} diff --git a/templates/base.html.twig b/templates/base.html.twig index 50e72b20..ab5dfb77 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -182,16 +182,6 @@ - diff --git a/templates/battery/form.html.twig b/templates/battery/form.html.twig index 4ac05437..53adb693 100644 --- a/templates/battery/form.html.twig +++ b/templates/battery/form.html.twig @@ -101,20 +101,6 @@ -
-
- - - - -
-
-
-
-
-
- - - -
-
-
-
@@ -772,10 +754,7 @@ - Total Rider Count - On Duty - In Transit - Available + Available Riders Job Order Count Jobs For Assignment Inventory @@ -785,7 +764,7 @@ - + No items to display. @@ -798,9 +777,6 @@ {{ hub.duration ? hub.duration : '-' }} --> {{ hub.rider_count }} - {{ hub.rider_logged_in|default('0') }} - {{ hub.rider_in_transit|default('0') }} - {{ hub.rider_available|default('0') }} {{ hub.redis_jo_count }} {{ hub.jo_count }} {{ hub.inventory|default('0') }} @@ -906,64 +882,48 @@
-
- - -
- - - - - - - - - - - - - - {% if obj.getHub %} - {% for key, data in rider_data %} - - - - - - - - - {% endfor %} - {% endif %} - -
First NameLast NameContact No.Plate NumberStatus
-
-
{{ data['first_name'] }} {{ data['last_name'] }} {{ data['contact_number'] }} {{ data['plate_number'] }} {{ data['status'] }}
-
-
-
+ {% if obj.getHub %} + {% for rider in avail_riders %} + + +
+ + {{ rider.getFirstName }} + {{ rider.getLastName }} + {{ rider.getContactNumber }} + {{ rider.getPlateNumber }} + + + {% endfor %} + {% endif %} + + +
+
+ {% endif %} diff --git a/templates/report/jo-raffle/form.html.twig b/templates/report/jo-raffle/form.html.twig deleted file mode 100644 index 0805d609..00000000 --- a/templates/report/jo-raffle/form.html.twig +++ /dev/null @@ -1,82 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block body %} - -
-
-
-

Job Order Raffle Report

-
-
-
- -
- -
-
-
-
-
-
- - - -

- Select a date range -

-
-
-
-
-
-
-
- -
- -
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-{% endblock %} - -{% block scripts %} - -{% endblock %} diff --git a/templates/report/warranty-raffle/form.html.twig b/templates/report/warranty-raffle/form.html.twig deleted file mode 100644 index f752ec81..00000000 --- a/templates/report/warranty-raffle/form.html.twig +++ /dev/null @@ -1,83 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block body %} - -
-
-
-

Warranty Raffle Report

-
-
-
- -
- -
-
-
-
-
-
- - - -

- Select a date range -

-
-
-
-
-
-
-
- -
- -
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-{% endblock %} - -{% block scripts %} - -{% endblock %} - diff --git a/templates/vehicle/form.html.twig b/templates/vehicle/form.html.twig index 99ecbc0f..09bee95f 100644 --- a/templates/vehicle/form.html.twig +++ b/templates/vehicle/form.html.twig @@ -233,13 +233,13 @@ $(function() { var batteryIds = []; var battMfgModelSize = [] - {% for batt in obj.getActiveBatteries %} + {% for batt in obj.getBatteries %} trow = { id: "{{ batt.getID }}", manufacturer: "{{ batt.getManufacturer.getName|default('') }} ", model: "{{ batt.getModel.getName|default('') }}", size: "{{ batt.getSize.getName|default('') }}", - sell_price: "{{ batt.getSellingPrice }}", + sell_price: "{{ batt.getSellingPrice }}" }; battRows.push(trow); diff --git a/templates/warranty/form.html.twig b/templates/warranty/form.html.twig index 7107d5e9..a1210ca9 100644 --- a/templates/warranty/form.html.twig +++ b/templates/warranty/form.html.twig @@ -182,54 +182,6 @@ -
-
- - - -
-
- - - -
-
- - - -
-
-
-
- - - -
-
-
-
- - - -
-
- - - -
-
diff --git a/utils/customer_locations/insert_customer_locations.sql b/utils/customer_locations/insert_customer_locations.sql deleted file mode 100644 index 5594b2a0..00000000 --- a/utils/customer_locations/insert_customer_locations.sql +++ /dev/null @@ -1,53 +0,0 @@ --- MySQL dump 10.19 Distrib 10.3.36-MariaDB, for Linux (x86_64) --- --- Host: localhost Database: resq --- ------------------------------------------------------ --- Server version 10.3.36-MariaDB - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `customer_location` --- - -DROP TABLE IF EXISTS `customer_location`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `customer_location` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `code` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - `name` varchar(25) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`), - KEY `cust_location_idx` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Dumping data for table `customer_location` --- - -LOCK TABLES `customer_location` WRITE; -/*!40000 ALTER TABLE `customer_location` DISABLE KEYS */; -INSERT INTO `customer_location` VALUES (1,'residence','Residence'),(2,'office','Office'),(3,'on_the_road','On the Road'),(4,'commercial','Commercial'); -/*!40000 ALTER TABLE `customer_location` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2023-02-23 8:03:35 diff --git a/utils/get_warranty_serial/new_get_serials.php b/utils/get_warranty_serial/new_get_serials.php index 63403203..61477885 100644 --- a/utils/get_warranty_serial/new_get_serials.php +++ b/utils/get_warranty_serial/new_get_serials.php @@ -11,7 +11,7 @@ use MicrosoftAzure\Storage\Common\ServiceException; // $blob_url = 'https://popappshopprodstorage.blob.core.windows.net'; $blob_url = 'https://motivstorageaccount.blob.core.windows.net'; -$sas_token = 'sp=r&st=2022-08-30T03:39:37Z&se=2030-09-30T11:39:37Z&sv=2021-06-08&sr=c&sig=9eETL%2F%2B2mbOPtW%2Fa4dZBnC8s61NwJpPZu6tsJS7frmk%3D'; +$sas_token = 'sp=r&st=2022-06-16T04:09:13Z&se=2030-06-16T12:09:13Z&spr=https&sv=2021-06-08&sr=c&sig=x26qUFEMIqg4JgTCVHoDv%2FtTqCprjogEqtOsTpBjkWA%3D'; $conn_string = "BlobEndpoint=$blob_url;\nSharedAccessSignature=$sas_token"; diff --git a/utils/warranty_serial_load/warranty_serial_load.sh b/utils/warranty_serial_load/warranty_serial_load.sh deleted file mode 100755 index af79f1af..00000000 --- a/utils/warranty_serial_load/warranty_serial_load.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# get the number fo warranty serial files to process -declare -i num_files - -num_files=`/var/www/resq/bin/console warrantyserial:count` - -for (( i = 1; i <= num_files; i++ )) -do - /usr/bin/php /var/www/resq/bin/console warrantyserial:load -done