Add get ticket by tracking ID
This commit is contained in:
parent
40d8b2b4a4
commit
0a3d50009a
@ -15,6 +15,8 @@ $request_method = $_SERVER['REQUEST_METHOD'];
|
|||||||
if ($request_method == 'GET') {
|
if ($request_method == 'GET') {
|
||||||
if (isset($_GET['id'])) {
|
if (isset($_GET['id'])) {
|
||||||
$results = get_ticket_for_id($hesk_settings, $_GET['id']);
|
$results = get_ticket_for_id($hesk_settings, $_GET['id']);
|
||||||
|
} elseif (isset($_GET['trackid'])) {
|
||||||
|
$results = get_ticket_by_tracking_id($hesk_settings, $_GET['trackid']);
|
||||||
} else {
|
} else {
|
||||||
$results = get_ticket_for_id($hesk_settings);
|
$results = get_ticket_for_id($hesk_settings);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,12 @@ function get_ticket_for_id($hesk_settings, $id = NULL) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$results = build_results($response);
|
||||||
|
|
||||||
|
return $id == NULL ? $results : $results[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_results($response) {
|
||||||
$results = [];
|
$results = [];
|
||||||
while ($row = hesk_dbFetchAssoc($response)) {
|
while ($row = hesk_dbFetchAssoc($response)) {
|
||||||
$row['id'] = intval($row['id']);
|
$row['id'] = intval($row['id']);
|
||||||
@ -34,5 +40,19 @@ function get_ticket_for_id($hesk_settings, $id = NULL) {
|
|||||||
$results[] = $row;
|
$results[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $id == NULL ? $results : $results[0];
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_ticket_by_tracking_id($hesk_settings, $trackid) {
|
||||||
|
$sql = "SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` WHERE `trackid` = '"
|
||||||
|
. hesk_dbEscape($trackid) . "'";
|
||||||
|
|
||||||
|
$response = hesk_dbQuery($sql);
|
||||||
|
|
||||||
|
if (hesk_dbNumRows($response) == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$results = build_results($response);
|
||||||
|
return $results[0];
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user