From ecf8f26d97167a111e2eef0d57c4402e176d8c3d Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 10 Mar 2021 15:37:59 +0800 Subject: [PATCH 01/43] Update FAQ for app #544 --- public/faq.html | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/faq.html b/public/faq.html index 2e0cdea3..d49a91c6 100644 --- a/public/faq.html +++ b/public/faq.html @@ -44,7 +44,7 @@

Can I request for any Res-Q service if I don't have or have a weak data signal?

-

Res-Q needs a stable data connection for you to be able to request for a service and track the location of our rider. If you don't have a stable data connection, you may call our hotline at (02) 370-6686. +

Res-Q needs a stable data connection for you to be able to request for a service and track the location of our rider. If you don't have a stable data connection, you may call our hotline at (02) 8370-6686.

@@ -58,7 +58,13 @@ Yes, we accept Visa and Mastercard issued in the Philippines. How can I pay for your services/ products?

-We accept COD, local Credit Cards, Debit Cards, and ATM Cards only. +We accept COD, local credit cards, debit cards, and ATM cards for battery replacement transactions. We only accept cash payment for flat tire, refuel and overheat transactions. +

+

+Credit Card and Debit Card Payment is for Battery Sales only. +

+

+Cash only for services request.

@@ -72,7 +78,7 @@ Once you have successfully submitted your request, you will be able to see the p How do I make a follow up for my order/service?

-Once your order/ service has been assigned to a Technician Rider, you may be able to see his/her contact details in the App. If no Technician Rider has been assigned yet, you may call our hotline at (02) 370-6686. +Once your order/ service has been assigned to a Technician Rider, you may be able to see his/her contact details in the App. If no Technician Rider has been assigned yet, you may call our hotline at (02) 8370-6686.

@@ -93,14 +99,14 @@ Delivery for battery purchase is free of charge. Can you deliver anywhere in the Philippines?

-Not yet. Res-Q is offered initially in Metro Manila only. +Not yet. Res-Q is offered Metro Manila, Baguio City and Binan, Laguna only.

My battery was pulled out and is being recharged in an outlet. How do I follow-up when I can take my battery back?

-Please call our hotline at (02) 370-6686. +Please call our hotline at (02) 8370-6686.

@@ -109,7 +115,7 @@ Please call our hotline at (02) 370-6686. How do I contact you for questions or feedback?

-You may call our Customer Support Hotline: 02-3706686 or email us at online@motolite.com. +You may call our Customer Support Hotline: 02-83706686 or email us at online@motolite.com.

From d84c1c42f1242e7664cdd5f8a3bc548df602a99f Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 12 Mar 2021 08:16:27 +0000 Subject: [PATCH 02/43] Add script to generate customer source report with input arguments year and month. #545 --- .../generateCurrentMonthCustomerSourceReport.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh diff --git a/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh b/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh new file mode 100755 index 00000000..79268c3a --- /dev/null +++ b/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/var/www/resq/bin/console report:customer_source $1 $2 /tmp/customer_source_report_$1$2.csv From e65f6ff5bfe38455ca33f77685371d71351e992c Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 12 Mar 2021 20:55:02 +0800 Subject: [PATCH 03/43] Make bash script for weekly reports #545 --- public/cust_reports/.gitkeep | 1 + .../generateCurrentMonthCustomerSourceReport.sh | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 public/cust_reports/.gitkeep diff --git a/public/cust_reports/.gitkeep b/public/cust_reports/.gitkeep new file mode 100644 index 00000000..8d1c8b69 --- /dev/null +++ b/public/cust_reports/.gitkeep @@ -0,0 +1 @@ + diff --git a/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh b/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh index 79268c3a..6ed86695 100755 --- a/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh +++ b/utils/current_customer_source_report/generateCurrentMonthCustomerSourceReport.sh @@ -1,3 +1,7 @@ #!/bin/sh -/var/www/resq/bin/console report:customer_source $1 $2 /tmp/customer_source_report_$1$2.csv +MONTH=`date +"%m"` +YEAR=`date +"%Y"` +FILE_DATE=`date +"%Y%m%d"` +FILE="/var/www/resq/public/cust_reports/cust_report_$FILE_DATE.csv" +/var/www/resq/bin/console report:customer_source $YEAR $MONTH $FILE From 25dfdf1bbcd3ac3601967d93cd5ddda384ac9674 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 14 Mar 2021 00:20:05 +0800 Subject: [PATCH 04/43] Handle file uploads for invoice and warranty card pics #540 --- public/.gitkeep | 0 src/Controller/APIController.php | 192 ++++++++++++++++++++----------- src/Entity/Warranty.php | 13 +++ 3 files changed, 140 insertions(+), 65 deletions(-) create mode 100644 public/.gitkeep diff --git a/public/.gitkeep b/public/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 94e9fb38..039dcc06 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -12,6 +12,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpKernel\KernelInterface; use CrEOF\Spatial\PHP\Types\Geometry\Point; @@ -2751,6 +2752,31 @@ class APIController extends Controller implements LoggedController return $res->getReturnResponse(); } + protected function checkCustomerPlateNumber($plate_number, $cust) + { + // strip spaces and make all caps + $plate_number = preg_replace('/\s+/', '', strtoupper($plate_number)); + + // if there's no customer linked to session + if ($cust != null) + { + // check all the customer vehicles + $cvs = $cust->getVehicles(); + foreach ($cvs as $cv) + { + $cv_plate = preg_replace('/\s+/', '', strtoupper($cv->getPlateNumber())); + + // did we find a match? + if ($cv_plate == $plate_number) + { + return true; + } + } + } + + return false; + } + public function warrantyCheck($serial, EntityManagerInterface $em, Request $req) { // check required parameters and api key @@ -2759,24 +2785,6 @@ class APIController extends Controller implements LoggedController if ($res->isError()) return $res->getReturnResponse(); - /* - // initialize data - $data = [ - 'is_valid' => false, - 'is_registered' => false, - 'customer' => [ - 'first_name' => '', - 'last_name' => '', - 'mobile_number' => '', - 'plate_number' => '', - ], - 'battery' => [ - 'brand' => '', - 'size' => '', - ], - ]; - */ - // check if warranty serial is there $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]); @@ -2790,29 +2798,39 @@ class APIController extends Controller implements LoggedController return $res->getReturnResponse(); } - // if warranty serial is there - if ($warr_serial != null) + // if we have a warranty entry for the serial already + if ($warr != null) { - // if we have a warranty entry for the serial already - if ($warr != null) + $warr_plate = $warr->getPlateNumber(); + $is_registered = true; + $is_customer_warranty = false; + + // TODO: check if the warranty is registered to a car owned by the customer + $cust = $this->session->getCustomer(); + + $is_customer_warranty = $this->checkCustomerPlateNumber($warr_plate, $cust); + + // null mobile number should be blank string instead + if ($warr->getMobileNumber() == null) + $mobile_num = ''; + else + $mobile_num = $warr->getMobileNumber(); + + $can_edit = $is_customer_warranty; + + // if customer plate number matches the one registered on the warranty + if ($is_customer_warranty) { - $is_registered = true; - - // null mobile number should be blank string instead - if ($warr->getMobileNumber() == null) - $mobile_num = ''; - else - $mobile_num = $warr->getMobileNumber(); - $customer = [ 'first_name' => $warr->getFirstName(), 'last_name' => $warr->getLastName(), 'mobile_number' => $mobile_num, - 'plate_number' => $warr->getPlateNumber(), + 'plate_number' => $warr_plate, ]; } else { + // hide customer information if customer is not the one registered $customer = [ 'first_name' => '', 'last_name' => '', @@ -2820,46 +2838,80 @@ class APIController extends Controller implements LoggedController 'plate_number' => '', ]; } - - $sku = $warr_serial->getSKU(); - $batt = $em->getRepository(SAPBattery::class)->find($sku); - // TODO: put this in a config file - $image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png'; - if ($batt != null) - { - $battery = [ - 'brand' => $batt->getBrand()->getName(), - 'size' => $batt->getSize()->getName(), - 'image_url' => $image_url, - ]; - } - else - { - $battery = [ - 'brand' => '', - 'size' => '', - 'image_url' => '', - ]; - } - - // populate data - $data = [ - 'is_valid' => true, - 'is_registered' => $is_registered, - 'customer' => $customer, - 'battery' => $battery, - 'message' => [ - 'register_error' => 'Warranty serial code has already been registered.', - ], + } + else + { + $can_edit = true; + $customer = [ + 'first_name' => '', + 'last_name' => '', + 'mobile_number' => '', + 'plate_number' => '', ]; } + $sku = $warr_serial->getSKU(); + $batt = $em->getRepository(SAPBattery::class)->find($sku); + // TODO: put this in a config file + $image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png'; + if ($batt != null) + { + $battery = [ + 'brand' => $batt->getBrand()->getName(), + 'size' => $batt->getSize()->getName(), + 'image_url' => $image_url, + ]; + } + else + { + $battery = [ + 'brand' => '', + 'size' => '', + 'image_url' => '', + ]; + } + + // populate data + $data = [ + 'is_valid' => true, + 'is_registered' => $is_registered, + 'can_edit' => $can_edit, + 'customer' => $customer, + 'battery' => $battery, + 'message' => [ + 'register_error' => 'Warranty serial code has already been registered.', + ], + ]; + $res->setData($data); return $res->getReturnResponse(); } - public function warrantyRegister($serial, EntityManagerInterface $em, Request $req) + protected function handlePictureUpload($file, $target_dir, $serial, $name) + { + // no file sent + if ($file == null) + return null; + + // create target dir if it doesn't exist + if (!file_exists($target_dir)) + { + if (!mkdir($target_dir, 0744, true)) + { + error_log('failed to create folder for warranty pictures'); + return null; + } + } + + // move file + $filename = $name . $file->getClientOriginalExtension(); + $file->move($target_dir . '/' . $serial, $filename); + + return $serial . '/' . $filename; + } + + public function warrantyRegister($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel) { // check required parameters and api key $required_params = [ @@ -2868,6 +2920,16 @@ class APIController extends Controller implements LoggedController 'email', 'plate_number', ]; + + // handle file uploads + $invoice = $req->files->get('invoice'); + $warr_card = $req->files->get('warr_card'); + + // process picture uploads + $upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads'; + $inv_filename = $this->warrantyRegister($invoice, $upload_dir, $serial, 'invoice'); + $wcard_filename = $this->warrantyRegister($warr_card, $upload_dir, $serial, 'wcard'); + $res = $this->checkParamsAndKey($req, $em, $required_params); if ($res->isError()) return $res->getReturnResponse(); @@ -2876,14 +2938,14 @@ class APIController extends Controller implements LoggedController $cust = $this->updateCustomerInfo($req, $em); // update warranty - $res = $this->updateWarranty($res, $em, $req, $serial); + $res = $this->updateWarranty($res, $em, $req, $serial, $inv_filename, $wcard_filename); $em->flush(); return $res->getReturnResponse(); } - protected function updateWarranty($res, $em, $req, $serial) + protected function updateWarranty($res, $em, $req, $serial, $inv_filename = null, $wcard_filename = null) { // get serial $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index 0f3f5c6c..26373b73 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -141,6 +141,19 @@ class Warranty */ protected $privacy_policy; + + // invoice picture + /** + * @ORM\Column(type="string", length=80) + */ + protected $file_invoice; + + // warranty card picture + /** + * @ORM\Column(type="string", length=80) + */ + protected $file_warr_card; + public function __construct() { $this->date_create = new DateTime(); From d79f3b8854ee6af4f5d4a7aaca14c058161e8df2 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 14 Mar 2021 00:21:15 +0800 Subject: [PATCH 05/43] Add warranty uploads folder to gitignore #540 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index bd8a680c..cf3b012e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ ###< symfony/framework-bundle ### *.swp +/public/warranty_uploads/* From 6a6b93e0876f3d2d054b72b7969dc574a143b974 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 14 Mar 2021 01:34:06 +0800 Subject: [PATCH 06/43] Handle file uploads properly #540 --- config/routes/customer.yaml | 2 +- src/Controller/APIController.php | 46 ++++++++++++++++++++++++++------ src/Entity/Warranty.php | 26 ++++++++++++++++-- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/config/routes/customer.yaml b/config/routes/customer.yaml index 90ac5591..9f952543 100644 --- a/config/routes/customer.yaml +++ b/config/routes/customer.yaml @@ -5,7 +5,7 @@ customer_list: customer_rows: path: /customers/rows controller: App\Controller\CustomerController::rows - methods: [POST] + methods: [GET,POST] customer_vehicle_search: path: /customers/vehicles diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 039dcc06..e6d8b7a4 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2805,9 +2805,8 @@ class APIController extends Controller implements LoggedController $is_registered = true; $is_customer_warranty = false; - // TODO: check if the warranty is registered to a car owned by the customer + // check if the warranty is registered to a car owned by the customer $cust = $this->session->getCustomer(); - $is_customer_warranty = $this->checkCustomerPlateNumber($warr_plate, $cust); // null mobile number should be blank string instead @@ -2880,6 +2879,7 @@ class APIController extends Controller implements LoggedController 'battery' => $battery, 'message' => [ 'register_error' => 'Warranty serial code has already been registered.', + 'edit_error' => 'Sorry, warranty is registered under another vehicle not in your list of vehicles.', ], ]; @@ -2890,9 +2890,13 @@ class APIController extends Controller implements LoggedController protected function handlePictureUpload($file, $target_dir, $serial, $name) { + error_log("handling $name upload"); // no file sent if ($file == null) + { + error_log('no file'); return null; + } // create target dir if it doesn't exist if (!file_exists($target_dir)) @@ -2904,10 +2908,15 @@ class APIController extends Controller implements LoggedController } } + error_log('HERE'); + // move file - $filename = $name . $file->getClientOriginalExtension(); + $filename = $name . '.' . $file->getClientOriginalExtension(); $file->move($target_dir . '/' . $serial, $filename); + error_log("filename - $filename"); + error_log($target_dir . '/' . $serial . '/' . $filename); + return $serial . '/' . $filename; } @@ -2927,8 +2936,8 @@ class APIController extends Controller implements LoggedController // process picture uploads $upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads'; - $inv_filename = $this->warrantyRegister($invoice, $upload_dir, $serial, 'invoice'); - $wcard_filename = $this->warrantyRegister($warr_card, $upload_dir, $serial, 'wcard'); + $inv_filename = $this->handlePictureUpload($invoice, $upload_dir, $serial, 'invoice'); + $wcard_filename = $this->handlePictureUpload($warr_card, $upload_dir, $serial, 'wcard'); $res = $this->checkParamsAndKey($req, $em, $required_params); if ($res->isError()) @@ -2962,9 +2971,29 @@ class APIController extends Controller implements LoggedController // skip warranty if it already exists if ($warr != null) { + /* + // NOTE: we could not update in the old version $res->setError(true) ->setErrorMessage('Warranty registration entry already exists.'); return $res; + */ + + // check if warranty is registered to a serial owned by customer + $warr_plate = $warr->getPlateNumber(); + $cust = $this->session->getCustomer(); + $is_customer_warranty = $this->checkCustomerPlateNumber($warr_plate, $cust); + + if (!$is_customer_warranty) + { + $res->setError(true) + ->setErrorMessage('Warranty registred to a vehicle not in your list of vehicles.'); + return $res; + } + + } + else + { + $warr = new Warranty(); } // get sap battery @@ -2980,8 +3009,7 @@ class APIController extends Controller implements LoggedController $date_pur = new DateTime(); - // create new warranty entry - $warr = new Warranty(); + // create or update warranty entry $warr->setSerial($serial) ->setFirstName($req->request->get('first_name')) ->setLastName($req->request->get('last_name')) @@ -2996,7 +3024,9 @@ class APIController extends Controller implements LoggedController // ->setBatteryModel() ->setSAPBattery($sap_bty) ->setMobileNumber(substr($this->session->getPhoneNumber(), 2)) - ->setActivated(true); + ->setActivated(true) + ->setFileInvoice($inv_filename) + ->setFileWarrantyCard($wcard_filename); // TODO: check for date purchase and date expire diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index 26373b73..25eafc6a 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -144,13 +144,13 @@ class Warranty // invoice picture /** - * @ORM\Column(type="string", length=80) + * @ORM\Column(type="string", length=80, nullable=true) */ protected $file_invoice; // warranty card picture /** - * @ORM\Column(type="string", length=80) + * @ORM\Column(type="string", length=80, nullable=true) */ protected $file_warr_card; @@ -425,4 +425,26 @@ class Warranty return $this->privacy_policy; } + public function setFileInvoice($file = null) + { + $this->file_invoice = $file; + return $this; + } + + public function getFileInvoice() + { + return $this->file_invoice; + } + + public function setFileWarrantyCard($file = null) + { + $this->file_warr_card = $file; + return $this; + } + + public function getFileWarrantyCard() + { + return $this->file_warr_card; + } + } From 59f06d7a5a1df96bd608ce06647d4afa44641d93 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 14 Mar 2021 20:06:07 +0800 Subject: [PATCH 07/43] Add odometer and date purchase (customer) to entity and api calls #540 --- src/Controller/APIController.php | 43 ++++++++++++++++++++++- src/Entity/Warranty.php | 58 ++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index e6d8b7a4..d51ad931 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2798,6 +2798,8 @@ class APIController extends Controller implements LoggedController return $res->getReturnResponse(); } + $today = new DateTime(); + // if we have a warranty entry for the serial already if ($warr != null) { @@ -2820,12 +2822,21 @@ class APIController extends Controller implements LoggedController // if customer plate number matches the one registered on the warranty if ($is_customer_warranty) { + if ($warr->getDatePurchaseCustomer() != null) + $date_purchase_cust = $warr->getDatePurchaseCustomer()->format('Y-m-d'); + else + $date_purchase_cust = $today->format('Y-m-d'); + $customer = [ 'first_name' => $warr->getFirstName(), 'last_name' => $warr->getLastName(), 'mobile_number' => $mobile_num, 'plate_number' => $warr_plate, ]; + $other_data = [ + 'odometer' => $warr->getOdometer(), + 'date_purchase' => $date_purchase_cust, + ]; } else { @@ -2836,6 +2847,10 @@ class APIController extends Controller implements LoggedController 'mobile_number' => '', 'plate_number' => '', ]; + $other_data = [ + 'odometer' => 0, + 'date_purchase' => $today->format('Y-m-d'), + ]; } } else @@ -2847,6 +2862,10 @@ class APIController extends Controller implements LoggedController 'mobile_number' => '', 'plate_number' => '', ]; + $other_data = [ + 'odometer' => 0, + 'date_purchase' => $today->format('Y-m-d'), + ]; } $sku = $warr_serial->getSKU(); @@ -2877,6 +2896,8 @@ class APIController extends Controller implements LoggedController 'can_edit' => $can_edit, 'customer' => $customer, 'battery' => $battery, + 'odometer' => $other_data['odometer'], + 'date_purchase' => $other_data['date_purchase'], 'message' => [ 'register_error' => 'Warranty serial code has already been registered.', 'edit_error' => 'Sorry, warranty is registered under another vehicle not in your list of vehicles.', @@ -2928,6 +2949,8 @@ class APIController extends Controller implements LoggedController 'last_name', 'email', 'plate_number', + 'odometer', + 'date_purchase', ]; // handle file uploads @@ -3006,8 +3029,19 @@ class APIController extends Controller implements LoggedController return $res; } + // default date purchase to today + // NOTE: might need to change this later $date_pur = new DateTime(); + // get date purchase specified by customer + $date_pur_cust = DateTime::createFromFormat('Y-m-d', $req->request->get('date_purchase')); + if (!$date_pur_cust) + { + $res->setError(true) + ->setErrorMessage('Invalid date format for date of purchase.'); + return $res; + } + // create or update warranty entry $warr->setSerial($serial) @@ -3025,8 +3059,15 @@ class APIController extends Controller implements LoggedController ->setSAPBattery($sap_bty) ->setMobileNumber(substr($this->session->getPhoneNumber(), 2)) ->setActivated(true) + + // files ->setFileInvoice($inv_filename) - ->setFileWarrantyCard($wcard_filename); + ->setFileWarrantyCard($wcard_filename) + + // new fields + ->setOdometer($req->request->get('odometer', 0)) + ->setDatePurchaseCustomer($date_pur_cust) + ->setValidated(false); // TODO: check for date purchase and date expire diff --git a/src/Entity/Warranty.php b/src/Entity/Warranty.php index 25eafc6a..a8da644b 100644 --- a/src/Entity/Warranty.php +++ b/src/Entity/Warranty.php @@ -142,6 +142,9 @@ class Warranty protected $privacy_policy; + // NOTE: the following were added later on, so they should all be nullable or have defaults, + // otherwise we get issues + // invoice picture /** * @ORM\Column(type="string", length=80, nullable=true) @@ -154,6 +157,26 @@ class Warranty */ protected $file_warr_card; + // odometer reading + /** + * @ORM\Column(type="integer", nullable=true) + */ + protected $odometer; + + // date purchase as specified by customer + // TODO: currently this does not affect warranty, someone will have to view this and set + // actual purchase date + /** + * @ORM\Column(type="date", nullable=true) + */ + protected $date_purchase_cust; + + // if the warranty has been validated by an agent + /** + * @ORM\Column(type="boolean", options={"default": false}) + */ + protected $flag_validated; + public function __construct() { $this->date_create = new DateTime(); @@ -162,6 +185,8 @@ class Warranty $this->date_claim = null; $this->flag_activated = false; $this->email = ''; + $this->odometer = 0; + $this->flag_validated = false; } public function getID() @@ -447,4 +472,37 @@ class Warranty return $this->file_warr_card; } + public function setOdometer($odometer) + { + $this->odometer = $odometer; + return $this; + } + + public function getOdometer() + { + return $this->odometer; + } + + public function setDatePurchaseCustomer($date) + { + $this->date_purchase_cust = $date; + return $this; + } + + public function getDatePurchaseCustomer() + { + return $this->date_purchase_cust; + } + + public function setValidated($bool = true) + { + $this->flag_validated = $bool; + return $this; + } + + public function isValidated() + { + return $this->flag_validated; + } + } From 7e7c93ce55446e447d96387ff2e2f3df3026ade8 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 14 Mar 2021 23:45:51 +0800 Subject: [PATCH 08/43] Add email, invoice and warranty card to warranty check api call #540 --- src/Controller/APIController.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index d51ad931..a5cf6691 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2822,20 +2822,37 @@ class APIController extends Controller implements LoggedController // if customer plate number matches the one registered on the warranty if ($is_customer_warranty) { + // purchase date of customer if ($warr->getDatePurchaseCustomer() != null) $date_purchase_cust = $warr->getDatePurchaseCustomer()->format('Y-m-d'); else $date_purchase_cust = $today->format('Y-m-d'); + + // invoice + if ($warr->getFileInvoice() != null) + $invoice_url = $req->getSchemeAndHttpHost() . '/warranty_uploads/' . $warr->getFileInvoice(); + else + $invoice_url = ''; + + // warranty card + if ($warr->getFileWarrantyCard() != null) + $warr_card_url = $req->getSchemeAndHttpHost() . '/warranty_uploads/' . $warr->getFileWarrantyCard(); + else + $warr_card_url = ''; + $customer = [ 'first_name' => $warr->getFirstName(), 'last_name' => $warr->getLastName(), 'mobile_number' => $mobile_num, 'plate_number' => $warr_plate, + 'email' => $warr->getEmail(), ]; $other_data = [ 'odometer' => $warr->getOdometer(), 'date_purchase' => $date_purchase_cust, + 'invoice' => $invoice_url, + 'warr_card' => $warr_card_url, ]; } else @@ -2846,10 +2863,13 @@ class APIController extends Controller implements LoggedController 'last_name' => '', 'mobile_number' => '', 'plate_number' => '', + 'email' => '', ]; $other_data = [ 'odometer' => 0, 'date_purchase' => $today->format('Y-m-d'), + 'invoice' => '', + 'warr_card' => '', ]; } } @@ -2861,10 +2881,13 @@ class APIController extends Controller implements LoggedController 'last_name' => '', 'mobile_number' => '', 'plate_number' => '', + 'email' => '', ]; $other_data = [ 'odometer' => 0, 'date_purchase' => $today->format('Y-m-d'), + 'invoice' => '', + 'warr_card' => '', ]; } @@ -2897,6 +2920,8 @@ class APIController extends Controller implements LoggedController 'customer' => $customer, 'battery' => $battery, 'odometer' => $other_data['odometer'], + 'invoice' => $other_data['invoice'], + 'warr_card' => $other_data['warr_card'], 'date_purchase' => $other_data['date_purchase'], 'message' => [ 'register_error' => 'Warranty serial code has already been registered.', From 9f00d8ded755b063ba8903d27cead3d700909ec5 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 17 Mar 2021 00:09:51 +0800 Subject: [PATCH 09/43] Add controller and routes for capi customer warranty #540 --- config/routes/capi.yaml | 6 + .../CAPI/CustomerWarrantyController.php | 208 ++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 src/Controller/CAPI/CustomerWarrantyController.php diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index 0c2e5ac1..243f0c39 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -149,3 +149,9 @@ capi_customer_register: path: /capi/quick_registration controller: App\Controller\CAPI\CustomerController::register methods: [POST] + +# customer warranty api +capi_cwarr_check: + path: /capi/customer_warranty/{serial} + controller: App\Controller\CAPI\CustomerWarrantyController::check + methods: [GET] diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php new file mode 100644 index 00000000..fcc5e675 --- /dev/null +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -0,0 +1,208 @@ +acl_gen = $acl_gen; + } + + protected function checkMissingParameters(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') + { + $check = $req->request->get($param); + if (empty($check)) + $missing[] = $param; + } + else + return $params; + } + + return $missing; + } + + protected function checkRequiredParams(Request $req, $params) + { + // check required parameters + $missing = $this->checkMissingParameters($req, $params); + if (count($missing) > 0) + { + $miss_string = implode(', ', $missing); + return new APIResponse(false, 'Missing parameter(s): ' . $miss_string); + } + + return true; + } + + protected function cleanSerial($serial) + { + return trim(strtoupper($serial)); + } + + public function check($serial, EntityManagerInterface $em, Request $req) + { + // check required parameters + $required_params = []; + $res = $this->checkRequiredParams($req, $required_params); + if (!$res) + return $res; + + // check if warranty serial is there + $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); + $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]); + $batt = null; + $is_registered = false; + + if ($warr_serial == null) + { + return new APIResponse(false, 'Invalid warranty serial code.'); + } + + $today = new DateTime(); + + // if we have a warranty entry for the serial already + if ($warr != null) + { + $warr_plate = $warr->getPlateNumber(); + $is_registered = true; + + // null mobile number should be blank string instead + if ($warr->getMobileNumber() == null) + $mobile_num = ''; + else + $mobile_num = $warr->getMobileNumber(); + + // purchase date of customer + if ($warr->getDatePurchaseCustomer() != null) + $date_purchase_cust = $warr->getDatePurchaseCustomer()->format('Y-m-d'); + else + $date_purchase_cust = $today->format('Y-m-d'); + + + // invoice + if ($warr->getFileInvoice() != null) + $invoice_url = $req->getSchemeAndHttpHost() . '/warranty_uploads/' . $warr->getFileInvoice(); + else + $invoice_url = ''; + + // warranty card + if ($warr->getFileWarrantyCard() != null) + $warr_card_url = $req->getSchemeAndHttpHost() . '/warranty_uploads/' . $warr->getFileWarrantyCard(); + else + $warr_card_url = ''; + + $customer = [ + 'first_name' => $warr->getFirstName(), + 'last_name' => $warr->getLastName(), + 'mobile_number' => $mobile_num, + 'plate_number' => $warr_plate, + 'email' => $warr->getEmail(), + ]; + $other_data = [ + 'odometer' => $warr->getOdometer(), + 'date_purchase' => $date_purchase_cust, + 'invoice' => $invoice_url, + 'warr_card' => $warr_card_url, + ]; + } + else + { + $customer = [ + 'first_name' => '', + 'last_name' => '', + 'mobile_number' => '', + 'plate_number' => '', + 'email' => '', + ]; + $other_data = [ + 'odometer' => 0, + 'date_purchase' => $today->format('Y-m-d'), + 'invoice' => '', + 'warr_card' => '', + ]; + } + + $sku = $warr_serial->getSKU(); + $batt = $em->getRepository(SAPBattery::class)->find($sku); + // TODO: put this in a config file + $image_url = $req->getSchemeAndHttpHost() . '/battery/generic.png'; + if ($batt != null) + { + $battery = [ + 'brand' => $batt->getBrand()->getName(), + 'size' => $batt->getSize()->getName(), + 'image_url' => $image_url, + ]; + } + else + { + $battery = [ + 'brand' => '', + 'size' => '', + 'image_url' => '', + ]; + } + + // populate data + $data = [ + 'is_valid' => true, + 'is_registered' => $is_registered, + 'customer' => $customer, + 'battery' => $battery, + 'odometer' => $other_data['odometer'], + 'invoice' => $other_data['invoice'], + 'warr_card' => $other_data['warr_card'], + 'date_purchase' => $other_data['date_purchase'], + ]; + + return new APIResponse(true, 'Warranty found.', $data); + } + +} From f08d7e03aa85d00aedeb6a86eb1d813baef9e921 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Wed, 17 Mar 2021 02:19:10 +0800 Subject: [PATCH 10/43] Add support for warranty registration via capi #540 --- config/routes/capi.yaml | 6 ++ src/Controller/APIController.php | 4 +- .../CAPI/CustomerWarrantyController.php | 81 +++++++++++++++++++ 3 files changed, 88 insertions(+), 3 deletions(-) diff --git a/config/routes/capi.yaml b/config/routes/capi.yaml index 243f0c39..485c97de 100644 --- a/config/routes/capi.yaml +++ b/config/routes/capi.yaml @@ -155,3 +155,9 @@ capi_cwarr_check: path: /capi/customer_warranty/{serial} controller: App\Controller\CAPI\CustomerWarrantyController::check methods: [GET] + +capi_cwarr_register: + path: /capi/customer_warranty/{serial} + controller: App\Controller\CAPI\CustomerWarrantyController::register + methods: [POST] + diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index a5cf6691..b93e5e36 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -2954,8 +2954,6 @@ class APIController extends Controller implements LoggedController } } - error_log('HERE'); - // move file $filename = $name . '.' . $file->getClientOriginalExtension(); $file->move($target_dir . '/' . $serial, $filename); @@ -2992,7 +2990,7 @@ class APIController extends Controller implements LoggedController return $res->getReturnResponse(); // update customer information - $cust = $this->updateCustomerInfo($req, $em); + // $cust = $this->updateCustomerInfo($req, $em); // update warranty $res = $this->updateWarranty($res, $em, $req, $serial, $inv_filename, $wcard_filename); diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index fcc5e675..428fa86c 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -205,4 +205,85 @@ class CustomerWarrantyController extends APIController return new APIResponse(true, 'Warranty found.', $data); } + + public function register($serial, EntityManagerInterface $em, Request $req) + { + // check required parameters + $required_params = [ + 'first_name', + 'last_name', + 'plate_num' + ]; + $res = $this->checkRequiredParams($req, $required_params); + if (!$res) + return $res; + + + $first_name = $req->request->get('first_name'); + $last_name = $req->request->get('last_name'); + $email = $req->request->get('email'); + $plate_num = $req->request->get('plate_num'); + $odometer = $req->request->get('odometer'); + $date_purchase = $req->request->get('date_purchase'); + + // file uploads + $invoice = $req->files->get('invoice'); + $warr_card = $req->files->get('warr_card'); + + // process picture uploads + $upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads'; + $inv_filename = $this->handlePictureUpload($invoice, $upload_dir, $serial, 'invoice'); + $wcard_filename = $this->handlePictureUpload($warr_card, $upload_dir, $serial, 'wcard'); + + + $data = [ + 'first_name' => $first_name, + 'last_name' => $last_name, + 'email' => $email, + 'plate_num' => $plate_num, + 'odometer' => $odometer, + 'date_purchase' => $date_purchase, + ]; + + error_log(print_r($data, true)); + + // do actual registering + + + $data = []; + + return new APIResponse(true, 'Warranty registered.', $data); + } + + // TODO: move this to a service, since it's shared by all warranty updaters + protected function handlePictureUpload($file, $target_dir, $serial, $name) + { + error_log("handling $name upload"); + // no file sent + if ($file == null) + { + error_log('no file'); + return null; + } + + // create target dir if it doesn't exist + if (!file_exists($target_dir)) + { + if (!mkdir($target_dir, 0744, true)) + { + error_log('failed to create folder for warranty pictures'); + return null; + } + } + + // move file + $filename = $name . '.' . $file->getClientOriginalExtension(); + $file->move($target_dir . '/' . $serial, $filename); + + error_log("filename - $filename"); + error_log($target_dir . '/' . $serial . '/' . $filename); + + return $serial . '/' . $filename; + } + } From 1fdd935b7f4398583d2727cb2b226aed6d3556ee Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 03:25:49 +0000 Subject: [PATCH 11/43] Add Trade-in Lazada field for battery size. #546 --- src/Controller/BatterySizeController.php | 3 ++- src/Entity/BatterySize.php | 19 +++++++++++++++++++ templates/battery-size/form.html.twig | 11 ++++++++++- translations/messages.en.yaml | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Controller/BatterySizeController.php b/src/Controller/BatterySizeController.php index 5dc2906a..177780e8 100644 --- a/src/Controller/BatterySizeController.php +++ b/src/Controller/BatterySizeController.php @@ -129,7 +129,8 @@ class BatterySizeController extends Controller $obj->setName($req->request->get('name')) ->setTIPriceMotolite($req->request->get('tip_motolite')) ->setTIPricePremium($req->request->get('tip_premium')) - ->setTIPriceOther($req->request->get('tip_other')); + ->setTIPriceOther($req->request->get('tip_other')) + ->setTIPriceLazada($req->request->get('tip_lazada')); } public function addSubmit(Request $req, ValidatorInterface $validator) diff --git a/src/Entity/BatterySize.php b/src/Entity/BatterySize.php index 9fff4d44..8b47d6af 100644 --- a/src/Entity/BatterySize.php +++ b/src/Entity/BatterySize.php @@ -51,12 +51,19 @@ class BatterySize */ protected $tip_other; + // lazada trade-in price + /** + * @ORM\Column(type="decimal", precision=7, scale=2) + */ + protected $tip_lazada; + public function __construct() { $this->batteries = new ArrayCollection(); $this->tip_motolite = 0; $this->tip_premium = 0; $this->tip_other = 0; + $this->tip_lazada = 0; } public function getID() @@ -130,4 +137,16 @@ class BatterySize { return $this->tip_other; } + + public function setTIPriceLazada($price) + { + $this->tip_lazada = $price; + return $this; + } + + public function getTIPriceLazada() + { + return $this->tip_lazada; + } + } diff --git a/templates/battery-size/form.html.twig b/templates/battery-size/form.html.twig index 1af1f342..06d3fadd 100644 --- a/templates/battery-size/form.html.twig +++ b/templates/battery-size/form.html.twig @@ -70,7 +70,16 @@ - + +
+ +
+ + +
+
diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index c0fb8ca1..e9f077a3 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -8,6 +8,7 @@ copyright: Motolite Res-Q battery_size_tradein_brand: Trade-in Motolite battery_size_tradein_premium: Trade-in Premium battery_size_tradein_other: Trade-in Other +battery_size_tradein_lazada: Trade-in Lazada add_cust_vehicle_battery_info: This vehicle is using a Motolite battery jo_title_pdf: Motolite Res-Q Job Order country_code_prefix: '+63' From d0eade30126cd812938207b3abd83b2402981d64 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 03:54:34 +0000 Subject: [PATCH 12/43] Add inventory flag to SAP battery. #546 --- src/Controller/SAPBatteryController.php | 10 ++++++++-- src/Entity/SAPBattery.php | 17 +++++++++++++++++ templates/sap-battery/form.html.twig | 16 +++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/Controller/SAPBatteryController.php b/src/Controller/SAPBatteryController.php index 099c1998..a06f4ef9 100644 --- a/src/Controller/SAPBatteryController.php +++ b/src/Controller/SAPBatteryController.php @@ -171,9 +171,12 @@ class SAPBatteryController extends Controller $error_array['id'] = 'SAP code is required.'; $flag_new = $req->request->get('flag_new', false); + $flag_inventory = $req->request->get('flag_inventory', false); + // set and save values $row->setID($id) - ->setNew($flag_new); + ->setNew($flag_new) + ->setInventory($flag_inventory); // custom validation for battery brand $brand = $em->getRepository(SAPBatteryBrand::class) @@ -277,9 +280,12 @@ class SAPBatteryController extends Controller $error_array['id'] = 'SAP code is required.'; $flag_new = $req->request->get('flag_new', false); + $flag_inventory = $req->request->get('flag_inventory', false); + // set and save values $row->setID($id) - ->setNew($flag_new); + ->setNew($flag_new) + ->setInventory($flag_inventory); // custom validation for battery brand $brand = $em->getRepository(SAPBatteryBrand::class) diff --git a/src/Entity/SAPBattery.php b/src/Entity/SAPBattery.php index 284e2e32..df4303d4 100644 --- a/src/Entity/SAPBattery.php +++ b/src/Entity/SAPBattery.php @@ -58,10 +58,17 @@ class SAPBattery */ protected $container_size; + // flag to indicate if this SAP battery is inventory or non-inventory + /** + * @ORM\Column(type="boolean") + */ + protected $flag_inventory; + public function __construct() { $this->date_create = new DateTime(); $this->flag_new = false; + $this->flag_inventory = false; } public function setID($id) @@ -129,4 +136,14 @@ class SAPBattery return $this->container_size; } + public function setInventory($inventory = false) + { + $this->flag_inventory = $inventory; + return $this; + } + + public function isInventory() + { + return $this->flag_inventory; + } } diff --git a/templates/sap-battery/form.html.twig b/templates/sap-battery/form.html.twig index 84e12d85..6e21086f 100644 --- a/templates/sap-battery/form.html.twig +++ b/templates/sap-battery/form.html.twig @@ -86,15 +86,25 @@
+
+ + + + +
- +
From c0ef8be34c84c4725edb92ee306d985ea027c1b5 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 06:02:56 +0000 Subject: [PATCH 13/43] Add Marketing Research checkbox under Marketing Promo for Customer. #546 --- src/Entity/Customer.php | 17 +++++++++++++++++ .../CustomerHandler/ResqCustomerHandler.php | 4 +++- templates/customer/form.html.twig | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 281c9fa9..f99df0d5 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -192,6 +192,11 @@ class Customer */ protected $date_create; + /** + * @ORM\Column(type="boolean", options={"default":false}) + */ + protected $flag_promo_marketing_research; + public function __construct() { $this->numbers = new ArrayCollection(); @@ -222,6 +227,7 @@ class Customer $this->flag_promo_email = false; $this->flag_promo_sms = false; $this->flag_dpa_consent = false; + $this->flag_promo_marketing_research = false; $this->date_create = new DateTime(); } @@ -555,4 +561,15 @@ class Customer { return $this->flag_dpa_consent; } + + public function setPromoMarketingResearch($flag_promo_marketing_research = true) + { + $this->flag_promo_marketing_research = $flag_promo_marketing_research; + return $this; + } + + public function isPromoMarketingResearch() + { + return $this->flag_promo_marketing_research; + } } diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index 5f3653dd..cf2a71d7 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -539,6 +539,7 @@ class ResqCustomerHandler implements CustomerHandlerInterface 'flag_dpa_consent' => $customer->isDpaConsent(), 'flag_promo_sms' => $customer->isPromoSms(), 'flag_promo_email' => $customer->isPromoEmail(), + 'flag_promo_marketing_research' => $customer->isPromoMarketingResearch(), ], 'vehicle' => [ 'id' => $vehicle->getID(), @@ -599,7 +600,8 @@ class ResqCustomerHandler implements CustomerHandlerInterface ->setActive($req->request->get('flag_active') ? true : false) ->setPromoSms($req->request->get('flag_promo_sms', false)) ->setPromoEmail($req->request->get('flag_promo_email', false)) - ->setDpaConsent($is_dpa_checked); + ->setDpaConsent($is_dpa_checked) + ->setPromoMarketingResearch($req->request->get('flag_promo_marketing_research', false)); // phone numbers $obj->setPhoneMobile($req->request->get('phone_mobile')) diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 97b80884..26b350e0 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -119,6 +119,12 @@ + From a879e94615719dd4d56dafd6bb2fd070f4add8d6 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 07:24:58 +0000 Subject: [PATCH 14/43] Update answers in FAQ. #546 --- public/static/faq.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/static/faq.html b/public/static/faq.html index 2e0cdea3..42b4110d 100644 --- a/public/static/faq.html +++ b/public/static/faq.html @@ -58,7 +58,7 @@ Yes, we accept Visa and Mastercard issued in the Philippines. How can I pay for your services/ products?

-We accept COD, local Credit Cards, Debit Cards, and ATM Cards only. +We accept COD, local credit cards, debit cards, and ATM cards for battery replacement transactions. We only accept cash payment for flat tire, refuel and overheat transactions.

@@ -93,7 +93,7 @@ Delivery for battery purchase is free of charge. Can you deliver anywhere in the Philippines?

-Not yet. Res-Q is offered initially in Metro Manila only. +Not yet. Res-Q is offered Metro Manila, Baguio City and Binan, Laguna only.

From ae9d32d434c96f0ab36a222bb54a0be2dbb7550a Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Thu, 18 Mar 2021 23:11:56 +0800 Subject: [PATCH 15/43] Add register functionality #540 --- .../CAPI/CustomerWarrantyController.php | 116 +++++++++++++++++- 1 file changed, 113 insertions(+), 3 deletions(-) diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index 428fa86c..29095240 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -4,12 +4,14 @@ namespace App\Controller\CAPI; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpKernel\KernelInterface; use Doctrine\ORM\Query; use Doctrine\ORM\EntityManagerInterface; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Catalyst\APIBundle\Controller\APIController; use Catalyst\APIBundle\Response\APIResponse; + use App\Entity\WarrantySerial; use App\Entity\Warranty; use App\Entity\BatteryModel; @@ -94,6 +96,8 @@ class CustomerWarrantyController extends APIController if (!$res) return $res; + error_log('check warranty serial'); + // check if warranty serial is there $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]); @@ -110,6 +114,8 @@ class CustomerWarrantyController extends APIController // if we have a warranty entry for the serial already if ($warr != null) { + error_log('already have warranty.'); + $warr_plate = $warr->getPlateNumber(); $is_registered = true; @@ -206,8 +212,9 @@ class CustomerWarrantyController extends APIController } - public function register($serial, EntityManagerInterface $em, Request $req) + public function register($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel) { + error_log('HERE - register'); // check required parameters $required_params = [ 'first_name', @@ -230,6 +237,7 @@ class CustomerWarrantyController extends APIController $invoice = $req->files->get('invoice'); $warr_card = $req->files->get('warr_card'); + error_log('handling file uploads'); // process picture uploads $upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads'; $inv_filename = $this->handlePictureUpload($invoice, $upload_dir, $serial, 'invoice'); @@ -247,12 +255,19 @@ class CustomerWarrantyController extends APIController error_log(print_r($data, true)); + error_log('updating warranty'); + // do actual registering + $res = $this->updateWarranty($em, $req, $serial, $inv_filename, $wcard_filename); + // flush to db + $em->flush(); - $data = []; + return $res; - return new APIResponse(true, 'Warranty registered.', $data); + error_log('after updating warranty'); + + return new APIResponse(true, 'Warranty registered.'); } // TODO: move this to a service, since it's shared by all warranty updaters @@ -286,4 +301,99 @@ class CustomerWarrantyController extends APIController return $serial . '/' . $filename; } + protected function updateWarranty($em, $req, $serial, $inv_filename = null, $wcard_filename = null) + { + error_log('warranty serial check'); + // get serial + $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); + if ($warr_serial == null) + { + return new APIResponse(false, 'Invalid warranty serial code.'); + } + + // check if warranty exists already + $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]); + + // skip warranty if it already exists + if ($warr != null) + { + return new APIResponse(false, 'Warranty registred to a vehicle not in your list of vehicles.'); + + /* + // check if warranty is registered to a serial owned by customer + $warr_plate = $warr->getPlateNumber(); + $cust = $this->session->getCustomer(); + $is_customer_warranty = $this->checkCustomerPlateNumber($warr_plate, $cust); + + if (!$is_customer_warranty) + { + return new APIResponse(false, 'Warranty registred to a vehicle not in your list of vehicles.'); + } + */ + + } + else + { + $warr = new Warranty(); + } + + error_log('sap battery check'); + // get sap battery + $sku = $warr_serial->getSKU(); + $sap_bty = $em->getRepository(SAPBattery::class)->find($sku); + if ($sap_bty == null) + { + return new APIResponse(false, 'Could not find battery entry for warranty.'); + } + + error_log('date check'); + // default date purchase to today + // NOTE: might need to change this later + $date_pur = new DateTime(); + + // get date purchase specified by customer + $date_pur_cust = DateTime::createFromFormat('Y-m-d', $req->request->get('date_purchase')); + if (!$date_pur_cust) + { + return new APIResponse(false, 'Invalid date format for date of purchase.'); + } + + + error_log('update entity / database'); + // 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_num')) + // TODO: figure out how to compute date of purchase + ->setDatePurchase($date_pur) + // TODO: set status + // ->setStatus() + // TODO: set battery model and size id + // ->setBatterySize() + // ->setBatteryModel() + ->setSAPBattery($sap_bty) + // ->setMobileNumber(substr($this->session->getPhoneNumber(), 2)) + ->setActivated(true) + + // files + ->setFileInvoice($inv_filename) + ->setFileWarrantyCard($wcard_filename) + + // new fields + ->setOdometer($req->request->get('odometer', 0)) + ->setDatePurchaseCustomer($date_pur_cust) + ->setValidated(false); + + // TODO: check for date purchase and date expire + + $em->persist($warr); + + // TODO: check if we need to do anyting else + $data = []; + + return new APIResponse(true, 'Warranty registered.', $data); + } + } From d4541a5fce075019b46032166fa483d00a2dece4 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 03:25:49 +0000 Subject: [PATCH 16/43] Add Trade-in Lazada field for battery size. #546 --- src/Controller/BatterySizeController.php | 3 ++- src/Entity/BatterySize.php | 19 +++++++++++++++++++ templates/battery-size/form.html.twig | 11 ++++++++++- translations/messages.en.yaml | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Controller/BatterySizeController.php b/src/Controller/BatterySizeController.php index 5dc2906a..177780e8 100644 --- a/src/Controller/BatterySizeController.php +++ b/src/Controller/BatterySizeController.php @@ -129,7 +129,8 @@ class BatterySizeController extends Controller $obj->setName($req->request->get('name')) ->setTIPriceMotolite($req->request->get('tip_motolite')) ->setTIPricePremium($req->request->get('tip_premium')) - ->setTIPriceOther($req->request->get('tip_other')); + ->setTIPriceOther($req->request->get('tip_other')) + ->setTIPriceLazada($req->request->get('tip_lazada')); } public function addSubmit(Request $req, ValidatorInterface $validator) diff --git a/src/Entity/BatterySize.php b/src/Entity/BatterySize.php index 9fff4d44..8b47d6af 100644 --- a/src/Entity/BatterySize.php +++ b/src/Entity/BatterySize.php @@ -51,12 +51,19 @@ class BatterySize */ protected $tip_other; + // lazada trade-in price + /** + * @ORM\Column(type="decimal", precision=7, scale=2) + */ + protected $tip_lazada; + public function __construct() { $this->batteries = new ArrayCollection(); $this->tip_motolite = 0; $this->tip_premium = 0; $this->tip_other = 0; + $this->tip_lazada = 0; } public function getID() @@ -130,4 +137,16 @@ class BatterySize { return $this->tip_other; } + + public function setTIPriceLazada($price) + { + $this->tip_lazada = $price; + return $this; + } + + public function getTIPriceLazada() + { + return $this->tip_lazada; + } + } diff --git a/templates/battery-size/form.html.twig b/templates/battery-size/form.html.twig index 1af1f342..06d3fadd 100644 --- a/templates/battery-size/form.html.twig +++ b/templates/battery-size/form.html.twig @@ -70,7 +70,16 @@ - + +
+ +
+ + +
+
diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index c0fb8ca1..e9f077a3 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -8,6 +8,7 @@ copyright: Motolite Res-Q battery_size_tradein_brand: Trade-in Motolite battery_size_tradein_premium: Trade-in Premium battery_size_tradein_other: Trade-in Other +battery_size_tradein_lazada: Trade-in Lazada add_cust_vehicle_battery_info: This vehicle is using a Motolite battery jo_title_pdf: Motolite Res-Q Job Order country_code_prefix: '+63' From 5b5d12cf42e64e8a41d94c7b67e677a1e50a01ed Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 03:54:34 +0000 Subject: [PATCH 17/43] Add inventory flag to SAP battery. #546 --- src/Controller/SAPBatteryController.php | 10 ++++++++-- src/Entity/SAPBattery.php | 17 +++++++++++++++++ templates/sap-battery/form.html.twig | 16 +++++++++++++--- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/Controller/SAPBatteryController.php b/src/Controller/SAPBatteryController.php index 099c1998..a06f4ef9 100644 --- a/src/Controller/SAPBatteryController.php +++ b/src/Controller/SAPBatteryController.php @@ -171,9 +171,12 @@ class SAPBatteryController extends Controller $error_array['id'] = 'SAP code is required.'; $flag_new = $req->request->get('flag_new', false); + $flag_inventory = $req->request->get('flag_inventory', false); + // set and save values $row->setID($id) - ->setNew($flag_new); + ->setNew($flag_new) + ->setInventory($flag_inventory); // custom validation for battery brand $brand = $em->getRepository(SAPBatteryBrand::class) @@ -277,9 +280,12 @@ class SAPBatteryController extends Controller $error_array['id'] = 'SAP code is required.'; $flag_new = $req->request->get('flag_new', false); + $flag_inventory = $req->request->get('flag_inventory', false); + // set and save values $row->setID($id) - ->setNew($flag_new); + ->setNew($flag_new) + ->setInventory($flag_inventory); // custom validation for battery brand $brand = $em->getRepository(SAPBatteryBrand::class) diff --git a/src/Entity/SAPBattery.php b/src/Entity/SAPBattery.php index 284e2e32..df4303d4 100644 --- a/src/Entity/SAPBattery.php +++ b/src/Entity/SAPBattery.php @@ -58,10 +58,17 @@ class SAPBattery */ protected $container_size; + // flag to indicate if this SAP battery is inventory or non-inventory + /** + * @ORM\Column(type="boolean") + */ + protected $flag_inventory; + public function __construct() { $this->date_create = new DateTime(); $this->flag_new = false; + $this->flag_inventory = false; } public function setID($id) @@ -129,4 +136,14 @@ class SAPBattery return $this->container_size; } + public function setInventory($inventory = false) + { + $this->flag_inventory = $inventory; + return $this; + } + + public function isInventory() + { + return $this->flag_inventory; + } } diff --git a/templates/sap-battery/form.html.twig b/templates/sap-battery/form.html.twig index 84e12d85..6e21086f 100644 --- a/templates/sap-battery/form.html.twig +++ b/templates/sap-battery/form.html.twig @@ -86,15 +86,25 @@
+
+ + + + +
- +
From 0103aadcc36285c064ce13456ea8809c5b7b40af Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 06:02:56 +0000 Subject: [PATCH 18/43] Add Marketing Research checkbox under Marketing Promo for Customer. #546 --- src/Entity/Customer.php | 17 +++++++++++++++++ .../CustomerHandler/ResqCustomerHandler.php | 4 +++- templates/customer/form.html.twig | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index 281c9fa9..f99df0d5 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -192,6 +192,11 @@ class Customer */ protected $date_create; + /** + * @ORM\Column(type="boolean", options={"default":false}) + */ + protected $flag_promo_marketing_research; + public function __construct() { $this->numbers = new ArrayCollection(); @@ -222,6 +227,7 @@ class Customer $this->flag_promo_email = false; $this->flag_promo_sms = false; $this->flag_dpa_consent = false; + $this->flag_promo_marketing_research = false; $this->date_create = new DateTime(); } @@ -555,4 +561,15 @@ class Customer { return $this->flag_dpa_consent; } + + public function setPromoMarketingResearch($flag_promo_marketing_research = true) + { + $this->flag_promo_marketing_research = $flag_promo_marketing_research; + return $this; + } + + public function isPromoMarketingResearch() + { + return $this->flag_promo_marketing_research; + } } diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index 5f3653dd..cf2a71d7 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -539,6 +539,7 @@ class ResqCustomerHandler implements CustomerHandlerInterface 'flag_dpa_consent' => $customer->isDpaConsent(), 'flag_promo_sms' => $customer->isPromoSms(), 'flag_promo_email' => $customer->isPromoEmail(), + 'flag_promo_marketing_research' => $customer->isPromoMarketingResearch(), ], 'vehicle' => [ 'id' => $vehicle->getID(), @@ -599,7 +600,8 @@ class ResqCustomerHandler implements CustomerHandlerInterface ->setActive($req->request->get('flag_active') ? true : false) ->setPromoSms($req->request->get('flag_promo_sms', false)) ->setPromoEmail($req->request->get('flag_promo_email', false)) - ->setDpaConsent($is_dpa_checked); + ->setDpaConsent($is_dpa_checked) + ->setPromoMarketingResearch($req->request->get('flag_promo_marketing_research', false)); // phone numbers $obj->setPhoneMobile($req->request->get('phone_mobile')) diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 97b80884..26b350e0 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -119,6 +119,12 @@ + From b2fcec5462bda127cd5731eac293150c7f36cdb5 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Mar 2021 07:24:58 +0000 Subject: [PATCH 19/43] Update answers in FAQ. #546 --- public/static/faq.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/static/faq.html b/public/static/faq.html index 2e0cdea3..42b4110d 100644 --- a/public/static/faq.html +++ b/public/static/faq.html @@ -58,7 +58,7 @@ Yes, we accept Visa and Mastercard issued in the Philippines. How can I pay for your services/ products?

-We accept COD, local Credit Cards, Debit Cards, and ATM Cards only. +We accept COD, local credit cards, debit cards, and ATM cards for battery replacement transactions. We only accept cash payment for flat tire, refuel and overheat transactions.

@@ -93,7 +93,7 @@ Delivery for battery purchase is free of charge. Can you deliver anywhere in the Philippines?

-Not yet. Res-Q is offered initially in Metro Manila only. +Not yet. Res-Q is offered Metro Manila, Baguio City and Binan, Laguna only.

From 3bc4bb8db798f680477447d1fa548b6ea3384a38 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Fri, 19 Mar 2021 02:23:22 +0800 Subject: [PATCH 20/43] Allow for same plate number update on register api call #540 --- src/Controller/CAPI/CustomerWarrantyController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Controller/CAPI/CustomerWarrantyController.php b/src/Controller/CAPI/CustomerWarrantyController.php index 29095240..5a8e87f0 100644 --- a/src/Controller/CAPI/CustomerWarrantyController.php +++ b/src/Controller/CAPI/CustomerWarrantyController.php @@ -88,6 +88,11 @@ class CustomerWarrantyController extends APIController return trim(strtoupper($serial)); } + protected function cleanPlateNumber($plate_num) + { + return preg_replace('/\s+/', '', strtoupper($plate_num)); + } + public function check($serial, EntityManagerInterface $em, Request $req) { // check required parameters @@ -303,6 +308,8 @@ class CustomerWarrantyController extends APIController protected function updateWarranty($em, $req, $serial, $inv_filename = null, $wcard_filename = null) { + $plate_num = $this->cleanPlateNumber($req->request->get('plate_num')); + error_log('warranty serial check'); // get serial $warr_serial = $em->getRepository(WarrantySerial::class)->find($serial); @@ -317,7 +324,12 @@ class CustomerWarrantyController extends APIController // skip warranty if it already exists if ($warr != null) { - return new APIResponse(false, 'Warranty registred to a vehicle not in your list of vehicles.'); + $warr_plate_num = $this->cleanPlateNumber($warr->getPlateNumber()); + + if ($plate_num != $warr_plate_num) + { + return new APIResponse(false, 'Plate number does not match vehicle registered to warranty.'); + } /* // check if warranty is registered to a serial owned by customer From 1f35feffc17fa648741def26dab5d1aecff9f0c1 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 19 Mar 2021 05:50:06 +0000 Subject: [PATCH 21/43] Create marketing research sms and email flags for customer. #546 --- src/Entity/Customer.php | 29 +++++++++++++++---- .../CustomerHandler/ResqCustomerHandler.php | 6 ++-- templates/customer/form.html.twig | 25 ++++++++++++---- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/Entity/Customer.php b/src/Entity/Customer.php index f99df0d5..12c7839c 100644 --- a/src/Entity/Customer.php +++ b/src/Entity/Customer.php @@ -195,7 +195,12 @@ class Customer /** * @ORM\Column(type="boolean", options={"default":false}) */ - protected $flag_promo_marketing_research; + protected $flag_research_sms; + + /** + * @ORM\Column(type="boolean", options={"default":false}) + */ + protected $flag_research_email; public function __construct() { @@ -227,7 +232,8 @@ class Customer $this->flag_promo_email = false; $this->flag_promo_sms = false; $this->flag_dpa_consent = false; - $this->flag_promo_marketing_research = false; + $this->flag_research_sms = false; + $this->flag_research_email = false; $this->date_create = new DateTime(); } @@ -562,14 +568,25 @@ class Customer return $this->flag_dpa_consent; } - public function setPromoMarketingResearch($flag_promo_marketing_research = true) + public function setResearchSms($flag_research_sms = true) { - $this->flag_promo_marketing_research = $flag_promo_marketing_research; + $this->flag_research_sms = $flag_research_sms; return $this; } - public function isPromoMarketingResearch() + public function isResearchSms() { - return $this->flag_promo_marketing_research; + return $this->flag_research_sms; + } + + public function setResearchEmail($flag_research_email = true) + { + $this->flag_research_email = $flag_research_email; + return $this; + } + + public function isResearchEmail() + { + return $this->flag_research_email; } } diff --git a/src/Service/CustomerHandler/ResqCustomerHandler.php b/src/Service/CustomerHandler/ResqCustomerHandler.php index cf2a71d7..76d20054 100644 --- a/src/Service/CustomerHandler/ResqCustomerHandler.php +++ b/src/Service/CustomerHandler/ResqCustomerHandler.php @@ -539,7 +539,8 @@ class ResqCustomerHandler implements CustomerHandlerInterface 'flag_dpa_consent' => $customer->isDpaConsent(), 'flag_promo_sms' => $customer->isPromoSms(), 'flag_promo_email' => $customer->isPromoEmail(), - 'flag_promo_marketing_research' => $customer->isPromoMarketingResearch(), + 'flag_research_sms' => $customer->isResearchSms(), + 'flag_research_email' => $customer->isResearchEmail(), ], 'vehicle' => [ 'id' => $vehicle->getID(), @@ -601,7 +602,8 @@ class ResqCustomerHandler implements CustomerHandlerInterface ->setPromoSms($req->request->get('flag_promo_sms', false)) ->setPromoEmail($req->request->get('flag_promo_email', false)) ->setDpaConsent($is_dpa_checked) - ->setPromoMarketingResearch($req->request->get('flag_promo_marketing_research', false)); + ->setResearchSms($req->request->get('flag_research_sms', false)) + ->setResearchEmail($req->request->get('flag_research_email', false)); // phone numbers $obj->setPhoneMobile($req->request->get('phone_mobile')) diff --git a/templates/customer/form.html.twig b/templates/customer/form.html.twig index 26b350e0..eeae4bbe 100644 --- a/templates/customer/form.html.twig +++ b/templates/customer/form.html.twig @@ -119,15 +119,30 @@ + + + +
+
+ +
+
+ +
{% if is_granted('customer.dpa') %} @@ -135,9 +150,7 @@ {% endif %}
-
-
-
+
+
+ + + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+ + +
+
+
+
{% if is_granted('customer.dpa') %} @@ -219,6 +266,15 @@
+
+ + + +
{% if obj.getCustomerVehicle %}
@@ -353,7 +409,7 @@
- +
@@ -375,34 +431,6 @@
-
-
-
-
- -
- - -
-
-
-
-
- - - -
-
+
+
+
+

Customer Source Report

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

+ Select a date range +

+
+
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+{% endblock %} + +{% block scripts %} + +{% endblock %}