diff --git a/backend/modules/task/controllers/TaskController.php b/backend/modules/task/controllers/TaskController.php index 735e2db..e062740 100644 --- a/backend/modules/task/controllers/TaskController.php +++ b/backend/modules/task/controllers/TaskController.php @@ -2,6 +2,8 @@ namespace backend\modules\task\controllers; +use common\models\forms\TasksImportForm; +use common\services\ImportProjectTaskService; use yii\data\ActiveDataProvider; use Yii; use backend\modules\task\models\ProjectTask; @@ -137,4 +139,33 @@ class TaskController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } + + public function actionImport() + { + $model = new TasksImportForm(); + + if ($model->load(Yii::$app->request->post()) && $model->validate()) { + $importTaskService = new ImportProjectTaskService(); + + $query = ProjectTask::genQueryToImport( + (int)$model->companyId, + (int)$model->userId, + (int)$model->projectId, + (int)$model->fromDate, + (int)$model->toDate + ); + $tasks = $query->all(); + + if (!$tasks) { + Yii::$app->session->setFlash('danger', 'Задачи не найдены!'); + return Yii::$app->getResponse()->redirect(['/task/task/import']); + } else { + return $importTaskService->importTasks($tasks); + } + } + + return $this->render('_form-import', [ + 'model' => $model, + ]); + } } diff --git a/backend/modules/task/views/task/_form-import.php b/backend/modules/task/views/task/_form-import.php new file mode 100644 index 0000000..46a9d19 --- /dev/null +++ b/backend/modules/task/views/task/_form-import.php @@ -0,0 +1,79 @@ +title = 'Импорт задач'; +$this->params['breadcrumbs'][] = ['label' => 'Tasks', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> + +
= Html::a('Создать задачу', ['create'], ['class' => 'btn btn-success']) ?> + = Html::a('Импорт задач', ['import'], ['class' => 'btn btn-primary']) ?>
= GridView::widget([ diff --git a/backend/modules/task/views/task/view.php b/backend/modules/task/views/task/view.php index 0f458b1..c3bc63d 100644 --- a/backend/modules/task/views/task/view.php +++ b/backend/modules/task/views/task/view.php @@ -83,7 +83,7 @@ YiiAsset::register($this); [ 'attribute' => 'project_user_id', - 'value' => 'user.email' + 'value' => 'user.username' ], [ diff --git a/common/models/MarkEntity.php b/common/models/MarkEntity.php index 8b54a0a..b4a2265 100644 --- a/common/models/MarkEntity.php +++ b/common/models/MarkEntity.php @@ -11,6 +11,8 @@ use Yii; * @property int $mark_id * @property int $entity_type * @property int $entity_id + * + * @property Mark $mark */ class MarkEntity extends \yii\db\ActiveRecord { diff --git a/common/models/ProjectTask.php b/common/models/ProjectTask.php index 7321c9b..e93838e 100644 --- a/common/models/ProjectTask.php +++ b/common/models/ProjectTask.php @@ -29,6 +29,9 @@ use yii\helpers\ArrayHelper; * @property User $user * @property UserCard $card * @property UserCard $cardIdCreator + * @property Company $company + * @property ProjectColumn $column + * @property User $executor * @property Mark[] $mark * @property MarkEntity[] $markEntity * @property ProjectTaskUser[] $taskUsers @@ -42,6 +45,8 @@ class ProjectTask extends ActiveRecord const PRIORITY_MEDIUM = 1; const PRIORITY_HIGH = 2; + const DAY_IN_UNIX_TIME = 86340; // 23:59:59 + /** * @return string[] */ @@ -147,7 +152,7 @@ class ProjectTask extends ActiveRecord 'user_id', 'user' => function () { return [ - "fio" => $this->user->userCard->fio ?? $this->user->id, + "fio" => $this->user->userCard->fio ?? ($this->user->id ?? ''), "avatar" => $this->user->userCard->photo ?? '', ]; }, @@ -164,7 +169,7 @@ class ProjectTask extends ActiveRecord return null; }, 'comment_count' => function () { - return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count(); + return $this->getCommentCount(); }, 'taskUsers', 'mark', @@ -172,6 +177,14 @@ class ProjectTask extends ActiveRecord ]; } + /** + * @return bool|int|string|null + */ + public function getCommentCount() + { + return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count(); + } + /** * @return string[] */ @@ -215,6 +228,15 @@ class ProjectTask extends ActiveRecord return $this->hasOne(Project::className(), ['id' => 'project_id']); } + /** + * @return ActiveQuery + */ + public function getCompany(): ActiveQuery + { + return $this->hasOne(Company::class,['id' => 'company_id']) + ->via('project'); + } + /** * @return ActiveQuery */ @@ -275,4 +297,71 @@ class ProjectTask extends ActiveRecord return ArrayHelper::map( self::find()->joinWith(['user', 'project'])->where(['project_id' => $task_id])->all(), 'id', 'user.username'); } + + /** + * @return string + */ + public function getTaskUsersToStr(): string + { + $participants = ''; + foreach ($this->taskUsers as $taskUser) { + $participants .= $taskUser->user->userCard->fio ?? $taskUser->user->username; + $participants .= ', '; + } + return $participants; + } + + /** + * @return string + */ + public function getMarkTitleToStr(): string + { + $tags = ''; + foreach ($this->markEntity as $markEntity) { + $tags .= $markEntity->mark->title . ', '; + } + return $tags; + } + + /** + * @param int|null $companyId + * @param int|null $userId + * @param int|null $projectId + * @param int|null $fromDate + * @param int|null $toDate + * @return ActiveQuery + */ + public static function genQueryToImport( + int $companyId = null, + int $userId = null, + int $projectId = null, + int $fromDate = null, + int $toDate = null + ): ActiveQuery + { + $query = ProjectTask::find(); + + if ($companyId) { + $query->joinWith('company') + ->andWhere(['company.id' => $companyId]); + } + + if ($userId) { + $query->andWhere(['project_task.user_id' => $userId]); + } + + if ($projectId) { + $query->andWhere(['project_task.project_id' => $projectId]); + } + + if ($fromDate) { + $query->andFilterWhere(['>=', 'project_task.created_at', date("Y-m-d H:i:s", $fromDate)]); + } + + if ($toDate) { + $query->andFilterWhere(['<=', 'project_task.created_at', date("Y-m-d H:i:s", ($toDate + self::DAY_IN_UNIX_TIME))]); + } + + return $query; + } } diff --git a/common/models/ProjectTaskUser.php b/common/models/ProjectTaskUser.php index fb22cec..89fddf0 100644 --- a/common/models/ProjectTaskUser.php +++ b/common/models/ProjectTaskUser.php @@ -11,8 +11,8 @@ use yii\db\ActiveQuery; * @property int $task_id * @property int $user_id * - * @property ProjectUser $projectUser * @property ProjectTask $task + * @property User $user */ class ProjectTaskUser extends \yii\db\ActiveRecord { diff --git a/common/models/forms/TasksImportForm.php b/common/models/forms/TasksImportForm.php new file mode 100644 index 0000000..21ee733 --- /dev/null +++ b/common/models/forms/TasksImportForm.php @@ -0,0 +1,44 @@ + 'php:Y-m-d', 'timestampAttribute' => 'fromDate'], + ['toDate', 'date', 'format' => 'php:Y-m-d', 'timestampAttribute' => 'toDate'], + ]; + } + + public function attributeLabels() + { + return [ + 'companyId' => 'ID компании', + 'userId' => 'ID пользователя', + 'projectId' => 'ID проекта', + 'fromDate' => 'Дата начала поиска', + 'toDate' => 'Дата конца поиска', + ]; + } + + /** + * @return string + */ + public function formName(): string + { + return ''; + } +} diff --git a/common/services/ImportProjectTaskService.php b/common/services/ImportProjectTaskService.php new file mode 100644 index 0000000..4cb8699 --- /dev/null +++ b/common/services/ImportProjectTaskService.php @@ -0,0 +1,78 @@ +getActiveSheet(); + + $sheet + ->setCellValue('A1', 'ID') + ->setCellValue('B1', 'ID проекта') + ->setCellValue('C1', 'Название проекта') + ->setCellValue('D1', 'Задача') + ->setCellValue('E1', 'Дата создания') + ->setCellValue('F1', 'Дата обновления') + ->setCellValue('G1', 'Дедлайн') + ->setCellValue('H1', 'Описание') + ->setCellValue('I1', 'Статус') + ->setCellValue('J1', 'Колонка') + ->setCellValue('G1', 'ID создателя задачи') + ->setCellValue('K1', 'Создатель задачи') + ->setCellValue('L1', 'ID исполнителя') + ->setCellValue('M1', 'Приоритет') + ->setCellValue('N1', 'Исполнитель') + ->setCellValue('O1', 'Количество коментариев') + ->setCellValue('P1', 'Участники') + ->setCellValue('Q1', 'Теги') + ->setCellValue('R1', 'Приоритет выполнения'); + + $i = 2; + /** @var ProjectTask $task */ + foreach ($tasks as $task) { + $sheet + ->setCellValue('A' . $i, $task->id) + ->setCellValue('B' . $i, $task->project_id) + ->setCellValue('C' . $i, $task->project->name) + ->setCellValue('D' . $i, $task->title) + ->setCellValue('E' . $i, $task->created_at) + ->setCellValue('F' . $i, $task->updated_at) + ->setCellValue('G' . $i, $task->dead_line) + ->setCellValue('H' . $i, $task->description) + ->setCellValue('I' . $i, ArrayHelper::getValue(ProjectTask::getStatus(), $task->status)) + ->setCellValue('J' . $i, $task->column->title) + ->setCellValue('G' . $i, $task->user_id) + ->setCellValue('K' . $i, $task->user->userCard->fio ?? ($task->user->username ?? 'kkk')) + ->setCellValue('L' . $i, $task->executor_id) + ->setCellValue('M' . $i, $task->priority) + ->setCellValue('N' . $i, $task->executor->userCard->fio ?? ($task->executor->username ?? 'ggg')) + ->setCellValue('O' . $i, $task->getCommentCount()) + ->setCellValue('P' . $i, $task->getTaskUsersToStr()) + ->setCellValue('Q' . $i, $task->getMarkTitleToStr()) + ->setCellValue('R' . $i, $task->execution_priority); + $i++; + } + + $writer = new Xlsx($spreadsheet); + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); + header('Content-Disposition: attachment; filename="'. urlencode('tasks.xlsx').'"'); + $writer->save('php://output'); + exit(); + } catch (\Exception $ex) { + return $ex->getMessage(); + } + } +} \ No newline at end of file diff --git a/common/services/TaskService.php b/common/services/TaskService.php deleted file mode 100644 index 835cd82..0000000 --- a/common/services/TaskService.php +++ /dev/null @@ -1,57 +0,0 @@ -load($taskParams, ''); - $task->save(); - return $task; - } - - public static function getTask($task_id): ?ProjectTask - { - return ProjectTask::findOne($task_id); - } - - public static function getTaskList($task_id): array - { - return ProjectTask::find()->asArray()->all(); - } - - public static function getTaskListByProject($project_id): array - { - return ProjectTask::find()->where(['project_id' => $project_id])->orderBy('priority DESC')->all(); - } - - public static function getTaskListByUser($user_id): array - { - $taskIdList = ProjectTaskUser::find()->where(['user_id' => $user_id])->select('task_id')->column(); - return ProjectTask::find()->where([ 'IN', 'id', $taskIdList])->orWhere(['user_id' => $user_id])->orderBy('priority DESC')->all(); - } - - public static function updateTask($task_params): ?ProjectTask - { - $modelTask = ProjectTask::findOne($task_params['task_id']); - - if (isset($task_params['executor_id']) && $task_params['executor_id'] == 0){ - $task_params['executor_id'] = null; - } - - $modelTask->load($task_params, ''); - $modelTask->save(); - - return $modelTask; - } - - public static function taskExists($task_id): bool - { - return ProjectTask::find()->where(['id' => $task_id])->exists(); - } -} \ No newline at end of file diff --git a/composer.json b/composer.json index dc0f9ed..f23ceb5 100755 --- a/composer.json +++ b/composer.json @@ -37,7 +37,9 @@ "kartik-v/yii2-mpdf": "dev-master", "mihaildev/yii2-ckeditor": "*", "developeruz/yii2-db-rbac": "*", - "zircote/swagger-php": "^4.7" + "zircote/swagger-php": "^4.7", + "phpoffice/phpspreadsheet": "^1.29", + "kartik-v/yii2-widget-datepicker": "dev-master" }, "require-dev": { "yiisoft/yii2-debug": "~2.0.0", diff --git a/frontend/modules/api/controllers/ProjectColumnController.php b/frontend/modules/api/controllers/ProjectColumnController.php index e690a02..f463c96 100644 --- a/frontend/modules/api/controllers/ProjectColumnController.php +++ b/frontend/modules/api/controllers/ProjectColumnController.php @@ -2,25 +2,14 @@ namespace frontend\modules\api\controllers; -use common\classes\Debug; use common\models\ProjectColumn; -use frontend\modules\api\models\Project; +use frontend\modules\api\models\project\Project; +use yii\db\ActiveRecord; use yii\web\BadRequestHttpException; use yii\web\NotFoundHttpException; class ProjectColumnController extends ApiController { - - public function verbs(): array - { - return [ - 'get-column-list' => ['get'], - 'create-column' => ['post'], - 'set-priority' => ['post'], - 'update-column' => ['put', 'patch'], - ]; - } - /** * * @OA\Get(path="/project-column/get-column-list", @@ -49,17 +38,17 @@ class ProjectColumnController extends ApiController * ) * * @param $project_id - * @return array|\yii\db\ActiveRecord[] + * @return array|ActiveRecord[] * @throws BadRequestHttpException */ - public function actionGetColumnList($project_id) + public function actionGetColumnList($project_id): array { $project = Project::findOne($project_id); if (!$project) { throw new BadRequestHttpException(json_encode(['Проект не найден'])); } - $columns = \frontend\modules\api\models\ProjectColumn::find()->where(['project_id' => $project_id, 'status' => ProjectColumn::STATUS_ACTIVE])->all(); + $columns = \frontend\modules\api\models\project\ProjectColumn::find()->where(['project_id' => $project_id, 'status' => ProjectColumn::STATUS_ACTIVE])->all(); return $columns; @@ -177,7 +166,7 @@ class ProjectColumnController extends ApiController * ), * ) * - * @return array|ProjectColumn|\yii\db\ActiveRecord|null + * @return array|ProjectColumn|ActiveRecord|null * @throws BadRequestHttpException * @throws \yii\base\InvalidConfigException */ @@ -241,7 +230,7 @@ class ProjectColumnController extends ApiController * ), * ) * - * @return array|Project|\yii\db\ActiveRecord + * @return array|Project|ActiveRecord * @throws BadRequestHttpException */ public function actionSetPriority() diff --git a/frontend/modules/api/controllers/ProjectController.php b/frontend/modules/api/controllers/ProjectController.php index 25ab4c3..68692f6 100644 --- a/frontend/modules/api/controllers/ProjectController.php +++ b/frontend/modules/api/controllers/ProjectController.php @@ -2,15 +2,16 @@ namespace frontend\modules\api\controllers; -use common\classes\Debug; use common\models\ProjectTaskCategory; use common\models\Status; use common\models\UseStatus; use frontend\modules\api\models\Manager; -use frontend\modules\api\models\Project; -use frontend\modules\api\models\ProjectUser; +use frontend\modules\api\models\project\Project; +use frontend\modules\api\models\project\ProjectUser; use Yii; +use yii\base\InvalidConfigException; use yii\data\ActiveDataProvider; +use yii\db\ActiveRecord; use yii\helpers\ArrayHelper; use yii\web\BadRequestHttpException; use yii\web\NotFoundHttpException; @@ -84,7 +85,7 @@ class ProjectController extends ApiController * ) * * @param $project_id - * @return array|Project|\yii\db\ActiveRecord|null + * @return array|ActiveRecord|null */ public function actionGetProject($project_id) { @@ -323,7 +324,7 @@ class ProjectController extends ApiController * ) * * @throws \Throwable - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException * @throws \yii\db\StaleObjectException * @throws NotFoundHttpException */ @@ -366,7 +367,7 @@ class ProjectController extends ApiController * ), * ) * - * @return array|\yii\db\ActiveRecord + * @return array|ActiveRecord * @throws BadRequestHttpException */ public function actionMyEmployee() @@ -486,7 +487,7 @@ class ProjectController extends ApiController * ) * * @return Project - * @throws \yii\base\InvalidConfigException + * @throws InvalidConfigException|NotFoundHttpException */ public function actionDelUser(): Project { diff --git a/frontend/modules/api/controllers/TaskController.php b/frontend/modules/api/controllers/TaskController.php index 77d830c..47f7908 100644 --- a/frontend/modules/api/controllers/TaskController.php +++ b/frontend/modules/api/controllers/TaskController.php @@ -2,31 +2,32 @@ namespace frontend\modules\api\controllers; -use common\classes\Debug; use common\models\ProjectTask; use common\models\ProjectTaskUser; use common\models\User; -use common\services\TaskService; -use frontend\modules\api\models\ProjectColumn; +use frontend\modules\api\models\project\ProjectColumn; +use frontend\modules\api\services\TaskService; use Yii; use yii\base\InvalidConfigException; +use yii\data\ActiveDataProvider; use yii\web\BadRequestHttpException; use yii\web\NotFoundHttpException; use yii\web\ServerErrorHttpException; class TaskController extends ApiController { - public function verbs(): array + private TaskService $taskService; + + /** + * @param $id + * @param $module + * @param TaskService $taskService + * @param array $config + */ + public function __construct($id, $module, TaskService $taskService, $config = []) { - return [ - 'get-task' => ['get'], - 'get-task-list' => ['get'], - 'get-user-tasks' => ['get'], - 'create-task' => ['post'], - 'update-task' => ['put', 'patch'], - 'add-user-to-task' => ['post'], - 'del-user' => ['delete'], - ]; + $this->taskService = $taskService; + parent::__construct($id, $module, $config); } /** @@ -117,7 +118,7 @@ class TaskController extends ApiController $request['user_id'] = Yii::$app->user->id; } - $taskModel = TaskService::createTask($request); + $taskModel = $this->taskService->createTask($request); if ($taskModel->errors) { throw new ServerErrorHttpException(json_encode($taskModel->errors)); } @@ -170,9 +171,9 @@ class TaskController extends ApiController if (empty($project_id) or !is_numeric($project_id)) { throw new NotFoundHttpException('Incorrect project ID'); } - $tasks = TaskService::getTaskListByProject($project_id); + $tasks = $this->taskService->getTaskListByProject($project_id); } else { - $tasks = TaskService::getTaskList($project_id); + $tasks = $this->taskService->getTaskList($project_id); } if (empty($tasks)) { @@ -228,9 +229,9 @@ class TaskController extends ApiController if (empty($user_id) or !is_numeric($user_id)) { throw new NotFoundHttpException('Incorrect project ID'); } - $tasks = TaskService::getTaskListByUser($user_id); + $tasks = $this->taskService->getTaskListByUser($user_id); } else { - $tasks = TaskService::getTaskList($user_id); + $tasks = $this->taskService->getTaskList($user_id); } if (empty($tasks)) { @@ -283,7 +284,7 @@ class TaskController extends ApiController throw new NotFoundHttpException('Incorrect task ID'); } - $task = TaskService::getTask($task_id); + $task = $this->taskService->getTask($task_id); if (empty($task)) { throw new NotFoundHttpException('The task does not exist'); } @@ -372,11 +373,11 @@ class TaskController extends ApiController public function actionUpdateTask(): ?ProjectTask { $params = array_diff(\Yii::$app->request->getBodyParams(), [null, '']); - if (empty ($params['task_id']) or !TaskService::taskExists($params['task_id'])) { + if (empty ($params['task_id']) or !$this->taskService->taskExists($params['task_id'])) { throw new NotFoundHttpException('The task does not exist'); } - $modelTask = TaskService::updateTask($params); + $modelTask = $this->taskService->updateTask($params); if (!empty($modelTask->hasErrors())) { throw new ServerErrorHttpException(json_encode($modelTask->errors)); } @@ -435,7 +436,7 @@ class TaskController extends ApiController throw new NotFoundHttpException('User not found'); } - if (empty ($request['task_id']) or !TaskService::taskExists($request['task_id'])) { + if (empty ($request['task_id']) or !$this->taskService->taskExists($request['task_id'])) { throw new NotFoundHttpException('The task does not exist'); } @@ -506,13 +507,13 @@ class TaskController extends ApiController throw new NotFoundHttpException('User not found'); } - if (empty ($request['task_id']) or !TaskService::taskExists($request['task_id'])) { + if (empty ($request['task_id']) or !$this->taskService->taskExists($request['task_id'])) { throw new NotFoundHttpException('The task does not exist'); } ProjectTaskUser::deleteAll(['task_id' => $request['task_id'], 'user_id' => $request['user_id']]); - return TaskService::getTask($request['task_id']); + return $this->taskService->getTask($request['task_id']); } /** @@ -582,4 +583,72 @@ class TaskController extends ApiController return $column; } + + /** + * + * @OA\Get(path="/task/import", + * summary="Экспорт задач", + * description="Метод экспорта задач в xlsx", + * security={ + * {"bearerAuth": {}} + * }, + * tags={"TaskManager"}, + * @OA\Parameter( + * name="companyId", + * in="query", + * description="ID компании", + * required=true, + * @OA\Schema( + * type="integer", + * ) + * ), + * @OA\Parameter( + * name="userId", + * in="query", + * description="ID исполнителя задачи", + * required=true, + * @OA\Schema( + * type="integer", + * ) + * ), + * @OA\Parameter( + * name="projectId", + * in="query", + * description="ID проекта", + * required=true, + * @OA\Schema( + * type="integer", + * ) + * ), + * @OA\Parameter( + * name="fromDate", + * in="query", + * example="2023-11-09", + * description="Поиск задач с указанной даты", + * @OA\Schema( + * type="string", + * ) + * ), + * @OA\Parameter( + * name="toDate", + * in="query", + * example="2023-11-09", + * description="Поиск задач до указанной даты", + * @OA\Schema( + * type="string", + * ) + * ), + * @OA\Response( + * response=200, + * description="Возвращает задачи в xlsx файле", + * ), + * ) + * + * @return string|void + * @throws BadRequestHttpException + */ + public function actionImport() + { + return $this->taskService->importTasks(Yii::$app->request->get()); + } } \ No newline at end of file diff --git a/frontend/modules/api/models/Project.php b/frontend/modules/api/models/project/Project.php similarity index 97% rename from frontend/modules/api/models/Project.php rename to frontend/modules/api/models/project/Project.php index 34ce13f..9e85130 100644 --- a/frontend/modules/api/models/Project.php +++ b/frontend/modules/api/models/project/Project.php @@ -1,7 +1,8 @@ importProjectTaskService = $importProjectTaskService; + } + + public function createTask($taskParams) + { + $task = new ProjectTask(); + $task->load($taskParams, ''); + $task->save(); + return $task; + } + + public function getTask($task_id): ?ProjectTask + { + return ProjectTask::findOne($task_id); + } + + public function getTaskList($task_id): array + { + return ProjectTask::find()->asArray()->all(); + } + + public function getTaskListByProject($project_id): array + { + return ProjectTask::find()->where(['project_id' => $project_id])->orderBy('priority DESC')->all(); + } + + public function getTaskListByUser($user_id): array + { + $taskIdList = ProjectTaskUser::find()->where(['user_id' => $user_id])->select('task_id')->column(); + return ProjectTask::find()->where([ 'IN', 'id', $taskIdList])->orWhere(['user_id' => $user_id])->orderBy('priority DESC')->all(); + } + + public function updateTask($task_params): ?ProjectTask + { + $modelTask = ProjectTask::findOne($task_params['task_id']); + + if (isset($task_params['executor_id']) && $task_params['executor_id'] == 0){ + $task_params['executor_id'] = null; + } + + $modelTask->load($task_params, ''); + $modelTask->save(); + + return $modelTask; + } + + public function taskExists($task_id): bool + { + return ProjectTask::find()->where(['id' => $task_id])->exists(); + } + + /** + * @throws BadRequestHttpException + */ + public function importTasks(array $params) + { + $form = new TasksImportForm(); + $form->load($params); + + if (!$form->validate()){ + $errors = $form->errors; + throw new BadRequestHttpException(array_shift($errors)[0]); + } + + $query = ProjectTask::genQueryToImport( + $form->companyId, + $form->userId, + $form->projectId, + $form->fromDate, + $form->toDate + ); + + $tasks = $query->all(); + + if (!$tasks) { + return null; + } + + return $this->importProjectTaskService->importTasks($tasks); + } +} \ No newline at end of file