Filter valid phone numbers and convert the 09XXXXXXXXX format to 9XXXXXXXXX #274

This commit is contained in:
Kendrick Chan 2019-11-21 10:20:07 +08:00
parent fba5d9cb86
commit 2b21db6c01

View file

@ -130,12 +130,26 @@ class CreateCustomerFromWarrantyCommand extends Command
if (empty($w_mobile_num))
continue;
// does it fit our 09XXXXXXXXX pattern?
if (preg_match('/^09[0-9]{9}$/', $w_mobile_num))
{
// remove first '0'
$w_mobile_num = substr($w_mobile_num, 1);
error_log("CONVERTED TO $w_mobile_num");
}
// does it fit our 9XXXXXXXXX pattern?
if (!preg_match('/^9[0-9]{9}$/', $w_mobile_num))
continue;
/*
// min length 2
// TODO: we need to check proper phone number format
// format should be '9XXXXXXXXX'
// TODO: if format doesn't fit and there's a 0 or 63 prefix, we should be able to detect and convert
if (strlen($w_mobile_num <= 2))
continue;
*/
error_log('');
error_log("($total_warr) processing $w_mobile_num from warranty...");