diff --git a/backend/modules/calendar/controllers/AjaxController.php b/backend/modules/calendar/controllers/AjaxController.php index 85530c3..e4fd7dc 100644 --- a/backend/modules/calendar/controllers/AjaxController.php +++ b/backend/modules/calendar/controllers/AjaxController.php @@ -4,22 +4,29 @@ namespace backend\modules\calendar\controllers; use backend\modules\card\models\UserCardSearch; use Yii; -use yii\helpers\ArrayHelper; use yii\web\Response; class AjaxController extends \yii\web\Controller { - public function actionGetBirthdayByMonth($month ) + + public function actionGetBirthdayDate($date) + { + $searchModel = new UserCardSearch(); + $dataProvider = $searchModel->search(['date' => $date]); + + return $this->render('_gridView', [ + 'dataProvider' => $dataProvider + ]); + } + + public function actionGetBirthdayDatesByMonth($month ) { $searchModel = new UserCardSearch(); $models = $searchModel->search(Yii::$app->request->queryParams)->getModels(); - $models_array = ArrayHelper::toArray($models, [ - 'backend\modules\card\models\UserCard' => [ - 'id', - 'dob', - 'fio' - ], - ]); + $models_array = array_map(function ($date){return date('Y').substr($date, 4,6);}, + array_column($models, 'dob') + ); + $response = Yii::$app->response; $response->format = Response::FORMAT_JSON; diff --git a/backend/modules/calendar/controllers/CalendarController.php b/backend/modules/calendar/controllers/CalendarController.php index 352efac..eac83ea 100644 --- a/backend/modules/calendar/controllers/CalendarController.php +++ b/backend/modules/calendar/controllers/CalendarController.php @@ -42,11 +42,11 @@ class CalendarController extends Controller * Renders the index view for the module * @return string */ - public function actionCalendar(){ - return $this->render('calendar'); + public function actionIndex(){ + return $this->render('index'); } - public function actionIndex() + public function actionTable() { $searchModel = new UserCardSearch(); $user_card = \common\models\UserCard::find()->all(); @@ -67,7 +67,7 @@ class CalendarController extends Controller $dataProvider = $searchModel->search(Yii::$app->request->queryParams); } - return $this->render('index', [ + return $this->render('table', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); diff --git a/backend/modules/calendar/views/ajax/_gridView.php b/backend/modules/calendar/views/ajax/_gridView.php new file mode 100644 index 0000000..301bad7 --- /dev/null +++ b/backend/modules/calendar/views/ajax/_gridView.php @@ -0,0 +1,18 @@ + $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'fio', + 'dob', + ['class' => 'yii\grid\ActionColumn'], + ], +]); +die(); + diff --git a/backend/modules/calendar/views/calendar/calendar.php b/backend/modules/calendar/views/calendar/calendar.php deleted file mode 100644 index ca050c5..0000000 --- a/backend/modules/calendar/views/calendar/calendar.php +++ /dev/null @@ -1,59 +0,0 @@ -title = 'Календарь ДР'; -?> -= \backend\widgets\Calendar::widget([ - - 'css' => '.success{color: orange;}', - - 'button' => Html::a(' Назад', - Yii::$app->request->referrer, ['class' => 'btn btn-primary',]), - 'runBuild' => "function (date, content){ - this.build(date, content) - }", - 'updateContent' => "function(date){ - let monthNumber = date.substr(5, 2); - return fetch('../ajax/get-birthday-by-month?' + - 'month=' + monthNumber) - .then((res) => { - return res.json() - }) - }", - 'getColor' => "function (date, dates = null) { - for (let contentDate of dates) { - if (contentDate['dob'].substr(8, 2) == DateHelper.intToDate(date.getDate())) { - return 'success'; - } - } - }", - 'getHtmlContentForDate' => 'function (content, date) { - let flag = false - let html = `
# | -ФИО | -Дата рождения | -- |
---|---|---|---|
${i} | ` - html += `${model["fio"]} | ` - html += `${model["dob"]} | ` - html += CalendarHelper._getActionColumn(`secure/calendar/calendar`,model[`id`]) - html += `
- -
-=Html::a('Календарь дней рождений '.Html::tag('i', null, ['class' => 'far fa-calendar-alt']), - ['calendar'], ['class' => 'btn btn-success', 'style' => 'margin-left: 10px'])?> -+ +
+=Html::a('Календарь дней рождений '.Html::tag('i', null, ['class' => 'far fa-calendar-alt']), + ['index'], ['class' => 'btn btn-success', 'style' => 'margin-left: 10px'])?> +$i. ($task->hours_spent ч.) $task->task
"; + $i++; + } + } + return $text; + } + ], + 'difficulties', + 'tomorrow', + ['class' => 'yii\grid\ActionColumn'], + ], +]); +die(); + diff --git a/backend/modules/reports/views/reports/calendar.php b/backend/modules/reports/views/reports/calendar.php index 2496e4b..7ae4024 100644 --- a/backend/modules/reports/views/reports/calendar.php +++ b/backend/modules/reports/views/reports/calendar.php @@ -2,6 +2,7 @@ use backend\widgets\Calendar; use yii\helpers\Html; +use yii\helpers\Url; /* @var $this yii\web\View */ /* @var $fio */ @@ -10,80 +11,20 @@ use yii\helpers\Html; $this->title = 'Календарь пользователя - ' . $fio; ?> -=Calendar::widget([ += Calendar::widget([ 'button' => Html::a(' Назад', Yii::$app->request->referrer, ['class' => 'btn btn-primary',]), - 'runBuild' => "function (date, content){ - contentDays = [] - for (let item of content){ - contentDays.push(item['created_at']) - } - this.build(date, contentDays) - }", + 'monthUpdate' => [ + 'url' => Url::base() . '/reports/ajax/get-reports-for-month-by-id-year-month', + 'data' => ['user_id' => $USER_ID] + ], + 'dayUpdate' => [ + 'url' => Url::base() . '/reports/ajax/get-reports-for-day-by-date', + 'data' => ['user_id' => $USER_ID] + ], + 'colorClasses' => ['accept' => 'success', 'default' => 'danger', 'offDay' => ''], + 'offDaysShow' => 1, - '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 = `