<?php

/**
 * Sirportly WHMCS Support Tickets Module
 * @copyright Copyright (c) 2015 aTech Media Ltd
 * @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['supportticketspagetitle']);
$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->initPage();
## Setup the menus
Menu::addContext('support_module', 'sirportly');
## Load the sirportly contact
$sirportlyContact = findOrCreateSirportlyContact($_SESSION['uid'], $_SESSION['cid']);
## Fetch an array of sirportly contact_ids
$contact_ids = sirportlyContacts($_SESSION['uid'], $_SESSION['cid']);
## Fetch the tickets
$sirportlyTickets = sirportlyTickets($contact_ids);
foreach ($sirportlyTickets['results'] as $ticket) {
    $tickets[] = array('tid' => $ticket[1], 'c' => $ticket[0], 'department' => $ticket[4], 'subject' => $ticket[2], 'statusColor' => '#' . $ticket[5], 'status' => $ticket[6], 'lastreply' => fromMySQLDate($ticket[3], true, true));
}
$ca->assign('tickets', $tickets);
$ca->assign('noSearch', true);
<?php

/**
 * Sirportly WHMCS Support Tickets Module
 * @copyright Copyright (c) 2015 aTech Media Ltd
 * @version 3.0
 */
use WHMCS\ClientArea;
define("CLIENTAREA", true);
## Required files
require_once ROOTDIR . "/includes/sirportly/functions.php";
include ROOTDIR . "/includes/sirportly/config.php";
$ca = new ClientArea();
$ca->setPageTitle($_LANG['supportticketssubmitticket']);
$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('submitticket.php', $whmcs->get_lang('supportticketssubmitticket'));
$ca->initPage();
## Return custom fields
if ($action == 'fetchcustomfields') {
    $sirportlyCustomFields = sirportlyCustomFields($deptid, $customfield);
    $ca->assign("customfields", $sirportlyCustomFields);
    echo $smarty->fetch($CONFIG['Template'] . "/supportticketsubmit-customfields.tpl");
    exit;
}
## Setup the menus
Menu::addContext('support_module', 'sirportly');
## Load the sirportly contact
$sirportlyContact = findOrCreateSirportlyContact($_SESSION['uid'], $_SESSION['cid']);
# Fetch the WHMCS client
<?php

/**
 * Sirportly WHMCS Support Tickets Module
 * @copyright Copyright (c) 2015 aTech Media Ltd
 * @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;
}