Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php	(revision 765)
@@ -1,189 +1,170 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php
 
-class User extends MX_Controller
-{
-	
+if (! defined ( 'BASEPATH' ))
+	exit ( 'No direct script access allowed' );
+
+class User extends MX_Controller {
 	const TOKENPW = 'violet';
-	
-	public function __construct()
-	{
-		parent::__construct();
-		$this->load->helper('cookie');
+	public function __construct() {
+		parent::__construct ();
+		$this->load->helper ( 'cookie' );
+		$this->load->helper('language');
+		$this->lang->load('messages', 'message');
 	}
 	
-	public function index()
-	{
-		$admin_info = $this->session->userdata('adminInfo');
-		if ($admin_info)
-		{
-			$data['content'] = $this->get_users();
-			$this->load->view('user/index', $data);
-		}else
-		{
-			$this->load->view('login');
+	public function index() {
+		$admin_info = $this->session->userdata ( 'adminInfo' );
+		if ($admin_info) {
+			$data ['content'] = $this->get_users ();
+			$this->load->view ( 'user/index', $data );
+		} else {
+			$this->load->view ( 'login' );
 		}
 	}
 	
-	public function get_users()
-	{
-		$this->load->helper('pagging');
-		$this->load->model('user_model');
-		$data['current_page'] = $this->uri->segment(4, 1);
-		$data['itemsoptions'] = array(10, 25, 50, 100);
-		$data['perpage'] = 10;
-		$data['statusoptions'] = array(0=>"Táº¥t cáº£", 1=>"ÄÃ£ ÄÄng kÃœ", 2=>"DÃ¹ng thá»­");
-		$data['status'] = 0;
-		if ($this->input->post('status')) 
-		{
-			$data['status'] = (int)$this->input->post('status') ;
+	public function get_users() {
+		$this->load->helper ( 'pagging' );
+		$this->load->model ( 'user_model' );
+		$provinces = lang('_PROVINCES_');
+		error_log(var_export($provinces, TRUE), 3, '/srv/www/sbg/log/provinces.log');
+		
+		$data ['current_page'] = $this->uri->segment ( 4, 1 );
+		$data ['itemsoptions'] = array (
+				10,
+				25,
+				50,
+				100 
+		);
+		$data ['perpage'] = 10;
+		$data ['statusoptions'] = array (
+				0 => "Táº¥t cáº£",
+				1 => "ÄÃ£ ÄÄng kÃœ",
+				2 => "DÃ¹ng thá»­" 
+		);
+		$data ['status'] = 0;
+		if ($this->input->post ( 'status' )) {
+			$data ['status'] = ( int ) $this->input->post ( 'status' );
 		}
-		$data['keyword'] = "";
-		$data['sorting_order']="sorting_desc";
-        $data['sorting_field']="created_time";
-		if ($this->input->post('sorting_order')) {
-			if ($this->input->post('sorting_order') != "sorting")
-			{
-				$data['sorting_order'] = $this->input->post('sorting_order');
-				$data['sorting_field'] = $this->input->post('sorting_field'); 
+		$data ['keyword'] = "";
+		$data ['sorting_order'] = "sorting_desc";
+		$data ['sorting_field'] = "created_time";
+		if ($this->input->post ( 'sorting_order' )) {
+			if ($this->input->post ( 'sorting_order' ) != "sorting") {
+				$data ['sorting_order'] = $this->input->post ( 'sorting_order' );
+				$data ['sorting_field'] = $this->input->post ( 'sorting_field' );
 			}
 		}
-		if ($this->input->post('items')) 
-		{
-			$data['perpage'] = $this->input->post('items');
+		if ($this->input->post ( 'items' )) {
+			$data ['perpage'] = $this->input->post ( 'items' );
 		}
-		if ($this->input->post('keyword')) {
-            $data['keyword'] = $this->input->post('keyword');
-        }
-		$data['daterange_start'] = "";
-		$data['daterange_end'] = "";
-		if ($this->input->post('daterange')){
-			$daterange = explode(" - ", $this->input->post('daterange'));
-			$daterange[0] = str_replace('/', '-', $daterange[0]);
-			$daterange[1] = str_replace('/', '-', $daterange[1]);
-			$data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
-			$data['daterange_end'] = date('Y-m-d H:is:s', strtotime($daterange[1].' + 1 day'));
+		if ($this->input->post ( 'keyword' )) {
+			$data ['keyword'] = $this->input->post ( 'keyword' );
 		}
-		$data['start'] = ($data['current_page'] - 1) * $data['perpage'];
-		$data['total'] = $this->user_model->get_total_users($data);
-		$us = $this->user_model->get_list_users($data);
-		$users = array();
+		$data ['daterange_start'] = "";
+		$data ['daterange_end'] = "";
+		if ($this->input->post ( 'daterange' )) {
+			$daterange = explode ( " - ", $this->input->post ( 'daterange' ) );
+			$daterange [0] = str_replace ( '/', '-', $daterange [0] );
+			$daterange [1] = str_replace ( '/', '-', $daterange [1] );
+			$data ['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $daterange [0] ) );
+			$data ['daterange_end'] = date ( 'Y-m-d H:is:s', strtotime ( $daterange [1] . ' + 1 day' ) );
+		}
+		$data ['start'] = ($data ['current_page'] - 1) * $data ['perpage'];
+		$data ['total'] = $this->user_model->get_total_users ( $data );
+		$us = $this->user_model->get_list_users ( $data );
+		$users = array ();
 		
-		foreach($us as $u) {
-			$id = $u['us_id'];
-			//$username = $this->get_username($id);
-			$userinfo = $this->get_userinfo($id);
-			if($userinfo){
-				$u['username'] = $userinfo['username'];
-				$u['province'] = $userinfo['province'];
-				array_push($users, $u);
+		foreach ( $us as $u ) {
+			$u ['province'] = isset($provinces[$u ['province']]) ? $provinces[$u ['province']] : $u ['province'];
+			$userinfo = $this->get_userinfo ( $u ['us_id'] );
+			if ($userinfo) {
+				$u ['username'] = $userinfo ['username'];
 			}
+			array_push ( $users, $u );
 		}
 		
-		$data['users'] = $users;
-		$data['paging_url'] = base_url() . "admin/nguoi_dung/trang/";
-		$data['num_links'] = 2;
-		$data['paging'] = pagging($data);
-		if ($this->input->is_ajax_request())
-		{
-			return $this->load->view('user/listview', $data);
+		$data ['users'] = $users;
+		$data ['paging_url'] = base_url () . "admin/nguoi_dung/trang/";
+		$data ['num_links'] = 2;
+		$data ['paging'] = pagging ( $data );
+		
+		if ($this->input->is_ajax_request ()) {
+			return $this->load->view ( 'user/listview', $data );
 		}
-		return $this->load->view('user/listview', $data, true);
+		return $this->load->view ( 'user/listview', $data, true );
 	}
 	
-	public function edit_user()
-	{
-		$admin_info = $this->session->userdata('adminInfo');
-		if ($admin_info)
-		{
-			$input = $this->input->post();
-			$result = array();
-			$result['success'] = 0;
-			$us_id = (int)$this->uri->segment(4, 0);
-			if ($us_id==0){
-				$result['success'] = 0;
-			}else
-			{
-				$this->load->model('user_model');
-				$input['updated_time'] = date("Y-m-d H:i:s");
-				$this->user_model->update($us_id, $input);
-				$result['success'] = 1;
+	public function edit_user() {
+		$admin_info = $this->session->userdata ( 'adminInfo' );
+		if ($admin_info) {
+			$input = $this->input->post ();
+			$result = array ();
+			$result ['success'] = 0;
+			$us_id = ( int ) $this->uri->segment ( 4, 0 );
+			if ($us_id == 0) {
+				$result ['success'] = 0;
+			} else {
+				$this->load->model ( 'user_model' );
+				$input ['updated_time'] = date ( "Y-m-d H:i:s" );
+				$this->user_model->update ( $us_id, $input );
+				$result ['success'] = 1;
 			}
-			echo json_encode($result);
-		}else
-		{
-			$this->load->view('login');
+			echo json_encode ( $result );
+		} else {
+			$this->load->view ( 'login' );
 		}
 	}
 	
-	public function delete_user()
-	{
-		$admin_info = $this->session->userdata('adminInfo');
-		if ($admin_info)
-		{
-			$result = array();
-			$result['success'] = 0;
-			$us_id = (int)$this->uri->segment(4, 0);
-			if ($us_id == 0){
-				$result['success'] = 0;
-			}else
-			{
-				$this->load->model('user_model');
-				$this->user_model->delete($us_id);
-				$result['success'] = 1;
+	public function delete_user() {
+		$admin_info = $this->session->userdata ( 'adminInfo' );
+		if ($admin_info) {
+			$result = array ();
+			$result ['success'] = 0;
+			$us_id = ( int ) $this->uri->segment ( 4, 0 );
+			if ($us_id == 0) {
+				$result ['success'] = 0;
+			} else {
+				$this->load->model ( 'user_model' );
+				$this->user_model->delete ( $us_id );
+				$result ['success'] = 1;
 			}
-			echo json_encode($result);
-		}else
-		{
-			$this->load->view('login');
+			echo json_encode ( $result );
+		} else {
+			$this->load->view ( 'login' );
 		}
 	}
 	
-	public function get_user_by_id()
-	{
-		$admin_info = $this->session->userdata('adminInfo');
-		if ($admin_info)
-		{
-			$result = array();
-			$result['success'] = 0;
-			$us_id = (int)$this->uri->segment(4, 0);
-			if ($us_id == 0)
-			{
-				$result['success'] = 0;	
-			}else
-			{
-				$this->load->model('user_model');
-				$data = $this->user_model->search_by_id($us_id);
-				$result['item'] = $data;
-				$result['success'] = 1;
+	public function get_user_by_id() {
+		$admin_info = $this->session->userdata ( 'adminInfo' );
+		if ($admin_info) {
+			$result = array ();
+			$result ['success'] = 0;
+			$us_id = ( int ) $this->uri->segment ( 4, 0 );
+			if ($us_id == 0) {
+				$result ['success'] = 0;
+			} else {
+				$this->load->model ( 'user_model' );
+				$data = $this->user_model->search_by_id ( $us_id );
+				$result ['item'] = $data;
+				$result ['success'] = 1;
 			}
-			echo json_encode($result);
-		}else
-		{
-			$this->load->view('login');
+			echo json_encode ( $result );
+		} else {
+			$this->load->view ( 'login' );
 		}
 	}
 	
-	private function get_userinfo($us_id)
-	{
+	private function get_userinfo($us_id) {
 		$src = 'violet';
-		$token = md5($us_id.self::TOKENPW);
-		$this->load->model('user_model');
-		$data = $this->user_model->get_user_info($src, $us_id, $token);
-		//var_dump($data);
-		$result = array();
-		parse_str($data, $result);
+		$token = md5 ( $us_id . self::TOKENPW );
+		$this->load->model ( 'user_model' );
+		$data = $this->user_model->get_user_info ( $src, $us_id, $token );
+		// var_dump($data);
+		$result = array ();
+		parse_str ( $data, $result );
 		return $result;
 		/*
-		if (strpos($data, '&')){
-			$arr_users = explode("&", $data);
-			$str_username = $arr_users[1];
-			$arr_username = explode("=", $str_username);
-			return $arr_username[1];
-		}else
-		{
-			return "";
-		}*/
-
+		 * if (strpos($data, '&')){ $arr_users = explode("&", $data); $str_username = $arr_users[1]; $arr_username = explode("=", $str_username); return $arr_username[1]; }else { return ""; }
+		 */
 	}
-	
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php	(revision 765)
@@ -1,213 +1,254 @@
 <?php
-
-if (!defined('BASEPATH'))
-    exit('No direct script access allowed');
+if (! defined ( 'BASEPATH' ))
+	exit ( 'No direct script access allowed' );
 
 class Reportmodel extends MY_Model {
-
-    protected $table_name = 'tblpaidlog';
-    protected $id_name = 'id';
-
-    function __construct() {
-        parent::__construct();
-        $this->load->helper('language');
-        $this->lang->load('messages', 'message');
-    }
-
-    function getProvinces($input) {
-
-        $from="tblpaidlog.paid_time >= '" . $input['year'] . "-" . $input['month'] . "-" . $input['date'] . " 00:00:00'";
-        $to="tblpaidlog.paid_time <= '" . $input['to_year'] . "-" . $input['to_month'] . "-" . $input['to_date'] . " 23:59:59'";
-        
-        $provinces = lang('_PROVINCES_');
-        // Tinh doanh thu theo tinh theo nam
-        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time >= '" . $input['year'] . "-01-01' AND tblpaidlog.paid_time <= '" . ($input['year'] + 1) . "-01-01' GROUP BY tbluser.province";
-        $query = $this->db->query($sql);
-        $dtns = $query->result_array();
-        
-        // tinh doanh thu theo thang
-        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE $from AND $to  GROUP BY tbluser.province";
-        $query = $this->db->query($sql);
-        $dtts = $query->result_array();
-        
-        // tinh doanh thu trong ngay hien tai
-        if (isset($input['to_month']))
-        {
-        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time >= '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 00:00:00' AND  tblpaidlog.paid_time <= '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 23:59:59'  GROUP BY tbluser.province";
-        }
-        $query = $this->db->query($sql);
-        $dtng = $query->result_array();
-
-        // Tinh thue bao theo tinh theo nam
-        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >= '" . $input['year'] . "-01-01' AND tbluser.created_time <= '" . ($input['year'] + 1) . "-01-01' GROUP BY tbluser.province";
-        $query = $this->db->query($sql);
-        $tbns = $query->result_array();
-
-        // tinh thue bao theo thang
-        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND  $to GROUP BY tbluser.province";
-        $query = $this->db->query($sql);
-        $tbts = $query->result_array();
-        
-         // tinh thue bao theo ngay
-        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >='" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 00:00:00' AND tbluser.created_time <= '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 23:59:59'  GROUP BY tbluser.province";
-        
-        $query = $this->db->query($sql);
-        $tbng = $query->result_array(); 
-        
-
-        $dem=1;
-        foreach ($provinces as $index2 => $province) {
-            $provinces[$index2] = array("stt" => ($dem), "province" => $province, "dtn" => 0, "dtt" => 0, "dtng" => 0, "tbn" => 0, "tbt" => 0, "tbng" => 0);
-            foreach ($dtns as $data) {
-                if ($index2 == $data['province']) {
-                    $provinces[$index2]['dtn'] = $data['total'];
-                }
-            } 
-            foreach ($dtng as $data) {
-                if ($index2 == $data['province']) {
-                    $provinces[$index2]['dtng'] = $data['total'];
-                }
-            }
-            foreach ($dtts as $data) {
-                if ($index2 == $data['province']) {
-                    $provinces[$index2]['dtt'] = $data['total'];
-                    
-                }
-            }
-
-            foreach ($tbns as $data) {
-                if ($index2 == $data['province']) {
-                    $provinces[$index2]['tbn'] = $data['total'];
-                }
-            }
-            foreach ($tbng as $data) {
-                if ($index2 == $data['province']) {
-                    $provinces[$index2]['tbng'] = $data['total'];
-                }
-            }
-            foreach ($tbts as $data) {
-                if ($index2 == $data['province']) {
-                    $provinces[$index2]['tbt'] = $data['total'];
-                }
-            }
-            $dem++;
-        }
-       
-        return $provinces;
-    }
-
-    function getPackages($input) {
-
-        $provinces = lang('_PROVINCES_');
-        // tinh thue bao theo thang
-        $sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >= '" . $input['year'] . "-" . $input['month'] . "-" . $input['date'] . "' AND tbluser.created_time <= '" . $input['to_year'] . "-" . $input['to_month'] . "-" . $input['to_date'] . "' AND tblservicepackage.p_period > 0 ";
-        $query = $this->db->query($sql);
-        $users = $query->result_array();
-
-
-        $sql = "SELECT * FROM tblservicepackage WHERE p_period>0";
-        $query = $this->db->query($sql);
-        $packages = $query->result_array();
-        foreach ($packages as $index => $package) {
-            $packages[$index]['users'] = array();
-            foreach ($users as $user) {
-                if ($user['p_id'] == $package['p_id']) {
-                    $packages[$index]['users'][] = $user;
-                }
-            }
-        }
-
-        foreach ($provinces as $index => $province) {
-            $provinces[$index] = array("province" => $province);
-        }
-        $dem=1;
-        foreach ($provinces as $index => $province) {
-            $provinces[$index]['stt'] = $dem;
-            $provinces[$index]['total'] = 0;
-            $totaluser = 0;
-            foreach ($packages as $index2 => $package) {
-                $provinces[$index]['packages'][$package['p_name']]['users'] = array();
-                $provinces[$index]['packages'][$package['p_name']]['total'] = 0;
-                $total = 0;
-                foreach ($package['users'] as $user) {
-                    if ($index == $user['province']) {
-                        $total = $total + 1;
-                        $totaluser = $totaluser + 1;
-                        $provinces[$index]['total'] = $totaluser;
-                        $provinces[$index]['packages'][$package['p_name']]['total'] = $total;
-
-                        $provinces[$index]['packages'][$package['p_name']]['users'][] = $user;
-                    }
-                }
-            }
-            $dem++;
-        }
-        foreach ($provinces as $index => $province) {
-            foreach ($packages as $index2 => $package) {
-                $provinces[$index]['packages'][$package['p_name']]['percent'] = 0;
-                if ($provinces[$index]['packages'][$package['p_name']]['total'] > 0 && $province['total'] > 0) {
-                    $provinces[$index]['packages'][$package['p_name']]['percent'] = round($provinces[$index]['packages'][$package['p_name']]['total'] / $province['total'], 2) * 100;
-                }
-            }
-        }
-
-        $data['packages'] = $packages;
-        $data['provinces'] = $provinces;
-        return $data;
-    }
-    public function exportProvince($input)
-    {   
-        //$input['date']=1;
-        //$input['month']=1;
-        //$input['year']=2014;
-        //$input['to_month']=1;
-        //$input['to_year']=2015;
-        //$input['to_date']=15;
-        if (isset($input['to_month']))
-        {
-            $date=$input['to_year'].$input['to_month'].$input['to_date'];
-        }
-        else {
-            $date=date("Ymd");
-        }
-        $provinces=array();
-        $data=$this->getProvinces($input);
-        foreach ($data as $index=>$province)
-        {
-            $provinces[]=array("stt"=>$province['stt'],"ngay"=>$date,"ma"=>$index,"tinh"=>$province['province'],"thue_bao_ngay"=>$province['tbng'],"thue_bao_thang"=>$province['tbt'],"thue_bao_nam"=>$province['tbn'],"doanh_thu_ngay"=>$province['dtng'],"doanh_thu_thang"=>$province['dtt'],"doanh_thu_nam"=>$province['dtn']);
-        }
-        return $provinces;
-    }
-    public function exportPackage($input)
-    {
-       // $input['date']=1;
-        //$input['month']=1;
-      //  $input['year']=2014;
-      // $input['to_month']=1;
-       // $input['to_year']=2015;
-       // $input['to_date']=15;
-        if (isset($input['month']))
-        {
-            $date=$input['year'].$input['month'];
-        }
-        else {
-            $date=date("Ym");
-        }
-        $result=array();
-        $data=$this->getPackages($input);
-        $data=$data['provinces'];
-        foreach ($data as $index=>$province)
-        {
-                $package=array();
-                foreach ($province['packages'] as $index2=>$packages)
-                {
-                    $package=  array_merge($package,array("tong_so_".$index2=>$packages['total'],"ti_le_".$index2=>$packages['percent']));
-                }
-                $tong=array("tong_so_tb"=>$province['total']);
-                $province=array("stt"=>$province['stt'],"ngay"=>$date,"ma"=>$index,"tinh"=>$province['province']);
-                $provinces[]= array_merge($province,$package,$tong);
-        }
-        return $provinces;
-    }
-
+	
+	protected $table_name = 'tblpaidlog';	
+	protected $id_name = 'id';
+	
+	/**
+	 * 
+	 */
+	function __construct() {
+		parent::__construct ();
+		$this->load->helper ( 'language' );
+		$this->lang->load ( 'messages', 'message' );
+	}
+	
+	/**
+	 * 
+	 * @param unknown $input
+	 * @return Ambigous <multitype:number unknown , unknown, string>
+	 */
+	function getProvinces($input) {
+		$from = "tblpaidlog.paid_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . " 00:00:00'";
+		$to = "tblpaidlog.paid_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59'";
+		
+		$provinces = lang ( '_PROVINCES_' );
+		// Tinh doanh thu theo tinh theo nam
+		$sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time >= '" . $input ['year'] . "-01-01' AND tblpaidlog.paid_time <= '" . ($input ['year'] + 1) . "-01-01' GROUP BY tbluser.province";
+		$query = $this->db->query ( $sql );
+		$dtns = $query->result_array ();
+		
+		// tinh doanh thu theo thang
+		$sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE $from AND $to  GROUP BY tbluser.province";
+		$query = $this->db->query ( $sql );
+		$dtts = $query->result_array ();
+		
+		// tinh doanh thu trong ngay hien tai
+		if (isset ( $input ['to_month'] )) {
+			$sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time >= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 00:00:00' AND  tblpaidlog.paid_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59'  GROUP BY tbluser.province";
+		}
+		$query = $this->db->query ( $sql );
+		$dtng = $query->result_array ();
+		
+		// Tinh thue bao theo tinh theo nam
+		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >= '" . $input ['year'] . "-01-01' AND tbluser.created_time <= '" . ($input ['year'] + 1) . "-01-01' GROUP BY tbluser.province";
+		$query = $this->db->query ( $sql );
+		$tbns = $query->result_array ();
+		
+		// tinh thue bao theo thang
+		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND  $to GROUP BY tbluser.province";
+		$query = $this->db->query ( $sql );
+		$tbts = $query->result_array ();
+		
+		// tinh thue bao theo ngay
+		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >='" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 00:00:00' AND tbluser.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59'  GROUP BY tbluser.province";
+		
+		$query = $this->db->query ( $sql );
+		$tbng = $query->result_array ();
+		
+		$dem = 1;
+		
+		foreach ( $provinces as $index2 => $province ) {
+			$provinces [$index2] = array (
+					"stt" => ($dem),
+					"province" => $province,
+					"dtn" => 0,
+					"dtt" => 0,
+					"dtng" => 0,
+					"tbn" => 0,
+					"tbt" => 0,
+					"tbng" => 0 
+			);
+			foreach ( $dtns as $data ) {
+				if ($index2 == $data ['province']) {
+					$provinces [$index2] ['dtn'] = $data ['total'];
+				}
+			}
+			foreach ( $dtng as $data ) {
+				if ($index2 == $data ['province']) {
+					$provinces [$index2] ['dtng'] = $data ['total'];
+				}
+			}
+			foreach ( $dtts as $data ) {
+				if ($index2 == $data ['province']) {
+					$provinces [$index2] ['dtt'] = $data ['total'];
+				}
+			}
+			
+			foreach ( $tbns as $data ) {
+				if ($index2 == $data ['province']) {
+					$provinces [$index2] ['tbn'] = $data ['total'];
+				}
+			}
+			foreach ( $tbng as $data ) {
+				if ($index2 == $data ['province']) {
+					$provinces [$index2] ['tbng'] = $data ['total'];
+				}
+			}
+			foreach ( $tbts as $data ) {
+				if ($index2 == $data ['province']) {
+					$provinces [$index2] ['tbt'] = $data ['total'];
+				}
+			}
+			$dem ++;
+		}
+		
+		return $provinces;
+	}
+	
+	/**
+	 * 
+	 * @param unknown $input
+	 * @return Ambigous <multitype:, number, string>
+	 */
+	function getPackages($input) {
+		$provinces = lang ( '_PROVINCES_' );
+		// tinh thue bao theo thang
+		$sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblservicepackage.p_period > 0 ";
+		$query = $this->db->query ( $sql );
+		$users = $query->result_array ();
+		
+		$sql = "SELECT * FROM tblservicepackage WHERE p_period>0";
+		$query = $this->db->query ( $sql );
+		$packages = $query->result_array ();
+		foreach ( $packages as $index => $package ) {
+			$packages [$index] ['users'] = array ();
+			foreach ( $users as $user ) {
+				if ($user ['p_id'] == $package ['p_id']) {
+					$packages [$index] ['users'] [] = $user;
+				}
+			}
+		}
+		
+		foreach ( $provinces as $index => $province ) {
+			$provinces [$index] = array (
+					"province" => $province 
+			);
+		}
+		$dem = 1;
+		foreach ( $provinces as $index => $province ) {
+			$provinces [$index] ['stt'] = $dem;
+			$provinces [$index] ['total'] = 0;
+			$totaluser = 0;
+			foreach ( $packages as $index2 => $package ) {
+				$provinces [$index] ['packages'] [$package ['p_name']] ['users'] = array ();
+				$provinces [$index] ['packages'] [$package ['p_name']] ['total'] = 0;
+				$total = 0;
+				foreach ( $package ['users'] as $user ) {
+					if ($index == $user ['province']) {
+						$total = $total + 1;
+						$totaluser = $totaluser + 1;
+						$provinces [$index] ['total'] = $totaluser;
+						$provinces [$index] ['packages'] [$package ['p_name']] ['total'] = $total;
+						
+						$provinces [$index] ['packages'] [$package ['p_name']] ['users'] [] = $user;
+					}
+				}
+			}
+			$dem ++;
+		}
+		foreach ( $provinces as $index => $province ) {
+			foreach ( $packages as $index2 => $package ) {
+				$provinces [$index] ['packages'] [$package ['p_name']] ['percent'] = 0;
+				if ($provinces [$index] ['packages'] [$package ['p_name']] ['total'] > 0 && $province ['total'] > 0) {
+					$provinces [$index] ['packages'] [$package ['p_name']] ['percent'] = round ( $provinces [$index] ['packages'] [$package ['p_name']] ['total'] / $province ['total'], 2 ) * 100;
+				}
+			}
+		}
+		
+		$data ['packages'] = $packages;
+		$data ['provinces'] = $provinces;
+		return $data;
+	}
+	
+	/**
+	 * 
+	 * @param unknown $input
+	 * @return multitype:multitype:unknown string Ambigous <Ambigous, multitype:number unknown , unknown, string>
+	 */
+	public function exportProvince($input) {
+		// $input['date']=1;
+		// $input['month']=1;
+		// $input['year']=2014;
+		// $input['to_month']=1;
+		// $input['to_year']=2015;
+		// $input['to_date']=15;
+		if (isset ( $input ['to_month'] )) {
+			$date = $input ['to_year'] . $input ['to_month'] . $input ['to_date'];
+		} else {
+			$date = date ( "Ymd" );
+		}
+		$provinces = array ();
+		$data = $this->getProvinces ( $input );
+		foreach ( $data as $index => $province ) {
+			$provinces [] = array (
+					"stt" => $province ['stt'],
+					"ngay" => $date,
+					"ma" => $index,
+					"tinh" => $province ['province'],
+					"thue_bao_ngay" => $province ['tbng'],
+					"thue_bao_thang" => $province ['tbt'],
+					"thue_bao_nam" => $province ['tbn'],
+					"doanh_thu_ngay" => $province ['dtng'],
+					"doanh_thu_thang" => $province ['dtt'],
+					"doanh_thu_nam" => $province ['dtn'] 
+			);
+		}
+		return $provinces;
+	}
+	
+	/**
+	 * 
+	 * @param unknown $input
+	 * @return multitype:
+	 */
+	public function exportPackage($input) {
+		// $input['date']=1;
+		// $input['month']=1;
+		// $input['year']=2014;
+		// $input['to_month']=1;
+		// $input['to_year']=2015;
+		// $input['to_date']=15;
+		if (isset ( $input ['month'] )) {
+			$date = $input ['year'] . $input ['month'];
+		} else {
+			$date = date ( "Ym" );
+		}
+		$result = array ();
+		$data = $this->getPackages ( $input );
+		$data = $data ['provinces'];
+		foreach ( $data as $index => $province ) {
+			$package = array ();
+			foreach ( $province ['packages'] as $index2 => $packages ) {
+				$package = array_merge ( $package, array (
+						"tong_so_" . $index2 => $packages ['total'],
+						"ti_le_" . $index2 => $packages ['percent'] 
+				) );
+			}
+			$tong = array (
+					"tong_so_tb" => $province ['total'] 
+			);
+			$province = array (
+					"stt" => $province ['stt'],
+					"ngay" => $date,
+					"ma" => $index,
+					"tinh" => $province ['province'] 
+			);
+			$provinces [] = array_merge ( $province, $package, $tong );
+		}
+		return $provinces;
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 765)
@@ -150,5 +150,5 @@
 <?php
 foreach ($users as $user) {
-    ?>
+?>
                                 <tr class="odd">
                                     <td class="center  sorting_1">
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php	(revision 765)
@@ -54,6 +54,8 @@
                $first_visit=1;
             }
+            
+            $isOverDate = strtotime($u['expire_date']) < strtotime(date('Y-m-d')) ? 0:1; 
  
-          $this->load->view('lecture_editor', array('username' => $username, 'licenseAvailable' => $licenseAvailable, 'first_visit' => $first_visit, 'licflashVars' => $aryParams,'update_user_info'=>$update_user_info,'us_id'=>$us_id,"p_period"=>$u['p_period'],"expire_date"=>date("d-m-Y", strtotime($u['expire_date'])), "fullname"=>$info['fullname'], "school"=>$info['school'], "province"=>$u['province'], "provinces"=>lang('_PROVINCES_')));
+            $this->load->view('lecture_editor', array('username' => $username, 'licenseAvailable' => $licenseAvailable, 'first_visit' => $first_visit, 'licflashVars' => $aryParams,'update_user_info'=>$update_user_info,'us_id'=>$us_id,"p_period"=>$u['p_period'],"expire_date"=>date("d-m-Y", strtotime($u['expire_date'])), 'isOverDate' => $isOverDate , "fullname"=>$info['fullname'], "school"=>$info['school'], "province"=>$u['province'], "provinces"=>lang('_PROVINCES_')));
         } else {
             redirect('/frontend/home/');
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 765)
@@ -64,4 +64,5 @@
             $result['can_buy'] = 1;
             $result['can_edit'] = 0;
+            
             if ($user['acc_balanced'] < $package['p_price']) {
                 $result['can_buy'] = 0;
@@ -142,5 +143,8 @@
         $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
         
-        $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == '' ? date('Y-m-d 00:00:00') : $user['expire_date'];
+        $today_dt = new DateTime(date('Y-m-d 00:00:00'));
+        $expire_dt = new DateTime($user['expire_date']);
+        
+        $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == '' || $today_dt > $expire_dt  ? date('Y-m-d 00:00:00') : $user['expire_date'];
         $user['expire_date'] = date('Y-m-d', strtotime("+" . $package['p_period'] . " ".$package['p_unit'], strtotime($currentExpireDate))); 
         $user['p_id'] = $package['p_id'];
@@ -175,5 +179,9 @@
         } else {
             $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
-            $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == '' ? date('Y-m-d 00:00:00') : $user['expire_date'];
+            
+            $today_dt = new DateTime(date('Y-m-d 00:00:00'));
+            $expire_dt = new DateTime($user['expire_date']);
+            
+            $currentExpireDate = $user['expire_date'] == NULL || trim($user['expire_date']) == ''  || $today_dt > $expire_dt ? date('Y-m-d 00:00:00') : $user['expire_date'];
 
             $user['expire_date'] = date('Y-m-d', strtotime("+" . $package['p_period'] . " " . $package['p_unit'], strtotime($currentExpireDate)));
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php	(revision 765)
@@ -117,4 +117,5 @@
     var update_user_info="<?php echo $update_user_info;?>";
     var us_id="<?php echo $us_id;?>";
+    var is_overdate = <?php echo $isOverDate;?>
 </script>		
 <?php
Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/report.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/report.php	(revision 764)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/report.php	(revision 765)
@@ -1,14 +1,18 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php
+
+if (! defined ( 'BASEPATH' ))
+	exit ( 'No direct script access allowed' );
 /**
  * Report Class
- * 
+ *
  * @author dzungnv02
- *
+ *        
  */
-
 class Report extends MX_Controller {
-	
 	private $_server = null;
 	
+	/**
+	 * 
+	 */
 	function __construct() {
 		parent::__construct ();
@@ -17,12 +21,18 @@
 				'soap_version' => SOAP_1_2,
 				'encoding' => 'UTF-8',
-				'uri' => 'http://tempuri.org/'
+				'uri' => 'http://tempuri.org/' 
 		) );
 	}
 	
+	/**
+	 * 
+	 */
 	function __destruct() {
 		ini_set ( "soap.wsdl_cache_enabled", "0" );
 	}
 	
+	/**
+	 * 
+	 */
 	public function index() {
 		if ($this->uri->segment ( 3 ) == "wsdl") {
@@ -30,6 +40,5 @@
 			$this->load->view ( 'reportwsdl' );
 			return;
-		}
-		else {
+		} else {
 			header ( 'Content-Type: text/html; charset: utf-8' );
 			echo '<div>See Report service <a href="', base_url (), 'violetservice/report/wsdl">WSDL page</a></div>';
@@ -37,93 +46,168 @@
 	}
 	
+	/**
+	 * 
+	 * @return multitype:string number |string
+	 */
 	public function get() {
-		function revenueReport () {
-			$aryArgs = func_get_args ();	
-			list ( $username, $password, $fromDate, $toDate) = $aryArgs;
-
+		
+		/**
+		 * 
+		 * @return multitype:string number
+		 */
+		function revenueReport() {
+			$aryArgs = func_get_args ();
+			list ( $username, $password, $fromDate, $toDate ) = $aryArgs;
+			
 			$CI = & get_instance ();
-			if (!$toDate) $toDate = date('Y-m-d');
-			$message = validate ($aryArgs);			
-			$success = $message == '' ? 1 : 0;// 0:error; 1:Success;
+			if (! $toDate)
+				$toDate = date ( 'Y-m-d' );
+			$message = validate ( $aryArgs );
+			$success = $message == '' ? 1 : 0; // 0:error; 1:Success;
 			
 			if ($success == 1) {
 				$CI->load->model ( 'Services_model' );
 				$CI->load->model ( 'admin/Reportmodel', 'objReportModel' );
-				$from = explode('-', $fromDate);
-				$to = explode('-', $toDate);
-				$input = array('year' => $from[0], 'month' => $from[1], 'to_year' => $to[0], 'to_month' => $to[1], 'to_date' => $to[2]);
-				$result = $CI->objReportModel->exportProvince( $input );
-				
-				if (count($result) > 0 && is_array($result)) {
-					//1|20140915|A076|0|0|0|100000|0|0
-					$aryTmp = array();
-					$aryResult = array();
-					foreach ($result as $provinceCode => $record) {
-						//No|toDate|ProvCode|TBngay|LKTBThang|TongTBNam|DTngay|LuyKeTBThang|TongDTNam
-						$aryTmp[] = $record['stt'];
-						$aryTmp[] = implode('', $to);
-						$aryTmp[] = $provinceCode;
-						$aryTmp[] = $record['tbng'];
-						$aryTmp[] = $record['tbt'];
-						$aryTmp[] = $record['tbn'];
-						$aryTmp[] = $record['dtng'];
-						$aryTmp[] = $record['dtt'];
-						$aryTmp[] = $record['dtn'];
-						$aryResult[] = implode('|', $aryTmp);
-						$aryTmp = array();
+				$from = explode ( '-', $fromDate );
+				$to = explode ( '-', $toDate );
+				$input = array (
+						'year' => $from [0],
+						'month' => $from [1],
+						'to_year' => $to [0],
+						'to_month' => $to [1],
+						'to_date' => $to [2] 
+				);
+				$result = $CI->objReportModel->exportProvince ( $input );
+				
+				if (count ( $result ) > 0 && is_array ( $result )) {
+					// 1|20140915|A076|0|0|0|100000|0|0
+					$aryTmp = array ();
+					$aryResult = array ();
+					foreach ( $result as $provinceCode => $record ) {
+						// No|toDate|ProvCode|TBngay|LKTBThang|TongTBNam|DTngay|LuyKeTBThang|TongDTNam
+						$aryTmp [] = $record ['stt'];
+						$aryTmp [] = implode ( '', $to );
+						$aryTmp [] = $record ['ma'];
+						$aryTmp [] = $record ['thue_bao_ngay'];
+						$aryTmp [] = $record ['thue_bao_thang'];
+						$aryTmp [] = $record ['thue_bao_nam'];
+						$aryTmp [] = $record ['doanh_thu_ngay'];
+						$aryTmp [] = $record ['doanh_thu_thang'];
+						$aryTmp [] = $record ['doanh_thu_nam'];
+						$aryResult [] = implode ( '|', $aryTmp );
+						$aryTmp = array ();
 					}
 					
-					$message = implode("\n", $aryResult);
+					$message = implode ( "\n", $aryResult );
 					$success = 1;
 				}
 			}
 			
-			return array($message, $success, date('YmdHis'));
-		}
-		
-		function subscribersReport () {
-			$aryArgs = func_get_args ();	
-			list ( $username, $password, $fromDate, $toDate) = $aryArgs;
-
+			return array (
+					$message,
+					$success,
+					date ( 'YmdHis' ) 
+			);
+		}
+		
+		/**
+		 * 
+		 * @return multitype:string number
+		 */
+		function subscribersReport() {
+			$aryArgs = func_get_args ();
+			list ( $username, $password, $fromDate, $toDate ) = $aryArgs;
+			
 			$CI = & get_instance ();
-			$message = validate ($aryArgs);
-			$success = $message == '' ? 1 : 0;// 0:error; 1:Success;
-			$message = $message == '' ? 'subscribersReport' : $message;
+			$message = validate ( $aryArgs );
+			$success = $message == '' ? 1 : 0; // 0:error; 1:Success;
+			
+			if ($success == 1) {
+				$CI->load->model ( 'Services_model' );
+				$CI->load->model ( 'admin/Reportmodel', 'objReportModel' );
+				$from = explode ( '-', $fromDate );
+				$to = explode ( '-', $toDate );
+				$input = array (
+						'year' => $from [0],
+						'month' => $from [1],
+						'date' => $from [2],
+						'to_year' => $to [0],
+						'to_month' => $to [1],
+						'to_date' => $to [2] 
+				);
+				$result = $CI->objReportModel->exportPackage ( $input );
+				
+				if (count ( $result ) > 0 && is_array ( $result )) {
+					$aryTmp = array ();
+					$aryResult = array ();
+					foreach ( $result as $provinceCode => $record ) {
+						$aryTmp [] = $record ['stt'];
+						$aryTmp [] = implode ( '', $to );
+						$aryTmp [] = $record ['ma'];
+						$aryTmp [] = $record ['tong_so_VIP 1'];
+						$aryTmp [] = $record ['ti_le_VIP 1'];
+						$aryTmp [] = $record ['tong_so_VIP 3'];
+						$aryTmp [] = $record ['ti_le_VIP 3'];
+						$aryTmp [] = $record ['tong_so_VIP 6'];
+						$aryTmp [] = $record ['ti_le_VIP 6'];
+						$aryTmp [] = $record ['tong_so_VIP 12'];
+						$aryTmp [] = $record ['ti_le_VIP 12'];
+						$aryTmp [] = $record ['tong_so_tb'];
+						$aryResult [] = implode ( '|', $aryTmp );
+						$aryTmp = array ();
+					}
+					
+					$message = implode ( "\n", $aryResult );
+					$success = 1;
+				}
+			}
 			
 			$CI->load->model ( 'Services_model' );
-			$CI->load->model ( 'admin/Reportmodel', 'objReportModel' );			
-			
-			return array($message, $success, date('YmdHis'));
-		}
-		
-		function validate ($aryArgs) {
-			list ( $username, $password, $fromDate, $toDate) = $aryArgs;
+			$CI->load->model ( 'admin/Reportmodel', 'objReportModel' );
+			
+			return array (
+					$message,
+					$success,
+					date ( 'YmdHis' ) 
+			);
+		}
+		
+		/**
+		 * 
+		 * @param unknown $aryArgs
+		 * @return string
+		 */
+		function validate($aryArgs) {
+			list ( $username, $password, $fromDate, $toDate ) = $aryArgs;
 			
 			$CI = & get_instance ();
 			$predefUsername = $CI->config->item ( 'report_username' );
 			$predefPassword = $CI->config->item ( 'report_password' );
-				
+			
 			$message = '';
-				
+			
 			if (! $username) {
 				$message = 'Username is required!';
-			}else if (! $password) {
-				$message =  'Password is required!';
-			}else if ($username != $predefUsername) {
-				$message =  'Username is not corrected!';
-			}else if ($password != $predefPassword) {
-				$message =  'Password is not corrected!';
-			}else if (! $fromDate) {
-				$message =  'fromDate is required!';
-			}else if (!preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $fromDate)) {
-				$message =  'fromDate is not corrected!';
-			}else if ($toDate && !preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $toDate)) {
-				$message =  'toDate is not corrected!';
-			}
-
+			} else if (! $password) {
+				$message = 'Password is required!';
+			} else if ($username != $predefUsername) {
+				$message = 'Username is not corrected!';
+			} else if ($password != $predefPassword) {
+				$message = 'Password is not corrected!';
+			} else if (! $fromDate) {
+				$message = 'fromDate is required!';
+			} else if (! preg_match ( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $fromDate )) {
+				$message = 'fromDate is not corrected!';
+			} else if ($toDate && ! preg_match ( '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $toDate )) {
+				$message = 'toDate is not corrected!';
+			}
+			
 			return $message;
 		}
 		
-		$this->_server->addFunction ( array('revenueReport', 'subscribersReport'));
+		$this->_server->addFunction ( array (
+				'revenueReport',
+				'subscribersReport' 
+		) );
 		
 		try {
@@ -136,13 +220,13 @@
 				$soapOutput = ob_get_clean ();
 			}
-				
+			
 			if ($soapOutput != '') {
-				error_log(var_export($soapOutput, true) . "\n\n\n", 3, '/srv/www/sbg/log/reportservicexml.log');
-				
-				$response = preg_match('/revenueReportResponse/', $soapOutput) ? 'revenueReportResponse' : (preg_match('/subscribersReportResponse/', $soapOutput) ? 'subscribersReportResponse':'');
+				error_log ( var_export ( $soapOutput, true ) . "\n\n\n", 3, '/srv/www/sbg/log/reportservicexml.log' );
+				
+				$response = preg_match ( '/revenueReportResponse/', $soapOutput ) ? 'revenueReportResponse' : (preg_match ( '/subscribersReportResponse/', $soapOutput ) ? 'subscribersReportResponse' : '');
 				
 				$pattern = '/<[^>]*[^\/]>/i';
 				$aryOutput = preg_split ( $pattern, $soapOutput, - 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
-				error_log(var_export($aryOutput, true) . "\n\n\n", 3, '/srv/www/sbg/log/reportservice.log');
+				error_log ( var_export ( $aryOutput, true ) . "\n\n\n", 3, '/srv/www/sbg/log/reportservice.log' );
 				$aryData = array ();
 				$aryData ['message'] = $aryOutput [1];
@@ -159,5 +243,5 @@
 		} catch ( Exception $e ) {
 			$this->_server->fault ( 'Sender', $e->getMessage () );
-		}		
+		}
 	}
 }
Index: pro-violet-viettel/sourcecode/assets/js/frontend/lecture.js
===================================================================
--- pro-violet-viettel/sourcecode/assets/js/frontend/lecture.js	(revision 764)
+++ pro-violet-viettel/sourcecode/assets/js/frontend/lecture.js	(revision 765)
@@ -6,7 +6,6 @@
     }
 }
-//if (first_visit == '1') {
 
-if (p_period == -1)
+if (p_period == -1 && is_overdate == 1)
 {
 	$('#alert-trial-services').modal('show');
@@ -25,7 +24,4 @@
 	}
 }
-
-//}
-
 
 $("#update_user_info.btn").click(function () {
