Merged in OS-116-Ticket-events (pull request #78)

OS-116 ticket events
This commit is contained in:
Ivan Diaz 2016-11-20 21:59:18 +00:00
commit 323b481c62
7 changed files with 48 additions and 6 deletions

View File

@ -35,6 +35,13 @@ class AssignStaffController extends Controller {
$this->user->sharedTicketList->add($this->ticket);
$this->ticket->owner = $this->user;
$this->ticket->unread = true;
$event = Ticketevent::getEvent(Ticketevent::ASSIGN);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'date' => Date::getCurrentDate()
));
$this->ticket->addEvent($event);
$this->ticket->store();
$this->user->store();

View File

@ -27,6 +27,13 @@ class UnAssignStaffController extends Controller {
$user->store();
$ticket->owner = null;
$ticket->unread = true;
$event = Ticketevent::getEvent(Ticketevent::UN_ASSIGN);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->store();
Response::respondSuccess();
} else {

View File

@ -33,6 +33,13 @@ class ChangeDepartmentController extends Controller {
return;
}
$event = Ticketevent::getEvent(Ticketevent::DEPARTMENT_CHANGED);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'content' => $department->name,
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->department = $department;
$ticket->unread = true;
$ticket->store();

View File

@ -29,6 +29,13 @@ class ChangePriorityController extends Controller {
if($ticket->owner && $user->id === $ticket->owner->id) {
$ticket->priority = $priority;
$ticket->unread = true;
$event = Ticketevent::getEvent(Ticketevent::PRIORITY_CHANGED);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'content' => $ticket->priority,
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->store();
Response::respondSuccess();
} else {

View File

@ -37,6 +37,13 @@ class CloseController extends Controller {
} else {
$ticket->unreadStaff = true;
}
$event = Ticketevent::getEvent(Ticketevent::CLOSE);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->closed = true;
$ticket->store();
Response::respondSuccess();

View File

@ -35,6 +35,12 @@ class ReOpenController extends Controller {
} else {
$ticket->unreadStaff = true;
}
$event = Ticketevent::getEvent(Ticketevent::RE_OPEN);
$event->setProperties(array(
'authorUser' => Controller::getLoggedUser(),
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->closed = false;
$ticket->store();
Response::respondSuccess();

View File

@ -5,20 +5,21 @@ class Ticketevent extends DataStore {
const COMMENT = 'COMMENT';
const ASSIGN = 'ASSIGN';
const UNASSIGN = 'UNASSIGN';
const UN_ASSIGN = 'UN_ASSIGN';
const CLOSE = 'CLOSE';
const REOPEN = 'REOPEN';
const RE_OPEN = 'RE_OPEN';
const DEPARTMENT_CHANGED = 'DEPARTMENT_CHANGED';
const PRIORITY_CHANGED = 'PRIORITY_CHANGED';
private static function getEventTypes() {
return [
'COMMENT',
'UNASSIGN',
'ASSIGN',
'UN_ASSIGN',
'CLOSE',
'REOPEN',
'RE_OPEN',
'DEPARTMENT_CHANGED',
'PRIORITY_CHANGED',
'PRIORITY_CHANGED'
];
}