Пример #1
1
 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]);
 }
Пример #2
0
 /**
  * Метод, возвращающий сумму платежей по заданым агенству и периоду
  * @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]);
     }
 }
Пример #4
0
 /**
  * Экшн для второго задания
  * @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]);
 }
Пример #5
0
 public static function getPastAccom()
 {
     if (Auth::check()) {
         return \View::make('layouts.default')->with('title', 'Past Accomodations')->with('guests', \App\Models\Billing::showPastAccom());
     } else {
         return Redirect::route('home')->with('message', 'You are not logged in!');
     }
 }
Пример #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBilling()
 {
     return $this->hasOne(Billing::className(), ['id' => 'billing_id']);
 }
 /**
  * Finds the Billing model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Billing the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Billing::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBillings()
 {
     return $this->hasMany(Billing::className(), ['agency_id' => 'id']);
 }