mirror of
https://github.com/openvk/openvk
synced 2025-07-07 08:19:49 +03:00
IF(s) fixed + AJAX 2.0 :D
This commit is contained in:
parent
bcdb62675f
commit
5c402c5479
3 changed files with 39 additions and 25 deletions
|
@ -232,20 +232,24 @@ final class SupportPresenter extends OpenVKPresenter
|
|||
$this->assertUserLoggedIn();
|
||||
|
||||
$comment = $this->comments->get($id);
|
||||
if ($this->user->id === $this->tickets->get($comment->getTicketId())->getUser()->getId()) {
|
||||
if ($mark === 1 || $mark === 2) {}
|
||||
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"));
|
||||
if($mark === 1) {
|
||||
// $this->flashFail("succ", tr("information_-1"), tr("support_rated_good"));
|
||||
exit(header("HTTP/1.1 200 OK"));
|
||||
} elseif($mark === 2) {
|
||||
// $this->flashFail("succ", tr("information_-1"), tr("support_rated_bad"));
|
||||
exit(header("HTTP/1.1 200 OK"));
|
||||
}
|
||||
} else {
|
||||
$this->flashFail("err", tr("error"), tr("wrong_parameters"));
|
||||
// $this->flashFail("err", tr("error"), tr("wrong_parameters"));
|
||||
exit(header("HTTP/1.1 400 Bad Request"));
|
||||
}
|
||||
} else {
|
||||
$this->flashFail("err", tr("error"), tr("forbidden"));
|
||||
// $this->flashFail("err", tr("error"), tr("forbidden"));
|
||||
exit(header("HTTP/1.1 403 Forbidden"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,16 +110,14 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if $comment->getUType() === 1}
|
||||
{if $comment->getUType() === 1 && $comment->getMark() != null}}
|
||||
<div class="post-menu">
|
||||
<strong>
|
||||
{if $comment->getMark() != null}
|
||||
{if $comment->getMark() === 1}
|
||||
{_support_good_answer_agent}
|
||||
{elseif $comment->getMark() === 2}
|
||||
{_support_bad_answer_agent}
|
||||
{/if}
|
||||
{/if}
|
||||
</strong>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
@ -6,14 +6,26 @@
|
|||
{/block}
|
||||
|
||||
{block content}
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
function markAnswer(id, mark) {
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "/support/comment/" + id + "/rate/" + mark);
|
||||
xhr.send();
|
||||
let url = "/support/comment/" + id + "/rate/" + mark;
|
||||
$.ajax(url, {
|
||||
error: errorHandler,
|
||||
success: success(id, mark)
|
||||
});
|
||||
}
|
||||
|
||||
location.reload();
|
||||
return false;
|
||||
function success(id, mark) {
|
||||
if(mark == 1) {
|
||||
document.getElementById("markText-" + id).innerHTML = {_support_good_answer_user};
|
||||
} else {
|
||||
document.getElementById("markText-" + id).innerHTML = {_support_bad_answer_user};
|
||||
}
|
||||
}
|
||||
|
||||
function errorHandler(id, mark) {
|
||||
document.getElementById("markText" + id).innerHTML = {_error};
|
||||
}
|
||||
</script>
|
||||
{if $ticket->isDeleted() == 0 }
|
||||
|
@ -107,21 +119,21 @@
|
|||
</div>
|
||||
{/if}
|
||||
|
||||
{if $comment->getUType() === 1}
|
||||
{if $comment->getUType() === 1 && $comment->getMark() != null}}
|
||||
<div class="post-menu">
|
||||
{if $comment->getMark() != null}
|
||||
<strong>
|
||||
<strong id="markText-{$comment->getId()}">
|
||||
{if $comment->getMark() === 1}
|
||||
{_support_good_answer_user}
|
||||
{elseif $comment->getMark() === 2}
|
||||
{_support_bad_answer_user}
|
||||
{/if}
|
||||
</strong>
|
||||
{else}
|
||||
{if $comment->getMark() === 0}
|
||||
<a onClick="markAnswer({$comment->getId()}, 1)">{_support_rate_good_answer}</a>
|
||||
|
|
||||
<a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue