Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php	(revision 906)
@@ -17,5 +17,11 @@
         $admin_info = $this->session->userdata('adminInfo');
         if ($admin_info) {
-            $data['content'] = $this->getCollaborators();
+			$roles=array();
+            foreach ($admin_info['roles'] as $role)
+            {
+                $roles[]=$role['role_name'];
+            }
+            //$data['roles']=$roles;
+            $data['content'] = $this->getCollaborators(array(), $roles);
             $this->load->view('collaborator/index', $data);
         } else {
@@ -24,5 +30,5 @@
     }
 
-    public function getCollaborators($filters = array()) {
+    public function getCollaborators($filters = array(), $roles) {
         $this->load->helper('pagging');
         $this->load->model('collabolator_model');
@@ -76,5 +82,6 @@
         $data['num_links'] = 2;
         $data['paging'] = pagging($data);
-
+		$data['roles'] = $roles;
+		
         if ($this->input->is_ajax_request()) {
             return $this->load->view('collaborator/listview', $data);
@@ -88,49 +95,33 @@
         $input = $this->input->post();
         $this->load->model('collabolator_model');
-        if (strlen($input['full_name'])==0)
-        {
-            $result['errors'][]=array("content"=>"TÃªn cá»ng tÃ¡c viÃªn khÃŽng ÄÆ°á»£c Äá» trá»ng","field"=>"full_name");
-        }
-        if (strlen($input['login_name'])==0)
-        {
-            $result['errors'][]=array("content"=>"TÃªn ÄÄng nháº­p khÃŽng ÄÆ°á»£c Äá» trá»ng","field"=>"login_name");
+		
+        if (strlen($input['cellphone'])==0)
+        {
+            $result['errors'][] = array("content"=>lang('_SBG_PHONE_REQUIRED_MSG'),"field"=>"cellphone");
         }
         else
         {
-            if ($this->collabolator_model->isExist(array('field'=>'login_name','value'=>$input['login_name'])))
-            {
-                $result['errors'][]=array("content"=>"TÃªn ÄÄng nháº­p ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng","field"=>"login_name");
-            }
-        }
-        if (strlen($input['cellphone'])==0)
-        {
-            $result['errors'][]=array("content"=>"Sá» Äiá»n thoáº¡i khÃŽng ÄÆ°á»£c Äá» trá»ng","field"=>"cellphone");
-        }
-        else
-        {
+			if (!preg_match('/^([0-9]{10,11}$)$/', $input['cellphone'])) {
+				$result['errors'][] = array("content"=>lang('_SBG_PHONE_FORMAT_ERROR_MSG'), "field"=>"cellphone");
+			}
+			
             if ($this->collabolator_model->isExist(array('field'=>'cellphone','value'=>$input['cellphone'])))
             {
-                $result['errors'][]=array("content"=>"Sá» Äiá»n thoáº¡i ÄÃ£ ÄÆ°á»£c sá»­ dá»¥ng","field"=>"cellphone");
-            }
-        }
-        if (strlen($input['passwd'])==0)
-        {
-            $result['errors'][]=array("content"=>"Máº­t kháº©u khÃŽng ÄÆ°á»£c Äá» trá»ng","field"=>"passwd");
-        }
-        else
-        {
-            if ($input['passwd'] != $input['passwd2'])
-            {
-                $result['errors'][]=array("content"=>"Máº­t kháº©u pháº£i trÃ¹ng nhau","field"=>"passwd");
-            }
-        }
+                $result['errors'][] = array("content"=>lang("_SBG_PHONE_DUPLICATE_MSG"),"field"=>"cellphone");
+            }
+        }
+        
         if (!isset($result['errors']))
         {
-            unset($input['passwd2']);
-            $input['passwd']=md5($input['activated']);
-            $input['activated']=1;
-            $input['created_time']=date("Y-m-d H:i:s");
-            $input['updated_time']=date("Y-m-d H:i:s");
+   
+			$passwd = $this->collabolator_model->createRandomPassword();
+            $input['passwd'] = md5($input['activated']);
+			$input['login_name'] = $input['cellphone'];
+			$input['author'] = 1;
+            $input['activated'] = 1;
+            $input['created_time'] = date("Y-m-d H:i:s");
+            $input['updated_time'] = date("Y-m-d H:i:s");
             $this->load->model('collabolator_model');
+			
             $this->collabolator_model->insert($input);
             $result['success'] = 1;
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportAsistant.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportAsistant.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportAsistant.php	(revision 906)
@@ -24,5 +24,5 @@
         }
     }
-
+	
     public function viewAsistant() {
         $data = array();
@@ -159,5 +159,5 @@
         $data['keyword'] = "";
         $data['sorting_order'] = "sorting_desc";
-        $data['sorting_field'] = "id";
+        $data['sorting_field'] = "user_created_time";
 
         if ($this->input->post('sorting_order')) {
@@ -181,4 +181,5 @@
 		$data['daterange_start'] = "";
 		$data['daterange_end'] = "";
+		
 		if ($this->input->post('daterange')){
 			$daterange = explode(" - ", $this->input->post('daterange'));
@@ -190,10 +191,14 @@
 		
         $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
+		//write_file('./log/sql.log', date('d-m-Y H:i:s').": Start query \n", FOPEN_WRITE_CREATE);
         $data['total'] = $this->collabolator_model->countCountCollaboratorUsers($data);
+		write_file('./log/sql.log', date('d-m-Y H:i:s').": Start query \n", FOPEN_WRITE_CREATE);
         $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
+		
         foreach ($data['paidlogs'] as $index=>$paidlog)
         {
             $data['paidlogs'][$index]['username']=$this->get_fullname($paidlog['us_id']);
         }
+		write_file('./log/sql.log', date('d-m-Y H:i:s').": Finished query \n", FOPEN_WRITE_CREATE);
         $data['paging_url'] = base_url() . "/admin/thong_ke_cong_tac_vien/trang_ctv/" . $data['id'];
         $data['num_links'] = 2;
@@ -203,4 +208,5 @@
             return $this->load->view('reportAsistant/listview_user', $data);
         }
+		
         return $this->load->view('reportAsistant/listview_user', $data, true);
     }
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php	(revision 906)
@@ -132,9 +132,10 @@
 		$this->load->model('reportmodel');
 		$data['date'] = 1;
-        $data['month'] = $this->uri->segment(4);
-        $data['year'] = $this->uri->segment(5);
-        $data['to_date'] = date("d");
+        $data['month'] = $this->uri->segment(5);
+        $data['year'] = $this->uri->segment(6);
+        $data['to_date'] = $this->uri->segment(4);
         $data['to_month'] = date("m");
         $data['to_year'] = date("Y");
+		/*
         if ($this->input->post()) {
 			//$data['date'] = $this->input->post('date');
@@ -144,5 +145,5 @@
             $data['to_month'] = $this->input->post('to_month');
             $data['to_year'] = $this->input->post('to_year');
-        }
+        }*/
 		
         $result = $this->reportmodel->getProvinces($data);
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php	(revision 906)
@@ -81,4 +81,6 @@
 			$daterange [0] = str_replace ( '/', '-', $daterange [0] );
 			$daterange [1] = str_replace ( '/', '-', $daterange [1] );
+			$data['date_start'] = $daterange [0];
+			$data['date_end'] = $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' ) );
@@ -208,67 +210,37 @@
 		);
 		$data ['status'] = $this->uri->segment (7, 0);
-		/*
-		if ($this->input->post ( 'status' )) {
-			$data ['status'] = ( int ) $this->input->post ( 'status' );
-		}
-		*/
+		
 		$data['provinces'] = $provinces;
 		$data['province'] = $this->uri->segment (8);
+		
 		if ($data['province'] == 'default') $data['province'] = null;
-		if ($this->input->post ( 'province' )) {
-			$data ['province'] = $this->input->post ( 'province' );
-		}
 		if ($data['province'])
 			$data['districts'] = $this->user_model->getDistrictByProvince($data ['province']);
-		if ($this->input->post ( 'district' )) {
-			$data['district'] = $this->input->post ( 'district' );
-		}
-		
+
 		$data['district'] = $this->uri->segment (9);
 		if ($data['district'] == 'default') $data['district'] = null;
 		$data ['keyword'] = $this->uri->segment (6);
 		if ($data['keyword'] == 'default') $data['keyword'] = null;
+		
 		$data ['sorting_order'] = "sorting_desc";
 		$data ['sorting_field'] = "created_time";
-		$data ['sorting_order'] = $this->uri->segment (11);
-		$data ['sorting_field'] = $this->uri->segment (12);
-		
-		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 ( 'keyword' )) {
-			$data ['keyword'] = $this->input->post ( 'keyword' );
-		}
-		
-		$data ['daterange_start'] = "";
-		$data ['daterange_end'] = "";
-		$daterange = $this->uri->segment (10);
-		if ($daterange == 'default') $daterange = null;
-		if($daterange){
-			$daterange = explode ( " - ", $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 ( '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 ['sorting_order'] = $this->uri->segment (12);
+		$data ['sorting_field'] = $this->uri->segment (13);
+
+		$data ['daterange_start'] = $this->uri->segment (10);
+		$data ['daterange_end'] = $this->uri->segment (11);
+		if ($data['daterange_start'] == 'default') $data['daterange_start'] = null;
+		if ($data['daterange_end'] == 'default') $data['daterange_end'] = null;
+		if ($data['daterange_start'])
+			$data['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $data ['daterange_start'] ) );
+		if ($data['daterange_end'])
+			$data['daterange_end'] = date ( 'Y-m-d H:i:s', strtotime ( $data['daterange_end'] . ' + 1 day' ) );
+
 		$data ['start'] = ($data ['current_page'] - 1) * $data ['perpage'];
+		//echo json_encode($data);
 		$data ['total'] = $this->user_model->get_total_users ( $data );
 		$us = $this->user_model->get_list_users ( $data );
 		$users = array ();
+		
 		
 		foreach ( $us as $u ) {
@@ -295,5 +267,5 @@
 			array_push ( $users, $u );
 		}
-	
+		
 		$data ['users'] = $users;
 		$data ['paging_url'] = base_url () . "admin/nguoi_dung/trang/";
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php	(revision 906)
@@ -49,13 +49,23 @@
     function getAllCollaboratorUser($from,$id=false)
     {
-        $from = date("Y-m-d 00:00:00",$from); 
+        $from = date("Y-m-d 00:00:00",$from);
+		$order = "";
+        if ($data['sorting_order'] != "sorting") {
+            
+                $sort = "DESC";
+                if ($data['sorting_order'] == "sorting_asc")
+                    $sort = "ASC";
+                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
+            
+        }
         $where="";
         if ($id)
         {
-            $where = " AND tbluser.collaborator = $id ";
+            //$where = " AND tbluser.collaborator = $id ";
+			$where = " AND tblcollaborator.id = $id ";
         }
         //$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.id WHERE tbluser.created_time > '".$from."'".$where."";
 		$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone WHERE tbluser.created_time > '".$from."'".$where."";
-
+		
         $result = $this->db->query($sql)->result_array();
         foreach ($result as $index=>$paidlog)
@@ -120,5 +130,5 @@
         
 		$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time, COUNT(tbluser.collaborator) as total_user  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." GROUP BY tblcollaborator.id ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
-
+		
         $result = $this->db->query($sql)->result_array();
         foreach ($result as $index=>$paidlog)
@@ -153,18 +163,20 @@
 		}else{
 			$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order."";
-		}	
+		}
+		//write_file('./log/sql.log', date('d-m-Y H:i:s').": ".$sql."\n", FOPEN_WRITE_CREATE);		
 		$result = $this->db->query($sql)->result_array();
+		
         foreach ($result as $index=>$paidlog)
         {
             $result[$index]['time']=  strtotime($paidlog['user_created_time']);
         }
-
+		
         return count($result);
     }
-        function getCountCollaboratorUsers($data)
+	
+	function getCountCollaboratorUsers($data)
     {
         $order = "";
-        if ($data['sorting_order'] != "sorting") {
-            
+        if ($data['sorting_order'] != "sorting") {        
                 $sort = "DESC";
                 if ($data['sorting_order'] == "sorting_asc")
@@ -174,4 +186,5 @@
         }
         $where="";
+		
         if ($data['keyword']) {
             if ($data['search_field'] == "cellphone") {
@@ -179,10 +192,21 @@
             } 
         }
+		
        // $from = date("Y-m-d 00:00:00",$from); 
        // $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.id ".$where." AND tbluser.collaborator = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
-		if(strlen($data['daterange_start'])>0){
-			$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND (tbluser.created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."') AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
+	   
+		if($data['daterange_start']){
+			
+			if ($data['perpage']){
+				$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND (tbluser.created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."') AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
+			}else{
+				$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND (tbluser.created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."') AND tblcollaborator.id = ".$data['id']." ".$order;
+			}
 		}else{
-			$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
+			if ($data['perpage']){
+				$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order." LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
+			}else{
+				$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time,tbluser.cellphone as user_cellphone,tblcollaborator.cellphone as collaborator_cellphone, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone ".$where." AND tblcollaborator.id = ".$data['id']." ".$order;
+			}
 		}
 		$result = $this->db->query($sql)->result_array();
@@ -454,3 +478,14 @@
 	}
 	
+	public function createRandomPassword()
+	{
+		$alphabet = "0123456789";
+		$pass = array ();
+		$alphaLength = strlen ( $alphabet ) - 1;
+		for($i = 0; $i < 6; $i ++) {
+			$n = rand ( 0, $alphaLength );
+			$pass [] = $alphabet [$n];
+		}
+		return implode ( $pass );
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php	(revision 906)
@@ -23,4 +23,5 @@
 	function get_list_users($data)
 	{
+		
 		$sql="SELECT * FROM ".$this->table_name;
 		if ($data['status'] == 1){
@@ -36,6 +37,6 @@
 			$sql.=" WHERE expire_date < NOW() AND p_id <> 5";
 		}
-		if (isset($data['keyword']))
-		{
+		//if (isset($data['keyword']))
+		//{
 			if (strlen($data['keyword'])>0){
 				if ($data['status']==0){
@@ -43,17 +44,21 @@
 						if (strlen($data['district'])>0){
 							if(strlen($data['daterange_start'])>0){
-								$sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
-							}
-						}else{
-							if(strlen($data['daterange_start'])>0){
-								$sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+								$sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
+							}
+						}else{
+							if(strlen($data['daterange_start'])>0){
+								$sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
 							}
 						}
 					}else{
 						if(strlen($data['daterange_start'])>0){
-							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
 						}else
 						{
-							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
+							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
 						}
 					}
@@ -63,13 +68,13 @@
 						if (strlen($data['district'])>0){
 							if(strlen($data['daterange_start'])>0){
-								$sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
-							}else{
-								$sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
-							}
-						}else{
-							if(strlen($data['daterange_start'])>0){
-								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
-							}else{
-								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
+								$sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" AND province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
+							}
+						}else{
+							if(strlen($data['daterange_start'])>0){
+								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
 							}
 						}
@@ -80,4 +85,5 @@
 			{
 				if(strlen($data['daterange_start'])>0){
+					
 					if ($data['status']==0){
 						if (strlen($data['province'])>0){
@@ -105,4 +111,5 @@
 				else{
 					if ($data['status']==0){
+					
 						if (strlen($data['province'])>0){
 							if (strlen($data['district'])>0){
@@ -111,6 +118,8 @@
 								$sql.=" WHERE province = '".$data['province']."'";
 							}
-						}
-					}else{
+							
+						}
+					}else{
+						write_file('./log/test.log', date("d-m-Y: H:i:s"). ": ".$sql."\n" , FOPEN_WRITE_CREATE);
 						if (strlen($data['province'])>0){
 							if (strlen($data['district'])>0){
@@ -125,5 +134,5 @@
 				}
 			}
-		}
+		//}
 	
 		$order = "";
@@ -158,6 +167,6 @@
 		}
 		
-		if (isset($data['keyword']))
-		{
+		//if (isset($data['keyword']))
+		//{
 			if (strlen($data['keyword'])>0){
 				if ($data['status']==0){
@@ -165,18 +174,24 @@
 						if (strlen($data['district'])>0){
 							if(strlen($data['daterange_start'])>0){
-							$sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
-						}
-						}else{
-							if(strlen($data['daterange_start'])>0){
-							$sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
-						}
+								$sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" WHERE province = '".$data['province']."' AND district = '".$data['district']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
+							}
+						
+						}else{
+							if(strlen($data['daterange_start'])>0){
+								$sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" WHERE province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
+							}
+						
 						}
 						
 					}else{
 						if(strlen($data['daterange_start'])>0){
-							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
 						}else
 						{
-							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
+							$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%')";
 						}
 					}
@@ -192,7 +207,7 @@
 						}else{
 							if(strlen($data['daterange_start'])>0){
-								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
-							}else{
-								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
+								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							}else{
+								$sql.=" AND province = '".$data['province']."' AND (cellphone LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%' OR district LIKE '%".$data['keyword']."%' OR province LIKE '%".$data['keyword']."%') ";
 							}
 						}
@@ -244,6 +259,6 @@
 				}
 			}
-		}
-		
+		//}
+		//write_file('./log/sql.log', date("d-m-Y: H:i:s"). ": ".$sql."\n" , FOPEN_WRITE_CREATE);
 		$query = $this->db->query($sql);
 		$row = $query->row_array();
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/index.php	(revision 906)
@@ -134,88 +134,19 @@
             <div class="modal-body">
                 <form id="add_user" onsubmit="return false;" class="form-horizontal" role="form">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> TÃªn Äáº§y Äá»§ </label>
-
-                        <div class="col-sm-9">
-                            <label class="block clearfix has-error">
-                            <span class="input-icon">
-                                <input name="full_name" type="text" id="form-field-1" placeholder="TÃªn cá»ng tÃ¡c viÃªn">
-                                <i class="icon-user blue"></i>
-                            </span>
-                            <div id="full_name" class="help-block error"></div>
-                            </label>
-                        </div>
-                        <div class="help-block"> </div>
+					 <div class="row">
+						<div class="col-sm-9">
+							<div class="form-group">
+								<label for="cellphone" class="col-sm-4 control-label no-padding-right">Sá» Äiá»n thoáº¡i</label>
+																	
+									<div class="col-sm-8">
+										<input type="text" name="cellphone" placeholder="Sá» Äiá»n thoáº¡i" id="cellphone" class="col-xs-12 col-sm-10">
+									</div>
+									<label class="block clearfix has-error">	
+										<small><div class="col-sm-8 help-block error" id="cellphone"> </div></small>
+									</label>
+							</div>
+						</div>
                     </div>
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> TÃªn ÄÄng nháº­p </label>
-
-                        <div class="col-sm-9">
-                            <label class="block clearfix has-error">
-                            <span class="input-icon">
-                                <input name="login_name" type="text" id="form-field-1" placeholder="TÃ i khoáº£n">
-                                <i class="icon-user blue"></i>
-                            </span>
-                            <div id="login_name" class="help-block error"></div>
-                            </label>
-                        </div>
-                        <div class="help-block"> </div>
-                    </div>
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Sá» Äiá»n thoáº¡i</label>
-
-                        <div class="col-sm-9">
-                            <label class="block clearfix has-error">
-                            <span class="input-icon">
-                                <input name="cellphone" type="text" id="form-field-1" placeholder="Sá» Äiá»n thoáº¡i">
-                                <i class="icon-user blue"></i>
-                            </span>
-                            <div id="cellphone" class="help-block error"></div>
-                            </label>
-                        </div>
-                        <div class="help-block"> </div>
-                    </div>
-                    <div class="space-4"></div>
-
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> Máº­t kháº©u </label>
-
-                        <div class="col-sm-9">
-                            <label class="block clearfix has-error">
-                            <span class="input-icon">
-                                <input type="password" name="passwd" id="form-field-2" placeholder="Máº­t kháº©u">
-                                <i class="icon-lock blue"></i>
-                            </span>
-                            <div id="passwd" class="help-block error"></div>
-                            </label>
-                        </div>
-                        <div class="help-block"> </div>
-                    </div>
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> Máº­t kháº©u </label>
-
-                        <div class="col-sm-9">
-                            <span class="input-icon">
-                                <input type="password" name="passwd2" id="form-field-2" placeholder="Nháº­p láº¡i máº­t kháº©u">
-                                <i class="icon-lock blue"></i>
-                            </span>
-                        </div>
-                        <div class="help-block"> </div>
-                    </div>
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> KÃ­ch hoáº¡t</label>
-
-                        <div class="col-sm-9">
-                            <span class="input-icon">
-                                <input type='checkbox' name="activated" checked="checked" value="1"  />
-                            </span>
-                        </div>
-                        <div class="help-block"> </div>
-                    </div>
-
-                    <div class="space-4"></div>
-                    <div class="form-group errors" id="add_user"></div>
-                        
-                    </div>
+					
                     <div class="clearfix form-actions">
                         <div class="col-md-offset-3 col-md-9">
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/listview.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/listview.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/collaborator/listview.php	(revision 906)
@@ -1,5 +1,5 @@
 <?php
-$admin_info = $this->session->userdata('adminInfo');
-$role_id = $admin_info['role_id'];
+//$admin_info = $this->session->userdata('adminInfo');
+//$role_id = $admin_info['role_id'];
 ?>
 <div id="breadcrumbs" class="breadcrumbs">
@@ -45,11 +45,15 @@
             <div style="padding-bottom:4px" class="table-header">
                 Thá»ng kÃª tÃ i khoáº£n
-                <?php if ($role_id == 1): ?>
-                    <button href="#addUser" data-toggle="modal" class="btn btn-success pull-right">
-                        <i class="icon-plus"></i>
-                        ThÃªm cá»ng tÃ¡c viÃªn
-                    </button>
-                <?php endif; ?>
-
+				<?php if (in_array("editUserInfo", $roles)) { ?>
+					<div class="col-xs-12 pull-right" style="margin:5px;">
+						<div class="form-group">
+							<!--<input  class="btn btn-primary pull-right " type="button" value="ThÃªm cá»ng tÃ¡c viÃªn" onclick="admin_update_user();"/>-->
+							<button href="#addUser" data-toggle="modal" class="btn btn-success pull-right">
+							<i class="icon-plus"></i>
+								ThÃªm cá»ng tÃ¡c viÃªn
+							</button>
+						</div>
+					</div>
+				<?php } ?>
             </div>
 
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/reportAsistant/listview_user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/reportAsistant/listview_user.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/reportAsistant/listview_user.php	(revision 906)
@@ -44,5 +44,5 @@
                                 <th class="<?php if ($sorting_field == 'full_name') {echo $sorting_order;} else {echo "";}?>" id="full_name" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Sá» Äiá»n thoáº¡i: activate to sort column ascending">TÃªn ngÆ°á»i dÃ¹ng</th>
                                 <th class="<?php if ($sorting_field == 'collaborator_cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 283px;" aria-label="Há» tÃªn: activate to sort column ascending">Sá» thuÃª bao</th>
-                                <th class="<?php if ($sorting_field == 'total_user') {echo $sorting_order;} else {echo "sorting";}?>" id="total_user" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Sá» Äiá»n thoáº¡i: activate to sort column ascending">NgÃ y giá»i thiá»u</th>  
+                                <th class="<?php if ($sorting_field == 'user_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="user_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="NgÃ y giá»i thiá»u: activate to sort column ascending">NgÃ y giá»i thiá»u</th>  
                                 <!--<th class="<?php if ($sorting_field == 'collaborator_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="NgÃ y ÄÄng kÃœ: activate to sort column ascending">NgÃ y ÄÄng kÃœ</th>-->
                                   
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php	(revision 906)
@@ -10,5 +10,5 @@
                 <div class="pull-right" style="margin:5px;">
                     <!--<a style="color:#fff" href="<?php echo base_url();?>admin/reportprovince/export/<?php echo $month;?>/<?php echo $year;?>">Xuáº¥t ra Excel</a>-->
-					<a style="color:#fff" href="<?php echo base_url();?>admin/reportprovince/exportProvince/<?php echo $month;?>/<?php echo $year;?>">Xuáº¥t ra Excel</a>
+					<a style="color:#fff" href="<?php echo base_url();?>admin/reportprovince/exportProvince/<?php echo $to_date; ?>/<?php echo $month;?>/<?php echo $year;?>">Xuáº¥t ra Excel</a>
                 </div>
             </div>
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 906)
@@ -47,5 +47,5 @@
 				<div class="pull-right" style="margin:5px;">
                     
-					<a style="color:#fff" href="<?php echo base_url();?>admin/user/export/<?php echo $current_page; ?>/<?php echo $perpage; ?>/<?php echo ($keyword)?$keyword:'default'; ?>/<?php echo $status; ?>/<?php echo ($province)?$povince:'default'; ?>/<?php echo ($district)?$district:'default';?>/<?php echo ($daterange)?$daterange:'default'; ?>/<?php echo $sorting_order; ?>/<?php echo $sorting_field;?>">Xuáº¥t ra Excel</a>
+					<a style="color:#fff" href="<?php echo base_url();?>admin/user/export/<?php echo $current_page; ?>/<?php echo $perpage; ?>/<?php echo ($keyword)?$keyword:'default'; ?>/<?php echo $status; ?>/<?php echo ($province)?$province:'default'; ?>/<?php echo ($district)?$district:'default';?>/<?php echo ($date_start)?$date_start:'default'; ?>/<?php echo ($date_end)?$date_end:'default'; ?>/<?php echo $sorting_order; ?>/<?php echo $sorting_field;?>">Xuáº¥t ra Excel</a>
 					
                 </div>
@@ -83,5 +83,5 @@
 								<div class="dataTables_province" style="float: right;" id="sample-table-2_status"><label>Lá»c theo Tá»nh/TP:
 									<select onchange="filter();" name="province" class="form-field-province" size="1" style="width: 176px; height: 28px;">
-										<option value=''></option>
+										<option value=''>Táº¥t cáº£</option>
 						
 										<?php foreach ($provinces as $key => $pro): ?>
@@ -94,5 +94,5 @@
 									<select onchange="filter();" name="district" id="form-field-district" class="form-field-district" size="1" style="width: 176px; height: 28px;">
 										<?php if ($districts):?>
-											<option value=''></option>
+											<option value=''>Táº¥t cáº£</option>
 											<?php foreach ($districts as $key => $dist): ?>
 												<option <?php if ($dist['district_id'] == $district) echo "selected"; ?> value="<?php echo $dist['district_id']; ?>"><?php echo $dist['district_name']; ?></option>
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/collaborator.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/collaborator.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/collaborator.php	(revision 906)
@@ -14,175 +14,37 @@
 		$this->lang->load('messages', 'message');
     }
-
-    public function index() {
-        $data = array();
-        $collaborator_info = $this->session->userdata('collaboratorInfo');
-        if ($collaborator_info) {
-            $data['statistics'] = $this->getStatistics();
-            $data['content'] = $this->getCollaborators();
-            $this->load->view('collaborator/reportAsistant/index', $data);
-        } else {
-            $this->load->view('login');
-        }
-    }
-
-    public function viewAsistant() {
-        $data = array();
-
-        $collaborator_info = $this->session->userdata('collaboratorInfo');
-        if ($collaborator_info) {
-            $id = $this->uri->segment(2);
-            $data['id'] = $id;
-            $data['statistics'] = $this->getStatistics($id);
-            $data['content'] = $this->getCollaboratorsUsers(array(), $id);
-            $this->load->view('collaborator/reportAsistant/indexCollaborator', $data);
-        } else {
-            $this->load->view('login');
-        }
-    }
-
-    public function getStatistics($id = false) {
-        $data = array();
-
-        $this_year['start'] = strtotime(date("Y") . "-01-01 00:00:00");
-
-        $this->load->model('admin/collabolator_model');
-        $collaborators = $this->collabolator_model->getAllCollaboratorUser($this_year['start'], $id);
-        for ($i = 1; $i <= 12; $i++) {
-            $statistics[$i] = 0;
-        }
-        $y = date("Y");
-        foreach ($collaborators as $collaborator) {
-            for ($i = 1; $i <= 12; $i++) {
-                if ($i < 12) {
-                    if (($collaborator['time'] > strtotime($y . "-" . $i . "-1 00:00:00")) && (($collaborator['time'] < strtotime($y . "-" . ($i + 1) . "-1 00:00:00")))) {
-                        $statistics[$i] ++;
-                    }
-                } else {
-                    if (($collaborator['time'] > strtotime($y . "-" . $i . "-1 00:00:00")) && (($collaborator['time'] < strtotime(($y + 1) . "-1-1 00:00:00")))) {
-                        $statistics[$i] ++;
-                    }
-                }
-            }
-        }
-
-        $max = 0;
-        foreach ($statistics as $index => $total) {
-            if ($total > $max) {
-                $max = $total;
-            }
-            $chart[] = array($index, $total);
-        }
-
-        $data['max'] = $max;
-        $chard[] = array("color" => "#e67e22", "label" => "LÆ°á»£ng ngÆ°á»i dÃ¹ng giá»i thiá»u bá»i cá»ng tÃ¡c viÃªn theo tá»«ng thÃ¡ng", "data" => $chart);
-        $data['chard'] = $chard;
-         
-        return $this->load->view('collaborator/reportAsistant/statistics', $data, true);
-    }
-
-    public function getLastquarter() {
-        $current_month = date('m');
-        $current_year = date('Y');
-
-        if ($current_month >= 1 && $current_month <= 3) {
-            $start_date = strtotime('1-October-' . ($current_year - 1));  // timestamp or 1-October Last Year 12:00:00 AM
-            $end_date = strtotime('1-Janauary-' . $current_year);  // // timestamp or 1-January  12:00:00 AM means end of 31 December Last year
-        } else if ($current_month >= 4 && $current_month <= 6) {
-            $start_date = strtotime('1-January-' . $current_year);  // timestamp or 1-Janauray 12:00:00 AM
-            $end_date = strtotime('1-April-' . $current_year);  // timestamp or 1-April 12:00:00 AM means end of 31 March
-        } else if ($current_month >= 7 && $current_month <= 9) {
-            $start_date = strtotime('1-April-' . $current_year);  // timestamp or 1-April 12:00:00 AM
-            $end_date = strtotime('1-July-' . $current_year);  // timestamp or 1-July 12:00:00 AM means end of 30 June
-        } else if ($current_month >= 10 && $current_month <= 12) {
-            $start_date = strtotime('1-July-' . $current_year);  // timestamp or 1-July 12:00:00 AM
-            $end_date = strtotime('1-October-' . $current_year);  // timestamp or 1-October 12:00:00 AM means end of 30 September
-        }
-        return array("start" => $start_date, "end" => $end_date);
-    }
-
-
-    public function getCollaboratorsUsers($filters = array(), $id = false) {
-
-        $this->load->helper('pagging');
-        $this->load->model('admin/collabolator_model');
-        $data['current_page'] = $this->uri->segment(5, 1);
-
-        $data['itemsoptions'] = array(10, 25, 50, 100);
-        $data['perpage'] = 10;
-        if (!$id) {
-            $data['id'] = $this->uri->segment(4, 1);
-        } else {
-            $data['id'] = $id;
-        }
-
-        $data['keyword'] = "";
-        $data['sorting_order'] = "sorting_desc";
-        $data['sorting_field'] = "id";
-
-        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('keyword')) {
-            $data['search_field'] = "";
-            $data['keyword'] = $this->input->post('keyword');
-
-            if (preg_match("/[0-9]/", $data['keyword'])) {
-                $data['search_field'] = "cellphone";
-            }
-        }
-
-		$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->collabolator_model->countCountCollaboratorUsers($data);
-        $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
-        foreach ($data['paidlogs'] as $index=>$paidlog)
-        {
-            $data['paidlogs'][$index]['username']=$this->get_fullname($paidlog['us_id']);
-        }
-        $data['paging_url'] = base_url() . "/cong_tac_vien/thong_ke_cong_tac_vien/trang_ctv/" . $data['id'];
-        $data['num_links'] = 2;
-        $data['paging'] = pagging($data);
-
-        if ($this->input->is_ajax_request()) {
-            return $this->load->view('collaborator/reportAsistant/listview_user', $data);
-        }
-        return $this->load->view('collaborator/reportAsistant/listview_user', $data, true);
-    }
-
-    private function get_fullname($us_id) {
-        $fullname="";
-        $src = 'violet';
-        $token = md5($us_id . self::TOKENPW);
-        $this->load->model('admin/user_model');
-        $data = $this->user_model->get_user_info($src, $us_id, $token);
-        parse_str($data,$data);
-        if (isset($data['fullname']))
-        {
-            $fullname=$data['fullname'];
-        }
-        return $fullname;
-    }
-
+	
 	public function profile(){
 		$collaborator_info = $this->session->userdata('collaboratorInfo');
         if ($collaborator_info) {
 			$data['collaborator_id'] = $collaborator_info['id'];
+			$data['username'] = $collaborator_info['login_name'];
+			$data['fullname'] = $collaborator_info['fullname'];
 			$this->load->view('collaborator/collaborator_profile', $data);
+		}else{
+			$this->load->view('login');
+		}
+	}
+	
+	public function updateCollaborator(){
+		$this->load->model('collaborator_model');
+		$collaborator_info = $this->session->userdata('collaboratorInfo');
+		$result['success'] = 0;
+        if ($collaborator_info) {
+			
+			$collaborator_id = $collaborator_info['id'];
+			$login_name = $collaborator_info['login_name'];
+			$input = $this->input->post();
+			if (strlen($input['fullname']) == 0) {
+				$result['errors'][] = array("content"=>lang('_SBG_FULLNAME_REQUIRED_MSG'),"field"=>"fullname_err");
+			}
+			if (!isset($result['errors'])) {
+				$collaborator = array('full_name' => $input['fullname']);
+				$result['success'] = 1;
+				$result['data'] = $this->collaborator_model->updateCollaborator($collaborator_id, $collaborator);
+                $collaboratorData = array('login_name' => $login_name, 'id' => $collaborator_id, 'fullname' => $input['fullname'], 'logined_in' => TRUE);
+                $this->session->set_userdata('collaboratorInfo', $collaboratorData);
+			}
+			echo json_encode($result);
 		}else{
 			$this->load->view('login');
@@ -192,5 +54,4 @@
 	public function change_password(){
 		$this->load->model('collaborator_model');
-		//$collaborator_id = $this->uri->segment(4, 1);
 		$collaborator_info = $this->session->userdata('collaboratorInfo');
         if ($collaborator_info) {
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/home.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/home.php	(revision 906)
@@ -20,7 +20,6 @@
         if ($collaborator_info) {
 			$id = $collaborator_info['id'];
-            $data['id'] = $id;
             $data['statistics'] = $this->getStatistics($id);
-            $data['content'] = $this->getCollaboratorsUsers(array(), $id);
+			$data['content'] = $this->getCollaboratorsUsers();
             $this->load->view('collaborator/reportAsistant/indexCollaborator', $data);
         } else {
@@ -122,68 +121,68 @@
 
 
-    public function getCollaboratorsUsers($filters = array(), $id = false) {
-
-        $this->load->helper('pagging');
-        $this->load->model('admin/collabolator_model');
-        $data['current_page'] = $this->uri->segment(5, 1);
-
-        $data['itemsoptions'] = array(10, 25, 50, 100);
-        $data['perpage'] = 10;
-        if (!$id) {
-            $data['id'] = $this->uri->segment(4, 1);
-        } else {
+    public function getCollaboratorsUsers() {
+		$collaborator_info = $this->session->userdata('collaboratorInfo');
+        if ($collaborator_info) {
+			$this->load->helper('pagging');
+			$this->load->model('admin/collabolator_model');
+			$data['current_page'] = $this->uri->segment(5, 1);
+			
+			$data['itemsoptions'] = array(10, 25, 50, 100);
+			$data['perpage'] = 10;
+			$id = $collaborator_info['id'];
             $data['id'] = $id;
-        }
-	
-        $data['keyword'] = "";
-        $data['sorting_order'] = "sorting_desc";
-        $data['sorting_field'] = "id";
-
-        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('keyword')) {
-            $data['search_field'] = "";
-            $data['keyword'] = $this->input->post('keyword');
-
-            if (preg_match("/[0-9]/", $data['keyword'])) {
-                $data['search_field'] = "cellphone";
-            }
-        }
-
-		$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['keyword'] = "";
+			$data['sorting_order'] = "sorting_desc";
+			$data['sorting_field'] = "user_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('keyword')) {
+				$data['search_field'] = "";
+				$data['keyword'] = $this->input->post('keyword');
+
+				if (preg_match("/[0-9]/", $data['keyword'])) {
+					$data['search_field'] = "cellphone";
+				}
+			}
+
+			$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['date_start'] = $daterange[0];
+				$data['date_end'] = $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->collabolator_model->countCountCollaboratorUsers($data);
+			$data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
+			foreach ($data['paidlogs'] as $index => $paidlog)
+			{
+				$data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']);
+			}
+			$data['paging_url'] = base_url() . "collaborator/home/getCollaboratorsUsers/".$data['id'];
+			$data['num_links'] = 2;
+			$data['paging'] = pagging($data);
+		
+			if ($this->input->is_ajax_request()) {
+				return $this->load->view('collaborator/reportAsistant/listview_user', $data);
+			}
+			return $this->load->view('collaborator/reportAsistant/listview_user', $data, true);
+		}else{
+			$this->load->view('login');
 		}
-		
-        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
-        $data['total'] = $this->collabolator_model->countCountCollaboratorUsers($data);
-        $data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
-
-        foreach ($data['paidlogs'] as $index => $paidlog)
-        {
-
-            $data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']);
-        }
-		
-        $data['paging_url'] = base_url() . "cong_tac_vien/thong_ke_nguoi_dung/trang/" ;
-        $data['num_links'] = 2;
-        $data['paging'] = pagging($data);
-		
-        if ($this->input->is_ajax_request()) {
-            return $this->load->view('collaborator/reportAsistant/listview_user', $data);
-        }
-        return $this->load->view('collaborator/reportAsistant/listview_user', $data, true);
     }
 
@@ -202,3 +201,157 @@
     }
 	
+	
+	public function export(){
+		
+		$collaborator_info = $this->session->userdata('collaboratorInfo');
+        if ($collaborator_info) {
+			$id = $collaborator_info['id'];
+            $data['id'] = $id;
+			$data['fullname'] = $collaborator_info['fullname'];
+			$this->load->model('admin/collabolator_model');
+			//$data['perpage'] = $this->uri->segment(4, 10);
+			$data['keyword'] = $this->uri->segment(5);
+			if ($data['keyword'] == 'default') $data['keyword'] = null;
+			if (preg_match("/[0-9]/", $data['keyword'])) {
+					$data['search_field'] = "cellphone";
+			}
+			$data['daterange_start'] = $this->uri->segment(6);
+			$data['daterange_end'] = $this->uri->segment(7);
+			if ($data['daterange_start'] == 'default') $data['daterange_start'] = null;
+			if ($data['daterange_end'] == 'default') $data['daterange_end'] = null;
+			if ($data['daterange_start'])
+				$data['daterange_start'] = date ( 'Y-m-d H:i:s', strtotime ( $data ['daterange_start'] ) );
+			if ($data['daterange_end'])
+				$data['daterange_end'] = date ( 'Y-m-d H:i:s', strtotime ( $data['daterange_end'] . ' + 1 day' ) );
+			
+			$data['sorting_field'] = "user_created_time";
+			$data['sorting_order'] = $this->uri->segment(8);
+			
+			$data['paidlogs'] = $this->collabolator_model->getCountCollaboratorUsers($data);
+			
+			foreach ($data['paidlogs'] as $index => $paidlog)
+			{
+				$data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']);
+			}
+			$users = $data['paidlogs'];
+			
+			ob_end_clean();
+			$this->load->library("PHPExcel");
+			$sheet = $this->phpexcel->getActiveSheet();
+			
+			$sheet->setTitle("bao cao cua CTV " . date('m') . " - " . date('Y'));
+			$sheet->getColumnDimension('A')->setWidth(10);
+			$sheet->getColumnDimension('B')->setWidth(25);
+			$sheet->getColumnDimension('C')->setWidth(25);
+			$sheet->getColumnDimension('D')->setWidth(25);
+			$sheet->getColumnDimension('E')->setWidth(15);
+			$sheet->getColumnDimension('F')->setWidth(15);
+			$sheet->getColumnDimension('G')->setWidth(15);
+			$sheet->getColumnDimension('H')->setWidth(25); 
+			$sheet->getColumnDimension('I')->setWidth(25);
+			
+			
+			$sheet->setCellValue('B1', "Táº¬P ÄOÃN VIá»N THÃNG QUÃN Äá»I");
+			$style = array(
+				'font' => array('bold' => true, 'size' => 12, 'name' =>'Cambria', 'color' => array('rgb' => '0070bf')),
+				'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+									'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
+									'wrap' => true )
+			);
+			$sheet->mergeCells('B1:E1');
+			$sheet->getStyle('B1')->applyFromArray($style);
+			
+			$sheet->setCellValue('B2', "Tá»NG CÃNG TY VIá»N THÃNG VIETTEL");
+			$style = array(
+				'font' => array('size' => 12, 'name' =>'Cambria', 'color' => array('rgb' => '0070bf')),
+				'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+									'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
+									'wrap' => true )
+			);
+			$sheet->mergeCells('B2:E2');
+			$sheet->getStyle('B2')->applyFromArray($style);
+			
+			
+			$sheet->setCellValue('A4', "DANH SÃCH NGÆ¯á»I DÃNG DO Cá»NG TÃC VIÃN GIá»I THIá»U");
+			$style = array(
+				'font' => array('bold' => true, 'size' => 14, 'name' =>'Cambria'),
+				'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+									'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
+									'wrap' => true )
+			);
+			$sheet->mergeCells('A4:E4');
+			$sheet->getStyle('A4')->applyFromArray($style);
+			
+			
+			
+			$style = array(
+				'font' => array('size' => 11, 'name' =>'Cambria'),
+				'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+									'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
+									'wrap' => true),
+				'borders' =>	array(
+					'allborders' => array(
+						'style' => \PHPExcel_Style_Border::BORDER_THIN
+						)
+				)
+			);
+			
+			$sheet->setCellValue('B6', "Tá»« ngÃ y: ".$data['daterange_start']);
+			$sheet->setCellValue('C6', "Äáº¿n ngÃ y: ".$data['daterange_end']);
+			$sheet->setCellValue('B7', "NgÃ y káº¿t xuáº¥t: ".date("d")."/".date("m")."/".date("Y"));
+			$sheet->setCellValue('C7', "CTV: ".$data['fullname']);
+			
+			$sheet->getStyle('B6')->applyFromArray($style);
+			$sheet->getStyle('C6')->applyFromArray($style);
+			$sheet->getStyle('B7')->applyFromArray($style);
+			$sheet->getStyle('C7')->applyFromArray($style);
+			
+			$sheet->setCellValue('A9', 'STT');
+			$sheet->setCellValue('B9', 'TÃªn ngÆ°á»i dÃ¹ng');
+			$sheet->setCellValue('C9', 'Sá» thuÃª bao');
+			$sheet->setCellValue('D9', 'NgÃ y giá» giá»i thiá»u');
+			$style = array(
+				'font' => array('bold' => true, 'size' => 11, 'name' =>'Cambria'),
+				'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+									'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
+									'wrap' => true),
+				'borders' =>	array(
+					'allborders' => array(
+						'style' => \PHPExcel_Style_Border::BORDER_THIN
+						)
+				)
+			);
+			$sheet->getStyle('A9:D9')->applyFromArray($style);
+			
+			$style = array(
+				'font' => array('size' => 11, 'name' =>'Cambria'),
+				'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+									'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER,
+									'wrap' => true),
+				'borders' =>	array(
+					'allborders' => array(
+						'style' => \PHPExcel_Style_Border::BORDER_THIN
+						)
+				)
+			);
+			
+			$dem = 0;
+			foreach ($users as $index => $user):
+				$sheet->setCellValue('A' . ($dem + 10), $index + 1);
+				$sheet->setCellValue('B' . ($dem + 10), $user['username']);
+				$sheet->setCellValueExplicit('C' . ($dem + 10), $user['user_cellphone'], PHPExcel_Cell_DataType::TYPE_STRING);
+				$sheet->setCellValue('D' . ($dem + 10), $user['user_created_time']);
+				$sheet->getStyle('A' . ($dem + 10).':D'.($dem + 10))->applyFromArray($style);
+				$dem++;
+			endforeach;
+			
+			$writer = new PHPExcel_Writer_Excel5($this->phpexcel);
+			header('Content-Type: application/vnd.ms-excel');
+			header('Content-Disposition: attachment; filename="danhsachnguoidung_ctv_'.date('d/m/Y').'.xls"');
+			$writer->save('php://output');
+		}else{
+			$this->load->view('login');
+		}
+	}
+	
 }
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/user.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/controllers/user.php	(revision 906)
@@ -22,5 +22,5 @@
 			$this->load->view('collaborator/user/index', $data);
 		}else{
-			show_404();
+			$this->load->view(login);
 		}
 	}
@@ -32,9 +32,5 @@
 			$collaborator = $collaborator_info['login_name'];
 			$config['upload_path'] = './upload/uploads/';
-			$config['allowed_types'] = 'xls|xlsx';
-			/*$config['max_size']	= '100';
-			$config['max_width']  = '1024';
-			$config['max_height']  = '768';*/
-			
+			$config['allowed_types'] = '*';
 			$this->load->library('upload', $config);
 			
@@ -43,5 +39,5 @@
 				$error = array('error' => $this->upload->display_errors('', ''));
 				$data['success'] = 0;
-				$data['process'] = $error;
+				$data['upload_error'] = $error;
 			}
 			else
@@ -49,11 +45,9 @@
 				$data = array('upload_data' => $this->upload->data());
 				$file = $data['upload_data']['full_path'];
-				//$result = $this->processData($file);
 				$process = $this->processData($file, $collaborator);
 				if ($process){
 					$data['process'] = $process;
-					
 				}else{
-					$data['process'] = null;
+					$data['process'] = null;				
 				}
 				$data['success'] = 1;
@@ -61,6 +55,7 @@
 			$result = $this->load->view('collaborator/user/result', $data, true);
 			echo json_encode($result);
+
 		}else{
-			show_404();
+			$this->load->view('login');
 		}
 	}
@@ -93,4 +88,5 @@
 		$this->load->model('collaborator_model');
 		$data = $this->readExcelFile($file);
+
 		$result = array();
 		$user = array();
@@ -104,26 +100,23 @@
 				$user['district'] = $arrPD['district'];
 				$user['school'] = $value['E'];
-				$user['username'] = $this->services_model->formatPhoneNumber($value['F'], 2);
+				$user['username'] = $this->services_model->formatPhoneNumber((string)$value['F'], 2);
 				$user['service'] = $value['G'];
 				$user['amount'] = $value['H'];
 				$user['collboratorId'] = $value['I'];
 				
+				
 				if ($user['username']){
 	
 					if (!preg_match('/^([0-9]{10,11}$)$/', $user['username'])) {
-						$result[$index]['success'] = 0;
-						$result[$index]['error'] = lang('_SBG_MO_PHONENUM_WRONG_FORMAT_MSG');
-						$result[$index]['user'] = $user;
+						$result[$index-1]['success'] = 0;
+						$result[$index-1]['error'] = lang('_SBG_MO_PHONENUM_WRONG_FORMAT_MSG');
+						$result[$index-1]['user'] = $user;
 					}else{
-						$result[$index] = $this->collaborator_model->processUser($user, $sentNumber);
-						
-						
+						$result[$index-1] = $this->collaborator_model->processUser($user, $sentNumber);
 					}
-					$result[$index]['date'] = date('d-m-Y H:i:s');
 				}
 				
 			endforeach;
 		}
-		
 		return $result;
 	}
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/models/collaborator_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/models/collaborator_model.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/models/collaborator_model.php	(revision 906)
@@ -7,5 +7,5 @@
 if ( ! defined('_SBG_REGISTER_VIP_FOR')) 				define('_SBG_REGISTER_VIP_FOR', 				'VIP');
 if ( ! defined('_SBG_CHARGING_FOR')) 					define('_SBG_CHARGING_FOR', 				'NAP');
-if ( ! defined('_SBG_SYNTAX_ERR')) 					define('_SBG_SYNTAX_ERR', 			'SYNTAX_ERR');
+if ( ! defined('_SBG_SYNTAX_ERR')) 						define('_SBG_SYNTAX_ERR', 			'SYNTAX_ERR');
 
 if ( ! defined('_SBG_CHARGING_SUCCESS')) 				define('_SBG_CHARGING_SUCCESS', 1);
@@ -24,4 +24,6 @@
 if ( ! defined('_SBG_PAIDTYPE_CARD')) define('_SBG_PAIDTYPE_CARD', 2);
 
+if ( ! defined('_SBG_MO_PROCCESS_ERR')) 				define('_SBG_MO_PROCCESS_ERR', 0);
+
 class Collaborator_model extends CI_Model {
 	
@@ -40,8 +42,4 @@
 		$this->load->helper('language');
 		$this->lang->load('messages', 'message');
-	}
-	
-	public function isExistUser($username){
-		return false;
 	}
 	
@@ -66,17 +64,115 @@
 		}
 		
+		
 		return array('case' => $case, 'content' => $aryContent);
 	}
 	
-	public function processUser($user, $sentNumber){
+	public function isExistUser($cellphone)
+	{
+		$sql = "SELECT * FROM tbluser WHERE cellphone = ?";
+		$this->db->query($sql, array('cellphone'=>$cellphone));
+		if ($this->db->affected_rows() >0){
+			return true;
+		}else{
+			return false;
+		}
+	}
+	
+	public function processUser($user, $sentNumber)
+	{
+		$this->load->model('frontend/user_model');
+		$data = array();
+		$data['charging'] = array();
+		$data['register-vip'] = array();
+		$data['register'] = array();
+		$username = $user['username'];
+		$service = $user['service'];
+		$amount = $user['amount'];
+		$isExist = $this->isExistUser($username);
+		//$isExist = false;
+		if (!$isExist){
+			$data['register']['data'] = $this->registerUser($user, $sentNumber);
+			$user['service'] = "ÄÄng kÃœ";
+			$user['amount'] = null;
+			$data['register']['user'] = $user;
+			$data['register']['date'] = date('d-m-Y H:i:s');
+		}else{
+			$data['register']['data']['success'] = 0;
+			$data['register']['data']['error'] = "NgÆ°á»i dÃ¹ng ÄÃ£ tá»n táº¡i";
+			$user['service'] = "ÄÄng kÃœ";
+			$user['amount'] = null;
+			$data['register']['user'] = $user;
+			$data['register']['date'] = date('d-m-Y H:i:s');
+		}
+		
+		// NAP
+		if ($amount){
+			$user['amount'] = $amount;
+			$data['charging']['data'] = $this->chargingForUser($user, $sentNumber);
+			$user['service'] = "Náº¡p tiá»n";
+			$data['charging']['user'] = $user;
+			$data['charging']['date'] = date('d-m-Y H:i:s');
+		}
+		if ($service){
+			// ÄK VIP
+			
+			$aryMatched = explode(' ', trim($service));
+			$p_code = $aryMatched[1];
+			$package = $package = $this->user_model->get_package ( $p_code );
+			$amount = $package['p_price'];
+			$user['amount'] = $amount;
+			$data['chargingvip']['data'] = $this->chargingForUser($user, $sentNumber);
+			$user['service'] = "Náº¡p tiá»n";
+			$data['chargingvip']['user'] = $user;
+			$data['chargingvip']['date'] = date('d-m-Y H:i:s');
+			
+			if ($data['chargingvip']['data']['success'] == 1){
+			
+				$data['register-vip']['data'] = $this->registerVipUser($user, $p_code);
+				$user['service'] = "ÄÄng kÃœ ".trim($service);
+				$user['amount'] = -$amount;
+				$data['register-vip']['user'] = $user;
+				$data['register-vip']['date'] = date('d-m-Y H:i:s');
+			}else{
+				$data['register-vip']['data']['success'] = 0;
+				$data['register-vip']['data']['error'] = "TÃ i khoáº£n chÃ­nh cá»§a thuÃª bao ".$sentNumber. " khÃŽng Äá»§ Äá» thá»±c hiá»n giao dá»ch nÃ y";
+				$user['service'] = "ÄÄng kÃœ ".trim($service);
+				$user['amount'] = -$amount;
+				$data['register-vip']['user'] = $user;
+				$data['register-vip']['date'] = date('d-m-Y H:i:s');
+			}
+			
+		}
+		/*	
+		}elseif ($service){
+			// ÄK VIP
+			$aryMatched = explode(' ', trim($service));
+			$p_code = $aryMatched[1];
+			$data['register-vip']['data'] = $this->registerVipUser($user, $p_code);
+			$user['service'] = "ÄÄng kÃœ ".trim($service);
+			$data['register-vip']['user'] = $user;
+			$data['register-vip']['date'] = date('d-m-Y H:i:s');
+		}else{
+			// DK
+			$data['register']['data'] = $this->registerUser($user, $sentNumber);
+			$user['service'] = "ÄÄng kÃœ";
+			$data['register']['user'] = $user;
+			$data['register']['date'] = date('d-m-Y H:i:s');
+		}*/
+		return $data;
+	}
+	/*
+	public function processUser($user, $sentNumber)
+	{
 		$data = array();	
 		$serviceAnalys = $this->serviceAnalys($user['service']);
 		
 		$case = $serviceAnalys['case'];
-		$aryContents = isset($serviceAnalys['content']) ? $serviceAnalys['content']: null;
+		$aryContents = isset($serviceAn
+		alys['content']) ? $serviceAnalys['content']: null;
 		
 		switch($case){
 			case _SBG_REGISTER_FOR:
-				$data = $this->registerUser($user);
+				$data = $this->registerUser($user, $sentNumber);
 				break;
 			case _SBG_REGISTER_VIP_FOR:
@@ -98,9 +194,10 @@
 		
 	}
-
-	public function registerUser($user){
+*/
+	public function registerUser($user, $sentNumber)
+	{
 
 		$data = array();
-		$data['user'] = $user;
+		//$data['user'] = $user;
 		$this->load->model('frontend/user_model');
 		$this->load->model('services/services_model');
@@ -108,5 +205,5 @@
 		$token = md5($user['username'] . self::TOKENPW);
 		$sms = '';
-		$collborator = $user['collboratorId'];
+		$collboratorId = $user['collboratorId'];
 		$username = $user['username'];
 		$password = $this->createRandomPassword();
@@ -139,5 +236,5 @@
 				$arrUser['us_id'] = $us_id;
 				$arrUser['cellphone'] = $username;
-				$arrUser['collborator'] = $collborator;
+				$arrUser['collaborator'] = $sentNumber;
 				$arrUser['acc_balanced'] = 0;
 				$arrUser['p_id'] = $trialpackage['p_id'];
@@ -178,7 +275,8 @@
 	}
 	
-	public function registerVipUser($arrUser, $p_code){
+	public function registerVipUser($arrUser, $p_code)
+	{
 		$data = array();
-		$data['user'] = $arrUser;
+		//$data['user'] = $arrUser;
 		$this->load->model('frontend/user_model');
 		$username = $arrUser['username'];
@@ -232,12 +330,19 @@
 	}
 	
-	public function chargingForUser($user, $sentNumber){
+	public function chargingForUser($user, $sentNumber)
+	{
 
 		$this->load->model('services/services_model');
 		$this->load->model('frontend/user_model');
 		$data = array();
-		$data['user'] = $user;
+		//$data['user'] = $user;
 		$username = $user['username'];
 		$amount = $user['amount'];
+		
+		if (!preg_match('/^[0-9]{3,}$/', $amount)) {
+			$smsReturn = lang('_SBG_MO_AMOUNT_WRONG_FORMAT_MSG');
+			$data['success'] = 0;
+			$data['error'] = $smsReturn;
+		}
 	
 		$result =$this->services_model->chargeRootAccountProcess($sentNumber, $amount, $sentNumber.' paid for SBG');
@@ -284,6 +389,32 @@
 	}
 	
-	
-	public function createRandomPassword(){
+	public function getCollaboratorByPhone($sentNumber){
+		$sql = "SELECT * from tblcollaborator where login_name = ? LIMIT 0,1";
+		$query = $this->db->query ( $sql, array ( $sentNumber  ) );
+		$row = $query->row_array ();
+		return $row;
+	}
+	
+	public function getPassword($sentNumber){
+		$collaborator = array();
+		$collaborator = $this->getCollaboratorByPhone($sentNumber);
+		if ($collaborator){
+			$passwd = $this->createRandomPassword();
+			$collaborator['passwd'] = md5($passwd);
+			$this->updateCollaborator($collaborator['id'], $collaborator);
+			$aryPatterns = array('/:password:/');
+			$sms = preg_replace($aryPatterns, array($passwd), lang('_SBG_COLLABORATOR_PASSWORD_MSG'));
+			$status = 1;
+			
+		}else{
+			$aryPatterns = array('/:collaborator:/');
+			$sms = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_COLLABORATOR_NOT_FOUND_MSG'));
+			$status = 0;
+		}
+		return $status . '|' . $sms;
+	}
+	
+	public function createRandomPassword()
+	{
 		$alphabet = "0123456789";
 		$pass = array ();
@@ -296,18 +427,22 @@
 	}
 	
-	public function getProvinceAndDistict($province, $district){
-		$result['province'] = $province;
-		$result['district'] = $district;
+	public function getProvinceAndDistict($province, $district)
+	{
+		$result['province'] = '';
+		$p = trim(ucwords($province));
+		$result['district'] = '';
+		$d = trim(ucwords($district));
 		$provinces = lang('_PROVINCES_');
 
 		foreach ($provinces as $key => $pro):
-			if($province == $pro){
+			if($p == $pro){
 				$result['province'] = $key;
 				break;
 			}
 		endforeach;
-		$sql = "SELECT * FROM tbldistrict where province_id = ? AND district_name = ?";
-		
-		$query = $this->db->query ( $sql, array ($result['province'], $result['district']) );
+		//$sql = "SELECT * FROM tbldistrict where province_id = ? AND district_name LIKE '%".$d."%'";
+		$sql = "SELECT * FROM tbldistrict where province_id = ? AND INSTR(?, district_name)>0";
+		//write_file('./log/sql.log', date('d-m-Y H:i:s') . ": " . $sql . "\n", FOPEN_WRITE_CREATE);
+		$query = $this->db->query ( $sql, array ($result['province'], $d) );
 		if ($query->num_rows () > 0) {
 			$row = $query->row_array ();
@@ -317,10 +452,12 @@
 	}
 	
-	public function updateCollaborator($id, $collaborator){
+	public function updateCollaborator($id, $collaborator)
+	{
 		$this->db->where ( 'id', $id );
 		return $this->db->update ( 'tblcollaborator', $collaborator );
 	}
 	
-	public function checkPassCollaborator($id, $passwd){
+	public function checkPassCollaborator($id, $passwd)
+	{
 		$passwd = md5($passwd);;
 		$sql = "SELECT * FROM tblcollaborator WHERE id = ? AND passwd = ?";
@@ -332,3 +469,14 @@
 		}
 	}
+	
+	public function insertUser($user)
+	{
+		$this->db->insert ( 'tbluser', $user );
+		//var_dump($user);
+		if ($this->db->affected_rows()>0){
+			return true;
+		}else{
+			return false;
+		}
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/views/collaborator_profile.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/views/collaborator_profile.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/views/collaborator_profile.php	(revision 906)
@@ -18,20 +18,56 @@
                 <div class="collaborator-profile row" id="collaborator-profile-3">
                     <div class="col-sm-offset-1 col-sm-10">
-
                         <div class="tabbable">
                             <ul class="nav nav-tabs padding-16">
-
-                                <li class="active">
-                                    <a id="edit-password-tab" href="" data-toggle="tab">
+								<li class="active">
+                                    <a id="edit-basic-tab" href="#edit-basic" data-toggle="tab">
+                                        <i class="blue icon-key bigger-125"></i>
+                                       ThÃŽng tin cÃ¡ nhÃ¢n
+                                    </a>
+                                </li>
+                                <li>
+                                    <a id="edit-password-tab" href="#edit-password" data-toggle="tab">
                                         <i class="blue icon-key bigger-125"></i>
                                        Thay Äá»i máº­t kháº©u
                                     </a>
                                 </li>
-
                             </ul>
-
+							
                             <div class="tab-content profile-edit-tab-content">
-                                <div class="tab-pane active" id="edit-password">
-									<!--<form id="frm-change-password" class="form-horizontal" role="form" action="<?php echo $base_url; ?>collaborator/collaborator/change_password" method="POST">-->
+								<div class="tab-pane active" id="edit-basic">		
+									<form id="frm-update-info" class="form-horizontal" role="form">
+										<h4 class="header blue bolder smaller">ThÃŽng tin cÃ¡ nhÃ¢n</h4>
+										<div class="row">
+                                            <div class="col-sm-9">
+												<div class="form-group">
+													<label for="form-field-username" class="col-sm-4 control-label no-padding-right">Sá» Äiá»n thoáº¡i</label>
+													<div class="col-sm-8">
+														<input type="text" name="username" value="<?php echo $username; ?>" placeholder="Sá» Äiá»n thoáº¡i" id="form-field-username" class="col-xs-12 col-sm-10" disabled>
+													</div>
+												</div>
+												<div class="form-group">
+													<label for="form-field-first" class="col-sm-4 control-label no-padding-right">Há» vÃ  tÃªn</label>
+													<label class="block clearfix has-error">										
+														<div class="col-sm-8">
+															<input type="text" name="fullname" value="<?php echo $fullname; ?>" placeholder="Há» vÃ  tÃªn" id="form-field-first" class="col-xs-12 col-sm-10">
+														</div>
+														<small><div class="col-sm-8 help-block" id="fullname_err"> </div></small>
+													</label>
+												</div>
+											</div>
+                                        </div>
+                                        <div class="clearfix form-actions">
+                                            <div class="col-md-offset-3 col-md-9">
+                                                <button type="button" onclick="return updateInfo();" class="btn btn-info">
+                                                    <i class="icon-ok bigger-110"></i>
+                                                    Cáº­p nháº­t
+                                                </button>	
+                                            </div>
+                                        </div>
+									</form>
+								</div>
+								
+                                <div class="tab-pane" id="edit-password">
+									
 									<form id="frm-change-password" class="form-horizontal" role="form">
 										<h4 class="header blue bolder smaller">Thay Äá»i máº­t kháº©u</h4>
@@ -81,5 +117,4 @@
 											<div class="col-md-offset-3 col-md-9">
 												<button type="button" onclick="return changePassword(<?php echo $collaborator_id; ?>);"  class="btn btn-info">
-												<!--<button type="submit"  class="btn btn-info">-->
 													<i class="icon-ok bigger-110"></i>
 													Thay Äá»i
@@ -90,4 +125,5 @@
 										</form>
                                 </div>
+								
 
                             </div>
@@ -103,4 +139,20 @@
 </div><!-- /.main-container-inner -->
 </div><!-- /.main-container -->
+
+<div class="modal fade" id="updateInfoSuccess" tabindex="-1" role="dialog"aria-hidden="true">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header">
+				<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+				<h4 class="modal-title">Cáº­p nháº­t thÃŽng tin</h4>
+			</div>
+			<div class="modal-body">
+				<div class="alert alert-block alert-success"><center><?php echo lang('_SBG_USER_UPDATE_INFO_SUCCESS_MSG'); ?><center></div>
+				<center><button id="close" class="btn btn-primary" data-dismiss="modal">ÄÃ³ng</button></center>
+			</div>
+		
+		</div>
+	</div>
+</div>
 
 <div class="modal fade" id="changePassSuccess" tabindex="-1" role="dialog"aria-hidden="true">
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/views/login.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/views/login.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/views/login.php	(revision 906)
@@ -80,4 +80,10 @@
 														<div class="help-block"> </div>
 													</label>
+													
+													<label class="block clearfix alert-success">
+															Náº¿u chÆ°a cÃ³ hoáº·c quÃªn máº­t kháº©u, soáº¡n tin nháº¯n theo cÃº phÃ¡p: <strong>SBG CTV</strong> gá»­i <strong>8062</strong>
+													</label>
+													
+												
 
 													<div class="space"></div>
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/indexCollaborator.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/indexCollaborator.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/indexCollaborator.php	(revision 906)
@@ -16,4 +16,5 @@
                 {
                     // $result = jQuery.parseJSON(data);
+					console.log(data);
                     $("#content").html(data);
                     init_page();
@@ -122,5 +123,5 @@
 		daterange = $('input[name="daterange"]').val();
         $.ajax({
-            url: '<?php echo base_url();?>cong_tac_vien/thong_ke_cong_tac_vien/trang_ctv/<?php echo $id;?>/1',
+            url: '<?php echo base_url();?>collaborator/home/getCollaboratorsUsers/<?php echo $id;?>/1',
             type: "POST",
             data: $("#collaborator").serialize(),
@@ -219,4 +220,4 @@
 </div><!-- /.modal-dialog -->
 <?php
-$this->load->view('layout/admin/footer', array('base_url' => $base_url,'adminjs' => array('assets/js/admin/collaborator.js')));
+$this->load->view('layout/collaborator/footer', array('base_url' => $base_url,'collaboratorjs' => array('assets/js/collaborator/collaborator.js')));
 ?>
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/listview_user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/listview_user.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/views/reportAsistant/listview_user.php	(revision 906)
@@ -3,5 +3,9 @@
             <!-- PAGE CONTENT BEGINS -->
             <div style="padding-bottom:4px" class="table-header">
+			
                 ÄÃ£ giá»i thiá»u
+				<div class="pull-right" style="margin:5px;">
+					<a style="color:#fff" href="<?php echo base_url();?>collaborator/home/export/<?php echo $perpage?>/<?php echo ($keyword)?$keyword:'default'; ?>/<?php echo ($date_start)?$date_start:'default'; ?>/<?php echo ($date_end)?$date_end:'default'; ?>/<?php echo $sorting_order; ?>">Xuáº¥t ra Excel</a>
+				</div>
             </div>
 
@@ -43,5 +47,5 @@
                                 <th class="<?php if ($sorting_field == 'full_name') {echo $sorting_order;} else {echo "";}?>" id="full_name" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Sá» Äiá»n thoáº¡i: activate to sort column ascending">TÃªn ngÆ°á»i dÃ¹ng</th>
                                 <th class="<?php if ($sorting_field == 'collaborator_cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_cellphone" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 283px;" aria-label="Há» tÃªn: activate to sort column ascending">Sá» thuÃª bao</th>
-                                <th class="<?php if ($sorting_field == 'total_user') {echo $sorting_order;} else {echo "sorting";}?>" id="total_user" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="Sá» Äiá»n thoáº¡i: activate to sort column ascending">NgÃ y giá»i thiá»u</th>  
+                                <th class="<?php if ($sorting_field == 'user_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="user_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 176px;" aria-label="NgÃ y giá»i thiá»u: activate to sort column ascending">NgÃ y giá»i thiá»u</th>  
                                 <!--<th class="<?php if ($sorting_field == 'collaborator_created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="collaborator_created_time" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="NgÃ y ÄÄng kÃœ: activate to sort column ascending">NgÃ y ÄÄng kÃœ</th>-->
                                   
@@ -52,4 +56,5 @@
                             
                             <?php
+							//var_dump($paidlogs);
                             foreach ($paidlogs as $paidlog) {
                                 ?>
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/index.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/index.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/index.php	(revision 906)
@@ -29,29 +29,59 @@
      <div class="row" id="content">
 		<div class="col-xs-12">
-			<div class="row">
-				<div class="col-sm-offset-1 col-sm-10">
-					<form method="POST" id="frm-upload" action="" enctype="multipart/form-data" class="form-horizontal">
-						<h4 class="header blue bolder smaller">Chá»n vÃ  táº£i file tá»« mÃ¡y tÃ­nh</h4>
-						<div class="row">
-							<div class="col-sm-9">
-								<div class="form-group">
-									<div class="col-sm-8" >
+			<div class="col-sm-offset-0 col-sm-12">
+				<div class="row">
+				<h4 class="header blue bolder smaller"> BÆ°á»c 1: Táº£i file ÄÄng kÃœ <a href="<?php echo $base_url ?>assets/Mau dang ky cua CTV.xls"><span style="color: red;">Táº¡i ÄÃ¢y</span></a></h4>
+				</div>
+				<div class="row">
+					<h4 class="header blue bolder smaller">BÆ°á»c 2: Äiá»n thÃŽng tin vÃ o file ÄÄng kÃœ</h4>
+					<h5>
+					<ul class="nav">
+						<li>	<b>TÃªn khÃ¡ch hÃ ng</b>: KhÃŽng báº¯t buá»c</li>
+						<li>	<b>Tá»nh</b>: KhÃŽng báº¯t buá»c</li>
+						<li>	<b>Quáº­n/Huyá»n</b>: KhÃŽng báº¯t buá»c</li>
+						<li>	<b>ÄÆ¡n vá»</b>: KhÃŽng báº¯t buá»c</li>
+						<li>	<b>Sá» Äiá»n thoáº¡i khÃ¡ch hÃ ng</b>: Báº¯t buá»c (cÃ³ thá» cÃ³ sá» 0 Äá»©ng Äáº§u hoáº·c khÃŽng cÃ³; pháº£i lÃ  sá» Äiá»n thoáº¡i Äi Äá»ng, chá» há» trá»£ Viettel, Vinaphone vÃ  Mobifone)</li>
+						<li>	<b>ÄÄng kÃœ gÃ³i dá»ch vá»¥</b>: KhÃŽng báº¯t buá»c (Chá»n VIP 1 hoáº·c VIP 3 hoáº·c Äá» trá»ng)</li>
+						<li>	<b>Sá» tiá»n náº¡p vÃ o TK SBG cá»§a khÃ¡ch hÃ ng</b>: KhÃŽng báº¯t buá»c (Náº¿u chá»n thÃ¬ chá»n cÃ¡c giÃ¡ trá» cÃ³ sáºµn hoáº·c Äá» trá»ng)</li>
+						<li>	<b>MÃ£ CTV</b>: KhÃŽng báº¯t buá»c</li>
+					</ul>
+					</h5>
+				</div>
+				<div class="row">
+					<h4 class="header blue bolder smaller">LÆ°u Ãœ:</h4>
+					<h5><ul>
+						<li>	File ÄÄng kÃœ máº«u pháº£i giá»¯ nguyÃªn Äá»nh dáº¡ng XLS. KhÃŽng sá»­a Äá»nh dáº¡ng cá»§a file máº«u, má»i sá»± thay Äá»i khÃŽng ÄÃºng sáºœ cÃ³ thá» dáº«n Äáº¿n viá»c trá»« tiá»n tá»« tÃ i khoáº£n cá»§a CTV khÃŽng ÄÃºng.</li>
+						<li>	CÃ¡c giao dá»ch trÃªn file, náº¿u cÃ³ tÃ­nh phÃ­ thÃ¬ phÃ­ sáºœ ÄÆ°á»£c trá»« trá»±c tiáº¿p tá»« tÃ i khoáº£n chÃ­nh cá»§a sá» Äiá»n thoáº¡i CTV (chÃ­nh lÃ  sá» ÄT dÃ¹ng Äá» ÄÄng nháº­p).</li>
+					</ul></h5>
+				</div>
+				
+				<div class="row">
+					<h4 class="header blue bolder smaller">Buá»c 3: Upload file ÄÄng kÃœ</h4>
+					<div class="col-sm-offset-1 col-sm-10">
+						<!--<h4 class="header blue bolder smaller">Chá»n vÃ  táº£i file tá»« mÃ¡y tÃ­nh</h4>-->
+						<form method="POST" id="frm-upload" action="" enctype="multipart/form-data" class="form-horizontal">
+							
+							<div class="row">
+								<div class="col-sm-9">
+									<div class="form-group">
+										<div class="col-sm-8" >
+											
+											<input type="text" id="input-upload" class="form-control"/>
+											<div class="file-upload btn btn-success">
+												<span>Chá»n file ...</span>
+											
+												<input id="userfile" type="file" class="upload" name="userfile" />
+											</div>
+											<input type="submit" id="btn-submit" class="btn btn-primary" value="Táº£i lÃªn" />
+										</div>
 										
-										<input type="text" id="input-upload" class="form-control"/>
-										<div class="file-upload btn btn-success">
-											<span>Chá»n file ...</span>
-										
-											<input id="userfile" type="file" class="upload" name="userfile" />
-										</div>
-										<input type="submit" id="btn-submit" class="btn btn-primary" value="Táº£i lÃªn" />
 									</div>
-									
 								</div>
 							</div>
-						</div>
-						<h4 class="header blue bolder smaller"></h4>
-						
+							<h4 class="header blue bolder smaller"></h4>
+							
 
-					</form>
+						</form>
+					</div>
 				</div>
 			</div>
@@ -61,5 +91,7 @@
 	<center><label id="charging" style="display: none;"><h4><span class="icon-refresh icon-refresh-animate"></span> Äang xá»­ lÃœ. Xin vui lÃ²ng chá»...</h4></label></center>
 	<div id="result">
-	</div>	
+	</div>
+	
+	
 </div><!-- /.main-content -->
 </div><!-- /.main-container-inner -->
Index: pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/result.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/result.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/collaborator/views/user/result.php	(revision 906)
@@ -1,18 +1,14 @@
-<?php if($success==0){ ?>
+<?php if ($success == 0){ ?>
 	<div id="error-upload" class="alert alert-danger" role="alert">
 		<span class="icon-exclamation-sign" aria-hidden="true"></span>
-		<span class="sr-only">Error:</span> <?php echo " ".$process['error']; ?>
+		<span class="sr-only">Error:</span> <?php echo " ".$upload_error['error']; ?>
 	</div>
-<?php }elseif($success == 1){ ?>
-	<?php if ($process){?>
+<?php }else { ?>
+	<?php if($process){ ?>
 		<div class="row">
 			<div class="col-xs-12">
-				<!-- PAGE CONTENT BEGINS -->
 				<div style="padding-bottom:4px" class="table-header">
 				Káº¿t quáº£
 				</div>
-			<?php //if ($success == 0){ ?>
-				
-			<?php //}elseif($success == 1){ ?>
 				<div class="table-responsive">
 					<div role="grid" class="dataTables_wrapper" id="sample-table-2_wrapper">
@@ -21,50 +17,75 @@
 								<thead>
 									<tr role="row">
-										<th class="center sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 44px;" aria-label="">
-											<label>
-												<input type="checkbox" class="ace">
-												<span class="lbl"></span>
-											</label>
 										</th>
 										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Sá» Äiá»n thoáº¡i</th>
 										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Há» vÃ  tÃªn</th>
-										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">GÃ³i dá»ch vá»¥</th>
-										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Sá» tiá»n náº¡p vÃ o</th>
+										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">TÃªn dá»ch vá»¥</th>
+										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Sá» tiá»n</th>
 										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">NgÃ y giá» thá»±c hiá»n</th>
 										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">Káº¿t quáº£</th>
 										<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 156px;">LÃœ do</th>
 									</tr>
-									 <tbody role="alert" aria-live="polite" aria-relevant="all">
-
-										<?php
-										foreach ($process as $user): ?>
-										<tr class="odd">
-											<td class="center  sorting_1">
-												<label>
-													<input type="checkbox" class="ace">
-													<span class="lbl"></span>
-												</label>
-											</td>
-											<td class=" "><?php echo $user['user']['username']; ?></td>
-											<td class=" "><?php echo $user['user']['fullname']; ?></td>
-											<td class=" "><?php echo $user['user']['service']; ?></td>
-											<td class=" "><?php echo $user['user']['amount']; ?></td>
-											<td class=" "><?php echo $user['date']; ?></td>
-											<td class=" "><?php echo ($user['success'] == 1? "ThÃ nh cÃŽng": "KhÃŽng thÃ nh cÃŽng"); ?></td>
-											<td class=" "><?php  echo $user['error']; ?></td>
-										</tr>
-										<?php endforeach; ?>
+									<tbody role="alert" aria-live="polite" aria-relevant="all">
+									<?php foreach ($process as $result ){ ?>
+									
+										<?php if ($result['register']){ ?>
+											<tr>
+												<td class=" "><?php echo $result['register']['user']['username']; ?></td>
+												<td class=" "><?php echo $result['register']['user']['fullname']; ?></td>
+												<td class=" "><?php echo $result['register']['user']['service']; ?></td>
+												<td class=" "><?php echo $result['register']['user']['amount']; ?></td>
+												<td class=" "><?php echo $result['register']['date']; ?></td>
+												<td class=" "><?php echo ($result['register']['data']['success'] == 1? "ThÃ nh cÃŽng": "KhÃŽng thÃ nh cÃŽng"); ?></td>
+												<td class=" "><?php echo $result['register']['data']['error']; ?></td>
+											</tr>									
+										<?php } ?>
+										
+										<?php if ($result['charging']){ ?>
+											<tr>
+												<td class=" "><?php echo $result['charging']['user']['username']; ?></td>
+												<td class=" "><?php echo $result['charging']['user']['fullname']; ?></td>
+												<td class=" "><?php echo $result['charging']['user']['service']; ?></td>
+												<td class=" "><?php echo number_format($result['charging']['user']['amount'], 0); ?></td>
+												<td class=" "><?php echo $result['charging']['date']; ?></td>
+												<td class=" "><?php echo ($result['charging']['data']['success'] == 1? "ThÃ nh cÃŽng": "KhÃŽng thÃ nh cÃŽng"); ?></td>
+												<td class=" "><?php echo $result['charging']['data']['error']; ?></td>
+											</tr>									
+										<?php } ?>
+										
+										<?php if ($result['chargingvip']){ ?>
+											<tr>
+												<td class=" "><?php echo $result['chargingvip']['user']['username']; ?></td>
+												<td class=" "><?php echo $result['chargingvip']['user']['fullname']; ?></td>
+												<td class=" "><?php echo $result['chargingvip']['user']['service']; ?></td>
+												<td class=" "><?php echo number_format($result['chargingvip']['user']['amount'], 0); ?></td>
+												<td class=" "><?php echo $result['chargingvip']['date']; ?></td>
+												<td class=" "><?php echo ($result['chargingvip']['data']['success'] == 1? "ThÃ nh cÃŽng": "KhÃŽng thÃ nh cÃŽng"); ?></td>
+												<td class=" "><?php echo $result['chargingvip']['data']['error']; ?></td>
+											</tr>									
+										<?php } ?>
+										
+										<?php if ($result['register-vip']){ ?>
+											<tr>
+												<td class=" "><?php echo $result['register-vip']['user']['username']; ?></td>
+												<td class=" "><?php echo $result['register-vip']['user']['fullname']; ?></td>
+												<td class=" "><?php echo $result['register-vip']['user']['service']; ?></td>
+												<td class=" "><?php echo number_format($result['register-vip']['user']['amount'], 0); ?></td>
+												<td class=" "><?php echo $result['register-vip']['date']; ?></td>
+												<td class=" "><?php echo ($result['register-vip']['data']['success'] == 1? "ThÃ nh cÃŽng": "KhÃŽng thÃ nh cÃŽng"); ?></td>
+												<td class=" "><?php echo $result['register-vip']['data']['error']; ?></td>
+											</tr>									
+										<?php } ?>
+										
+										
+									<?php } ?>
+									
 									</tbody>
 								</thead>
-								</table>
+							</table>
 						</div>
 					</div>
 				</div>
 			</div>
-			</div>
-	<?php }else{ ?>
-		<div id="error-upload" class="alert alert-danger" role="alert">
-			<span class="icon-exclamation-sign" aria-hidden="true"></span>
-			<span class="sr-only">Error:</span> KhÃŽng Äá»c ÄÆ°á»£c file</div>
+		</div>							
 	<?php } ?>
 <?php } ?>
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 906)
@@ -136,13 +136,11 @@
 	
 	public function test(){
-		$aryMatch = array();
-		$phoneNumber = '987133325';
-		$regex = '/^[1,9][0-9]{8,9}$/';
-		if (preg_match('/^[1,9]([0-9]{8,9})$/', $phoneNumber, $aryMatch)){
-			$phoneNumber = "0".$phoneNumber;
-			echo $phoneNumber;
-		}else{
-			echo "Not match";
-		}
+		$this->load->model('collaborator/collaborator_model');
+		$province = ' Hà nội';
+		//$str = trim(ucwords($str));
+		$district = 'Quận Hai bà trưng';
+		$str = $this->collaborator_model->getProvinceAndDistict($province, $district);
+		var_dump($str);
+		//echo "Result: ".$str;
 	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/lecture.php	(revision 906)
@@ -53,5 +53,5 @@
             }
 			
-			if ($u['province'] == '' && $u['p_id'] != ''){
+			if ((!$u['province'] || !$u['district']) && $u['p_id'] != ''){
 				$update_user_info=1;
 			}
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 906)
@@ -286,4 +286,7 @@
 				if (strlen($input['province']) == 0) {
                     $result['errors'][] = array("content"=>lang('_SBG_PROVINCE_REQUIRED_MSG'),"field"=>"province");
+                }
+				if (strlen($input['district']) == 0) {
+                    $result['errors'][] = array("content"=>lang('_SBG_DISTRICT_REQUIRED_MSG'),"field"=>"district");
                 }
                 $input['password'] = '';
Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 906)
@@ -100,11 +100,12 @@
 				$this->db->insert ( 'tbluser', $user );
 				//write_file('./log/test.log', date("H:i:s m-d-Y").": ". var_export($user, TRUE)."\n" , FOPEN_WRITE_CREATE);
-				$aryPatterns = array ('/:trialdays:/', '/:username:/', '/:password:/');
+				//$aryPatterns = array ('/:trialdays:/', '/:username:/', '/:password:/');
+				$aryPatterns = array ('/:username:/', '/:password:/');
 				$trialdays = $this->config->item('trial_period');
 				$trialdays = strlen($trialdays) < 2 ? '0'. $trialdays : $trialdays;
 				if ($this->isViettel($username)){
-					$sms = preg_replace($aryPatterns, array($trialdays. ' ngay', $username, $password), lang('_SBG_MO_USER_VIETTEL_REGISTER_SUCCESS_MSG'));
+					$sms = preg_replace($aryPatterns, array($username, $password), lang('_SBG_MO_USER_VIETTEL_REGISTER_SUCCESS_MSG'));
 				}else{
-					$aryPatterns = array ('/:username:/', '/:password:/');
+					//$aryPatterns = array ('/:username:/', '/:password:/');
 					$sms = preg_replace($aryPatterns, array($username, $password), lang('_SBG_MO_USER_NOT_VIETTEL_REGISTER_SUCCESS_MSG'));
 				}
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/lecture_editor.php	(revision 906)
@@ -93,8 +93,12 @@
 						</div>
 						<div class="form-group">
-							<label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quáº­n / Huyá»n</label>
+							<label for="form-field-district" class="col-sm-4 control-label no-padding-right">Quáº­n / Huyá»n</label>
 							<div class="col-sm-8">
 								<select name="district" id="form-field-district" class="input-large"></select>
+								<label class="block clearfix has-error">
+									<div id="district" class="help-block error"></div>
+                                </label> 
 							</div>
+							
 						</div>
 
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/user_infor.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/user_infor.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/user_infor.php	(revision 906)
@@ -26,5 +26,6 @@
             <label for="form-field-username" class="col-sm-4 control-label no-padding-right">Tá»nh / ThÃ nh phá»</label>
             <div class="col-sm-8">
-                <select name="province" id="form-field-province" class="form-field-province col-xs-12 col-sm-10">
+                <select name="province" id="form-field-province" class="form-field-province-user col-xs-12 col-sm-10">
+					<option></option>
                     <?php foreach ($provinces as $key => $pro): ?>
                         <option value="<?php echo $key; ?>" <?php if ($user['province'] == $key) echo "selected"; ?>><?php echo $pro; ?></option>
@@ -38,5 +39,5 @@
 			<label for="form-field-username" class="col-sm-4 control-label no-padding-right">Quáº­n / Huyá»n</label>
 			<div class="col-sm-8">
-				<select name="district" id="form-field-district" class="form-field-district col-xs-12 col-sm-10">
+				<select name="district" id="form-field-district" class="form-field-district-user col-xs-12 col-sm-10">
 
 				</select>
@@ -60,11 +61,54 @@
 var district_id = "<?php echo $user['district']; ?>";
 var province_id = "<?php echo $user['province']; ?>";
+
 $(document).ready(function(){
-	$(".form-field-province").change(function(){
+	$(".form-field-province-user").change(function(){
 		changeEventProvince(province_id);
 	});
-	if ($(".form-field-province").val() !== 'undefined'){
+	if ($(".form-field-province-user").val() !== 'undefined'){
 		checkSelectedDistrict(province_id);
 	}
 });
+
+function changeEventProvince(provinceId){
+	$(".form-field-district-user").html("");
+	$.ajax({
+        url: '/frontend/user/getDistrict/' + provinceId,
+        type: 'POST',
+        success: function (data, textStatus, jqXHR)
+        {
+            result = jQuery.parseJSON(data);
+			content = "<option></option>";
+			if (result != null){
+				for (var i in result){			
+					content = content + '<option value="' + result[i].district_id + '">'+ result[i].type + " "  + result[i].district_name + '</option>'
+				}
+			}
+			$(".form-field-district-user").html(content);
+        }
+    });
+}
+
+function checkSelectedDistrict(provinceId){
+	$.ajax({
+        url: '/frontend/user/getDistrict/' + provinceId,
+        type: 'POST',
+        success: function (data, textStatus, jqXHR)
+        {
+            result = jQuery.parseJSON(data);	
+			content = "<option></option>";
+			if (result != null){
+				for (var i in result){
+					if (result[i].district_id === district_id){
+						content = content + '<option value="' + result[i].district_id + '" selected >' + result[i].type + " " + result[i].district_name + '</option>';
+					}else{
+						content = content + '<option value="' + result[i].district_id + '">' + result[i].type + " "  + result[i].district_name + '</option>';
+					}
+				}
+				
+			}
+			$(".form-field-district-user").html(content);
+        }
+    });
+}
 </script>
Index: pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/views/user_profile.php	(revision 906)
@@ -302,5 +302,5 @@
                                         <div class="alert alert-block alert-success">						
                                             <p>
-                                                QuÃœ vá» cÅ©ng cÃ³ thá» sá»­ dá»¥ng sá» Äiá»n thoáº¡i&nbsp;<strong><?php echo $username;?></strong> vÃ  soáº¡n tin theo cÃº phÃ¡p: <strong>SBG VIP 1</strong> (hay VIP 3, VIP 6, VIP 12) <strong>gá»­i tá»i 8062</strong> (Há» thá»ng sáºœ trá»« tiá»n trÃªn tÃ i khoáº£n chÃ­nh cá»§a sá» Äiá»n thoáº¡i&nbsp;<strong><?php echo $username;?></strong>)
+                                                QuÃœ vá» cÅ©ng cÃ³ thá» sá»­ dá»¥ng sá» Äiá»n thoáº¡i&nbsp;<strong><?php echo $username;?></strong> vÃ  soáº¡n tin theo cÃº phÃ¡p: <strong>SBG VIP 1</strong> (hay VIP 3) <strong>gá»­i tá»i 8062</strong> (Há» thá»ng sáºœ trá»« tiá»n trÃªn tÃ i khoáº£n chÃ­nh cá»§a sá» Äiá»n thoáº¡i&nbsp;<strong><?php echo $username;?></strong>)
                                         </p>
                                         </div>
Index: pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/services/controllers/sync.php	(revision 906)
@@ -47,5 +47,6 @@
 								'id'=>(int)$item['id'],
 								'full_name'=>(string)$item['name'],
-								'passwd' => md5($phoneNumber),
+								'passwd'=>md5($phoneNumber),
+								'login_name'=>$phoneNumber,
 								'cellphone'=>$phoneNumber,
 								'precinct'=>(string)$item['precinct'],
Index: pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 884)
+++ pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 906)
@@ -1,56 +1,58 @@
 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
-if ( ! defined('_SBG_MO_REGISTER')) 					define('_SBG_MO_REGISTER', 				'SUBSCR');
-if ( ! defined('_SBG_MO_REGISTER_FOR')) 				define('_SBG_MO_REGISTER_FOR', 			'SUBSCR_FOR');
-if ( ! defined('_SBG_MO_PHONENUM_CHANGE')) 				define('_SBG_MO_PHONENUM_CHANGE', 		'PHONE_CHANGE');
-if ( ! defined('_SBG_MO_PASSWORD_RECOVERY')) 			define('_SBG_MO_PASSWORD_RECOVERY', 	'PWD_RECOVER');
-if ( ! defined('_SBG_MO_VIP_REGISTER')) 				define('_SBG_MO_VIP_REGISTER', 			'REG_VIP');
-if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT')) 				define('_SBG_MO_PAY_TO_ACCOUNT', 		'PAY');
-if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT_FOR')) 			define('_SBG_MO_PAY_TO_ACCOUNT_FOR', 	'PAY_FOR');
-if ( ! defined('_SBG_MO_UNSUBSCRIBE_SERVICE')) 			define('_SBG_MO_UNSUBSCRIBE_SERVICE', 	'UNSUBSCR');
-if ( ! defined('_SBG_MO_SUPPOR_SERVICE')) 				define('_SBG_MO_SUPPOR_SERVICE', 		'SUPPORT');
-if ( ! defined('_SBG_MO_SYNTAX_ERR')) 					define('_SBG_MO_SYNTAX_ERR', 			'SYNTAX_ERR');
-
-if ( ! defined('_SBG_CARD_PAY_FAIL')) 					define('_SBG_CARD_PAY_FAIL', 			-1);
-if ( ! defined('_SBG_CARD_PAY_SUCCESS')) 				define('_SBG_CARD_PAY_SUCCESS', 		1);
-
-if ( ! defined('_SBG_CHARGING_FAIL')) 					define('_SBG_CHARGING_FAIL', -1);
-if ( ! defined('_SBG_CHARGING_SUCCESS')) 				define('_SBG_CHARGING_SUCCESS', 1);
-if ( ! defined('_SBG_CHARGING_FAIL_NOT_ENOUGH')) 		define('_SBG_CHARGING_FAIL_NOT_ENOUGH', 401);
-if ( ! defined('_SBG_CHARGING_FAIL_NOT_VIETTEL')) 		define('_SBG_CHARGING_FAIL_NOT_VIETTEL', 402);
-if ( ! defined('_SBG_CHARGING_NUMBER_NOT_EXISTED')) 	define('_SBG_CHARGING_NUMBER_NOT_EXISTED', 403);
-if ( ! defined('_SBG_CHARGING_NUMBER_NOT_AVAILABLE')) 	define('_SBG_CHARGING_NUMBER_NOT_AVAILABLE', 404);
-if ( ! defined('_SBG_CHARGING_NUMBER_CHANGED_OWNER')) 	define('_SBG_CHARGING_NUMBER_CHANGED_OWNER', 405);
-if ( ! defined('_SBG_CHARGING_FAIL_MORETHAN_LIMIT')) 	define('_SBG_CHARGING_FAIL_MORETHAN_LIMIT', 406);
-if ( ! defined('_SBG_CHARGING_GENERAL_ERROR')) 			define('_SBG_CHARGING_GENERAL_ERROR', 440);
-if ( ! defined('_SBG_CHARGING_NUMBER_NOT_REGISTED')) 	define('_SBG_CHARGING_NUMBER_NOT_REGISTED', 501);
-if ( ! defined('_SBG_CHARGING_MAX_VALUE')) 				define('_SBG_CHARGING_MAX_VALUE', 50000);
-if ( ! defined('_SBG_CHARGING_MIN_VALUE')) 				define('_SBG_CHARGING_MIN_VALUE', 5000);
-
-
-if ( ! defined('_SBG_SEND_MT_FAIL')) 					define('_SBG_SEND_MT_FAIL', -1);
-if ( ! defined('_SBG_SEND_MT_SUCCESS')) 				define('_SBG_SEND_MT_SUCCESS', 1);
-if ( ! defined('_SBG_MT_SEND_NUMBER')) 					define('_SBG_MT_SEND_NUMBER', '841662860000');
-if ( ! defined('_SBG_MT_CP_CODE')) 						define('_SBG_MT_CP_CODE', '601');
-
-if ( ! defined('_SBG_SERVICE_COMMAND_CODE'))			define('_SBG_SERVICE_COMMAND_CODE', 'SBG');
-if ( ! defined('_SBG_SERVICE_SERVICEID')) 				define('_SBG_SERVICE_SERVICEID', '8062');
-
-if ( ! defined('_SBG_MO_PROCCESS_ERR')) 				define('_SBG_MO_PROCCESS_ERR', 0);
-
-if ( ! defined('_SBG_GET_COLLABORATOR_FAIL')) 			define('_SBG_GET_COLLABORATOR_FAIL', -1);
+if ( ! defined('_SBG_MO_REGISTER')) 						define('_SBG_MO_REGISTER', 				 		'SUBSCR');
+if ( ! defined('_SBG_MO_REGISTER_FOR')) 					define('_SBG_MO_REGISTER_FOR', 					'SUBSCR_FOR');
+if ( ! defined('_SBG_MO_PHONENUM_CHANGE')) 					define('_SBG_MO_PHONENUM_CHANGE', 		 		'PHONE_CHANGE');
+if ( ! defined('_SBG_MO_PASSWORD_RECOVERY')) 				define('_SBG_MO_PASSWORD_RECOVERY', 	 		'PWD_RECOVER');
+if ( ! defined('_SBG_MO_VIP_REGISTER')) 					define('_SBG_MO_VIP_REGISTER', 			 		'REG_VIP');
+if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT')) 					define('_SBG_MO_PAY_TO_ACCOUNT', 		 		'PAY');
+if ( ! defined('_SBG_MO_PAY_TO_ACCOUNT_FOR')) 				define('_SBG_MO_PAY_TO_ACCOUNT_FOR', 	 		'PAY_FOR');
+if ( ! defined('_SBG_MO_UNSUBSCRIBE_SERVICE')) 				define('_SBG_MO_UNSUBSCRIBE_SERVICE', 	 		'UNSUBSCR');
+if ( ! defined('_SBG_MO_SUPPOR_SERVICE')) 					define('_SBG_MO_SUPPOR_SERVICE', 		 		'SUPPORT');
+if ( ! defined('_SBG_MO_SYNTAX_ERR')) 						define('_SBG_MO_SYNTAX_ERR', 			 		'SYNTAX_ERR');
+if ( ! defined('_SBG_MO_PASSWORD_COLLABORATOR_SERVICE'))	define('_SBG_MO_PASSWORD_COLLABORATOR_SERVICE', 'PWD_COLLABORATOR');
+
+if ( ! defined('_SBG_CARD_PAY_FAIL')) 						define('_SBG_CARD_PAY_FAIL', 			-1);
+if ( ! defined('_SBG_CARD_PAY_SUCCESS')) 					define('_SBG_CARD_PAY_SUCCESS', 		1);
+
+if ( ! defined('_SBG_CHARGING_FAIL')) 						define('_SBG_CHARGING_FAIL', -1);
+if ( ! defined('_SBG_CHARGING_SUCCESS')) 					define('_SBG_CHARGING_SUCCESS', 1);
+if ( ! defined('_SBG_CHARGING_FAIL_NOT_ENOUGH')) 			define('_SBG_CHARGING_FAIL_NOT_ENOUGH', 401);
+if ( ! defined('_SBG_CHARGING_FAIL_NOT_VIETTEL')) 			define('_SBG_CHARGING_FAIL_NOT_VIETTEL', 402);
+if ( ! defined('_SBG_CHARGING_NUMBER_NOT_EXISTED')) 		define('_SBG_CHARGING_NUMBER_NOT_EXISTED', 403);
+if ( ! defined('_SBG_CHARGING_NUMBER_NOT_AVAILABLE')) 		define('_SBG_CHARGING_NUMBER_NOT_AVAILABLE', 404);
+if ( ! defined('_SBG_CHARGING_NUMBER_CHANGED_OWNER')) 		define('_SBG_CHARGING_NUMBER_CHANGED_OWNER', 405);
+if ( ! defined('_SBG_CHARGING_FAIL_MORETHAN_LIMIT')) 		define('_SBG_CHARGING_FAIL_MORETHAN_LIMIT', 406);
+if ( ! defined('_SBG_CHARGING_GENERAL_ERROR')) 				define('_SBG_CHARGING_GENERAL_ERROR', 440);
+if ( ! defined('_SBG_CHARGING_NUMBER_NOT_REGISTED')) 		define('_SBG_CHARGING_NUMBER_NOT_REGISTED', 501);
+if ( ! defined('_SBG_CHARGING_MAX_VALUE')) 					define('_SBG_CHARGING_MAX_VALUE', 50000);
+if ( ! defined('_SBG_CHARGING_MIN_VALUE')) 					define('_SBG_CHARGING_MIN_VALUE', 5000);
+
+
+if ( ! defined('_SBG_SEND_MT_FAIL')) 						define('_SBG_SEND_MT_FAIL', -1);
+if ( ! defined('_SBG_SEND_MT_SUCCESS')) 					define('_SBG_SEND_MT_SUCCESS', 1);
+if ( ! defined('_SBG_MT_SEND_NUMBER')) 						define('_SBG_MT_SEND_NUMBER', '841662860000');
+if ( ! defined('_SBG_MT_CP_CODE')) 							define('_SBG_MT_CP_CODE', '601');
+
+if ( ! defined('_SBG_SERVICE_COMMAND_CODE'))				define('_SBG_SERVICE_COMMAND_CODE', 'SBG');
+if ( ! defined('_SBG_SERVICE_SERVICEID')) 					define('_SBG_SERVICE_SERVICEID', '8062');
+
+if ( ! defined('_SBG_MO_PROCCESS_ERR')) 					define('_SBG_MO_PROCCESS_ERR', 0);
+
+if ( ! defined('_SBG_GET_COLLABORATOR_FAIL')) 				define('_SBG_GET_COLLABORATOR_FAIL', -1);
 
 Class Services_model extends CI_Model
 {
 	private $_arySmsMO = array(
-		_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_PASSWORD_RECOVERY 	=> array('pattern' => '/^(SBG)([[:blank:]])(MK)$/'),
-		_SBG_MO_VIP_REGISTER 		=> array('pattern' => '/^(SBG)([[:blank:]])(VIP)([[:blank:]])([a-zA-Z0-9]{1,})$/'),
-		_SBG_MO_PAY_TO_ACCOUNT 		=> array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})$/'),
-		_SBG_MO_PAY_TO_ACCOUNT_FOR 	=> array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})([[:blank:]])([0-9]{10,11})$/'),
-		_SBG_MO_SUPPOR_SERVICE 		=> array('pattern' => '/^(SBG)([[:blank:]])(HD)$/'),
-		_SBG_MO_UNSUBSCRIBE_SERVICE => array('pattern' => '/^(SBG)([[:blank:]])(HUY)$/')
+		_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_PASSWORD_RECOVERY 				=> array('pattern' => '/^(SBG)([[:blank:]])(MK)$/'),
+		_SBG_MO_VIP_REGISTER 					=> array('pattern' => '/^(SBG)([[:blank:]])(VIP)([[:blank:]])([a-zA-Z0-9]{1,})$/'),
+		_SBG_MO_PAY_TO_ACCOUNT 					=> array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})$/'),
+		_SBG_MO_PAY_TO_ACCOUNT_FOR 				=> array('pattern' => '/^(SBG)([[:blank:]])(NAP)([[:blank:]])([0-9]{3,})([[:blank:]])([0-9]{10,11})$/'),
+		_SBG_MO_SUPPOR_SERVICE 					=> array('pattern' => '/^(SBG)([[:blank:]])(HD)$/'),
+		_SBG_MO_UNSUBSCRIBE_SERVICE 			=> array('pattern' => '/^(SBG)([[:blank:]])(HUY)$/'),
+		_SBG_MO_PASSWORD_COLLABORATOR_SERVICE	=> array('pattern' => '/^(SBG)([[:blank:]])(CTV)$/')
 	);
 
@@ -113,4 +115,5 @@
 		$aryContents = isset($aryMOAnalys['content']) ? $aryMOAnalys['content']: null;
 		$this->load->model('frontend/user_model', 'objUserModel');
+		$this->load->model('collaborator/collaborator_model', 'objCollaboratorModel');
 		$debugMsg .= $case;
 
@@ -262,5 +265,9 @@
 				}
 				break;
-
+				
+			case _SBG_MO_PASSWORD_COLLABORATOR_SERVICE:
+				$smsReturn = $this->objCollaboratorModel->getPassword($sentNumber);
+				break;
+			
 			case _SBG_MO_UNSUBSCRIBE_SERVICE:
 			case _SBG_MO_SYNTAX_ERR:
@@ -508,5 +515,5 @@
 
 	public function deleteCollaborator($id){
-		$sql = "DELETE FROM tblcollaborator WHERE id = ". $id;
+		$sql = "DELETE FROM tblcollaborator WHERE id = ". $id. " AND author is null";
 		$this->db->query($sql);
 		if ($this->db->affected_rows()){
