Files
tinker_tickets/controllers/DashboardController.php

30 lines
1.1 KiB
PHP

<?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';
}
}