Basic initial load is working
parent
5255ef0425
commit
1f397af222
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
define('IN_SCRIPT', 1);
|
||||
define('HESK_PATH', '../../../');
|
||||
define('INTERNAL_API_PATH', '../../');
|
||||
require_once(HESK_PATH . 'hesk_settings.inc.php');
|
||||
require_once(HESK_PATH . 'inc/common.inc.php');
|
||||
require_once(INTERNAL_API_PATH . 'core/output.php');
|
||||
require_once(INTERNAL_API_PATH . 'dao/message_log_dao.php');
|
||||
|
||||
hesk_load_internal_api_database_functions();
|
||||
hesk_dbConnect();
|
||||
|
||||
// Routing
|
||||
$request_method = $_SERVER['REQUEST_METHOD'];
|
||||
if ($request_method == 'POST') {
|
||||
$location = $_POST['location'];
|
||||
$from_date = $_POST['fromDate'];
|
||||
$to_date = $_POST['toDate'];
|
||||
$severity_id = $_POST['severityId'];
|
||||
|
||||
$results = search_log($hesk_settings, $location, $from_date, $to_date, $severity_id);
|
||||
print json_encode($results);
|
||||
return http_response_code(200);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
function search_log($hesk_settings, $location, $from_date, $to_date, $severity_id) {
|
||||
$sql = "SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "logging` WHERE 1=1 ";
|
||||
|
||||
if ($location != NULL) {
|
||||
$sql .= "AND `location` LIKE '%" . hesk_dbEscape(hesk_dbLike($location)) . "%' ";
|
||||
}
|
||||
$from_date_format = preg_match("/\d{4}-\d{2}-\d{2}/", $from_date);
|
||||
if ($from_date != NULL
|
||||
&& $from_date_format === 1) {
|
||||
$sql .= "AND `timestamp` >= '" . hesk_dbEscape($from_date) . " 00:00:00' ";
|
||||
}
|
||||
$to_date_format = preg_match("/\d{4}-\d{2}-\d{2}/", $to_date);
|
||||
if ($to_date != NULL
|
||||
&& $to_date_format === 1) {
|
||||
$sql .= "AND `timestamp` <= '" . hesk_dbEscape($to_date) . " 23:59:59' ";
|
||||
}
|
||||
if ($severity_id != NULL) {
|
||||
$sql .= "AND `severity` = " . intval($severity_id);
|
||||
}
|
||||
|
||||
$rs = hesk_dbQuery($sql);
|
||||
|
||||
$results = [];
|
||||
while ($row = hesk_dbFetchAssoc($rs)) {
|
||||
$results[] = $row;
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
$(document).ready(function() {
|
||||
// We should show the latest 50 logs when the user first views the page.
|
||||
var endpoint = getHelpdeskUrl();
|
||||
endpoint += '/internal-api/admin/message-log/';
|
||||
$.ajax({
|
||||
url: endpoint,
|
||||
data: {
|
||||
location: null,
|
||||
fromDate: null,
|
||||
toDate: null,
|
||||
severityId: null
|
||||
},
|
||||
method: 'POST',
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
},
|
||||
error: function(data) {
|
||||
console.error(data);
|
||||
}
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue