public function createTicket($data) { $default_status_id = kyTicketStatus::getAll()->filterByTitle('New')->first()->getId(); $default_priority_id = kyTicketPriority::getAll()->filterByTitle('Normal')->first()->getId(); $default_type_id = $data['issue']; kyTicket::setDefaults($default_status_id, $default_priority_id, $default_type_id); $general_department = kyDepartment::getAll()->filterByTitle('Customer Service')->filterByModule(kyDepartment::MODULE_TICKETS)->first(); $ticket = kyTicket::createNewAuto($general_department, $data['name'], $data['email'], $data['comment'], $data['subject'])->create(); return true; }
/** * Returns list of departments in the form of array: * array( * <top department id> => array( * 'department' => <top department object>, * 'child_departments' => array(<child department object>, ...) * ), * ... * ) * * @return array */ function getDepartmentsTree() { $departments_tree = array(); $all_departments = kyDepartment::getAll()->filterByModule(kyDepartment::MODULE_TICKETS)->filterByType(kyDepartment::TYPE_PUBLIC); $top_departments = $all_departments->filterByParentDepartmentId(null)->orderByDisplayOrder(); foreach ($top_departments as $top_department) { /* @var $top_department kyDepartment */ $departments_tree[$top_department->getId()] = array('department' => $top_department, 'child_departments' => $all_departments->filterByParentDepartmentId($top_department->getId())->orderByDisplayOrder()); } return $departments_tree; }
/** * Sets the department the ticket belongs to. * * @param kyDepartment $department Department. * @return kyTicket */ public function setDepartment($department) { $this->department = ky_assure_object($department, 'kyDepartment'); $this->department_id = $this->department !== null ? $this->department->getId() : null; return $this; }
/** * Creates new subdepartment in this department. Module of new department will be the same as parent department's module. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $title Title of new department. * @param string $type Type of new department - one of kyDepartment::TYPE_* constants. * @return kyDepartment */ public function newSubdepartment($title, $type = self::TYPE_PUBLIC) { $new_department = kyDepartment::createNew($title, $type, $this->getModule()); $new_department->setParentDepartment($this); return $new_department; }
<?php /** * @copyright 2001-2015 Kayako * @license https://www.freebsd.org/copyright/freebsd-license.html * @link https://github.com/kayako/whmcs-integration */ //Include config file require_once __DIR__ . '/config.php'; //Include all necessary classes and helper methods 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();
</tr> <tr> <td><?php echo $list->getDisplayId(); ?> </td> <td><?php echo date('M d, Y h:i A', strtotime($list->getLastActivity())); ?> </td> <td><?php echo $list->getLastReplier(); ?> </td> <td><?php echo kyDepartment::get($list->getDepartmentId())->getTitle(); ?> </td> <td><?php echo kyTicketType::get($list->getTypeId())->getTitle(); ?> </td> <td><?php echo kyTicketStatus::get($list->getStatusId())->getTitle(); ?> </td> <td style=" background-color: <?php echo kyTicketPriority::get($list->getPriorityId())->getBackgroundColor(); ?> ;"> <span style="color: <?php
/** * Returns Department list * * @return kyResultSet */ public function getAllDepartments() { $_departments = kyDepartment::getAll(); return $_departments; }
$smarty->assign('_templateURL', getcwd() . '/templates/kayako'); $smarty->assign('_imageURL', WHMCS_URL . 'templates/kayako/images'); $templatefile = 'ticketform'; } else { header('Location: ' . WHMCS_URL . 'submitticket.php'); } } else { if ($_REQUEST['step'] == 3) { if (!empty($_POST)) { //Set Defaults for a new ticket $_defaultStatusID = kyTicketStatus::getAll()->filterByType(kyTicketStatus::TYPE_PUBLIC)->first()->getId(); $_defaultPriorityID = kyTicketPriority::getAll()->filterByType(kyTicketStatus::TYPE_PUBLIC)->first()->getId(); $_defaultTypeID = kyTicketType::getAll()->filterByType(kyTicketStatus::TYPE_PUBLIC)->first()->getId(); kyTicket::setDefaults($_defaultStatusID, $_defaultPriorityID, $_defaultTypeID); //Create ticket $_department = kyDepartment::get($_POST['departmentid']); $_priority = kyTicketPriority::get($_POST['ticketpriorityid']); $_ticket = kyTicket::createNewAuto($_department, $clientsdetails['firstname'] . ' ' . $clientsdetails['lastname'], $clientsdetails['email'], $_POST['ticketmessage'], $_POST['ticketsubject'])->setPriority($_priority)->setIgnoreAutoResponder($_settings['ignoreautoresponder'])->create(); $_ticketPosts = $_ticket->getPosts(); //Save ticket attachments foreach ($_FILES['ticketattachments']['tmp_name'] as $_key => $_ticketAttachment) { kyTicketAttachment::createNewFromFile($_ticketPosts[0], $_ticketAttachment, $_FILES['ticketattachments']['name'][$_key])->create(); } //Save custom fields $_ticket->setCustomFieldValuesFromPOST(); $_ticket->updateCustomFields(); $smarty->assign('_ticketDisplayID', $_ticket->getDisplayId()); $smarty->assign('_ticketSubject', $_POST['ticketsubject']); $smarty->assign('_ticketMessage', nl2br($_POST['ticketmessage'])); $templatefile = 'ticketConfirmation'; } else {
/** * Returns whether this ticket status is visible under specified department. * * @param kyDepartment|int $department Department or its identifier. * @return bool * @filterBy */ public function isAvailableInDepartment($department) { if ($this->department_id == null) { return true; } if ($department instanceof kyDepartment) { $department_id = $department->getId(); } else { $department_id = intval($department); } return $this->department_id === $department_id; }
?> </div> <table id="ticket"> <tr> <th>Department</th> <th>Owner</th> <th>Type</th> <th>Status</th> <th style="background-color: <?php echo kyTicketPriority::get($ticket_details->getPriorityId())->getBackgroundColor(); ?> ;">Priority</th> </tr> <tr> <td><?php echo kyDepartment::get($ticket_details->getDepartmentId())->getTitle(); ?> </td> <td><?php echo $ticket_details->getFullName(); ?> </td> <td><?php echo kyTicketType::get($ticket_details->getTypeId())->getTitle(); ?> </td> <td> <select name="status"> <?php foreach ($status_list as $status) { ?>
/** * Create urgent ticket providing only name and e-mail of the user. * * @return ticket mask id */ public function createTickets() { $input = JFactory::getApplication()->input; $form_value = $input->getArray(array('fname' => null, 'mail' => null, 'message' => null, 'subject' => null, 'dep_type' => null, 'priority' => null, 'status' => null, 'type' => null)); if ($form_value['dep_type'] == null || $form_value['fname'] == null || $form_value['mail'] == null || $form_value['priority'] == null || $form_value['status'] == null || $form_value['type'] == null || $form_value['subject'] == null || $form_value['message'] == null) { return false; } else { require_once 'modules/mod_kayako/includes/kayako-php-api/kyIncludes.php'; JTickets::init(); kyTicket::setDefaults($form_value['status'], $form_value['priority'], $form_value['type']); //Create urgent ticket providing only name and e-mail of the user. $ticket = kyTicket::createNewAuto(kyDepartment::get($form_value['dep_type']), $form_value['fname'], $form_value['mail'], $form_value['message'], $form_value['subject'])->create(); //get ticket id $ticket_mask_id = $ticket->getDisplayId(); return $ticket_mask_id; } }
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; }
* 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);