Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 443)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 457)
@@ -9,5 +9,6 @@
 class Sendmessage extends MX_Controller 
 {
-	
+	private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
+		
 	public function __construct() 
 	{
@@ -15,5 +16,47 @@
 	}
 	
-	public function send()
+	public function testmo() {
+		$url = 'http://10.58.38.162/violetservice/soanbai/mo';
+		//$url = 'http://viettel.violet.vn/violetservice/soanbai/mo';
+		$aryParams = array(
+				'username' => 'sbg',
+				'password' => 'sbg571285',
+				'requestID' => '4',
+				'userID' => '841662860000',
+				'receiverID' => '84988568786',
+				'serviceID' => '8062',
+				'commandCode' => 'SBG',
+				'contentType' => '0',
+				'info' => 'SBG DK',
+				'receiveTime' => date('Ymd H:i:s')
+		);
+		
+		$client = new nusoap_client($url, false);
+		$client->useHTTPPersistentConnection();
+		$xml = $this->load->view('mo', null, true);
+		
+		$operator = 'MOReceiver';
+		$operation = 'http://tempuri.org/MOReceiver';
+
+		$client->soap_defencoding = 'UTF-8';
+		$client->operation = $operation;
+		$result = $client->send($this->_xmlHeader.$xml, $operation);		
+		
+		//$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
+		
+		$err = $client->getError();
+			
+		if ($err) {
+			echo '<p><b>Error: ' . $err . '</b></p>';
+		}
+		
+		echo "<br/>";
+		echo "<h2>Request</h2>";
+		echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
+		echo "<h2>Response</h2>";
+		echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";		
+	}
+	
+	public function send($msg)
 	{
 		$url = $this->config->item('mt_service_url');
@@ -22,6 +65,5 @@
 		$operator = 'InsertMT';
 		$operation = 'http://tempuri.org/InsertMT';
-		$xmlHeader = '<?xml version="1.0" encoding="utf-8" ?>'."\n";
-	
+			
 		$aryParams = array(
 				'User' => $username,
@@ -34,5 +76,5 @@
 				'CommandCode' => 'SBG',
 				'ContentType' => '0',
-				'Info' => 'SMS test! - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
+				'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
 		);
 	
@@ -43,5 +85,5 @@
 		$client->operation = $operation;
 	
-		$result = $client->send($xmlHeader.$xml, $operation);
+		$result = $client->send($this->_xmlHeader.$xml, $operation);
 		$err = $client->getError();
 			
@@ -56,4 +98,77 @@
 		echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
 	
-	}	
+	}
+	
+	public function topup () 
+	{
+		$url = $this->config->item('topup_service_url');
+		$operator = 'TopupService';
+		$operation = 'http://tempuri.org/ITopupService/TopUp';
+		
+		$username = 'sbg';
+		$password = 'sbg56ab77cdsgb';
+		
+		$aryParams = array(
+			'EWalletID' => 0,
+			'CardSerial' => '11111',
+			'PinCard' => 'eeeeeeeee'
+		);
+		
+		$xml = $this->load->view('topup', $aryParams, true);
+		$client = new nusoap_client($url);
+		$client->useHTTPPersistentConnection();
+		$client->soap_defencoding = 'UTF-8';
+		$client->operation = $operation;
+		
+		$result = $client->send($this->_xmlHeader.$xml, $operation);
+		$err = $client->getError();
+			
+		if ($err) {
+			echo '<p><b>Error: ' . $err . '</b></p>';
+		}
+		
+		echo "<br/>";
+		echo "<h2>Request</h2>";
+		echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
+		echo "<h2>Response</h2>";
+		echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";		
+	}
+	
+	public function charging ()
+	{
+		$url = $this->config->item('charging_service_url');
+		
+		$username = $this->config->item('charging_username');
+		$password = $this->config->item('charging_password');
+		
+		$operator = 'processCharging';
+		$operation = 'http://tempuri.org/processCharging';
+		
+		$aryParams = array(
+				'user' => $username,
+				'pass' => $password,
+				'MSISDN' => '1689925260',
+				'Charging' => '100',
+				'Contents' => 'Namta-Active'
+		);
+		
+		$xml = $this->load->view('charging', $aryParams, true);
+		$client = new nusoap_client($url);
+		$client->useHTTPPersistentConnection();
+		$client->soap_defencoding = 'UTF-8';
+		$client->operation = $operation;
+		
+		$result = $client->send($this->_xmlHeader.$xml, $operation);
+		$err = $client->getError();
+			
+		if ($err) {
+			echo '<p><b>Error: ' . $err . '</b></p>';
+		}
+		
+		echo "<br/>";
+		echo "<h2>Request</h2>";
+		echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
+		echo "<h2>Response</h2>";
+		echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";		
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php	(revision 443)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/viettel.php	(revision 457)
@@ -10,48 +10,101 @@
 {
 	
-	public function __construct() 
-	{
-		parent::__construct();
+	function __construct() {
+		parent::__construct ();
+		$this->nusoap_server = new soap_server ();
+		$this->nusoap_server->configureWSDL('messageReceiver', 'urn:messageReceiver');
+		$this->nusoap_server->soap_defencoding = 'UTF-8';
+		$this->nusoap_server->methodreturnisliteral=TRUE;
+		
+		$this->nusoap_server->wsdl->addComplexType(
+				'messageReceiver',
+				'simpleType',
+				'struct',
+				'',
+				'SOAP-ENC:Array',
+				array(
+						'username'=>array('name'=>'username', 'type'=>'xsd:string'),
+						'password'=>array('name'=>'password', 'type'=>'xsd:string'),
+						'requestID'=>array('name'=>'requestID', 'type'=>'xsd:string'),
+						'userID'=>array('name'=>'userID', 'type'=>'xsd:string'),
+						'receiverID'=>array('name'=>'receiverID', 'type'=>'xsd:string'),
+						'serviceID'=>array('name'=>'serviceID', 'type'=>'xsd:string'),
+						'commandCode'=>array('name'=>'commandCode', 'type'=>'xsd:string'),
+						'info'=>array('name'=>'info', 'type'=>'xsd:string'),
+						'receiveTime'=>array('name'=>'receiveTime', 'type'=>'xsd:string')
+				)
+		);
+		
+		$this->nusoap_server->register ( 'MOReceiver', 
+				array( 'username' => 'xsd:string',
+						'password' => 'xsd:string',
+						'requestID' => 'xsd:string',
+						'userID' => 'xsd:string',
+						'receiverID' => 'xsd:string',
+						'serviceID' => 'xsd:string',
+						'commandCode' => 'xsd:string',
+						'info' => 'xsd:string',
+						'receiveTime' => 'xsd:string')
+				, array ('return' => 'xsd:string'),false,false
+				,'rpc'				
+				);
 	}
 
-	public function index() 
-	{
-		$this->load->view ( 'main');
+	function index() {
+		if($this->uri->segment(3) == "wsdl") {
+			$_SERVER['QUERY_STRING'] = "wsdl";
+		} else {
+			$_SERVER['QUERY_STRING'] = "";
+		}
+		$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA:'';
+		$this->nusoap_server->service($HTTP_RAW_POST_DATA);
 	}
 	
 	public function mo() 
 	{
-		$aryParams = array();
-		$aryParamsName = array(	'username',
-								'password',
-								'requestID',
-								'userID',
-								'receiverID',
-								'serviceID',
-								'commandCode',
-								'info',
-								'receiveTime');
-		
-		foreach ($aryParams as $key => $value) {
-			$aryParams[$value] =  $this->input->post($value,TRUE);
+		function MOReceiver($username, $password, $requestID, $userID, $receiverID, $serviceID, $commandCode, $info,$receiveTime){
+			$msgType = '0'; //text message
+			$errCode = '1'; //#1:error; 1:Success;
+			
+			$CI =& get_instance();			
+			$mo_username = $CI->config->item('mo_username');
+			$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!';
+			if ($username != $mo_username) return '0|0|Username is not corrected!';
+			if ($password != $mo_password) return '0|0|Password is not corrected!';
+			if (!$requestID) return '0|0|requestID is required!';
+			if (!$userID) return '0|0|UserID is required!';
+			if (!$serviceID) return '0|0|serviceID is required!';
+			if ($serviceID != '8062') return '0|0|serviceID is not corrected!';
+						
+			$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);
+			
+			//return $status.'|'.$msgType.'|'.$msg;
+
+			//for dummy data
+			return '1|0|'.$sms;
 		}
 		
-		$this->load->model('Sms_model', 'objSMS');
-		
-		$separator = '|';
-		$errCode = 1;
-		$messageType = 0;
-		$message = $this->objSMS->getSMSByServiceId();;
-		
-		header('Content-type:text/html');
-		echo $errCode,$separator,$messageType,$separator,$message;
-	}
-	
-	public function mt() 
-	{
-		
+		$this->nusoap_server->service(file_get_contents("php://input"));
 	}
 }
 
 /* End of file viettel.php */
-/* Location: ./application/modules/service/controllers/viettel.php */
+/* Location: ./application/modules/service/controllers/viettel.php */ 
