public function actionIndex() { $rate = new Rate(); $currency = new Currency(); $billing = ArrayHelper::map(Billing::find()->asArray()->all(), 'id', 'name'); return $this->render('index', ['rate' => $rate, 'billing' => $billing, 'currency' => $currency]); }
/** * Метод, возвращающий сумму платежей по заданым агенству и периоду * @param string $id int Номер ID агенста в БД * @param $startDate string Начальная дата запрашиваемого периода * @param $endDate string Конечная дата запрашиваемого периода * @return mixed Сумма платежей по агенству */ public function getTotal($id = '', $startDate, $endDate) { if ($id != '') { return Billing::find()->andWhere(['agency_id' => $id])->andWhere(['between', 'date', $startDate, $endDate])->sum('amount'); } return Billing::find()->andWhere(['between', 'date', $startDate, $endDate])->sum('amount'); }
/** * Updates an existing Currency model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { $billing_id = ArrayHelper::map(Billing::find()->asArray()->all(), 'id', 'name'); return $this->render('update', ['model' => $model, 'billing_id' => $billing_id]); } }
/** * Экшн для второго задания * @return string */ public function actionSecondTask() { $dateRange = []; $filesModel = new UploadFiles(); if (\Yii::$app->request->isPost) { $filesModel->dbFiles = UploadedFile::getInstances($filesModel, 'dbFiles'); $filesModel->upload(); new Second($filesModel->dbFiles); } array_push($dateRange, $startDate = Billing::find()->min('date')); array_push($dateRange, $endDate = Billing::find()->max('date')); $model = Agency::find()->all(); $marker = $model != null ? 1 : 0; return $this->render('second', ['uploadFiles' => $filesModel, 'dateRange' => $dateRange, 'marker' => $marker]); }
/** * Lists all Billing models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Billing::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }