Index: /pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 908)
+++ /pro-violet-viettel/sourcecode/application/modules/services/controllers/sendmessage.php	(revision 909)
@@ -2,19 +2,19 @@
 /**
  * Viettel Class
- * 
+ *
  * @author dzungnv02
  *
  */
 
-class Sendmessage extends MX_Controller 
+class Sendmessage extends MX_Controller
 {
 	private $_xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
-		
-	public function __construct() 
+
+	public function __construct()
 	{
 		parent::__construct();
 	}
-	
-	public function index () 
+
+	public function index ()
 	{
 		error_reporting(E_ALL);
@@ -29,5 +29,5 @@
 		echo $this->Services_model->cardPaidProcess($aryParams);
 	}
-	
+
 	public function testmo() {
 		$url = 'http://10.58.38.162/violetservice/soanbai/mo?wsdl';
@@ -45,9 +45,9 @@
 				'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';
@@ -55,22 +55,22 @@
 		$client->soap_defencoding = 'UTF-8';
 		$client->operation = $operation;
-		$result = $client->send($this->_xmlHeader.$xml, $operation);		
+		$result = $client->send($this->_xmlHeader.$xml, $operation);
 		//$result = $client->call('MOReceiver', $aryParams ,$operator ,$operation);
-		
+
 		echo $client->responseData;
-		
+
 		/* $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>"; */		
-	}
-	
+
+		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, $receiverID)
 	{
@@ -80,10 +80,10 @@
 		$operator = 'InsertMT';
 		$operation = 'http://tempuri.org/InsertMT';
-		
+
 		$aryMatch = array();
 		if (preg_match('/^(0)([0-9]{9,10})$/', $receiverID, $aryMatch) == 1) {
 			$receiverID = '84'. $aryMatch[2];
 		}
-		
+
 		$aryParams = array(
 				'User' => $username,
@@ -98,5 +98,5 @@
 				'Info' => urldecode($msg).' - Host: '.$_SERVER['HTTP_HOST'].' - '. date('Y-m-d H:i:s')//'Test MT '. date('Y-m-d H:i:s'),
 		);
-	
+
 		$xml = $this->load->view('mt', $aryParams, true);
 		$client = new nusoap_client($url);
@@ -104,14 +104,14 @@
 		$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>';
 		}
-		
+
 		var_dump($result);
-		
+
 		echo "<br/>";
 		echo "<h2>Request</h2>";
@@ -119,19 +119,19 @@
 		echo "<h2>Response</h2>";
 		echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
-	
-	}
-	
-	public function topup () 
+
+	}
+
+	public function topup ()
 	{
 		$url = $this->config->item('topup_service_url');
-		
+
 		//echo file_get_contents($url);
 		//exit();
-		
+
 		$operation = 'http://tempuri.org/ITopupService/TopUp';
-		
+
 		$username = 'sbg';
 		$password = 'sbg56ab77cdsgb';
-		
+
 		$aryParams = array(
 			'EWalletID' => 0,
@@ -144,8 +144,8 @@
 		$client->soap_defencoding = 'UTF-8';
 		$client->operation = $operation;
-		
+
 		$result = $client->send($this->_xmlHeader.$xml, $operation);
 		$err = $client->getError();
-		
+
 		if ($client->fault) {
 		    echo "<h2>Fault loi:</h2><pre>";
@@ -169,17 +169,65 @@
 		echo "<h2>Response</h2>";
 		echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
-		
-	}
-	
-	public function charging ()
-	{
+
+	}
+
+	public function chargingws ()
+	{
+		//$op = $this->input->get('op', TRUE);
+		//$op = trim($op) == '' ? 'Balance' : 'processCharging';
 		$url = $this->config->item('charging_service_url');
-		
+		$content = file_get_contents ($url.'?op=Charge');
+		header('Content-Type: text/html; charset=utf-8');
+		echo $content;
+	}
+
+	public function getBalance()
+	{
+		//GetAmountBalance
+		$url = $this->config->item('charging_service_url');
+
 		$username = $this->config->item('charging_username');
 		$password = $this->config->item('charging_password');
-		
+		$operator = 'GetAmountBalance';
+		$operation = 'http://tempuri.org/Balance';
+
+		$aryParams = array(
+				'user' => $username,
+				'pass' => $password,
+				'MSISDN' => '01662860000',
+		);
+
+		$xml = $this->load->view('chargingBalance', $aryParams, true);
+		$client = new nusoap_client($url.'?op=Balance');
+		$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>';
+		}
+
+		var_dump($result);
+
+		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';
-		
+		$operation = 'http://tempuri.org/Charge';
+
 		$aryParams = array(
 				'user' => $username,
@@ -189,5 +237,5 @@
 				'Contents' => 'Namta-Active'
 		);
-		
+
 		$xml = $this->load->view('charging', $aryParams, true);
 		$client = new nusoap_client($url);
@@ -195,21 +243,21 @@
 		$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>';
 		}
-		
+
 		var_dump($result);
-		
-		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>";		
-	}
-	
+
+		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 getCollaborators () {
 		$client = new SoapClient($this->config->item('bccs_service_url'), array(  'trace'      => true,
@@ -219,8 +267,8 @@
 		$password = $this->config->item('bccs_password');
 		$wscode = 'getListShopAndStaftInfo';
-		
+
 		$input = new Input($username, $password, $wscode/* , 2, 1,5000 */);
 		$param = new Param();
-		
+
 		$params = array(
 				"Input" => $input,
@@ -228,5 +276,5 @@
 				"Param" => $param,
 		);
-		
+
 		var_dump($params);
 
@@ -234,6 +282,6 @@
 		var_dump($response);
 	}
-	
-	
+
+
 }
 
Index: /pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 908)
+++ /pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 909)
@@ -177,13 +177,6 @@
 
 				if (trim($arySmsReturn[1]) == trim(lang('_SBG_MO_USER_REGISTER_VIP_FAIL_NOT_ENOUGH_MSG'))) {
-					$maxCharging = 50000;
 					$amount = $packageData ['p_price'];
-					$count = $amount > $maxCharging ? ceil($amount/ _SBG_CHARGING_MAX_VALUE) : 1;
-					$value = 0;
-					for ($i = 1; $i <= $count; $i++) {
-						$value = $amount > _SBG_CHARGING_MAX_VALUE ? _SBG_CHARGING_MAX_VALUE : $amount;
-						$amount -= $value;
-						$result = $this->chargeRootAccountProcess($sentNumber, $value, $sentNumber.' paid for SBG');
-					}
+					$result = $this->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG');
 
 					if ($result == _SBG_CHARGING_SUCCESS) {
@@ -243,11 +236,7 @@
 				}
 				else if ($result == _SBG_CHARGING_FAIL_MORETHAN_LIMIT) {
-					/* $aryPatterns = array ('/:sendid:/');
+					$aryPatterns = array ('/:sendid:/');
 					$smsReturn = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_CHARGING_FAIL_MORETHAN_LIMIT_MSG'));
-					$smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn; */
-
-
-
-
+					$smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn;
 				}else if ($result == _SBG_CHARGING_FAIL_NOT_VIETTEL || $result == _SBG_CHARGING_NUMBER_NOT_EXISTED || $result == _SBG_CHARGING_NUMBER_NOT_AVAILABLE) {
 					$smsReturn = _SBG_MO_PROCCESS_ERR.'|'.lang('_SBG_MO_CHARGING_FAIL_NOT_VIETTEL_MSG');
@@ -265,9 +254,9 @@
 				}
 				break;
-				
+
 			case _SBG_MO_PASSWORD_COLLABORATOR_SERVICE:
 				$smsReturn = $this->objCollaboratorModel->getPassword($sentNumber);
 				break;
-			
+
 			case _SBG_MO_UNSUBSCRIBE_SERVICE:
 			case _SBG_MO_SYNTAX_ERR:
@@ -339,5 +328,5 @@
 		$username = $this->config->item('charging_username');
 		$password = $this->config->item('charging_password');
-		$action = 'http://tempuri.org/processCharging';
+		$action = 'http://tempuri.org/Charge';
 
 		$aryParams = array(
@@ -355,4 +344,8 @@
 		$client->operation = $action;
 		$result = $client->send($xml, $action);
+
+		error_log(date('Y-m-d H:i:s').' -- DATA: '. var_export($xml, TRUE).' -- CASE: '. $case . "\n", 3, '/srv/www/sbg/log/chargeresult.log');
+		error_log(date('Y-m-d H:i:s').' -- DATA: '. var_export($result, TRUE).' -- CASE: '. $case . "\n", 3, '/srv/www/sbg/log/chargeresult.log');
+
 		if ($client->fault) {
 			return _SBG_CHARGING_FAIL;
Index: /pro-violet-viettel/sourcecode/application/modules/services/views/charging.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/services/views/charging.php	(revision 908)
+++ /pro-violet-viettel/sourcecode/application/modules/services/views/charging.php	(revision 909)
@@ -1,5 +1,5 @@
 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
-    <processCharging xmlns="http://tempuri.org/">
+    <Charge xmlns="http://tempuri.org/">
       <user><?php echo $user?></user>
       <pass><?php echo $pass?></pass>
@@ -7,5 +7,5 @@
       <Charging><?php echo $Charging?></Charging>
       <Contents><?php echo $Contents?></Contents>
-    </processCharging>
+    </Charge>
   </soap:Body>
 </soap:Envelope>
Index: /pro-violet-viettel/sourcecode/application/modules/services/views/chargingBalance.php
===================================================================
--- /pro-violet-viettel/sourcecode/application/modules/services/views/chargingBalance.php	(revision 909)
+++ /pro-violet-viettel/sourcecode/application/modules/services/views/chargingBalance.php	(revision 909)
@@ -0,0 +1,9 @@
+<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+  <soap:Body>
+    <Balance xmlns="http://tempuri.org/">
+      <user><?php echo $user?></user>
+      <pass><?php echo $pass?></pass>
+      <MSISDN><?php echo $MSISDN?></MSISDN>
+    </Balance>
+  </soap:Body>
+</soap:Envelope>
