source: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportprovince.php @ 757

Last change on this file since 757 was 757, checked in by quyenla, 10 years ago

report update

File size: 4.0 KB
Line 
1<?php
2
3if (!defined('BASEPATH'))
4    exit('No direct script access allowed');
5
6class 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');
15        $this->load->model('reportmodel');
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
29    public function getProvince($filters = array()) {
30
31        $this->load->model('reportmodel');
32        $data['month'] = date("m");
33        $data['year'] = date("Y");
34        if ($this->input->post('month')) {
35            $data['month'] = $this->input->post('month');
36            $data['year'] = $this->input->post('year');
37        }
38        $data['provinces'] = $this->reportmodel->getProvinces($data);
39
40        if ($this->input->is_ajax_request()) {
41            return $this->load->view('reportprovince/province', $data);
42        }
43        return $this->load->view('reportprovince/province', $data, true);
44    }
45
46 
47
48    public function export() {
49        $this->load->model('reportmodel');
50        $data['month'] = $this->uri->segment(4);
51        $data['year'] = $this->uri->segment(5);
52       
53        $data['provinces'] = $this->reportmodel->getProvinces($data);
54
55        $this->load->library("PHPExcel");
56        $sheet = $this->phpexcel->getActiveSheet();
57        $sheet->setTitle("bao cao thue bao " . $data['month'] . " - " . $data['year']);
58        $sheet->getColumnDimension('A')->setWidth(10);
59        $sheet->getColumnDimension('B')->setWidth(25);
60        $sheet->getColumnDimension('C')->setWidth(25);
61        $sheet->getColumnDimension('D')->setWidth(15);
62        $sheet->getColumnDimension('E')->setWidth(15);
63        $sheet->getColumnDimension('F')->setWidth(15);
64        $sheet->getColumnDimension('G')->setWidth(15);
65        $sheet->getColumnDimension('H')->setWidth(15);
66        $sheet->getColumnDimension('I')->setWidth(20);
67        $sheet->setCellValue('A1', "Báo cáo thuê bao theo tỉnh");
68        $sheet->setCellValue('A2', "Tháng: " . $data['month'] . " - " . $data['year']);
69        $sheet->setCellValue('C2', "Ngày: ".date('d')." - ".date('m')." - ". date('Y')."");
70        $sheet->setCellValue('A4', "STT");
71        $sheet->setCellValue('B4', "Mã Tỉnh/Thành Phố");
72        $sheet->setCellValue('C4', "Tỉnh/Thành phố");
73        $sheet->setCellValue('D4', "TB Ngày");
74        $sheet->setCellValue('E4', "LÅ©y kế TB tháng");
75        $sheet->setCellValue('F4', "Tổng TB Ngày");
76        $sheet->setCellValue('G4', "DT Ngày");
77        $sheet->setCellValue('H4', "LÅ©y kế DT tháng");
78        $sheet->setCellValue('I4', "Tổng DT năm");
79        $dem=0;
80        foreach ($data['provinces'] as $index => $provinces) {
81            $sheet->setCellValue('A' . ($dem + 5), $provinces['stt']);
82            $sheet->setCellValue('B' . ($dem + 5), $index);
83            $sheet->setCellValue('C' . ($dem + 5), $provinces['province']);
84            $sheet->setCellValue('D' . ($dem + 5), $provinces['tbng']);
85            $sheet->setCellValue('E' . ($dem + 5), $provinces['tbt']);
86            $sheet->setCellValue('F' . ($dem + 5), $provinces['tbn']);
87            $sheet->setCellValue('G' . ($dem + 5), $provinces['dtng']);
88            $sheet->setCellValue('H' . ($dem + 5), $provinces['dtt']);
89            $sheet->setCellValue('I' . ($dem + 5), $provinces['dtn']);
90            $dem++;
91        }
92        $writer = new PHPExcel_Writer_Excel5($this->phpexcel);
93                header('Content-Type: application/vnd.ms-excel');
94        header('Content-Disposition: attachment; filename="thue_bao_' . $data['month'] . "_" . $data['year'] . '.xls"');
95        $writer->save('php://output');
96    }
97}
Note: See TracBrowser for help on using the repository browser.