Changeset 688 for pro-violet-viettel/sourcecode/application/modules
- Timestamp:
- Jan 6, 2015 11:52:00 AM (10 years ago)
- Location:
- pro-violet-viettel/sourcecode/application/modules/services
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
r687 r688 214 214 public function collaborator () 215 215 { 216 /*error_reporting(E_ALL);216 error_reporting(E_ALL); 217 217 $this->load->model('Services_model'); 218 218 … … 220 220 221 221 $result = $this->Services_model->getCollaborator(2,1,1); 222 $this->xml->parse($result); 223 $xml = $this->xml; 224 var_dump($xml); */ 225 226 $xml = '<?xml version="1.0" ?> 227 <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 228 <S:Body> 229 <ns2:getListShopAndStaftInfoResponse xmlns:ns2="http://process.wsim.viettel.com/"> 230 <return> 231 <description>Thᅵnh cᅵng</description> 232 <responseCode>0</responseCode> 233 <lst> 234 <address>S? nhᅵ null ???ng Null Khu?i Thu?m Huy?n T?ng B?c K?n B?c K?n</address> 235 <code>1000004001_00001_CTVTMDT</code> 236 <district>001</district> 237 <email></email> 238 <id>20513478</id> 239 <name>V? Th? Luy?n</name> 240 <phone></phone> 241 <precinct>004</precinct> 242 <province>B281</province> 243 </lst> 244 <page>1</page> 245 <totalpage>102123</totalpage> 246 </return> 247 </ns2:getListShopAndStaftInfoResponse> 248 </S:Body> 249 </S:Envelope>'; 250 251 $xml = simplexml_load_string($xml); 252 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/"); 253 $xml = $xml->xpath('//S:Body')[0]; 254 $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/"); 255 $lst = (array)$xml->xpath('//return//lst')[0]; 256 $totalpage = (int)$xml->xpath('//return//totalpage')[0]; 257 echo json_encode(array('lst'=>$lst, 'totalpage'=>$totalpage)); 222 if ($result){ 223 //$this->xml->parse($result); 224 //$xml = $this->xml; 225 //var_dump($xml); 226 /* 227 $xml = '<?xml version="1.0" ?> 228 <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 229 <S:Body> 230 <ns2:getListShopAndStaftInfoResponse xmlns:ns2="http://process.wsim.viettel.com/"> 231 <return> 232 <description>Thᅵnh cᅵng</description> 233 <responseCode>0</responseCode> 234 <lst> 235 <address>S? nhᅵ null ???ng Null Khu?i Thu?m Huy?n T?ng B?c K?n B?c K?n</address> 236 <code>1000004001_00001_CTVTMDT</code> 237 <district>001</district> 238 <email></email> 239 <id>20513478</id> 240 <name>V? Th? Luy?n</name> 241 <phone></phone> 242 <precinct>004</precinct> 243 <province>B281</province> 244 </lst> 245 <lst> 246 <address>S? nhᅵ 01 ???ng 01 ??c Xuᅵn B?c K?n B?c K?n</address> 247 <code>1000004001_00002_GPKHDN</code> 248 <district>001</district> 249 <email></email> 250 <id>20536705</id> 251 <name>Chu ?ᅵnh Anh</name> 252 <phone>962143096</phone> 253 <precinct>004</precinct> 254 <province>B281</province> 255 </lst> 256 <lst> 257 <address>S? nhᅵ 186 ???ng Nguy?n Th? Minh Khai T? 8 Nguy?n Th? Minh Khai B?c K?n B?c K?n</address> 258 <code>1000004001_00003_CTVTMDT</code> 259 <district>001</district> 260 <email></email> 261 <id>20519414</id> 262 <name>Hoᅵng Cᅵng Minh</name> 263 <phone>0983532981</phone> 264 <precinct>004</precinct> 265 <province>B281</province> 266 </lst> 267 <page>1</page> 268 <totalpage>102123</totalpage> 269 </return> 270 </ns2:getListShopAndStaftInfoResponse> 271 </S:Body> 272 </S:Envelope>'; 273 */ 274 $xml = $result['result']['original']; 275 $xml = simplexml_load_string($xml); 276 $xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/"); 277 $xml = $xml->xpath('//S:Body')[0]; 278 $xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/"); 279 $lst = $xml->xpath('//return//lst'); 280 foreach($lst as $item){ 281 $item = (array)$item; 282 $data = array( 283 'address'=> (string)$item['address'], 284 'code'=>(string)$item['code'], 285 'district'=>(string)$item['district'], 286 'email'=>(string)$item['email'], 287 'id'=>(int)$item['id'], 288 'full_name'=>(string)$item['name'], 289 'cellphone'=>(string)$item['phone'], 290 'precinct'=>(string)$item['precinct'], 291 'province'=>(string)$item['province'], 292 'updated_time'=>date('Y-m-d H:i:s') 293 ); 294 $this->Services_model->syncCollaborator($data); 295 } 296 $totalpage = (int)$xml->xpath('//return//totalpage')[0]; 297 //var_dump($totalpage); 298 }else{ 299 var_dump($result); 300 } 258 301 } 259 302 } -
pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
r685 r688 420 420 return $result; 421 421 } 422 423 424 public function syncCollaborator($data){ 425 if ($data){ 426 $sql = $this->db->insert_string('tblcollaborator', $data) . ' ON DUPLICATE KEY UPDATE address = "'.$data['address'].'", 427 code = "'.$data['code'].'", 428 district = "'.$data['district'].'", 429 email = "'.$data['email'].'", 430 full_name = "'.$data['full_name'].'", 431 cellphone = "'.$data['cellphone'].'", 432 precinct = "'.$data['precinct'].'", 433 province = "'.$data['province'].'", 434 updated_time = "'.$data['updated_time'].'"'; 435 $this->db->query($sql); 436 $id = $this->db->insert_id(); 437 if ($this->db->affected_rows()){ 438 echo "Collaborator ID: ".$id.". Sync Success !<br/>"; 439 }else{ 440 echo "Collaborator ID: ".$id.". Sync fail!. Sql = ".$sql."<br/>"; 441 } 442 }else { 443 var_dump($data); 444 } 445 } 422 446 }
Note: See TracChangeset
for help on using the changeset viewer.