From 2a422a72225dc65a38786b05b00990e5dbd8f05c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 12 May 2024 00:06:28 +0000 Subject: [PATCH] bug fixes --- .github/workflows/greetings.yml | 2 +- Controller/ApiController.php | 48 +++++++++++++++++++++++++- Controller/BackendController.php | 4 +-- Theme/Backend/report-create.tpl.php | 2 +- Theme/Backend/report-dashboard.tpl.php | 21 +---------- Theme/Backend/report-view.tpl.php | 6 ++-- 6 files changed, 55 insertions(+), 28 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index adb8716..75cb759 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -9,5 +9,5 @@ jobs: - uses: actions/first-interaction@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: 'Thank you for createing this issue. We will check it as soon as possible.' + issue-message: 'Thank you for creating this issue. We will check it as soon as possible.' pr-message: 'Thank you for your pull request. We will check it as soon as possible.' diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7049a1f..3884a96 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -14,9 +14,12 @@ declare(strict_types=1); namespace Modules\QualityManagement\Controller; +use Attribute; +use Modules\Admin\Models\NullAccount; use Modules\Notification\Models\NotificationType; use Modules\QualityManagement\Models\Report; use Modules\QualityManagement\Models\ReportMapper; +use Modules\Tasks\Models\Attribute\TaskAttributeTypeMapper; use Modules\Tasks\Models\TaskElementMapper; use Modules\Tasks\Models\TaskMapper; use Modules\Tasks\Models\TaskStatus; @@ -101,9 +104,52 @@ final class ApiController extends Controller private function createReportFromRequest(RequestAbstract $request) : Report { $request->setData('redirect', 'qualitymanagement/report/view?for={$id}'); + /** @var \Modules\Tasks\Models\Task $task */ $task = $this->app->moduleManager->get('Tasks', 'Api')->createTaskFromRequest($request); - $task->type = TaskType::HIDDEN; $task->unit ??= $this->app->unitId; + $task->for = $request->hasData('account') ? new NullAccount((int) $request->getData('account')) : null; + + if (($value = $request->getDataString('bill')) !== null) { + $attrType = TaskAttributeTypeMapper::get() + ->where('name', 'bill') + ->execute(); + + if ($attrType->id !== 0) { + $internalRequest = new RequestAbstract(); + $internalRequest->setData('value', $value); + $attribute = $this->app->moduleManager->get('Attribute', 'Api')->createAttributeFromRequest($internalRequest, $attrType); + + $task->attributes[] = $attribute; + } + } + + if (($value = $request->getDataString('item')) !== null) { + $attrType = TaskAttributeTypeMapper::get() + ->where('name', 'item') + ->execute(); + + if ($attrType->id !== 0) { + $internalRequest = new RequestAbstract(); + $internalRequest->setData('value', $value); + $attribute = $this->app->moduleManager->get('Attribute', 'Api')->createAttributeFromRequest($internalRequest, $attrType); + + $task->attributes[] = $attribute; + } + } + + if (($value = $request->getDataString('lot')) !== null) { + $attrType = TaskAttributeTypeMapper::get() + ->where('name', 'lot_internal') + ->execute(); + + if ($attrType->id !== 0) { + $internalRequest = new RequestAbstract(); + $internalRequest->setData('value', $value); + $attribute = $this->app->moduleManager->get('Attribute', 'Api')->createAttributeFromRequest($internalRequest, $attrType); + + $task->attributes[] = $attribute; + } + } return new Report($task); } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 46f911f..c5746e3 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -94,8 +94,6 @@ final class BackendController extends Controller ->query($openQuery) ->executeGetArray(); - $view->data['stats'] = ReportMapper::getStatOverview(); - return $view; } @@ -145,6 +143,8 @@ final class BackendController extends Controller ->with('task/taskElements/createdBy') ->with('task/taskElements/files') ->with('task/attributes') + ->with('task/attributes/type') + ->with('task/attributes/value') ->with('task/for') ->where('id', (int) $request->getData('id')) ->where('task/tags/title/language', $request->header->l11n->language) diff --git a/Theme/Backend/report-create.tpl.php b/Theme/Backend/report-create.tpl.php index d725949..a687e0c 100644 --- a/Theme/Backend/report-create.tpl.php +++ b/Theme/Backend/report-create.tpl.php @@ -44,7 +44,7 @@ echo $this->data['nav']->render(); ?>
- +
diff --git a/Theme/Backend/report-dashboard.tpl.php b/Theme/Backend/report-dashboard.tpl.php index 3e022ff..7ca163e 100644 --- a/Theme/Backend/report-dashboard.tpl.php +++ b/Theme/Backend/report-dashboard.tpl.php @@ -23,7 +23,7 @@ $reports = $this->data['reports']; echo $this->data['nav']->render(); ?>
-
+
getHtml('Open'); ?>download
@@ -34,7 +34,6 @@ echo $this->data['nav']->render(); ?> getHtml('Creator'); ?> getHtml('Assigned'); ?> getHtml('For'); ?> - getHtml('Item'); ?> getHtml('Created'); ?> data['nav']->render(); ?> printHtml($report->task->for->name1); ?> printHtml($report->task->for->name2); ?> - getHtml('P' . $report->task->priority, 'Tasks'); ?> printHtml($report->task->createdAt->format('Y-m-d H:i')); ?> getHtml('Empty', '0', '0'); ?> @@ -75,7 +73,6 @@ echo $this->data['nav']->render(); ?> getHtml('Creator'); ?> getHtml('Assigned'); ?> getHtml('For'); ?> - getHtml('Item'); ?> getHtml('Created'); ?> data['nav']->render(); ?> printHtml($report->task->for->name1); ?> printHtml($report->task->for->name2); ?> - getHtml('P' . $report->task->priority, 'Tasks'); ?> printHtml($report->task->createdAt->format('Y-m-d H:i')); ?> getHtml('Empty', '0', '0'); ?> @@ -106,19 +102,4 @@ echo $this->data['nav']->render(); ?>
- -
-
-
getHtml('Stats'); ?>
-
- -
getHtml('Unassigned'); ?>data['stats']['unassigned'] ?? 0; ?> -
getHtml('Open'); ?>data['stats']['open'] ?? 0; ?> -
getHtml('InProgress'); ?>data['stats']['inprogress'] ?? 0; ?> -
getHtml('Closed'); ?>data['stats']['closed'] ?? 0; ?> -
getHtml('Total'); ?>data['stats']['total'] ?? 0; ?> -
-
-
-
\ No newline at end of file diff --git a/Theme/Backend/report-view.tpl.php b/Theme/Backend/report-view.tpl.php index 0421b6e..ec954ea 100644 --- a/Theme/Backend/report-view.tpl.php +++ b/Theme/Backend/report-view.tpl.php @@ -371,13 +371,13 @@ echo $this->data['nav']->render(); ?>
- -