Re-did everything, Now is modulaar and better bro.
This commit is contained in:
30
controllers/DashboardController.php
Normal file
30
controllers/DashboardController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once 'models/TicketModel.php';
|
||||
|
||||
class DashboardController {
|
||||
private $ticketModel;
|
||||
|
||||
public function __construct($conn) {
|
||||
$this->ticketModel = new TicketModel($conn);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
// Get query parameters
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||
$limit = isset($_COOKIE['ticketsPerPage']) ? (int)$_COOKIE['ticketsPerPage'] : 15;
|
||||
$status = isset($_GET['status']) ? $_GET['status'] : 'Open';
|
||||
$sortColumn = isset($_COOKIE['defaultSortColumn']) ? $_COOKIE['defaultSortColumn'] : 'ticket_id';
|
||||
$sortDirection = isset($_COOKIE['sortDirection']) ? $_COOKIE['sortDirection'] : 'desc';
|
||||
|
||||
// Get tickets with pagination
|
||||
$result = $this->ticketModel->getAllTickets($page, $limit, $status, $sortColumn, $sortDirection);
|
||||
|
||||
// Extract data for the view
|
||||
$tickets = $result['tickets'];
|
||||
$totalTickets = $result['total'];
|
||||
$totalPages = $result['pages'];
|
||||
|
||||
// Load the dashboard view
|
||||
include 'views/DashboardView.php';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user