diff --git a/server/controllers/staff.php b/server/controllers/staff.php index 8699ac91..0c1df4eb 100644 --- a/server/controllers/staff.php +++ b/server/controllers/staff.php @@ -1,11 +1,13 @@ setGroupPath('/staff'); $systemControllerGroup->addController(new GetStaffController); $systemControllerGroup->addController(new AssignStaffController); +$systemControllerGroup->addController(new UnAssignStaffController); $systemControllerGroup->finalize(); \ No newline at end of file diff --git a/server/controllers/staff/un-assign-ticket.php b/server/controllers/staff/un-assign-ticket.php new file mode 100644 index 00000000..303358dd --- /dev/null +++ b/server/controllers/staff/un-assign-ticket.php @@ -0,0 +1,36 @@ + 'staff_1', + 'requestData' => [ + 'ticketNumber' => [ + 'validation' => DataValidator::validTicketNumber(), + 'error' => ERRORS::INVALID_TICKET + ] + ] + ]; + } + + public function handler() { + $ticketNumber = Controller::request('ticketNumber'); + $user = Controller::getLoggedUser(); + $ticket = Ticket::getByTicketNumber($ticketNumber); + + if($ticket->owner->id == $user->id) { + $user->sharedTicketList->remove($ticket); + $user->store(); + $ticket->owner = null; + $ticket->store(); + Response::respondSuccess(); + } else { + Response::respondError(ERRORS::NO_PERMISSION); + return; + } + } +} \ No newline at end of file