From 46da9b6bfd28f9a67987e7ffac62e04323048510 Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Mon, 4 May 2020 18:04:56 +0800 Subject: [PATCH] Add details to message #394 --- src/Command/WarrantySMSCommand.php | 35 +++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Command/WarrantySMSCommand.php b/src/Command/WarrantySMSCommand.php index dfacab65..4758d4ab 100644 --- a/src/Command/WarrantySMSCommand.php +++ b/src/Command/WarrantySMSCommand.php @@ -50,28 +50,51 @@ class WarrantySMSCommand extends Command $warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]); + $valid_numbers = []; foreach ($warrs as $w) { error_log($w->getID() . ' - ' . $w->getMobileNumber()); // check valid number $num = trim($w->getMobileNumber()); - // should start with '9' - if ($num[0] != '9') - continue; - // should be 10 digits if (strlen($num) != 10) continue; + // should start with '9' + if ($num[0] != '9') + continue; + // should be numeric if (!is_numeric($num)) continue; - error_log('valid!'); - // add 63 prefix $num = '63' . $num; + + // get battery model and size + $bsize = $w->getBatterySize(); + $bmodel = $w->getBatteryModel(); + + if ($bsize == null || $bmodel == null) + $batt = ''; + else + $batt = $bsize->getName() . ' ' . $bmodel->getName(); + + $valid_numbers[] = [ + 'number' => $num, + 'name' => $w->getFirstName(), + 'plate' => $w->getPlateNumber(), + 'batt' => $batt, + ]; + } + + + error_log(print_r($valid_numbers, true)); + foreach ($valid_numbers as $wdata) + { + $msg = 'Hi ' . $wdata['name'] . ', the warranty for the ' . $wdata['batt'] . ' installed in your car(' . $wdata['plate'] . ') has expired already. Please call MOTOLITE EXPRESS HATID at 8370-6686 to have the status of your battery checked to avoid any inconvenience. Thank you for choosing Motolite.'; + error_log($wdata['number'] . ' - sending ' . $msg); } /*