From 0c29d4f4d5fa988eaaeed657e43eef491b6d00d7 Mon Sep 17 00:00:00 2001 From: maxim Date: Wed, 8 Sep 2021 14:39:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3,=20=D0=B4=D0=B5=D0=B1=D0=B0=D0=B3=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BB=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D1=8F,=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20=D0=BD=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D0=B4,=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=BD=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/assets/AppAsset.php | 1 + .../reports/controllers/AjaxController.php | 28 +- .../reports/controllers/ReportsController.php | 42 +- backend/modules/reports/models/Month.php | 7 +- .../modules/reports/models/ReportsSearch.php | 6 +- .../modules/reports/views/reports/index.php | 122 +-- .../modules/reports/views/reports/user.php | 853 +++++------------- backend/web/css/calendar.css | 380 ++++++++ 8 files changed, 692 insertions(+), 747 deletions(-) create mode 100644 backend/web/css/calendar.css diff --git a/backend/assets/AppAsset.php b/backend/assets/AppAsset.php index 21e4b4b..723d1d2 100755 --- a/backend/assets/AppAsset.php +++ b/backend/assets/AppAsset.php @@ -13,6 +13,7 @@ class AppAsset extends AssetBundle public $baseUrl = '@web'; public $css = [ 'css/site.css', + 'https://pro.fontawesome.com/releases/v5.10.0/css/all.css', ]; public $js = [ 'js/site.js', diff --git a/backend/modules/reports/controllers/AjaxController.php b/backend/modules/reports/controllers/AjaxController.php index 8941ba1..3971529 100644 --- a/backend/modules/reports/controllers/AjaxController.php +++ b/backend/modules/reports/controllers/AjaxController.php @@ -12,35 +12,23 @@ use yii\web\Response; class AjaxController extends \yii\web\Controller { - public function actionGetReportsForMonthByIdYearMonth($id, $year=null, $month=null){ - if (!($year and $month)){ - $searchModel->month = date('m'); - $searchModel->year = date('Y'); - Debug::prn('Неверный год или месяц'); - } - + public function actionGetReportsForMonthByIdYearMonth($user_id, $year, $month){ $searchModel = new ReportsSearch(); - $searchModel->id = $id; - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $reports = $dataProvider->getModels(); - $reports_no_task = array_column($reports, 'attributes'); - for ($i = 0; $itask, 'attributes'); + $reports_array = array_column($reports, 'attributes'); + foreach ($reports as $i => $report){ + $reports_array[$i]['today'] = array_column($report->task, 'attributes'); } - $reports = $reports_no_task; - - $month = new Month($year.'-'.$month.'-01'); - $response = Yii::$app->response; - $response->format = Response::FORMAT_JSON; - - $response->content = json_encode(array_merge(['reports' => $reports_no_task], - ['month'=>(array)$month])); $response->getHeaders()->set('Content-Type', 'application/json; charset=utf-8'); + $response->content = json_encode(array_merge( + ['reports' => $reports_array], + ['month' => (array)new Month($year.'-'.$month.'-01')]) + ); return $response; } diff --git a/backend/modules/reports/controllers/ReportsController.php b/backend/modules/reports/controllers/ReportsController.php index 5a78b61..5f11f35 100644 --- a/backend/modules/reports/controllers/ReportsController.php +++ b/backend/modules/reports/controllers/ReportsController.php @@ -3,7 +3,6 @@ namespace backend\modules\reports\controllers; use backend\modules\card\models\UserCardSearch; -use backend\modules\reports\models\Month; use Yii; use common\models\Reports; use backend\modules\reports\models\ReportsSearch; @@ -49,53 +48,29 @@ class ReportsController extends Controller public function actionIndex() { $searchModel = new ReportsSearch(); - $reports = $searchModel->search([])->getModels(); - $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - $user_id__fio = []; - for ($i=0; $iuser_card_id] = \common\models\Reports::getFio($reports[$i]); - } + foreach ($searchModel->search([])->getModels() as $model) + $user_id__fio[$model->user_card_id] = \common\models\Reports::getFio($model); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'user_id__fio' => $user_id__fio, - ]); } - public function actionUser($id, $date = null) + public function actionUser($user_id) { - if (!(isset($date) and preg_match("/^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/", $date))) { - $date = date('Y-m-01'); - } - $date = date('Y-m-01', strtotime($date)); - $searchModel = new ReportsSearch(); - $searchModel->id = $id; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - $reports = $dataProvider->getModels(); + return $this->render('user', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); - $ID = $reports[0]->user_card_id; - - $reports_no_task = array_column($reports, 'attributes'); - for ($i = 0; $i < count($reports); $i++) { - $reports_no_task[$i]['today'] = array_column($reports[$i]->task, 'attributes'); - } - $month = new Month($date); - - if (!Yii::$app->request->isAjax) { - return $this->render('user', [ - 'ID' => $ID, - 'reports' => $reports, - 'reports_month' => json_encode(array_merge(['reports' => $reports_no_task], - ['month' => (array)$month])), - 'date' => $date - ]); - } } public function actionGroup() @@ -107,7 +82,6 @@ class ReportsController extends Controller return $this->render('group', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, - ]); } diff --git a/backend/modules/reports/models/Month.php b/backend/modules/reports/models/Month.php index 3dd02a8..bd84fbe 100644 --- a/backend/modules/reports/models/Month.php +++ b/backend/modules/reports/models/Month.php @@ -2,10 +2,6 @@ namespace backend\modules\reports\models; -use common\classes\Debug; -use yii\base\Model; -use function GuzzleHttp\Psr7\str; - class Month { @@ -18,10 +14,9 @@ class Month { $this->inactive_begin = []; $this->inactive_end = []; - if (!$date and !self::is_date($date)) { + if ( !($date and self::is_date($date)) ){ $date = date('Y-m-d'); } - $first_day_of_week = self::get_day_week(self::get_first_day($date)); $quantity_days = self::get_days_month($date); diff --git a/backend/modules/reports/models/ReportsSearch.php b/backend/modules/reports/models/ReportsSearch.php index 1c5a158..47f18c8 100644 --- a/backend/modules/reports/models/ReportsSearch.php +++ b/backend/modules/reports/models/ReportsSearch.php @@ -59,7 +59,9 @@ class ReportsSearch extends Reports $this->load($params); - + if (isset($params['user_id'])) { + $this->user_card_id = $params['user_id']; + } if (isset($params['year'])) { $query->andFilterWhere(['=', 'YEAR(reports.created_at)', $params['year']]); } @@ -79,7 +81,7 @@ class ReportsSearch extends Reports $query->andFilterWhere([ - 'user_card.id' => $this->id, + 'reports.id' => $this->id, 'reports.created_at' => $this->created_at, 'user_card_id' => $this->user_card_id, ]); diff --git a/backend/modules/reports/views/reports/index.php b/backend/modules/reports/views/reports/index.php index d954271..68156b5 100644 --- a/backend/modules/reports/views/reports/index.php +++ b/backend/modules/reports/views/reports/index.php @@ -1,8 +1,10 @@ title = 'Отчеты'; $this->params['breadcrumbs'][] = $this->title; +$this->registerCss(' +.date_sort { +display: inline-flex; +} +.row * { + margin-right: 10px; +} +'); define('TODAY', date('Y-m-d')); define('WEEK_AGO', date('Y-m-d', time() - 3600 * 24 * 7)); @@ -19,81 +29,63 @@ function next_day($date, $number) { return date('Y-m-d', strtotime($date) + 3600 * 24 * $number); } - ?> -
-

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

-

- request->url . '?ReportsSearch[created_at]='; - } else { - $url = '../..' . Yii::$app->request->url . '&ReportsSearch[created_at]='; - } - for ($date = TODAY; - $date != WEEK_AGO; - $date = next_day($date, -1)): ?> + - $date], ['class' => 'btn btn-primary']) ?> -

-
-
- - field($searchModel, 'today')->hiddenInput()->label(false) ?> - -
- - - - - - '; - } - ?> - + - 'form-control', - 'style' => 'display:', - 'id' => 'date' + + $date], ['class' => 'btn btn-primary']) ?> - ]) ?> + + + + 'row'])?> + 'col-xs-6'])?> + 'get', 'options' => ['class' => 'date_sort'] ])?> + attributes )as $attribute): ?> + + user_card_id):?> + user_card_id as $i => $id):?> + field($searchModel, 'user_card_id['.$i.']')->hiddenInput()->label(false)?> + + + + + + created_at ? $searchModel->created_at : date('Y-m-d'), + ['class' => 'form-control']) ?> - 'btn btn-danger sort_by_date', 'type' => 'submit']) ?> + 'btn btn-danger']) ?> + 'btn btn-primary']) ?> + + - 'btn btn-primary']) ?> + - -
-
- -
-

+ + + $dataProvider, 'filterModel' => $searchModel, - 'columns' => [ ['class' => 'yii\grid\SerialColumn'], - [ 'format' => 'raw', 'attribute' => 'created_at', - 'filter' => Html::input('date', 'ReportsSearch[created_at]', - null, [ + 'filter' => Html::input('date', 'ReportsSearch[created_at]', null, [ 'class' => 'form-control', 'style' => 'display:', 'id' => 'date' @@ -127,28 +119,14 @@ function next_day($date, $number) 'attribute' => 'user_card_id', 'data' => $user_id__fio, 'options' => ['multiple' => true, 'class' => 'form-control'], - 'pluginOptions' => [ - - 'multiple' => true, - ], ]), - 'value' => function ($data) { - return '' . \common\models\Reports::getFio($data) . ''; + 'value' => function ($model) { + return Html::a(Reports::getFio($model).' '.Html::tag('i', null, ['class' => 'far fa-calendar-alt']), + ['user', 'user_id' => $model['user_card_id']]); + }, ], ['class' => 'yii\grid\ActionColumn'], ], -]); -$this->registerCssFile('../../css/site.css'); -?> - - - - - \ No newline at end of file +]);?> diff --git a/backend/modules/reports/views/reports/user.php b/backend/modules/reports/views/reports/user.php index 7e8e4eb..f6b0eaf 100644 --- a/backend/modules/reports/views/reports/user.php +++ b/backend/modules/reports/views/reports/user.php @@ -4,170 +4,154 @@ use yii\helpers\Html; use common\models\Reports; use backend\modules\reports\models\Month; - /* @var $this yii\web\View */ /* @var $searchModel backend\modules\reports\models\ReportsSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ -/* @var $reports common\models\Reports */ -/* @var $ID */ -/* @var $reports_month */ -/* @var $date */ +$reports = $dataProvider->getModels(); +$USER_ID = $searchModel->user_card_id; - -$month = new Month($date); -$index_raw = 0; - -function next_day($date, $number) -{ - return date('Y-m-d', strtotime($date) + 3600 * 24 * $number); +$reports_array = array_column($reports, 'attributes'); +foreach ($reports as $i => $report){ + $reports_array[$i]['today'] = array_column($report->task, 'attributes'); } +$reports_month = json_encode(array_merge( + ['reports' => $reports_array], + ['month' => (array)new Month()]) +); -function get_dates_created_at(Reports $report) -{ - return $report->created_at; -} - -function get_color($date, $dates_created_at) -{ - if (in_array(Month::get_day_week($date), array(6, 7))) - return; - if (in_array($date, $dates_created_at)) { - return 'success'; - } else - return 'danger'; -} - -$this->title = 'Календарь пользователя - ' . Reports::getFio($reports[0]); -$dates_created_at = array_unique(array_map('get_dates_created_at', $reports)); +$this->registerCssFile('@web/css/calendar.css'); +$this->title = 'Календарь пользователя - ' . Reports::getFio($searchModel); ?> -
- -
-
-
- - diff --git a/backend/web/css/calendar.css b/backend/web/css/calendar.css new file mode 100644 index 0000000..e5f844d --- /dev/null +++ b/backend/web/css/calendar.css @@ -0,0 +1,380 @@ +.calendar-contain { + position: relative; + left: 0; + right: 0; + border-radius: 0; + width: 100%; + overflow: hidden; + max-width: 1920px; + min-width: 450px; + margin: 1rem auto; + background-color: #f5f7f6; + box-shadow: 5px 5px 72px rgba(30, 46, 50, 0.5); + color: #040605; +} + +@media screen and (min-width: 55em) { + .calendar-contain { + margin: auto; + top: 5%; + } +} + +.title-bar { + position: relative; + width: 100%; + display: flex; + text-align: right; + background: #f5f7f6; + padding: 0.5rem; + margin-bottom: 0; +} + +.title-bar:after { + display: table; + clear: both; +} + +.title-bar__burger { + display: block; + position: relative; + float: left; + overflow: hidden; + margin: 0; + padding: 0; + width: 38px; + height: 30px; + font-size: 0; + text-indent: -9999px; + appearance: none; + box-shadow: none; + border: none; + cursor: pointer; + background: none; +} + +.title-bar__burger:focus { + outline: none; +} + +.burger__lines { + display: block; + position: absolute; + width: 18px; + top: 15px; + left: 0; + right: 0; + margin: auto; + height: 1px; + background: #040605; +} + +.burger__lines:before, .burger__lines:after { + position: absolute; + display: block; + left: 0; + width: 100%; + height: 1px; + background-color: #040605; + content: ""; +} + +.burger__lines:before { + top: -5px; +} + +.burger__lines:after { + bottom: -5px; +} + +.title-bar__year { + display: block; + position: relative; + float: left; + font-size: 1rem; + line-height: 30px; + width: 43%; + padding: 0 0.5rem; + text-align: left; +} + +@media screen and (min-width: 55em) { + .title-bar__year { + width: 27%; + } +} + +.title-bar__month { + position: relative; + /*float: center;*/ + font-size: 1rem; + line-height: 30px; + width: 22%; + padding: 0 0.5rem; + text-align: center; + margin-right: 67px; + word-spacing: 30px; +} + +@media screen and (min-width: 55em) { + .title-bar__month { + width: 12%; + } +} + +.title-bar__minimize, .title-bar__maximize, .title-bar__close { + position: relative; + float: left; + width: 34px; + height: 34px; +} + +.title-bar__minimize:before, .title-bar__maximize:before, .title-bar__close:before, .title-bar__minimize:after, .title-bar__maximize:after, .title-bar__close:after { + top: 30%; + right: 30%; + bottom: 30%; + left: 30%; + content: " "; + position: absolute; + border-color: #8e8e8e; + border-style: solid; + border-width: 0 0 2px 0; +} + +.title-bar .title-bar__controls { + display: inline-block; + vertical-align: top; + position: relative; + float: right; + width: auto; +} + +.title-bar .title-bar__controls:before, .title-bar .title-bar__controls:after { + content: none; +} + +.title-bar .title-bar__minimize:before { + border-bottom-width: 2px; +} + +.title-bar .title-bar__maximize:before { + border-width: 1px 1px 2px 1px; +} + +.title-bar .title-bar__close:before, .title-bar .title-bar__close:after { + bottom: 50%; + top: 49.9%; +} + +.title-bar .title-bar__close:before { + transform: rotate(45deg); +} + +.title-bar .title-bar__close:after { + transform: rotate(-45deg); +} + +.calendar__sidebar { + width: 100%; + margin: 0 auto; + float: none; + background: linear-gradient(120deg, #eff3f3, #e1e7e8); + padding-bottom: 0.7rem; +} + +@media screen and (min-width: 55em) { + .calendar__sidebar { + position: absolute; + height: 100%; + width: 50%; + float: left; + margin-bottom: 0; + } +} + +.calendar__sidebar .content { + padding: 2rem 1.5rem 2rem 4rem; + color: #040605; +} + +.sidebar__nav { + display: flex; + align-items: center; + justify-content: flex-start; + margin-bottom: 0.9rem; + padding: 0.7rem 1rem; + background-color: #f5f7f6; +} + +.sidebar__nav-item { + display: inline-block; + width: 22px; + margin-right: 23px; + padding: 0; + opacity: 0.8; +} + +.sidebar__list { + list-style: none; + margin: 0; + padding-left: 1rem; + padding-right: 1rem; +} + +.sidebar__list-item { + margin: 1.2rem 0; + color: #2d4338; + font-weight: 100; + font-size: 1rem; +} + +.list-item__time { + display: inline-block; + width: 60px; +} + +@media screen and (min-width: 55em) { + .list-item__time { + margin-right: 2rem; + } +} + +.sidebar__list-item--complete { + color: rgba(4, 6, 5, 0.3); +} + +.sidebar__list-item--complete .list-item__time { + color: rgba(4, 6, 5, 0.3); +} + +.sidebar__heading { + font-size: 2.2rem; + font-weight: bold; + padding-left: 1rem; + padding-right: 1rem; + margin-bottom: 3rem; + margin-top: 1rem; +} + +.sidebar__heading span { + float: right; + font-weight: 300; +} + +.calendar__heading-highlight { + color: #2d444a; + font-weight: 900; +} + +.calendar__days { + display: flex; + flex-flow: column wrap; + align-items: stretch; + width: 100%; + float: none; + min-height: 580px; + height: 100%; + font-size: 12px; + /*padding: 0.8rem 0 1rem 1rem;*/ + background: #f5f7f6; +} + +@media screen and (min-width: 55em) { + .calendar__days { + width: 50%; + float: right; + } +} + +.calendar__top-bar { + background: #b8cad6; + text-align: center; + display: flex; + flex: 56px 0 0; +} + +.top-bar__days { + width: 100%; + padding: 0 5px; + color: #2d4338; + font-weight: 100; + -webkit-font-smoothing: subpixel-antialiased; + font-size: 1rem; +} + +.calendar__week { + display: flex; + flex: 1 1 0; +} + +.calendar__day { + text-align: center; + display: flex; + flex-flow: column wrap; + + width: 100%; + justify-content: space-around; + /*padding: 1.9rem 0.2rem 0.2rem;*/ +} + + +.calendar__date { + /*margin: 25px;*/ + color: #040605; + font-size: 1.7rem; + font-weight: 600; + line-height: 0.7; +} + +@media screen and (min-width: 55em) { + .calendar__date { + font-size: 2.3rem; + } +} + +.calendar__week .inactive .calendar__date, .calendar__week .inactive .task-count { + color: #c6c6c6; +} + +.calendar__week .today .calendar__date { + color: #fd588a; +} + +.calendar__task { + color: #040605; + display: flex; + font-size: 0.8rem; +} + +@media screen and (min-width: 55em) { + .calendar__task { + font-size: 1rem; + } +} + +.calendar__task.calendar__task--today { + color: #fd588a; +} + + +.danger { + color: red; +} + +.success { + color: green; +} + +.calendar__day:hover { + color: #0a0a0a; + background: #c2c2c2; + cursor: pointer; +} +.calendar__day:active { + background: #727272; + cursor: pointer; +} + +.active_day { + background: #cdcfce; +} \ No newline at end of file