Ignore:
Timestamp:
Mar 27, 2015 9:49:55 AM (10 years ago)
Author:
namnd
Message:
 
Location:
pro-violet-viettel/sourcecode/application/modules/services
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php

    r822 r838  
    3939                                        foreach($lst as $item){
    4040                                                $item = (array)$item;
    41                                
     41                                                $phoneNumber = $this->Services_model->formatPhoneNumber((string)$item['phone'], 2);
    4242                                                $data = array(
    4343                                                                'address'=> (string)$item['address'],
     
    4747                                                                'id'=>(int)$item['id'],
    4848                                                                'full_name'=>(string)$item['name'],
    49                                                                 'cellphone'=>(string)$item['phone'],
     49                                                                'passwd' => md5($phoneNumber),
     50                                                                'cellphone'=>$phoneNumber,
    5051                                                                'precinct'=>(string)$item['precinct'],
    5152                                                                'province'=>(string)$item['province'],
  • pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php

    r822 r838  
    449449         */
    450450        public function formatPhoneNumber ($phoneNumber, $direction = 1) {
     451                $result = $phoneNumber;
    451452                $aryMatch = array();
    452453                if (preg_match('/^(84)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1 && $direction == 1) {
     
    461462                else if (preg_match('/^(0)([0-9]{9,10})$/', $phoneNumber, $aryMatch) == 1 && $direction == -1) {
    462463                        $result = '84'. $aryMatch[2];
     464                }
     465                else if (preg_match('/^[1,9]([0-9]{8,9})$/', $phoneNumber, $aryMatch) == 1 && $direction = 2) {
     466                        $result = '0'. $phoneNumber;
    463467                }
    464468               
     
    473477                                                                                                                                                                                                district = "'.$data['district'].'",
    474478                                                                                                                                                                                                email = "'.$data['email'].'",
    475                                                                                                                                                                                                 full_name = "'.$data['full_name'].'",
     479                                                                                                                                                                                                full_name = "'.$data['full_name'].'",
     480                                                                                                                                                                                                passwd = "'.$data['passwd'].'",
    476481                                                                                                                                                                                                cellphone = "'.$data['cellphone'].'",
    477482                                                                                                                                                                                                precinct = "'.$data['precinct'].'",
Note: See TracChangeset for help on using the changeset viewer.