diff --git a/Web/Models/Entities/SupportAlias.php b/Web/Models/Entities/SupportAlias.php
new file mode 100644
index 00000000..9ad618a6
--- /dev/null
+++ b/Web/Models/Entities/SupportAlias.php
@@ -0,0 +1,39 @@
+get($this->getRecord()->agent);
+ }
+
+ function getName(): string
+ {
+ return $this->getRecord()->name;
+ }
+
+ function getIcon(): ?string
+ {
+ return $this->getRecord()->icon;
+ }
+
+ function shouldAppendNumber(): bool
+ {
+ return (bool) $this->getRecord()->numerate;
+ }
+
+ function setAgent(User $agent): void
+ {
+ $this->stateChanges("agent", $agent->getId());
+ }
+
+ function setNumeration(bool $numerate): void
+ {
+ $this->stateChanges("numerate", $numerate);
+ }
+}
diff --git a/Web/Models/Entities/TicketComment.php b/Web/Models/Entities/TicketComment.php
index 25568bc7..9cbc4716 100644
--- a/Web/Models/Entities/TicketComment.php
+++ b/Web/Models/Entities/TicketComment.php
@@ -4,7 +4,7 @@ use openvk\Web\Util\DateTime;
use Nette\Database\Table\ActiveRow;
use openvk\Web\Models\RowModel;
use Chandler\Database\DatabaseConnection;
-use openvk\Web\Models\Repositories\Users;
+use openvk\Web\Models\Repositories\{Users, SupportAliases};
use Chandler\Database\DatabaseConnection as DB;
use Nette\InvalidStateException as ISE;
use Nette\Database\Table\Selection;
@@ -12,7 +12,12 @@ use Nette\Database\Table\Selection;
class TicketComment extends RowModel
{
protected $tableName = "tickets_comments";
-
+
+ private function getSupportAlias(): ?SupportAlias
+ {
+ return (new SupportAliases)->get($this->getUser()->getId());
+ }
+
function getId(): int
{
return $this->getRecord()->id;
@@ -26,7 +31,34 @@ class TicketComment extends RowModel
function getUser(): User
{
return (new Users)->get($this->getRecord()->user_id);
- }
+ }
+
+ function getAuthorName(): string
+ {
+ if($this->getUType() === 0)
+ return $this->getUser()->getCanonicalName();
+
+ $alias = $this->getSupportAlias();
+ if(!$alias)
+ return OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"] . " №" . $this->getAgentNumber();
+
+ $name = $alias->getName();
+ if($alias->shouldAppendNumber())
+ $name .= " №" . $this->getAgentNumber();
+
+ return $name;
+ }
+
+ function getAvatar(): string
+ {
+ if($this->getUType() === 0)
+ return $this->getUser()->getAvatarUrl();
+
+ $default = "/assets/packages/static/openvk/img/support.jpeg";
+ $alias = $this->getSupportAlias();
+
+ return is_null($alias) ? $default : ($alias->getIcon() ?? $default);
+ }
function getAgentNumber(): ?string
{
@@ -46,6 +78,9 @@ class TicketComment extends RowModel
if(is_null($agent = $this->getAgentNumber()))
return NULL;
+ if(!is_null($this->getSupportAlias()))
+ return 0;
+
$agent = (int) $agent;
$rotation = $agent > 500 ? ( ($agent * 360) / 999 ) : $agent; # cap at 360deg
$values = [0, 45, 160, 220, 310, 345]; # good looking colors
diff --git a/Web/Models/Repositories/SupportAliases.php b/Web/Models/Repositories/SupportAliases.php
new file mode 100644
index 00000000..cb1a2521
--- /dev/null
+++ b/Web/Models/Repositories/SupportAliases.php
@@ -0,0 +1,13 @@
+toEntity($this->table->where("agent", $agent)->fetch());
+ }
+}
diff --git a/Web/Presenters/templates/Support/AnswerTicket.xml b/Web/Presenters/templates/Support/AnswerTicket.xml
index 68194810..8b3f9313 100644
--- a/Web/Presenters/templates/Support/AnswerTicket.xml
+++ b/Web/Presenters/templates/Support/AnswerTicket.xml
@@ -15,7 +15,7 @@
Автор: {$ticket->getUser()->getFullName()} | {$ticket->getUser()->getRegistrationIP()} | Статус: {$ticket->getStatus()}