source: pro-violet-viettel/sourcecode/application/modules/admin/controllers/reportpackage.php @ 702

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

Report by provinces

File size: 2.8 KB
Line 
1<?php
2
3if (!defined('BASEPATH'))
4    exit('No direct script access allowed');
5
6class Reportpackage 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    }
16
17    public function index() {
18        $data = array();
19        $admin_info = $this->session->userdata('adminInfo');
20        if ($admin_info) {
21            $data['content'] = $this->getProvince();
22            $this->load->view('reportpackage/index', $data);
23        } else {
24            $this->load->view('login');
25        }
26   
27    }
28
29
30
31    public function getProvince($filters = array()) {
32       
33        $this->load->model('reportmodel');
34        $data['month']=date("m");
35        $data['year']=date("Y");
36        if ($this->input->post('month')) {
37          $data['month']=$this->input->post('month');
38          $data['year']=$this->input->post('year');
39        }
40        $data['month_days']=1;
41        if("".$data['year']."-".$data['month'].""==date("Y-m"))
42        {
43        $data['month_days']=date("d");
44        }
45        else
46        {
47        $data['month_days']=cal_days_in_month(CAL_GREGORIAN, $data['month'], $data['year']); // 31 
48        }
49        $data['year_days']=1;
50        if($data['year']== date("Y"))
51        {
52        $data['year_days']=date('z') + 1;
53        }
54        else
55        {
56        $data['year_days']=date("z", mktime(0,0,0,12,31,$data['year'])) + 1;
57        }
58       
59
60       
61        $result=$this->reportmodel->getPackages($data);
62        $data['provinces'] = $result['provinces'];
63        $data['packages'] = $result['packages'];
64       
65        if ($this->input->is_ajax_request()) {
66            return $this->load->view('reportpackage/province', $data);
67        }
68        return $this->load->view('reportpackage/province', $data, true);
69    }
70
71    private function get_fullname($us_id) {
72        $fullname="";
73        $src = 'violet';
74        $token = md5($us_id . self::TOKENPW);
75        $this->load->model('user_model');
76        $data = $this->user_model->get_user_info($src, $us_id, $token);
77        parse_str($data,$data);
78        if (isset($data['fullname']))
79        {
80            $fullname=$data['fullname'];
81        }
82        return $fullname;
83    }
84
85    public function test() {
86
87            $provinces=lang('_PROVINCES_');
88            $sql="SELECT * FROM tbluser";
89            $query = $this->db->query ($sql);
90                $result = $query->result_array();
91            foreach ($result as $user)
92            {
93                $p=$provinces[rand(0,62)];
94                $user['province']=$p;
95                $this->db->where('us_id', $user['us_id']);
96                $this->db->update('tbluser', $user);
97            }
98    }
99
100}
Note: See TracBrowser for help on using the repository browser.