From 9f7b8e6c38513f8ecf57ce785142eac0fb4e1a1d Mon Sep 17 00:00:00 2001 From: CJ Date: Sat, 19 Jul 2014 11:11:01 +0800 Subject: [PATCH 1/3] Added SG phone number support --- app/libraries/utils.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/libraries/utils.php b/app/libraries/utils.php index f2ae828a1aac..11273428d7bb 100755 --- a/app/libraries/utils.php +++ b/app/libraries/utils.php @@ -139,6 +139,12 @@ class Utils $phoneNumber = '+'.$countryCode.' ('.$areaCode.') '.$nextThree.'-'.$lastFour; } + else if(strlen($phoneNumber) == 10 && substr($phoneNumber, 0, 2) == 65) { + $countryCode = substr($phoneNumber, 0, 2); + $nextFour = substr($phoneNumber, 2, 4); + $lastFour = substr($phoneNumber, 6, 4); + $phoneNumber = '+'.$countryCode.' '.$nextFour.' '.$lastFour; + } else if(strlen($phoneNumber) == 10) { $areaCode = substr($phoneNumber, 0, 3); $nextThree = substr($phoneNumber, 3, 3); From e6c78e3621657ac6072b9a084c2338792d5d9caf Mon Sep 17 00:00:00 2001 From: CJ Date: Sat, 19 Jul 2014 11:11:01 +0800 Subject: [PATCH 2/3] Added SGD currency --- app/database/seeds/ConstantsSeeder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/database/seeds/ConstantsSeeder.php b/app/database/seeds/ConstantsSeeder.php index 4e8c44dfb170..8c9b9114e122 100755 --- a/app/database/seeds/ConstantsSeeder.php +++ b/app/database/seeds/ConstantsSeeder.php @@ -128,6 +128,7 @@ class ConstantsSeeder extends Seeder Currency::create(array('name' => 'Rand', 'code' => 'ZAR', 'symbol' => 'R', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); Currency::create(array('name' => 'Danish Krone', 'code' => 'DKK', 'symbol' => 'kr ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); Currency::create(array('name' => 'Israeli Shekel', 'code' => 'ILS', 'symbol' => 'NIS ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); + Currency::create(array('name' => 'Singapore Dollar', 'code' => 'SGD', 'symbol' => 'SGD ', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); DatetimeFormat::create(array('format' => 'd/M/Y g:i a', 'label' => '10/Mar/2013')); DatetimeFormat::create(array('format' => 'd-M-Yk g:i a', 'label' => '10-Mar-2013')); From 2d3ef1e4a8ccbb924a8a17cafa6dcea4e2ffe3f5 Mon Sep 17 00:00:00 2001 From: CJ Date: Wed, 23 Jul 2014 02:17:49 +0800 Subject: [PATCH 3/3] Fix SG vs US phone country/area code clashes --- app/libraries/utils.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/libraries/utils.php b/app/libraries/utils.php index 11273428d7bb..fa1f2542b3c2 100755 --- a/app/libraries/utils.php +++ b/app/libraries/utils.php @@ -139,10 +139,17 @@ class Utils $phoneNumber = '+'.$countryCode.' ('.$areaCode.') '.$nextThree.'-'.$lastFour; } - else if(strlen($phoneNumber) == 10 && substr($phoneNumber, 0, 2) == 65) { + else if(strlen($phoneNumber) == 10 && in_array(substr($phoneNumber, 0, 3), array(653, 656, 658, 659))) { + /** + * SG country code are 653, 656, 658, 659 + * US area code consist of 650, 651 and 657 + * @see http://en.wikipedia.org/wiki/Telephone_numbers_in_Singapore#Numbering_plan + * @see http://www.bennetyee.org/ucsd-pages/area.html + */ $countryCode = substr($phoneNumber, 0, 2); $nextFour = substr($phoneNumber, 2, 4); $lastFour = substr($phoneNumber, 6, 4); + $phoneNumber = '+'.$countryCode.' '.$nextFour.' '.$lastFour; } else if(strlen($phoneNumber) == 10) {