[702] | 1 | <?php |
---|
| 2 | |
---|
| 3 | if (!defined('BASEPATH')) |
---|
| 4 | exit('No direct script access allowed'); |
---|
| 5 | |
---|
| 6 | class Reportprovince extends MX_Controller { |
---|
| 7 | |
---|
| 8 | const TOKENPW = 'violet'; |
---|
| 9 | |
---|
| 10 | public function __construct() { |
---|
| 11 | parent::__construct(); |
---|
| 12 | $this->load->helper('cookie'); |
---|
| 13 | $this->load->helper('language'); |
---|
| 14 | $this->lang->load('messages', 'message'); |
---|
[749] | 15 | $this->load->model('reportmodel'); |
---|
[702] | 16 | } |
---|
| 17 | |
---|
| 18 | public function index() { |
---|
| 19 | $data = array(); |
---|
| 20 | $admin_info = $this->session->userdata('adminInfo'); |
---|
| 21 | if ($admin_info) { |
---|
| 22 | $data['content'] = $this->getProvince(); |
---|
| 23 | $this->load->view('reportprovince/index', $data); |
---|
| 24 | } else { |
---|
| 25 | $this->load->view('login'); |
---|
| 26 | } |
---|
| 27 | } |
---|
| 28 | |
---|
[713] | 29 | public function getProvince($filters = array()) { |
---|
[702] | 30 | |
---|
| 31 | $this->load->model('reportmodel'); |
---|
[761] | 32 | $data['date'] = 1; |
---|
[713] | 33 | $data['month'] = date("m"); |
---|
| 34 | $data['year'] = date("Y"); |
---|
[761] | 35 | $data['to_date'] = 31; |
---|
| 36 | $data['to_month'] = date("m"); |
---|
| 37 | $data['to_year'] = date("Y"); |
---|
[702] | 38 | if ($this->input->post('month')) { |
---|
[713] | 39 | $data['month'] = $this->input->post('month'); |
---|
| 40 | $data['year'] = $this->input->post('year'); |
---|
[702] | 41 | } |
---|
| 42 | $data['provinces'] = $this->reportmodel->getProvinces($data); |
---|
| 43 | |
---|
| 44 | if ($this->input->is_ajax_request()) { |
---|
| 45 | return $this->load->view('reportprovince/province', $data); |
---|
| 46 | } |
---|
| 47 | return $this->load->view('reportprovince/province', $data, true); |
---|
| 48 | } |
---|
| 49 | |
---|
[749] | 50 | |
---|
[702] | 51 | |
---|
[713] | 52 | public function export() { |
---|
| 53 | $this->load->model('reportmodel'); |
---|
| 54 | $data['month'] = $this->uri->segment(4); |
---|
| 55 | $data['year'] = $this->uri->segment(5); |
---|
[749] | 56 | |
---|
[713] | 57 | $data['provinces'] = $this->reportmodel->getProvinces($data); |
---|
[702] | 58 | |
---|
[713] | 59 | $this->load->library("PHPExcel"); |
---|
| 60 | $sheet = $this->phpexcel->getActiveSheet(); |
---|
| 61 | $sheet->setTitle("bao cao thue bao " . $data['month'] . " - " . $data['year']); |
---|
| 62 | $sheet->getColumnDimension('A')->setWidth(10); |
---|
| 63 | $sheet->getColumnDimension('B')->setWidth(25); |
---|
[756] | 64 | $sheet->getColumnDimension('C')->setWidth(25); |
---|
[713] | 65 | $sheet->getColumnDimension('D')->setWidth(15); |
---|
| 66 | $sheet->getColumnDimension('E')->setWidth(15); |
---|
| 67 | $sheet->getColumnDimension('F')->setWidth(15); |
---|
| 68 | $sheet->getColumnDimension('G')->setWidth(15); |
---|
[756] | 69 | $sheet->getColumnDimension('H')->setWidth(15); |
---|
[761] | 70 | $sheet->getColumnDimension('I')->setWidth(15); |
---|
| 71 | $sheet->getColumnDimension('J')->setWidth(15); |
---|
[713] | 72 | $sheet->setCellValue('A1', "Báo cáo thuê bao theo tá»nh"); |
---|
[745] | 73 | $sheet->setCellValue('A2', "Tháng: " . $data['month'] . " - " . $data['year']); |
---|
[761] | 74 | //$sheet->setCellValue('C2', "Ngà y: ".date('d')." - ".date('m')." - ". date('Y').""); |
---|
[713] | 75 | $sheet->setCellValue('A4', "STT"); |
---|
[761] | 76 | $sheet->setCellValue('B4', "Ngà y"); |
---|
| 77 | $sheet->setCellValue('C4', "Mã Tá»nh/Thà nh Phá»"); |
---|
| 78 | $sheet->setCellValue('D4', "Tá»nh/Thà nh phá»"); |
---|
| 79 | $sheet->setCellValue('E4', "TB Ngà y"); |
---|
| 80 | $sheet->setCellValue('F4', "Lũy kế TB tháng"); |
---|
| 81 | $sheet->setCellValue('G4', "Tá»ng TB Ngà y"); |
---|
| 82 | $sheet->setCellValue('H4', "DT Ngà y"); |
---|
| 83 | $sheet->setCellValue('I4', "Lũy kế DT tháng"); |
---|
| 84 | $sheet->setCellValue('J4', "Tá»ng DT nÄm"); |
---|
[754] | 85 | $dem=0; |
---|
[713] | 86 | foreach ($data['provinces'] as $index => $provinces) { |
---|
[754] | 87 | $sheet->setCellValue('A' . ($dem + 5), $provinces['stt']); |
---|
[761] | 88 | $sheet->setCellValue('B' . ($dem + 5), date('d')." - ".date('m')." - ". date('Y')); |
---|
| 89 | $sheet->setCellValue('C' . ($dem + 5), $index); |
---|
| 90 | $sheet->setCellValue('D' . ($dem + 5), $provinces['province']); |
---|
| 91 | $sheet->setCellValue('E' . ($dem + 5), $provinces['tbng']); |
---|
| 92 | $sheet->setCellValue('F' . ($dem + 5), $provinces['tbt']); |
---|
| 93 | $sheet->setCellValue('G' . ($dem + 5), $provinces['tbn']); |
---|
| 94 | $sheet->setCellValue('H' . ($dem + 5), $provinces['dtng']); |
---|
| 95 | $sheet->setCellValue('I' . ($dem + 5), $provinces['dtt']); |
---|
| 96 | $sheet->setCellValue('J' . ($dem + 5), $provinces['dtn']); |
---|
[754] | 97 | $dem++; |
---|
[713] | 98 | } |
---|
| 99 | $writer = new PHPExcel_Writer_Excel5($this->phpexcel); |
---|
[737] | 100 | header('Content-Type: application/vnd.ms-excel'); |
---|
[713] | 101 | header('Content-Disposition: attachment; filename="thue_bao_' . $data['month'] . "_" . $data['year'] . '.xls"'); |
---|
| 102 | $writer->save('php://output'); |
---|
[702] | 103 | } |
---|
[761] | 104 | |
---|
[702] | 105 | } |
---|