Exemplo n.º 1
0
}
if ($_SESSION['userlevel'] != 1) {
    $admin = true;
} else {
    $admin = false;
}
if (isset($_GET['search'])) {
    $gettickets = $ticket->search_tickets($_GET['search'], $page, $admin, $_SESSION['uid']);
} elseif (isset($_GET['from']) && isset($_GET['to'])) {
    $pattern = '^(\\d{4})\\D?(0[1-9]|1[0-2])\\D?([12]\\d|0[1-9]|3[01])$^';
    if (preg_match($pattern, $_GET['from']) && preg_match($pattern, $_GET['to'])) {
        $day = 86400;
        $from = strtotime($_GET['from']);
        $to = strtotime($_GET['to']) + $day;
        if (!$admin) {
            $gettickets = $ticket->get_user_tickets($_SESSION['uid'], $page, 'DESC', 'edittstamp', 15, $from, $to);
        } else {
            $gettickets = $ticket->get_all_tickets($page, 'DESC', 'edittstamp', 15, $from, $to);
        }
    } else {
        $error = "Invalid dates.";
    }
} elseif (isset($_GET['status'])) {
    if ($_GET['status'] == 'Pending' || $_GET['status'] == 'Closed' || $_GET['status'] == 'Open') {
        if (!$admin) {
            $gettickets = $ticket->get_user_tickets($_SESSION['uid'], $page, 'DESC', 'edittstamp', 15, NULL, NULL, $_GET['status']);
        } else {
            $gettickets = $ticket->get_all_tickets($page, 'DESC', 'edittstamp', 15, NULL, NULL, $_GET['status']);
        }
    } else {
        $error = "Invalid status filter.";