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 = 'Календарь отчетов'; ?> -= Html::beginTag('div', ['class' => 'reports-index'])?> - =Html::beginTag('p')?> += Calendar::widget([ - = Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?> - = Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => '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']), - =Html::endTag('p')?> - =Html::beginTag('p')?> - - - = Html::a($date, ['index', 'ReportsSearch[created_at]' => $date], ['class' => 'btn btn-primary']) ?> - - - =Html::endTag('p')?> -= Html::endTag('div')?> - -= Html::beginTag('div', ['class' => 'row'])?> - = Html::beginTag('div', ['class' => 'col-xs-6'])?> - 'get', 'options' => ['style' => 'display: inline-flex;'] ])?> - - attributes )as $attribute): ?> - - user_card_id):?> - user_card_id as $i => $id):?> - = $form->field($searchModel, 'user_card_id['.$i.']')->hiddenInput()->label(false)?> - - - - - - - = Html::input('date', 'ReportsSearch[created_at]', - $searchModel->created_at ? $searchModel->created_at : date('Y-m-d'), - ['class' => 'form-control']) ?> - - = Html::submitButton('Сортировка по дате', ['class' => 'btn btn-danger']) ?> - = Html::a('Все дни', ['index'], ['class' => 'btn btn-primary']) ?> - - - - - - - = Html::endTag('div')?> -= Html::endTag('div')?> - -= GridView::widget([ - 'dataProvider' => $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); +} +?> + += Html::beginTag('div', ['class' => 'reports-index'])?> + =Html::beginTag('p')?> + =Html::a(' Назад', + Yii::$app->request->referrer, ['class' => 'btn btn-success',])?> + = Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a('Сгрупированный по пользователям вид', ['group'], ['class' => 'btn btn-success']) ?> + + =Html::endTag('p')?> + + =Html::beginTag('p')?> + + + = Html::a($date, ['list', 'ReportsSearch[created_at]' => $date], ['class' => 'btn btn-primary']) ?> + + + =Html::endTag('p')?> += Html::endTag('div')?> + += Html::beginTag('div', ['class' => 'row'])?> + = Html::beginTag('div', ['class' => 'col-xs-6'])?> + 'get', 'options' => ['style' => 'display: inline-flex;'] ])?> + + attributes )as $attribute): ?> + + user_card_id):?> + user_card_id as $i => $id):?> + = $form->field($searchModel, 'user_card_id['.$i.']')->hiddenInput()->label(false)?> + + + + + + + = Html::input('date', 'ReportsSearch[created_at]', + $searchModel->created_at ? $searchModel->created_at : date('Y-m-d'), + ['class' => 'form-control']) ?> + + = Html::submitButton('Сортировка по дате', ['class' => 'btn btn-danger']) ?> + = Html::a('Все дни', ['list'], ['class' => 'btn btn-primary']) ?> + + + + + + + = Html::endTag('div')?> += Html::endTag('div')?> += GridView::widget([ + 'dataProvider' => $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') . '