Index: pro-violet-viettel/sourcecode/application/language/message/messages_lang.php
===================================================================
--- pro-violet-viettel/sourcecode/application/language/message/messages_lang.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/language/message/messages_lang.php	(revision 707)
@@ -77,5 +77,5 @@
 $lang['_SBG_MO_PAY_TO_ACCOUNT_SUCCESS_MSG'] = 'Ban da nap thanh cong :amount:d vao tai khoan cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).';
 $lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_MSG'] = 'Ban da duoc nap :amount:d vao tai khoan cua DV Soan bai giang Online tu so dien thoai :sentNumber:. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_OTHER_SUCCESS_MSG'] = ' Ban da nap thanh cong :amount:d vao tai khoan :username: cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).';
+$lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_OTHER_SUCCESS_MSG'] = 'Ban da nap thanh cong :amount:d vao tai khoan :username: cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).';
 $lang['_SBG_MO_ACCOUNT_NOT_FOUND_MSG'] = 'So thue bao :username: chua dang ky DV Soan bai giang Online. De dang ky, soan SBG DK gui 8062 (500d/tin). Chi tiet soan SBG HD gui 8062 (500d/tin) hoac LH 01662860000 (cuoc goi di dong).';
 $lang['_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_MSG'] = 'Tai khoan cua ban khong du de thuc hien nap :amount: vao tai khoan cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).:amount: ';
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/home.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/home.php	(revision 707)
@@ -47,5 +47,6 @@
 
     public function logout() {
-        $this->session->sess_destroy();
+        //$this->session->sess_destroy();
+		$this->session->unset_userdata('adminInfo');
         redirect("/admin/home");
     }
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 707)
@@ -63,4 +63,5 @@
 			parse_str ( $result['data'] );
 			$is_viettel = $this->is_viettel ( $phone );
+			
 			if ($autologin == 1) {
 				$cookie_name = 'siteCookie';
@@ -69,4 +70,5 @@
 				setcookie ( $cookie_name, 'username=' . $username . '&user=' . $result['data'] . '&us_id=' . $id, time () + $cookie_time );
 			}
+
 			$userdata = array (
 					'username' => $username,
@@ -82,6 +84,7 @@
 	
 	public function signout() {
-		$this->session->sess_destroy ();
+		//$this->session->sess_destroy ();
 		// unset($this->session->userdata);
+		$this->session->unset_userdata('userInfo');
 		$cookie_name = "siteCookie";
 		setcookie ( $cookie_name, 'username=' . "", time () - 3600 );
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 707)
@@ -17,4 +17,5 @@
     public function profile() {
         $user_info = $this->session->userdata('userInfo');
+
         if ($user_info) {
             $this->load->model('User_model');
Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 707)
@@ -103,6 +103,6 @@
 				$sms = preg_replace($aryPatterns, array($trialdays. ' ngay', $username, $password), lang('_SBG_MO_USER_REGISTER_SUCCESS_MSG'));
 				$status = 1;
-				$aryPatterns = array('/:collaborator:/');
-				$collaboratorMsg = $status . '|'. preg_replace($aryPatterns, array($collaborator), lang('_SBG_MO_COLLABOLATOR_REGISTER_SUCCESS_MSG'));
+				$aryPatterns = array('/:username:/');
+				$collaboratorMsg = $status . '|'. preg_replace($aryPatterns, array($username), lang('_SBG_MO_COLLABOLATOR_REGISTER_SUCCESS_MSG'));
 				break;
 			case 2 :
@@ -327,5 +327,5 @@
 	}
 	
-	public function registerVip($username, $p_code) {
+	public function registerVip($username, $p_code, &$packageData = null) {
 		$user = array ();
 		$sms = '';
@@ -333,4 +333,5 @@
 		$result = $this->get_user_by_cellphone ( $username );
 		$package = $this->get_package ( ( int ) $p_code );
+		
 		if (!$package)
 		{
@@ -339,6 +340,8 @@
 			return $status . '|' . $sms;
 		}
+			
+		$packageData = $package;
+
 		if ($result) {
-			
 			if ($result ['acc_balanced'] >= $package ['p_price']) {
 				$us_id = $result ['us_id'];
@@ -497,5 +500,5 @@
 		$this->db->query ( 'UNLOCK TABLES' );
 		$sql = 'INSERT INTO tblcardlog(sender, us_id, status, pin_code, serial_num, card_value, created_time) VALUES(?,?,?,?,?,?,?)';
-		$query = $this->db->query ($sql, $cardlog);
+		return $this->db->query ($sql, $cardlog);
 	}
 	
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php	(revision 707)
@@ -119,5 +119,5 @@
                                             </div>
 											<div class="col-sm-3">
-											<h4><small><a href="#" data-toggle="modal" data-target="#changeProfile"><i>Äá»i sá» Äiá»n thoáº¡i</i></a></small></h4>
+											<!--<h4><small><a href="#" data-toggle="modal" data-target="#changeProfile"><i>Äá»i sá» Äiá»n thoáº¡i</i></a></small></h4>-->
 											</div>
                                         </div>
@@ -245,6 +245,6 @@
                                         <h4 class="header blue bolder smaller">Náº¡p tiá»n báº±ng tÃ i khoáº£n gá»c</h4>
                                         <div class="alert alert-block alert-success">						
-                                            <p> 
-                                                <span <?php if(($is_viettel==1)) echo 'style="display: none;"'?> >Sá»­ dá»¥ng thuÃª bao <strong><?php echo @$username; ?></strong> soáº¡n tin nháº¯n: <strong>SBG NAP [SoTien] gá»­i 8062</strong>. </span><br/>
+                                            <p>
+                                                <span <?php if(($is_viettel==1)) /*echo 'style="display: none;"'*/{?> >Sá»­ dá»¥ng thuÃª bao <strong><?php echo @$username; ?></strong> soáº¡n tin nháº¯n: <strong>SBG NAP [SoTien] gá»­i 8062</strong>.<?php } ?> </span><br/>
                                                 Náº¿u QuÃœ vá» sá»­ dá»¥ng thuÃª bao Viettel khÃ¡c thÃ¬ soáº¡n tin nháº¯n: <strong>SBG NAP [SoTien] <?php  echo $username; ?> gá»­i tá»i 8062</strong>.
           
Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/recharge.php	(revision 707)
@@ -15,4 +15,8 @@
 	public function recharge_card()
 	{
+		$trackingFile = '/srv/www/sbg/log/recharge_card.log';
+		error_log ('--START CARD CHARGE--'."\n", 3, $trackingFile);
+		error_log ('TIME: '.date('Y-m-d H:i:s')."\n", 3, $trackingFile);
+
 		$userID = $this->uri->segment(4);
 		$input = $this->input->post();
@@ -21,4 +25,8 @@
 		$isLocked = 0;
 		
+		error_log ('$cardSerial: '.$cardSerial."\n", 3, $trackingFile);
+		error_log ('$cardSerial: '.$pinCard."\n", 3, $trackingFile);
+		error_log ('$userID: '.$userID."\n", 3, $trackingFile);
+
 		$user = $this->objUserModel->get_user_by_id($userID);
 		$lockFilePreFix = $user['cellphone'];
@@ -26,4 +34,7 @@
 		$maxReach = $this->config->item('topup_lock_max_reach');
 		$timeToUnlock = $this->config->item('topup_unlock_minute');
+
+		error_log ('Phone num: '.$user['cellphone']."\n", 3, $trackingFile);
+		error_log ('Locked: '.($isLocked ? 'LOCKED':'UNLOCKED')."\n", 3, $trackingFile);
 
 		$isLocked = createLockFile($lockFilePreFix, $maxReach, $timeToUnlock, $lockFilePath, TRUE);
@@ -56,4 +67,7 @@
 			$chargCard = $this->services_model->cardPaidProcess($aryParams,  $aryResult);
 			$status = $chargCard;
+			
+			error_log ('CALL TOPUP SERVICE: '.($status ? 'SUCCESS':'NOT SUCCESS')."\n", 3, $trackingFile);
+			error_log ('CALL TOPUP SERVICE DATA: '.var_export($aryResult, TRUE)."\n", 3, $trackingFile);
 
 			$paidType = 2;
@@ -66,4 +80,5 @@
 				$updateData = array('acc_balanced' => $user['acc_balanced'], 'updated_time' => $user['updated_time'] );
 				$updated = $this->objUserModel->updateUser($userID, $updateData);
+				error_log ('UPDATE ACCOUNT SUCCESS: '.($updated ? 'SUCCESS':'NOT SUCCESS')."\n", 3, $trackingFile);
 			}
 			
@@ -76,5 +91,6 @@
 				$aryPatterns = array('/:amount:/', '/:username:/', '/:acc_balanced:/');
 				$result['message'] = preg_replace($aryPatterns, array($amount, $user['cellphone'], $user['acc_balanced']), lang('_SBG_CHARGING_FROM_CARD_SUCCESS_MSG'));
-				$this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
+				$paidResult = $this->objUserModel->insertPaidlog($user['cellphone'], $user['cellphone'], $paidType, $amount, $paidTime);
+				error_log ('INSERT PAID LOG: '.var_export($paidResult, TRUE)."\n", 3, $trackingFile);
 				releaseLockFile($lockFilePreFix, $lockFilePath);
 			}
@@ -89,10 +105,13 @@
 		}
 
-		$this->objUserModel->insertCardlog($user['cellphone'],$userID, $status, $pinCard, $cardSerial, $cardValue, $updatedTime);
-		
+		$cardLogResult = $this->objUserModel->insertCardlog($user['cellphone'],$userID, $status, $pinCard, $cardSerial, $cardValue, $updatedTime);
+		error_log ('INSERT CARD LOG: '.var_export($cardLogResult, TRUE)."\n", 3, $trackingFile);
+	
 		$result['us_id'] = $userID;
 		$result['UPDATED_DATA'] = $user;
 		$result['errMsg'] = $errMsg;
 		echo json_encode($result);
+		error_log ('RETURN JSON: '.json_encode($result)."\n", 3, $trackingFile);
+		error_log ('--FINISH CARD CHARGE--'."\n", 3, $trackingFile);
 	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 707)
@@ -43,5 +43,5 @@
 		_SBG_MO_REGISTER 			=> array('pattern' => '/^(SBG)([[:blank:]])(DK)$/'),
 		_SBG_MO_REGISTER_FOR 		=> array('pattern' => '/^(SBG)([[:blank:]])(DK)([[:blank:]])([0-9]{10,11})$/'),
-		_SBG_MO_PHONENUM_CHANGE 	=> array('pattern' => '/^(SBG)([[:blank:]])(DDT)([[:blank:]])([0-9]{10,11})([[:blank:]])([a-zA-Z0-9]{1,})$/'),
+		//_SBG_MO_PHONENUM_CHANGE 	=> array('pattern' => '/^(SBG)([[:blank:]])(DDT)([[:blank:]])([0-9]{10,11})([[:blank:]])([a-zA-Z0-9]{1,})$/'),
 		_SBG_MO_PASSWORD_RECOVERY 	=> array('pattern' => '/^(SBG)([[:blank:]])(MK)$/'),
 		_SBG_MO_VIP_REGISTER 		=> array('pattern' => '/^(SBG)([[:blank:]])(VIP)([[:blank:]])([a-zA-Z0-9]{1,})$/'),
@@ -87,5 +87,5 @@
 		}
 		
-		return array('case' => $case, 'content' => $aryContent);;
+		return array('case' => $case, 'content' => $aryContent);
 	}
 	
@@ -127,4 +127,5 @@
 				
 				$sms = $this->objUserModel->register($userName, $collaborator, $collaboratorMsg);
+				
 				if ($case == _SBG_MO_REGISTER_FOR) {
 					$smsReturn = $collaboratorMsg;
@@ -136,4 +137,5 @@
 					$smsReturn = $sms;
 				}
+
 				break;
 			case _SBG_MO_PHONENUM_CHANGE:
@@ -158,10 +160,32 @@
 				break;
 			case _SBG_MO_VIP_REGISTER:
+				$packageData = array();
 				$p_code = $aryContents[0];
-				$smsReturn = $this->objUserModel->registerVip($sentNumber, $p_code);
-				$this->objUserModel->insertRegisterVipLog($sentNumber, $p_code, true);
-				break;
+				$smsReturn = $this->objUserModel->registerVip($sentNumber, $p_code, $packageData);
+				
+				$arySmsReturn = explode('|', $smsReturn);
+				$result = $arySmsReturn[0];
+
+				if (trim($arySmsReturn[1]) == trim(lang('_SBG_MO_USER_REGISTER_VIP_FAIL_NOT_ENOUGH_MSG'))) {
+					
+					$amount = $packageData ['p_price'];
+					$result = $this->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG');
+
+					if ($result == _SBG_CHARGING_SUCCESS) {
+						$this->objUserModel->rechargeAccount($sentNumber, $amount);
+						$smsReturn = $this->objUserModel->registerVip($sentNumber, $p_code, $packageData);
+						
+						$paidTime = date('Y-m-d H:i:s');
+						$this->objUserModel->insertPaidlog($sentNumber, $sentNumber, _SBG_PAIDTYPE_SMS, $amount, $paidTime);
+						$result = 1;
+					}
+				}
+
+				if ((int)$result == 1) $this->objUserModel->insertRegisterVipLog($sentNumber, $p_code, true);
+				break;
+
 			case _SBG_MO_PAY_TO_ACCOUNT:
 			case _SBG_MO_PAY_TO_ACCOUNT_FOR:
+
 				$userName = isset($aryContents[1]) ? $this->formatPhoneNumber($aryContents[1]) : $sentNumber;
 				
@@ -186,6 +210,6 @@
 						$smsMT = preg_replace($aryPatterns, array($amount, $sentNumber), lang('_SBG_MO_PAY_TO_ACCOUNT_FOR_MSG'));
 						$sendMT = $this->sendMT($this->formatPhoneNumber($userName, -1), $smsMT);
+						$smsReturn = $arySmsReturn[0].'|'.preg_replace(array('/:amount:/','/:username:/'), array($amount, $userName), lang('_SBG_MO_PAY_TO_ACCOUNT_FOR_OTHER_SUCCESS_MSG'));
 					}
-					
 					//write to paid log
 					$paidTime = date('Y-m-d H:i:s');
@@ -290,5 +314,5 @@
 				'Contents' => $contents
 		);
-		
+
 		$xml = $this->load->view('charging', $aryParams, true);
 		$client = new nusoap_client($url);
Index: pro-violet-viettel/sourcecode/application/views/layout/admin/sidebar.php
===================================================================
--- pro-violet-viettel/sourcecode/application/views/layout/admin/sidebar.php	(revision 706)
+++ pro-violet-viettel/sourcecode/application/views/layout/admin/sidebar.php	(revision 707)
@@ -122,5 +122,5 @@
 									<a href="<?php echo $base_url; ?>admin/reportprovince">
 										<i class="icon-double-angle-right"></i>
-										Thá»ng kÃª doanh thu
+										BÃ¡o cÃ¡o thuÃª bao theo tá»nh
 									</a>
 								</li>
@@ -128,5 +128,5 @@
 									<a href="<?php echo $base_url; ?>admin/reportpackage">
 										<i class="icon-double-angle-right"></i>
-										Thá»ng kÃª doanh thu gÃ³i
+										BÃ¡o cÃ¡o doanh thu theo tá»nh
 									</a>
 								</li>
