$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')])
$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');
'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
--- /dev/null
+<?php
+
+namespace yii_app\controllers\crud;
+
+
+use Yii;
+use yii_app\records\TaskEntity;
+use yii\data\ActiveDataProvider;
+use yii\web\Controller;
+use yii\web\NotFoundHttpException;
+use yii\filters\VerbFilter;
+
+class TaskEntityController extends Controller
+{
+ public function behaviors()
+ {
+ return [
+ 'verbs' => [
+ '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
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;
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;
}
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) {
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;
}
}
}
--- /dev/null
+<?php
+use yii\helpers\Html;
+use yii\widgets\ActiveForm;
+?>
+
+<div class="task-entity-form">
+ <?php $form = ActiveForm::begin(); ?>
+ <?= $form->field($model, 'name')->textInput(['maxlength' => true])->label('Имя') ?>
+ <?= $form->field($model, 'alias')->textInput(['maxlength' => true])->label('Псевдоним') ?>
+ <div class="form-group">
+ <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+ </div>
+ <?php ActiveForm::end(); ?>
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-danger']) ?>
+
+</div>
--- /dev/null
+<?php
+use yii\helpers\Html;
+
+$this->title = 'Создание типа сущности';
+$this->params['breadcrumbs'][] = ['label' => 'Task Entities', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="task-entity-create p-4">
+ <h1><?= Html::encode($this->title) ?></h1>
+ <?= $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+</div>
--- /dev/null
+<?php
+use yii\helpers\Html;
+use yii\grid\GridView;
+
+$this->title = 'Тип сущности';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="task-entity-index p-4">
+ <h1><?= Html::encode($this->title) ?></h1>
+ <p>
+ <?= Html::a('Создать', ['create'], ['class' => 'btn btn-success']) ?>
+ </p>
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+ 'id',
+ 'name',
+ 'alias',
+ ['class' => 'yii\grid\ActionColumn'],
+ ],
+ ]); ?>
+</div>
--- /dev/null
+<?php
+use yii\helpers\Html;
+
+$this->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';
+?>
+<div class="task-entity-update p-4">
+ <h1><?= Html::encode($this->title) ?></h1>
+ <?= $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+</div>
--- /dev/null
+<?php
+use yii\helpers\Html;
+use yii\widgets\DetailView;
+
+$this->title = $model->name;
+$this->params['breadcrumbs'][] = ['label' => 'Task Entities', 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="task-entity-view p-4">
+ <h1><?= Html::encode($this->title) ?></h1>
+ <p>
+ <?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
+ <?= Html::a('Удалить', ['delete', 'id' => $model->id], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => 'Вы уверены что хотите удалить эту запись?',
+ 'method' => 'post',
+ ],
+ ]) ?>
+ </p>
+ <?= DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id',
+ 'name',
+ 'alias',
+ ],
+ ]) ?>
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-danger']) ?>
+</div>
\ No newline at end of file
'pluginEvents' => [
"change" => "function() {
var value= $(this).val();
-
+ console.log(value);
$.ajax({
method: 'POST',
dataType: 'text',
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);
use \kartik\select2\Select2;
use dosamigos\datepicker\DatePicker;
-
+use yii\helpers\ArrayHelper;
use \yii_app\helpers\PrintBlockHelper;
/** @var array $tasks */
])->label(false) ?>
</div>
</div>
-
+<div class="row">
+ <div class="col-2">
+ <?= $form->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) ?>
+ </div>
+ <div class="col-2">
+ <?= $form->field($filterModel, 'entity_id')->widget(Select2::class, [
+ 'data' => $entities, // Изначально пустой или предзагруженные сущности
+ 'language' => 'ru',
+ 'options' => ['placeholder' => 'Сущность...'],
+ 'pluginOptions' => [
+ 'allowClear' => true,
+ ]
+ ])->label(false) ?>
+ </div>
+</div>
<div class="row">
<div class="col-3">
<div class="row">
</div>
</div>
+
<?php ActiveForm::end() ?>
+<div class="row">
+ <div class="col-4">
+ <?= Html::a('Создать задачу', ['/crud/task/create'], ['class' => 'btn btn-success', 'target' => '_blank', 'data-pjax' => '0']) ?>
+ </div>
+
+</div>
<div class="card mt-2">
<div class="row g-0">
<?php if (isset($taskStatuses)): //<div class="col-1 font-weight-bold"></div> ?>