From db65c6d623de7b6da104cac8c752a85a7d43443c Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 17 Jun 2022 10:44:28 +0000 Subject: [PATCH 01/23] Add more dates to bulk script. #684 --- utils/warranty_motiv_local_bulk.sh | 3 +++ utils/warranty_motiv_prod_bulk.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/utils/warranty_motiv_local_bulk.sh b/utils/warranty_motiv_local_bulk.sh index cf0f11eb..8c906c27 100755 --- a/utils/warranty_motiv_local_bulk.sh +++ b/utils/warranty_motiv_local_bulk.sh @@ -77,5 +77,8 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-14-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-15-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-16-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-17-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-18-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt diff --git a/utils/warranty_motiv_prod_bulk.sh b/utils/warranty_motiv_prod_bulk.sh index cf0f11eb..8c906c27 100755 --- a/utils/warranty_motiv_prod_bulk.sh +++ b/utils/warranty_motiv_prod_bulk.sh @@ -77,5 +77,8 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-14-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-15-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-16-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-17-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-18-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt From fb766eb99f202f933d9b01a50793174db332c7e0 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 20 Jun 2022 06:56:48 +0000 Subject: [PATCH 02/23] Change diesel fuel fee. #687 --- src/Service/InvoiceGenerator/ResqInvoiceGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index b6e913d8..5ee7669c 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 = 380; - const REFUEL_FEE_DIESEL = 360; + const REFUEL_FEE_DIESEL = 400; private $security; protected $em; From 2ca7f86829723b9b86ddd856c871eac4e8d3107a Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 20 Jun 2022 06:59:37 +0000 Subject: [PATCH 03/23] Add another day to batch script. #684 --- utils/warranty_motiv_local_bulk.sh | 1 + utils/warranty_motiv_prod_bulk.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/utils/warranty_motiv_local_bulk.sh b/utils/warranty_motiv_local_bulk.sh index 8c906c27..1efb84ca 100755 --- a/utils/warranty_motiv_local_bulk.sh +++ b/utils/warranty_motiv_local_bulk.sh @@ -80,5 +80,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-17-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-18-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt diff --git a/utils/warranty_motiv_prod_bulk.sh b/utils/warranty_motiv_prod_bulk.sh index 8c906c27..1efb84ca 100755 --- a/utils/warranty_motiv_prod_bulk.sh +++ b/utils/warranty_motiv_prod_bulk.sh @@ -80,5 +80,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-17-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-18-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt From b4def3c1a7fcde29d49b1f9dd208da314797344d Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Tue, 21 Jun 2022 21:51:31 +0800 Subject: [PATCH 04/23] Add check to see if motiv reply is valid #688 --- .../JobOrderHandler/ResqJobOrderHandler.php | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index 1562659f..a5487311 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -2425,13 +2425,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $mres = $motiv->getInventory($branch_codes, $skus); foreach ($mres as $mres_item) { - $bcode = $mres_item['BranchCode']; - $inv_count = $mres_item['Quantity']; - if (isset($inv_data[$bcode])) + // check if we have a valid response from motiv, ignore otherwise + if (isset($mres_item['BranchCode'])) { - $hub_id = $inv_data[$bcode]['hub_id']; + $bcode = $mres_item['BranchCode']; + $inv_count = $mres_item['Quantity']; + if (isset($inv_data[$bcode])) + { + $hub_id = $inv_data[$bcode]['hub_id']; - $params['hubs'][$hub_id]['inventory'] = $inv_count; + $params['hubs'][$hub_id]['inventory'] = $inv_count; + } } } @@ -2728,13 +2732,17 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $mres = $motiv->getInventory($branch_codes, $skus); foreach ($mres as $mres_item) { - $bcode = $mres_item['BranchCode']; - $inv_count = $mres_item['Quantity']; - if (isset($inv_data[$bcode])) + // check if we have a valid response from motiv, ignore otherwise + if (isset($mres_item['BranchCode'])) { - $hub_id = $inv_data[$bcode]['hub_id']; + $bcode = $mres_item['BranchCode']; + $inv_count = $mres_item['Quantity']; + if (isset($inv_data[$bcode])) + { + $hub_id = $inv_data[$bcode]['hub_id']; - $params['hubs'][$hub_id]['inventory'] = $inv_count; + $params['hubs'][$hub_id]['inventory'] = $inv_count; + } } } From 3ce12df214baf41a20ca6258dd2cceebedb4700a Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 22 Jun 2022 01:14:49 +0000 Subject: [PATCH 05/23] Add another date to the bulk script. #684 --- utils/warranty_motiv_local_bulk.sh | 1 + utils/warranty_motiv_prod_bulk.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/utils/warranty_motiv_local_bulk.sh b/utils/warranty_motiv_local_bulk.sh index 1efb84ca..f00b57ad 100755 --- a/utils/warranty_motiv_local_bulk.sh +++ b/utils/warranty_motiv_local_bulk.sh @@ -81,5 +81,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-18-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-21-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt diff --git a/utils/warranty_motiv_prod_bulk.sh b/utils/warranty_motiv_prod_bulk.sh index 1efb84ca..f00b57ad 100755 --- a/utils/warranty_motiv_prod_bulk.sh +++ b/utils/warranty_motiv_prod_bulk.sh @@ -81,5 +81,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-18-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-21-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt From 873bf8015461b7cd78df5e1a121f17144c467ab7 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 22 Jun 2022 02:09:28 +0000 Subject: [PATCH 06/23] Fixed the sql with emergency type code. #682 --- utils/emergency_type/emergency_type.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/emergency_type/emergency_type.sql b/utils/emergency_type/emergency_type.sql index 47bf9393..5e046416 100644 --- a/utils/emergency_type/emergency_type.sql +++ b/utils/emergency_type/emergency_type.sql @@ -25,7 +25,9 @@ DROP TABLE IF EXISTS `emergency_type`; CREATE TABLE `emergency_type` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(80) COLLATE utf8_unicode_ci NOT NULL, - PRIMARY KEY (`id`) + `code` varchar(80) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`id`), + KEY `emergency_type_idx` (`code`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35,7 +37,7 @@ CREATE TABLE `emergency_type` ( LOCK TABLES `emergency_type` WRITE; /*!40000 ALTER TABLE `emergency_type` DISABLE KEYS */; -INSERT INTO `emergency_type` VALUES (1,'Emergency Situation Related to Vehicle Problem'),(2,'Avoiding Towing'),(3,'Road Obstruction'),(4,'Along the Road'),(5,'With Babies or Kids Inside the Car'),(6,'Senior Citizen'),(7,'Buying Medicine'),(8,'Going to Hospital'),(9,'Uniformed Officials'); +INSERT INTO `emergency_type` VALUES (1,'Emergency Situation Related to Vehicle Problem','emergency_situation_related_to_vehicle_problem'),(2,'Avoiding Towing','avoiding_towing'),(3,'Road Obstruction','road_obstruction'),(4,'Along the Road','along_the_road'),(5,'With Babies or Kids Inside the Car','with_babies_or_kids_inside_the_car'),(6,'Senior Citizen','senior_citizen'),(7,'Buying Medicine','buying_medicine'),(8,'Going to Hospital','going_to_hospital'),(9,'Uniformed Officials','uniformed_officials'); /*!40000 ALTER TABLE `emergency_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -48,4 +50,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-06-06 8:52:11 +-- Dump completed on 2022-06-10 8:31:30 From 7995706dd3e60d5f36b6c82d132217d62c088cfe Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 23 Jun 2022 03:07:12 +0000 Subject: [PATCH 07/23] Add another date to bulk script. #684 --- utils/warranty_motiv_local_bulk.sh | 1 + utils/warranty_motiv_prod_bulk.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/utils/warranty_motiv_local_bulk.sh b/utils/warranty_motiv_local_bulk.sh index f00b57ad..44425c4f 100755 --- a/utils/warranty_motiv_local_bulk.sh +++ b/utils/warranty_motiv_local_bulk.sh @@ -82,5 +82,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-21-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-22-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt diff --git a/utils/warranty_motiv_prod_bulk.sh b/utils/warranty_motiv_prod_bulk.sh index f00b57ad..44425c4f 100755 --- a/utils/warranty_motiv_prod_bulk.sh +++ b/utils/warranty_motiv_prod_bulk.sh @@ -82,5 +82,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-19-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-21-22 /tmp/warranty_download_serial.csv 0 +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-22-22 /tmp/warranty_download_serial.csv 0 touch /tmp/warranty_load_status.txt /usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt From ce160c506c6c153455d84c24dcb9ee360a29dc07 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 24 Jun 2022 07:13:09 +0000 Subject: [PATCH 08/23] Add a process date for the output filename when loading serials. Change the write method to append. #684 --- utils/load_warranty_serial/bulk_load_serials.php | 2 +- utils/warranty_motiv_local_bulk.sh | 7 +++++-- utils/warranty_motiv_prod_bulk.sh | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/utils/load_warranty_serial/bulk_load_serials.php b/utils/load_warranty_serial/bulk_load_serials.php index bfdd547a..cc68f0ab 100644 --- a/utils/load_warranty_serial/bulk_load_serials.php +++ b/utils/load_warranty_serial/bulk_load_serials.php @@ -10,7 +10,7 @@ use Symfony\Component\Dotenv\Dotenv; $csv = fopen($argv[1], 'r'); $output_file = $argv[2]; -$output_fh = fopen($output_file, "w"); +$output_fh = fopen($output_file, "a"); if (!file_exists($argv[1])) { diff --git a/utils/warranty_motiv_local_bulk.sh b/utils/warranty_motiv_local_bulk.sh index 44425c4f..f47e31a1 100755 --- a/utils/warranty_motiv_local_bulk.sh +++ b/utils/warranty_motiv_local_bulk.sh @@ -1,4 +1,6 @@ #!/bin/bash +proc_date=`date +%m-%d-%y` +load_status_file="/tmp/warranty_load_status_$proc_date.txt" touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 04-01-22 /tmp/warranty_download_serial.csv 1 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 04-02-22 /tmp/warranty_download_serial.csv 0 @@ -83,5 +85,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-21-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-22-22 /tmp/warranty_download_serial.csv 0 -touch /tmp/warranty_load_status.txt -/usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-23-22 /tmp/warranty_download_serial.csv 0 +touch $load_status_file +/usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv $load_status_file diff --git a/utils/warranty_motiv_prod_bulk.sh b/utils/warranty_motiv_prod_bulk.sh index 44425c4f..f47e31a1 100755 --- a/utils/warranty_motiv_prod_bulk.sh +++ b/utils/warranty_motiv_prod_bulk.sh @@ -1,4 +1,6 @@ #!/bin/bash +proc_date=`date +%m-%d-%y` +load_status_file="/tmp/warranty_load_status_$proc_date.txt" touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 04-01-22 /tmp/warranty_download_serial.csv 1 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 04-02-22 /tmp/warranty_download_serial.csv 0 @@ -83,5 +85,6 @@ touch /tmp/warranty_download_serial.csv /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-20-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-21-22 /tmp/warranty_download_serial.csv 0 /usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-22-22 /tmp/warranty_download_serial.csv 0 -touch /tmp/warranty_load_status.txt -/usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv /tmp/warranty_load_status.txt +/usr/bin/php /var/www/resq/utils/get_warranty_serial/new_get_serials.php 06-23-22 /tmp/warranty_download_serial.csv 0 +touch $load_status_file +/usr/bin/php /var/www/resq/utils/load_warranty_serial/bulk_load_serials.php /tmp/warranty_download_serial.csv $load_status_file From 48aa0b024fbcd2d3183f2b86b713a258e451e451 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 28 Jun 2022 12:47:42 +0000 Subject: [PATCH 09/23] Fix warranty creation issue. #690 --- src/Service/WarrantyHandler.php | 62 ++++++++++++++------------------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php index b59083a2..79ab3390 100644 --- a/src/Service/WarrantyHandler.php +++ b/src/Service/WarrantyHandler.php @@ -14,6 +14,7 @@ use App\Entity\CustomerVehicle; use App\Service\WarrantyAPILogger; use App\Ramcar\WarrantyClass; +use App\Ramcar\WarrantyStatus; use DateTime; use DateInterval; @@ -37,8 +38,8 @@ class WarrantyHandler $bsize_id = ''; $bmodel_name = ''; $bsize_name =''; - $sap_batt_id = ''; - $w_serial = null; + $sap_batt_id = null; + $w_serial = ''; foreach ($batt_list as $battery) { @@ -61,7 +62,6 @@ class WarrantyHandler if (!empty($sap_code)) { // find sap battery - /* $conn = $this->em->getConnection(); $sql = 'SELECT sap.id FROM sap_battery sap WHERE sap.id = :id'; $stmt = $conn->prepare($sql); @@ -73,56 +73,46 @@ class WarrantyHandler { $sap_batt_id = $row['id']; } - */ - $sap_batt_id = $sap_code; } } // compute expiry date $date_expire = null; + $str_date_expire = 'NULL'; if ((!empty($warranty_class)) && (count($batt_list) != 0)) { $period = $this->getWarrantyPeriod($batt_list, $warranty_class); $date_expire = $this->computeDateExpire($date_purchase, $period); + $str_date_expire = $date_expire->format('Y-m-d H:i:s'); } // set and save values if (trim($serial) != '') $w_serial = $serial; + $str_date_purchase = $date_purchase->format('Y-m-d H:i:s'); + $date_create = new DateTime(); + $str_date_create = $date_create->format('Y-m-d H:i:s'); + // insert warranty - $q = $this->em->createQuery('INSERT App\Entity\Warranty w - SET w.serial = :serial, - w.plate_number = :plate_number, - w.first_name = :first_name, - w.last_name = :last_name, - w.mobile_number = :mobile_number, - w.date_purchase = :date_purchase, - w.warranty_class = :warranty_class, - w.create_source = :create_source, - w.customer_id = :customer_id, - w.vehicle_id = :vehicle_id, - w.bty_model_id = :bmodel_id, - w.bty_size_id = :bsize_id, - w.sap_bty_id = :sap_batt_id, - w.date_expire = :date_expire') - ->setParameters([ - 'serial' => $serial, - 'plate_number' => $plate_number, - 'first_name' => $first_name, - 'last_name' => $last_name, - 'mobile_number' => $mobile_number, - 'date_purchase' => $date_purchase, - 'warranty_class' => $warranty_class, - 'create_source' => $source, - 'customer_id' => $customer->getID(), - 'vehicle_id' => $cust_vehicle->getID(), - 'bmodel_id' => $bmodel_id, - 'bsize_id' => $bsize_id, - 'sap_batt_id' => $sap_batt_id, - 'date_expire' => $date_expire]); - $q->execute(); + $sql_values = '(' . $bmodel_id . ',' . $bsize_id. ','; + if (empty($sap_batt_id)) + $sql_values = $sql_values . 'NULL,'; + else + $sql_values = $sql_values . '\'' . $sap_batt_id . '\','; + + if (empty($w_serial)) + $sql_values = $sql_values . 'NULL,\''; + else + $sql_values = $sql_values . '\'' . $w_serial . '\','; + + $sql_values = $sql_values . $warranty_class . '\',\'' . $plate_number . '\',\'' . WarrantyStatus::ACTIVE . '\',\'' . $str_date_create . '\',\'' . $str_date_purchase . '\',\'' . $str_date_expire . '\',\'' . $first_name . '\',\'' . $last_name . '\',\'' . $mobile_number . '\','. 1 . ',' . $cust_vehicle->getID() . ',' . $customer->getID() . ',\'' . $source . '\')'; + + $w_sql = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,sap_bty_id,serial,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source) VALUES ' . $sql_values . ';' . "\n"; + $conn = $this->em->getConnection(); + $w_stmt = $conn->prepare($w_sql); + $w_stmt->execute(); // log warranty creation $action = 'create'; From 270867f86fdd3e230e62fe58d194a9dce758ec7b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 28 Jun 2022 13:21:47 +0000 Subject: [PATCH 10/23] Redo the warranty creation. #690 --- src/Service/WarrantyHandler.php | 83 ++++++++++----------------------- 1 file changed, 24 insertions(+), 59 deletions(-) diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php index 79ab3390..ccd38746 100644 --- a/src/Service/WarrantyHandler.php +++ b/src/Service/WarrantyHandler.php @@ -34,11 +34,9 @@ class WarrantyHandler $batt_list, DateTime $date_purchase, $warranty_class, $user_id, $source, $customer, $cust_vehicle) { - $bmodel_id = ''; - $bsize_id = ''; - $bmodel_name = ''; - $bsize_name =''; - $sap_batt_id = null; + $bty_model = null; + $bty_size = null; + $sap_batt = null; $w_serial = ''; foreach ($batt_list as $battery) @@ -62,81 +60,48 @@ class WarrantyHandler if (!empty($sap_code)) { // find sap battery - $conn = $this->em->getConnection(); - $sql = 'SELECT sap.id FROM sap_battery sap WHERE sap.id = :id'; - $stmt = $conn->prepare($sql); - $stmt->execute(array('id' => $sap_code)); - - $query_results = $stmt->fetchAll(); - - foreach($query_results as $row) - { - $sap_batt_id = $row['id']; - } + $sap_batt = $this->em->getRepository(SAPBattery::class)->find($sap_code); } } // compute expiry date $date_expire = null; - $str_date_expire = 'NULL'; if ((!empty($warranty_class)) && (count($batt_list) != 0)) { $period = $this->getWarrantyPeriod($batt_list, $warranty_class); $date_expire = $this->computeDateExpire($date_purchase, $period); - $str_date_expire = $date_expire->format('Y-m-d H:i:s'); } // set and save values if (trim($serial) != '') $w_serial = $serial; - $str_date_purchase = $date_purchase->format('Y-m-d H:i:s'); - $date_create = new DateTime(); - $str_date_create = $date_create->format('Y-m-d H:i:s'); + $warranty = new Warranty(); + $warranty->setWarrantyClass($warranty_class) + ->setPlateNumber($plate_number) + ->setFirstName($first_name) + ->setLastName($last_name) + ->setMobileNumber($mobile_number) + ->setBatteryModel($bty_model) + ->setBatterySize($bty_size) + ->setSAPBattery($sap_batt) + ->setDatePurchase($date_purchase) + ->setCustomer($customer) + ->setVehicle($cust_vehicle) + ->setCreateSource($source); - // insert warranty - $sql_values = '(' . $bmodel_id . ',' . $bsize_id. ','; - if (empty($sap_batt_id)) - $sql_values = $sql_values . 'NULL,'; - else - $sql_values = $sql_values . '\'' . $sap_batt_id . '\','; + // set serial + if (!empty($w_serial)) + $warranty->setSerial($w_serial); - if (empty($w_serial)) - $sql_values = $sql_values . 'NULL,\''; - else - $sql_values = $sql_values . '\'' . $w_serial . '\','; - - $sql_values = $sql_values . $warranty_class . '\',\'' . $plate_number . '\',\'' . WarrantyStatus::ACTIVE . '\',\'' . $str_date_create . '\',\'' . $str_date_purchase . '\',\'' . $str_date_expire . '\',\'' . $first_name . '\',\'' . $last_name . '\',\'' . $mobile_number . '\','. 1 . ',' . $cust_vehicle->getID() . ',' . $customer->getID() . ',\'' . $source . '\')'; - - $w_sql = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,sap_bty_id,serial,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source) VALUES ' . $sql_values . ';' . "\n"; - $conn = $this->em->getConnection(); - $w_stmt = $conn->prepare($w_sql); - $w_stmt->execute(); - - // log warranty creation - $action = 'create'; - $exp_date = ''; + // set date expire if ($date_expire != null) - $exp_date = $date_expire->format('d-M-y'); + $warranty->setDateExpire($date_expire); - $log_data = [ - 'serial' => $serial, - 'warranty_class' => $warranty_class, - 'first_name' => $first_name, - 'last_name' => $last_name, - 'mobile_number' => $mobile_number, - 'date_purchase' => $date_purchase->format('d-M-y'), - 'date_expire' => $exp_date, - 'battery_model' => $bmodel_name, - 'battery_size' => $bsize_name, - 'sap_battery' => $sap_batt_id, - 'plate_number' => $plate_number, - ]; - //$this->logger->logWarrantyInfo($log_data, '', $user_id, $action, $source); + $this->em->persist($warranty); + $this->em->flush(); - // update customer vehicle with warranty info - //$this->updateCustomerVehicle($serial, $batt_list, $plate_number, $date_expire); } public function updateCustomerVehicle($serial, $batteries, $plate_number, $date_expire) From 559d4bbc01199bd40a46679a6697f1e50a569929 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 13 Jul 2022 00:45:58 +0800 Subject: [PATCH 11/23] Clean plate number before warranty registering for mobile API --- src/Controller/APIController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 4fd4e30e..66500409 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -4033,12 +4033,20 @@ class APIController extends Controller implements LoggedController $warr->setVehicle($vehicle); } + // TODO: make a standard clean plate number service + // clean plate number + $plate = $req->request->get('plate_number'); + // upper case and remove spaces + $plate = strtoupper(str_replace(' ', '', $plate)); + // remove special characters + $plate = preg_replace('/[^A-Za-z0-9. -]/', '', $plate); + // create or update warranty entry $warr->setSerial($serial) ->setFirstName($req->request->get('first_name')) ->setLastName($req->request->get('last_name')) ->setEmail($req->request->get('email')) - ->setPlateNumber($req->request->get('plate_number')) + ->setPlateNumber($plate) // TODO: figure out how to compute date of purchase ->setDatePurchase($date_pur) // TODO: set status From d27d54f7da460360ef6444c2b87c5ed7a5c453a2 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sat, 16 Jul 2022 19:22:59 +0800 Subject: [PATCH 12/23] Fix motiv being down for getInventory --- src/Service/MotivConnector.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Service/MotivConnector.php b/src/Service/MotivConnector.php index 60847192..f0ee8bc1 100644 --- a/src/Service/MotivConnector.php +++ b/src/Service/MotivConnector.php @@ -32,7 +32,13 @@ class MotivConnector $res = $this->curlPost('InventoryService', $body_text); - return json_decode($res, true); + $inv_res = json_decode($res, true); + + // check result + if ($inv_res == null) + return []; + + return $inv_res; } protected function curlPost($url, $body) From 774599a01b6ea73141a044ab1a299b14e0f05ddb Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 5 Aug 2022 22:10:12 +0800 Subject: [PATCH 13/23] Change prices for refuel #693 --- src/Service/InvoiceGenerator/ResqInvoiceGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index 5ee7669c..298d9988 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -35,8 +35,8 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface const WARRANTY_FEE = 0; const OTHER_SERVICES_FEE = 200; const COOLANT_FEE = 1600; - const REFUEL_FEE_GAS = 380; - const REFUEL_FEE_DIESEL = 400; + const REFUEL_FEE_GAS = 340; // for 4 liters + const REFUEL_FEE_DIESEL = 360; // for 4 liters private $security; protected $em; From 80d4063238b555cb35fd12cedb2e7826ee47e7ea Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 5 Aug 2022 22:21:49 +0800 Subject: [PATCH 14/23] Change error message for geofence #693 --- src/Controller/APIController.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 66500409..0df9bffe 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -902,7 +902,7 @@ class APIController extends Controller implements LoggedController { // TODO: put geofence error message in config file somewhere $res->setError(true) - ->setErrorMessage('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'); + ->setErrorMessage($this->getGeoErrorMessage()); return $res->getReturnResponse(); } @@ -2308,7 +2308,7 @@ class APIController extends Controller implements LoggedController if (!$is_covered) { $res->setError(true) - ->setErrorMessage('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'); + ->setErrorMessage($this->getGeoErrorMessage()); } return $res->getReturnResponse(); @@ -2769,7 +2769,7 @@ class APIController extends Controller implements LoggedController { // TODO: put geofence error message in config file somewhere $res->setError(true) - ->setErrorMessage('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'); + ->setErrorMessage($this->getGeoErrorMessage()); return $res->getReturnResponse(); } @@ -4708,4 +4708,8 @@ class APIController extends Controller implements LoggedController { return trim(strtolower($string)); } + + protected function getGeoErrorMessage() { + return 'Oops! Our service is limited to some areas in Metro Manila, Laguna, Cavite, Pampanga and Baguio only. We will update you as soon as we are able to cover your area'; + } } From 5f94f252bc04ea462b4f25918cd76a7f8db86f9b Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 12 Aug 2022 08:36:21 +0000 Subject: [PATCH 15/23] Add new transaction origin types for Yokohama. #694 --- src/Entity/JobOrder.php | 2 +- src/Ramcar/TransactionOrigin.php | 23 ++++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index 0278405a..10117f0b 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -156,7 +156,7 @@ class JobOrder // where requested job order came from (transaction origin) /** - * @ORM\Column(type="string", length=15) + * @ORM\Column(type="string", length=30) */ protected $source; diff --git a/src/Ramcar/TransactionOrigin.php b/src/Ramcar/TransactionOrigin.php index 8d4c12aa..4a13075e 100644 --- a/src/Ramcar/TransactionOrigin.php +++ b/src/Ramcar/TransactionOrigin.php @@ -4,15 +4,20 @@ 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 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'; + const YOKOHAMA_CAROUSELL = 'yokohama_carousell'; // TODO: for now, resq also gets the walk-in option + // resq also gets new YOKOHAMA options const COLLECTION = [ 'call' => 'Hotline', 'online' => 'Online', @@ -21,5 +26,9 @@ class TransactionOrigin extends NameValue 'mobile_app' => 'Mobile App', 'walk_in' => 'Walk-in', 'lazada' => 'Lazada', + 'yokohama_op_facebook' => 'Yokohama OP Facebook', + 'yokohama_twitter' => 'Yokohama Twitter', + 'yokohama_instagram' => 'Yokohama Instagram', + 'yokohama_carousell' => 'Yokohama Carousell', ]; } From c1e33fb5dd596002204d5f6dce9d5afdd6b95f92 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 12 Aug 2022 10:39:08 +0000 Subject: [PATCH 16/23] Add new ticket and new subticket types. #695 --- src/Controller/TicketController.php | 12 ++++++++++-- src/Entity/Ticket.php | 17 +++++++++++++++++ templates/ticket/form.html.twig | 7 +++++++ utils/ticket_types/subticket_type.sql | 6 +++--- utils/ticket_types/ticket_type.sql | 6 +++--- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Controller/TicketController.php b/src/Controller/TicketController.php index 00dd82be..0f918058 100644 --- a/src/Controller/TicketController.php +++ b/src/Controller/TicketController.php @@ -251,6 +251,9 @@ class TicketController extends Controller $ttype_id = $req->request->get('new_ticket_type'); $sub_ttype_id = $req->request->get('sub_ticket_type'); + // get other description if any + $other_desc = $req->request->get('other_desc'); + // get source of awareness if any $soa_type = $req->request->get('source_of_awareness'); @@ -269,7 +272,8 @@ class TicketController extends Controller ->setDateCreate(new DateTime()) ->setCreatedBy($this->getUser()) ->setSourceOfAwareness($soa_type) - ->setRemarks($remarks); + ->setRemarks($remarks) + ->setOtherDescription($other_desc); // if assigned to customer, set association if ($customer_id) { @@ -458,6 +462,9 @@ class TicketController extends Controller $ttype_id = $req->request->get('new_ticket_type'); $sub_ttype_id = $req->request->get('sub_ticket_type'); + // get other description if any + $other_desc = $req->request->get('other_desc'); + // get source of awareness if any $soa_type = $req->request->get('source_of_awareness'); @@ -474,7 +481,8 @@ class TicketController extends Controller ->setDetails($req->request->get('details')) ->setPlateNumber($req->request->get('plate_number')) ->setSourceOfAwareness($soa_type) - ->setRemarks($remarks); + ->setRemarks($remarks) + ->setOtherDescription($other_desc); // initialize error list $error_array = []; diff --git a/src/Entity/Ticket.php b/src/Entity/Ticket.php index d2a19569..0249d985 100644 --- a/src/Entity/Ticket.php +++ b/src/Entity/Ticket.php @@ -133,6 +133,12 @@ class Ticket */ protected $subticket_type; + // text field for Other subticket type + /** + * @ORM\Column(type="text", nullable=true) + */ + protected $other_description; + public function __construct() { $this->date_create = new DateTime(); @@ -337,4 +343,15 @@ class Ticket { return $this->subticket_type; } + + public function setOtherDescription($other_description) + { + $this->other_description = $other_description; + return $this; + } + + public function getOtherDescription() + { + return $this->other_description; + } } diff --git a/templates/ticket/form.html.twig b/templates/ticket/form.html.twig index da0bca86..ea97f4ac 100644 --- a/templates/ticket/form.html.twig +++ b/templates/ticket/form.html.twig @@ -93,6 +93,13 @@ +
+
+ + + +
+
diff --git a/utils/ticket_types/subticket_type.sql b/utils/ticket_types/subticket_type.sql index 7f37f20a..ea9d17a5 100644 --- a/utils/ticket_types/subticket_type.sql +++ b/utils/ticket_types/subticket_type.sql @@ -31,7 +31,7 @@ CREATE TABLE `subticket_type` ( KEY `IDX_F18521A4C980D5C1` (`ticket_type_id`), KEY `subticket_type_idx` (`code`), CONSTRAINT `FK_F18521A4C980D5C1` FOREIGN KEY (`ticket_type_id`) REFERENCES `ticket_type` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=182 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -40,7 +40,7 @@ CREATE TABLE `subticket_type` ( LOCK TABLES `subticket_type` WRITE; /*!40000 ALTER TABLE `subticket_type` DISABLE KEYS */; -INSERT INTO `subticket_type` VALUES (1,1,'Hub / Distributor','hub_distributor'),(2,1,'Rider / Technician','rider_technician'),(3,1,'Service Procedure (Incomplete Document/s)','service_procedure_incomplete_documents'),(4,1,'Agent','agent'),(5,1,'Wrong Battery','wrong_battery'),(6,2,'Delivery Time','delivery_time'),(7,2,'Line Up Status','line_up_status'),(8,2,'Recharged / Replacement Battery','recharged_replacement_battery'),(9,3,'Battery Brand','battery_brand'),(10,3,'Battery Life Span','battery_life_span'),(11,3,'Battery Price and Trade-in','battery_price_and_trade_in'),(12,3,'Battery Specifications','battery_specifications'),(13,3,'Battery Warranty','battery_warranty'),(14,3,'Call Out Request','call_out_request'),(15,3,'Dealership','dealership'),(16,3,'Distributor Call','distributor_call'),(17,3,'For Generator Set (GenSet)','for_generator_set_genset'),(18,3,'Grab','grab'),(19,3,'Mode of Payment','mode_of_payment'),(20,3,'Motorcycle Batteries','motorcycle_batteries'),(21,3,'Operating Hours','operating_hours'),(22,3,'Outlet nearby details (Province)','outlet_nearby_details_province'),(23,3,'Pezza or EWT','pezza_or_ewt'),(24,3,'Promo or Discount','promo_or_discount'),(25,3,'PVC','pvc'),(26,3,'ResQ Services and Fee','resq_services_and_fee'),(27,3,'Service Fee','service_fee'),(28,3,'Serviceable Area','serviceable_area'),(29,3,'Shell','shell'),(30,3,'VAT Exempt','vat_exempt'),(31,3,'Warranty Claim / Procedures','warranty_claim_procedures'),(32,3,'Test Call','test_call'),(33,4,'Ghost Call','ghost_call'),(34,4,'Line Cut','line_cut'),(35,4,'System Problem','system_problem'),(36,4,'Transferred Calls','transferred_calls'),(37,4,'VPN Down','vpn_down'); +INSERT INTO `subticket_type` VALUES (1,1,'Hub / Distributor','hub_distributor'),(2,1,'Rider / Technician','rider_technician'),(3,1,'Service Procedure (Incomplete Document/s)','service_procedure_incomplete_documents'),(4,1,'Agent','agent'),(5,1,'Wrong Battery','wrong_battery'),(6,2,'Delivery Time','delivery_time'),(7,2,'Line Up Status','line_up_status'),(8,2,'Recharged / Replacement Battery','recharged_replacement_battery'),(9,3,'Battery Brand','battery_brand'),(10,3,'Battery Life Span','battery_life_span'),(11,3,'Battery Price and Trade-in','battery_price_and_trade_in'),(12,3,'Battery Specifications','battery_specifications'),(13,3,'Battery Warranty','battery_warranty'),(14,3,'Call Out Request','call_out_request'),(15,3,'Dealership','dealership'),(16,3,'Distributor Call','distributor_call'),(17,3,'For Generator Set (GenSet)','for_generator_set_genset'),(18,3,'Grab','grab'),(19,3,'Mode of Payment','mode_of_payment'),(20,3,'Motorcycle Batteries','motorcycle_batteries'),(21,3,'Operating Hours','operating_hours'),(22,3,'Outlet nearby details (Province)','outlet_nearby_details_province'),(23,3,'Pezza or EWT','pezza_or_ewt'),(24,3,'Promo or Discount','promo_or_discount'),(25,3,'PVC','pvc'),(26,3,'ResQ Services and Fee','resq_services_and_fee'),(27,3,'Service Fee','service_fee'),(28,3,'Serviceable Area','serviceable_area'),(29,3,'Shell','shell'),(30,3,'VAT Exempt','vat_exempt'),(31,3,'Warranty Claim / Procedures','warranty_claim_procedures'),(32,3,'Test Call','test_call'),(33,4,'Ghost Call','ghost_call'),(34,4,'Line Cut','line_cut'),(35,4,'System Problem','system_problem'),(36,4,'Transferred Calls','transferred_calls'),(37,4,'VPN Down','vpn_down'),(38,5,'AB Price Inquiry','ab_price_inquiry_yokohama_op_facebook'),(39,5,'AB Delivery Inquiry','ab_delivery_inquiry_yokohama_op_facebook'),(40,5,'AB Service Inquiry','ab_service_inquiry_yokohama_op_facebook'),(41,5,'AB Service Fee Inquiry','ab_service_fee_inquiry_yokohama_op_facebook'),(42,5,'Special Battery Type Price Inquiry','special_battery_type_price_inquiry_yokohama_op_facebook'),(43,5,'Special Battery Type Service Inquiry','special_battery_type_service_inquiry_yokohama_op_facebook'),(44,5,'AB Battery Recharging Inquiry','ab_battery_recharging_inquiry_yokohama_op_facebook'),(45,5,'Sponsorship','sponsorship_yokohama_op_facebook'),(46,5,'Dealership','dealership_yokohama_op_facebook'),(47,5,'Yokohama Provincial Store Contact Information','yokohama_provincial_store_contact_information_yokohama_op_faceboook'),(48,5,'Unknown (The Customer did not proceed with his message)','unknown_customer_not_proceed_message_yokohama_op_facebook'),(49,5,'MCB Price Inquiry','mcb_price_inquiry_yokohama_op_facebook'),(50,5,'MCB Delivery Inquiry','mcb_delivery_inquiry_yokohama_op_facebook'),(51,5,'Recommended MCB Inquiry','recommended_mcb_inquiry_yokohama_op_facebook'),(52,5,'Recommended AB Battery Inquiry','recommended_ab_battery_inquiry_yokohama_op_facebook'),(53,5,'Battery Quotation Request','battery_quotation_request_yokohama_op_facebook'),(54,5,'CC Hours of Operation Inquiry','cc_hours_of_operation_inquiry_yokohama_op_facebook'),(55,5,'Battery Warranty Claim Inquiry','battery_warranty_claim_inquiry_yokohama_op_facebook'),(56,5,'Mode of Payment Inquiry','mode_of_payment_inquiry_yokohama_op_facebook'),(57,5,'YOKOHAMA Request FUP','yokohama_request_fup_yokohama_op_facebook'),(58,5,'Battery Manufacturing Date Inquiry','battery_manufacturing_date_inquiry_yokohama_op_facebook'),(59,5,'Battery Production Date Inquiry','battery_production_date_inquiry_yokohama_op_facebook'),(60,5,'MM Store Contact Info Inquiry','mm_store_contact_info_inquiry_yokohama_op_facebook'),(61,5,'Customer Complaint – Distributor/Dealer','customer_complaint_distributor_dealer_yokohama_op_facebook'),(62,5,'Customer Complaint – YOKOHAMA','customer_complaint_yokohama_yokohama_op_facebook'),(63,5,'Social Media Mentions','social_media_mentions_yokohama_op_facebook'),(64,5,'CC Hotline Number Inquiry','cc_hotline_number_inquiry_yokohama_op_facebook'),(65,5,'Battery Trade-in Inquiry','battery_trade_in_inquiry_yokohama_op_facebook'),(66,5,'AB Battery Specifications Inquiry','ab_battery_specifications_inquiry_yokohama_op_facebook'),(67,5,'Special Battery Type Specification Inquiry','special_battery_type_specification_inquiry_yokohama_op_facebook'),(68,5,'Prank / Troll','prank_troll_yokohama_op_facebook'),(69,5,'Company Job Opening Inquiry','company_job_opening_inquiry_yokohama_op_facebook'),(70,5,'AB Battery Discounts / Promotions','ab_battery_discounts_promotions_yokohama_op_facebook'),(71,5,'Business Proposal','business_proposal_yokohama_op_facebook'),(72,5,'Customer Commendation','customer_commendation_yokohama_op_facebook'),(73,5,'Other (please allot a field to input descriptions)','other_yokohama_op_facebook'),(74,6,'AB Price Inquiry','ab_price_inquiry_yokohama_twitter'),(75,6,'AB Delivery Inquiry','ab_delivery_inquiry_yokohama_twitter'),(76,6,'AB Service Inquiry','ab_service_inquiry_yokohama_twitter'),(77,6,'AB Service Fee Inquiry','ab_service_fee_inquiry_yokohama_twitter'),(78,6,'Special Battery Type Price Inquiry','special_battery_type_price_inquiry_yokohama_twitter'),(79,6,'Special Battery Type Service Inquiry','special_battery_type_service_inquiry_yokohama_twitter'),(80,6,'AB Battery Recharging Inquiry','ab_battery_recharging_inquiry_yokohama_twitter'),(81,6,'Sponsorship','sponsorship_yokohama_twitter'),(82,6,'Dealership','dealership_yokohama_twitter'),(83,6,'Yokohama Provincial Store Contact Information','yokohama_provincial_store_contact_information_yokohama_twitter'),(84,6,'Unknown (The Customer did not proceed with his message)','unknown_customer_not_proceed_message_yokohama_twitter'),(85,6,'MCB Price Inquiry','mcb_price_inquiry_yokohama_twitter'),(86,6,'MCB Delivery Inquiry','mcb_delivery_inquiry_yokohama_twitter'),(87,6,'Recommended MCB Inquiry','recommended_mcb_inquiry_yokohama_twitter'),(88,6,'Recommended AB Battery Inquiry','recommended_ab_battery_inquiry_yokohama_twitter'),(89,6,'Battery Quotation Request','battery_quotation_request_yokohama_twitter'),(90,6,'CC Hours of Operation Inquiry','cc_hours_of_operation_inquiry_yokohama_twitter'),(91,6,'Battery Warranty Claim Inquiry','battery_warranty_claim_inquiry_yokohama_twitter'),(92,6,'Mode of Payment Inquiry','mode_of_payment_inquiry_yokohama_twitter'),(93,6,'YOKOHAMA Request FUP','yokohama_request_fup_yokohama_twitter'),(94,6,'Battery Manufacturing Date Inquiry','battery_manufacturing_date_inquiry_yokohama_twitter'),(95,6,'Battery Production Date Inquiry','battery_production_date_inquiry_yokohama_twitter'),(96,6,'MM Store Contact Info Inquiry','mm_store_contact_info_inquiry_yokohama_twitter'),(97,6,'Customer Complaint – Distributor/Dealer','customer_complaint_distributor_dealer_yokohama_twitter'),(98,6,'Customer Complaint – YOKOHAMA','customer_complaint_yokohama_yokohama_twitter'),(99,6,'Social Media Mentions','social_media_mentions_yokohama_twitter'),(100,6,'CC Hotline Number Inquiry','cc_hotline_number_inquiry_yokohama_twitter'),(101,6,'Battery Trade-in Inquiry','battery_trade_in_inquiry_yokohama_twitter'),(102,6,'AB Battery Specifications Inquiry','ab_battery_specifications_inquiry_yokohama_twitter'),(103,6,'Special Battery Type Specification Inquiry','special_battery_type_specification_inquiry_yokohama_twitter'),(104,6,'Prank / Troll','prank_troll_yokohama_twitter'),(105,6,'Company Job Opening Inquiry','company_job_opening_inquiry_yokohama_twitter'),(106,6,'AB Battery Discounts / Promotions','ab_battery_discounts_promotions_yokohama_twitter'),(107,6,'Business Proposal','business_proposal_yokohama_twitter'),(108,6,'Customer Commendation','customer_commendation_yokohama_twitter'),(109,6,'Other (please allot a field to input descriptions)','other_yokohama_twitter'),(110,7,'AB Price Inquiry','ab_price_inquiry_yokohama_instagram'),(111,7,'AB Delivery Inquiry','ab_delivery_inquiry_yokohama_instagram'),(112,7,'AB Service Inquiry','ab_service_inquiry_yokohama_instagram'),(113,7,'AB Service Fee Inquiry','ab_service_fee_inquiry_yokohama_instagram'),(114,7,'Special Battery Type Price Inquiry','special_battery_type_price_inquiry_yokohama_instagram'),(115,7,'Special Battery Type Service Inquiry','special_battery_type_service_inquiry_yokohama_instagram'),(116,7,'AB Battery Recharging Inquiry','ab_battery_recharging_inquiry_yokohama_instagram'),(117,7,'Sponsorship','sponsorship_yokohama_instagram'),(118,7,'Dealership','dealership_yokohama_instagram'),(119,7,'Yokohama Provincial Store Contact Information','yokohama_provincial_store_contact_information_yokohama_instagram'),(120,7,'Unknown (The Customer did not proceed with his message)','unknown_customer_not_proceed_message_yokohama_instagram'),(121,7,'MCB Price Inquiry','mcb_price_inquiry_yokohama_instagram'),(122,7,'MCB Delivery Inquiry','mcb_delivery_inquiry_yokohama_instagram'),(123,7,'Recommended MCB Inquiry','recommended_mcb_inquiry_yokohama_instagram'),(124,7,'Recommended AB Battery Inquiry','recommended_ab_battery_inquiry_yokohama_instagram'),(125,7,'Battery Quotation Request','battery_quotation_request_yokohama_instagram'),(126,7,'CC Hours of Operation Inquiry','cc_hours_of_operation_inquiry_yokohama_instagram'),(127,7,'Battery Warranty Claim Inquiry','battery_warranty_claim_inquiry_yokohama_instagram'),(128,7,'Mode of Payment Inquiry','mode_of_payment_inquiry_yokohama_instagram'),(129,7,'YOKOHAMA Request FUP','yokohama_request_fup_yokohama_instagram'),(130,7,'Battery Manufacturing Date Inquiry','battery_manufacturing_date_inquiry_yokohama_instagram'),(131,7,'Battery Production Date Inquiry','battery_production_date_inquiry_yokohama_instagram'),(132,7,'MM Store Contact Info Inquiry','mm_store_contact_info_inquiry_yokohama_instagram'),(133,7,'Customer Complaint – Distributor/Dealer','customer_complaint_distributor_dealer_yokohama_instagram'),(134,7,'Customer Complaint – YOKOHAMA','customer_complaint_yokohama_yokohama_instagram'),(135,7,'Social Media Mentions','social_media_mentions_yokohama_instagram'),(136,7,'CC Hotline Number Inquiry','cc_hotline_number_inquiry_yokohama_instagram'),(137,7,'Battery Trade-in Inquiry','battery_trade_in_inquiry_yokohama_instagram'),(138,7,'AB Battery Specifications Inquiry','ab_battery_specifications_inquiry_yokohama_instagram'),(139,7,'Special Battery Type Specification Inquiry','special_battery_type_specification_inquiry_yokohama_instagram'),(140,7,'Prank / Troll','prank_troll_yokohama_instagram'),(141,7,'Company Job Opening Inquiry','company_job_opening_inquiry_yokohama_instagram'),(142,7,'AB Battery Discounts / Promotions','ab_battery_discounts_promotions_yokohama_instagram'),(143,7,'Business Proposal','business_proposal_yokohama_instagram'),(144,7,'Customer Commendation','customer_commendation_yokohama_instagram'),(145,7,'Other (please allot a field to input descriptions)','other_yokohama_instagram'),(146,8,'AB Price Inquiry','ab_price_inquiry_yokohama_carousell'),(147,8,'AB Delivery Inquiry','ab_delivery_inquiry_yokohama_carousell'),(148,8,'AB Service Inquiry','ab_service_inquiry_yokohama_carousell'),(149,8,'AB Service Fee Inquiry','ab_service_fee_inquiry_yokohama_carousell'),(150,8,'Special Battery Type Price Inquiry','special_battery_type_price_inquiry_yokohama_carousell'),(151,8,'Special Battery Type Service Inquiry','special_battery_type_service_inquiry_yokohama_carousell'),(152,8,'AB Battery Recharging Inquiry','ab_battery_recharging_inquiry_yokohama_carousell'),(153,8,'Sponsorship','sponsorship_yokohama_carousell'),(154,8,'Dealership','dealership_yokohama_carousell'),(155,8,'Yokohama Provincial Store Contact Information','yokohama_provincial_store_contact_information_yokohama_carousell'),(156,8,'Unknown (The Customer did not proceed with his message)','unknown_customer_not_proceed_message_yokohama_carousell'),(157,8,'MCB Price Inquiry','mcb_price_inquiry_yokohama_carousell'),(158,8,'MCB Delivery Inquiry','mcb_delivery_inquiry_yokohama_carousell'),(159,8,'Recommended MCB Inquiry','recommended_mcb_inquiry_yokohama_carousell'),(160,8,'Recommended AB Battery Inquiry','recommended_ab_battery_inquiry_yokohama_carousell'),(161,8,'Battery Quotation Request','battery_quotation_request_yokohama_carousell'),(162,8,'CC Hours of Operation Inquiry','cc_hours_of_operation_inquiry_yokohama_carousell'),(163,8,'Battery Warranty Claim Inquiry','battery_warranty_claim_inquiry_yokohama_carousell'),(164,8,'Mode of Payment Inquiry','mode_of_payment_inquiry_yokohama_carousell'),(165,8,'YOKOHAMA Request FUP','yokohama_request_fup_yokohama_carousell'),(166,8,'Battery Manufacturing Date Inquiry','battery_manufacturing_date_inquiry_yokohama_carousell'),(167,8,'Battery Production Date Inquiry','battery_production_date_inquiry_yokohama_carousell'),(168,8,'MM Store Contact Info Inquiry','mm_store_contact_info_inquiry_yokohama_carousell'),(169,8,'Customer Complaint – Distributor/Dealer','customer_complaint_distributor_dealer_yokohama_carousell'),(170,8,'Customer Complaint – YOKOHAMA','customer_complaint_yokohama_yokohama_carousell'),(171,8,'Social Media Mentions','social_media_mentions_yokohama_carousell'),(172,8,'CC Hotline Number Inquiry','cc_hotline_number_inquiry_yokohama_carousell'),(173,8,'Battery Trade-in Inquiry','battery_trade_in_inquiry_yokohama_carousell'),(174,8,'AB Battery Specifications Inquiry','ab_battery_specifications_inquiry_yokohama_carousell'),(175,8,'Special Battery Type Specification Inquiry','special_battery_type_specification_inquiry_yokohama_carousell'),(176,8,'Prank / Troll','prank_troll_yokohama_carousell'),(177,8,'Company Job Opening Inquiry','company_job_opening_inquiry_yokohama_carousell'),(178,8,'AB Battery Discounts / Promotions','ab_battery_discounts_promotions_yokohama_carousell'),(179,8,'Business Proposal','business_proposal_yokohama_carousell'),(180,8,'Customer Commendation','customer_commendation_yokohama_carousell'),(181,8,'Other (please allot a field to input descriptions)','other_yokohama_carousell'); /*!40000 ALTER TABLE `subticket_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -53,4 +53,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-06-10 6:44:22 +-- Dump completed on 2022-08-12 10:25:20 diff --git a/utils/ticket_types/ticket_type.sql b/utils/ticket_types/ticket_type.sql index 0887e77e..dead80a9 100644 --- a/utils/ticket_types/ticket_type.sql +++ b/utils/ticket_types/ticket_type.sql @@ -28,7 +28,7 @@ CREATE TABLE `ticket_type` ( `code` varchar(25) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `ticket_type_idx` (`code`) -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -37,7 +37,7 @@ CREATE TABLE `ticket_type` ( LOCK TABLES `ticket_type` WRITE; /*!40000 ALTER TABLE `ticket_type` DISABLE KEYS */; -INSERT INTO `ticket_type` VALUES (1,'Complaint','complaint'),(2,'Follow up','follow_up'),(3,'Inquiry','inquiry'),(4,'Others','others'); +INSERT INTO `ticket_type` VALUES (1,'Complaint','complaint'),(2,'Follow up','follow_up'),(3,'Inquiry','inquiry'),(4,'Others','others'),(5,'Yokohama OP Facebook','yokohama_op_facebook'),(6,'Yokohama Twitter','yokohama_twitter'),(7,'Yokohama Instagram','yokohama_instagram'),(8,'Yokohama Carousell','yokohama_carousell'); /*!40000 ALTER TABLE `ticket_type` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -50,4 +50,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-06-10 6:44:12 +-- Dump completed on 2022-08-12 10:25:41 From 837a3a2ec53df41b499fcea7c10d20e834ce1432 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 15 Aug 2022 07:10:15 +0000 Subject: [PATCH 17/23] Add ownership type CRUD. #696 --- config/acl.yaml | 14 ++ config/menu.yaml | 4 + config/routes/ownership_type.yaml | 35 +++ src/Controller/OwnershipTypeController.php | 255 +++++++++++++++++++++ src/Entity/OwnershipType.php | 63 +++++ templates/ownership-type/form.html.twig | 142 ++++++++++++ templates/ownership-type/list.html.twig | 146 ++++++++++++ 7 files changed, 659 insertions(+) create mode 100644 config/routes/ownership_type.yaml create mode 100644 src/Controller/OwnershipTypeController.php create mode 100644 src/Entity/OwnershipType.php create mode 100644 templates/ownership-type/form.html.twig create mode 100644 templates/ownership-type/list.html.twig diff --git a/config/acl.yaml b/config/acl.yaml index 3e221f67..6da5b558 100644 --- a/config/acl.yaml +++ b/config/acl.yaml @@ -568,3 +568,17 @@ access_keys: label: Update - id: emergency_type.delete label: Delete + + - id: ownership_type + label: Ownership Type Access + acls: + - id: ownership_type.menu + label: Menu + - id: ownership_type.list + label: List + - id: ownership_type.add + label: Add + - id: ownership_type.update + label: Update + - id: ownership_type.delete + label: Delete diff --git a/config/menu.yaml b/config/menu.yaml index 487a4ef7..b75a9d38 100644 --- a/config/menu.yaml +++ b/config/menu.yaml @@ -245,3 +245,7 @@ main_menu: acl: emergency_type.menu label: Emergency Types parent: database + - id: ownership_type_list + acl: ownership_type.menu + label: Ownership Types + parent: database diff --git a/config/routes/ownership_type.yaml b/config/routes/ownership_type.yaml new file mode 100644 index 00000000..9d0b17b9 --- /dev/null +++ b/config/routes/ownership_type.yaml @@ -0,0 +1,35 @@ +ownership_type_list: + path: /ownership-types + controller: App\Controller\OwnershipTypeController::index + methods: [GET] + +ownership_type_rows: + path: /ownership-types/rowdata + controller: App\Controller\OwnershipTypeController::datatableRows + methods: [POST] + +ownership_type_add_form: + path: /ownership-types/newform + controller: App\Controller\OwnershipTypeController::addForm + methods: [GET] + +ownership_type_add_submit: + path: /ownership-types + controller: App\Controller\OwnershipTypeController::addSubmit + methods: [POST] + +ownership_type_update_form: + path: /ownership-types/{id} + controller: App\Controller\OwnershipTypeController::updateForm + methods: [GET] + +ownership_type_update_submit: + path: /ownership-types/{id} + controller: App\Controller\OwnershipTypeController::updateSubmit + methods: [POST] + +ownership_type_delete: + path: /ownership-types/{id} + controller: App\Controller\OwnershipTypeController::deleteSubmit + methods: [DELETE] + diff --git a/src/Controller/OwnershipTypeController.php b/src/Controller/OwnershipTypeController.php new file mode 100644 index 00000000..3817b64e --- /dev/null +++ b/src/Controller/OwnershipTypeController.php @@ -0,0 +1,255 @@ +denyAccessUnlessGranted('ownership_type.list', null, 'No access.'); + + return $this->render('ownership-type/list.html.twig'); + } + + /** + * @IsGranted("ownership_type.list") + */ + public function datatableRows(Request $req) + { + // get query builder + $qb = $this->getDoctrine() + ->getRepository(OwnershipType::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('ownership_type.update')) + $row['meta']['update_url'] = $this->generateUrl('ownership_type_update_form', ['id' => $row['id']]); + if ($this->isGranted('ownership_type.delete')) + $row['meta']['delete_url'] = $this->generateUrl('ownership_type_delete', ['id' => $row['id']]); + + $rows[] = $row; + } + + // response + return $this->json([ + 'meta' => $meta, + 'data' => $rows + ]); + } + + /** + * @Menu(selected="ownership_type.list") + * @IsGranted("ownership_type.add") + */ + public function addForm() + { + $ownership_type = new OwnershipType(); + $params = [ + 'ownership_type' => $ownership_type, + 'mode' => 'create', + ]; + + // response + return $this->render('ownership-type/form.html.twig', $params); + } + + /** + * @IsGranted("ownership_type.add") + */ + public function addSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator) + { + $ownership_type = new OwnershipType(); + + $this->setObject($ownership_type, $req); + + // validate + $errors = $validator->validate($ownership_type); + + // 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($ownership_type); + $em->flush(); + + // return successful response + return $this->json([ + 'success' => 'Changes have been saved!' + ]); + + } + + /** + * @Menu(selected="ownership_type_list") + * @ParamConverter("ownership_type", class="App\Entity\OwnershipType") + * @IsGranted("ownership_type.update") + */ + public function updateForm($id, EntityManagerInterface $em, OwnershipType $ownership_type) + { + $params = []; + $params['ownership_type'] = $ownership_type; + $params['mode'] = 'update'; + + // response + return $this->render('ownership-type/form.html.twig', $params); + } + + /** + * @ParamConverter("ownership_type", class="App\Entity\OwnershipType") + * @IsGranted("ownership_type.update") + */ + public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, OwnershipType $ownership_type) + { + $this->setObject($ownership_type, $req); + + // validate + $errors = $validator->validate($ownership_type); + + // 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("ownership_type", class="App\Entity\OwnershipType") + * @IsGranted("ownership_type.update") + */ + public function deleteSubmit(EntityManagerInterface $em, OwnershipType $ownership_type) + { + // delete this object + $em->remove($ownership_type); + $em->flush(); + + // response + $response = new Response(); + $response->setStatusCode(Response::HTTP_OK); + $response->send(); + } + + + protected function setObject(OwnershipType $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/Entity/OwnershipType.php b/src/Entity/OwnershipType.php new file mode 100644 index 00000000..86d1171c --- /dev/null +++ b/src/Entity/OwnershipType.php @@ -0,0 +1,63 @@ +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/templates/ownership-type/form.html.twig b/templates/ownership-type/form.html.twig new file mode 100644 index 00000000..5db87a17 --- /dev/null +++ b/templates/ownership-type/form.html.twig @@ -0,0 +1,142 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

Ownership Types

+
+
+
+ +
+ +
+
+
+
+
+
+ + + +

+ {% if mode == 'update' %} + Edit Ownership Type + {{ ownership_type.getName() }} + {% else %} + New Ownership Type + {% endif %} +

+
+
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+
+
+
+
+ + Back +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} diff --git a/templates/ownership-type/list.html.twig b/templates/ownership-type/list.html.twig new file mode 100644 index 00000000..c5554fad --- /dev/null +++ b/templates/ownership-type/list.html.twig @@ -0,0 +1,146 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+
+
+

+ Ownership Types +

+
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ + + + +
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %} From a4338c8f61a1b28f7f247c9325ad8f36d8c8bac8 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 15 Aug 2022 08:28:23 +0000 Subject: [PATCH 18/23] Add ownership type dropdown to JO form. #696 --- src/Entity/JobOrder.php | 17 ++++++ .../JobOrderHandler/ResqJobOrderHandler.php | 57 +++++++++++++++++-- templates/job-order/form.html.twig | 16 ++++++ 3 files changed, 84 insertions(+), 6 deletions(-) diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index 0278405a..8711c988 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -415,6 +415,13 @@ class JobOrder */ protected $emergency_type; + // new ownership type + /** + * @ORM\ManyToOne(targetEntity="OwnershipType", inversedBy="job_orders") + * @ORM\JoinColumn(name="ownership_type_id", referencedColumnName="id", nullable=true) + */ + protected $ownership_type; + public function __construct() { $this->date_create = new DateTime(); @@ -1182,4 +1189,14 @@ class JobOrder return $this->emergency_type; } + public function setOwnershipType(OwnershipType $ownership_type = null) + { + $this->ownership_type = $ownership_type; + return $this; + } + + public function getOwnershipType() + { + return $this->ownership_type; + } } diff --git a/src/Service/JobOrderHandler/ResqJobOrderHandler.php b/src/Service/JobOrderHandler/ResqJobOrderHandler.php index a5487311..5f88b057 100644 --- a/src/Service/JobOrderHandler/ResqJobOrderHandler.php +++ b/src/Service/JobOrderHandler/ResqJobOrderHandler.php @@ -27,6 +27,7 @@ use App\Entity\Warranty; use App\Entity\Customer; use App\Entity\CustomerTag; use App\Entity\EmergencyType; +use App\Entity\OwnershipType; use App\Ramcar\InvoiceCriteria; use App\Ramcar\ServiceType; @@ -445,6 +446,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + // TODO: check status before saving since JO might already // have a status that needs to be retained @@ -483,7 +488,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setInitialConcernNotes($initial_concern_notes) ->setCallerClassification($caller_class) ->setGender($gender) - ->setEmergencyType($etype); + ->setEmergencyType($etype) + ->setOwnershipType($owner_type); // check if user is null, meaning call to create came from API if ($user != null) @@ -700,6 +706,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + if (empty($error_array)) { // get current user @@ -733,7 +743,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setInitialConcernNotes($initial_concern_notes) ->setCallerClassification($caller_class) ->setGender($gender) - ->setEmergencyType($etype); + ->setEmergencyType($etype) + ->setOwnershipType($owner_type); // did they change invoice? $invoice_items = $req->request->get('invoice_items', []); @@ -901,6 +912,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + if (empty($error_array)) { // coordinates @@ -931,7 +946,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setInitialConcernNotes($initial_concern_notes) ->setGender($gender) ->setCallerClassification($caller_class) - ->setEmergencyType($etype); + ->setEmergencyType($etype) + ->setOwnershipType($owner_type); // validate $errors = $this->validator->validate($obj); @@ -1045,6 +1061,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + // get current user $user = $this->security->getUser(); @@ -1077,7 +1097,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setInitialConcernNotes($initial_concern_notes) ->setCallerClassification($caller_class) ->setGender($gender) - ->setEmergencyType($etype); + ->setEmergencyType($etype) + ->setOwnershipType($owner_type); if ($user != null) { @@ -1180,6 +1201,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + if (empty($error_array)) { // coordinates $point = new Point($req->request->get('coord_lng'), $req->request->get('coord_lat')); @@ -1206,7 +1231,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setInitialConcernNotes($initial_concern_notes) ->setGender($gender) ->setCallerClassification($caller_class) - ->setEmergencyType($etype); + ->setEmergencyType($etype) + ->setOwnershipType($owner_type); // validate $errors = $this->validator->validate($obj); @@ -1429,6 +1455,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + // get previously assigned hub, if any $old_hub = $obj->getHub(); @@ -1486,6 +1516,7 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setGender($gender) ->setCallerClassification($caller_class) ->setEmergencyType($etype) + ->setOwnershipType($owner_type) ->clearRider(); if ($user != null) @@ -1704,6 +1735,10 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface $etype_id = $req->request->get('emergency_type', 0); $etype = $em->getRepository(EmergencyType::class)->find($etype_id); + // get ownership type if any + $ownertype_id = $req->request->get('ownership_type', 0); + $owner_type = $em->getRepository(OwnershipType::class)->find($ownertype_id); + if (empty($error_array)) { // rider mqtt event // NOTE: need to send this before saving because rider will be cleared @@ -1755,7 +1790,8 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface ->setInitialConcernNotes($initial_concern_notes) ->setGender($gender) ->setCallerClassification($caller_class) - ->setEmergencyType($etype); + ->setEmergencyType($etype) + ->setOwnershipType($owner_type); if ($user != null) { @@ -3254,6 +3290,15 @@ class ResqJobOrderHandler implements JobOrderHandlerInterface } $params['emergency_types'] = $emergency_types; + // list of ownership types + $owner_types = $em->getRepository(OwnershipType::class)->findBy([]); + $ownership_types = []; + foreach ($owner_types as $ownership_type) + { + $ownership_types[$ownership_type->getID()] = $ownership_type->getName(); + } + $params['ownership_types'] = $ownership_types; + // list of hubs $hubs = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']); $fac_hubs = []; diff --git a/templates/job-order/form.html.twig b/templates/job-order/form.html.twig index b98b27bf..e57f8114 100644 --- a/templates/job-order/form.html.twig +++ b/templates/job-order/form.html.twig @@ -517,6 +517,22 @@
+
+ + + +
+
+
From 1feef7484ebac0d325350b485cbe957a3902c1f3 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 16 Aug 2022 07:44:36 +0000 Subject: [PATCH 19/23] Adjust fuel charges. #700 --- src/Service/InvoiceGenerator/ResqInvoiceGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index 298d9988..0a1ed4ed 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -35,8 +35,8 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface const WARRANTY_FEE = 0; const OTHER_SERVICES_FEE = 200; const COOLANT_FEE = 1600; - const REFUEL_FEE_GAS = 340; // for 4 liters - const REFUEL_FEE_DIESEL = 360; // for 4 liters + const REFUEL_FEE_GAS = 320; // for 4 liters + const REFUEL_FEE_DIESEL = 340; // for 4 liters private $security; protected $em; From 34accc1a0ccfb17d0c6553a0322ddfa0708621d1 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 16 Aug 2022 08:05:02 +0000 Subject: [PATCH 20/23] Add sql file for ownership types. #696 --- utils/ownership_types/ownership_type.sql | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 utils/ownership_types/ownership_type.sql diff --git a/utils/ownership_types/ownership_type.sql b/utils/ownership_types/ownership_type.sql new file mode 100644 index 00000000..1dadac91 --- /dev/null +++ b/utils/ownership_types/ownership_type.sql @@ -0,0 +1,53 @@ +-- MySQL dump 10.19 Distrib 10.3.32-MariaDB, for Linux (x86_64) +-- +-- Host: localhost Database: resq +-- ------------------------------------------------------ +-- Server version 10.3.32-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 `ownership_type` +-- + +DROP TABLE IF EXISTS `ownership_type`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ownership_type` ( + `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 `ownership_type_idx` (`code`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `ownership_type` +-- + +LOCK TABLES `ownership_type` WRITE; +/*!40000 ALTER TABLE `ownership_type` DISABLE KEYS */; +INSERT INTO `ownership_type` VALUES (1,'first','First'),(2,'second','Second'),(3,'not_determined','Not Determined'); +/*!40000 ALTER TABLE `ownership_type` 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 2022-08-16 8:04:30 From 6231db24673895935fa9176a00c1cb47c93a1cb2 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 30 Aug 2022 04:29:16 +0000 Subject: [PATCH 21/23] Update the token for the motiv blob. #701 --- utils/get_warranty_serial/new_get_serials.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/get_warranty_serial/new_get_serials.php b/utils/get_warranty_serial/new_get_serials.php index 61477885..63403203 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-06-16T04:09:13Z&se=2030-06-16T12:09:13Z&spr=https&sv=2021-06-08&sr=c&sig=x26qUFEMIqg4JgTCVHoDv%2FtTqCprjogEqtOsTpBjkWA%3D'; +$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'; $conn_string = "BlobEndpoint=$blob_url;\nSharedAccessSignature=$sas_token"; From f51ec9112de73e464ef932588cedb753b86eed09 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Tue, 30 Aug 2022 04:38:22 +0000 Subject: [PATCH 22/23] Modify fuel prices. #702 --- src/Service/InvoiceGenerator/ResqInvoiceGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php index 0a1ed4ed..298d9988 100644 --- a/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php +++ b/src/Service/InvoiceGenerator/ResqInvoiceGenerator.php @@ -35,8 +35,8 @@ class ResqInvoiceGenerator implements InvoiceGeneratorInterface const WARRANTY_FEE = 0; const OTHER_SERVICES_FEE = 200; const COOLANT_FEE = 1600; - const REFUEL_FEE_GAS = 320; // for 4 liters - const REFUEL_FEE_DIESEL = 340; // for 4 liters + const REFUEL_FEE_GAS = 340; // for 4 liters + const REFUEL_FEE_DIESEL = 360; // for 4 liters private $security; protected $em; From dae8fe70516c96f43184b38a1f34482ec178a1f9 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Wed, 31 Aug 2022 04:57:27 +0000 Subject: [PATCH 23/23] Add credit card amex to mode of payment. #703 --- src/Ramcar/ModeOfPayment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Ramcar/ModeOfPayment.php b/src/Ramcar/ModeOfPayment.php index 1b522dde..139dd18c 100644 --- a/src/Ramcar/ModeOfPayment.php +++ b/src/Ramcar/ModeOfPayment.php @@ -9,6 +9,7 @@ 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', @@ -16,5 +17,6 @@ class ModeOfPayment extends NameValue 'debit_card' => 'Debit Card', 'installment' => 'Installment - BDO', 'gcash' => 'GCash', + 'credit_card_amex' => 'Credit Card - AMEX', ]; }