Support: Indicator for answered tickets for user

Fixes #187
This commit is contained in:
veselcraft 2021-11-27 12:24:34 +03:00
parent 25d0fde3c3
commit 478f8f9368
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
3 changed files with 11 additions and 2 deletions

View file

@ -35,6 +35,11 @@ class Tickets
{ {
foreach($this->tickets->where(['user_id' => $user_id, 'deleted' => 0]) as $ticket) yield new Ticket($ticket); foreach($this->tickets->where(['user_id' => $user_id, 'deleted' => 0]) as $ticket) yield new Ticket($ticket);
} }
function getTicketsCountByuId(int $user_id, int $type = 0): int
{
return sizeof($this->tickets->where(['user_id' => $user_id, 'deleted' => 0, 'type' => $type]));
}
function getRequestById(int $req_id): ?Ticket function getRequestById(int $req_id): ?Ticket
{ {

View file

@ -7,7 +7,7 @@ use Chandler\Security\Authenticator;
use Latte\Engine as TemplatingEngine; use Latte\Engine as TemplatingEngine;
use openvk\Web\Models\Entities\IP; use openvk\Web\Models\Entities\IP;
use openvk\Web\Themes\Themepacks; use openvk\Web\Themes\Themepacks;
use openvk\Web\Models\Repositories\{IPs, Users, APITokens}; use openvk\Web\Models\Repositories\{IPs, Users, APITokens, Tickets};
abstract class OpenVKPresenter extends SimplePresenter abstract class OpenVKPresenter extends SimplePresenter
{ {
@ -207,6 +207,7 @@ abstract class OpenVKPresenter extends SimplePresenter
$this->user->identity->save(); $this->user->identity->save();
} }
$this->template->ticketAnsweredCount = (new Tickets)->getTicketsCountByuId($this->user->id, 1);
} }
setlocale(LC_TIME, ...(explode(";", tr("__locale")))); setlocale(LC_TIME, ...(explode(";", tr("__locale"))));

View file

@ -98,7 +98,10 @@
<a href="/search">{_"header_search"}</a> <a href="/search">{_"header_search"}</a>
</div> </div>
<div class="link"> <div class="link">
<a href="/support">{_"header_help"}</a> <a href="/support">
{_"header_help"}
<b n:if="$ticketAnsweredCount > 0">({$ticketAnsweredCount})</b>
</a>
</div> </div>
<div class="link"> <div class="link">
<a href="/logout">{_"header_log_out"}</a> <a href="/logout">{_"header_log_out"}</a>