From 523f7fe697e2534f84f657b18934d00119910483 Mon Sep 17 00:00:00 2001 From: vladfo Date: Thu, 19 Sep 2024 14:33:16 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=20=D0=B4=D0=B8=D0=B7=D0=B0=D0=B9=D0=BD=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/crud/TaskController.php | 13 + erp24/views/crud/task/_form.php | 476 +++++++++++----------- erp24/views/task/four-columns.php | 35 +- erp24/views/task/index.php | 33 +- 4 files changed, 311 insertions(+), 246 deletions(-) diff --git a/erp24/controllers/crud/TaskController.php b/erp24/controllers/crud/TaskController.php index bf662ae7..a7871b43 100644 --- a/erp24/controllers/crud/TaskController.php +++ b/erp24/controllers/crud/TaskController.php @@ -199,6 +199,19 @@ class TaskController extends Controller $entities = []; // TaskService::getEntitiesByAlias(EntityType::findOne($model->entity_type)->alias); $canUpdateAll = true; $canUpdateStatusAndDuration = true; + + // Логирование передаваемых переменных + Yii::info([ + 'model' => $model, + 'entities' => $entities, + 'taskEntity' => $taskEntity, + 'tasksType' => $tasksType, + 'taskStatus' => $taskStatus, + 'taskAlertLevels' => $taskAlertLevels, + 'canUpdateAll' => $canUpdateAll, + 'canUpdateStatusAndDuration' => $canUpdateStatusAndDuration + ], 'debug'); + // Возвращаем HTML формы для рендеринга в модальном окне return $this->renderAjax('_form', compact('model', 'entities', 'taskEntity', 'tasksType', 'taskStatus', 'taskAlertLevels', 'canUpdateAll', 'canUpdateStatusAndDuration')); } diff --git a/erp24/views/crud/task/_form.php b/erp24/views/crud/task/_form.php index f511f181..bf8f2378 100755 --- a/erp24/views/crud/task/_form.php +++ b/erp24/views/crud/task/_form.php @@ -4,19 +4,20 @@ use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; - use kartik\select2\Select2; use dosamigos\datetimepicker\DateTimePicker; - use yii_app\records\Admin; - -use yii_app\helpers\PrintBlockHelper; use yii_app\services\FileService; /* @var $this yii\web\View */ /* @var $model yii_app\records\Task */ /* @var $form yii\widgets\ActiveForm */ -/* @var $comment \yii_app\records\Comment */ +/* @var $comment yii_app\records\Comment|null */ +/* @var $entities array */ +/* @var $taskEntity array */ +/* @var $tasksType array */ +/* @var $taskStatus array */ +/* @var $taskAlertLevels array */ /* @var $canUpdateAll boolean */ /* @var $canUpdateStatusAndDuration boolean */ @@ -24,115 +25,128 @@ $this->registerJsFile('/js/crud/task/update.js', ['position' => \yii\web\View::P ?> -
+
- ['enctype' => 'multipart/form-data']]); ?> + ['enctype' => 'multipart/form-data']]); ?>
field($model, 'id')->hiddenInput()->label(false) ?>
- field($model, 'task_type_id')->dropDownList( - ArrayHelper::map($tasksType, 'id', 'name'), ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)); ?> - - field($model, 'name')->textInput(['maxlength' => true, 'disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?> - - field($model, 'description')->textarea(['rows' => 6, 'disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?> - - field($model, 'group_id')->textInput() ?> - - field($model, 'entity_type')->widget(Select2::class, [ - 'data' => ArrayHelper::map($taskEntity, 'id', 'name'), - 'language' => 'ru', - 'options' => ['placeholder' => 'Тип сущности для привязки...'], - 'pluginOptions' => [ - 'allowClear' => true, - 'disabled' => !$canUpdateAll - ], - 'pluginEvents' => [ - "change" => "function() { - var value= $(this).val(); - console.log(value); - $.ajax({ - method: 'POST', - dataType: 'text', - url: window.location.href, - data: { value : value }, - success: function (response) { - var r = JSON.parse(response); - console.log(r); - var myDropDownList = document.getElementById('task-entity_id'); - while (myDropDownList.options.length > 0) { - myDropDownList.remove(myDropDownList.options.length - 1); - } - $.each(r, function(index, value) { - var option = document.createElement(\"option\"); - option.text = value; - option.value = index; - try { - myDropDownList.options.add(option); - } catch (e) { - alert(e); - } - }); - } - }); - }", - ] - ])->label(false)) ?> - - field($model, 'entity_id')->textInput() ?> +
+ + field($model, 'task_type_id')->dropDownList( + ArrayHelper::map($tasksType, 'id', 'name'), + ['disabled' => $canUpdateAll ? null : 'disabled'] + )->label(false); ?> +
- field($model, 'entity_id')->dropDownList($entities, ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?> +
+ + field($model, 'name')->textInput([ + 'maxlength' => true, + 'disabled' => $canUpdateAll ? null : 'disabled' + ])->label(false); ?> +
+
+ + field($model, 'description')->textarea([ + 'rows' => 6, + 'disabled' => $canUpdateAll ? null : 'disabled' + ])->label(false); ?> +
- field($model, 'entity_type')->dropDownList( - // ArrayHelper::map($entityType, 'id', 'name')) ?> +
+ + field($model, 'entity_type')->widget(Select2::class, [ + 'data' => ArrayHelper::map($taskEntity, 'id', 'name'), + 'language' => 'ru', + 'options' => ['placeholder' => 'Тип сущности для привязки...'], + 'pluginOptions' => [ + 'allowClear' => true, + 'disabled' => !$canUpdateAll + ], + 'pluginEvents' => [ + "change" => "function() { + var value= $(this).val(); + console.log(value); + $.ajax({ + method: 'POST', + dataType: 'text', + url: window.location.href, + data: { value : value }, + success: function (response) { + var r = JSON.parse(response); + console.log(r); + var myDropDownList = document.getElementById('task-entity_id'); + while (myDropDownList.options.length > 0) { + myDropDownList.remove(myDropDownList.options.length - 1); + } + $.each(r, function(index, value) { + var option = document.createElement(\"option\"); + option.text = value; + option.value = index; + try { + myDropDownList.options.add(option); + } catch (e) { + alert(e); + } + }); + } + }); + }", + ] + ])->label(false); ?> +
- field($model, 'status')->dropDownList( - ArrayHelper::map($taskStatus, 'id','name'), ['disabled' => $canUpdateStatusAndDuration ? null : 'disabled'])->label(false)) ?> +
+ + field($model, 'entity_id')->dropDownList( + $entities, + ['disabled' => $canUpdateAll ? null : 'disabled'] + )->label(false); ?> +
- field($model, 'prioritet')->textInput() ?> +
+ + field($model, 'status')->dropDownList( + ArrayHelper::map($taskStatus, 'id', 'name'), + ['disabled' => $canUpdateStatusAndDuration ? null : 'disabled'] + )->label(false); ?> +
- +
+ + field($model, 'duration')->textInput(['type' => 'number', 'disabled' => !$canUpdateStatusAndDuration])->label(false); ?> +
- + - - - field($model, 'duration')->textInput(['type' => 'number'])->label(false)) ?> - - field($model, 'is_completed')->textInput() ?> - - field($model, 'data_start')->widget(DateTimePicker::class, [ - 'language' => 'ru', - 'template' => '{input}', - 'clientOptions' => [ - 'autoclose' => true, - 'format' => 'Y-m-d H:i', - 'todayBtn' => true - ], - ])->label(false)) ?> + - field($model, 'data_start', [ - 'inputOptions' => [ - 'class' => 'form-control datetime', - 'type' => 'datetime-local', - ], - 'options' => ['tag' => null], - ])->textInput()->label(false)) */ ?> - - field($model, 'data_start')->textInput() // календарь ?> - - + + field($model, 'data_start')->widget(DateTimePicker::class, [ + 'language' => 'ru', + 'template' => '{input}', + 'clientOptions' => [ + 'autoclose' => true, + 'format' => 'Y-m-d H:i', + 'todayBtn' => true + ], + ])->label(false); ?> +
- if ($model->deadline_permission != 0 || ($model->controller && ($model->controller->id == $_SESSION['admin_id']))) { - PrintBlockHelper::printBlock('Крайний срок', $form->field($model, 'deadline')->widget(DateTimePicker::class, [ +deadline_permission != 0 || ($model->controller && ($model->controller->id == $_SESSION['admin_id']))): ?> +
+ + field($model, 'deadline')->widget(DateTimePicker::class, [ 'language' => 'ru', 'template' => '{input}', 'clientOptions' => [ @@ -140,150 +154,154 @@ $this->registerJsFile('/js/crud/task/update.js', ['position' => \yii\web\View::P 'format' => 'Y-m-d H:i', 'todayBtn' => true ], - ])->label(false)); - } - - ?> - - field($model, 'deadline', [ - 'inputOptions' => [ - 'class' => 'form-control datetime', - 'type' => 'datetime-local', - ], - 'options' => ['tag' => null], - ])->textInput()->label(false)) */ ?> - - field($model, 'dead_line')->textInput() // календарь ?> - - field($model, 'data_end')->textInput() ?> - - field($model, 'result')->textarea(['rows' => 6]) ?> - - field($model, 'updated_by')->textInput() // проверяющий id должен быть в бд, а поле это "для кого" подтягивается из админа ?> - - field($model, 'alert_level_id')->dropDownList( - ArrayHelper::map($taskAlertLevels, 'id', 'name'), ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?> - - field($model, 'motivation_id')->dropDownList( - ArrayHelper::map(\yii_app\records\TaskMotivation::find()->all(), 'id', 'name'), ['disabled' => $canUpdateAll ? null : 'disabled'])->label(false)) ?> - - with('adminGroup')->all() as $admin) { - $adminArr[] = ['id' => $admin->id, 'name' => $admin->name, 'groupName' => $admin->adminGroup->name ?? "Другие"]; - } - - ?> - - - - field($model, 'updated_by')->widget(Select2::class, [ - 'data' => $admins, - 'language' => 'ru', - 'options' => ['placeholder' => 'Кому адресовать задачу...'], - 'pluginOptions' => [ - 'allowClear' => true, - 'disabled' => !$canUpdateAll - ], - ])->label(false)); ?> - - field($model, 'controller_id')->widget(Select2::class, [ - 'data' => $admins, - 'language' => 'ru', - 'options' => ['placeholder' => 'Кто контроллирует задачу...'], - 'pluginOptions' => [ - 'allowClear' => true, - 'disabled' => !$canUpdateAll - ], - ])->label(false)); ?> - - 'taskUsers', - 'value' => array_values(ArrayHelper::map($model->users, 'id', 'id')), - 'data' => $admins, - 'options' => ['multiple' => true, 'placeholder' => 'Выберете участников ...'], - 'pluginOptions' => [ - 'disabled' => !$canUpdateAll - ], - ])); ?> - - 'taskViewers', - 'value' => array_values(ArrayHelper::map($model->viewers, 'id', 'id')), - 'data' => $admins, - 'options' => ['multiple' => true, 'placeholder' => 'Выберете наблюдателей ...'], - 'pluginOptions' => [ - 'disabled' => !$canUpdateAll - ], - ])); ?> - - field($model, 'created_by')->textInput() // создаётся из под того кто сидит ?> - - field($model, 'created_at')->textInput() // автоматом в момент создания ?> - - field($model, 'updated_at')->textInput() ?> - - field($model, 'close_at')->textInput() ?> - - field($model, 'closed_by')->textInput() ?> - - attachedFiles): ?> -
- attachedFiles as $file): ?> -
- file_type == 'image'): ?> - img - - url)?> - -
- -
- + ])->label(false); ?> +
+ - -
'); ?> - +
+ + field($model, 'alert_level_id')->dropDownList( + ArrayHelper::map($taskAlertLevels, 'id', 'name'), + ['disabled' => $canUpdateAll ? null : 'disabled'] + )->label(false); ?> +
- 'btn btn-success btn-lg']) ?> + + field($model, 'motivation_id')->dropDownList( + ArrayHelper::map(\yii_app\records\TaskMotivation::find()->all(), 'id', 'name'), + ['disabled' => $canUpdateAll ? null : 'disabled'] + )->label(false); ?>
- +with('adminGroup')->all() as $admin) { + $adminArr[] = ['id' => $admin->id, 'name' => $admin->name, 'groupName' => $admin->adminGroup->name ?? "Другие"]; +} +$admins = ArrayHelper::map($adminArr, 'id', 'name', 'groupName'); +?> - - 'comment-form', 'options' => ['enctype' => 'multipart/form-data']]) ?> - field($comment, 'msg')->textInput()->label(false)) ?> +
+ + field($model, 'updated_by')->widget(Select2::class, [ + 'data' => $admins, + 'language' => 'ru', + 'options' => ['placeholder' => 'Кому адресовать задачу...'], + 'pluginOptions' => [ + 'allowClear' => true, + 'disabled' => !$canUpdateAll + ], + ])->label(false); ?> +
- '); ?> +
+ + field($model, 'controller_id')->widget(Select2::class, [ + 'data' => $admins, + 'language' => 'ru', + 'options' => ['placeholder' => 'Кто контроллирует задачу...'], + 'pluginOptions' => [ + 'allowClear' => true, + 'disabled' => !$canUpdateAll + ], + ])->label(false); ?> +
-
- 'btn btn-success btn']) ?> -
- - - comments)): ?> - comments as $cmnt): ?> +
+ + 'taskUsers', + 'value' => array_values(ArrayHelper::map($model->users, 'id', 'id')), + 'data' => $admins, + 'options' => ['multiple' => true, 'placeholder' => 'Выберете участников ...'], + 'pluginOptions' => [ + 'disabled' => !$canUpdateAll + ], + ]); ?> +
+ +
+ + 'taskViewers', + 'value' => array_values(ArrayHelper::map($model->viewers, 'id', 'id')), + 'data' => $admins, + 'options' => ['multiple' => true, 'placeholder' => 'Выберете наблюдателей ...'], + 'pluginOptions' => [ + 'disabled' => !$canUpdateAll + ], +]); ?> +
+ + attachedFiles): ?>
-
- createdBy->name ?> (created_at) ?>): + attachedFiles as $file): ?> +
+ file_type == 'image'): ?> + img + + url) ?> + +
+ +
+ + + +
+ +
+
-
- msg ?> - attachedFiles)): ?> - attachedFiles as $file): ?> - file_type == 'image'): ?> - url), [$file->url], ['class' => 'btn btn-link', 'target' => '_blank']) ?> - - url), ['/files/download', 'url' => $file->url], ['class' => 'btn btn-link']) ?> - - - +
+ + +
+ 'btn btn-success btn-lg']) ?> +
+ + + + + 'comment-form', 'options' => ['enctype' => 'multipart/form-data']]) ?> +
+ + field($comment, 'msg')->textInput()->label(false) ?> +
+ +
+ +
+
- - -
+ +
+ 'btn btn-success btn']) ?> +
+ + + + comments)): ?> + comments as $cmnt): ?> +
+
+ createdBy->name ?> (created_at) ?>): +
+
+ msg ?> + attachedFiles)): ?> + attachedFiles as $file): ?> + file_type == 'image'): ?> + url), [$file->url], ['class' => 'btn btn-link', 'target' => '_blank']) ?> + + url), ['/files/download', 'url' => $file->url], ['class' => 'btn btn-link']) ?> + + + +
+
+ + +
\ No newline at end of file diff --git a/erp24/views/task/four-columns.php b/erp24/views/task/four-columns.php index c3ca0256..5c89d949 100755 --- a/erp24/views/task/four-columns.php +++ b/erp24/views/task/four-columns.php @@ -1,5 +1,7 @@ 'filter-form']); ?> toggleTasks(); }); + + $(document).on('click', '#create-task-button', function() { + // Отправляем AJAX-запрос для получения формы + $.get(createTaskUrl, function(data) { + // Помещаем полученный HTML в модальное окно + $('#create-task-content').html(data); - - // Когда пользователь нажимает на кнопку "Создать задачу" -$('#create-task-button').on('click', function() { - // Открываем модальное окно - $('#create-task-modal').modal('show') - .find('#create-task-content') // Загружаем контент формы в модальное окно - .load('/crud/task/create-ajax'); // URL на экшен, который выводит форму создания задачи + // Открываем модальное окно + $('#create-task-modal').modal('show'); + }); }); // Обработка формы создания задачи после отправки @@ -502,4 +506,19 @@ JS; - \ No newline at end of file + + + + \ No newline at end of file diff --git a/erp24/views/task/index.php b/erp24/views/task/index.php index c927bf74..69eeded5 100755 --- a/erp24/views/task/index.php +++ b/erp24/views/task/index.php @@ -5,7 +5,7 @@ use yii\helpers\Html; use yii\helpers\Url; use yii\helpers\ArrayHelper; use yii\widgets\Pjax; - +use yii\helpers\HtmlPurifier; use yii_app\services\TaskService; use yii_app\services\FileService; @@ -15,7 +15,7 @@ if (isset($task)) { $rootTask = $rootTask->parent; } } - +$this->title = 'Список задач'; function writeNode($node, $selectedNode, $depth, $writePosit) { echo "" . ($writePosit ? "" . $node->posit . ")" : "") @@ -34,6 +34,18 @@ function writeNode($node, $selectedNode, $depth, $writePosit) { } ?> +
+ +

title) ?>

+
+
+ 'btn btn-success', 'target' => '_blank', 'data-pjax' => '0']) ?> +
+ + +
'SomePjax']) ?>
@@ -43,10 +55,13 @@ function writeNode($node, $selectedNode, $depth, $writePosit) { 'Мои', '1' => 'На контроле', '2' => 'Участвую', '3' => 'Просматриваю', '4' => 'Неразобранные', '5' => 'Закрытые'], ['class' => 'form-control']); ?> 'btn btn-primary']) ?>
+ + +
-