From 575bf21639e0e1474713c1680dd29b83db37445f Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Thu, 21 Nov 2019 09:10:58 +0800 Subject: [PATCH] Fix blank phone number issue #274 --- src/Command/CreateCustomerFromWarrantyCommand.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Command/CreateCustomerFromWarrantyCommand.php b/src/Command/CreateCustomerFromWarrantyCommand.php index ddc6d3a4..9303c0c4 100644 --- a/src/Command/CreateCustomerFromWarrantyCommand.php +++ b/src/Command/CreateCustomerFromWarrantyCommand.php @@ -127,10 +127,19 @@ class CreateCustomerFromWarrantyCommand extends Command $cust_found = false; foreach ($w_mobile_array as $w_mobile_num) { + $w_mobile_num = trim($w_mobile_num); + // empty mobile num if (empty($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..."); @@ -249,6 +258,7 @@ class CreateCustomerFromWarrantyCommand extends Command fclose($fh); + $output->writeln(''); $output->writeln('Total warranties: ' . $total_warr); $output->writeln('Total warranties with no mobile number: ' . $total_inv_warr); $output->writeln('Total customers added: ' . $total_cust_added);