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:
commit
634296f9bc
1 changed files with 29 additions and 6 deletions
|
|
@ -50,28 +50,51 @@ class WarrantySMSCommand extends Command
|
||||||
|
|
||||||
$warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]);
|
$warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]);
|
||||||
|
|
||||||
|
$valid_numbers = [];
|
||||||
foreach ($warrs as $w)
|
foreach ($warrs as $w)
|
||||||
{
|
{
|
||||||
error_log($w->getID() . ' - ' . $w->getMobileNumber());
|
error_log($w->getID() . ' - ' . $w->getMobileNumber());
|
||||||
// check valid number
|
// check valid number
|
||||||
$num = trim($w->getMobileNumber());
|
$num = trim($w->getMobileNumber());
|
||||||
|
|
||||||
// should start with '9'
|
|
||||||
if ($num[0] != '9')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// should be 10 digits
|
// should be 10 digits
|
||||||
if (strlen($num) != 10)
|
if (strlen($num) != 10)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// should start with '9'
|
||||||
|
if ($num[0] != '9')
|
||||||
|
continue;
|
||||||
|
|
||||||
// should be numeric
|
// should be numeric
|
||||||
if (!is_numeric($num))
|
if (!is_numeric($num))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
error_log('valid!');
|
|
||||||
|
|
||||||
// add 63 prefix
|
// add 63 prefix
|
||||||
$num = '63' . $num;
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue