Ignore:
Timestamp:
Jan 29, 2015 10:46:25 AM (10 years ago)
Author:
namnd
Message:
 
Location:
pro-violet-viettel/sourcecode/application/modules/services/controllers
Files:
1 added
1 edited

Legend:

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

    r711 r714  
    212212        }
    213213       
    214         public function collaborator ()
    215         {
    216                 error_reporting(E_ALL);
    217 
    218                 $this->load->model('Services_model');
    219                
    220                 //$totalpage = 10213;
    221                
    222                 // get total page
    223                 $totalpage = 1;
    224                
    225                 $default = $this->Services_model->getCollaborator(2,1,100);
    226                 //var_dump($default);
    227                 $data = mb_convert_encoding($default, 'UTF-8', 'ISO-8859-1');
    228                 if($data){
    229                         $xml = simplexml_load_string($data);
    230                         $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
    231                        
    232                         $xml = $xml->xpath('//S:Body');
    233                         $xml = $xml[0];
    234 
    235                         $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/");
    236                        
    237                         $totalpage = $xml->xpath('//return//totalpage');
    238                         $totalpage = (int)$totalpage[0];
    239                 }
    240                
    241                 for ($i=1; $i<=$totalpage; $i++){
    242                         $result = $this->Services_model->getCollaborator(2,$i,100);
    243                         $data = mb_convert_encoding($result, 'UTF-8', 'ISO-8859-1');
    244                         if($data && $data != -1){
    245                                 $xml = simplexml_load_string($data);
    246                                 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
    247                                 $xml = $xml->xpath('//S:Body');
    248                                 $xml = $xml[0];
    249                                 $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/");
    250                                 $lst = $xml->xpath('//return//lst');
    251                                 foreach($lst as $item){
    252                                         $item = (array)$item;
    253                        
    254                                         $data = array(
    255                                                         'address'=> (string)$item['address'],
    256                                                         'code'=>(string)$item['code'],
    257                                                         'district'=>(string)$item['district'],
    258                                                         'email'=>(string)$item['email'],
    259                                                         'id'=>(int)$item['id'],
    260                                                         'full_name'=>(string)$item['name'],
    261                                                         'cellphone'=>(string)$item['phone'],
    262                                                         'precinct'=>(string)$item['precinct'],
    263                                                         'province'=>(string)$item['province'],
    264                                                         'created_time'=>date('Y-m-d H:i:s'),
    265                                                         'updated_time'=>date('Y-m-d H:i:s')
    266                                                 );
    267                                         write_file('./log/sync_collaborator.log', var_export($data, TRUE), FOPEN_WRITE_CREATE);
    268                                         if ((string)$item['phone']){
    269                                                 $this->Services_model->syncCollaborator($data);
    270                                         }
    271                                 }
    272                         }else{
    273                                 $logMsg = date('Y-m-d H:i:s') . " Result is null \n";
    274                                 write_file('./log/sync_collaborator.log', $logMsg, FOPEN_WRITE_CREATE);
    275                         }
    276                 }
    277         }
     214       
    278215}
    279216
Note: See TracChangeset for help on using the changeset viewer.