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; }
/** * Fetch the list of departments */ public function fetchAllDepartment() { $this->init(); $departments_tree = $this->getDepartmentsTree(); foreach ($departments_tree as $key => $val) { $options_array[$key] = $val['department']; foreach ($val['child_departments'] as $child_dept_key => $child_dept_value) { $options_array[$child_dept_key] = $child_dept_value; } } $this->all_departments = $options_array; $this->priority_list = kyTicketPriority::getAll(); $this->status_list = kyTicketStatus::getAll(); $this->ticket_type = kyTicketType::getAll(); }
/** * Sets this ticket priority. * * @param kyTicketPriority $ticket_priority * @return kyTicket */ public function setPriority($ticket_priority) { $this->priority = ky_assure_object($ticket_priority, 'kyTicketPriority'); $this->priority_id = $this->priority !== null ? $this->priority->getId() : null; return $this; }
?> </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 echo kyTicketPriority::get($list->getPriorityId())->getForegroundColor(); ?> ;"> <?php echo kyTicketPriority::get($list->getPriorityId())->getTitle(); ?> </span> </td> </tr> <?php } ?> <?php } else { ?> <tr> <td colspan="7">No records...</td> </tr> <?php }
$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 { header('Location: ' . WHMCS_URL . 'submitticket.php');
<?php } //we are rendering General Information form if ($render === 'general') { //load the department we've chosen in Department form $department = kyDepartment::get($department_id); //load user group for ticket type and priority visibility test $user_group = kyUserGroup::getAll()->filterByTitle(USER_GROUP_TITLE)->first(); //load public ticket types $ticket_types = kyTicketType::getAll()->filterByType(kyTicketType::TYPE_PUBLIC); //get only types visible to user group if ($user_group !== null) { $ticket_types = $ticket_types->filterByIsVisibleToUserGroup(true, $user_group); } //load public ticket priorities $ticket_priorities = kyTicketPriority::getAll()->filterByType(kyTicketPriority::TYPE_PUBLIC); //get only priorities visible to user group if ($user_group !== null) { $ticket_priorities = $ticket_priorities->filterByIsVisibleToUserGroup(true, $user_group); } ?> <form method="POST"> <input type="hidden" name="page" id="page" value="general"> <input type="hidden" name="department_id" id="department_id" value="<?php echo $department_id; ?> "> <fieldset> <legend>General Information</legend>
" <?php if ($status->id == $ticket_details->getStatusId()) { echo "selected"; } ?> ><?php echo $status->title; ?> </option> <?php } ?> </select> </td> <td style="background-color: <?php echo kyTicketPriority::get($ticket_details->getPriorityId())->getBackgroundColor(); ?> ;"> <select name="priority"> <?php foreach ($priority_list as $priority) { ?> <option value="<?php echo $priority->id; ?> " <?php if ($priority->id == $ticket_details->getPriorityId()) { echo "selected"; } ?>
/** * Returns Ticket Priority list * * @return array $_ticketPriorities */ public function getTicketPriorityList() { // Load ticket priorities $_ticketPriorities = kyTicketPriority::getAll()->filterByType(kyTicketPriority::TYPE_PUBLIC); return $_ticketPriorities; }
* Load some user organization. */ $user_organization = kyUserOrganization::getAll()->first(); print 'Fetched: ' . $user_organization; /** * Create new user in Registered group: * fullname: Anno Ying * email: anno.ying@example.com * password: qwerty123 */ $user = $registered_user_group->newUser("Anno Ying", "*****@*****.**", "qwerty123")->setUserOrganization($user_organization)->setSalutation(kyUser::SALUTATION_MR)->setSendWelcomeEmail(false)->create(); print 'Created: ' . $user; /** * Load urgent priority. */ $priority_urgent = kyTicketPriority::getAll()->filterByTitle("Urgent")->first(); print 'Fetched: ' . $priority_urgent; /** * Create urgent ticket as the user created in previous step. */ $ticket = $user->newTicket($printers_department, "The printer on 4th floor in building B2 doesn't print at all. Fix it quickly, please.", "Printer not working (example)")->setPriority($priority_urgent)->create(); print 'Created: ' . $ticket; /** * Get ticket display id and print it. */ $ticket_display_id = $ticket->getDisplayId(); printf("The ticket was created and its ID is: %s\n", $ticket_display_id); /** * Ticket processing. */ /**
$_ticketStatusContainer = []; foreach ($_ticketStatusObjectContainer as $_ticketStatusObject) { $_ticketStatus['ticketstatusid'] = $_ticketStatusObject->getId(); $_ticketStatus['title'] = $_ticketStatusObject->getTitle(); $_ticketStatus['displayorder'] = $_ticketStatusObject->getId(); $_ticketStatus['markasresolved'] = $_ticketStatusObject->getMarkAsResolved(); $_ticketStatus['statustype'] = $_ticketStatusObject->getType(); $_ticketStatus['displaycount'] = $_ticketStatusObject->getDisplayCount(); $_ticketStatus['statuscolor'] = $_ticketStatusObject->getStatusColor(); $_ticketStatus['statusbgcolor'] = $_ticketStatusObject->getStatusBackgroundColor(); $_ticketStatus['displayicon'] = $_ticketStatusObject->getDisplayIcon(); $_ticketStatus['triggersurvey'] = $_ticketStatusObject->getTriggerSurvey(); $_ticketStatusContainer[$_ticketStatusObject->getId()] = $_ticketStatus; } //Process ticket priorities $_ticketPriorityObjectContainer = kyTicketPriority::getAll()->filterByType(kyDepartment::TYPE_PUBLIC); $_ticketPriorityContainer = []; foreach ($_ticketPriorityObjectContainer as $_ticketPriorityObject) { $_ticketPriority['priorityid'] = $_ticketPriorityObject->getId(); $_ticketPriority['title'] = $_ticketPriorityObject->getTitle(); $_ticketPriority['displayorder'] = $_ticketPriorityObject->getDisplayOrder(); $_ticketPriority['type'] = $_ticketPriorityObject->getType(); $_ticketPriority['frcolorcode'] = $_ticketPriorityObject->getForegroundColor(); $_ticketPriority['bgcolorcode'] = $_ticketPriorityObject->getBackgroundColor(); $_ticketPriority['displayicon'] = $_ticketPriorityObject->getDisplayIcon(); $_ticketPriority['uservisibilitycustom'] = $_ticketPriorityObject->getUserVisibilityCustom(); $_ticketPriorityContainer[$_ticketPriorityObject->getId()] = $_ticketPriority; } if (isset($_GET['aid'])) { $_ticketAttachment = kyTicketAttachment::get($_GET['tid'], $_GET['aid']); Download($_ticketAttachment->getFileName(), $_ticketAttachment->getContents());