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..54f624c 100644
--- a/backend/modules/reports/views/reports/calendar.php
+++ b/backend/modules/reports/views/reports/calendar.php
@@ -7,27 +7,123 @@ use yii\helpers\Url;
/* @var $fio */
/* @var $USER_ID */
-$this->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;
?>
-=Html::beginTag('section', ['class' => 'calendar-contain'])?>
- =Html::beginTag('aside', ['class' => 'calendar__sidebar'])?>
- =Html::beginTag('section', ['class' => 'title-bar'])?>
- = Html::a(' Назад', Yii::$app->request->referrer, ['class' => 'btn btn-primary',]) ?>
- = Html::input('date', null, date('Y-m-d'), ['class' => 'form-control', 'id' => 'date',]) ?>
- =Html::endTag('section')?>
+= \backend\widgets\Calendar::widget([
+ 'button' => Html::a(' Назад',
+ Yii::$app->request->referrer, ['class' => 'btn btn-primary',]),
- =Html::tag('h2', date('l').'
'.date('F d'), ['class' => 'sidebar__heading'])?>
+ '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 = `