From 6d37a8ef18cca9fcf81d008988ffbd1db83cffc8 Mon Sep 17 00:00:00 2001 From: akosse Date: Wed, 5 Feb 2020 16:28:37 +0300 Subject: [PATCH] report fix --- .../modules/reports/models/ReportsSearch.php | 5 ++ .../views/reports/_expand-row-details.php | 2 + .../modules/reports/views/reports/_form.php | 29 ++++++--- .../modules/reports/views/reports/group.php | 2 + .../modules/reports/views/reports/update.php | 4 +- .../modules/reports/views/reports/view.php | 2 +- composer.json | 3 +- composer.lock | 63 +++++++++++++++++-- .../modules/reports/models/ReportsSearch.php | 5 ++ .../modules/reports/views/reports/_form.php | 33 ++++++---- .../modules/reports/views/reports/index.php | 24 +++++-- .../modules/reports/views/reports/update.php | 2 +- .../modules/reports/views/reports/view.php | 2 +- frontend/web/css/site.css | 4 ++ 14 files changed, 144 insertions(+), 36 deletions(-) diff --git a/backend/modules/reports/models/ReportsSearch.php b/backend/modules/reports/models/ReportsSearch.php index 5d80f0d..edd2311 100644 --- a/backend/modules/reports/models/ReportsSearch.php +++ b/backend/modules/reports/models/ReportsSearch.php @@ -48,6 +48,11 @@ class ReportsSearch extends Reports $dataProvider = new ActiveDataProvider([ 'query' => $query, + 'sort' => [ + 'defaultOrder' => [ + 'created_at' => SORT_DESC, + ] + ], ]); $this->load($params); diff --git a/backend/modules/reports/views/reports/_expand-row-details.php b/backend/modules/reports/views/reports/_expand-row-details.php index b521a67..91df521 100644 --- a/backend/modules/reports/views/reports/_expand-row-details.php +++ b/backend/modules/reports/views/reports/_expand-row-details.php @@ -3,9 +3,11 @@ use yii\grid\GridView; /* @var $dataProvider yii\data\ActiveDataProvider */ +/* @var $pages */ echo GridView::widget([ 'dataProvider' => $dataProvider, + 'columns' => [ ['class' => 'yii\grid\SerialColumn'], diff --git a/backend/modules/reports/views/reports/_form.php b/backend/modules/reports/views/reports/_form.php index 46e3974..59aa5fb 100644 --- a/backend/modules/reports/views/reports/_form.php +++ b/backend/modules/reports/views/reports/_form.php @@ -1,5 +1,7 @@ - + field($model, 'created_at')->input( - 'date', - [ - 'placeholder' => 'Zadejte svůj Datum narození', - 'language' => 'en', - "data-format" => "DD MMMM YYYY", - 'class' => 'form-control report-date' + $now = time(); + $day = idate('d', $now); + $month = idate('m', $now); + $year = idate('Y', $now); + $date = $year."-".$month."-".$day; + if(!$model->created_at) + $model->created_at = $date; + echo 'Дата заполнения отчета:'; + echo DatePicker::widget([ + 'model' => $model, + 'attribute' => 'created_at', + 'options' => [], + 'pluginOptions' => [ + 'autoclose' => true, + 'format' => 'yyyy-mm-dd' ] - ) ?> + ]).'
'; + ?> field($model, 'today')->textarea(['maxlength' => true]) ?> diff --git a/backend/modules/reports/views/reports/group.php b/backend/modules/reports/views/reports/group.php index 7ca5723..d566e14 100644 --- a/backend/modules/reports/views/reports/group.php +++ b/backend/modules/reports/views/reports/group.php @@ -2,6 +2,7 @@ use backend\modules\reports\models\ReportsSearch; use kartik\grid\GridView; +use yii\data\Pagination; use yii\helpers\Html; /* @var $this yii\web\View */ @@ -38,6 +39,7 @@ $this->params['breadcrumbs'][] = $this->title; $searchReports = new ReportsSearch(); $providerReports = $searchReports->search(Yii::$app->request->queryParams); $providerReports->query->andWhere(['user_card.id_user' => $model->id_user]); + $providerReports->pagination->pageSize = 10; return Yii::$app->controller->renderPartial('_expand-row-details', ['dataProvider' => $providerReports]); }, diff --git a/backend/modules/reports/views/reports/update.php b/backend/modules/reports/views/reports/update.php index d9dd599..5451d1f 100644 --- a/backend/modules/reports/views/reports/update.php +++ b/backend/modules/reports/views/reports/update.php @@ -5,9 +5,9 @@ use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model common\models\Reports */ -$this->title = 'Редактировать отчет'; +$this->title = 'Редактировать отчет ' . $model->created_at; $this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = ['label' => $model->created_at, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Редактировать'; ?>
diff --git a/backend/modules/reports/views/reports/view.php b/backend/modules/reports/views/reports/view.php index 8ea2ce2..e5b4741 100644 --- a/backend/modules/reports/views/reports/view.php +++ b/backend/modules/reports/views/reports/view.php @@ -6,7 +6,7 @@ use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model common\models\Reports */ -$this->title = 'Отчет'; +$this->title = $model->created_at; $this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); diff --git a/composer.json b/composer.json index 3c53bb1..9f87c1f 100755 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "mirocow/yii2-eav": "*", "kartik-v/yii2-widget-fileinput": "^1.0", "2amigos/yii2-file-upload-widget": "~1.0", - "kartik-v/yii2-grid": "dev-master" + "kartik-v/yii2-grid": "dev-master", + "kartik-v/yii2-widget-datetimepicker": "dev-master" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", diff --git a/composer.lock b/composer.lock index 6ac7c64..34633b5 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "27fb15c02f7c345930818f5f2b532cf8", + "content-hash": "fa1395e986b21ee60c85db006a32bcc9", "packages": [ { "name": "2amigos/yii2-file-upload-widget", @@ -257,7 +257,7 @@ "version": "v3.4.1", "source": { "type": "git", - "url": "git@github.com:twbs/bootstrap.git", + "url": "https://github.com/twbs/bootstrap.git", "reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e" }, "dist": { @@ -317,7 +317,7 @@ "version": "1.12.1", "source": { "type": "git", - "url": "https://github.com/components/jqueryui.git", + "url": "git@github.com:components/jqueryui.git", "reference": "44ecf3794cc56b65954cc19737234a3119d036cc" }, "dist": { @@ -1049,6 +1049,60 @@ ], "time": "2019-08-23T17:23:20+00:00" }, + { + "name": "kartik-v/yii2-widget-datetimepicker", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/kartik-v/yii2-widget-datetimepicker.git", + "reference": "c201f98d3b8e41dcce2c70678ae31008246fc430" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-datetimepicker/zipball/c201f98d3b8e41dcce2c70678ae31008246fc430", + "reference": "c201f98d3b8e41dcce2c70678ae31008246fc430", + "shasum": "" + }, + "require": { + "kartik-v/yii2-krajee-base": ">=2.0.0" + }, + "type": "yii2-extension", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "kartik\\datetime\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kartik Visweswaran", + "email": "kartikv2@gmail.com", + "homepage": "http://www.krajee.com/" + } + ], + "description": "Enhanced Yii2 wrapper for the bootstrap datetimepicker plugin (sub repo split from yii2-widgets)", + "homepage": "https://github.com/kartik-v/yii2-widget-datetimepicker", + "keywords": [ + "datetime", + "extension", + "form", + "jquery", + "picker", + "plugin", + "select2", + "widget", + "yii2" + ], + "time": "2019-12-16T09:37:15+00:00" + }, { "name": "kartik-v/yii2-widget-fileinput", "version": "v1.0.9", @@ -4945,7 +4999,8 @@ "kartik-v/yii2-widget-select2": 20, "kavalar/hhapi": 20, "kartik-v/yii2-widget-datepicker": 20, - "kartik-v/yii2-grid": 20 + "kartik-v/yii2-grid": 20, + "kartik-v/yii2-widget-datetimepicker": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/frontend/modules/reports/models/ReportsSearch.php b/frontend/modules/reports/models/ReportsSearch.php index f413e49..c8af36e 100644 --- a/frontend/modules/reports/models/ReportsSearch.php +++ b/frontend/modules/reports/models/ReportsSearch.php @@ -46,6 +46,11 @@ class ReportsSearch extends Reports $dataProvider = new ActiveDataProvider([ 'query' => $query, + 'sort' => [ + 'defaultOrder' => [ + 'created_at' => SORT_DESC, + ] + ], ]); $this->load($params); diff --git a/frontend/modules/reports/views/reports/_form.php b/frontend/modules/reports/views/reports/_form.php index 1251dcd..d274c8b 100644 --- a/frontend/modules/reports/views/reports/_form.php +++ b/frontend/modules/reports/views/reports/_form.php @@ -1,5 +1,6 @@ - field($model, 'created_at')->input( - 'date', - [ - 'placeholder' => 'Zadejte svůj Datum narození', - 'language' => 'en', - "data-format" => "DD MMMM YYYY", - 'class' => 'form-control report-date' + created_at) + $model->created_at = $date; + echo 'Дата заполнения отчета:'; + echo DatePicker::widget([ + 'model' => $model, + 'attribute' => 'created_at', + 'options' => [], + 'pluginOptions' => [ + 'autoclose' => true, + 'format' => 'yyyy-mm-dd' ] - ) ?> + ]).'
'; + ?> - field($model, 'today')->textInput(['maxlength' => true]) ?> + field($model, 'today')->textarea(['maxlength' => true]) ?> - field($model, 'difficulties')->textInput(['maxlength' => true]) ?> + field($model, 'difficulties')->textarea(['maxlength' => true]) ?> - field($model, 'tomorrow')->textInput(['maxlength' => true]) ?> + field($model, 'tomorrow')->textarea(['maxlength' => true]) ?>
'btn btn-success']) ?> diff --git a/frontend/modules/reports/views/reports/index.php b/frontend/modules/reports/views/reports/index.php index 41dc787..0d2cbf3 100644 --- a/frontend/modules/reports/views/reports/index.php +++ b/frontend/modules/reports/views/reports/index.php @@ -24,13 +24,25 @@ $this->params['breadcrumbs'][] = $this->title; 'columns' => [ ['class' => 'yii\grid\SerialColumn'], -// 'id', 'created_at', - 'today', - 'difficulties', - 'tomorrow', -// 'user_card_id', - //'status', + [ + 'format' => 'raw', + 'attribute' => 'Что было сделано сегодня?', + 'filter' => Html::activeTextInput($searchModel, 'today', ['class' => 'form-control']), + 'value' => function ($data) { return '
'.$data->today.'
'; }, + ], + [ + 'format' => 'raw', + 'attribute' => 'Какие сложности возникли?', + 'filter' => Html::activeTextInput($searchModel, 'difficulties', ['class' => 'form-control']), + 'value' => function ($data) { return '
'.$data->difficulties.'
'; }, + ], + [ + 'format' => 'raw', + 'attribute' => 'Что планируется сделать завтра?', + 'filter' => Html::activeTextInput($searchModel, 'tomorrow', ['class' => 'form-control']), + 'value' => function ($data) { return '
'.$data->tomorrow.'
'; }, + ], ['class' => 'yii\grid\ActionColumn'], ], diff --git a/frontend/modules/reports/views/reports/update.php b/frontend/modules/reports/views/reports/update.php index d9dd599..12761ab 100644 --- a/frontend/modules/reports/views/reports/update.php +++ b/frontend/modules/reports/views/reports/update.php @@ -7,7 +7,7 @@ use yii\helpers\Html; $this->title = 'Редактировать отчет'; $this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = ['label' => $model->created_at, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Редактировать'; ?>
diff --git a/frontend/modules/reports/views/reports/view.php b/frontend/modules/reports/views/reports/view.php index 5fcc103..ba16aec 100644 --- a/frontend/modules/reports/views/reports/view.php +++ b/frontend/modules/reports/views/reports/view.php @@ -6,7 +6,7 @@ use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model common\models\Reports */ -$this->title = $model->id; +$this->title = $model->created_at; $this->params['breadcrumbs'][] = ['label' => 'Отчеты', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; \yii\web\YiiAsset::register($this); diff --git a/frontend/web/css/site.css b/frontend/web/css/site.css index 0729653..3e7ce2e 100755 --- a/frontend/web/css/site.css +++ b/frontend/web/css/site.css @@ -125,4 +125,8 @@ a.desc:after { .report-date { width: 155px; +} + +.custom-text { + white-space: normal; } \ No newline at end of file