Merge branch '394-warranty-expiration-sms-reminder' into 'master'

Resolve "Warranty expiration sms reminder"

Closes #394

See merge request jankstudio/resq!447
This commit is contained in:
Kendrick Chan 2020-05-04 10:05:53 +00:00
commit 634296f9bc

View file

@ -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);
}
/*