Example #1
0
 /**
  * Экшн для выведения отчета за выбраный период времени
  * @return string
  */
 public function actionSecondResult()
 {
     $startDate = \Yii::$app->request->post('from');
     $endDate = \Yii::$app->request->post('to');
     $dateRange = array($startDate, $endDate);
     $model = Agency::find()->with('network')->all();
     return $this->render('second-result', ['model' => $model, 'dateRange' => $dateRange]);
 }
Example #2
0
 public function actionQ2()
 {
     $rows = [];
     $process_going = file_exists(Yii::$app->basePath . '/data/2/lock');
     $cmd = Yii::$app->request->post('startload');
     if (!$process_going && $cmd !== null) {
         $cmd = "php " . Yii::$app->basePath . "/yii data/load2";
         $ret = exec($cmd, $output);
         $process_going = true;
     } else {
     }
     $rows = Agency::find()->select(['{{AgencyNetwork}}.name as networkname', '{{Agency}}.name', 'SUM({{Billing}}.amount) AS agencysum'])->joinWith(['network'])->joinWith('billings', true, 'LEFT JOIN')->groupBy('{{Agency}}.name')->all();
     $total = 0;
     foreach ($rows as $row) {
         $total += $row->agencysum;
     }
     return $this->render('q2', ['total' => $total, 'rows' => $rows, 'process_going' => $process_going, 'codefile' => __FILE__]);
 }
 /**
  * Lists all Agency models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Agency::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }