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; }
/** * Creates a ticket * * @param array $data * * @return string $_ticketMaskID */ public function createTicket($data) { // Load department $objDepartment = Mage::getModel("client/department"); $_department = $objDepartment->getDepartmentByID($data['departmentID']); // Load default ticket status $_statusID = kyTicketStatus::getAll()->filterByType(kyTicketStatus::TYPE_PUBLIC)->first()->getId(); kyTicket::setDefaults($_statusID, $data['ticketpriorityid'], $data['tickettypeid']); // Create new ticket $ticket = kyTicket::createNewAuto($_department, $data['ticketfullname'], $data['ticketemail'], $data['ticketmessage'], $data['ticketsubject'])->create(); // Retrieve ticket mask id $_ticketMaskID = $ticket->getDisplayId(); return $_ticketMaskID; }
/** * Creates new ticket in this department with creator user automatically created by server using provided name and e-mail. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $creator_full_name Creator full name. * @param string $creator_email Creator e-mail. * @param string $contents Contents of the first post. * @param string $subject Subject of new ticket. * @return kyTicket */ public function newTicketAuto($creator_full_name, $creator_email, $contents, $subject) { return kyTicket::createNewAuto($this, $creator_full_name, $creator_email, $contents, $subject); }
$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'); }
<input type="submit" name="submit_general" value="Submit"> </form> <?php } //we are submitting the ticket; we are doing this before rendering Custom Fields form because there is no way to load them before creating the ticket (see http://dev.kayako.com/browse/SWIFT-2391 for improvement request) if ($render === 'submit') { //load the department we've chosen in Department form /** @var $department kyDepartment */ $department = kyDepartment::get($department_id); //load default ticket status (based on DEFAULT_TICKET_STATUS_NAME constant defined at top of the file) $status_id = kyTicketStatus::getAll()->filterByTitle(DEFAULT_TICKET_STATUS_NAME)->first()->getId(); //initialize default ticket status (loaded line before), priority (from General Information form) and type (from General Information form) kyTicket::setDefaults($status_id, $priority_id, $type_id); //create the ticket /** @var $ticket kyTicket */ $ticket = kyTicket::createNewAuto($department, $creator_full_name, $creator_email, $contents, $subject)->create(); //get ticket id $ticket_id = $ticket->getId(); //load ticket custom fields $file_custom_field_present = true; $ticket_custom_fields = get_ticket_custom_fields($ticket, $file_custom_field_present); if (count($ticket_custom_fields) > 0) { //load custom field default values $custom_field_values = array(); foreach ($ticket_custom_fields as $custom_fields) { foreach ($custom_fields as $custom_field) { /* @var $custom_field kyCustomField */ $field_default_value = $custom_field->getDefinition()->getDefaultValue(); if ($field_default_value === null) { continue; }
/** * 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; } }