/** * Creates new attachment in this post with contents read from physical file. * WARNING: Data is not sent to Kayako unless you explicitly call create() on this method's result. * * @param string $file_path Path to file. * @param string $file_name Optional. Use to set filename other than physical file. * @return kyTicketAttachment */ public function newAttachmentFromFile($file_path, $file_name = null) { return kyTicketAttachment::createNewFromFile($this, $file_path, $file_name); }
} 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'); } } else { header('Location: ' . WHMCS_URL . 'submitticket.php'); } }