diff --git a/Web/Models/Repositories/TicketComments.php b/Web/Models/Repositories/TicketComments.php index f675bf7f..af5d8029 100644 --- a/Web/Models/Repositories/TicketComments.php +++ b/Web/Models/Repositories/TicketComments.php @@ -49,12 +49,11 @@ class TicketComments // return $this->toTicket($this->tickets->get($id)); // } - // We can get comment by it's ID using this function function get(int $id): TicketComment { - $comm = $this->comments->where(['id' => $id])->fetch(); - if (!is_null($comm)) - return new TicketComment($comm); + $comment = $this->comments->where(['id' => $id])->fetch(); + if (!is_null($comment)) + return new TicketComment($comment); else return null; } diff --git a/Web/Presenters/SupportPresenter.php b/Web/Presenters/SupportPresenter.php index 745ab389..7298e3ac 100644 --- a/Web/Presenters/SupportPresenter.php +++ b/Web/Presenters/SupportPresenter.php @@ -226,35 +226,26 @@ final class SupportPresenter extends OpenVKPresenter $this->template->content = $parser->parse($content); } - function renderRateAnswerGood(int $id): void + function renderRateAnswer(int $id, int $mark): void { $this->willExecuteWriteAction(); $this->assertUserLoggedIn(); $comment = $this->comments->get($id); - if ($this->user->id === $this->tickets->get($comment->getTicketId()->getUser()->getId())) { - $comment->setMark(1); - $comment->save(); - - $this->flashFail("succ", "Успешно", "Вы оставили положительный отзыв об ответе"); + if ($this->user->id === $this->tickets->get($comment->getTicketId())->getUser()->getId()) { + if ($mark === 1 || $mark === 2) {} + $comments->setMark($mark); + $comments->save(); + if ($mark === 1) { + $this->flashFail("succ", tr("information_-1"), tr("support_rated_good")); + } elseif ($mark === 2) { + $this->flashFail("succ", tr("information_-1"), tr("support_rated_bad")); + } + } else { + $this->flashFail("err", tr("error"), tr("wrong_parameters")); + } } else { - $this->flashFail("err", "Ошибка", "Ошибка доступа"); - } - } - - function renderRateAnswerBad(int $id): void - { - $this->willExecuteWriteAction(); - $this->assertUserLoggedIn(); - - $comment = $this->comments->get($id); - if ($this->user->id === $this->tickets->get($comment->getTicketId()->getUser()->getId())) { - $comment->setMark(2); - $comment->save(); - - $this->flashFail("succ", "Успешно", "Вы оставили положительный отзыв об ответе"); - } else { - $this->flashFail("err", "Ошибка", "Ошибка доступа"); + $this->flashFail("err", tr("error"), tr("forbidden")); } } } diff --git a/Web/Presenters/templates/Support/AnswerTicket.xml b/Web/Presenters/templates/Support/AnswerTicket.xml index 7b01056d..2a9928e0 100644 --- a/Web/Presenters/templates/Support/AnswerTicket.xml +++ b/Web/Presenters/templates/Support/AnswerTicket.xml @@ -109,16 +109,19 @@ {_delete} {/if} - {elseif $comment->getUType() === 1} - {if $comment->getMark() === 1} -
- {elseif $comment->getMark() === 2} - - {/if} + + {if $comment->getUType() === 1} + {/if} diff --git a/Web/Presenters/templates/Support/View.xml b/Web/Presenters/templates/Support/View.xml index f97b2e7a..b906f5f7 100644 --- a/Web/Presenters/templates/Support/View.xml +++ b/Web/Presenters/templates/Support/View.xml @@ -90,31 +90,34 @@ {$comment->getText()|noescape} {/if} + {if $comment->getUType() === 0} - + {/if} - {if $comment->getUType() === 1 && $comment->getMark() === 0} - - {elseif $comment->getMark() === 1} - - {elseif $comment->getMark() === 2} - - {/if} + {if $comment->getUType() === 1} + + {/if} {/if} -{/block} +{/block} \ No newline at end of file diff --git a/Web/routes.yml b/Web/routes.yml index 1ec60651..5e1d1d51 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -17,10 +17,8 @@ routes: handler: "Support->AnswerTicket" - url: "/support/view/{num}" handler: "Support->view" - - url: "/support/comment/{num}/rateGood" - handler: "Support->RateAnswerGood" - - url: "/support/comment/{num}/rateBad" - handler: "Support->RateAnswerBad" + - url: "/support/comment/{num}/rate/{num}" + handler: "Support->RateAnswer" - url: "/al_comments.pl/create/support/{num}" handler: "Support->makeComment" - url: "/al_comments.pl/create/support/reply/{num}" diff --git a/locales/en.strings b/locales/en.strings index 8ff0ee01..70eed29e 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -552,6 +552,16 @@ "support_new_title" = "Enter the topic of your ticket"; "support_new_content" = "Describe the issue or suggestion"; +"support_rate_good_answer" = "This is good answer"; +"support_rate_bad_answer" = "This is bad answer"; +"support_good_answer_user" = "You have left a positive feedback."; +"support_bad_answer_user" = "You have left a negative feedback."; +"support_good_answer_agent" = "User left a positive feedback."; +"support_bad_answer_agent" = "User left a negative feedback."; +"support_rated_good" = "You have left a positive feedback about the answer."; +"support_rated_bad" = "You have left a negative feedback about the answer."; +"wrong_parameters" = "Неверные параметры запроса."; + "comment" = "Comment"; "sender" = "Sender"; diff --git a/locales/ru.strings b/locales/ru.strings index a09cfa40..79f897a4 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -583,6 +583,9 @@ "support_bad_answer_user" = "Вы оставили негативный отзыв."; "support_good_answer_agent" = "Пользователь оставил положительный отзыв"; "support_bad_answer_agent" = "Пользователь оставил негативный отзыв"; +"support_rated_good" = "Вы оставили положительный отзыв об ответе."; +"support_rated_bad" = "Вы оставили негативный отзыв об ответе."; +"wrong_parameters" = "Неверные параметры запроса."; "comment" = "Комментарий"; "sender" = "Отправитель";