Guillermo - Ticket-seen [skip ci]

This commit is contained in:
ivan 2016-10-21 16:12:17 -03:00
parent ef3bd809aa
commit 221288402e
9 changed files with 21 additions and 7 deletions

View File

@ -34,6 +34,7 @@ class AssignStaffController extends Controller {
} else { } else {
$this->user->sharedTicketList->add($this->ticket); $this->user->sharedTicketList->add($this->ticket);
$this->ticket->owner = $this->user; $this->ticket->owner = $this->user;
$this->ticket->unread = true;
$this->ticket->store(); $this->ticket->store();
$this->user->store(); $this->user->store();

View File

@ -26,6 +26,7 @@ class UnAssignStaffController extends Controller {
$user->sharedTicketList->remove($ticket); $user->sharedTicketList->remove($ticket);
$user->store(); $user->store();
$ticket->owner = null; $ticket->owner = null;
$ticket->uread = true;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();
} else { } else {

View File

@ -34,6 +34,7 @@ class ChangeDepartmentController extends Controller {
} }
$ticket->department = $department; $ticket->department = $department;
$ticket->unread = true;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();
} }

View File

@ -28,6 +28,7 @@ class ChangePriorityController extends Controller {
if($ticket->owner && $user->id === $ticket->owner->id) { if($ticket->owner && $user->id === $ticket->owner->id) {
$ticket->priority = $priority; $ticket->priority = $priority;
$ticket->unread = true;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();
} else { } else {

View File

@ -32,6 +32,11 @@ class CloseController extends Controller {
return; return;
} }
if(Controller::isStaffLogged()) {
$ticket->unread = true;
} else {
$ticket->unreadStaff = true;
}
$ticket->closed = true; $ticket->closed = true;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();

View File

@ -51,11 +51,11 @@ class CommentController extends Controller {
)); ));
if(Controller::isStaffLogged()) { if(Controller::isStaffLogged()) {
$comment->authorUser = Controller::getLoggedUser(); $this->ticket->unread = true;
} else { } else {
$comment->authorUser = Controller::getLoggedUser(); $this->ticket->unreadStaff = true;
} }
$comment->authorUser = Controller::getLoggedUser();
$this->ticket->addEvent($comment); $this->ticket->addEvent($comment);
$this->ticket->store(); $this->ticket->store();
} }

View File

@ -58,6 +58,7 @@ class CreateController extends Controller {
'file' => '', 'file' => '',
'date' => Date::getCurrentDate(), 'date' => Date::getCurrentDate(),
'unread' => false, 'unread' => false,
'unreadStaff' => true,
'closed' => false, 'closed' => false,
)); ));

View File

@ -30,7 +30,11 @@ class ReOpenController extends Controller {
Response::respondError(ERRORS::NO_PERMISSION); Response::respondError(ERRORS::NO_PERMISSION);
return; return;
} }
if(Controller::isStaffLogged()) {
$ticket->unread = true;
} else {
$ticket->unreadStaff = true;
}
$ticket->closed = false; $ticket->closed = false;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();

View File

@ -21,13 +21,13 @@ class SeenController extends Controller {
$user = Controller::getLoggedUser(); $user = Controller::getLoggedUser();
$ticket = Ticket::getByTicketNumber($ticketnumber); $ticket = Ticket::getByTicketNumber($ticketnumber);
if (Controller::isStaffLogged() && $ticket->owner_id === $user->id) { if (Controller::isStaffLogged() && $ticket->owner && $ticket->owner->id === $user->id) {
$ticket->unreadStaff = false; $ticket->unreadStaff = false;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();
return; return;
} }
if (!Controller::isStaffLogged() && $user->id === $ticket->author_id) { if (!Controller::isStaffLogged() && $ticket->author && $user->id === $ticket->author->id) {
$ticket->unread = false; $ticket->unread = false;
$ticket->store(); $ticket->store();
Response::respondSuccess(); Response::respondSuccess();