Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 688)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 689)
@@ -217,61 +217,20 @@
 		$this->load->model('Services_model');
 		
-		$totalpage = 10213;
-		
-		$result = $this->Services_model->getCollaborator(2,1,1);
+		//$totalpage = 10213;
+		
+		// get total page
+		$totalpage = 1;
+		$default = $this->Services_model->getCollaborator(2,1,1);
+		if($default){
+			$xml = simplexml_load_string($default);
+			$xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
+			$xml = $xml->xpath('//S:Body')[0];
+			$xml->registerXPathNamespace("ns2", "http://process.wsim.viettel.com/");
+			$totalpage = (int)$xml->xpath('//return//totalpage')[0];
+		}
+		
+		$result = $this->Services_model->getCollaborator(2,1,$totalpage);
 		if ($result){
-			//$this->xml->parse($result);
-			//$xml = $this->xml;
-			//var_dump($xml);
-			/*
-			$xml = '<?xml version="1.0" ?>
-					<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
-						<S:Body>
-							<ns2:getListShopAndStaftInfoResponse xmlns:ns2="http://process.wsim.viettel.com/">
-								<return>
-									<description>Thï¿œnh cï¿œng</description>
-									<responseCode>0</responseCode>
-									<lst>
-										<address>S? nhï¿œ null ???ng Null Khu?i Thu?m Huy?n T?ng B?c K?n B?c K?n</address>
-										<code>1000004001_00001_CTVTMDT</code>
-										<district>001</district>
-										<email></email>
-										<id>20513478</id>
-										<name>V? Th? Luy?n</name>
-										<phone></phone>
-										<precinct>004</precinct>
-										<province>B281</province>
-									</lst>
-									<lst>
-										<address>S? nhï¿œ 01 ???ng 01  ??c Xuï¿œn B?c K?n B?c K?n</address>
-										<code>1000004001_00002_GPKHDN</code>
-										<district>001</district>
-										<email></email>
-										<id>20536705</id>
-										<name>Chu ?ï¿œnh Anh</name>
-										<phone>962143096</phone>
-										<precinct>004</precinct>
-										<province>B281</province>
-									</lst>
-									<lst>
-										<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>
-										<code>1000004001_00003_CTVTMDT</code>
-										<district>001</district>
-										<email></email>
-										<id>20519414</id>
-										<name>Hoï¿œng Cï¿œng Minh</name>
-										<phone>0983532981</phone>
-										<precinct>004</precinct>
-										<province>B281</province>
-									</lst>
-									<page>1</page>
-									<totalpage>102123</totalpage>
-								</return>
-							</ns2:getListShopAndStaftInfoResponse>
-						</S:Body>
-					</S:Envelope>';
-			*/
-			$xml = $result['result']['original'];
-			$xml = simplexml_load_string($xml);
+			$xml = simplexml_load_string($result);
 			$xml->registerXPathNamespace("S", "http://schemas.xmlsoap.org/soap/envelope/");
 			$xml = $xml->xpath('//S:Body')[0];
@@ -280,22 +239,23 @@
 			foreach($lst as $item){
 				$item = (array)$item;
-				$data = array(
-						'address'=> (string)$item['address'],
-						'code'=>(string)$item['code'],
-						'district'=>(string)$item['district'],
-						'email'=>(string)$item['email'],
-						'id'=>(int)$item['id'],
-						'full_name'=>(string)$item['name'],
-						'cellphone'=>(string)$item['phone'],
-						'precinct'=>(string)$item['precinct'],
-						'province'=>(string)$item['province'],
-						'updated_time'=>date('Y-m-d H:i:s')
-					);
-				$this->Services_model->syncCollaborator($data);
+				if ((string)$item['phone']){
+					$data = array(
+							'address'=> (string)$item['address'],
+							'code'=>(string)$item['code'],
+							'district'=>(string)$item['district'],
+							'email'=>(string)$item['email'],
+							'id'=>(int)$item['id'],
+							'full_name'=>(string)$item['name'],
+							'cellphone'=>(string)$item['phone'],
+							'precinct'=>(string)$item['precinct'],
+							'province'=>(string)$item['province'],
+							'updated_time'=>date('Y-m-d H:i:s')
+						);
+					$this->Services_model->syncCollaborator($data);
+				}
 			}
-			$totalpage = (int)$xml->xpath('//return//totalpage')[0];
-			//var_dump($totalpage);
 		}else{
-			var_dump($result);
+			$logMsg = date('Y-m-d H:i:s') . " Result is null \n";
+			write_file('./log/sync_collaborator.log', $logMsg, FOPEN_WRITE_CREATE);
 		}
 	}
Index: pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 688)
+++ pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 689)
@@ -436,10 +436,15 @@
 			$id = $this->db->insert_id();
 			if ($this->db->affected_rows()){
-				echo "Collaborator ID: ".$id.". Sync Success !<br/>";
+				//echo "Collaborator ID: ".$id.". Sync Success !<br/>";
+				$logMsg = date('Y-m-d H:i:s') . " Collaborator ID: ".$id.". Sync Success !\n";
+				write_file('./log/sync_collaborator.log', $logMsg, FOPEN_WRITE_CREATE);
 			}else{
-				echo "Collaborator ID: ".$id.". Sync fail!. Sql = ".$sql."<br/>";
+				//echo "Collaborator ID: ".$id.". Sync fail!. Sql = ".$sql."<br/>";
+				$logMsg = date('Y-m-d H:i:s') . " Collaborator ID: ".$id.". Sync fail!. Sql = ".$sql."\n";
+				write_file('./log/sync_collaborator.log', $logMsg, FOPEN_WRITE_CREATE);
 			}
 		}else {
-			var_dump($data);
+			$logMsg = date('Y-m-d H:i:s') . " Data is null \n";
+			write_file('./log/sync_collaborator.log', $logMsg, FOPEN_WRITE_CREATE);
 		}
 	}
