bug fixes

This commit is contained in:
Dennis Eichhorn 2024-05-12 00:06:29 +00:00
parent 764fb40e14
commit de0445b026
8 changed files with 136 additions and 16 deletions

View File

@ -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.'

View File

@ -9,12 +9,12 @@
"l11n": {
"en": {
"subject": "Ticket Notification #{ticket_id}",
"body": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Ticket Notification</title></head><body style=\"font-family: Arial, sans-serif; font-size: 14px; line-height: 1.5;\"><div class=\"container\" style=\"max-width: 600px; margin: 20px auto; padding: 20px; background-color: #fff;\"><h1 style=\"color: #333;\">Ticket Notification</h1><p>Hello {use_name},</p><p>Your ticket has been [created/updated] successfully. Below are the details:</p><div class=\"ticket-details\" style=\"margin-top: 20px; padding: 10px; background-color: #f9f9f9; border-radius: 5px;\"><h2 style=\"color: #333;\">Ticket Information</h2><p><strong>Ticket ID:</strong> {ticket_id}</p><p><strong>Status:</strong> {ticket_status}</p><p><strong>Subject:</strong> {ticket_subject}</p></div><p style=\"margin-top: 40px;\">Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058</p></td></tr></table></td></tr></table></body></html>",
"body": "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Ticket Notification</title></head><body style=\"font-family: Arial, sans-serif; font-size: 14px; line-height: 1.5;\"><div class=\"container\" style=\"max-width: 600px; margin: 20px auto; padding: 20px; background-color: #fff;\"><h1 style=\"color: #333;\">Ticket Notification</h1><p>Hello {use_name},</p><p>Your ticket has been [created/updated] successfully. Below are the details:</p><div class=\"ticket-details\" style=\"margin-top: 20px; padding: 10px; background-color: #f9f9f9; border-radius: 5px;\"><h2 style=\"color: #333;\">Ticket Information</h2><p><strong>Ticket ID:</strong> {ticket_id}</p><p><strong>Status:</strong> {ticket_status}</p><p><strong>Subject:</strong> {ticket_subject}</p></div><p style=\"margin-top: 40px;\">Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058</p></body></html>",
"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": "<!DOCTYPE html><html lang=\"de\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Ticket Benachrichtigung</title></head><body style=\"font-family: Arial, sans-serif; font-size: 14px; line-height: 1.5;\"><div class=\"container\" style=\"max-width: 600px; margin: 20px auto; padding: 20px; background-color: #fff;\"><h1 style=\"color: #333;\">Ticket Benachrichtigung</h1><p>Hallo {use_name},</p><p>Ihr Ticket wurde erfolgreich [erstellt/upgedated]. Im Folgenden finden Sie die Details:</p><div class=\"ticket-details\" style=\"margin-top: 20px; padding: 10px; background-color: #f9f9f9; border-radius: 5px;\"><h2 style=\"color: #333;\">Ticket Information</h2><p><strong>Ticket ID:</strong> {ticket_id}</p><p><strong>Status:</strong> {ticket_status}</p><p><strong>Betreff:</strong> {ticket_subject}</p></div><p style=\"margin-top: 40px;\">Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058</p></td></tr></table></td></tr></table></body></html>",
"body": "<!DOCTYPE html><html lang=\"de\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>Ticket Benachrichtigung</title></head><body style=\"font-family: Arial, sans-serif; font-size: 14px; line-height: 1.5;\"><div class=\"container\" style=\"max-width: 600px; margin: 20px auto; padding: 20px; background-color: #fff;\"><h1 style=\"color: #333;\">Ticket Benachrichtigung</h1><p>Hallo {use_name},</p><p>Ihr Ticket wurde erfolgreich [erstellt/upgedated]. Im Folgenden finden Sie die Details:</p><div class=\"ticket-details\" style=\"margin-top: 20px; padding: 10px; background-color: #f9f9f9; border-radius: 5px;\"><h2 style=\"color: #333;\">Ticket Information</h2><p><strong>Ticket ID:</strong> {ticket_id}</p><p><strong>Status:</strong> {ticket_status}</p><p><strong>Betreff:</strong> {ticket_subject}</p></div><p style=\"margin-top: 40px;\">Jingga e.K. - www.jingga.app - CEO Dennis Eichhorn - Amtsgericht Friedberg HRA 5058</p></body></html>",
"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"
}
},

View File

@ -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"
}
}
}
}

View File

@ -31,7 +31,7 @@ echo $this->data['nav']->render(); ?>
<div class="tab">
<div class="row">
<div class="col-xs-12 col-md-6">
<div class="portlet">
<section class="portlet">
<form id="iGeneralSettings" action="<?= UriFactory::build('{/api}admin/settings/module?id={?id}&csrf={$CSRF}'); ?>" method="post">
<div class="portlet-head"><?= $this->getHtml('Settings'); ?></div>
<div class="portlet-body">
@ -77,11 +77,11 @@ echo $this->data['nav']->render(); ?>
<input id="iSubmitGeneral" name="submitGeneral" type="submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
</div>
</form>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="portlet">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Applications'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="settingsList" class="default sticky">
@ -126,7 +126,7 @@ echo $this->data['nav']->render(); ?>
<?php endif; ?>
</table>
</div>
</div>
</section>
</div>
</div>
</div>
@ -135,7 +135,7 @@ echo $this->data['nav']->render(); ?>
<div class="tab">
<div class="row">
<div class="col-xs-12">
<div class="portlet">
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Settings'); ?><i class="g-icon download btn end-xs">download</i></div>
<div class="slider">
<table id="settingsList" class="default sticky">
@ -208,7 +208,7 @@ echo $this->data['nav']->render(); ?>
<?php endif; ?>
</table>
</div>
</div>
</section>
</div>
</div>
</div>

View File

@ -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<string, bool>
*
* @since 1.0.0
*/
private function validateNoteCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['id'] = !$request->hasData('id'))) {
return $val;
}
return [];
}
}

View File

@ -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;
}

View File

@ -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<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @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.
*

View File

@ -310,7 +310,7 @@ echo $this->data['nav']->render(); ?>
</div>
<div class="col-md-6 col-xs-12">
<div class="portlet">
<section class="portlet">
<form
id="taskElementCreate" method="PUT"
action="<?= UriFactory::build('{/api}task/element?{?}&csrf={$CSRF}'); ?>"
@ -352,13 +352,13 @@ echo $this->data['nav']->render(); ?>
<div class="form-group wf-100">
<div class="more-container wf-100">
<input id="more-customer-sales" type="checkbox" name="more-container">
<label for="more-customer-sales">
<input id="more-customer-sales" class="more" type="checkbox" name="more-container">
<label class="more" for="more-customer-sales">
<span><?= $this->getHtml('Advanced'); ?></span>
<i class="g-icon expand">chevron_right</i>
</label>
<div class="form-group">
<div class="form-group more">
<label for="iPriority"><?= $this->getHtml('Priority'); ?></label>
<select id="iPriority" name="priority">
<option value="<?= TaskPriority::NONE; ?>"<?= $task->priority === TaskPriority::NONE ? ' selected' : '';?>><?= $this->getHtml('P0', 'Tasks'); ?>
@ -402,7 +402,7 @@ echo $this->data['nav']->render(); ?>
<input type="hidden" name="task" value="<?= $this->printHtml($this->request->getData('id')); ?>"><input type="hidden" name="type" value="1">
</div>
</form>
</div>
</section>
<section class="portlet">
<div class="portlet-head"><?= $this->getHtml('Tickets'); ?></div>