コード例 #1
0
ファイル: TestController.php プロジェクト: VitaliyMinenko/CRM
 public function actionIndex()
 {
     $model = new UserReports();
     $reports = $model->getByDate(3, '2012-01-01', '2018-01-01');
     $data = new CArrayDataProvider($reports, array('id' => 'id', 'sort' => array('attributes' => array('city', 'phone')), 'pagination' => array('pageSize' => 1)));
     $this->render('index', array('dataProvider' => $data));
 }
コード例 #2
0
 public function actionRenPart($user_id, $start, $stop)
 {
     $model = new UserReports();
     $reports = $model->getByDate($user_id, $start, $stop);
     var_dump($reports);
     die;
     if (count($reports) != 0) {
         $statisic = array('Совершено звонков' => 0, 'Проведено встречь' => 0, 'Заключено договоров' => 0, 'Иные действия' => 0, 'Особые поручения' => 0, 'Отправил mail' => 0);
         foreach ($reports as $report) {
             if ($report['action'] == 1) {
                 $statisic['Совершено звонков'] = $statisic['Совершено звонков'] + 1;
             }
             if ($report['action'] == 2) {
                 $statisic['Проведено встречь'] = $statisic['Проведено встречь'] + 1;
             }
             if ($report['action'] == 3) {
                 $statisic['Заключено договоров'] = $statisic['Заключено договоров'] + 1;
             }
             if ($report['action'] == 4) {
                 $statisic['Иные действия'] = $statisic['Иные действия'] + 1;
             }
             if ($report['action'] == 5) {
                 $statisic['Особые поручения'] = $statisic['Особые поручения'] + 1;
             }
             if ($report['action'] == 6) {
                 $statisic['Отправил mail'] = $statisic['Отправил mail'] + 1;
             }
         }
         arsort($statisic);
         $maxIs100 = max($statisic);
         $one_procent = 100 / $maxIs100;
         foreach ($statisic as $key => $sta) {
             $new_static[$key] = array($sta, ceil($one_procent * $sta));
         }
         $data = new CArrayDataProvider($reports, array('pagination' => array('pageSize' => 999)));
         $this->renderPartial('result', array('dataProvider' => $data, 'statisic' => $new_static, 'maxIs100' => $maxIs100), FALSE, true);
     } else {
         $this->renderPartial('ss');
     }
 }