diff --git a/system/autoload/Lang.php b/system/autoload/Lang.php
index 15894492..6c790bd4 100644
--- a/system/autoload/Lang.php
+++ b/system/autoload/Lang.php
@@ -21,4 +21,14 @@ class Lang
global $config;
return $config['currency_code'] . ' ' .number_format($var, 0, $config['dec_point'], $config['thousands_sep']);
}
+
+ public static function phoneFormat($phone)
+ {
+ global $config;
+ if(Validator::UnsignedNumber($phone) && !empty($config['country_code_phone'])){
+ return preg_replace('/^0/', $config['country_code_phone'], $phone);
+ }else{
+ return $phone;
+ }
+ }
}
diff --git a/system/controllers/customers.php b/system/controllers/customers.php
index 3aabc72b..96f99356 100644
--- a/system/controllers/customers.php
+++ b/system/controllers/customers.php
@@ -116,7 +116,7 @@ switch ($action) {
$username = _post('username');
$fullname = _post('fullname');
$password = _post('password');
- $cpassword = _post('cpassword');
+ $email = _post('email');
$address = _post('address');
$phonenumber = _post('phonenumber');
run_hook('add_customer'); #HOOK
@@ -130,9 +130,6 @@ switch ($action) {
if (!Validator::Length($password, 35, 2)) {
$msg .= 'Password should be between 3 to 35 characters' . '
';
}
- if ($password != $cpassword) {
- $msg .= 'Passwords does not match' . '
';
- }
$d = ORM::for_table('tbl_customers')->where('username', $username)->find_one();
if ($d) {
@@ -141,11 +138,12 @@ switch ($action) {
if ($msg == '') {
$d = ORM::for_table('tbl_customers')->create();
- $d->username = $username;
+ $d->username = Lang::phoneFormat($username);
$d->password = $password;
+ $d->email = $email;
$d->fullname = $fullname;
$d->address = $address;
- $d->phonenumber = $username;
+ $d->phonenumber = Lang::phoneFormat($phonenumber);
$d->save();
r2(U . 'customers/list', 's', $_L['account_created_successfully']);
} else {
@@ -154,27 +152,24 @@ switch ($action) {
break;
case 'edit-post':
- $username = _post('username');
+ $username = Lang::phoneFormat(_post('username'));
$fullname = _post('fullname');
$password = _post('password');
- $cpassword = _post('cpassword');
+ $email = _post('email');
$address = _post('address');
- $phonenumber = _post('phonenumber');
+ $phonenumber = Lang::phoneFormat(_post('phonenumber'));
run_hook('edit_customer'); #HOOK
$msg = '';
if (Validator::Length($username, 16, 2) == false) {
$msg .= 'Username should be between 3 to 15 characters' . '
';
}
- if (Validator::Length($fullname, 26, 2) == false) {
- $msg .= 'Full Name should be between 3 to 25 characters' . '
';
+ if (Validator::Length($fullname, 26, 1) == false) {
+ $msg .= 'Full Name should be between 2 to 25 characters' . '
';
}
if ($password != '') {
if (!Validator::Length($password, 15, 2)) {
$msg .= 'Password should be between 3 to 15 characters' . '
';
}
- if ($password != $cpassword) {
- $msg .= 'Passwords does not match' . '
';
- }
}
$id = _post('id');
@@ -218,6 +213,7 @@ switch ($action) {
$d->password = $password;
}
$d->fullname = $fullname;
+ $d->email = $email;
$d->address = $address;
$d->phonenumber = $phonenumber;
$d->save();
@@ -227,6 +223,7 @@ switch ($action) {
$d->password = $password;
}
$d->fullname = $fullname;
+ $d->email = $email;
$d->address = $address;
$d->phonenumber = $phonenumber;
$d->save();
diff --git a/system/controllers/register.php b/system/controllers/register.php
index 5f41f97f..8ebd8226 100644
--- a/system/controllers/register.php
+++ b/system/controllers/register.php
@@ -26,7 +26,8 @@ switch ($do) {
$cpassword = _post('cpassword');
$address = _post('address');
if(!empty($config['sms_url'])){
- $phonenumber = $username;
+ $phonenumber = Lang::phoneFormat($username);
+ $username = $phonenumber;
}else if(strlen($username)<21){
$phonenumber = $username;
}
diff --git a/ui/ui/customers-add.tpl b/ui/ui/customers-add.tpl
index 0d4ecb9d..90b3e94c 100644
--- a/ui/ui/customers-add.tpl
+++ b/ui/ui/customers-add.tpl
@@ -9,9 +9,13 @@