Merged in OS-86-path-staff-get-new-tickets (pull request #67)
OS-86 path staff get new tickets
This commit is contained in:
commit
96c01cc357
|
@ -3,6 +3,7 @@ require_once 'staff/get.php';
|
|||
require_once 'staff/assign-ticket.php';
|
||||
require_once 'staff/un-assign-ticket.php';
|
||||
require_once 'staff/get-tickets.php';
|
||||
require_once 'staff/get-new-tickets.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/staff');
|
||||
|
@ -11,5 +12,6 @@ $systemControllerGroup->addController(new GetStaffController);
|
|||
$systemControllerGroup->addController(new AssignStaffController);
|
||||
$systemControllerGroup->addController(new UnAssignStaffController);
|
||||
$systemControllerGroup->addController(new GetTicketStaffController);
|
||||
$systemControllerGroup->addController(new GetNewTicketsStaffController);
|
||||
|
||||
$systemControllerGroup->finalize();
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
class GetNewTicketsStaffController extends Controller {
|
||||
const PATH = '/get-new-tickets';
|
||||
|
||||
public function validations() {
|
||||
return[
|
||||
'permission' => 'staff_1',
|
||||
'requestData' => []
|
||||
];
|
||||
}
|
||||
public function handler() {
|
||||
$user = Controller::getLoggedUser();
|
||||
$query = ' (';
|
||||
foreach ($user->sharedDepartmentList as $department) {
|
||||
$query .= 'department_id=' . $department->id . ' OR ';
|
||||
}
|
||||
$query = substr($query,0,-3);
|
||||
$query .= ') AND owner_id IS NULL';
|
||||
|
||||
$ticketList = Ticket::find($query);
|
||||
|
||||
Response::respondSuccess($ticketList->toArray());
|
||||
}
|
||||
}
|
|
@ -30,6 +30,11 @@ abstract class DataStore {
|
|||
|
||||
return $dataStoreList;
|
||||
}
|
||||
public static function find($query) {
|
||||
$beanList = RedBean::find(static::TABLE,$query);
|
||||
|
||||
return DataStoreList::getList(ucfirst(static::TABLE),$beanList);
|
||||
}
|
||||
|
||||
private static function validateProp($propToValidate) {
|
||||
$validProp = false;
|
||||
|
|
|
@ -30,5 +30,6 @@ require './staff/assign-ticket.rb'
|
|||
require './staff/un-assign-ticket.rb'
|
||||
require './staff/get-tickets.rb'
|
||||
require './ticket/change-priority.rb'
|
||||
require './staff/get-new-tickets.rb'
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
describe '/staff/get-new-tickets' do
|
||||
request('/user/logout')
|
||||
Scripts.login($staff[:email], $staff[:password], true)
|
||||
|
||||
it 'should get news tickets' do
|
||||
|
||||
result = request('/staff/get-new-tickets', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
(result['data'].size).should.equal(7)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue