Changeset 741


Ignore:
Timestamp:
Feb 3, 2015 6:14:25 PM (10 years ago)
Author:
quyenla
Message:

fixing charts

Location:
pro-violet-viettel/sourcecode/application/modules/admin
Files:
3 edited

Legend:

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

    r736 r741  
    7373        }
    7474
    75         $data['max'] = 50000;
     75        $data['max'] = $max;
    7676        $chard[] = array("color" => "#e67e22", "label" => "Lượng người dùng giới thiệu bởi cộng tác viên theo từng tháng", "data" => $chart);
    7777        $data['chard'] = $chard;
    78 
     78         
    7979        return $this->load->view('reportAsistant/statistics', $data, true);
    8080    }
  • pro-violet-viettel/sourcecode/application/modules/admin/models/collabolator_model.php

    r737 r741  
    5656        }
    5757        //$sql="SELECT *,tblcollaborator.created_time as collaborator_created_time, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.id WHERE tbluser.created_time > '".$from."'".$where."";
    58 
    5958                $sql="SELECT *,tblcollaborator.created_time as collaborator_created_time, tbluser.created_time as user_created_time  FROM ".$this->table_name." INNER JOIN tbluser ON tbluser.collaborator = tblcollaborator.cellphone WHERE tbluser.created_time > '".$from."'".$where."";
    6059
     
    6463            $result[$index]['time']=  strtotime($paidlog['user_created_time']);
    6564        }
     65       
    6666        return $result;
    6767    }
     
    238238    function getStatistics()
    239239    {
     240     
     241       $day = date('w');
    240242        $data = array();
    241         $last_month['start'] = strtotime(date("Y-m-d", strtotime("first day of previous month")) . " 00:00:00");
    242         $last_month['end'] = strtotime(date("Y-m-d", strtotime("last day of previous month")) . " 23:59:59");
    243 
    244         $last_week['start'] = strtotime(date("Y-m-d", strtotime("first day of previous week")) . " 00:00:00");
    245         $last_week['end'] = strtotime(date("Y-m-d", strtotime("last day of previous week")) . " 23:59:59");
     243        $last_month['start'] = strtotime(date("Y-m-d", strtotime(date("Y-m-d", mktime(0, 0, 0, date("m")-1, 1, date("Y"))))) . " 00:00:00");
     244        $last_month['end'] = strtotime(date("Y-m-d", strtotime(date("Y-m-d", mktime(0, 0, 0, date("m"), 0, date("Y"))))) . " 23:59:59");
     245
     246        $last_week['start'] = strtotime(date("Y-m-d", strtotime(date('m-d-Y', strtotime('-'.$day.' days')))) . " 00:00:00");
     247        $last_week['end'] = strtotime(date("Y-m-d", strtotime(date('m-d-Y', strtotime('+'.(6-$day).' days')))) . " 23:59:59");
    246248
    247249        $last_week['end'] = strtotime('last sunday') + (24 * 60 * 60 - 1);
     
    266268        $revenue['last_year'] = 0;
    267269
    268         $lastmonth = strtotime("first day of previous month");
    269         $thismonth = strtotime("first day of this month");
     270        $lastmonth = strtotime(date("Y-m-d", mktime(0, 0, 0, date("m")-1, 1, date("Y"))));
     271        $thismonth = strtotime(date('Y-m-01'));
    270272        $charts['last_month'] = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
    271273        $charts['this_month'] = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0);
     
    279281        $top['this_month']['card']=0;
    280282        $top['this_month']['collaborator']=0;
     283       
    281284        foreach ($paidlogs as $paidlog) {
    282285
    283286           
    284287            if (($paidlog['time'] < $last_week['end']) && ($paidlog['time'] > $last_week['start'])) {
     288               
    285289                $revenue['last_week']+=$paidlog['amount'];
    286290            }
    287291            if (($paidlog['time'] < $last_month['end']) && ($paidlog['time'] > $last_month['start'])) {
     292           
    288293                $revenue['last_month']+=$paidlog['amount'];
    289294            }
    290295            if (($paidlog['time'] < $last_quarter['end']) && ($paidlog['time'] > $last_quarter['start'])) {
     296             
    291297                $revenue['last_quarter']+=$paidlog['amount'];
    292298            }
    293299            if (($paidlog['time'] < $last_year['end']) && ($paidlog['time'] > $last_year['start'])) {
     300             
    294301                $revenue['last_year']+=$paidlog['amount'];
    295302            }
     
    331338
    332339            if (($paidlog['time'] < $thismonth + (7 * 24 * 60 * 60)) && ($paidlog['time'] > $thismonth)) {
    333                 $charts['this_month'][0]+=$paidlog['amount'];
     340             
     341                $charts['this_month'][0] += $paidlog['amount'];
    334342            }
    335343            if (($paidlog['time'] < $thismonth + (14 * 24 * 60 * 60)) && ($paidlog['time'] > $thismonth + (7 * 24 * 60 * 60))) {
     344               
    336345                $charts['this_month'][1]+=$paidlog['amount'];
    337346            }
    338347            if (($paidlog['time'] < $thismonth + (21 * 24 * 60 * 60)) && ($paidlog['time'] > $thismonth + (14 * 24 * 60 * 60))) {
     348               
    339349                $charts['this_month'][2]+=$paidlog['amount'];
    340350            }
    341351            if (($paidlog['time'] < $thismonth + (28 * 24 * 60 * 60)) && ($paidlog['time'] > $thismonth + (21 * 24 * 60 * 60))) {
     352               
    342353                $charts['this_month'][3]+=$paidlog['amount'];
    343354            }
    344355            if (($paidlog['time'] < $thismonth + (31 * 24 * 60 * 60)) && ($paidlog['time'] > $thismonth + (28 * 24 * 60 * 60))) {
     356               
    345357                $charts['this_month'][4]+=$paidlog['amount'];
    346358            }
     
    361373            }
    362374        }
     375     
    363376        $percent=array();
    364377        foreach ($top['this_month'] as $index=>$value)
     
    394407
    395408        $data['revenue'] = $revenue;
    396         $data['max'] = 50000;
     409        $data['max'] = $max;
    397410        $chard[] = array("color" => "#e67e22", "label" => "Tháng hiện tại", "data" => $chart_this_month);
    398411        $chard[] = array("color" => "#1abc9c", "label" => "Tháng trước", "data" => $chart_last_month);
    399 
     412         
    400413        $data['chard'] = $chard;
     414       
    401415        return $data;
    402416    }
  • pro-violet-viettel/sourcecode/application/modules/admin/models/paidlog_model.php

    r740 r741  
    7676            $result[$index]['time']=  strtotime($paidlog['paid_time']);
    7777        }
    78         $file = fopen("/srv/www/sbg/log/dump.log","w");
    79         fwrite($file,  serialize($result));
    80         fclose($file);
     78         
    8179        return $result;
    8280    }
Note: See TracChangeset for help on using the changeset viewer.