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();
 }
示例#3
0
 /**
  * Sets ticket status.
  *
  * @param kyTicketStatus $ticket_status Ticket status.
  * @return kyTicket
  */
 public function setStatus($ticket_status)
 {
     $this->status = ky_assure_object($ticket_status, 'kyTicketStatus');
     $this->status_id = $this->status !== null ? $this->status->getId() : null;
     return $this;
 }
/**
 * @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();
    $_ticketStatus = $_ticketObject->getStatusId();
        ?>
</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 
        echo kyTicketPriority::get($list->getPriorityId())->getForegroundColor();
        ?>
;">
                        <?php 
        echo kyTicketPriority::get($list->getPriorityId())->getTitle();
        ?>
                    </span>
					</td>
             }
         }
         $smarty->assign('_customFieldGroupContainer', $_customFieldGroupContainer);
         $smarty->assign('_ticketFormURL', WHMCS_URL . 'submitticket.php?step=3');
         $smarty->assign('_departmentID', $_POST['departmentid']);
         $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();
">Provide the contents of your request.</span>
			</label>

		</fieldset>

		<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) {
require_once 'modules/mod_kayako/includes/kayako-php-api/kyIncludes.php';
require_once 'modules/mod_kayako/helper.php';
$email = JFactory::getUser()->email;
if (empty($email) || !isset($email)) {
    throw new kyException();
}
//Retrieve the get value
$input = JFactory::getApplication()->input;
//$edit_id = $input->get('id', null);
$edit_id = $_REQUEST['ticketid'];
JTickets::init();
$all_departments = kyDepartment::getAll()->filterByModule(kyDepartment::MODULE_TICKETS)->filterByType(kyDepartment::TYPE_PUBLIC);
$department_titles = kyDepartment::getAll()->collectTitle();
$department_id = kyDepartment::getAll()->collectId();
$priority_list = kyTicketPriority::getAll();
$status_list = kyTicketStatus::getAll();
$ticket_type = kyTicketType::getAll();
$ticket_details = kyTicket::get($edit_id);
$document =& JFactory::getDocument();
$document->addScript('/media/jui/js/jquery.min.js');
?>

<link rel="stylesheet" type="text/css" href="modules/mod_kayako/resources/css/style.css">

<script>
	jQuery(document).ready(function() {
		jQuery('#Reply').click(function() {
			jQuery('#div_reply').slideToggle("fast");
		});
	});
示例#9
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;
}
示例#10
0
 /**
  * Returns TicketStatus list
  *
  * @return array $ticketStatusList
  */
 public function getTicketStatusList()
 {
     $ticketStatusList = kyTicketStatus::getAll()->filterByType(kyTicketType::TYPE_PUBLIC);
     return $ticketStatusList;
 }
示例#11
0
 * which were created by user with e-mail anno.ying@example.com.
 */
$tickets = kyTicket::getAll(kyDepartment::getAll()->filterByTitle(array("~", "/printer/i")), kyTicketStatus::getAll()->filterByTitle(array("!=", "Closed")), array(), kyUser::getAll()->filterByEmail("*****@*****.**"));
//print them
print "Searching tickets:\n" . $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();
示例#12
0
 * @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';
require_once 'functions.php';
//Include constants file
require_once 'constants.php';
if (!isset($clientsdetails['email'])) {
    header('Location: ' . WHMCS_URL . 'clientarea.php');
}
//Initialize the client
kyConfig::set(new kyConfig(API_URL, API_KEY, SECRET_KEY));
//Process ticket status
$_ticketStatusObjectContainer = kyTicketStatus::getAll()->filterByType(kyDepartment::TYPE_PUBLIC);
$_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