From: vladfo Date: Mon, 16 Sep 2024 15:02:03 +0000 (+0300) Subject: задачи X-Git-Tag: 1.5~5^2~16 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=95fcd1294a8eec7c053abf48f3583b2e0d351098;p=erp24_rep%2Fyii-erp24%2F.git задачи --- diff --git a/erp24/actions/task/FourColumnsAction.php b/erp24/actions/task/FourColumnsAction.php index dfd54c41..aa529e42 100755 --- a/erp24/actions/task/FourColumnsAction.php +++ b/erp24/actions/task/FourColumnsAction.php @@ -75,6 +75,14 @@ class FourColumnsAction extends Action $tasksQuery = $tasksQuery->andWhere(['like', 'created_by', $filterModel->createdBy]); } + if ((int)$filterModel->entity_type > 0) { + $tasksQuery = $tasksQuery->andWhere(['entity_type_id' => $filterModel->entity_type]); + } + + if ((int)$filterModel->entity_id > 0) { + $tasksQuery = $tasksQuery->andWhere(['entity_id' => $filterModel->entity_id]); + } + $tasksQuery = $tasksQuery ->andWhere(['>=', 'created_at', DateTime::createFromFormat('d.m.Y', $filterModel->created_at_from)->format('Y-m-d 00:00:00')]) ->andWhere(['<=', 'created_at', DateTime::createFromFormat('d.m.Y', $filterModel->created_at_to)->format('Y-m-d 23:59:59')]) @@ -108,6 +116,8 @@ class FourColumnsAction extends Action $tasksQuery = $eit ? $tasksQuery->joinWith('companyFunction')->andWhere(['entity' => 'store'])->andWhere(['function_entity_id' => $eit->export_val])->andWhere(['or', ['updated_by' => 0], ['updated_by' => null]]) : null; } + + $tasks = $tasksQuery ? $tasksQuery->andWhere(['or', ['task.parent_id' => 0], ['task.parent_id' => null]])->all() : []; $taskStatuses = ArrayHelper::map(TaskStatus::find()->all(), 'id', 'name'); diff --git a/erp24/controllers/TaskController.php b/erp24/controllers/TaskController.php index 221a480c..04f6bb43 100755 --- a/erp24/controllers/TaskController.php +++ b/erp24/controllers/TaskController.php @@ -28,4 +28,16 @@ class TaskController extends \yii\web\Controller 'support' => SupportAction::class, ]; } + + public function actionGetEntities() + { + if (Yii::$app->request->isAjax) { + $entityTypeId = Yii::$app->request->post('entity_type'); + $entities = Entity::find()->where(['entity_type_id' => $entityTypeId])->all(); + + // Вернем JSON ответ с сущностями + Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + return ArrayHelper::map($entities, 'id', 'name'); + } + } } \ No newline at end of file diff --git a/erp24/controllers/crud/TaskEntityController.php b/erp24/controllers/crud/TaskEntityController.php new file mode 100644 index 00000000..fb43f43e --- /dev/null +++ b/erp24/controllers/crud/TaskEntityController.php @@ -0,0 +1,86 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + public function actionIndex() + { + $dataProvider = new ActiveDataProvider([ + 'query' => TaskEntity::find(), + ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + ]); + } + + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + public function actionCreate() + { + $model = new TaskEntity(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('create', [ + 'model' => $model, + ]); + } + + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } + + return $this->render('update', [ + 'model' => $model, + ]); + } + + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + protected function findModel($id) + { + if (($model = TaskEntity::findOne($id)) !== null) { + return $model; + } + + throw new NotFoundHttpException('The requested page does not exist.'); + } +} \ No newline at end of file diff --git a/erp24/services/TaskService.php b/erp24/services/TaskService.php index c0e6f06e..d9ecef01 100644 --- a/erp24/services/TaskService.php +++ b/erp24/services/TaskService.php @@ -6,6 +6,7 @@ use yii\helpers\ArrayHelper; use yii_app\records\Admin; use yii_app\records\Files; use yii_app\records\Lessons; +use yii_app\records\UniversalCatalogItem; use yii_app\records\Products1c; use yii_app\records\Task; use yii_app\records\TaskStatus; @@ -18,6 +19,7 @@ class TaskService switch ($alias) { case 'matrix': return ArrayHelper::map(Products1c::find()->joinWith('productClass pc')->where(['pc.tip' => 'matrix'])->all(), 'id', 'name'); case "lesson": return ArrayHelper::map(Lessons::find()->all(), 'id', 'name'); + case "bpmn": return ArrayHelper::map(UniversalCatalogItem::find()->where(['catalog_alias' => 'bpmn'])->all(), 'id', 'name'); case 'store': return ArrayHelper::map(Products1c::find()->where(['tip' => 'city_store'])->andWhere(['view' => '1'])->orderBy('name')->all(), 'id', 'name'); case "lesson_group": break; } @@ -175,26 +177,50 @@ class TaskService switch ($task->status) { case 1: case 2: - TelegramService::sendMessage($task->updated_by, $msg, $reply_markup_updated_by); break; + try { + TelegramService::sendMessage($task->updated_by, $msg, $reply_markup_updated_by); + } catch (\Exception $e) { + + error_log("Error sending message to updated_by: " . $e->getMessage()); + } + break; case -1: case 3: case 4: case 5: case 6: - TelegramService::sendMessage($task->updated_by, $msg . "(исполнителю)", $reply_markup_info); break; + try { + TelegramService::sendMessage($task->updated_by, $msg . "(исполнителю)", $reply_markup_info); + } catch (\Exception $e) { + + error_log("Error sending message to updated_by: " . $e->getMessage()); + } + break; } } if ($task->controller_id && ($task->controller_id != $task->updated_by || $task->status == 5)) { switch ($task->status) { case 5: - TelegramService::sendMessage($task->controller_id, $msg, $reply_markup_controller); break; + try { + TelegramService::sendMessage($task->controller_id, $msg, $reply_markup_controller); + } catch (\Exception $e) { + + error_log("Error sending message to controller_id: " . $e->getMessage()); + } + break; case -1: case 1: case 2: case 3: case 4: case 6: - TelegramService::sendMessage($task->controller_id, $msg . "(контроллеру)", $reply_markup_info); break; + try { + TelegramService::sendMessage($task->controller_id, $msg . "(контроллеру)", $reply_markup_info); + } catch (\Exception $e) { + + error_log("Error sending message to controller_id: " . $e->getMessage()); + } + break; } } if ($task->created_by && $task->created_by != $task->controller_id && $task->created_by != $task->updated_by) { @@ -206,7 +232,13 @@ class TaskService case 4: case 5: case 6: - TelegramService::sendMessage($task->created_by, $msg . "(создателю)", $reply_markup_info); break; + try { + TelegramService::sendMessage($task->created_by, $msg . "(создателю)", $reply_markup_info); + } catch (\Exception $e) { + + error_log("Error sending message to created_by: " . $e->getMessage()); + } + break; } } } diff --git a/erp24/views/crud/task-entity/_form.php b/erp24/views/crud/task-entity/_form.php new file mode 100644 index 00000000..a0da5da3 --- /dev/null +++ b/erp24/views/crud/task-entity/_form.php @@ -0,0 +1,16 @@ + + +
+ + field($model, 'name')->textInput(['maxlength' => true])->label('Имя') ?> + field($model, 'alias')->textInput(['maxlength' => true])->label('Псевдоним') ?> +
+ 'btn btn-success']) ?> +
+ + 'btn btn-danger']) ?> + +
diff --git a/erp24/views/crud/task-entity/create.php b/erp24/views/crud/task-entity/create.php new file mode 100644 index 00000000..4a557065 --- /dev/null +++ b/erp24/views/crud/task-entity/create.php @@ -0,0 +1,13 @@ +title = 'Создание типа сущности'; +$this->params['breadcrumbs'][] = ['label' => 'Task Entities', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+ render('_form', [ + 'model' => $model, + ]) ?> +
diff --git a/erp24/views/crud/task-entity/index.php b/erp24/views/crud/task-entity/index.php new file mode 100644 index 00000000..fcd7dd37 --- /dev/null +++ b/erp24/views/crud/task-entity/index.php @@ -0,0 +1,23 @@ +title = 'Тип сущности'; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'id', + 'name', + 'alias', + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/erp24/views/crud/task-entity/update.php b/erp24/views/crud/task-entity/update.php new file mode 100644 index 00000000..a96990b3 --- /dev/null +++ b/erp24/views/crud/task-entity/update.php @@ -0,0 +1,14 @@ +title = 'Редактирование типа сущности: ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Task Entities', 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = 'Update'; +?> +
+

title) ?>

+ render('_form', [ + 'model' => $model, + ]) ?> +
diff --git a/erp24/views/crud/task-entity/view.php b/erp24/views/crud/task-entity/view.php new file mode 100644 index 00000000..50879560 --- /dev/null +++ b/erp24/views/crud/task-entity/view.php @@ -0,0 +1,30 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Task Entities', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+

title) ?>

+

+ $model->id], ['class' => 'btn btn-primary']) ?> + $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Вы уверены что хотите удалить эту запись?', + 'method' => 'post', + ], + ]) ?> +

+ $model, + 'attributes' => [ + 'id', + 'name', + 'alias', + ], + ]) ?> + 'btn btn-danger']) ?> +
\ No newline at end of file diff --git a/erp24/views/crud/task/_form.php b/erp24/views/crud/task/_form.php index e08171dd..f511f181 100755 --- a/erp24/views/crud/task/_form.php +++ b/erp24/views/crud/task/_form.php @@ -52,7 +52,7 @@ $this->registerJsFile('/js/crud/task/update.js', ['position' => \yii\web\View::P 'pluginEvents' => [ "change" => "function() { var value= $(this).val(); - + console.log(value); $.ajax({ method: 'POST', dataType: 'text', @@ -60,6 +60,7 @@ $this->registerJsFile('/js/crud/task/update.js', ['position' => \yii\web\View::P 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); diff --git a/erp24/views/task/four-columns.php b/erp24/views/task/four-columns.php index 5e3c2845..749100e2 100755 --- a/erp24/views/task/four-columns.php +++ b/erp24/views/task/four-columns.php @@ -5,7 +5,7 @@ use yii\helpers\Html; use \kartik\select2\Select2; use dosamigos\datepicker\DatePicker; - +use yii\helpers\ArrayHelper; use \yii_app\helpers\PrintBlockHelper; /** @var array $tasks */ @@ -61,7 +61,45 @@ $this->registerJsFile('/js/task/four-columns.js', ['position' => \yii\web\View:: ])->label(false) ?> - +
+
+ field($filterModel, 'entity_type')->widget(Select2::class, [ + 'data' => ArrayHelper::map($taskEntityTypes, 'id', 'name'), // Типы сущностей + 'language' => 'ru', + 'options' => ['placeholder' => 'Тип сущности...'], + 'pluginOptions' => [ + 'allowClear' => true, + ], + 'pluginEvents' => [ + "change" => "function() { + var entityType = $(this).val(); + $.ajax({ + method: 'POST', + url: '/path/to/get-entities', // Указать URL для получения сущностей по типу + data: { entity_type: entityType }, + success: function(data) { + var entitiesDropdown = $('#dynamicmodel-entity_id'); + entitiesDropdown.empty(); // Очистить предыдущие значения + $.each(data, function(index, value) { + entitiesDropdown.append(new Option(value, index)); + }); + } + }); + }" + ] + ])->label(false) ?> +
+
+ field($filterModel, 'entity_id')->widget(Select2::class, [ + 'data' => $entities, // Изначально пустой или предзагруженные сущности + 'language' => 'ru', + 'options' => ['placeholder' => 'Сущность...'], + 'pluginOptions' => [ + 'allowClear' => true, + ] + ])->label(false) ?> +
+
@@ -196,8 +234,15 @@ $this->registerJsFile('/js/task/four-columns.js', ['position' => \yii\web\View::
+ +
+
+ 'btn btn-success', 'target' => '_blank', 'data-pjax' => '0']) ?> +
+ +
?>