Ignore:
Timestamp:
Feb 11, 2015 4:08:09 PM (10 years ago)
Author:
quyenla
Message:

report

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/models/reportmodel.php

    r760 r761  
    1616
    1717    function getProvinces($input) {
    18         $ext="";
    19         if (isset($input['to_month']))
    20         {
    21             $ext="AND tblpaidlog.paid_time <'" . $input['to_year'] . "-" . $input['to_month'] . "-01 23:59:59'";
    22         }
     18
     19        $from="tblpaidlog.paid_time >'" . $input['year'] . "-" . $input['month'] . "-" . $input['date'] . " 00:00:00'";
     20        $to="tblpaidlog.paid_time <'" . $input['to_year'] . "-" . $input['to_month'] . "-" . $input['to_date'] . " 23:59:59'";
     21       
    2322        $provinces = lang('_PROVINCES_');
    2423        // Tinh doanh thu theo tinh theo nam
     
    2625        $query = $this->db->query($sql);
    2726        $dtns = $query->result_array();
     27       
    2828        // tinh doanh thu theo thang
    29         $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time >'" . $input['year'] . "-" . $input['month'] . "-01' $ext  GROUP BY tbluser.province";
     29        $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE $from AND $to  GROUP BY tbluser.province";
    3030        $query = $this->db->query($sql);
    3131        $dtts = $query->result_array();
     32       
    3233        // tinh doanh thu trong ngay hien tai
    33         $sql = "SELECT *,SUM(amount) as total FROM tblpaidlog LEFT JOIN tbluser ON tbluser.us_id=tblpaidlog.us_id WHERE tblpaidlog.paid_time > '" . date('Y') . "-" . date('m') . "-".date('d')." 00:00:00' AND  tblpaidlog.paid_time <'" . date('Y') . "-" . date('m') . "-".date('d')." 23:59:59'  GROUP BY tbluser.province";
    3434        if (isset($input['to_month']))
    3535        {
     
    4545
    4646        // tinh thue bao theo thang
    47         $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . $input['year'] . "-" . $input['month'] . "-01'  $ext GROUP BY tbluser.province";
     47        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE $from AND  $to GROUP BY tbluser.province";
    4848        $query = $this->db->query($sql);
    4949        $tbts = $query->result_array();
    5050       
    5151         // tinh thue bao theo ngay
    52         $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . date('Y') . "-" . date('m') . "-".date('d')." 00:00:00' AND tbluser.created_time < '" . date('Y') . "-" . date('m') . "-".date('d')." 23:59:59'  GROUP BY tbluser.province";
    53         if (isset($input['to_month']))
    54         {
    55             $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 00:00:00' AND tbluser.created_time < '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 23:59:59'  GROUP BY tbluser.province";
    56         }
     52        $sql = "SELECT *,count(us_id) as total FROM tbluser WHERE tbluser.created_time >'" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 00:00:00' AND tbluser.created_time < '" . $input['to_year'] . "-" . $input['to_month'] . "-".$input['to_date']." 23:59:59'  GROUP BY tbluser.province";
     53       
    5754        $query = $this->db->query($sql);
    5855        $tbng = $query->result_array();
     
    104101        $provinces = lang('_PROVINCES_');
    105102        // tinh thue bao theo thang
    106         $sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >'" . $input['year'] . "-" . $input['month'] . "-01' AND tbluser.created_time <'" . $input['year'] . "-" . $input['month'] . "-31' AND tblservicepackage.p_period > 0 ";
     103        $sql = "SELECT * FROM tbluser LEFT JOIN tblservicepackage ON tbluser.p_id=tblservicepackage.p_id  WHERE tbluser.created_time >'" . $input['year'] . "-" . $input['month'] . "-" . $input['date'] . "' AND tbluser.created_time <'" . $input['to_year'] . "-" . $input['to_month'] . "-" . $input['to_date'] . "' AND tblservicepackage.p_period > 0 ";
    107104        $query = $this->db->query($sql);
    108105        $users = $query->result_array();
     
    160157    }
    161158    public function exportProvince($input)
    162     {
     159    {   
     160        //$input['date']=1;
    163161        //$input['month']=1;
    164162        //$input['year']=2014;
     
    183181    public function exportPackage($input)
    184182    {
     183       // $input['date']=1;
    185184        //$input['month']=1;
    186         //$input['year']=2014;
     185      //  $input['year']=2014;
     186      // $input['to_month']=1;
     187       // $input['to_year']=2015;
     188       // $input['to_date']=15;
    187189        if (isset($input['month']))
    188190        {
Note: See TracChangeset for help on using the changeset viewer.