From de0445b02689a23860b5c6b665119fe6ccae6b39 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 12 May 2024 00:06:29 +0000 Subject: [PATCH] bug fixes --- .github/workflows/greetings.yml | 2 +- Admin/Install/Messages.install.json | 4 +- Admin/Install/db.json | 26 +++++++ Admin/Settings/Theme/Backend/settings.tpl.php | 12 +-- Controller/ApiController.php | 76 ++++++++++++++++++- Models/Ticket.php | 6 ++ Models/TicketMapper.php | 16 ++++ Theme/Backend/support-ticket.tpl.php | 10 +-- 8 files changed, 136 insertions(+), 16 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/Admin/Install/Messages.install.json b/Admin/Install/Messages.install.json index 2f3b32c..1eec832 100644 --- a/Admin/Install/Messages.install.json +++ b/Admin/Install/Messages.install.json @@ -9,12 +9,12 @@ "l11n": { "en": { "subject": "Ticket Notification #{ticket_id}", - "body": "Ticket Notification

Ticket Notification

Hello {use_name},

Your ticket has been [created/updated] successfully. Below are the details:

Ticket Information

Ticket ID: {ticket_id}

Status: {ticket_status}

Subject: {ticket_subject}

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Ticket Notification

Ticket Notification

Hello {use_name},

Your ticket has been [created/updated] successfully. Below are the details:

Ticket Information

Ticket ID: {ticket_id}

Status: {ticket_status}

Subject: {ticket_subject}

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Dear {user_name},\n\nYour ticket has been [created/updated] successfully. Below are the details:\n\nTicket ID: {ticket_id}\nStatus: {ticket_status}\nSubject: {ticket_subject}\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" }, "de": { "subject": "Ticket Benachrichtigung #{ticket_id}", - "body": "Ticket Benachrichtigung

Ticket Benachrichtigung

Hallo {use_name},

Ihr Ticket wurde erfolgreich [erstellt/upgedated]. Im Folgenden finden Sie die Details:

Ticket Information

Ticket ID: {ticket_id}

Status: {ticket_status}

Betreff: {ticket_subject}

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", + "body": "Ticket Benachrichtigung

Ticket Benachrichtigung

Hallo {use_name},

Ihr Ticket wurde erfolgreich [erstellt/upgedated]. Im Folgenden finden Sie die Details:

Ticket Information

Ticket ID: {ticket_id}

Status: {ticket_status}

Betreff: {ticket_subject}

Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058

", "bodyalt": "Sehr geehrte/r {user_name},\n\nIhr Ticket wurde erfolgreich [erstellt/upgedated]. Im Folgenden finden Sie die Details:\n\nTicket ID: {ticket_id}\nStatus: {ticket_status}\nBetreff: {ticket_subject}\n\n\nJingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058" } }, diff --git a/Admin/Install/db.json b/Admin/Install/db.json index bc81ab3..a3ece9d 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -49,5 +49,31 @@ "foreignKey": "support_app_id" } } + }, + "support_ticket_note": { + "name": "support_ticket_note", + "fields": { + "support_ticket_note_id": { + "name": "support_ticket_note_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "support_ticket_note_ticket": { + "name": "support_ticket_note_ticket", + "type": "INT", + "null": false, + "foreignTable": "support_ticket", + "foreignKey": "support_ticket_id" + }, + "support_ticket_note_doc": { + "name": "support_ticket_note_doc", + "type": "INT", + "null": false, + "foreignTable": "editor_doc", + "foreignKey": "editor_doc_id" + } + } } } \ No newline at end of file diff --git a/Admin/Settings/Theme/Backend/settings.tpl.php b/Admin/Settings/Theme/Backend/settings.tpl.php index c53be4f..043f0da 100755 --- a/Admin/Settings/Theme/Backend/settings.tpl.php +++ b/Admin/Settings/Theme/Backend/settings.tpl.php @@ -31,7 +31,7 @@ echo $this->data['nav']->render(); ?>
-
+
getHtml('Settings'); ?>
@@ -77,11 +77,11 @@ echo $this->data['nav']->render(); ?>
-
+
-
+
getHtml('Applications'); ?>download
@@ -126,7 +126,7 @@ echo $this->data['nav']->render(); ?>
-
+
@@ -135,7 +135,7 @@ echo $this->data['nav']->render(); ?>
-
+
getHtml('Settings'); ?>download
@@ -208,7 +208,7 @@ echo $this->data['nav']->render(); ?>
-
+
diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 4249bf4..e7a3865 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -232,8 +232,7 @@ final class ApiController extends Controller private function createTicketFromRequest(RequestAbstract $request) : Ticket { $request->setData('redirect', 'support/ticket/view?for={$id}'); - $task = $this->app->moduleManager->get('Tasks')->createTaskFromRequest($request); - $task->type = TaskType::HIDDEN; + $task = $this->app->moduleManager->get('Tasks', 'Api')->createTaskFromRequest($request); $ticket = new Ticket($task); $ticket->app = new NullSupportApp($request->getDataInt('app') ?? 1); @@ -470,4 +469,77 @@ final class ApiController extends Controller return []; } + + /** + * Api method to create Note + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param array $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiNoteCreate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void + { + if (!empty($val = $this->validateNoteCreate($request))) { + $response->header->status = RequestStatusCode::R_400; + $this->createInvalidCreateResponse($request, $response, $val); + + return; + } + + /** @var \Modules\Support\Models\Ticket $ticket */ + $ticket = TicketMapper::get()->where('id', (int) $request->getData('id'))->execute(); + + $request->setData('virtualpath', $this->createTicketDir($ticket), true); + $this->app->moduleManager->get('Editor', 'Api')->apiEditorCreate($request, $response, $data); + + if ($response->header->status !== RequestStatusCode::R_200) { + return; + } + + /** @var \Modules\Editor\Models\EditorDoc $model */ + $model = $response->getDataArray($request->uri->__toString())['response']; + $this->createModelRelation($request->header->account, $request->getDataInt('id'), $model->id, TicketMapper::class, 'notes', '', $request->getOrigin()); + } + + /** + * Create media directory path + * + * @param Ticket $ticket Ticket + * + * @return string + * + * @since 1.0.0 + */ + private function createTicketDir(Ticket $ticket) : string + { + return '/Modules/Support/Ticket/' + . $this->app->unitId . '/' + . $ticket->task->createdAt->format('Y/m/d') . '/' + . $ticket->id; + } + + /** + * Validate ticket note create request + * + * @param RequestAbstract $request Request + * + * @return array + * + * @since 1.0.0 + */ + private function validateNoteCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['id'] = !$request->hasData('id'))) { + return $val; + } + + return []; + } } diff --git a/Models/Ticket.php b/Models/Ticket.php index a0a1fd5..dc253fb 100755 --- a/Models/Ticket.php +++ b/Models/Ticket.php @@ -24,6 +24,10 @@ use Modules\Tasks\Models\TaskType; * @license OMS License 2.0 * @link https://jingga.app * @since 1.0.0 + * + * @question Consider to add internal comment for a ticket + * Maybe at least a remark field? + * https://github.com/Karaka-Management/oms-Support/issues/11 */ class Ticket { @@ -84,4 +88,6 @@ class Ticket { return $this->toArray(); } + + use \Modules\Editor\Models\EditorDocListTrait; } diff --git a/Models/TicketMapper.php b/Models/TicketMapper.php index 27fab46..96e9043 100755 --- a/Models/TicketMapper.php +++ b/Models/TicketMapper.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace Modules\Support\Models; +use Modules\Editor\Models\EditorDocMapper; use Modules\Tasks\Models\AccountRelationMapper; use Modules\Tasks\Models\TaskElementMapper; use Modules\Tasks\Models\TaskMapper; @@ -49,6 +50,21 @@ final class TicketMapper extends DataMapperFactory 'support_ticket_app' => ['name' => 'support_ticket_app', 'type' => 'int', 'internal' => 'app'], ]; + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + public const HAS_MANY = [ + 'notes' => [ + 'mapper' => EditorDocMapper::class, /* mapper of the related object */ + 'table' => 'support_ticket_note', /* table of the related object, null if no relation table is used (many->1) */ + 'external' => 'support_ticket_note_doc', + 'self' => 'support_ticket_note_ticket', + ], + ]; + /** * Has one relation. * diff --git a/Theme/Backend/support-ticket.tpl.php b/Theme/Backend/support-ticket.tpl.php index 8dafddc..8dbf325 100755 --- a/Theme/Backend/support-ticket.tpl.php +++ b/Theme/Backend/support-ticket.tpl.php @@ -310,7 +310,7 @@ echo $this->data['nav']->render(); ?>
-
+
data['nav']->render(); ?>
- -
getHtml('Tickets'); ?>