Index: pro-violet-viettel/sourcecode/application/language/message/messages_lang.php
===================================================================
--- pro-violet-viettel/sourcecode/application/language/message/messages_lang.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/language/message/messages_lang.php	(revision 818)
@@ -50,15 +50,16 @@
 
 // mo
-$lang['_SBG_MO_SYNTAX_ERR_MSG'] = 'Tin nhan sai cu phap. Chi tiet soan SBG HD gui 8062 (500d/tin) hoac LH 01662860000 (cuoc goi di dong).';
+$lang['_SBG_MO_SYNTAX_ERR_MSG'] = 'Khong tim thay dich vu nay. Vui long soan SBG HD gui 8062 (500d/tin) hoac LH 01662860000 de biet them chi tiet';
 $lang['_SBG_MO_REGISTER_DISCONTINUE_MSG'] = 'DV Soan bai giang Online tam thoi khong hoat dong. Vui long thu lai sau it phut hoac LH 01662860000 de biet them chi tiet';
 $lang['_SBG_MO_PHONENUM_CHANGE_DISCONTINUE_MSG'] = $lang['_SBG_MO_REGISTER_DISCONTINUE_MSG'];
 $lang['_SBG_MO_PASSWORD_CHANGE_DISCONTINUE_MSG'] = $lang['_SBG_MO_REGISTER_DISCONTINUE_MSG'];
 
-$lang['_SBG_MO_COLLABORATOR_NOT_FOUND_MSG'] = 'He thong khong tim thay Cong tac vien co so dien thoai :collaborator:. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_COLLABOLATOR_REGISTER_DUPLICATE_MSG'] = 'Khach hang :username: da dang ky DV Soan bai giang Online truoc do. Vui long kiem tra lai hoac LH 01662860000 (cuoc goi di dong) de biet them chi tiet.';
+$lang['_SBG_MO_COLLABORATOR_NOT_FOUND_MSG'] = 'He thong khong tim thay Cong tac vien co so dien thoai :collaborator:. Vui long kiem tra lai hoac LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_COLLABOLATOR_REGISTER_DUPLICATE_MSG'] = 'So dien thoai cua KH da duoc dang ky DV Soan bai giang Online. Huong dan KH soan tin nhan SBG MK gui den 8062 de lay lai mat khau';
 $lang['_SBG_MO_COLLABOLATOR_REGISTER_SUCCESS_MSG'] = 'Ban da dang ky thanh cong dich vu SBG Online cho so dien thoai :username:';
 
-$lang['_SBG_MO_USER_REGISTER_SUCCESS_MSG'] = 'Chuc mung ban da dang ky thanh cong DV Soan bai giang Online. Ban duoc dung thu dich vu voi phi 0d trong :trialdays: hoac dang ky cac goi VIP voi phi tu 15000d/thang. Truy cap soanbaigiang.smas.vn voi tai khoan :username:, mat khau :password: de su dung DV. Vui long LH 01662860000 de biet them chi tiet (cuoc goi di dong).';
-$lang['_SBG_MO_USER_REGISTER_DUPLICATE_MSG'] = 'So dien thoai cua Ban da dang ky tai khoan DV Soan bai giang Online truoc do. Vui long long truy cap http://soanbaigiang.smas.vn de su dung DV hoac LH 01662860000 (cuoc goi di dong) de biet them chi tiet';
+$lang['_SBG_MO_USER_VIETTEL_REGISTER_SUCCESS_MSG'] = 'Chuc mung ban da dang ky thanh cong DV Soan bai giang Online. Ban duoc dung thu dich vu voi phi 0d trong :trialdays: hoac dang ky cac goi VIP voi phi tu 15000d/thang. Truy cap soanbaigiang.smas.vn voi tai khoan :username:, mat khau :password: de su dung DV. Vui long LH 01662860000 de biet them chi tiet (cuoc goi di dong).';
+$lang['_SBG_MO_USER_NOT_VIETTEL_REGISTER_SUCCESS_MSG'] = 'Ban da dang ky thanh cong DV. Phi dung thu 0d hoac dang ky cac goi VIP phi tu 15000d/thang, tai khoan :username:, mat khau :password:. Chi tiet LH 01662860000';
+$lang['_SBG_MO_USER_REGISTER_DUPLICATE_MSG'] = 'So dien thoai cua ban da duoc dang ky DV Soan bai giang Online. Vui long soan tin nhan SBG MK gui den 8062 de lay lai mat khau';
 
 $lang['_SBG_MO_USER_PHONENUM_CHANGE_DUPLICATE_MSG'] = 'So dien thoai :sentNumber: da dang ky DV Soan bai giang Online. Vui long soan SBG HD gui 8062 (500d/tin) hoac LH 01662860000 de biet them chi tiet';
@@ -68,6 +69,6 @@
 $lang['_SBG_MO_USER_OLD_PHONENUM_CHANGE_SUCCESS_MSG'] = 'Ban da doi thanh cong so dien thoai tai DV Soan bai giang Online sang so dien thoai :sentNumber:. Vui long LH 01662860000 de biet them chi tiet';
 
-$lang['_SBG_MO_USER_PHONENUM_NOT_REGISTER_MSG'] = 'So thue bao :username: chua dang ky DV Soan bai giang Online. De dang ky, soan SBG DK gui 8062 (500d/tin). Chi tiet soan SBG HD gui 8062 (500d/tin) hoac LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_USER_PASSWORD_RECOVERY_MSG'] = 'Mat khau cua Ban la :pass:. Moi Ban truy cap soanbaigiang.smas.vn de su dung DV. Chi tiet LH 01662860000 (cuoc goi di dong).';
+$lang['_SBG_MO_USER_PHONENUM_NOT_REGISTER_MSG'] = 'So dien thoai :username: chua dang ky DV Soan bai giang Online. Vui long soan SBG DK gui 8062 (500d/tin) de dang ky DV. LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_USER_PASSWORD_RECOVERY_MSG'] = 'Mat khau cua ban la :pass:. Vui long truy cap soanbaigiang.smas.vn de su dung dich vu. Vui long LH 01662860000 de biet them chi tiet';
 $lang['_SBG_MO_USER_PASSWORD_CHANGE_SUCCESS_MSG'] = 'Ban da doi thanh cong mat khau tren SBG Online. Mat khau moi cua ban la :password:. Tran trong.';
 
@@ -76,17 +77,17 @@
 $lang['_SBG_MO_USER_REGISTER_VIP_FAIL_NOT_ENOUGH_MSG'] = 'Tai khoan cua ban khong du de dang ky dich vu SBG Online. Vui long nap tien va dang ky lai. Tran trong.';
 
-$lang['_SBG_MO_PAY_TO_ACCOUNT_SUCCESS_MSG'] = 'Ban da nap thanh cong :amount:d vao tai khoan cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_MSG'] = 'Ban da duoc nap :amount:d vao tai khoan cua DV Soan bai giang Online tu so dien thoai :sentNumber:. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_OTHER_SUCCESS_MSG'] = 'Ban da nap thanh cong :amount:d vao tai khoan :username: cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_ACCOUNT_NOT_FOUND_MSG'] = 'So thue bao :username: chua dang ky DV Soan bai giang Online. De dang ky, soan SBG DK gui 8062 (500d/tin). Chi tiet soan SBG HD gui 8062 (500d/tin) hoac LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_MSG'] = 'Tai khoan cua ban khong du de thuc hien nap :amount: vao tai khoan cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).:amount: ';
+$lang['_SBG_MO_PAY_TO_ACCOUNT_SUCCESS_MSG'] = 'Ban da nap thanh cong :amount:d vao tai khoan tren DV Soan bai giang Online. Vui long LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_MSG'] = 'Ban da duoc nap :amount:d vao tai khoan tren DV Soan bai giang Online tu so dien thoai :sentNumber:. Vui long LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_PAY_TO_ACCOUNT_FOR_OTHER_SUCCESS_MSG'] = 'Ban da nap thanh cong :amount:d tren tai khoan :username: cua DV Soan bai giang Online. Vui long LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_ACCOUNT_NOT_FOUND_MSG'] = 'So dien thoai :username: chua dang ky DV Soan bai giang Online. Vui long soan SBG DK gui 8062 (500d/tin) de dang ky DV. LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_MSG'] = 'Tai khoan chinh thue bao :sentNumber: cua ban khong du de thuc hien giao dich. Vui long nap them tien de thuc hien hoac LH 01662860000 de biet them chi tiet';
 $lang['_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_FOR_MSG'] = 'Tai khoan cua Ban khong du de thuc hien nap :amount: vao tai khoan :username: cua DV Soan bai giang Online. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_CHARGING_FAIL_MORETHAN_LIMIT_MSG'] = 'So tien toi da cho mot lan nap vao tai khoan cua DV Soan bai giang Online la 50.000d. Ban vui long thao tac lai hoac LH 01662860000 (cuoc goi di dong) de biet them chi tiet';
-$lang['_SBG_MO_CHARGING_FAIL_NOT_VIETTEL_MSG'] = 'Chuc nang nap tien qua SMS cua DV Soan bai giang Online chi ap dung cho thue bao Viettel. Chi tiet LH 01662860000 (cuoc goi di dong).';
+$lang['_SBG_MO_CHARGING_FAIL_MORETHAN_LIMIT_MSG'] = 'So tien nap lon nhat DV Soan bai giang Online la 50.000d.Vui long LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_CHARGING_FAIL_NOT_VIETTEL_MSG'] = 'Chuc nang nap tien qua SMS cua DV Soan bai giang Online chi ap dung cho thue bao Viettel. Vui long LH 01662860000 de biet them chi tiet';
 $lang['_SBG_MO_CHARGING_FAIL_MSG'] = 'Loi, khong thanh toan duoc tu tai khoan goc';
-$lang['_SBG_MO_AMOUNT_WRONG_FORMAT_MSG'] = 'So tien nap khong hop le. Vui long kiem tra lai hoac LH 01662860000 (cuoc goi di dong) de biet them chi tiet';
-$lang['_SBG_MO_PHONENUM_WRONG_FORMAT_MSG'] = 'So dien thoai Khach hang khong hop le. Chi tiet LH 01662860000 (cuoc goi di dong).';
-$lang['_SBG_MO_SUPPORT_MSG'] = 'Soan bai giang Online la DV cho phep Ban tao cac noi dung phuc vu giang day truc tuyen. De dang ky DV, soan SBG DK; De nap tien vao tai khoan, soan SBG NAP [so tien]; De lay lai mat khau, soan SBG MK, tin nhan gui 8062 (500d/tin). Vui long long truy cap http://soanbaigiang.smas.vn hoac LH 01662860000 (cuoc di dong) de biet them chi tiet';
-
+$lang['_SBG_MO_AMOUNT_WRONG_FORMAT_MSG'] = 'So tien nap khong hop le. Vui long kiem tra lai hoac LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_PHONENUM_WRONG_FORMAT_MSG'] = 'So dien thoai Khach hang khong hop le. Vui long kiem tra lai hoac LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_SUPPORT_VIETTEL_MSG'] = 'Soan bai giang Online la DV cho phep ban tao cac noi dung phuc vu giang day. De dang ky su dung DV nhan tin theo cu phap SBG DK. Vui long truy cap http://soanbaigiang.smas.vn hoac LH 01662860000 de biet them chi tiet';
+$lang['_SBG_MO_SUPPORT_NOT_VIETTEL_MSG'] = 'Soan bai giang Online la DV cho phep ban tao cac noi dung phuc vu giang day. Chi tiet vui long truy cap http://soanbaigiang.smas.vn hoac LH 01662860000';
 
 $lang['_PROVINCES_'] = array('A076'=>'An Giang',
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/report.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/report.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/report.php	(revision 818)
@@ -137,4 +137,168 @@
         }
     }
-
+	
+	public function export(){
+        $this->load->model('paidlog_model');
+		$data ['paid_types'] = array (
+					0 => "Táº¥t cáº£",
+					1 => "SMS",
+					2 => "Card",
+		);
+		$data ['paid_type'] = 0;
+		if ($this->input->post ( 'paid_type' )) {
+			$data ['paid_type'] = ( int ) $this->input->post ( 'paid_type' );
+		}
+		
+		$data['daterange_start'] = "";
+		$data['daterange_end'] = "";
+		if ($this->input->post('daterange')){
+			$daterange = explode(" - ", $this->input->post('daterange'));
+			$data['daterange_start'] = date('Y-m-d H:i:s', strtotime($daterange[0]));
+			$data['daterange_end'] = date('Y-m-d 23:59:59', strtotime($daterange[1]));
+		}
+        $data['total'] = $this->paidlog_model->countPaidlog($data);
+        $data['paidlogs'] = $this->paidlog_model->getPaidlogs($data)['paid_logs'];
+		$data['total_amount'] = $this->paidlog_model->getPaidlogs($data)['total_amount'];
+		
+        foreach ($data['paidlogs'] as $index => $paidlog) {
+            $data['paidlogs'][$index]['username'] = $this->get_fullname($paidlog['us_id']); 
+        }
+		
+		
+        $this->load->library("PHPExcel");
+        $sheet = $this->phpexcel->getActiveSheet();
+		
+        $sheet->setTitle("bao cao tong hop ");
+        $sheet->getColumnDimension('A')->setWidth(20);
+        $sheet->getColumnDimension('B')->setWidth(25);
+        $sheet->getColumnDimension('C')->setWidth(15);
+        $sheet->getColumnDimension('D')->setWidth(15);
+        $sheet->getColumnDimension('E')->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', "BÃO CÃO DOANH THU Tá»NG Há»¢P");
+		
+		$style = array(
+			'font' => array('size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
+								'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', "NhÃ¢n viÃªn káº¿t xuáº¥t: ");
+		
+		$sheet->getStyle('B6')->applyFromArray($style);
+		$sheet->getStyle('C6')->applyFromArray($style);
+		$sheet->getStyle('B7')->applyFromArray($style);
+		$sheet->getStyle('C7')->applyFromArray($style);
+		
+		
+		$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);
+		
+		$sheet->setCellValue('A9', 'Sá» Äiá»n thoáº¡i');
+		$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->setCellValue('B9', 'Há» tÃªn');
+		$sheet->setCellValue('C9', "Sá» tiá»n (VNÄ)");
+		$sheet->setCellValue('D9', "SMS/Card");
+		$sheet->setCellValue('E9', "NgÃ y");		
+		
+		$sheet->getStyle('A9:E9')->applyFromArray($style);
+		
+		$sheet->setCellValue('A10', "Tá»ng");
+		$sheet->mergeCells('A10:B10');
+		$sheet->getStyle('A10:B10')->applyFromArray($style);
+		
+		$style = array(
+			'font' => array('bold' => true, 'size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER),
+			'borders' =>	array(
+				'allborders' => array(
+					'style' => \PHPExcel_Style_Border::BORDER_THIN
+					)
+			)
+		);
+		
+		$sheet->setCellValue('C10', $data['total_amount']);
+		$sheet->getStyle('C10:E10')->applyFromArray($style);
+
+		$style = array(
+			'font' => array('size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER),
+			'borders' =>	array(
+				'allborders' => array(
+					'style' => \PHPExcel_Style_Border::BORDER_THIN
+					)
+			)
+		);
+
+        $dem=0;
+        foreach ($data['paidlogs'] as $index => $paidlog) {
+			$type = "";
+           // $sheet->setCellValue('A' . ($dem + 11), $paidlog['cellphone']);
+		    if ($paidlog['paid_type'] == 1) { 
+				$type = "SMS";
+			}else {
+				$type = "Card";
+			}
+			$sheet->setCellValueExplicit('A' . ($dem + 11), $paidlog['cellphone'], PHPExcel_Cell_DataType::TYPE_STRING);
+			
+            $sheet->setCellValue('B' . ($dem + 11), $paidlog['username']);
+            $sheet->setCellValue('C' . ($dem + 11), $paidlog['amount']);
+            $sheet->setCellValue('D' . ($dem + 11), $type);
+			$sheet->setCellValue('E' . ($dem + 11), $paidlog['paid_time']);
+			$sheet->getStyle('A'. ($dem + 11).':E'.($dem + 11))->applyFromArray($style);
+            $dem++;
+        }
+        $writer = new PHPExcel_Writer_Excel5($this->phpexcel);
+		header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment; filename="bao_cao_tong_hop_'.date('d-m-Y').'.xls"');
+        $writer->save('php://output');
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php	(revision 818)
@@ -32,5 +32,5 @@
         $data['month'] = date("m");
         $data['year'] = date("Y");
-        $data['to_date']=31;
+        $data['to_date']= 31;
         $data['to_month'] = date("m");
         $data['to_year'] = date("Y");
@@ -44,5 +44,5 @@
         $data['provinces'] = $result['provinces'];
         $data['packages'] = $result['packages'];
-
+		$data['totalVip'] = $result['totalVip'];
         if ($this->input->is_ajax_request()) {
             return $this->load->view('reportpackage/province', $data);
@@ -70,10 +70,15 @@
     public function export() {
         $this->load->model('reportmodel');
+		$data['date']=1;
         $data['month'] = $this->uri->segment(4);
         $data['year'] = $this->uri->segment(5);
+		$data['to_date']=31;
+        $data['to_month'] = date("m");
+        $data['to_year'] = date("Y");
         $data = $this->getdays($data);
         $result = $this->reportmodel->getPackages($data);
         $data['provinces'] = $result['provinces'];
         $data['packages'] = $result['packages'];
+		$data['totalVip'] = $result['totalVip'];
 
         $this->load->library("PHPExcel");
Index: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php	(revision 818)
@@ -30,16 +30,28 @@
 
         $this->load->model('reportmodel');
-        $data['date'] = 1;
+        $data['date'] = date("d");
         $data['month'] = date("m");
         $data['year'] = date("Y");
-        $data['to_date'] = 31; 
+        $data['to_date'] = date("d");
         $data['to_month'] = date("m");
         $data['to_year'] = date("Y");
-        if ($this->input->post('month')) {
+        if ($this->input->post()) {
+			$data['date'] = $this->input->post('date');
             $data['month'] = $this->input->post('month');
             $data['year'] = $this->input->post('year');
-        }
-        $data['provinces'] = $this->reportmodel->getProvinces($data);
-
+			$data['to_date'] = $this->input->post('to_date');
+            $data['to_month'] = $this->input->post('to_month');
+            $data['to_year'] = $this->input->post('to_year');
+        }
+		$result = $this->reportmodel->getProvinces($data);
+        $data['provinces'] =  $result['provinces'];
+		$data['totalTbng'] = $result['totalTbng'];
+		$data['totalTbth'] = $result['totalTbth'];
+		$data['totalTbn'] = $result['totalTbn'];
+		
+		$data['totalDtng'] = $result['totalDtng'];
+		$data['totalDtth'] = $result['totalDtth'];
+		$data['totalDtn'] = $result['totalDtn'];
+		
         if ($this->input->is_ajax_request()) {
             return $this->load->view('reportprovince/province', $data);
@@ -115,3 +127,241 @@
         echo "</pre>";
     }
+	
+	public function exportProvince(){
+		$this->load->model('reportmodel');
+		$data['date'] = date("d");
+        $data['month'] = $this->uri->segment(4);
+        $data['year'] = $this->uri->segment(5);
+        $data['to_date'] = date("d");
+        $data['to_month'] = date("m");
+        $data['to_year'] = date("Y");
+        if ($this->input->post()) {
+			$data['date'] = $this->input->post('date');
+            $data['month'] = $this->input->post('month');
+            $data['year'] = $this->input->post('year');
+			$data['to_date'] = $this->input->post('to_date');
+            $data['to_month'] = $this->input->post('to_month');
+            $data['to_year'] = $this->input->post('to_year');
+        }
+		
+        $result = $this->reportmodel->getProvinces($data);
+        $data['provinces'] =  $result['provinces'];
+		
+		$data['totalTbng'] = $result['totalTbng'];
+		$data['totalTbth'] = $result['totalTbth'];
+		$data['totalTbn'] = $result['totalTbn'];
+		
+		$data['totalDtng'] = $result['totalDtng'];
+		$data['totalDtth'] = $result['totalDtth'];
+		$data['totalDtn'] = $result['totalDtn'];
+
+        $this->load->library("PHPExcel");
+        $sheet = $this->phpexcel->getActiveSheet();
+		
+        $sheet->setTitle("bao cao thue bao " . $data['month'] . " - " . $data['year']);
+        $sheet->getColumnDimension('A')->setWidth(10);
+        $sheet->getColumnDimension('B')->setWidth(25);
+        $sheet->getColumnDimension('C')->setWidth(25);
+        $sheet->getColumnDimension('D')->setWidth(15);
+        $sheet->getColumnDimension('E')->setWidth(15);
+        $sheet->getColumnDimension('F')->setWidth(15);
+        $sheet->getColumnDimension('G')->setWidth(15);
+        $sheet->getColumnDimension('H')->setWidth(15); 
+        $sheet->getColumnDimension('I')->setWidth(15);
+        $sheet->getColumnDimension('J')->setWidth(15);
+		
+		
+		$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:I1');
+		$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:I2');
+		$sheet->getStyle('B2')->applyFromArray($style);
+		
+		
+		$sheet->setCellValue('A4', "BÃO CÃO Tá»NG Há»¢P PHÃT TRIá»N THUÃ BAO VÃ DOANH THU Dá»CH Vá»€ SBG THEO Tá»NH");
+		
+		$style = array(
+			'font' => array('size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
+								'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['date']."/".$data['month']."/".$data['year']);
+		$sheet->setCellValue('C6', "Äáº¿n ngÃ y: ".$data['to_date']."/".$data['to_month']."/".$data['to_year']);
+		$sheet->setCellValue('B7', "NgÃ y káº¿t xuáº¥t: ".date("d")."/".date("m")."/".date("Y"));
+		$sheet->setCellValue('C7', "NhÃ¢n viÃªn káº¿t xuáº¥t: ");
+		
+		$sheet->getStyle('B6')->applyFromArray($style);
+		$sheet->getStyle('C6')->applyFromArray($style);
+		$sheet->getStyle('B7')->applyFromArray($style);
+		$sheet->getStyle('C7')->applyFromArray($style);
+		
+		
+		$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:I4');
+		$sheet->getStyle('A4')->applyFromArray($style);
+		
+		$sheet->setCellValue('A9', 'STT');
+		$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->mergeCells('A9:A10');
+		$sheet->getStyle('A9')->applyFromArray($style);
+		
+		$sheet->setCellValue('B9', 'MÃ£ Tá»nh/ThÃ nh Phá»');
+		$sheet->mergeCells('B9:B10');
+		$sheet->getStyle('B9:B10')->applyFromArray($style);
+		
+		$sheet->setCellValue('C9', "Tá»nh/ThÃ nh phá»");
+		$sheet->mergeCells('C9:C10');
+		$sheet->getStyle('C9:C10')->applyFromArray($style);
+		
+		$sheet->setCellValue('D9', "THUÃ BAO");
+		$sheet->mergeCells('D9:F9');
+		$sheet->getStyle('D9:F9')->applyFromArray($style);
+		
+		$sheet->setCellValue('G9', "DOANH THU");
+		$sheet->mergeCells('G9:I9');
+		$sheet->getStyle('G9:I9')->applyFromArray($style);
+		
+		$sheet->setCellValue('A11', "Tá»ng");
+		$sheet->mergeCells('A11:C11');
+		$sheet->getStyle('A11:C11')->applyFromArray($style);
+		
+		$style = array(
+			'font' => array('bold' => true, 'size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER),
+			'borders' =>	array(
+				'allborders' => array(
+					'style' => \PHPExcel_Style_Border::BORDER_THIN
+					)
+			)
+		);
+		
+		$sheet->setCellValue('D11', $data['totalTbng']);
+		$sheet->setCellValue('E11', $data['totalTbth']);
+		$sheet->setCellValue('F11', $data['totalTbn']);
+		$sheet->setCellValue('G11', $data['totalDtng']);
+		$sheet->setCellValue('H11', $data['totalDtth']);	
+		$sheet->setCellValue('I11', $data['totalDtn']);
+	
+		$sheet->getStyle('D11')->applyFromArray($style);
+		$sheet->getStyle('E11')->applyFromArray($style);
+		$sheet->getStyle('F11')->applyFromArray($style);
+		$sheet->getStyle('G11')->applyFromArray($style);
+		$sheet->getStyle('H11')->applyFromArray($style);
+		$sheet->getStyle('I11')->applyFromArray($style);
+		
+		$styleSTT = array(
+			'font' => array('size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('horizontal' => \PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
+								'vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER),
+			'borders' =>	array(
+				'allborders' => array(
+					'style' => \PHPExcel_Style_Border::BORDER_THIN
+					)
+			)
+		);
+		
+		$style = array(
+			'font' => array('size' => 11, 'name' =>'Cambria'),
+			'alignment' => array('vertical' => \PHPExcel_Style_Alignment::VERTICAL_CENTER),
+			'borders' =>	array(
+				'allborders' => array(
+					'style' => \PHPExcel_Style_Border::BORDER_THIN
+					)
+			)
+		);
+		
+		$sheet->setCellValue('D10', "Thá»±c hiá»n NgÃ y");
+		$sheet->getStyle('D10')->applyFromArray($style);
+		$sheet->setCellValue('E10', "LÅ©y káº¿ ThÃ¡ng");
+		$sheet->getStyle('E10')->applyFromArray($style);
+		$sheet->setCellValue('F10', "LÅ©y káº¿ NÄm");
+		$sheet->getStyle('F10')->applyFromArray($style);
+		$sheet->setCellValue('G10', "Thá»±c hiá»n NgÃ y");
+		$sheet->getStyle('G10')->applyFromArray($style);
+		$sheet->setCellValue('H10', "LÅ©y káº¿ ThÃ¡ng");
+		$sheet->getStyle('H10')->applyFromArray($style);
+		$sheet->setCellValue('I10', "LÅ©y káº¿ NÄm");
+		$sheet->getStyle('I10')->applyFromArray($style);
+		
+		/*
+        $sheet->setCellValue('A1', "BÃ¡o cÃ¡o thuÃª bao theo tá»nh");
+        $sheet->setCellValue('A2', "ThÃ¡ng: " . $data['month'] . " - " . $data['year']);
+        //$sheet->setCellValue('C2', "NgÃ y: ".date('d')." - ".date('m')." - ". date('Y').""); 
+        $sheet->setCellValue('A4', "STT");
+        $sheet->setCellValue('B4', "NgÃ y");
+        $sheet->setCellValue('C4', "MÃ£ Tá»nh/ThÃ nh Phá»");
+        $sheet->setCellValue('D4', "Tá»nh/ThÃ nh phá»");
+        $sheet->setCellValue('E4', "TB NgÃ y");
+        $sheet->setCellValue('F4', "LÅ©y káº¿ TB thÃ¡ng");
+        $sheet->setCellValue('G4', "Tá»ng TB NgÃ y");
+        $sheet->setCellValue('H4', "DT NgÃ y");
+        $sheet->setCellValue('I4', "LÅ©y káº¿ DT thÃ¡ng");
+        $sheet->setCellValue('J4', "Tá»ng DT nÄm");
+		*/
+        $dem=0;
+        foreach ($data['provinces'] as $index => $provinces) {
+            $sheet->setCellValue('A' . ($dem + 12), $provinces['stt']);
+            $sheet->setCellValue('B' . ($dem + 12), $index);
+            $sheet->setCellValue('C' . ($dem + 12), $provinces['province']);
+            $sheet->setCellValue('D' . ($dem + 12), $provinces['tbng']);
+            $sheet->setCellValue('E' . ($dem + 12), $provinces['tbt']);
+            $sheet->setCellValue('F' . ($dem + 12), $provinces['tbn']);
+            $sheet->setCellValue('G' . ($dem + 12), $provinces['dtng']);
+            $sheet->setCellValue('H' . ($dem + 12), $provinces['dtt']);
+            $sheet->setCellValue('I' . ($dem + 12), $provinces['dtn']);
+			
+			$sheet->getStyle('A'. ($dem + 12))->applyFromArray($styleSTT);
+			$sheet->getStyle('B'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('C'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('D'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('E'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('F'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('G'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('H'. ($dem + 12))->applyFromArray($style);
+			$sheet->getStyle('I'. ($dem + 12))->applyFromArray($style);
+			
+            $dem++;
+        }
+		
+        $writer = new PHPExcel_Writer_Excel5($this->phpexcel);
+		header('Content-Type: application/vnd.ms-excel');
+        header('Content-Disposition: attachment; filename="thue_bao_va_doanh_thu_theo_tinh_' .$data["date"]. $data['month'] . $data['year']."_".$data["to_date"]. $data['to_month']. $data['to_year'] . '.xls"');
+        $writer->save('php://output');
+	}
 }
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/paidlog_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/paidlog_model.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/paidlog_model.php	(revision 818)
@@ -1,3 +1,3 @@
-﻿<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
 class Paidlog_model extends MY_Model
@@ -37,5 +37,4 @@
 			if ($data['paid_type'] ==0){
 				$sql.=" WHERE paid_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'";
-				//write_file('./log/sql.log', date("m/d/Y H:i:s")." ".$sql."\n", FOPEN_WRITE_CREATE);
 			}else{
 				$sql.=" AND paid_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'";
@@ -45,13 +44,17 @@
 
         $order = "";
-        if ($data['sorting_order'] != "sorting") {
-            if ($data['sorting_field'] != "money") {
-                $sort = "DESC";
-                if ($data['sorting_order'] == "sorting_asc")
-                    $sort = "ASC";
-                $order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
-            }
-        }
-        $sql=$sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
+		if ($data['sorting_order']){
+			if ($data['sorting_order'] != "sorting") {
+				if ($data['sorting_field'] != "money") {
+					$sort = "DESC";
+					if ($data['sorting_order'] == "sorting_asc")
+						$sort = "ASC";
+					$order = "ORDER BY " . $data['sorting_field'] . " " . $sort;
+				}
+			}
+		}
+		if ($data['start']){
+			$sql=$sql . " " . $order . " LIMIT " . $data['start'] . ", " . $data['perpage'] . " ";
+		}
         //return $this->db->query($sql)->result_array();
 		$re = $this->db->query($sql)->result_array();
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php	(revision 818)
@@ -45,10 +45,12 @@
 		
 		// Tinh thue bao theo tinh theo nam
-		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >= '" . $input ['year'] . "-01-01' AND tbluser.created_time <= '" . ($input ['year'] + 1) . "-01-01' GROUP BY tbluser.province";
-		$query = $this->db->query ( $sql );
+		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >= '" . $input ['year'] . "-01-01 00:00:00' AND tbluser.created_time <= '" . ($input ['year'] + 1) . "-01-01 23:59:59' GROUP BY tbluser.province";
+		$query = $this->db->query ( $sql );
+		write_file('./log/test.log', date('d-m-Y H:i:s').": ".$sql."\n", FOPEN_WRITE_CREATE);
 		$tbns = $query->result_array ();
 		
 		// tinh thue bao theo thang
-		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND  $to GROUP BY tbluser.province";
+		//$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND  $to GROUP BY tbluser.province";
+		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . '01 00:00:00' . "' AND created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59' GROUP BY tbluser.province";
 		$query = $this->db->query ( $sql );
 		$tbts = $query->result_array ();
@@ -56,9 +58,14 @@
 		// tinh thue bao theo ngay
 		$sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >='" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 00:00:00' AND tbluser.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . " 23:59:59'  GROUP BY tbluser.province";
-		
 		$query = $this->db->query ( $sql );
 		$tbng = $query->result_array ();
-		
 		$dem = 1;
+		
+		$totalTbng = 0;
+		$totalTbth = 0;
+		$totalTbn = 0;
+		$totalDtng = 0;
+		$totalDtth = 0;
+		$totalDtn = 0;
 		
 		foreach ( $provinces as $index2 => $province ) {
@@ -104,8 +111,28 @@
 				}
 			}
+			
+			$totalTbng = $totalTbng + $provinces [$index2] ['tbng'];
+			$totalTbth = $totalTbth + $provinces [$index2] ['tbt'];
+			$totalTbn = $totalTbn + $provinces [$index2] ['tbn'];
+			
+			$totalDtng = $totalDtng + $provinces [$index2] ['dtng'];
+			$totalDtth = $totalDtth + $provinces [$index2] ['dtt'];
+			$totalDtn = $totalDtn + $provinces [$index2] ['dtn'];
+			
 			$dem ++;
 		}
-		
-		return $provinces;
+
+		$data['provinces'] = $provinces;
+		
+		$data['totalTbng'] = $totalTbng;
+		$data['totalTbth'] = $totalTbth;
+		$data['totalTbn'] = $totalTbn;
+		
+		$data['totalDtng'] = $totalDtng;
+		$data['totalDtth'] = $totalDtth;
+		$data['totalDtn'] = $totalDtn;
+		
+		//return $provinces;
+		return $data;
 	}
 	
@@ -118,5 +145,6 @@
 		$provinces = lang ( '_PROVINCES_' );
 		// tinh thue bao theo thang
-		$sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblservicepackage.p_period > 0 ";
+		//$sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id LEFT JOIN tblregisterpackagelog ON tbluser.cellphone = tblregisterpackagelog.username WHERE tbluser.updated_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.updated_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblregisterpackagelog.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tblregisterpackagelog.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblservicepackage.p_period > 0 ";
+		$sql = "SELECT * FROM tbluser LEFT JOIN tblregisterpackagelog ON tbluser.cellphone = tblregisterpackagelog.username WHERE tbluser.updated_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tbluser.updated_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "' AND tblregisterpackagelog.created_time >= '" . $input ['year'] . "-" . $input ['month'] . "-" . $input ['date'] . "' AND tblregisterpackagelog.created_time <= '" . $input ['to_year'] . "-" . $input ['to_month'] . "-" . $input ['to_date'] . "'";
 		$query = $this->db->query ( $sql );
 		$users = $query->result_array ();
@@ -128,10 +156,9 @@
 			$packages [$index] ['users'] = array ();
 			foreach ( $users as $user ) {
-				if ($user ['p_id'] == $package ['p_id']) {
+				if ($user ['p_code'] == $package ['p_code']) {
 					$packages [$index] ['users'] [] = $user;
 				}
 			}
 		}
-		
 		foreach ( $provinces as $index => $province ) {
 			$provinces [$index] = array (
@@ -139,5 +166,7 @@
 			);
 		}
+		
 		$dem = 1;
+		
 		foreach ( $provinces as $index => $province ) {
 			$provinces [$index] ['stt'] = $dem;
@@ -154,6 +183,6 @@
 						$provinces [$index] ['total'] = $totaluser;
 						$provinces [$index] ['packages'] [$package ['p_name']] ['total'] = $total;
+						$provinces [$index] ['packages'] [$package ['p_name']] ['users'] [] = $user;
 						
-						$provinces [$index] ['packages'] [$package ['p_name']] ['users'] [] = $user;
 					}
 				}
@@ -161,4 +190,25 @@
 			$dem ++;
 		}
+		
+		$totalByVIP = array();
+		
+		foreach ($packages as $index => $package){
+			$totalByVIP[$package ['p_name']] = 0;
+			foreach ( $provinces as $index=>$province){
+				foreach ($province['packages'] as $index2 => $p){
+					if ($index2 == $package['p_name'])
+						$totalByVIP[$package ['p_name']] = $totalByVIP[$package ['p_name']] + $p['total'];
+				}
+			}
+		}
+		
+		$totalVip = 0;
+		
+		foreach ($totalByVIP as $vipName=>$total){
+			$totalVip = $totalVip + $total;
+		}
+		
+		$totalByVIP['total'] = $totalVip;
+		
 		foreach ( $provinces as $index => $province ) {
 			foreach ( $packages as $index2 => $package ) {
@@ -172,4 +222,5 @@
 		$data ['packages'] = $packages;
 		$data ['provinces'] = $provinces;
+		$data['totalVip'] = $totalByVIP;
 		return $data;
 	}
Index: pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/models/user_model.php	(revision 818)
@@ -69,5 +69,5 @@
 							$sql.=" WHERE province = '".$data['province_code']."' AND created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."'";
 						}else{
-							$sql.=" AND (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
+							$sql.=" WHERE (created_time BETWEEN '".$data['daterange_start']."' AND '".$data['daterange_end']."')";
 						}
 					}else{
@@ -101,4 +101,5 @@
 			}
 		}
+		write_file('./log/test.log', date("d-m-Y: H:i:s"). ": ".$sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage'] , FOPEN_WRITE_CREATE);
 		return $this->db->query($sql." ".$order." LIMIT ".$data['start'].", ".$data['perpage']." ")->result_array();
 	}
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/report/index.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/report/index.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/report/index.php	(revision 818)
@@ -1,6 +1,6 @@
-<?php
+﻿<?php
 $base_url = base_url();
 $this->load->view('layout/admin/header', array('base_url' => $base_url));
-$this->load->view('layout/admin/sidebar', array('base_url' => $base_url, 'method'=>$this->router->method, 'class'=>$this->router->class  ));
+$this->load->view('layout/admin/sidebar', array('base_url' => $base_url, 'method'=>$this->router->method, 'class'=>$this->router->class));
 ?>
 <script type="text/javascript">
@@ -26,5 +26,5 @@
             });
             return false;
-        })
+        });
         $('#keyword').keyup(function (event) {
             if (event.keyCode == '13') {
@@ -157,9 +157,9 @@
         <li>
             <i class="icon-home home-icon"></i>
-            <a href="#">Trang chá»§</a>
+            <a href="#">Trang chủ</a>
         </li>
 
         <li>
-            <a href="#">Quáº£n lÃœ tin nháº¯n</a>
+            <a href="#">Quản lý tin nhắn</a>
         </li>
         
@@ -169,5 +169,5 @@
         <form class="form-search">
             <span class="input-icon">
-                <input type="text" autocomplete="off" id="nav-search-input" class="nav-search-input" placeholder="TÃ¬m kiáº¿m ...">
+                <input type="text" autocomplete="off" id="nav-search-input" class="nav-search-input" placeholder="Tìm kiếm ...">
                 <i class="icon-search nav-search-icon"></i>
             </span>
@@ -183,8 +183,8 @@
     <div class="page-header">
         <h1>
-            Tin nháº¯n
+            Tin nhắn
             <small>
                 <i class="icon-double-angle-right"></i>
-                Máº«u tin nháº¯n
+                Mẫu tin nhắn
             </small>
         </h1>
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/report/listview.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/report/listview.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/report/listview.php	(revision 818)
@@ -3,4 +3,7 @@
 		<div style="padding-bottom:4px" class="table-header">
 			Doanh thu
+			<div class="pull-right" style="margin:5px;">
+					<a style="color:#fff" href="<?php echo base_url();?>admin/report/export">Xuất ra Excel</a>
+                </div>
 		</div>
 
@@ -48,6 +51,6 @@
 						<tr role="row">
 							
-							<th class="<?php if ($sorting_field == 'fullname') {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">Họ tên</th>
-							<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: 283px;" aria-label="Họ tên: activate to sort column ascending">Số điện thoại</th>
+							<th class="<?php if ($sorting_field == 'fullname') {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">Số điện thoại</th>
+							<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: 283px;" aria-label="Họ tên: activate to sort column ascending">Họ tên</th>
 							<th class="<?php if ($sorting_field == 'amount') {echo $sorting_order;} else {echo "sorting";}?>" id="amount" 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ố tiền</th> 
 							<th class="<?php if ($sorting_field == 'paid_type') {echo $sorting_order;} else {echo "sorting";}?>" id="paid_type" 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">SMS/Card</th> 
@@ -66,7 +69,7 @@
 
 							<td class=" ">
-								<a onclick="getUserHistory(<?php echo $paidlog['us_id']; ?>, 1);" data-toggle="modal"><?php echo $paidlog['username'];?></a>
+								<a onclick="getUserHistory(<?php echo $paidlog['us_id']; ?>, 1);" data-toggle="modal"><?php echo $paidlog['cellphone']?></a>
 							</td>
-							<td class=" "><?php echo $paidlog['cellphone']?></td>
+							<td class=" "><?php echo $paidlog['username'];?></td>
 							
 							<td class="hidden-480 "><?php echo number_format($paidlog['amount'],0);?></td>
@@ -134,4 +137,7 @@
                 <div class="tab-content history-tab-content">
                     <div class="tab-pane in active" id="regis">
+						<div class="col-sm-12">
+							<h5>Tài khoản SBG Online: <b><span class="blue"><span id="topup-money"><?php echo number_format($acc_balanced, 0); ?></span> VNĐ <span></b></h5>
+						</div>
                         <div class="table-responsive">
                             <table id="sample-table-1" class="table table-striped table-bordered table-hover">
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/reportpackage/province.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/reportpackage/province.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/reportpackage/province.php	(revision 818)
@@ -55,7 +55,18 @@
                             </tr>
                         </thead>
-
+						<tr>
+								<td colspan=2 align="center" style="font-weight:bold;">Tá»ng</td>
+								<?php $d = 0; ?>
+								<?php foreach ($totalVip as $vipName => $total): ?>	
+									<?php $d++;?>
+									<td style="font-weight:bold;"><?php echo $total; ?></td>
+									<?php if($d<count($totalVip)): ?>
+									<td></td>
+									<?php endif;?>
+								<?php endforeach; ?>
+							</tr>
                         <tbody role="alert" aria-live="polite" aria-relevant="all">
                             <?php
+							$total = array();
                             foreach ($provinces as $province) {
                                 ?>
@@ -75,7 +86,9 @@
                                 </tr>
                             <?php } ?>
+							<?php //var_dump($total);?>
+							
                         </tbody>
                     </table>
-                    <div class="row"><div class="col-sm-6">
+                    <!--<div class="row"><div class="col-sm-6">-->
 
                         </div>
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/reportprovince/province.php	(revision 818)
@@ -9,5 +9,6 @@
                 BÃ¡o cÃ¡o doanh thu theo tá»nh / thÃ nh phá»
                 <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/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>
                 </div>
             </div>
@@ -17,6 +18,17 @@
                     <form autocomplete="off" onsubmit="return false;" id="province" >
                         <div class="row">
-                            <div class="col-sm-6">
-                                <div class="" style="display: inline-block"><label>ThÃ¡ng
+                            <div class="col-sm-1">
+                                <div class="" style="display: inline-block"><label><strong>Tá»«: </strong></label></div>
+							</div>
+							<div class="col-sm-6">
+								<div class="" style="display: inline-block"><label>NgÃ y</label>
+
+                                        <select aria-controls="sample-table-2" size="1" name="date" onchange="filter();">                                      
+                                            <?php for ($i=1;$i<=31;$i++) { ?>
+                                            <option value="<?php echo $i;?>" <?php if($date==$i) { ?> selected <?php }?>><?php echo $i;?></option>
+                                            <?php }?>
+                                        </select>
+                                </div>
+								<div class="" style="display: inline-block"><label>ThÃ¡ng</label>
 
                                         <select aria-controls="sample-table-2" size="1" name="month" onchange="filter();">                                      
@@ -34,5 +46,6 @@
                                         </select>
                                 </div>
-                            </div>
+							</div>
+							
 
                             <div class="col-sm-6">
@@ -40,4 +53,36 @@
                             </div>
                         </div>
+						
+						<div class="row">
+							<div class="col-sm-1">
+								<div class="" style="display: inline-block"><label><strong>Äáº¿n: </strong></label></div>
+							</div>
+							<div class="col-sm-6">
+								<div class="" style="display: inline-block"><label>NgÃ y</label>
+
+                                        <select aria-controls="sample-table-2" size="1" name="to_date" onchange="filter();">                                      
+                                            <?php for ($i=1;$i<=31;$i++) { ?>
+                                            <option value="<?php echo $i;?>" <?php if($to_date==$i) { ?> selected <?php }?>><?php echo $i;?></option>
+                                            <?php }?>
+                                        </select>
+                                </div>
+                                <div class="" style="display: inline-block"><label>ThÃ¡ng</label>
+
+                                        <select aria-controls="sample-table-2" size="1" name="to_month" onchange="filter();">                                      
+                                            <?php for ($i=1;$i<=12;$i++) { ?>
+                                            <option value="<?php echo $i;?>" <?php if($to_month==$i) { ?> selected <?php }?>><?php echo $i;?></option>
+                                            <?php }?>
+                                        </select>
+                                </div>
+                                <div class=""  style="display: inline-block"><label>NÄm
+
+                                        <select aria-controls="sample-table-2" size="1" name="to_year" onchange="filter();">                                      
+                                            <?php for ($i=2014;$i<=date("Y");$i++) { ?>
+                                            <option value="<?php echo $i;?>" <?php if($to_year==$i) { ?> selected <?php }?>><?php echo $i;?></option>
+                                            <?php }?>
+                                        </select>
+                                </div>
+                            </div>
+						</div>
                           </form>
                     <table class="table table-striped table-bordered table-hover dataTable" id="sample-table-2" aria-describedby="sample-table-2_info">
@@ -58,4 +103,14 @@
 
                         <tbody role="alert" aria-live="polite" aria-relevant="all">
+							<tr>
+								<td colspan=2 align="center" style="font-weight:bold;">Tá»ng</td>
+								<td style="font-weight:bold;"><?php echo $totalTbng; ?></td>
+								<td style="font-weight:bold;"><?php echo $totalTbth; ?></td>
+								<td style="font-weight:bold;"><?php echo $totalTbn; ?></td>
+								<td style="font-weight:bold;"><?php echo $totalDtng; ?></td>
+								<td style="font-weight:bold;"><?php echo $totalDtng; ?></td>
+								<td style="font-weight:bold;"><?php echo $totalDtn; ?></td>
+								
+							</tr>
                             <?php
                             foreach ($provinces as $province) {
@@ -77,4 +132,5 @@
 
                                 </tr>
+								
                             <?php } ?>
                         </tbody>
Index: pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/admin/views/user/listview.php	(revision 818)
@@ -171,5 +171,5 @@
                                     <td class=" ">
                                         <a onclick="getUserHistory(<?php echo $user['us_id']; ?>, 1);" data-toggle="modal"><?php echo $user['username']; ?></a>
-                                                                             <!--<a href="#user-history" data-toggle="modal"><?php echo @$user['username']; ?></a>-->
+                                                                             <!--<a href="#user-history" data-toggle="modal"><?php echo $user['username']; ?></a>-->
                                     </td>
                                     <td class=" ">
@@ -177,5 +177,5 @@
                                     </td>
                                     <td class="hidden-480 "><?php echo number_format($user['acc_balanced'], 0); ?></td>
-									<td class=" "><?php echo $user['created_time']; ?></td>
+									<td class=" "><?php echo date('d/m/Y', strtotime($user['created_time'])); ?></td>
                                     <td class=" "><?php echo isset($user['expire_date']) && strtotime($user['expire_date']) > 0 ? date('d/m/Y', strtotime($user['expire_date'])) : ''; ?></td>
                                     <td><?php echo $user['province']; ?></td>
@@ -225,5 +225,5 @@
             <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">Lá»ch sá»­</h4>
+                <h4 class="modal-title">ThÃŽng tin ngÆ°á»i dÃ¹ng</h4>
             </div>
             <div class="modal-body">
@@ -242,4 +242,7 @@
                 <div class="tab-content history-tab-content">
                     <div class="tab-pane in active" id="regis">
+						<div class="col-sm-12">
+							<h5>TÃ i khoáº£n SBG Online: <b><span class="blue"><span id="topup-money"><?php echo number_format($acc_balanced, 0); ?></span> VNÄ <span></b></h5>
+						</div>
                         <div class="table-responsive">
                             <table id="sample-table-1" class="table table-striped table-bordered table-hover">
Index: pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/controllers/user.php	(revision 818)
@@ -453,4 +453,5 @@
 			$data['us_id'] = $us_id;
 			$data['username'] = $username;
+			$data['acc_balanced'] = number_format($user['acc_balanced']);
 			$data['perpage'] = 10;
 			$data['current_page'] = $this->uri->segment(6, 1);
Index: pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/frontend/models/user_model.php	(revision 818)
@@ -88,4 +88,5 @@
 				$us_id = $id;
 				$user ['created_time'] = date ( 'Y-m-d H:i:s' );
+				$user ['updated_time'] = date ( 'Y-m-d H:i:s' );
 				$user ['us_id'] = $us_id;
 				$user ['p_id'] = $trialpackage['p_id']; 
@@ -98,8 +99,14 @@
 				$this->db->query ( 'UNLOCK TABLES' );
 				$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:/');
 				$trialdays = $this->config->item('trial_period');
 				$trialdays = strlen($trialdays) < 2 ? '0'. $trialdays : $trialdays;
-				$sms = preg_replace($aryPatterns, array($trialdays. ' ngay', $username, $password), lang('_SBG_MO_USER_REGISTER_SUCCESS_MSG'));
+				if ($this->isViettel($username)){
+					$sms = preg_replace($aryPatterns, array($trialdays. ' ngay', $username, $password), lang('_SBG_MO_USER_VIETTEL_REGISTER_SUCCESS_MSG'));
+				}else{
+					$aryPatterns = array ('/:username:/', '/:password:/');
+					$sms = preg_replace($aryPatterns, array($username, $password), lang('_SBG_MO_USER_NOT_VIETTEL_REGISTER_SUCCESS_MSG'));
+				}
 				$status = 1;
 				$aryPatterns = array('/:username:/');
@@ -565,12 +572,9 @@
 	{
 		$username = $data['username'];
-                $us_id = $data['us_id'];
-		$this->db->query ( 'UNLOCK TABLES' );
-                //$sql="SELECT tblregisterpackagelog.source,tblservicepackage.p_name,tblregisterpackagelog.created_time FROM tblregisterpackagelog INNER JOIN tblservicepackage ON tblservicepackage.p_code = tblregisterpackagelog.p_code where username = ? UNION SELECT tblpaidlog.source,tblpaidlog.amount,tblpaidlog.paid_time FROM tblpaidlog where us_id = ? ORDER BY created_time DESC LIMIT ".$data['start'].", ".$data['perpage']."";
-				$sql="SELECT tblregisterpackagelog.source,0 as amount,tblservicepackage.p_name,tblregisterpackagelog.created_time FROM tblregisterpackagelog INNER JOIN tblservicepackage ON tblservicepackage.p_code = tblregisterpackagelog.p_code where username = ? UNION SELECT tblpaidlog.source,tblpaidlog.amount,'Nạp tiền' as name,tblpaidlog.paid_time FROM tblpaidlog where us_id = ? ORDER BY created_time DESC LIMIT ".$data['start'].", ".$data['perpage']."";
-                $query = $this->db->query ( $sql, array (
-				"$username",
-                                $us_id
-		) );
+		$us_id = $data['us_id'];
+		$this->db->query ( 'UNLOCK TABLES' );
+		//$sql="SELECT tblregisterpackagelog.source,tblservicepackage.p_name,tblregisterpackagelog.created_time FROM tblregisterpackagelog INNER JOIN tblservicepackage ON tblservicepackage.p_code = tblregisterpackagelog.p_code where username = ? UNION SELECT tblpaidlog.source,tblpaidlog.amount,tblpaidlog.paid_time FROM tblpaidlog where us_id = ? ORDER BY created_time DESC LIMIT ".$data['start'].", ".$data['perpage']."";
+		$sql="SELECT tblregisterpackagelog.source,0 as amount,tblservicepackage.p_name,tblregisterpackagelog.created_time FROM tblregisterpackagelog INNER JOIN tblservicepackage ON tblservicepackage.p_code = tblregisterpackagelog.p_code where username = ? UNION SELECT tblpaidlog.source,tblpaidlog.amount,'Nạp tiền' as name,tblpaidlog.paid_time FROM tblpaidlog where us_id = ? ORDER BY created_time DESC LIMIT ".$data['start'].", ".$data['perpage']."";
+		$query = $this->db->query ( $sql, array ("$username", $us_id) );
 		$row = $query->result_array();
 		return $row;
@@ -597,3 +601,19 @@
 		}
 	}
+	
+	public function isViettel($number) {
+		$prefixViettel = array (
+					'96', '97', '98',
+					'096', '097', '098', '162', '163', '164', '165', '166', '167', '168', '169',
+					'8496', '8497', '8498', '0162', '0163', '0164', '0165', '0166', '0167', '0168', '0169',
+					'84162', '84163', '84164', '84165', '84166', '84167', '84168', '84169'
+		);
+		foreach ( $prefixViettel as $value ) {
+			if (strpos ( $number, $value ) === 0) {
+				return 1;
+			}
+		}
+		return 0;
+	}
+	
 }
Index: pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php
===================================================================
--- pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 777)
+++ pro-violet-viettel/sourcecode/application/modules/services/models/services_model.php	(revision 818)
@@ -228,10 +228,12 @@
 				}
 				else if ($result == _SBG_CHARGING_FAIL_NOT_ENOUGH) {
-					$aryPatterns = array ('/:amount:/');
-					$smsReturn = preg_replace($aryPatterns, array($amount), lang('_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_MSG'));
+					//$aryPatterns = array ('/:amount:/');
+					$aryPatterns = array ('/:sentNumber:/');
+					$smsReturn = preg_replace($aryPatterns, array($sentNumber), lang('_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_MSG'));
+					/*
 					if ($case == _SBG_MO_PAY_TO_ACCOUNT_FOR) {
 						$aryPatterns = array ('/:amount:/', '/:username:/');
 						$smsReturn = preg_replace($aryPatterns, array($amount, $userName), lang('_SBG_MO_CHARGING_FAIL_NOT_ENOUGH_FOR_MSG'));
-					}
+					}*/
 					$smsReturn = _SBG_MO_PROCCESS_ERR.'|'.$smsReturn;
 				}
@@ -248,5 +250,10 @@
 				break;
 			case _SBG_MO_SUPPOR_SERVICE:
-				$smsReturn = '1|'.lang('_SBG_MO_SUPPORT_MSG');
+				//$smsReturn = '1|'.lang('_SBG_MO_SUPPORT_MSG');
+				if ($this->isViettel($sentNumber)){
+					$smsReturn = '1|'.lang('_SBG_MO_SUPPORT_VIETTEL_MSG');
+				}else{
+					$smsReturn = '1|'.lang('_SBG_MO_SUPPORT_NOT_VIETTEL_MSG');
+				}
 				break;
 			case _SBG_MO_UNSUBSCRIBE_SERVICE:
@@ -511,3 +518,18 @@
 		}
 	}
+	
+	public function isViettel($number) {
+		$prefixViettel = array (
+					'96', '97', '98',
+					'096', '097', '098', '162', '163', '164', '165', '166', '167', '168', '169',
+					'8496', '8497', '8498', '0162', '0163', '0164', '0165', '0166', '0167', '0168', '0169',
+					'84162', '84163', '84164', '84165', '84166', '84167', '84168', '84169'
+		);
+		foreach ( $prefixViettel as $value ) {
+			if (strpos ( $number, $value ) === 0) {
+				return 1;
+			}
+		}
+		return 0;
+	}
 }
