Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 459)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 460)
@@ -66,39 +66,33 @@
 	}
 
-	function register ($sentNumber, $receiverID, $serviceID, $commandcode, $info, $receiveTime, &$status='')
+	function register ($sentNumber, $receiverID, $serviceID, $commandcode, $info, $receiveTime, &$status)
 	{
-		//1. check collaborator info if $receiverID existed
-		//2. insert new user to database
-		//3. create random password for new user
-		//4. return sms contain password
-		
 		$username = '';
 		$collaborator = '';
-		if (is_null($receiverID) || $receiverID == '') {
-			$username = $sentNumber;
-		}
-		else {
-			$username = $receiverID;
-			$collaborator = $sentNumber;
-		}
+		$username = $receiverID;
 		$user = array();
 		$smslog = array();
 		$password = $this->create_random_password();
 		$src = 'SBG';
-		$token = md5($username.self::TOKENPW);
+		$username = '0'.substr($username, 2, strlen($username));
+		$token = md5($username.self::TOKENPW);		
 		$phone = $username;
-		$data = $this->vservices->actionExecute('update', array('src'=>$src, 'username'=>$username, 'password'=>$password, 'fullname'=>" ", 'phone'=>$username, 'token'=>$token), 'user');
-		$status = substr($data, 7, 1);
+		$data = $this->vservices->actionExecute('update', array('src'=>$src, 'username'=>$username, 'password'=>$password, 'fullname'=>null, 'phone'=>$username, 'token'=>$token), 'user');
+
+		$id = 0;
+		$errMsg = '';
+		parse_str($data);
 		$sms = "";
-		switch($status)
+		
+		switch((int)$status)
 		{
 			case 0:
-				$us_id = (int)substr($data, 12);
+				$us_id = $id;
 				$user['created_time'] = $receiveTime;
-				$user['updated_time'] = $receiveTime;
 				$user['us_id'] = $us_id;
 				$user['cellphone'] = $username;
 				$user['collaborator'] = $collaborator;
 				$this->db->insert('tbluser', $user);
+				
 				$smslog['sender'] = $sentNumber;
 				$smslog['us_id'] = $us_id;
@@ -108,16 +102,19 @@
 				$smslog['created_time'] = $receiveTime;
 				$this->db->insert('tblsmslog', $smslog);
-				$sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan Soan Bai giang Online.
-					Hay dang nhap vao http://soanbaigiang.smas.vn/ voi ten truy nhap ".$username.", mat khau ".$password." de su dung.";
-				return $sms;
-			case 2:
-				$sms = "Tai khoan cua Qui vi da duoc dang ky !";			
-				return $sms;
+				$sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan Soan Bai giang Online. Hay dang nhap vao soanbaigiang.smas.vn voi ten truy nhap ".$username.", mat khau ".$password." de su dung.";
+				$status = 1;
+				break;
+			case 2:				
 			case 4:
 				$sms = "So dien thoai cá»§a Qui vi da duoc dang ky !";
-				return $sms;
+				$status = 0;
+				break;
 			default:
+				$status = 0;
+				$sms = $errMsg;
 				break;
 		}
+		
+		return $status.'|'.$sms;
 	}
 	
Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 459)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 460)
@@ -18,4 +18,5 @@
 	public function testmo() {
 		$url = 'http://10.58.38.162/violetservice/soanbai/mo';
+		//$url = 'http://10.58.38.162/services/viettel';
 		//$url = 'http://viettel.violet.vn/violetservice/soanbai/mo';
 		$aryParams = array(
@@ -42,5 +43,4 @@
 		$client->operation = $operation;
 		$result = $client->send($this->_xmlHeader.$xml, $operation);		
-		
 		//$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
 		
@@ -102,5 +102,4 @@
 	public function topup () 
 	{
-		$url = $this->config->item('topup_service_url');
 		$operator = 'TopupService';
 		$operation = 'http://tempuri.org/ITopupService/TopUp';
Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php	(revision 459)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php	(revision 460)
@@ -31,4 +31,5 @@
 						'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
 						'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
+						'contentType'=>array('name'=>'contentType', 'type'=>'xsd:string'),
 						'info'=>array('name'=>'info', 'type'=>'xsd:string'),
 						'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
@@ -44,4 +45,5 @@
 						'serviceID' => 'xsd:string',
 						'commandCode' => 'xsd:string',
+						'contentType' => 'xsd:string',
 						'info' => 'xsd:string',
 						'receiveTime' => 'xsd:string')
@@ -57,4 +59,9 @@
 			$_SERVER['QUERY_STRING'] = "";
 		}
+		
+		function MOReceiver () {
+			return 'Service not available!';
+		}
+		
 		$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA:'';
 		$this->nusoap_server->service($HTTP_RAW_POST_DATA);
@@ -63,5 +70,5 @@
 	public function mo() 
 	{
-		function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info,$receiveTime){
+		function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $contentType ,$info, $receiveTime){
 			$msgType = '0'; //text message
 			$errCode = '1'; //#1:error; 1:Success;
@@ -71,13 +78,4 @@
 			$mo_password = $CI->config->item('mo_password');
 
-			/* if (!isset($parameters['username'])) return '0|0|Username is required!';
-			if (!isset($parameters['password'])) return '0|0|Password is required!';
-			if ($parameters['username'] != $mo_username) return '0|0|Username is not corrected!'.var_export($parameters, true);
-			if ($parameters['password'] != $mo_password) return '0|0|Password is not corrected!';
-			if (!isset($parameters['userID'])) return '0|0|UserID is required!';
-			if (!isset($parameters['userID'])) return '0|0|UserID is required!';
-			if (!isset($parameters['serviceID'])) return '0|0|serviceID is required!';
-			if ($parameters['serviceID'] != '8062') return '0|0|serviceID is not corrected!'; */
-			
 			if (!$username) return '0|0|Username is required!';
 			if (!$password) return '0|0|Password is required!';
@@ -88,17 +86,21 @@
 			if (!$serviceID) return '0|0|serviceID is required!';
 			if ($serviceID != '8062') return '0|0|serviceID is not corrected!';
-						
+			
+			$status = 0;
 			$sentNumber = $userID;									
 			$username = !$receiverID ? $sentNumber : $receiverID;
 			
 			$CI->load->model('frontend/user_model', 'userModel');
-			$password = $CI->userModel->create_random_password();
-			$sms = "Chuc mung Qui vi da dang ky thanh cong tai khoan SBGOnline. Hay dang nhap vao http://soanbaigiang.smas.vn/ voi ten truy nhap ".$username.", mat khau ".$password." de su dung.";			
-			//$msg = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status);
+			$password = $CI->userModel->create_random_password();		
 			
-			//return $status.'|'.$msgType.'|'.$msg;
-
-			//for dummy data
-			return '1|0|'.$sms;
+			$result = $CI->userModel->register ($sentNumber, $receiverID, $serviceID, $commandCode, $info, $receiveTime, $status);
+			$aryAgrs = func_get_args ();
+			$fh = fopen('register.log', 'a+');
+			fwrite ($fh, var_export($aryAgrs, true). "\n");
+			fclose($fh);
+			
+			$aryResult = explode ('|', $result);
+			
+			return $aryResult[0].'|'.$msgType.'|'.$aryResult[1];
 		}
 		
Index: pro-violet-viettel/sourcecode/application/modules/services/views/mo.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/views/mo.php	(revision 459)
+++ pro-violet-viettel/sourcecode/application/modules/services/views/mo.php	(revision 460)
@@ -5,11 +5,11 @@
       <password>sbg571285</password>    
       <requestID>4</requestID>
-      <userID>841662860000</userID>
-      <receiveID>84988568786</receiveID>
+      <userID>841695061706</userID>
+      <receiverID>841695061706</receiverID>
       <serviceID>8062</serviceID>
       <commandCode>SBG</commandCode>
       <contentType>0</contentType>
       <info>SBG DK</info>
-      <receiveTime><?php echo date('Ymd H:i:s') ?></receiveTime>
+      <receiveTime><?php echo date('Y-m-d H:i:s') ?></receiveTime>
     </MOReceiver>
   </soap:Body>
