From: vladfo Date: Thu, 19 Sep 2024 23:46:47 +0000 (+0300) Subject: Поиск и прочее X-Git-Tag: 1.5~5^2~11 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=6e729e6193c6d4d493c1d6e659fd7c96cc9813d7;p=erp24_rep%2Fyii-erp24%2F.git Поиск и прочее --- diff --git a/erp24/actions/task/FourColumnsAction.php b/erp24/actions/task/FourColumnsAction.php index 686d10c4..9528c3ab 100755 --- a/erp24/actions/task/FourColumnsAction.php +++ b/erp24/actions/task/FourColumnsAction.php @@ -20,6 +20,14 @@ class FourColumnsAction extends Action { public function run($task_id = null) { + if (Yii::$app->request->isAjax) { + $val = Yii::$app->request->post("value"); + $alias = TaskEntity::findOne($val)->alias; + return json_encode(TaskService::getEntitiesByAlias($alias), JSON_UNESCAPED_UNICODE); + } + + + $action = Yii::$app->request->post('action'); if ($action == 'updateTaskStatus') { $task_id = Yii::$app->request->post('task_id'); diff --git a/erp24/actions/task/IndexAction.php b/erp24/actions/task/IndexAction.php index bf2a8a90..b20aea63 100755 --- a/erp24/actions/task/IndexAction.php +++ b/erp24/actions/task/IndexAction.php @@ -249,20 +249,24 @@ class IndexAction extends Action } $text = Yii::$app->request->post('name'); + // var_dump($text); if (!isset($text)) { $text = Yii::$app->session->get('searchFilter'); } - if (isset($text)) { + if (isset($text) && !empty($text)) { Yii::$app->session->set('searchFilter', $text); - $tasks = Task::find()->where( - ['or', - ['like', 'task.name', '%' . $text . '%', false], - ['like', 'task.description', '%' . $text . '%', false] - ]); + //$text = 'Создание'; + $tasks = Task::find() + ->where( + ['ilike', 'task.name', $text], // Регистронезависимый поиск по полю name + );// Получаем все записи + + // var_dump($tasks); + } else { Yii::$app->session->set('searchFilter', ''); $tasks = Task::find(); - } + if (!isset($taskFilterSelection) || $taskFilterSelection == "" || $taskFilterSelection == "0") { $tasks = $tasks->andWhere(['or', ['like', 'updated_by', $_SESSION["admin_id"]], ['like', 'created_by', $_SESSION["admin_id"]]])->where(['<', 'status', Task::STATUS_CLOSED]); @@ -290,9 +294,9 @@ class IndexAction extends Action if ($taskFilterSelection == "5") { $tasks = $tasks->andWhere(['status' => Task::STATUS_CLOSED]); } - + } $tasks = $tasks->andWhere(['or', ['parent_id' => 0], ['parent_id' => null]])->all(); - + //var_dump($tasks); if (Yii::$app->request->isPjax) { $task = Task::findOne($task_id); $balance = []; diff --git a/erp24/controllers/crud/TaskController.php b/erp24/controllers/crud/TaskController.php index a7871b43..0dd044f8 100644 --- a/erp24/controllers/crud/TaskController.php +++ b/erp24/controllers/crud/TaskController.php @@ -200,17 +200,15 @@ class TaskController extends Controller $canUpdateAll = true; $canUpdateStatusAndDuration = true; - // Логирование передаваемых переменных - Yii::info([ - 'model' => $model, - 'entities' => $entities, - 'taskEntity' => $taskEntity, - 'tasksType' => $tasksType, - 'taskStatus' => $taskStatus, - 'taskAlertLevels' => $taskAlertLevels, - 'canUpdateAll' => $canUpdateAll, - 'canUpdateStatusAndDuration' => $canUpdateStatusAndDuration - ], 'debug'); + $model->loadDefaultValues(); + $model->data_start = date("Y-m-d H:i:s"); + $model->duration = 30; + $model->name = ''; + $model->description = ''; + $model->task_type_id = 0; + $model->deadline = date("Y-m-d H:i:s", strtotime("+1 day", strtotime($model->data_start))); + + // Возвращаем HTML формы для рендеринга в модальном окне return $this->renderAjax('_form', compact('model', 'entities', 'taskEntity', 'tasksType', 'taskStatus', 'taskAlertLevels', 'canUpdateAll', 'canUpdateStatusAndDuration')); @@ -218,7 +216,10 @@ class TaskController extends Controller // Если это POST-запрос для сохранения данных if ($this->request->isPost) { + + if ($model->load($this->request->post()) && $model->save()) { + //var_dump($model->id); // Обработка taskUsers $taskUsers = Yii::$app->request->post('taskUsers'); TaskUsers::deleteAll(['task_id' => $model->id]); @@ -248,7 +249,9 @@ class TaskController extends Controller $model->group_id = 1; $model->is_completed = 0; $model->result = ''; - $model->created_by = Yii::$app->user->id; // Используем текущего пользователя + $model->created_by = $_SESSION['admin_id']; + + $model->save(false); // Сохранение файлов $model->files = UploadedFile::getInstances($model, 'files'); diff --git a/erp24/views/crud/task/_form.php b/erp24/views/crud/task/_form.php index bf8f2378..acaea75c 100755 --- a/erp24/views/crud/task/_form.php +++ b/erp24/views/crud/task/_form.php @@ -25,7 +25,7 @@ $this->registerJsFile('/js/crud/task/update.js', ['position' => \yii\web\View::P ?> -
+
['enctype' => 'multipart/form-data']]); ?> diff --git a/erp24/views/crud/task/create.php b/erp24/views/crud/task/create.php index 2ae86dbd..4a12b298 100755 --- a/erp24/views/crud/task/create.php +++ b/erp24/views/crud/task/create.php @@ -1,6 +1,7 @@ -
- +
+ Доска задач

title) ?>

render('_form', compact('model', 'entities', 'taskEntity', 'tasksType', 'taskStatus', 'taskAlertLevels', diff --git a/erp24/views/crud/task/index.php b/erp24/views/crud/task/index.php index b69c384b..4ac2afc5 100644 --- a/erp24/views/crud/task/index.php +++ b/erp24/views/crud/task/index.php @@ -4,6 +4,7 @@ use yii\helpers\Html; use yii\helpers\Url; use yii\grid\ActionColumn; use yii\grid\GridView; +use yii\helpers\HtmlPurifier; /* @var $this yii\web\View */ /* @var $dataProvider yii\data\ActiveDataProvider */ @@ -51,9 +52,10 @@ $this->params['breadcrumbs'][] = $this->title; ], [ 'attribute' => 'description', + 'label' => 'Описание задачи', 'format' => 'raw', 'value' => function ($model) { - $fullText = Html::encode($model->description); // Полный текст + $fullText = HtmlPurifier::process(nl2br($model->description)); // Полный текст $shortText = mb_substr($model->description, 0, 50); // Обрезаем до 50 символов // Если текст длиннее 50 символов, добавляем кнопку для показа полного текста @@ -72,7 +74,7 @@ $this->params['breadcrumbs'][] = $this->title; 'group_id', //'entity_id', [ - 'label' => 'entity_id', + 'label' => 'Сущность', 'value' => function ($model) { if ($model->taskEntity) { switch ($model->taskEntity->alias) { diff --git a/erp24/views/crud/task/update.php b/erp24/views/crud/task/update.php index f22b7190..6972ee7a 100755 --- a/erp24/views/crud/task/update.php +++ b/erp24/views/crud/task/update.php @@ -1,6 +1,7 @@ params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id $this->params['breadcrumbs'][] = 'Update'; ?> -
+
+ Доска задач + Назад +

Редактирование задачи: - Редактирование задачи: -

Назад name) ?>

render('_form', compact('model', 'entities', 'taskEntity', 'tasksType', 'taskStatus', 'taskAlertLevels', 'comment', diff --git a/erp24/views/task/four-columns.php b/erp24/views/task/four-columns.php index 5c89d949..aeba9908 100755 --- a/erp24/views/task/four-columns.php +++ b/erp24/views/task/four-columns.php @@ -85,19 +85,6 @@ if ($filterModel->company_function_id !== '0') { 'id' => 'create-task-button', ]) ?> - - '

Создать задачу

', - 'id' => 'create-task-modal', - 'size' => 'modal-lg', // Размер модального окна - 'footer' => '', // Убираем футер, так как не нужен - ]); ?> - -
- -
- -
@@ -386,22 +373,27 @@ $form = ActiveForm::begin(['id' => 'filter-form']); ?> if ($('#activeTasksToggle').is(':checked')) { - // Скрываем первый и последний дочерние элементы в #title-row и #column-row - $('#title-row').children(':first-child').hide(); - $('#title-row').children(':last-child').hide(); + // Скрываем первый и последний дочерние элементы в #column-row $('#column-row').children(':first-child').hide(); $('#column-row').children(':last-child').hide(); } else { - // Показываем первый и последний дочерние элементы в #title-row и #column-row - $('#title-row').children(':first-child').show(); - $('#title-row').children(':last-child').show(); + // Показываем первый и последний дочерние элементы в #column-row $('#column-row').children(':first-child').show(); $('#column-row').children(':last-child').show(); } } + +/*$(document).ready(function() { + $("#task-entity_type").select2({ + dropdownParent: $("#create-task-modal") + }); + $('.select2').each(function() { + $(this).select2({ dropdownParent: $(this).parent()}); +}) +});*/ // Изначально скрываем задачи с data-status = -1 или 6, если тумблер выключен toggleTasks(); @@ -409,18 +401,39 @@ $form = ActiveForm::begin(['id' => 'filter-form']); ?> $('#activeTasksToggle').on('change', function() { toggleTasks(); }); - - - $(document).on('click', '#create-task-button', function() { - // Отправляем AJAX-запрос для получения формы - $.get(createTaskUrl, function(data) { - // Помещаем полученный HTML в модальное окно - $('#create-task-content').html(data); - - // Открываем модальное окно - $('#create-task-modal').modal('show'); + $(document).ready(function() { + // Открытие модального окна по кнопке + $('#create-task-button').on('click', function() { + // Загружаем данные через AJAX (если нужно) + $.get(createTaskUrl, function(data) { + $('#create-task-content').html(data); + + // Показываем модальное окно + $('#create-task-modal').fadeIn(); + + // Отключаем скролл body + $('body').addClass('no-scroll'); + }); + }); + + // Закрытие модального окна + $('.close').on('click', function() { + $('#create-task-modal').fadeOut(); + + // Включаем скролл body + $('body').removeClass('no-scroll'); + }); + + // Закрытие окна при клике вне содержимого + $(window).on('click', function(event) { + if ($(event.target).is('#create-task-modal')) { + $('#create-task-modal').fadeOut(); + $('body').removeClass('no-scroll'); + } }); }); + + // Обработка формы создания задачи после отправки $(document).on('beforeSubmit', '#create-task-form', function(e) { @@ -457,22 +470,16 @@ JS;
-
-
?> - $taskStatusName):?> - -2 && $ind < 7): ?> -
- -
- - - -
+
?> $taskStatusName):?> -2 && $ind < 7): ?> -
+
+
+ +
+
status == $ind): ?> @@ -500,6 +507,7 @@ JS;
+
@@ -511,14 +519,13 @@ JS; var createTaskUrl = ''; - \ No newline at end of file + + diff --git a/erp24/views/task/index.php b/erp24/views/task/index.php index 69eeded5..e3523701 100755 --- a/erp24/views/task/index.php +++ b/erp24/views/task/index.php @@ -39,6 +39,7 @@ function writeNode($node, $selectedNode, $depth, $writePosit) { Доска задач

title) ?>

+

Всего задач:

'btn btn-success', 'target' => '_blank', 'data-pjax' => '0']) ?> @@ -52,8 +53,8 @@ function writeNode($node, $selectedNode, $depth, $writePosit) {
'filter-form', 'options' => ['data-pjax' => true]]); ?>
- 'Мои', '1' => 'На контроле', '2' => 'Участвую', '3' => 'Просматриваю', '4' => 'Неразобранные', '5' => 'Закрытые'], ['class' => 'form-control']); ?> - 'btn btn-primary']) ?> + 'Мои', '1' => 'На контроле', '2' => 'Участвую', '3' => 'Просматриваю', '4' => 'Неразобранные', '5' => 'Закрытые'], ['class' => 'form-control d-flex justify-content-between']); ?> + 'btn btn-primary countButton']) ?>
@@ -70,16 +71,16 @@ function writeNode($node, $selectedNode, $depth, $writePosit) {
'search-form', 'options' => ['data-pjax' => true]]); ?>
- 'form-control']) ?> - 'btn btn-primary']) ?> + 'form-control', 'method' => 'post']) ?> + 'btn btn-primary countButton']) ?>
- -
+ +
name ?>
+ + +