mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-30 17:25:11 +02:00
Merges search-tickets with get-all-tickets
This commit is contained in:
parent
5405f2b9ec
commit
ac11db5505
@ -32,14 +32,12 @@ export default {
|
||||
};
|
||||
},
|
||||
|
||||
retrieveAllTickets(page = 1, closed = 0) {
|
||||
console.log('Closed is:');
|
||||
console.log(closed);
|
||||
retrieveAllTickets(page = 1, query = '', closed = 0) {
|
||||
return {
|
||||
type: 'ALL_TICKETS',
|
||||
payload: API.call({
|
||||
path: '/staff/get-all-tickets',
|
||||
data: {page, closed}
|
||||
data: {page, query, closed}
|
||||
})
|
||||
};
|
||||
},
|
||||
|
@ -2,18 +2,19 @@
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
/**
|
||||
* @api {post} /staff/get-all-tickets Get all tickets
|
||||
* @api {post} /staff/get-all-tickets Get all tickets according to search
|
||||
* @apiVersion 4.3.0
|
||||
*
|
||||
* @apiName Get all tickets
|
||||
*
|
||||
* @apiGroup Staff
|
||||
*
|
||||
* @apiDescription This path retrieves all tickets.
|
||||
* @apiDescription This path retrieves all tickets according to search and opened/closed filters.
|
||||
*
|
||||
* @apiPermission staff1
|
||||
*
|
||||
* @apiParam {Number} page The page number.
|
||||
* @apiParam {String} query Query string to search.
|
||||
* @apiParam {Boolean} closed Include closed tickets.
|
||||
*
|
||||
* @apiUse NO_PERMISSION
|
||||
@ -59,11 +60,24 @@ class GetAllTicketsStaffController extends Controller {
|
||||
private function getTicketList() {
|
||||
$page = Controller::request('page');
|
||||
|
||||
$query = $this->getStaffDepartmentsQueryFilter();
|
||||
$query = $this->getSearchQuery();
|
||||
$query .= $this->getStaffDepartmentsQueryFilter();
|
||||
$query .= $this->getClosedFilter();
|
||||
$query .= ' ORDER BY id DESC LIMIT 10 OFFSET ' . (($page-1)*10);
|
||||
$query .= "ORDER BY CASE WHEN (title LIKE ?) THEN 1 ELSE 2 END ASC LIMIT 10 OFFSET " . (($page-1)*10);
|
||||
|
||||
return Ticket::find($query);
|
||||
return Ticket::find($query, [
|
||||
Controller::request('query') . '%',
|
||||
'%' . Controller::request('query') . '%',
|
||||
Controller::request('query') . '%'
|
||||
]);
|
||||
}
|
||||
|
||||
private function getSearchQuery() {
|
||||
$page = Controller::request('page');
|
||||
|
||||
$query = " (title LIKE ? OR title LIKE ?) AND ";
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function getTotalPages() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user