/**
  * Fetch tickets on the basis of department id
  */
 public function view($get_dep_id)
 {
     $department = kyDepartment::get($get_dep_id);
     $joomlauser = JFactory::getSession()->get('user');
     $kayakouser = kyUser::search($joomlauser->email);
     $userid = 0;
     foreach ($kayakouser as $userObject) {
         $userid = $userObject->GetID();
     }
     if (!empty($userid)) {
         $this->tickets = kyTicket::getAll($department, array(), array(), $kayakouser)->getRawArray();
     } else {
         $this->tickets = array();
     }
 }
require_once 'API/kyIncludes.php';
//Include constants file
require_once 'constants.php';
//Initialize the client
kyConfig::set(new kyConfig(API_URL, API_KEY, SECRET_KEY));
$_ticketDepartmentObjectContainer = kyDepartment::getAll()->filterByModule(kyDepartment::MODULE_TICKETS)->filterByType(kyDepartment::TYPE_PUBLIC);
$_ticketStatusObjectContainer = kyTicketStatus::getAll()->filterByType(kyTicketStatus::TYPE_PUBLIC)->first();
$_ticketStatusContainer = [];
foreach ($_ticketStatusObjectContainer as $_ticketStatusObject) {
    $_ticketStatusID = $_ticketStatusObject->getId();
    $_ticketStatus['ticketstatusid'] = $_ticketStatusID;
    $_ticketStatus['title'] = $_ticketStatusObject->getTitle();
    $_ticketStatus['markasresolved'] = $_ticketStatusObject->getMarkAsResolved();
    $_ticketStatusContainer[$_ticketStatusID] = $_ticketStatus;
}
$_ticketObjectContainer = kyTicket::getAll($_ticketDepartmentObjectContainer, $_ticketStatusObjectContainer, [], [], $_params['clientsdetails']['email'], $_settings['recordsperpage'], 0)->orderByLastActivity();
$_totalTicketCount = kyTicket::getTicketCount($_ticketDepartmentObjectContainer, $_ticketStatusObjectContainer, array(), array(), $clientsdetails['email']);
$_ticketContainer = [];
$_numActiveTickets = 0;
foreach ($_ticketObjectContainer as $_ticketObject) {
    $_ticketID = $_ticketObject->getId();
    $_ticketStatus = $_ticketObject->getStatusId();
    if (isset($_ticketStatusContainer[$_ticketStatus]) && $_ticketStatusContainer[$_ticketStatus]['markasresolved'] == '1') {
        continue;
    } else {
        $_numActiveTickets++;
    }
    $_ticket = [];
    $_ticket['tid'] = $_ticketID;
    $_ticket['date'] = $_ticketObject->getCreationTime();
    $_ticket['department'] = $_ticketObject->getDepartment()->getTitle();
}
if (!isset($_GET['sortby'])) {
    $_sortBy = 'LastActivity';
    $_sortOrder = 'DESC';
    $_order = false;
} else {
    $_sortBy = $_GET['sortby'];
}
$_offset = $_GET['page'] > 1 ? ($_GET['page'] - 1) * $_settings['recordsperpage'] : 0;
if ($_order) {
    $_sortOrderFlip = 'DESC';
} else {
    $_sortOrderFlip = 'ASC';
}
$_totalTicketCount = kyTicket::getTicketCount($_ticketDepartmentContainer, $_ticketStatusObjectContainer, [], [], $clientsdetails['email']);
$_ticketObjectContainer = kyTicket::getAll($_ticketDepartmentContainer, $_ticketStatusObjectContainer, [], [], $clientsdetails['email'], $_settings['recordsperpage'], $_offset, $_sortBy, $_sortOrder);
$_ticketContainer = [];
$_resolvedTicketCount = 0;
foreach ($_ticketObjectContainer as $_ticketObject) {
    $_ticket = [];
    $_ticketID = $_ticketObject->getId();
    $_ticketStatus = $_ticketObject->getStatusId();
    $_ticket['ticketid'] = $_ticketID;
    $_ticket['ticketstatusid'] = $_ticketStatus;
    $_ticket['displayticketid'] = $_ticketObject->getDisplayId();
    $_ticket['departmentid'] = $_ticketObject->getDepartmentId();
    $_ticket['department'] = $_ticketObject->getDepartment()->getTitle();
    $_ticket['status'] = $_ticketObject->getStatus()->getTitle();
    $_ticket['statusbgcolor'] = $_ticketObject->getStatus()->getStatusBackgroundColor();
    $_ticket['priorityid'] = $_ticketObject->getPriorityId();
    $_ticket['priority'] = $_ticketObject->getPriority()->getTitle();
Example #4
0
function get_tickets_by_dept_status($department, $status)
{
    $tickets = kyTicket::getAll(kyDepartment::getAll()->filterByTitle(array("~", "/" . $department . "/i")), kyTicketStatus::getAll()->filterByTitle(array("=", $status)), array(), array());
    return $tickets;
}
Example #5
0
 /**
  * Retrieves all tickets
  *
  * @param string $userEmail
  * @param array  $params
  *
  * @return array $_ticketObjectContainer
  */
 public function getAllTickets($userEmail, $params = array())
 {
     // Load departments
     $objDepartment = Mage::getModel("client/department");
     $_departmentObjectContainer = $objDepartment->getAllDepartments();
     // Load ticket status
     $_ticketStatusObjectContainer = $this->getTicketStatusList();
     if (empty($params['dir'])) {
         $params['dir'] = 'asc';
     }
     if (empty($params['order'])) {
         $params['order'] = 'DisplayId';
     }
     if ($params['dir'] == 'desc') {
         $_sortBy = false;
     } else {
         $_sortBy = true;
     }
     $_orderByFunction = $this->getOrderByFunctionName($params['order']);
     // Load all tickets
     $_ticketObjectContainer = kyTicket::getAll($_departmentObjectContainer, $_ticketStatusObjectContainer)->filterByEmail($userEmail)->{$_orderByFunction}($_sortBy);
     return $_ticketObjectContainer;
 }
 * Search for tickets with "power cable" text in contents of posts or notes.
 */
$tickets = kyTicket::search("power cable", array(kyTicket::SEARCH_CONTENTS, kyTicket::SEARCH_NOTES));
//print them
print "Searching tickets:\n" . $tickets;
/**
 * Search for open and assigned tickets with no replies in all departments.
 * WARNING: Can be time consuming.
 */
$tickets = kyTicket::getAll(kyDepartment::getAll())->filterByStatusId(kyTicketStatus::getAll()->filterByTitle(array("!=", "Closed"))->collectId())->filterByReplies(array('<=', 1))->filterByOwnerStaffId(array("!=", null));
//print them
print "Searching tickets:\n" . $tickets;
/**
 * Filtering, sorting and paging results.
 */
//print available filter methods for User objects
print "User available filter methods:\n";
print_r(kyUser::getAvailableFilterMethods());
//print available order methods for Staff objects
print "Staff available order methods:\n";
print_r(kyStaff::getAvailableOrderMethods());
//find the user with email someuser@example.com
$user = kyUser::getAll()->filterByEmail("*****@*****.**")->first();
//find ticket time tracks with billable time greater than 10 minutes and sort them ascending using time worked
$time_tracks = $ticket->getTimeTracks()->filterByTimeBillable(array(">", 10 * 60))->orderByTimeWorked();
//find department with title "General"
$general_department = kyDepartment::getAll()->filterByTitle("General")->first();
//find tickets in "General" department with word "help" in subject
$tickets = kyTicket::getAll($general_department->getId())->filterBySubject(array("~", "/help/i"));
//assuming 10 items per page, get second page from list of staff users ordered by fullname
$staff_page_2 = kyStaff::getAll()->orderByFullName()->getPage(2, 10);