Esempio n. 1
0
 public function retrieveIssues()
 {
     try {
         $ticket_types = kyTicketType::getAll();
         foreach ($ticket_types as $ticket_type) {
             $issuesArray[] = array('value' => $ticket_type->getId(), 'label' => $ticket_type->getTitle());
         }
         return $issuesArray;
     } catch (Exception $e) {
         Mage::getSingleton('core/session')->addError('Error: Please check Kayako API credentials');
         return array();
     }
 }
 /**
  * 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();
 }
Esempio n. 3
0
 /**
  * Sets this ticket type.
  *
  * @param kyTicketType $ticket_type Ticket type.
  * @return kyTicket
  */
 public function setType($ticket_type)
 {
     $this->type = ky_assure_object($ticket_type, 'kyTicketType');
     $this->type_id = $this->type !== null ? $this->type->getId() : null;
     return $this;
 }
        ?>
</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 
        echo kyTicketPriority::get($list->getPriorityId())->getForegroundColor();
        ?>
;">
                        <?php 
         $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();
             $smarty->assign('_ticketDisplayID', $_ticket->getDisplayId());
             $smarty->assign('_ticketSubject', $_POST['ticketsubject']);
    ?>
			</div>
		</fieldset>

		<input type="submit" name="submit_department" value="Next">
	</form>
<?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 
				<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) {
    ?>
							<option
								value="<?php 
    echo $status->id;
    ?>
" <?php 
    if ($status->id == $ticket_details->getStatusId()) {
        echo "selected";
    }
Esempio n. 8
0
 /**
  * Returns TicketType list
  *
  * @return array $_ticketTypes
  */
 public function getTicketTypeList()
 {
     // Load ticket types
     $_ticketTypes = kyTicketType::getAll()->filterByType(kyTicketType::TYPE_PUBLIC);
     return $_ticketTypes;
 }
Esempio n. 9
0
require_once "../kyIncludes.php";
print "<pre>";
/**
 * Initialization.
 */
kyConfig::set(new kyConfig("<API URL>", "<API key>", "<Secret key>"));
kyConfig::get()->setDebugEnabled(true);
/**
 * Optional. Setting defaults for new tickets.
 * WARNING:
 * Names may be different in your instalation.
 */
$default_status_id = kyTicketStatus::getAll()->filterByTitle("Open")->first()->getId();
$default_priority_id = kyTicketPriority::getAll()->filterByTitle("Normal")->first()->getId();
$default_type_id = kyTicketType::getAll()->filterByTitle("Issue")->first()->getId();
kyTicket::setDefaults($default_status_id, $default_priority_id, $default_type_id);
$general_department = kyDepartment::getAll()->filterByTitle("General")->filterByModule(kyDepartment::MODULE_TICKETS)->first();
/**
 * Cleanup - delete what's left from previous run of this example.
 */
$example_department = kyDepartment::getAll()->filterByTitle("Printers (example)");
if (count($example_department) > 0) {
    $tickets_to_delete = kyTicket::getAll($example_department)->filterBySubject("Printer not working (example)");
    $tickets_to_delete->deleteAll();
    if (count($tickets_to_delete) > 0) {
        printf("Tickets DELETED:\n%s", $tickets_to_delete);
    }
}
$users_to_delete = kyUser::getAll()->filterByEmail("*****@*****.**");
$users_to_delete->deleteAll();