Index: pro-violet-viettel/sourcecode/application/config/routes.php
===================================================================
--- pro-violet-viettel/sourcecode/application/config/routes.php	(revision 395)
+++ pro-violet-viettel/sourcecode/application/config/routes.php	(revision 396)
@@ -61,4 +61,9 @@
 $route['admin/nguoi_dung/trang'] = 'admin/user/get_users/1';
 $route['admin/nguoi_dung/trang/:any'] = 'admin/user/get_users/$1';
+$route['admin/nguoi_dung/them'] = 'admin/user/add_user';
+$route['admin/nguoi_dung/sua/:any'] = 'admin/user/edit_user/$1';
+$route['admin/nguoi_dung/xoa/:any'] = 'admin/user/delete_user/$1';
+$route['admin/nguoi_dung/id/:any'] = 'admin/user/get_user_by_id/$1';
+
 /* End of file routes.php */
 /* Location: ./application/config/routes.php */
Index: pro-violet-viettel/sourcecode/application/core/MY_Model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/core/MY_Model.php	(revision 395)
+++ pro-violet-viettel/sourcecode/application/core/MY_Model.php	(revision 396)
@@ -47,4 +47,5 @@
 	{
 		$sql="SELECT COUNT(".$this->id_name.") as total FROM ".$this->table_name." WHERE ".$data['field']." = '".$data['value']."' LIMIT 1";
+		if (!isset($this->db->query($sql)->row_array()['total'])) return false;
 		if ($this->db->query($sql)->row_array()['total']==1)
 		{
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php	(revision 395)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/user.php	(revision 396)
@@ -27,7 +27,16 @@
 		$this->load->model('user_model');
 		$data['current_page'] = $this->uri->segment(4, 1);
-		$data['itemsoptions'] = array(1, 25, 50, 100);
-		$data['perpage'] = 1;
+		$data['itemsoptions'] = array(10, 25, 50, 100);
+		$data['perpage'] = 10;
 		$data['keyword'] = "";
+		$data['sorting_order']="sorting_desc";
+        $data['sorting_field']="created_time";
+		if ($this->input->post('sorting_order')) {
+			if ($this->input->post('sorting_order') != "sorting")
+			{
+				$data['sorting_order'] = $this->input->post('sorting_order');
+				$data['sorting_field'] = $this->input->post('sorting_field'); 
+			}
+		}
 		if ($this->input->post('items')) 
 		{
@@ -50,3 +59,76 @@
 	}
 	
+	public function edit_user()
+	{
+		$admin_info = $this->session->userdata('adminInfo');
+		if ($admin_info)
+		{
+			$input = $this->input->post();
+			$result = array();
+			$result['success'] = 0;
+			$us_id = (int)$this->uri->segment(4, 0);
+			if ($us_id==0){
+				$result['success'] = 0;
+			}else
+			{
+				$this->load->model('user_model');
+				$input['updated_time'] = date("Y-m-d H:i:s");
+				$this->user_model->update($us_id, $input);
+				$result['success'] = 1;
+			}
+			echo json_encode($result);
+		}else
+		{
+			$this->load->view('login');
+		}
+	}
+	
+	public function delete_user()
+	{
+		$admin_info = $this->session->userdata('adminInfo');
+		if ($admin_info)
+		{
+			$result = array();
+			$result['success'] = 0;
+			$us_id = (int)$this->uri->segment(4, 0);
+			if ($us_id == 0){
+				$result['success'] = 0;
+			}else
+			{
+				$this->load->model('user_model');
+				$this->user_model->delete($us_id);
+				$result['success'] = 1;
+			}
+			echo json_encode($result);
+		}else
+		{
+			$this->load->view('login');
+		}
+	}
+	
+	public function get_user_by_id()
+	{
+		$admin_info = $this->session->userdata('adminInfo');
+		if ($admin_info)
+		{
+			$result = array();
+			$result['success'] = 0;
+			$us_id = (int)$this->uri->segment(4, 0);
+			if ($us_id == 0)
+			{
+				$result['success'] = 0;	
+			}else
+			{
+				$this->load->model('user_model');
+				$data = $this->user_model->search_by_id($us_id);
+				$result['item'] = $data;
+				$result['success'] = 1;
+			}
+			echo json_encode($result);
+		}else
+		{
+			$this->load->view('login');
+		}
+	}
+	
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php	(revision 395)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php	(revision 396)
@@ -22,8 +22,14 @@
 	{
 		$sql="SELECT * FROM ".$this->table_name;
-		$data['keyword']='';
 		if ($data['keyword'])
 		{
 			$sql.=" WHERE (cellphone LIKE '%".$data['keyword']."%' OR collaborator LIKE '%".$data['keyword']."%' OR acc_balanced LIKE '%".$data['keyword']."%') ";
+		}
+		$order = "";
+		if ($data['sorting_order'] != "sorting") {
+			$sort = "DESC";
+			if ($data['sorting_order'] == "sorting_asc")
+				$sort = "ASC";
+			$order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
 		}
 		return $this->db->query($sql." ORDER BY us_id DESC LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/user/index.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/user/index.php	(revision 395)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/user/index.php	(revision 396)
@@ -24,4 +24,36 @@
             return false;
         });
+		$('#keyword').bind('input', function(){
+			filter();
+		});
+		
+		$( '.sorting, .sorting_desc, .sorting_asc' ).click(function( index ) {
+            var current_class=$( this ).attr('class');
+            $(".sorting_desc").attr("class","sorting");
+            $(".sorting_asc").attr("class","sorting");
+     
+            if(current_class=='sorting')
+            {
+                $(this).attr("class","sorting_desc");
+            }
+            else
+            {
+                if(current_class=='sorting_desc')
+                {
+                    $(this).attr("class","sorting_asc");
+                }
+                else
+                    {
+                    if(current_class=='sorting_asc')
+                    {
+                        $(this).attr("class","sorting");
+                    }
+                }
+            }
+			console.log($( this ).attr('class'));
+            $("#sorting_field").val($(this).attr("id"));
+            $("#sorting_order").val($(this).attr("class"));
+            filter();
+        });
 	}
 	
@@ -36,6 +68,6 @@
 				$("#content").html(data);
 				init_page();
-				//$("#keyword").focus();
-				//$("#keyword").setCursorToTextEnd();
+				$("#keyword").focus();
+				$("#keyword").setCursorToTextEnd();
 
 			},
@@ -144,5 +176,108 @@
 </div><!-- /.modal-dialog -->
 
+<!-- Edit User -->
+<div tabindex="-1" class="modal fade in" id="editUser">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header no-padding">
+				<div class="table-header">
+					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">
+						<span class="white">Ã</span>
+					</button>
+					Sá»­a ngÆ°á»i dÃ¹ng
+				</div>
+			</div>
+	
+			<div class="modal-body">
+				<form id="edit_frm" onsubmit="return false;" class="form-horizontal" role="form">
+					<div class="form-group">
+						<label for="form-field-1" class="col-sm-3 control-label no-padding-right"> Sá» Äiá»n thoáº¡i </label>
+						<div class="col-sm-9">
+							<label class="block clearfix has-error">
+								<span class="input-icon">
+									<input type="text" id="edit_cellphone" name="cellphone" placeholder="Phone" id="form-field-1" value="">
+									<i class="icon-user blue"></i>
+								</span>
+								<div class="help-block"> </div>
+							</label>
+						</div>
+					</div>
+
+					<div class="form-group">
+						<label for="form-field-2" class="col-sm-3 control-label no-padding-right"> Tiá»n </label>
+						<div class="col-sm-9">
+							<span class="input-icon">
+								<input type="text" id="edit_acc_balanced" name="acc_balanced" placeholder="" id="form-field-2" value="">
+								<i class="icon-user blue"></i>
+							</span>
+						</div>
+						<label class="block clearfix has-error">
+							<div class="help-block"> </div>
+						</label>
+						
+					</div>
+
+					<div class="space-4"></div>
+					<div class="clearfix form-actions">
+						<div class="col-md-offset-3 col-md-9">
+							<button type="button" id="edit" class="btn btn-info">
+								<i class="icon-ok bigger-110"></i>
+								HoÃ n táº¥t
+							</button>
+
+							&nbsp; &nbsp; &nbsp;
+							<button type="reset" name="reset" class="btn">
+								<i class="icon-undo bigger-110"></i>
+								XÃ³a háº¿t
+							</button>
+						</div>
+					</div>
+				</form>
+			</div>
+		</div>
+	</div>
+</div>
+<!-- End Edit User -->
+
+<!-- Delete User -->
+<div tabindex="-1" class="modal fade in" id="deleteUser">
+	<div class="modal-dialog">
+		<div class="modal-content">
+			<div class="modal-header no-padding">
+				<div class="table-header">
+					<button aria-hidden="true" data-dismiss="modal" class="close" type="button">
+						<span class="white">Ã</span>
+					</button>
+					XÃ³a ngÆ°á»i dÃ¹ng
+				</div>
+			</div>
+			
+			<div class="modal-body">
+				<form id="delete_frm" onsubmit="return false;" class="form-horizontal" role="form">
+					<div class="form-group">
+						<center><h4> Cháº¯c cháº¯n muá»n xÃ³a tÃ i khoáº£n nÃ y? </h4></center>
+					</div>
+					<div class="clearfix form-actions">
+						<div class="col-md-offset-3 col-md-9">
+							<button type="button" id="delete" class="btn btn-info">
+								<i class="icon-ok bigger-110"></i>
+								XÃ³a
+							</button>
+
+							&nbsp; &nbsp; &nbsp;
+							<button type="reset" name="reset" class="btn" data-dismiss="modal">
+								<i class="icon-undo bigger-110"></i>
+								Há»§y
+							</button>
+						</div>
+					</div>
+				</form>
+			</div>
+		</div>
+	</div>
+</div>					
+<!-- End Delete User -->
+
 <?php
-$this->load->view('layout/admin/footer', array('base_url' => $base_url));
+$this->load->view('layout/admin/footer', array('base_url' => $base_url, 'adminjs' => array('assets/js/admin/user.js')));
 ?>
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 395)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 396)
@@ -71,4 +71,6 @@
                             </div>
                         </div>
+						<input type="hidden" name="sorting_order" id="sorting_order" value="<?php echo $sorting_order;?>" />
+						<input type="hidden" name="sorting_field" id="sorting_field" value="<?php echo $sorting_field;?>"/>
                     </form>
                     <table class="table table-striped table-bordered table-hover dataTable" id="sample-table-2" aria-describedby="sample-table-2_info">
@@ -81,11 +83,15 @@
                                     </label>
                                 </th>
-                                <th class="sorting" 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">Sá» Äiá»n thoáº¡i</th>
-                                <th class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 122px;" aria-label="Tiá»n: activate to sort column ascending">Tiá»n</th>
-                                <th class="sorting" 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">
+                                <th class="<?php if ($sorting_field == 'cellphone') {echo $sorting_order;} else {echo "sorting";}?>" id="cellphone" 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">Sá» Äiá»n thoáº¡i</th>
+                                <th class="<?php if ($sorting_field == 'acc_balanced') {echo $sorting_order;} else {echo "sorting";}?>" id="acc_balanced" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 122px;" aria-label="Tiá»n: activate to sort column ascending">Tiá»n</th>
+                                <th class="<?php if ($sorting_field == 'created_time') {echo $sorting_order;} else {echo "sorting";}?>" id="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">
                                     <i class="icon-time bigger-110 hidden-480"></i>
                                     NgÃ y ÄÄng kÃœ
                                 </th>
-                                <th class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 158px;" aria-label="Tráº¡ng thÃ¡i: activate to sort column ascending">Tráº¡ng thÃ¡i</th><th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 133px;" aria-label=""></th></tr>
+								<th class="<?php if ($sorting_field == 'expire_date') {echo $sorting_order;} else {echo "sorting";}?>" id="expire_date" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" style="width: 209px;" aria-label="NgÃ y háº¿t háº¡n: activate to sort column ascending">
+                                    <i class="icon-time bigger-110 hidden-480"></i>
+                                    NgÃ y háº¿t háº¡n
+                                </th>
+                                <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" style="width: 133px;" aria-label=""></th></tr>
                         </thead>
 
@@ -108,8 +114,5 @@
                                 <td class="hidden-480 "><?php echo $user['acc_balanced']; ?></td>
                                 <td class=" "><?php echo $user['created_time']; ?></td>
-
-                                <td class="hidden-480 ">
-                                    <span class="label label-sm label-success">ÄÃ£ kÃ­ch hoáº¡t</span>
-                                </td>
+								<td class=" "><?php echo $user['expire_date']; ?></td>
 
                                 <td class=" ">
@@ -119,9 +122,9 @@
                                         </a>
 
-                                        <a href="#" class="green">
+                                        <a href="#editUser" data-toggle="modal" data-us-id=<?php echo $user['us_id']; ?> class="green">
                                             <i class="icon-pencil bigger-130"></i>
                                         </a>
 
-                                        <a href="#" class="red">
+                                        <a href="#deleteUser" data-toggle="modal" data-us-id=<?php echo $user['us_id']; ?> class="red">
                                             <i class="icon-trash bigger-130"></i>
                                         </a>
