Updated TheTool Frontend Framework & Table

This commit is contained in:
Luca Haid
2024-05-08 12:54:26 +00:00
parent 1e57d983b7
commit 58e124a461
46 changed files with 1364 additions and 2535 deletions

View File

@@ -54,19 +54,22 @@ class HistoricTicketController extends mfBaseController {
$json = json_decode(file_get_contents('php://input'), true);
$filters = $json['filters'] ?? [];
$order = $json['order'] ?? [];
$page = $json['pagination']['page'] ?? 1;
$perPage = $json['pagination']['per_page'] ?? 10;
$historicTickets = HistoricTicketModel::getAllHistoricTickets($filters, $perPage, ($page - 1) * $perPage);
$total = HistoricTicketModel::countHistoricTickets($filters);
$historicTickets = HistoricTicketModel::getAllHistoricTickets($filters, $perPage, ($page - 1) * $perPage, $order);
$filtered_available = HistoricTicketModel::countHistoricTickets($filters);
$totalRows = HistoricTicketModel::countHistoricTickets([]);
return [
"rows" => $historicTickets,
"pagination" => [
"page" => $page,
"total_pages" => ceil($total / $perPage),
"total_pages" => ceil($totalRows / $perPage),
"per_page" => $perPage,
"total_rows" => intval($total)
"filtered_available" => intval($filtered_available),
"total_rows" => intval($totalRows)
]
];
}
@@ -88,16 +91,6 @@ class HistoricTicketController extends mfBaseController {
];
}
$rows = HistoricTicketModel::findTicket($query);
return [
"rows" => $rows,
"pagination" => [
"page" => 1,
"total_pages" => 1,
"per_page" => count($rows),
"total_rows" => count($rows)
]
];
return HistoricTicketModel::findTicket($query);
}
}

View File

@@ -88,11 +88,13 @@ class HistoricTicketModel {
return $sql;
}
public static function getAllHistoricTickets($filters, $limit = null, $offset = 0): array {
public static function getAllHistoricTickets($filters, $limit = null, $offset = 0, $order = null): array {
$db = FronkDB::singleton();
$sql = "SELECT * FROM `HistoricTicket` WHERE 1 " . self::getSqlFilter($filters) . " ORDER BY `ticket_number` DESC";
$sql = "SELECT * FROM `HistoricTicket` WHERE 1 " . self::getSqlFilter($filters);
$sql .= $order === null || $order['key'] === null ? " ORDER BY `ticket_number` DESC " : " ORDER BY `" . $order['key'] . "` " . $order['order'];
$sql .= $limit === null ? "" : " LIMIT " . $limit . " OFFSET " . $offset;
// die($sql);
$result = $db->query($sql);
$rows = [];
while ($row = $result->fetch_assoc()) {
@@ -162,7 +164,7 @@ class HistoricTicketModel {
"table_entry" => "ticket",
"ticket_id" => $ticket["id"],
"ticket_number" => $ticket["ticket_number"],
"ctime" => $ticket["ctime"],
"ctime" => intval($ticket["ctime"]),
"ticket_subject" => $ticket["subject"],
];
}
@@ -173,7 +175,7 @@ class HistoricTicketModel {
"ticket_id" => $message["ticket_id"],
"ticket_number" => $message["ticket_number"],
"ticket_subject" => $message["subject"],
"ctime" => $message["ctime"],
"ctime" => intval($message["ctime"]),
"ticket_message" => $message["content"],
];
}