Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 821)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/home.php	(revision 838)
@@ -179,4 +179,51 @@
 		return 0;
 	}
+	
+	public function test(){
+		$provinces = lang('_PROVINCES_');
+		$this->load->library("PHPExcel");
+		$file = './assets/danhsachquanhuyen.xls';
+		$objPHPExcel = PHPExcel_IOFactory::load($file);
+		$cell_collection = $objPHPExcel->getActiveSheet()->getCellCollection();
+		foreach ($cell_collection as $cell) {
+			$column = $objPHPExcel->getActiveSheet()->getCell($cell)->getColumn();
+			$row = $objPHPExcel->getActiveSheet()->getCell($cell)->getRow();
+			$data_value = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue();
+			
+			if ($row == 1) {
+				$header[$row][$column] = $data_value;
+			} else {
+				$arr_data[$row][$column] = $data_value;
+			}
+		}
+		
+		$data['header'] = $header;
+		$data['values'] = $arr_data;
+		
+		foreach ($data['values'] as $index => $value){
+			foreach ($provinces as $provinceId => $province){
+				if ($value['C'] == $province) $data['values'][$index]['C'] = $provinceId;
+				if ($value['B'] >= 10){
+					$data['values'][$index]['B'] = "0".$value['B'];
+				}else{
+					$data['values'][$index]['B'] = "00".$value['B'];
+				}
+			}
+			
+		}
+		
+		$dt = array();
+		foreach ($data['values'] as $index => $value){
+			
+			$dt[$index]['district_id'] = $value['B'];
+			$dt[$index]['province_id'] = $value['C'];
+			$dt[$index]['district_name'] = $value['D'];
+			$dt[$index]['type'] = $value['E'];
+		}
+		//var_dump($dt);
+		//$this->load->model ( 'user_model' );
+		//$result = $this->user_model->insertDistrict($dt);
+		//var_dump($result);
+	}
 }
 
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 821)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 838)
@@ -62,4 +62,7 @@
             $us_id = $user_info['us_id'];
             $user = $this->user_model->get_user_by_id($us_id);
+			//$us = array();
+			$user['district'] = $this->user_model->getDistrictByIdAndProvince($user['district'], $user['province']);
+			
             $result['can_buy'] = 1;
             $result['can_edit'] = 0;
@@ -140,4 +143,5 @@
         //$user = $this->user_model->get_user_by_id($us_id);
 		$user = $this->user_model->getUserById($us_id);
+		//$user['district'] = $this->user_model->getDistrictByIdAndProvince($user['district'], $user['province']);
         $package = $this->servicepackage_model->getPackage($input['p_id']);
         $user['acc_balanced'] = $user['acc_balanced'] - $package['p_price'];
@@ -150,4 +154,5 @@
         $user['p_id'] = $package['p_id'];
 		$user['province'] = $input['province'];
+		$user['district'] = $input['district'];
         $this->user_model->updateUser($us_id, $user);
         $user['expire_date'] = date("d-m-Y", (strtotime($user['expire_date'])));
@@ -172,4 +177,5 @@
 
         $user = $this->user_model->get_user_by_id($us_id);
+		$user['district'] = $this->user_model->getDistrictByIdAndProvince($user['district'], $user['province']);
         $package = $this->servicepackage_model->getPackage($p_id);
 
@@ -207,6 +213,7 @@
             parse_str($user);
             $us = $this->user_model->get_user_by_id($us_id);
+			$us['district'] = $this->user_model->getDistrictByIdAndProvince($us['district'], $province);
             $data = array('us_id' => $us_id, 'username' => $username, 'fullname' => $fullname,
-                'gender' => $gender, 'email' => $email, 'phone' => $phone, 'school' => $school, 'province' => $province,
+                'gender' => $gender, 'email' => $email, 'phone' => $phone, 'school' => $school, 'province' => $province, 'district' => $us['district'],
                 'acc_balanced' => $us['acc_balanced'], 'expire_date' => $us['expire_date'], 'date_diff' => $this->dateDiff($us['expire_date'])
             );
@@ -476,4 +483,21 @@
 		
 	}
+	
+	function getDistrict(){
+		
+		$user_info = $this->session->userdata('userInfo');
+		if ($user_info) {
+			$result = array();
+			$provinceId = $this->uri->segment(4);
+			$this->load->model ( 'user_model' );
+			if ($provinceId){
+				$results = $this->user_model->getDistrictByProvince($provinceId);
+			}
+			echo json_encode($results);
+		}else{
+			show_404();
+		}
+		
+	}
 
 }
