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');
+	}
 }
