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

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

report

File size: 4.3 KB
RevLine 
[702]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');
[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}
Note: See TracBrowser for help on using the repository browser.