<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ $products = module_faq::get_faq_products_rel(); $current_faq_product_id = false; if (isset($_REQUEST['faq_product_id'])) { $current_faq_product_id = (int) $_REQUEST['faq_product_id']; } ?> <h3><?php echo _l('Product Details'); ?> </h3> <table border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form tableclass_full"> <tbody> <tr> <th class="width1"> <?php echo _l('Product'); ?> </th> <td> <?php
if ($create_user['customer_id']) { echo module_user::link_open_contact($ticket['user_id'], true, array(), true); } else { echo module_user::link_open($ticket['user_id'], true, array(), true); } echo ' ' . htmlspecialchars($create_user['email']); } })); $fieldset_data['elements'][] = array('title' => _l('Type/Department'), 'fields' => array(array('type' => 'select', 'name' => 'ticket_type_id', 'value' => $ticket['ticket_type_id'], 'options' => module_ticket::get_types(), 'blank' => module_ticket::can_edit_tickets(), 'options_array_id' => 'name'))); if (class_exists('module_faq', false) && module_config::c('ticket_faq_link', 1) && module_faq::get_faq_products() > 0) { $fieldset_data['elements'][] = array('title' => _l('Product'), 'fields' => array(function () use($ticket, $ticket_id) { if (module_ticket::can_edit_tickets()) { echo print_select_box(module_faq::get_faq_products_rel(), 'faq_product_id', $ticket['faq_product_id']); _h('Use this to link a ticket to a product. Set products in Settings > FAQ. This allows you to have different FAQ items for different products. Users are shown the FAQ items before submitting a support ticket.'); } else { echo friendly_key(module_faq::get_faq_products_rel(), $ticket['faq_product_id']); } // show a button that does a jquery popup with the list of faq items and an option to create new one. //if(module_faq::can_i('edit','FAQ')){ echo ' '; echo popup_link('<a href="' . module_faq::link_open_list($ticket['faq_product_id']) . '">' . _l('FAQ') . '</a>', array('force' => true, 'width' => 1100, 'height' => 600)); //} })); } if (module_config::c('ticket_support_accounts', 1) && module_ticket::get_accounts_rel()) { $fieldset_data['elements'][] = array('title' => _l('Account'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'ticket_account_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['ticket_account_id'] : friendly_key(module_ticket::get_accounts_rel(), $ticket['ticket_account_id']), 'options' => module_ticket::get_accounts_rel()))); } $fieldset_data['elements'][] = array('title' => _l('Status'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'status_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['status_id'] : friendly_key(module_ticket::get_statuses(), $ticket['status_id']), 'options' => module_ticket::get_statuses()))); if (module_ticket::can_edit_tickets() || module_config::c('ticket_allow_priority_selection', 0)) { $priorities = module_ticket::get_ticket_priorities(); if (!module_ticket::can_edit_tickets() && isset($priorities[_TICKET_PRIORITY_STATUS_ID]) && $ticket['priority'] != _TICKET_PRIORITY_STATUS_ID) { unset($priorities[_TICKET_PRIORITY_STATUS_ID]);
public function external_hook($hook) { switch ($hook) { case 'public': $faq_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false; $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false; if ($faq_id && $hash) { $correct_hash = $this->link_open_public($faq_id, true); if ($correct_hash == $hash) { $faq = array(); if ($faq_id > 0) { $faq = $this->get_faq($faq_id); } if ($faq) { $template = module_template::get_template_by_key('faq_item'); $faq['answer'] = self::html_faq($faq['answer']); $faq['faq_back'] = $this->link_open_public(-1) . (isset($_REQUEST['faq_product_id']) ? '&faq_product_id=' . (int) $_REQUEST['faq_product_id'] : ''); $template->assign_values($faq); $template->page_title = $faq['question']; echo $template->render('pretty_html'); } else { $template = module_template::get_template_by_key('faq_list'); $data = array(); ob_start(); include 'public/faq_listing.php'; $data['listing'] = ob_get_clean(); $template->assign_values($data); $template->page_title = _l('FAQ'); echo $template->render('pretty_html'); } } } break; case 'faq_list_json': @ob_end_clean(); header("Content-type: text/javascript"); $faq_id = isset($_REQUEST['faq_id']) ? (int) $_REQUEST['faq_id'] : false; if ($faq_id > 0) { $faq = $this->get_faq($faq_id); if ($faq) { $faq['url'] = module_faq::link_open_public($faq_id, false); echo json_encode($faq); /*$template = module_template::get_template_by_key('faq_item'); $faq['answer'] = forum_text($faq['answer']); $faq['faq_back'] = $this->link_open_public(-1).(isset($_REQUEST['faq_product_id']) ? '&faq_product_id='.(int)$_REQUEST['faq_product_id'] : ''); $template->assign_values($faq); $template->page_title = $faq['question']; echo $template->replace_content();*/ } exit; } $faq_product_id = isset($_REQUEST['faq_product_id']) ? (int) $_REQUEST['faq_product_id'] : false; $faq_search = isset($_REQUEST['faq_search']) ? $_REQUEST['faq_search'] : false; $faqs = $this->get_faqs(array('faq_product_id' => $faq_product_id, 'question' => $faq_search)); $faqs_json = array(); $all_products = module_faq::get_faq_products_rel(); foreach ($faqs as $faq) { $faq = module_faq::get_faq($faq['faq_id']); $faq_products = array(); foreach ($faq['faq_product_ids'] as $faq_product_id) { $faq_products[$faq_product_id] = $all_products[$faq_product_id]; } $faqs_json[$faq['faq_id']] = array('question' => $faq['question'], 'url' => module_faq::link_open_public($faq['faq_id'], false), 'products' => $faq_products); } echo json_encode($faqs_json); exit; break; case 'ticket_list': $faq_product_id = isset($_REQUEST['faq_product_id']) ? (int) $_REQUEST['faq_product_id'] : false; @ob_end_clean(); header("Content-type: text/javascript"); if ($faq_product_id) { $product = $this->get_faq_product($faq_product_id); // find the faq items that match this product id. if ($product && $product['faq_product_id'] == $faq_product_id) { $faqs = $this->get_faqs(array('faq_product_id' => $faq_product_id)); ob_start(); $x = 0; $half = ceil(count($faqs) / 2); ?> <tr> <th> <?php _e('FAQ'); ?> </th> <td> <?php _e('Please read through the below FAQ to see if the question has already been answered'); ?> </tr> <tr> <td colspan="2"> <table width="100%" class="tableclass tableclass_full table_faq_class"> <tbody> <tr> <td width="50%" valign="top"> <ul><?php for (true; $x < $half; $x++) { $data = array_shift($faqs); $faq = module_faq::get_faq($data['faq_id']); ?> <li> <a href="<?php echo module_faq::link_open_public($data['faq_id'], false); ?> " target="_blank"><?php echo htmlspecialchars($faq['question']); ?> </a> </li> <?php } ?> </ul> </td> <td width="50%" valign="top"> <ul><?php foreach ($faqs as $data) { $faq = module_faq::get_faq($data['faq_id']); ?> <li> <a href="<?php echo module_faq::link_open_public($data['faq_id'], false); ?> " target="_blank"><?php echo htmlspecialchars($faq['question']); ?> </a> </li> <?php } ?> </ul> </td> </tr> </tbody> </table> </td> </tr> <?php $html = preg_replace('#\\s+#', ' ', ob_get_clean()); ?> $('#faq_product_area').html('<?php echo addcslashes($html, "'"); ?> '); <?php if ($product['default_type_id']) { ?> $('#ticket_type_id').val(<?php echo (int) $product['default_type_id']; ?> ); <?php } // and now we have to set the ticket position. if (module_config::c('ticket_show_position', 1)) { $new_position = module_ticket::ticket_position(false, $faq_product_id); ?> $('#ticket_position_field').html('<?php echo addcslashes(_l('%s out of %s other support tickets', ordinal($new_position['current'] + 1), $new_position['total'] + 1), "'"); ?> '); <?php if (module_config::c('ticket_allow_priority', 0)) { $c = module_ticket::get_ticket_count($faq_product_id); ?> $('#priority_ticket_position').html('<?php _e('%s out of %s', ordinal($c['priority'] + 1), $new_position['total'] + 1); ?> '); <?php } } exit; } } ?> $('#faq_product_area').html(''); <?php if (module_config::c('ticket_show_position', 1)) { $new_position = module_ticket::ticket_position(); ?> $('#ticket_position_field').html('<?php echo addcslashes(_l('%s out of %s other support tickets', ordinal($new_position['current'] + 1), $new_position['total'] + 1), "'"); ?> '); <?php if (module_config::c('ticket_allow_priority', 0)) { ?> $('#priority_ticket_position').html('<?php _e('%s out of %s', ordinal(module_ticket::ticket_count('priority') + 1), $new_position['total'] + 1); ?> '); <?php } } break; } }
<form action="" method="<?php echo _DEFAULT_FORM_METHOD; ?> "> <input type="hidden" name="customer_id" value="<?php echo isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : ''; ?> "> <?php module_form::print_form_auth(); $search_bar = array('elements' => array('ticket_id' => array('title' => _l('Number:'), 'field' => array('type' => 'text', 'name' => 'search[ticket_id]', 'value' => isset($search['ticket_id']) ? $search['ticket_id'] : '', 'size' => 5)), 'name' => array('title' => _l('Subject:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : '', 'size' => 10)), 'ticket_content' => array('title' => _l('Message:'), 'field' => array('type' => 'text', 'name' => 'search[ticket_content]', 'value' => isset($search['ticket_content']) ? $search['ticket_content'] : '', 'size' => 10)), 'contact' => array('title' => _l('Contact:'), 'field' => array('type' => 'text', 'name' => 'search[contact]', 'value' => isset($search['contact']) ? $search['contact'] : '', 'size' => 10)), 'date' => array('title' => _l('Date:'), 'fields' => array(array('type' => 'date', 'name' => 'search[date_from]', 'value' => isset($search['date_from']) ? $search['date_from'] : ''), _l('to'), array('type' => 'date', 'name' => 'search[date_to]', 'value' => isset($search['date_to']) ? $search['date_to'] : ''))), 'type' => array('title' => _l('Type:'), 'field' => array('type' => 'select', 'name' => 'search[ticket_type_id]', 'value' => isset($search['ticket_type_id']) ? $search['ticket_type_id'] : '', 'options' => module_ticket::get_types(), 'options_array_id' => 'name')), 'Status' => array('title' => _l('Status:'), 'field' => array('type' => 'select', 'name' => 'search[status_id]', 'value' => isset($search['status_id']) ? $search['status_id'] : '', 'options' => $search_statuses, 'blank' => _l('All'))), 'Priority' => array('title' => _l('Priority:'), 'field' => array('type' => 'select', 'name' => 'search[priority]', 'value' => isset($search['priority']) ? $search['priority'] : '', 'options' => module_ticket::get_ticket_priorities())), 'Staff' => array('title' => _l('Staff:'), 'field' => array('type' => 'select', 'name' => 'search[assigned_user_id]', 'value' => isset($search['assigned_user_id']) ? $search['assigned_user_id'] : '', 'options' => module_ticket::get_ticket_staff_rel())))); if (class_exists('module_faq', false) && module_config::c('ticket_show_product_list', 1)) { $search_bar['elements']['Product'] = array('title' => _l('Product:'), 'field' => array('type' => 'select', 'name' => 'search[faq_product_id]', 'value' => isset($search['faq_product_id']) ? $search['faq_product_id'] : '', 'options' => module_faq::get_faq_products_rel())); } if (class_exists('module_envato', false)) { $search_bar['elements']['envato'] = array('title' => _l('Envato:'), 'field' => array('type' => 'select', 'name' => 'search[envato_item_id]', 'value' => isset($search['envato_item_id']) ? $search['envato_item_id'] : '', 'options' => array(-1 => 'No product') + module_envato::get_envato_items_rel())); } echo module_form::search_bar($search_bar); if (class_exists('module_envato', false) && module_config::c('envato_show_ticket_earning', 0)) { $item_ticket_count = array(); $envato_count = module_cache::get('ticket', 'envato_ticket_earning'); //if($envato_count===false){ while ($ticket = mysql_fetch_assoc($tickets)) { $items = module_envato::get_items_by_ticket($ticket['ticket_id']); if (count($items)) { foreach ($items as $item_id => $item) { if (!isset($item_ticket_count[$item_id])) { $item_ticket_count[$item_id] = array('envato_id' => $item_id, 'name' => $item['name'], 'count' => 0, 'cost' => $item['cost']);
public static function get_replace_fields($ticket_id, $ticket_data = array()) { if (!$ticket_data) { $ticket_data = module_ticket::get_ticket($ticket_id); } $staff_user_id = $ticket_data['assigned_user_id'] ? $ticket_data['assigned_user_id'] : module_config::c('ticket_default_user_id', 1); $to = module_user::get_user($staff_user_id); //$ticket_data['assigned_user_id']); $ticket_data['staff_name'] = $to['name'] . ' ' . $to['last_name']; $ticket_data['ticket_number'] = module_ticket::ticket_number($ticket_data['ticket_id']); $ticket_contact = module_user::get_user($ticket_data['user_id'], false); $ticket_data['contact_name'] = (isset($ticket_contact['name']) ? $ticket_contact['name'] . ' ' : '') . (isset($ticket_contact['last_name']) ? $ticket_contact['last_name'] : ''); $ticket_data['contact_fname'] = isset($ticket_contact['name']) ? $ticket_contact['name'] : ''; $ticket_data['contact_lname'] = isset($ticket_contact['last_name']) ? $ticket_contact['last_name'] : ''; // addition. find all extra keys for this ticket and add them in. // we also have to find any EMPTY extra fields, and add those in as well. if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $all_extra_fields = module_extra::get_defaults('ticket'); foreach ($all_extra_fields as $e) { $ticket_data[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'ticket', 'owner_id' => $ticket_id)); foreach ($extras as $e) { $ticket_data[$e['extra_key']] = $e['extra']; } } if (isset($ticket_data['faq_product_id']) && (int) $ticket_data['faq_product_id'] > 0) { $ticket_data['faq_product'] = friendly_key(module_faq::get_faq_products_rel(), $ticket_data['faq_product_id']); } else { $ticket_data['faq_product'] = _l('N/A'); } // find any extra keys (defined in the db for ticket submission, not the module_extra extra keys) $extras = module_ticket::get_ticket_extras_keys(); if (count($extras)) { foreach ($extras as $extra) { $key = strtolower($extra['key']); if (!isset($ticket_data[$key])) { $ticket_data[$key] = isset($ticket_data['extra_data'][$extra['ticket_data_key_id']]) ? $ticket_data['extra_data'][$extra['ticket_data_key_id']]['value'] : ''; } } } return $ticket_data; }