Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/collaborator.php	(revision 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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 883)
+++ 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>
