Add details to message #394
This commit is contained in:
parent
1a78320ca9
commit
46da9b6bfd
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]);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue