diff --git a/backend/modules/reports/controllers/AjaxController.php b/backend/modules/reports/controllers/AjaxController.php index 16de037..7b81181 100644 --- a/backend/modules/reports/controllers/AjaxController.php +++ b/backend/modules/reports/controllers/AjaxController.php @@ -35,10 +35,7 @@ class AjaxController extends \yii\web\Controller $response = Yii::$app->response; $response->format = Response::FORMAT_JSON; $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')]) - ); + $response->content = json_encode($reports_array); return $response; } diff --git a/backend/modules/reports/views/reports/calendar.php b/backend/modules/reports/views/reports/calendar.php index 1521155..2496e4b 100644 --- a/backend/modules/reports/views/reports/calendar.php +++ b/backend/modules/reports/views/reports/calendar.php @@ -1,33 +1,89 @@ registerJs('let userID = '. $USER_ID); -$this->registerJs(file_get_contents(Url::base(true).'/js/calendar.js')); -$this->registerCssFile('@web/css/calendar.css'); $this->title = 'Календарь пользователя - ' . $fio; ?> - 'calendar-contain'])?> - 'calendar__sidebar'])?> - 'title-bar'])?> - Назад', Yii::$app->request->referrer, ['class' => 'btn btn-primary',]) ?> - 'form-control', 'id' => 'date',]) ?> - - '.date('F d'), ['class' => 'sidebar__heading'])?> + 'sidebar__list'])?> - - + 'button' => Html::a(' Назад', + Yii::$app->request->referrer, ['class' => 'btn btn-primary',]), - 'calendar__days'])?> - - + 'runBuild' => "function (date, content){ + contentDays = [] + for (let item of content){ + contentDays.push(item['created_at']) + } + this.build(date, contentDays) + }", + 'updateContent' => "function(date){ + let monthNumber = date.substr(5, 2); + let yearNumber = date.substr(0, 4); + return fetch('../ajax/get-reports-for-month-by-id-year-month?user_id='+".$USER_ID."+ + '&month=' + monthNumber + + '&year=' + yearNumber) + .then((res) => { + return res.json() + }) + }", + 'getColor' => "function (date, dates = null) { + let d = date; + if ([6, 0].includes(d.getDay())) + return; + for (let i = 0; i < dates.length; i++) { + if (dates[i] == DateHelper.dateToString(date)) { + return 'success'; + } + } + return 'danger'; + }", + 'getHtmlContentForDate' => "function (content, date) { + if ([0, 6].includes(new Date(date).getDay())) { + return 'Выходной день'; + } + let j = 0; + let html = `