diff --git a/backend/modules/calendar/views/ajax/_gridView.php b/backend/modules/calendar/views/ajax/_gridView.php index 301bad7..ef8a75e 100644 --- a/backend/modules/calendar/views/ajax/_gridView.php +++ b/backend/modules/calendar/views/ajax/_gridView.php @@ -11,7 +11,11 @@ echo GridView::widget([ ['class' => 'yii\grid\SerialColumn'], 'fio', 'dob', - ['class' => 'yii\grid\ActionColumn'], + ['class' => 'yii\grid\ActionColumn', + 'urlCreator' => function ($action, $model, $key, $index) { + return \yii\helpers\Url::base(true) . '/calendar/calendar/' . $action . '?id=' . $model->id; + } + ], ], ]); die(); diff --git a/backend/modules/reports/controllers/AjaxController.php b/backend/modules/reports/controllers/AjaxController.php index ebcd2da..ea04a83 100644 --- a/backend/modules/reports/controllers/AjaxController.php +++ b/backend/modules/reports/controllers/AjaxController.php @@ -10,17 +10,22 @@ use yii\web\Response; class AjaxController extends \yii\web\Controller { - public function actionGetReportsForDayByDate($user_id, $date) + public function actionGetReportsForDayByDate($date, $user_id = null) { $searchModel = new ReportsSearch(); - $params = ['ReportsSearch' => ['created_at' => $date], 'user_id' => $user_id]; + $params = ['ReportsSearch' => ['created_at' => $date]]; + $view = '_gridViewAllUsers'; + if ($user_id){ + $params['user_id'] = $user_id; + $view = '_gridViewOneUser'; + } $dataProvider = $searchModel->search($params); - return $this->render('_gridView', [ - 'dataProvider' => $dataProvider + return $this->render($view, [ + 'dataProvider' => $dataProvider, ]); } - public function actionGetReportsForMonthByIdYearMonth($user_id, $year, $month) + public function actionGetReportsForMonthByIdYearMonth($year, $month, $user_id=null) { $searchModel = new ReportsSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); diff --git a/backend/modules/reports/controllers/ReportsController.php b/backend/modules/reports/controllers/ReportsController.php index 3a0e29a..16ebefc 100644 --- a/backend/modules/reports/controllers/ReportsController.php +++ b/backend/modules/reports/controllers/ReportsController.php @@ -58,7 +58,23 @@ class ReportsController extends Controller ]),'user_card_id', 'fio'); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - return $this->render('index', [ + return $this->render('index'); + } + + public function actionList() + { + $searchModel = new ReportsSearch(); + $user_id__fio = ArrayHelper::map(ArrayHelper::toArray($searchModel->search([])->getModels(), [ + 'common\models\Reports' => [ + 'user_card_id', + 'fio' => function ($report) { + return Reports::getFio($report); + } + ], + ]),'user_card_id', 'fio'); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('list', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'user_id__fio' => $user_id__fio, @@ -94,7 +110,7 @@ class ReportsController extends Controller if (!$dataProvider->getCount()){ return $this->render('non-exist_user_id', ['id' => $user_id]); } - return $this->render('calendar', [ + return $this->render('calendarOneUser', [ 'reports' => $reports_array, 'fio' => Reports::getFio($searchModel), 'USER_ID' => $user_id diff --git a/backend/modules/reports/views/ajax/_gridViewAllUsers.php b/backend/modules/reports/views/ajax/_gridViewAllUsers.php new file mode 100644 index 0000000..e3fc14e --- /dev/null +++ b/backend/modules/reports/views/ajax/_gridViewAllUsers.php @@ -0,0 +1,51 @@ + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + [ + 'attribute' => 'today', + 'format' => 'raw', + 'value' => function ($model) { + + $text = ''; + if ($model->task) { + $i = 1; + foreach ($model->task as $task) { + $text .= "

$i. ($task->hours_spent ч.) $task->task

"; + $i++; + } + } + return $text; + } + ], + 'difficulties', + 'tomorrow', + [ + 'format' => 'raw', + 'attribute' => 'user_card_id', + 'value' => function ($model) { + return Html::a(Reports::getFio($model) . ' ' . Html::tag('i', null, ['class' => 'far fa-calendar-alt']), + \yii\helpers\Url::base(true) . '/reports/reports/calendar?user_id=' . $model['user_card_id'], ['data-pjax' => 0]); + }, + ], + [ + 'class' => 'yii\grid\ActionColumn', + 'urlCreator' => function ($action, $model, $key, $index) { + return \yii\helpers\Url::base(true) . '/reports/reports/' . $action . '?id=' . $model->id; + } + ], + ], + +]); +die(); + diff --git a/backend/modules/reports/views/ajax/_gridView.php b/backend/modules/reports/views/ajax/_gridViewOneUser.php similarity index 70% rename from backend/modules/reports/views/ajax/_gridView.php rename to backend/modules/reports/views/ajax/_gridViewOneUser.php index 9d1a0e6..a8be714 100644 --- a/backend/modules/reports/views/ajax/_gridView.php +++ b/backend/modules/reports/views/ajax/_gridViewOneUser.php @@ -3,6 +3,7 @@ use yii\grid\GridView; /* @var $this yii\web\View */ +/* @var $searchModel backend\modules\reports\models\ReportsSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ echo GridView::widget([ @@ -27,7 +28,12 @@ echo GridView::widget([ ], 'difficulties', 'tomorrow', - ['class' => 'yii\grid\ActionColumn'], + [ + 'class' => 'yii\grid\ActionColumn', + 'urlCreator' => function ($action, $model, $key, $index) { + return \yii\helpers\Url::base(true) . '/reports/reports/' . $action . '?id=' . $model->id; + } + ], ], ]); die(); diff --git a/backend/modules/reports/views/reports/calendar.php b/backend/modules/reports/views/reports/calendarOneUser.php similarity index 100% rename from backend/modules/reports/views/reports/calendar.php rename to backend/modules/reports/views/reports/calendarOneUser.php diff --git a/backend/modules/reports/views/reports/index.php b/backend/modules/reports/views/reports/index.php index c236c06..73ba002 100644 --- a/backend/modules/reports/views/reports/index.php +++ b/backend/modules/reports/views/reports/index.php @@ -1,127 +1,29 @@ title = 'Отчеты'; -$this->params['breadcrumbs'][] = $this->title; -$this->registerCss('.row * {margin-right: 10px;}'); -define('TODAY', date('Y-m-d')); -define('WEEK_AGO', date('Y-m-d', time() - 3600 * 24 * 7)); -function next_day($date, $number) -{ - return date('Y-m-d', strtotime($date) + 3600 * 24 * $number); -} +$this->title = 'Календарь отчетов'; ?> - 'reports-index'])?> - + 'btn btn-success']) ?> - 'btn btn-success']) ?> + 'button' => Html::a(' Назад', + Yii::$app->request->referrer, ['class' => 'btn btn-primary',]). + Html::a(' Список', + ['list'], ['class' => 'btn btn-success', 'style ' => 'margin: 0 5px']), - - - - - $date], ['class' => 'btn btn-primary']) ?> - - - - - - 'row'])?> - 'col-xs-6'])?> - 'get', 'options' => ['style' => 'display: inline-flex;'] ])?> - - 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']) ?> - 'btn btn-primary']) ?> - - - - - - - - - - $dataProvider, - 'filterModel' => $searchModel, - 'columns' => [ - ['class' => 'yii\grid\SerialColumn'], - [ - 'format' => 'raw', - 'attribute' => 'created_at', - 'filter' => Html::input('date', 'ReportsSearch[created_at]', null, [ - 'class' => 'form-control', - 'style' => 'display:', - 'id' => 'date' - - ]), - 'value' => 'created_at', - ], -// [ -// 'attribute' => 'today', -// 'format' => 'raw', -// 'value' => function ($model) { -// -// $text = ''; -// if ($model->task) { -// $i = 1; -// foreach ($model->task as $task) { -// $text .= "

$i. ($task->hours_spent ч.) $task->task

"; -// $i++; -// } -// } -// return $text; -// } -// ], - //'difficulties', - //'tomorrow', - [ - 'format' => 'raw', - 'attribute' => 'user_card_id', - 'filter' => kartik\select2\Select2::widget([ - 'model' => $searchModel, - 'attribute' => 'user_card_id', - 'data' => $user_id__fio, - 'options' => ['multiple' => true, 'class' => 'form-control'], - ]), - 'value' => function ($model) { - return Html::a(Reports::getFio($model).' '.Html::tag('i', null, ['class' => 'far fa-calendar-alt']), - ['calendar', 'user_id' => $model['user_card_id']]); - - }, - ], - - ['class' => 'yii\grid\ActionColumn'], + 'monthUpdate' => [ + 'url' => Url::base() . '/reports/ajax/get-reports-for-month-by-id-year-month' ], -]);?> - + 'dayUpdate' => [ + 'url' => Url::base() . '/reports/ajax/get-reports-for-day-by-date' + ], + 'colorClasses' => ['accept' => 'success', 'default' => 'danger', 'offDay' => ''], + 'offDaysShow' => 1, + +]) ?> diff --git a/backend/modules/reports/views/reports/list.php b/backend/modules/reports/views/reports/list.php new file mode 100644 index 0000000..0e55016 --- /dev/null +++ b/backend/modules/reports/views/reports/list.php @@ -0,0 +1,125 @@ +title = 'Отчеты'; +$this->params['breadcrumbs'][] = $this->title; +$this->registerCss('.row * {margin-right: 10px;}'); +define('TODAY', date('Y-m-d')); +define('WEEK_AGO', date('Y-m-d', time() - 3600 * 24 * 7)); +function next_day($date, $number) +{ + return date('Y-m-d', strtotime($date) + 3600 * 24 * $number); +} +?> + + 'reports-index'])?> + + Назад', + Yii::$app->request->referrer, ['class' => 'btn btn-success',])?> + 'btn btn-success']) ?> + 'btn btn-success']) ?> + + + + + + + $date], ['class' => 'btn btn-primary']) ?> + + + + + + 'row'])?> + 'col-xs-6'])?> + 'get', 'options' => ['style' => 'display: inline-flex;'] ])?> + + 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']) ?> + 'btn btn-primary']) ?> + + + + + + + + + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + [ + 'format' => 'raw', + 'attribute' => 'created_at', + 'filter' => Html::input('date', 'ReportsSearch[created_at]', null, [ + 'class' => 'form-control', + 'style' => 'display:', + 'id' => 'date' + + ]), + 'value' => 'created_at', + ], +// [ +// 'attribute' => 'today', +// 'format' => 'raw', +// 'value' => function ($model) { +// +// $text = ''; +// if ($model->task) { +// $i = 1; +// foreach ($model->task as $task) { +// $text .= "

$i. ($task->hours_spent ч.) $task->task

"; +// $i++; +// } +// } +// return $text; +// } +// ], + //'difficulties', + //'tomorrow', + [ + 'format' => 'raw', + 'attribute' => 'user_card_id', + 'filter' => kartik\select2\Select2::widget([ + 'model' => $searchModel, + 'attribute' => 'user_card_id', + 'data' => $user_id__fio, + 'options' => ['multiple' => true, 'class' => 'form-control'], + ]), + 'value' => function ($model) { + return Html::a(Reports::getFio($model).' '.Html::tag('i', null, ['class' => 'far fa-calendar-alt']), + ['calendar', 'user_id' => $model['user_card_id']]); + + }, + ], + + ['class' => 'yii\grid\ActionColumn'], + ], +]);?> diff --git a/backend/widgets/Calendar.php b/backend/widgets/Calendar.php index 249c678..eb64121 100644 --- a/backend/widgets/Calendar.php +++ b/backend/widgets/Calendar.php @@ -6,6 +6,7 @@ namespace backend\widgets; use common\classes\Debug; use yii\base\Widget; use yii\helpers\Html; +use yii\widgets\Pjax; class Calendar extends Widget @@ -51,8 +52,10 @@ class Calendar extends Widget echo Html::input('date', null, date('Y-m-d'), ['class' => 'form-control', 'id' => 'date',]); echo Html::endTag('section'); echo Html::tag('h2', date('l') . '
' . date('F d'), ['class' => 'sidebar__heading']); - echo Html::beginTag('ul', ['class' => 'sidebar__list']); - echo Html::endTag('ul'); + echo '
'; + Pjax::begin(['enablePushState' => false, 'class' => 'sidebar__list']); + Pjax::end(); + echo '
'; echo Html::endTag('aside'); echo Html::beginTag('section', ['class' => 'calendar__days']); echo Html::endTag('section'); diff --git a/backend/widgets/Calendar/assets/css/style.css b/backend/widgets/Calendar/assets/css/style.css index 6d9188b..25daad6 100644 --- a/backend/widgets/Calendar/assets/css/style.css +++ b/backend/widgets/Calendar/assets/css/style.css @@ -220,6 +220,12 @@ padding-left: 1rem; padding-right: 1rem; } +#p0 { + list-style: none; + margin: 0; + padding-left: 1rem; + padding-right: 1rem; +} .sidebar__list-item { margin: 1.2rem 0; diff --git a/backend/widgets/Calendar/assets/js/src/CalendarHelper.js b/backend/widgets/Calendar/assets/js/src/CalendarHelper.js index 477dbd2..3dcf616 100644 --- a/backend/widgets/Calendar/assets/js/src/CalendarHelper.js +++ b/backend/widgets/Calendar/assets/js/src/CalendarHelper.js @@ -46,11 +46,10 @@ class CalendarHelper { let oldDate = datePicker.value.substr(0, 7); let nameDateBoard = document.querySelector('.sidebar__heading'); - let contentBoard = document.querySelector('.sidebar__list'); + this._getMonth(datePicker.value.substr(5, 2), datePicker.value.substr(0, 4)) .then(dates => { - this.build(DateHelper.stringToDate(datePicker.value), dates) datePicker.onchange = async function (day = null) { @@ -75,7 +74,7 @@ class CalendarHelper { let monthName = date.toLocaleString('default', {month: 'long'}); let dayWeekName = date.toLocaleString('default', {weekday: 'long'}); nameDateBoard.innerHTML = `${dayWeekName}
${monthName} ${datePicker.value.substr(8, 2)}`; - contentBoard.innerHTML = CalendarHelper._getHtmlContentForDate(dates, datePicker.value) + document.querySelector('#p0').innerHTML = CalendarHelper._getHtmlContentForDate(dates, datePicker.value) }) } @@ -85,7 +84,7 @@ class CalendarHelper { let monthName = date.toLocaleString('default', {month: 'long'}); let dayWeekName = date.toLocaleString('default', {weekday: 'long'}); nameDateBoard.innerHTML = `${dayWeekName}
${monthName} ${datePicker.value.substr(8, 2)}`; - contentBoard.innerHTML = await CalendarHelper._getDayContent(date) + document.querySelector('#p0').innerHTML = await CalendarHelper._getDayContent(date) } let days = document.querySelectorAll('.calendar__day'); @@ -111,6 +110,7 @@ class CalendarHelper { } } + datePicker.onchange() }) }