mirror of
https://github.com/Karaka-Management/oms-Support.git
synced 2026-01-10 16:48:41 +00:00
fix support lists
This commit is contained in:
parent
1ba2133d85
commit
8480819da4
|
|
@ -26,6 +26,12 @@ use phpOMS\Message\RequestAbstract;
|
|||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Views\View;
|
||||
use Modules\Profile\Models\SettingsEnum as ProfileSettingsEnum;
|
||||
use Modules\Tasks\Models\AccountRelationMapper;
|
||||
use Modules\Tasks\Models\TaskElementMapper;
|
||||
use Modules\Tasks\Models\TaskMapper;
|
||||
use Modules\Tasks\Models\TaskStatus;
|
||||
use Modules\Tasks\Models\TaskType;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
|
||||
/**
|
||||
* Support controller class.
|
||||
|
|
@ -80,6 +86,9 @@ final class BackendController extends Controller
|
|||
->with('task')
|
||||
->with('task/createdBy')
|
||||
->with('task/for')
|
||||
->with('task/taskElements')
|
||||
->with('task/taskElements/accRelation')
|
||||
->with('task/taskElements/accRelation/relation')
|
||||
->with('app')
|
||||
->limit(25);
|
||||
|
||||
|
|
@ -251,10 +260,56 @@ final class BackendController extends Controller
|
|||
*/
|
||||
public function viewPrivateSupportDashboard(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$head = $response->data['Content']->head;
|
||||
$head->addAsset(AssetType::CSS, 'Modules/Tasks/Theme/Backend/css/styles.css?v=1.0.0');
|
||||
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/Support/Theme/Backend/user-support-dashboard');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1002901101, $request, $response);
|
||||
|
||||
// @todo Use ticket implementation "getAnyRelatedToUser($request->header->account)
|
||||
$mapperQuery = TicketMapper::getAnyRelatedToUser($request->header->account)
|
||||
->with('task')
|
||||
->with('task/createdBy')
|
||||
->with('task/for')
|
||||
->with('task/taskElements')
|
||||
->with('task/taskElements/accRelation')
|
||||
->with('task/taskElements/accRelation/relation')
|
||||
->with('app')
|
||||
->sort('task/createdAt', OrderType::DESC)
|
||||
->limit(25);
|
||||
|
||||
if ($request->getData('ptype') === 'p') {
|
||||
$mapperQuery->where('id', $request->getDataInt('id') ?? 0, '<');
|
||||
} elseif ($request->getData('ptype') === 'n') {
|
||||
$mapperQuery->where('id', $request->getDataInt('id') ?? 0, '>');
|
||||
} else {
|
||||
$mapperQuery->where('id', 0, '>');
|
||||
}
|
||||
|
||||
$view->data['tickets'] = $mapperQuery->execute();
|
||||
|
||||
$openQuery = new Builder($this->app->dbPool->get(), true);
|
||||
$openQuery->innerJoin(TaskMapper::TABLE, TaskMapper::TABLE . '_d2_task')
|
||||
->on(TicketMapper::TABLE . '_d1.support_ticket_task', '=', TaskMapper::TABLE . '_d2_task.task_id')
|
||||
->innerJoin(TaskElementMapper::TABLE)
|
||||
->on(TaskMapper::TABLE . '_d2_task.' . TaskMapper::PRIMARYFIELD, '=', TaskElementMapper::TABLE . '.task_element_task')
|
||||
->innerJoin(AccountRelationMapper::TABLE)
|
||||
->on(TaskElementMapper::TABLE . '.' . TaskElementMapper::PRIMARYFIELD, '=', AccountRelationMapper::TABLE . '.task_account_task_element')
|
||||
->andWhere(AccountRelationMapper::TABLE . '.task_account_account', '=', $request->header->account);
|
||||
|
||||
/** @var \Modules\Tasks\Models\Task[] $open */
|
||||
$open = TicketMapper::getAll()
|
||||
->with('task')
|
||||
->with('task/createdBy')
|
||||
->where('task/type', TaskType::TEMPLATE, '!=')
|
||||
->where('task/status', TaskStatus::OPEN)
|
||||
->sort('task/createdAt', OrderType::DESC)
|
||||
->query($openQuery)
|
||||
->execute();
|
||||
|
||||
$view->data['open'] = $open;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,14 @@ declare(strict_types=1);
|
|||
namespace Modules\Support\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use Modules\Tasks\Models\AccountRelationMapper;
|
||||
use Modules\Tasks\Models\TaskElementMapper;
|
||||
use Modules\Tasks\Models\TaskMapper;
|
||||
use Modules\Tasks\Models\TaskStatus;
|
||||
use Modules\Tasks\Models\TaskType;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\DataStorage\Database\Mapper\ReadMapper;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\Stdlib\Base\SmartDateTime;
|
||||
|
||||
/**
|
||||
|
|
@ -114,4 +119,46 @@ final class TicketMapper extends DataMapperFactory
|
|||
'inprogress' => self::count()->with('task')->where('task/status', TaskStatus::WORKING)->execute(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tasks that have something to do with the user
|
||||
*
|
||||
* @param int $user User
|
||||
*
|
||||
* @return ReadMapper
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getAnyRelatedToUser(int $user) : ReadMapper
|
||||
{
|
||||
$query = new Builder(self::$db, true);
|
||||
$query->innerJoin(TaskMapper::TABLE, TaskMapper::TABLE . '_d2_task')
|
||||
->on(self::TABLE . '_d1.support_ticket_task', '=', TaskMapper::TABLE . '_d2_task.task_id')
|
||||
->innerJoin(TaskElementMapper::TABLE)
|
||||
->on(TaskMapper::TABLE . '_d2_task.task_id', '=', TaskElementMapper::TABLE . '.task_element_task')
|
||||
->on(TaskMapper::TABLE . '_d2_task.task_type', '!=', TaskType::TEMPLATE)
|
||||
->innerJoin(AccountRelationMapper::TABLE)
|
||||
->on(TaskElementMapper::TABLE . '.task_element_id', '=', AccountRelationMapper::TABLE . '.task_account_task_element')
|
||||
->where(AccountRelationMapper::TABLE . '.task_account_account', '=', $user)
|
||||
->orWhere(TaskMapper::TABLE . '_d2_task.task_created_by', '=', $user)
|
||||
->groupBy(self::PRIMARYFIELD);
|
||||
|
||||
// @todo Improving query performance by using raw queries and result arrays for large responses like this
|
||||
$sql = <<<SQL
|
||||
SELECT DISTINCT task.*, account.*
|
||||
FROM task
|
||||
INNER JOIN task_element ON task.task_id = task_element.task_element_task
|
||||
INNER JOIN task_account ON task_element.task_element_id = task_account.task_account_task_element
|
||||
INNER JOIN account ON task.task_created_by = account.account_id
|
||||
WHERE
|
||||
task.task_status != 1
|
||||
AND (
|
||||
task_account.task_account_account = {$user}
|
||||
OR task.task_created_by = {$user}
|
||||
)
|
||||
LIMIT 25;
|
||||
SQL;
|
||||
|
||||
return self::getAll()->query($query);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,12 @@ echo $this->data['nav']->render(); ?>
|
|||
<td><a href="<?= $url; ?>"><?= $this->getHtml('P' . $ticket->task->priority, 'Tasks'); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($ticket->task->title); ?></a>
|
||||
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $ticket->task->createdBy->id); ?>"><?= $this->printHtml($ticket->task->createdBy->name1); ?> <?= $this->printHtml($ticket->task->createdBy->name2); ?></a>
|
||||
<td><a class="content" href="<?= $url; ?>"><?= $this->printHtml($ticket->task->createdBy->name1); ?> <?= $this->printHtml($ticket->task->createdBy->name2); ?></a>
|
||||
<td><?php $responsibles = $ticket->task->getResponsible();
|
||||
foreach ($responsibles as $responsible) : ?>
|
||||
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $responsible->id); ?>">
|
||||
<?= $this->printHtml($responsible->name1); ?> <?= $this->printHtml($responsible->name2); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<td><a class="content"><?= $this->printHtml($ticket->task->for->name1); ?> <?= $this->printHtml($ticket->task->for->name2); ?>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($ticket->task->createdAt->format('Y-m-d H:i')); ?></a>
|
||||
<?php endforeach; if ($c == 0) : ?>
|
||||
|
|
|
|||
|
|
@ -1 +1,110 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Support
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
echo $this->data['nav']->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Open'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table class="default sticky">
|
||||
<thead>
|
||||
<td><?= $this->getHtml('Status'); ?>
|
||||
<td><?= $this->getHtml('Priority'); ?>
|
||||
<td class="full"><?= $this->getHtml('Title'); ?>
|
||||
<td><?= $this->getHtml('Creator'); ?>
|
||||
<td><?= $this->getHtml('Assigned'); ?>
|
||||
<td><?= $this->getHtml('For'); ?>
|
||||
<td><?= $this->getHtml('Created'); ?>
|
||||
<tbody>
|
||||
<?php
|
||||
$c = 0;
|
||||
foreach ($this->data['open'] as $key => $ticket) : ++$c;
|
||||
$url = UriFactory::build('{/base}/support/ticket?{?}&id=' . $ticket->id);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>">
|
||||
<span class="tag <?= $this->printHtml('task-status-' . $ticket->task->status); ?>">
|
||||
<?= $this->getHtml('S' . $ticket->task->status, 'Tasks'); ?>
|
||||
</span></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->getHtml('P' . $ticket->task->priority, 'Tasks'); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($ticket->task->title); ?></a>
|
||||
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $ticket->task->createdBy->id); ?>"><?= $this->printHtml($ticket->task->createdBy->name1); ?> <?= $this->printHtml($ticket->task->createdBy->name2); ?></a>
|
||||
<td><?php $responsibles = $ticket->task->getResponsible();
|
||||
foreach ($responsibles as $responsible) : ?>
|
||||
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $responsible->id); ?>">
|
||||
<?= $this->printHtml($responsible->name1); ?> <?= $this->printHtml($responsible->name2); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<td><a class="content"><?= $this->printHtml($ticket->task->for->name1); ?> <?= $this->printHtml($ticket->task->for->name2); ?>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($ticket->task->createdAt->format('Y-m-d H:i')); ?></a>
|
||||
<?php endforeach; if ($c == 0) : ?>
|
||||
<tr><td colspan="7" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head"><?= $this->getHtml('Tickets'); ?><i class="g-icon download btn end-xs">download</i></div>
|
||||
<div class="slider">
|
||||
<table class="default sticky">
|
||||
<thead>
|
||||
<td><?= $this->getHtml('Status'); ?>
|
||||
<td><?= $this->getHtml('Priority'); ?>
|
||||
<td class="full"><?= $this->getHtml('Title'); ?>
|
||||
<td><?= $this->getHtml('Creator'); ?>
|
||||
<td><?= $this->getHtml('Assigned'); ?>
|
||||
<td><?= $this->getHtml('For'); ?>
|
||||
<td><?= $this->getHtml('Created'); ?>
|
||||
<tbody>
|
||||
<?php
|
||||
$c = 0;
|
||||
foreach ($this->data['tickets'] as $key => $ticket) : ++$c;
|
||||
$url = UriFactory::build('{/base}/support/ticket?{?}&id=' . $ticket->id);
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>">
|
||||
<span class="tag <?= $this->printHtml('task-status-' . $ticket->task->status); ?>">
|
||||
<?= $this->getHtml('S' . $ticket->task->status, 'Tasks'); ?>
|
||||
</span></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->getHtml('P' . $ticket->task->priority, 'Tasks'); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($ticket->task->title); ?></a>
|
||||
<td><a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $ticket->task->createdBy->id); ?>"><?= $this->printHtml($ticket->task->createdBy->name1); ?> <?= $this->printHtml($ticket->task->createdBy->name2); ?></a>
|
||||
<td><?php $responsibles = $ticket->task->getResponsible();
|
||||
foreach ($responsibles as $responsible) : ?>
|
||||
<a class="content" href="<?= UriFactory::build('{/base}/profile/view?for=' . $responsible->id); ?>">
|
||||
<?= $this->printHtml($responsible->name1); ?> <?= $this->printHtml($responsible->name2); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<td><a class="content"><?= $this->printHtml($ticket->task->for->name1); ?> <?= $this->printHtml($ticket->task->for->name2); ?>
|
||||
<td><a href="<?= $url; ?>"><?= $this->printHtml($ticket->task->createdAt->format('Y-m-d H:i')); ?></a>
|
||||
<?php endforeach; if ($c == 0) : ?>
|
||||
<tr><td colspan="7" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user