Esempio n. 1
0
 /**
  * Lists all Estate models.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new EstateSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $user = User::findOne(Yii::$app->user->id);
     $isManager = LinkManager::isAccessible($user->id);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'user' => $user, 'isManager' => $isManager]);
 }
Esempio n. 2
0
 /**
  * Generate record list for Communal Service manager
  *
  * @return string
  * @throws ForbiddenHttpException
  */
 public function actionGetRecords()
 {
     $currentUserId = Yii::$app->user->id;
     $comService = LinkManager::findByUserId($currentUserId);
     if (LinkManager::isAccessible($currentUserId)) {
         if ($post = Yii::$app->request->post()) {
             if (isset($post["get-list"]) && isset($post["get-format"])) {
                 if ($post["get-list"] == 'month') {
                     $model = Record::find()->where(['comservice_id' => $comService->id])->andWhere(['>=', 'created_at', time() - 2678400])->all();
                 } elseif ($post["get-list"] == 'interval' && isset($post["from_date"]) && isset($post["to_date"])) {
                     $from_date = strtotime($post["from_date"]);
                     $to_date = strtotime($post["to_date"]);
                     $model = Record::find()->where(['comservice_id' => $comService->id])->andWhere(['>=', 'created_at', $from_date])->andWhere(['<=', 'created_at', $to_date])->all();
                 } else {
                     $model = Record::find()->where(['comservice_id' => $comService->id])->andWhere(['status' => Record::STATUS_NEW])->all();
                 }
                 return $this->renderPartial('get-records-list', ['model' => $model, 'format' => $post["get-format"]]);
             }
         }
         return $this->render('get-records', ['comService' => $comService]);
     } else {
         throw new ForbiddenHttpException(Yii::t('app', 'ERROR_FORBIDDEN'));
     }
 }