Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 632)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 633)
@@ -47,50 +47,32 @@
 				'user_model' 
 		) );
-		$data = $this->user_model->checkLogin ( $src, $token, $username, $password );
-		
-		if ($data == null) {
+		$result = $this->user_model->checkLogin ( $src, $token, $username, $password );
+		if ($result['success'] == -1)
+		{
+			$this->session->set_flashdata ( 'login_api_error', TRUE );
+			redirect ( '/frontend/home' );
+			
+		}else if ($result['success'] == 0)
+		{
 			$this->session->set_flashdata ( 'login_error', TRUE );
 			redirect ( '/frontend/home' );
-		} else {
-			parse_str ( $data );
+		}else{
+			parse_str ( $result['data'] );
 			$is_viettel = $this->is_viettel ( $phone );
-			switch ($status) {
-				case 0 :
-				case 4 :
-					
-					if ($autologin == 1) {
-						$cookie_name = 'siteCookie';
-						// $cookie_time = 7200;
-						$cookie_time = 3600 * 24 * 30;
-						setcookie ( $cookie_name, 'username=' . $username . '&user=' . $data . '&us_id=' . $id, time () + $cookie_time );
-					}
-					$userdata = array (
-							'username' => $username,
-							'user' => $data,
-							'us_id' => $id,
-							'logined_in' => TRUE,
-							'is_viettel' => $is_viettel 
-					);
-					$this->session->set_userdata ( 'userInfo', $userdata );
-					redirect ( '/frontend/lecture' );
-					break;
-				case 1 :
-					$this->session->set_flashdata ( 'login_error', TRUE );
-					redirect ( '/frontend/home' );
-					break;
-				case 2 :
-				case 3 :
-					$this->session->set_flashdata ( 'login_error', TRUE );
-					redirect ( '/frontend/home' );
-					break;
-				// case 4:
-				// redirect('/frontend/home');
-				case 10 :
-					$this->session->set_flashdata ( 'login_error_token', TRUE );
-					redirect ( '/frontend/home' );
-					break;
-				default :
-					break;
+			if ($autologin == 1) {
+				$cookie_name = 'siteCookie';
+				// $cookie_time = 7200;
+				$cookie_time = 3600 * 24 * 30;
+				setcookie ( $cookie_name, 'username=' . $username . '&user=' . $result['data'] . '&us_id=' . $id, time () + $cookie_time );
 			}
+			$userdata = array (
+					'username' => $username,
+					'user' => $result['data'],
+					'us_id' => $id,
+					'logined_in' => TRUE,
+					'is_viettel' => $is_viettel 
+			);
+			$this->session->set_userdata ( 'userInfo', $userdata );
+			redirect ( '/frontend/lecture' );
 		}
 	}
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 632)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 633)
@@ -129,4 +129,7 @@
         $result['expire_date'] = $user['expire_date'];
         $result['success'] = 1;
+		$source = 'web';
+		$toDate = date("Y-m-d", (strtotime($result['expire_date'])));
+		$this->user_model->insertRegisterVipLog($source,  $package['p_code'], $toDate);
         echo json_encode($result);
     }
@@ -156,4 +159,6 @@
 
             $this->user_model->updateUser($us_id, $user);
+			$source = 'web';
+			$this->user_model->insertRegisterVipLog($source,  $package['p_code']);
             $message = 'QuÃœ vá» ÄÃ£ ÄÄng kÃ­ sá»­ dá»¥ng CÃŽng cá»¥ Soáº¡n BÃ i giáº£ng trá»©c tuyáº¿n. QuÃœ vá» ÄÆ°á»£c sá»­ dá»¥ng dá»ch vá»¥ Äáº¿n háº¿t ngÃ y ' . date('d-m-Y', strtotime($user['expire_date']));
         }
Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 632)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 633)
@@ -23,38 +23,8 @@
 				'password' => $password 
 		), 'user' );
-		
-		$arr_users = explode ( "&", $data );
-		$str_status = '';
-		$str_fullname = '';
-		$str_usid = '';
-		$usid = '';
-		$fullname = '';
-		
-		for($i = 0; $i < count ( $arr_users ); $i ++) {
-			if (strpos ( $arr_users [$i], 'status=' ) !== false) {
-				$str_status = $arr_users [$i];
-			}
-			
-			if (strpos ( $arr_users [$i], 'fullname=' ) !== false) {
-				$str_fullname = $arr_users [$i];
-			}
-			
-			if (strpos ( $arr_users [$i], 'id=' ) !== false) {
-				$str_usid = $arr_users [$i];
-			}
-		}
-		$arr_status = explode ( "=", $str_status );
-		if ($str_fullname != '') {
-			$arr_fullname = explode ( "=", $str_fullname );
-			$fullname = $arr_fullname [1];
-		}
-		if ($str_usid !== '') {
-			$arr_usid = explode ( "=", $str_usid );
-			$usid = $arr_usid [1];
-		}
-		$status = ( int ) $arr_status [1];
-		
+		if(!($data) || is_null($data)) return array('success'=>-1, 'data'=>$data);
+		parse_str ( $data );
 		if ($status == 0 || $status == 4) {
-			$us_id = ( int ) $usid;
+			$us_id = ( int ) $id;
 			$query = "SELECT * FROM tbluser WHERE us_id = ?";
 			$result = $this->db->query ( $query, array (
@@ -62,10 +32,10 @@
 			) );
 			if ($result->num_rows () == 1) {
-				return $data;
+				return array('success'=>1, 'data'=>$data);
 			} else {
-				return null;
+				return array('success'=>0, 'data'=>$data);
 			}
 		} else {
-			return $data;
+			return array('success'=>0, 'data'=>$data);
 		}
 	}
@@ -527,3 +497,14 @@
 		if(md5($password) == $pencrypted) return true; else return false;
 	}
+	
+	public function insertRegisterVipLog($source, $p_code)
+	{
+		$createdTime = date('Y-m-d H:i:s');
+		$sql = 'INSERT INTO tblregisterpackagelog (source, p_code, created_time) VALUES (?,?,?)';
+		$query = $this->db->query ( $sql,  array (
+				'source'=>$source,
+				'p_code'=>$p_code,
+				'created_time'=>$createdTime
+		) );
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/home.php	(revision 632)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/home.php	(revision 633)
@@ -68,4 +68,7 @@
 																echo 'ThÃŽng tin ÄÄng nháº­p khÃŽng chÃ­nh xÃ¡c!';
 															}
+															if($this->session->flashdata('login_api_error')){
+																echo 'Táº¡m thá»i báº¡n khÃŽng thá» ÄÄng nháº­p ÄÆ°á»£c !';
+															}
 														?>
 														</div>
