* @version 3.0
 */
use WHMCS\ClientArea;
define("CLIENTAREA", true);
## Required files
require_once ROOTDIR . "/includes/sirportly/functions.php";
include_once ROOTDIR . "/includes/sirportly/config.php";
$ca = new ClientArea();
$ca->setPageTitle($_LANG['supportticketsviewticket']);
$ca->addToBreadCrumb('index.php', $whmcs->get_lang('globalsystemname'));
$ca->addToBreadCrumb('clientarea.php', $whmcs->get_lang('clientareatitle'));
$ca->addToBreadCrumb('supporttickets.php', $whmcs->get_lang('supportticketspagetitle'));
$ca->addToBreadCrumb("viewticket.php", $whmcs->get_lang('supportticketsviewticket'));
$ca->initPage();
$ca->setTemplate('/templates/sirportly/viewticket.tpl');
$ca->requireLogin();
## Fetch the ticket from Sirportly
$response = _doSirportlyAPICall('tickets/ticket', array('reference' => $tid));
## Fetch an array of sirportly contact_ids
$contact_ids = sirportlyContacts($_SESSION['uid'], $_SESSION['cid']);
## Check to see if we encountered any errors
if (checkForSirportlyErrors($response)) {
    $ca->assign('invalidTicketId', true);
    $ca->output();
    return;
}
## Check to ensure that the ID matches and the user has access
if ($response['id'] != $c || !in_array($response['contact']['id'], $contact_ids)) {
    $ca->assign('invalidTicketId', true);
    $ca->output();
    return;