From 3da2dd154359498c0623639f11d871a1df1f143e Mon Sep 17 00:00:00 2001 From: akosse Date: Wed, 5 Feb 2020 12:08:01 +0300 Subject: [PATCH] reports --- backend/config/main.php | 5 +- backend/modules/reports/Reports.php | 24 +++ .../reports/controllers/DefaultController.php | 20 +++ .../reports/controllers/ReportsController.php | 140 ++++++++++++++++++ .../modules/reports/models/ReportsSearch.php | 75 ++++++++++ .../modules/reports/views/default/index.php | 12 ++ .../views/reports/_expand-row-details.php | 19 +++ .../modules/reports/views/reports/_form.php | 43 ++++++ .../modules/reports/views/reports/_search.php | 37 +++++ .../modules/reports/views/reports/create.php | 18 +++ .../modules/reports/views/reports/group.php | 52 +++++++ .../modules/reports/views/reports/index.php | 42 ++++++ .../modules/reports/views/reports/update.php | 19 +++ .../modules/reports/views/reports/view.php | 44 ++++++ backend/views/layouts/left.php | 1 + backend/web/css/site.css | 4 + common/models/Reports.php | 72 +++++++++ .../m200204_125649_create_reports_table.php | 51 +++++++ frontend/config/main.php | 3 + frontend/modules/access/models/Access.php | 2 - frontend/modules/reports/Reports.php | 24 +++ .../reports/controllers/DefaultController.php | 20 +++ .../reports/controllers/ReportsController.php | 134 +++++++++++++++++ frontend/modules/reports/models/Reports.php | 32 ++++ .../modules/reports/models/ReportsSearch.php | 73 +++++++++ .../modules/reports/views/default/index.php | 12 ++ .../modules/reports/views/reports/_form.php | 38 +++++ .../modules/reports/views/reports/_search.php | 39 +++++ .../modules/reports/views/reports/create.php | 18 +++ .../modules/reports/views/reports/index.php | 38 +++++ .../modules/reports/views/reports/update.php | 19 +++ .../modules/reports/views/reports/view.php | 41 +++++ frontend/views/layouts/main.php | 1 + frontend/web/css/site.css | 4 + 34 files changed, 1173 insertions(+), 3 deletions(-) create mode 100644 backend/modules/reports/Reports.php create mode 100644 backend/modules/reports/controllers/DefaultController.php create mode 100644 backend/modules/reports/controllers/ReportsController.php create mode 100644 backend/modules/reports/models/ReportsSearch.php create mode 100644 backend/modules/reports/views/default/index.php create mode 100644 backend/modules/reports/views/reports/_expand-row-details.php create mode 100644 backend/modules/reports/views/reports/_form.php create mode 100644 backend/modules/reports/views/reports/_search.php create mode 100644 backend/modules/reports/views/reports/create.php create mode 100644 backend/modules/reports/views/reports/group.php create mode 100644 backend/modules/reports/views/reports/index.php create mode 100644 backend/modules/reports/views/reports/update.php create mode 100644 backend/modules/reports/views/reports/view.php create mode 100644 common/models/Reports.php create mode 100644 console/migrations/m200204_125649_create_reports_table.php create mode 100644 frontend/modules/reports/Reports.php create mode 100644 frontend/modules/reports/controllers/DefaultController.php create mode 100644 frontend/modules/reports/controllers/ReportsController.php create mode 100644 frontend/modules/reports/models/Reports.php create mode 100644 frontend/modules/reports/models/ReportsSearch.php create mode 100644 frontend/modules/reports/views/default/index.php create mode 100644 frontend/modules/reports/views/reports/_form.php create mode 100644 frontend/modules/reports/views/reports/_search.php create mode 100644 frontend/modules/reports/views/reports/create.php create mode 100644 frontend/modules/reports/views/reports/index.php create mode 100644 frontend/modules/reports/views/reports/update.php create mode 100644 frontend/modules/reports/views/reports/view.php diff --git a/backend/config/main.php b/backend/config/main.php index 9325812..6a5dcb7 100755 --- a/backend/config/main.php +++ b/backend/config/main.php @@ -46,7 +46,10 @@ return [ ], 'gridview' => [ 'class' => 'kartik\grid\Module', - ] + ], + 'reports' => [ + 'class' => 'backend\modules\reports\Reports', + ], ], 'components' => [ 'request' => [ diff --git a/backend/modules/reports/Reports.php b/backend/modules/reports/Reports.php new file mode 100644 index 0000000..52d1ca8 --- /dev/null +++ b/backend/modules/reports/Reports.php @@ -0,0 +1,24 @@ +render('index'); + } +} diff --git a/backend/modules/reports/controllers/ReportsController.php b/backend/modules/reports/controllers/ReportsController.php new file mode 100644 index 0000000..9506afd --- /dev/null +++ b/backend/modules/reports/controllers/ReportsController.php @@ -0,0 +1,140 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Reports models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ReportsSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + public function actionGroup() + { + $searchModel = new UserCardSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + $dataProvider->query->innerJoin('reports', 'user_card.id = reports.user_card_id'); + + return $this->render('group', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Reports model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Reports model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Reports(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Reports model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Reports model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Reports model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Reports the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Reports::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/backend/modules/reports/models/ReportsSearch.php b/backend/modules/reports/models/ReportsSearch.php new file mode 100644 index 0000000..5d80f0d --- /dev/null +++ b/backend/modules/reports/models/ReportsSearch.php @@ -0,0 +1,75 @@ +leftJoin('user_card', 'reports.user_card_id = user_card.id'); + + // add conditions that should always apply here + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'created_at' => $this->created_at, + 'user_card_id' => $this->user_card_id, + ]); + + $query->andFilterWhere(['like', 'today', $this->today]) + ->andFilterWhere(['like', 'difficulties', $this->difficulties]) + ->andFilterWhere(['like', 'tomorrow', $this->tomorrow]) + ->andFilterWhere(['like', 'user_card.fio', $this->fio]); + + return $dataProvider; + } +} diff --git a/backend/modules/reports/views/default/index.php b/backend/modules/reports/views/default/index.php new file mode 100644 index 0000000..1b8dd38 --- /dev/null +++ b/backend/modules/reports/views/default/index.php @@ -0,0 +1,12 @@ +
+

context->action->uniqueId ?>

+

+ This is the view content for action "context->action->id ?>". + The action belongs to the controller "context) ?>" + in the "context->module->id ?>" module. +

+

+ You may customize this page by editing the following file:
+ +

+
diff --git a/backend/modules/reports/views/reports/_expand-row-details.php b/backend/modules/reports/views/reports/_expand-row-details.php new file mode 100644 index 0000000..b521a67 --- /dev/null +++ b/backend/modules/reports/views/reports/_expand-row-details.php @@ -0,0 +1,19 @@ + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'created_at', + 'today', + 'difficulties', + 'tomorrow', + + ['class' => 'yii\grid\ActionColumn'], + ] +]); \ No newline at end of file diff --git a/backend/modules/reports/views/reports/_form.php b/backend/modules/reports/views/reports/_form.php new file mode 100644 index 0000000..46e3974 --- /dev/null +++ b/backend/modules/reports/views/reports/_form.php @@ -0,0 +1,43 @@ + + +
+ + + + field($model, 'created_at')->input( + 'date', + [ + 'placeholder' => 'Zadejte svůj Datum narození', + 'language' => 'en', + "data-format" => "DD MMMM YYYY", + 'class' => 'form-control report-date' + + ] + ) ?> + + field($model, 'today')->textarea(['maxlength' => true]) ?> + + field($model, 'difficulties')->textarea(['maxlength' => true]) ?> + + field($model, 'tomorrow')->textarea(['maxlength' => true]) ?> + + field($model, 'user_card_id')->dropDownList( + \yii\helpers\ArrayHelper::map(common\models\UserCard::find()->all(), 'id', 'fio'), + ['prompt' => '...'] + ) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/backend/modules/reports/views/reports/_search.php b/backend/modules/reports/views/reports/_search.php new file mode 100644 index 0000000..c24983d --- /dev/null +++ b/backend/modules/reports/views/reports/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/modules/reports/views/reports/create.php b/backend/modules/reports/views/reports/create.php new file mode 100644 index 0000000..4e8dd88 --- /dev/null +++ b/backend/modules/reports/views/reports/create.php @@ -0,0 +1,18 @@ +title = 'Добавить отчет'; +$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/reports/views/reports/group.php b/backend/modules/reports/views/reports/group.php new file mode 100644 index 0000000..7ca5723 --- /dev/null +++ b/backend/modules/reports/views/reports/group.php @@ -0,0 +1,52 @@ +title = 'Доступы'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

+ 'btn btn-success']) ?> + 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'pjax' => true, + 'striped' => true, + 'hover' => true, + 'toggleDataContainer' => ['class' => 'btn-group mr-2'], + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + [ + 'class' => 'kartik\grid\ExpandRowColumn', + 'width' => '50px', + 'value' => function ($model, $key, $index, $column) { + return GridView::ROW_COLLAPSED; + }, + 'detail' => function ($model, $key, $index, $column) { + $searchReports = new ReportsSearch(); + $providerReports = $searchReports->search(Yii::$app->request->queryParams); + $providerReports->query->andWhere(['user_card.id_user' => $model->id_user]); + + return Yii::$app->controller->renderPartial('_expand-row-details', ['dataProvider' => $providerReports]); + }, + 'headerOptions' => ['class' => 'kartik-sheet-style'], + 'expandOneOnly' => true + ], + 'fio', + 'email' + ], + ]); + ?> +
diff --git a/backend/modules/reports/views/reports/index.php b/backend/modules/reports/views/reports/index.php new file mode 100644 index 0000000..e83b4d2 --- /dev/null +++ b/backend/modules/reports/views/reports/index.php @@ -0,0 +1,42 @@ +title = 'Отчеты'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> + 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'created_at', + 'today', + 'difficulties', + 'tomorrow', + [ + 'format' => 'raw', + 'attribute' => 'ФИО', + 'filter' => Html::activeTextInput($searchModel, 'fio', ['class' => 'form-control']), + 'value' => function ($data) { return \common\models\Reports::getFio($data); }, + ], + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/backend/modules/reports/views/reports/update.php b/backend/modules/reports/views/reports/update.php new file mode 100644 index 0000000..d9dd599 --- /dev/null +++ b/backend/modules/reports/views/reports/update.php @@ -0,0 +1,19 @@ +title = 'Редактировать отчет'; +$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Редактировать'; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/modules/reports/views/reports/view.php b/backend/modules/reports/views/reports/view.php new file mode 100644 index 0000000..8ea2ce2 --- /dev/null +++ b/backend/modules/reports/views/reports/view.php @@ -0,0 +1,44 @@ +title = 'Отчет'; +$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Вы уверенны, что хотите удалить этот элемент?', + 'method' => 'post', + ], + ]) ?> + $model->id], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ +// 'id', + 'created_at', + 'today', + 'difficulties', + 'tomorrow', +// 'user_card_id', + [ + 'format' => 'raw', + 'attribute' => 'ФИО', + 'value' => function ($data) { return \common\models\Reports::getFio($data); }, + ], + ], + ]) ?> + +
diff --git a/backend/views/layouts/left.php b/backend/views/layouts/left.php index 9a4d4f9..d14669e 100755 --- a/backend/views/layouts/left.php +++ b/backend/views/layouts/left.php @@ -48,6 +48,7 @@ ['label' => 'Доступы', 'icon' => 'key', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'], ['label' => 'Заметки', 'icon' => 'sticky-note', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes'], ['label' => 'Календарь ДР', 'icon' => 'calendar', 'url' => ['/calendar/calendar'], 'active' => \Yii::$app->controller->id == 'calendar'], + ['label' => 'Отчеты', 'icon' => 'list-alt', 'url' => ['/reports/reports'], 'active' => \Yii::$app->controller->id == 'reports'], /*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']], ['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']], diff --git a/backend/web/css/site.css b/backend/web/css/site.css index b319bb6..db97cf9 100755 --- a/backend/web/css/site.css +++ b/backend/web/css/site.css @@ -35,4 +35,8 @@ .field-usercard-fields-0-value .itemImg { width: 100% !important; +} + +.report-date { + width: 155px; } \ No newline at end of file diff --git a/common/models/Reports.php b/common/models/Reports.php new file mode 100644 index 0000000..f5d2bb5 --- /dev/null +++ b/common/models/Reports.php @@ -0,0 +1,72 @@ + 255], + [['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']], + ]; + } + + /** + * {@inheritdoc} + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'created_at' => 'Дата заполнения отчета', + 'today' => 'Что было сделано сегодня?', + 'difficulties' => 'Какие сложности возникли?', + 'tomorrow' => 'Что планируется сделать завтра?', + 'user_card_id' => 'Пользователь', + 'status' => 'Статус' + ]; + } + + /** + * @return \yii\db\ActiveQuery + */ + public function getUserCard() + { + return $this->hasOne(UserCard::className(), ['id' => 'user_card_id']); + } + + public static function getFio($data) + { + $user_card = UserCard::findOne(['id' => $data->user_card_id]); + return $user_card->fio; + } +} diff --git a/console/migrations/m200204_125649_create_reports_table.php b/console/migrations/m200204_125649_create_reports_table.php new file mode 100644 index 0000000..9df03e3 --- /dev/null +++ b/console/migrations/m200204_125649_create_reports_table.php @@ -0,0 +1,51 @@ +createTable('{{%reports}}', [ + 'id' => $this->primaryKey(), + 'created_at' => $this->date()->notNull(), + 'today' => $this->string()->notNull(), + 'difficulties' => $this->string(), + 'tomorrow' => $this->string(), + 'status' => $this->integer() + ]); + + $this->addColumn('{{%reports}}', 'user_card_id', $this->integer()->notNull()); + + // creates index for column `user_card_id` + $this->createIndex( + '{{%idx-reports-user_card_id}}', + '{{%reports}}', + 'user_card_id' + ); + + // add foreign key for table `{{%user_card}}` + $this->addForeignKey( + '{{%fk-reports-user_card_id}}', + '{{%reports}}', + 'user_card_id', + '{{%user_card}}', + 'id', + 'CASCADE' + ); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropTable('{{%reports}}'); + } +} diff --git a/frontend/config/main.php b/frontend/config/main.php index 9fbadf2..7d0a06b 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -20,6 +20,9 @@ return [ 'card' => [ 'class' => 'frontend\modules\card\Card', ], + 'reports' => [ + 'class' => 'frontend\modules\reports\Reports', + ], ], 'components' => [ diff --git a/frontend/modules/access/models/Access.php b/frontend/modules/access/models/Access.php index 3ffeb0d..27d27ce 100644 --- a/frontend/modules/access/models/Access.php +++ b/frontend/modules/access/models/Access.php @@ -3,8 +3,6 @@ namespace frontend\modules\access\models; - -use common\classes\Debug; use common\models\UserCardAccesses; use frontend\modules\card\models\UserCard; use Yii; diff --git a/frontend/modules/reports/Reports.php b/frontend/modules/reports/Reports.php new file mode 100644 index 0000000..8a393a4 --- /dev/null +++ b/frontend/modules/reports/Reports.php @@ -0,0 +1,24 @@ +render('index'); + } +} diff --git a/frontend/modules/reports/controllers/ReportsController.php b/frontend/modules/reports/controllers/ReportsController.php new file mode 100644 index 0000000..f6fe4e7 --- /dev/null +++ b/frontend/modules/reports/controllers/ReportsController.php @@ -0,0 +1,134 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all Reports models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ReportsSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + $dataProvider->query + ->where(['user_card.id_user' => Yii::$app->user->identity->id]) + ->innerJoin('user_card', 'reports.user_card_id = user_card.id'); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Reports model. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Reports model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new \frontend\modules\reports\models\Reports(); + + if ($model->load(Yii::$app->request->post())) { + $model->save(); + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + /** + * Updates an existing Reports model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + /** + * Deletes an existing Reports model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException if the model cannot be found + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Reports model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Reports the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Reports::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} diff --git a/frontend/modules/reports/models/Reports.php b/frontend/modules/reports/models/Reports.php new file mode 100644 index 0000000..3bd72a2 --- /dev/null +++ b/frontend/modules/reports/models/Reports.php @@ -0,0 +1,32 @@ + Yii::$app->user->identity->id]); +// $this->user_card_id = $user_card->id; +// return parent::beforeSave($insert); +// } + + public function beforeValidate() + { + if (empty($this->user_card_id)) { + $user_card = UserCard::findOne(['id_user' => Yii::$app->user->identity->id]); + $this->user_card_id = $user_card->id; + } + return parent::beforeValidate(); + } +} \ No newline at end of file diff --git a/frontend/modules/reports/models/ReportsSearch.php b/frontend/modules/reports/models/ReportsSearch.php new file mode 100644 index 0000000..f413e49 --- /dev/null +++ b/frontend/modules/reports/models/ReportsSearch.php @@ -0,0 +1,73 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'created_at' => $this->created_at, + 'user_card_id' => $this->user_card_id, + 'status' => $this->status, + ]); + + $query->andFilterWhere(['like', 'today', $this->today]) + ->andFilterWhere(['like', 'difficulties', $this->difficulties]) + ->andFilterWhere(['like', 'tomorrow', $this->tomorrow]); + + return $dataProvider; + } +} diff --git a/frontend/modules/reports/views/default/index.php b/frontend/modules/reports/views/default/index.php new file mode 100644 index 0000000..1b8dd38 --- /dev/null +++ b/frontend/modules/reports/views/default/index.php @@ -0,0 +1,12 @@ +
+

context->action->uniqueId ?>

+

+ This is the view content for action "context->action->id ?>". + The action belongs to the controller "context) ?>" + in the "context->module->id ?>" module. +

+

+ You may customize this page by editing the following file:
+ +

+
diff --git a/frontend/modules/reports/views/reports/_form.php b/frontend/modules/reports/views/reports/_form.php new file mode 100644 index 0000000..1251dcd --- /dev/null +++ b/frontend/modules/reports/views/reports/_form.php @@ -0,0 +1,38 @@ + + +
+ + + + field($model, 'created_at')->input( + 'date', + [ + 'placeholder' => 'Zadejte svůj Datum narození', + 'language' => 'en', + "data-format" => "DD MMMM YYYY", + 'class' => 'form-control report-date' + + ] + ) ?> + + field($model, 'today')->textInput(['maxlength' => true]) ?> + + field($model, 'difficulties')->textInput(['maxlength' => true]) ?> + + field($model, 'tomorrow')->textInput(['maxlength' => true]) ?> + +
+ 'btn btn-success']) ?> +
+ + + +
diff --git a/frontend/modules/reports/views/reports/_search.php b/frontend/modules/reports/views/reports/_search.php new file mode 100644 index 0000000..b69583a --- /dev/null +++ b/frontend/modules/reports/views/reports/_search.php @@ -0,0 +1,39 @@ + + + diff --git a/frontend/modules/reports/views/reports/create.php b/frontend/modules/reports/views/reports/create.php new file mode 100644 index 0000000..2f98be9 --- /dev/null +++ b/frontend/modules/reports/views/reports/create.php @@ -0,0 +1,18 @@ +title = 'Добавить отчет'; +$this->params['breadcrumbs'][] = ['label' => 'Reports', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/modules/reports/views/reports/index.php b/frontend/modules/reports/views/reports/index.php new file mode 100644 index 0000000..41dc787 --- /dev/null +++ b/frontend/modules/reports/views/reports/index.php @@ -0,0 +1,38 @@ +title = 'Отчеты'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ + render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + +// 'id', + 'created_at', + 'today', + 'difficulties', + 'tomorrow', +// 'user_card_id', + //'status', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/frontend/modules/reports/views/reports/update.php b/frontend/modules/reports/views/reports/update.php new file mode 100644 index 0000000..d9dd599 --- /dev/null +++ b/frontend/modules/reports/views/reports/update.php @@ -0,0 +1,19 @@ +title = 'Редактировать отчет'; +$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Редактировать'; +?> +
+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/modules/reports/views/reports/view.php b/frontend/modules/reports/views/reports/view.php new file mode 100644 index 0000000..5fcc103 --- /dev/null +++ b/frontend/modules/reports/views/reports/view.php @@ -0,0 +1,41 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +\yii\web\YiiAsset::register($this); +?> +
+ +

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Вы уверенны, что хотите удалить этот отчет?', + 'method' => 'post', + ], + ]) ?> + $model->id], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ +// 'id', + 'created_at', + 'today', + 'difficulties', + 'tomorrow', +// 'user_card_id', +// 'status', + ], + ]) ?> + +
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index b5e0846..37b7d7d 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -45,6 +45,7 @@ AppAsset::register($this); $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; } else { $menuItems[] = ['label' => 'Доступы', 'url' => ['/access/access/index']]; + $menuItems[] = ['label' => 'Отчеты', 'url' => ['/reports/reports/index']]; $menuItems[] = '
  • ' . Html::beginForm(['/site/logout'], 'post') . Html::submitButton( diff --git a/frontend/web/css/site.css b/frontend/web/css/site.css index a3b38da..0729653 100755 --- a/frontend/web/css/site.css +++ b/frontend/web/css/site.css @@ -121,4 +121,8 @@ a.desc:after { .custom-input { width: 50%; +} + +.report-date { + width: 155px; } \ No newline at end of file