diff --git a/Web/Models/Entities/TicketComment.php b/Web/Models/Entities/TicketComment.php index 02e37002..28329cd7 100644 --- a/Web/Models/Entities/TicketComment.php +++ b/Web/Models/Entities/TicketComment.php @@ -28,6 +28,35 @@ class TicketComment extends RowModel return (new Users)->get($this->getRecord()->user_id); } + function getAgentNumber(): ?string + { + if($this->getUType() === 0) + return NULL; + + $salt = "kiraMiki"; + $hash = $this->getUser()->getId() . CHANDLER_ROOT_CONF["security"]["secret"] . $salt; + $hash = hexdec(substr(hash("adler32", $hash), 0, 3)); + $hash = ceil(($hash * 999) / 4096); # proportionalize to 0-999 + + return str_pad((string) $hash, 3, "0", STR_PAD_LEFT); + } + + function getColorRotation(): ?int + { + if(is_null($agent = $this->getAgentNumber())) + return NULL; + + $agent = (int) $agent; + $rotation = $agent > 500 ? ( ($agent * 360) / 999 ) : $agent; # cap at 360deg + $values = [0, 45, 160, 220, 310, 345]; # good looking colors + usort($values, function($x, $y) use ($rotation) { + # find closest + return abs($x - $rotation) - abs($y - $rotation); + }); + + return array_shift($values); + } + function getContext(): string { return $this->getRecord()->text; diff --git a/Web/Presenters/templates/Support/AnswerTicket.xml b/Web/Presenters/templates/Support/AnswerTicket.xml index ba92bb57..68194810 100644 --- a/Web/Presenters/templates/Support/AnswerTicket.xml +++ b/Web/Presenters/templates/Support/AnswerTicket.xml @@ -49,7 +49,9 @@ {else} - + {/if} @@ -62,9 +64,19 @@ {elseif ($comment->getUType() === 1)}
- - {=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]} - написал
+ + + {=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]} №{$comment->getAgentNumber()} + + + {if $thisUser->getChandlerUser()->can("write")->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)} + + + ({$comment->getUser()->getFirstName()} {iconv_substr($comment->getUser()->getLastName(), 0, 1)}.) + + + {/if} + написал
{$comment->getTime()}
{/if} diff --git a/Web/Presenters/templates/Support/View.xml b/Web/Presenters/templates/Support/View.xml index 8af132af..c53b22b4 100644 --- a/Web/Presenters/templates/Support/View.xml +++ b/Web/Presenters/templates/Support/View.xml @@ -48,7 +48,9 @@ {else} - + {/if} @@ -62,7 +64,7 @@ {elseif ($comment->getUType() === 1)}
- {=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]} + {=OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["supportName"]} №{$comment->getAgentNumber()} написал
{$comment->getTime()}