Ignore:
Timestamp:
Nov 10, 2014 10:10:32 AM (11 years ago)
Author:
quyenla
Message:

paidlogs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/sourcecode/application/modules/admin/controllers/report.php

    r422 r441  
    1515        $admin_info = $this->session->userdata('adminInfo');
    1616        if ($admin_info) {
    17             $data['statistics'] = $this->getStatistics();
    18             $data['content'] = $this->getSmstemplates();
     17            $data['statistics'] = $this->getStatistics();           
     18            $data['content'] = $this->getPaidlogs();
    1919            $this->load->view('report/index', $data);
    2020        } else {
     
    2525    {
    2626        $data=array();
     27       
     28        $last_month['start']= strtotime(date("Y-m-d", strtotime("first day of previous month"))." 00:00:00");
     29        $last_month['end']= strtotime(date("Y-m-d", strtotime("last day of previous month"))." 23:59:59");
     30       
     31        $last_week['start']= strtotime(date("Y-m-d", strtotime("first day of previous week"))." 00:00:00");
     32        $last_week['end']= strtotime(date("Y-m-d", strtotime("last day of previous week"))." 23:59:59");
     33       
     34        $last_week['end']=strtotime('last sunday')+(24*60*60-1);
     35        $last_week['start']=($last_week['end']-7*24*60*60+1);
     36       
     37        $last_year['start']=  strtotime((date("Y")-1)."-01-01 00:00:00");
     38        $last_year['end']=  strtotime((date("Y")-1)."-12-31 23:59:59");
     39       
     40       
     41       
     42        $last_quarter=$this->getLastquarter();
     43        $last_quarter['start']=  $last_quarter['start'];
     44        $last_quarter['end']=  $last_quarter['end'];
     45       
     46       
     47        $this->load->model('paidlog_model');
     48        $paidlogs = $this->paidlog_model->getAllPaidlogs($last_year['start']);
     49       
     50        $revenue['last_week']=0;
     51        $revenue['last_month']=0;
     52        $revenue['last_quarter']=0;
     53        $revenue['last_year']=0;
     54        foreach ($paidlogs as $paidlog)
     55        {
     56           
     57            if (($paidlog['time'] < $last_week['end'])&&($paidlog['time'] > $last_week['start']))
     58            {
     59                $revenue['last_week']+=$paidlog['amount'];
     60            }
     61            if (($paidlog['time'] < $last_month['end'])&&($paidlog['time'] > $last_month['start']))
     62            {
     63                $revenue['last_month']+=$paidlog['amount'];
     64            }
     65            if (($paidlog['time'] < $last_quarter['end'])&&($paidlog['time'] > $last_quarter['start']))
     66            {
     67                $revenue['last_quarter']+=$paidlog['amount'];
     68            }
     69            if (($paidlog['time'] < $last_year['end'])&&($paidlog['time'] > $last_year['start']))
     70            {
     71                $revenue['last_year']+=$paidlog['amount'];
     72            }
     73        }
     74        $data['revenue']=$revenue;
    2775        return $this->load->view('report/statistics', $data, true);
    2876    }
    29     public function getSmstemplates($filters = array()) {
     77    public function getLastquarter()
     78    {
     79        $current_month = date('m');
     80          $current_year = date('Y');
     81
     82          if($current_month>=1 && $current_month<=3)
     83          {
     84            $start_date = strtotime('1-October-'.($current_year-1));  // timestamp or 1-October Last Year 12:00:00 AM
     85            $end_date = strtotime('1-Janauary-'.$current_year);  // // timestamp or 1-January  12:00:00 AM means end of 31 December Last year
     86          }
     87          else if($current_month>=4 && $current_month<=6)
     88          {
     89            $start_date = strtotime('1-January-'.$current_year);  // timestamp or 1-Janauray 12:00:00 AM
     90            $end_date = strtotime('1-April-'.$current_year);  // timestamp or 1-April 12:00:00 AM means end of 31 March
     91          }
     92          else  if($current_month>=7 && $current_month<=9)
     93          {
     94            $start_date = strtotime('1-April-'.$current_year);  // timestamp or 1-April 12:00:00 AM
     95            $end_date = strtotime('1-July-'.$current_year);  // timestamp or 1-July 12:00:00 AM means end of 30 June
     96          }
     97          else  if($current_month>=10 && $current_month<=12)
     98          {
     99            $start_date = strtotime('1-July-'.$current_year);  // timestamp or 1-July 12:00:00 AM
     100            $end_date = strtotime('1-October-'.$current_year);  // timestamp or 1-October 12:00:00 AM means end of 30 September
     101          }
     102          return array("start"=>$start_date,"end"=>$end_date);
     103    }
     104    public function getPaidlogs($filters = array()) {
    30105        $this->load->helper('pagging');
    31106        $this->load->model('paidlog_model');
     
    58133        }
    59134       
    60         $data['start'] = ($data['current_page'] - 1) * $data['perpage'];
    61         $data['total'] = $this->paidlog_model->countSmstemplate($data); 
    62        
    63         $data['paidlogs'] = $this->paidlog_model->getSmstemplates($data);
    64 
    65         $data['paging_url'] = base_url() . "/admin/mau_tin_nhan/trang/";
     135        $data['start'] = ($data['current_page'] - 1) * $data['perpage'];   
     136        $data['total'] = $this->paidlog_model->countPaidlog($data); 
     137        $data['paidlogs'] = $this->paidlog_model->getPaidlogs($data);
     138
     139        $data['paging_url'] = base_url() . "/admin/doanh_thu_tong_hop/trang/";
    66140        $data['num_links'] = 2;
    67141        $data['paging'] = pagging($data);
     
    73147    }
    74148
    75     public function addSmstemplate() {
     149    public function addPaidlog() {
    76150        $result['success'] = 0;
    77151        $result = array();
     
    124198        $id=$this->uri->segment(4);
    125199        $this->load->model('paidlog_model');
    126         $data=$this->paidlog_model->getSmstemplate($id);
     200        $data=$this->paidlog_model->getPaidlog($id);
    127201        $this->load->view('report/viewSms',$data);
    128202    }
     
    131205        $id=$this->uri->segment(4);
    132206        $this->load->model('paidlog_model');
    133         $data=$this->paidlog_model->getSmstemplate($id);
     207        $data=$this->paidlog_model->getPaidlog($id);
    134208        $this->load->view('report/editSms',$data);
    135209    }
     
    147221        $id=$this->uri->segment(4);
    148222        $this->load->model('paidlog_model');
    149         $data=$this->paidlog_model->getSmstemplate($id);
     223        $data=$this->paidlog_model->getPaidlog($id);
    150224        $this->load->view('report/deleteSms',$data);
    151225    }
     
    198272    public function test() {
    199273       
    200       /*
    201         for ($i = 1; $i <= 1500; $i++) {
     274     
     275        for ($i = 1; $i <= 5000; $i++) {
    202276            $input['us_id']=rand(1,100);
    203277            $input['paid_type']=rand(1,2);
    204278            $input['amount']=rand(3,10)*1000;
    205             $time=(rand((time()-(5*30*24*60*60)),time()));
     279            $time=(rand((time()-(12*30*24*60*60)),time()));
    206280            $input['paid_time']= date("Y-m-d H:i:s",$time);
    207281            $this->load->model('paidlog_model');
    208282            $this->paidlog_model->insert($input);
    209283        }
    210        *
    211        */
     284       
     285       die();
     286     
    212287        for ($i = 1; $i <= 100; $i++) {
    213288            $input['us_id']=$i;
Note: See TracChangeset for help on using the changeset viewer.