@ -9,17 +9,17 @@
$cidReset = true;
// needed in order to load the plugin lang variables
$course_plugin = 'ticket';
require_once '../config.php';
require_once __DIR__. '/ ../config.php';
$plugin = TicketPlugin::create ();
api_block_anonymous_users ();
$plugin = TicketPlugin::create();
$tool_name = $plugin->get_lang('LastEdit');
api_block_anonymous_users();
$libPath = api_get_path(LIBRARY_PATH);
$webLibPath = api_get_path(WEB_LIBRARY_PATH);
$htmlHeadXtra[] = '< script type = "text/javascript" >
function load_history_ticket (div_course,ticket_id) {
$htmlHeadXtra[] = '< script >
function load_history_ticket(div_course, ticket_id) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(object) {
@ -34,21 +34,16 @@ function load_history_ticket (div_course,ticket_id) {
}
});
}
function clear_course_list (div_course) {
function clear_course_list(div_course) {
$("div#"+div_course).html(" ");
$("div#"+div_course).hide("");
}
$(function() {
$( "#keyword_start_date_start" ).datepicker({ dateFormat: ' . "'dd/mm/yy'" . ' });
$( "#keyword_start_date_end" ).datepicker({ dateFormat: ' . "'dd/mm/yy'" . ' });
});
$(document).ready(function() {
$("#advanced_search_form").css("display","none");
});
function display_advanced_search_form () {
function display_advanced_search_form() {
if ($("#advanced_search_form").css("display") == "none") {
$("#advanced_search_form").css("display","block");
$("#img_plus_and_minus").html(\' ' . Display::return_icon('div_hide.gif', get_lang('Hide'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AdvancedSearch') . '\');
@ -57,70 +52,7 @@ function display_advanced_search_form () {
$("#img_plus_and_minus").html(\' ' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AdvancedSearch') . '\');
}
}
< / script >
< style >
.label2 {
float: left;
text-align: left;
width: 75px;
}
.label3 {
margin-left: 20px;
float: left;
text-align: left;
margin-top: 10px;
width: 95px;
}
.label4 {
float: left;
text-align: left;
margin-top: 10px;
width: 75px;
}
.formw2 {
float: left;
margin-left: 4px;
margin-top: 5px;
}
.blackboard_show {
float: left;
position: absolute;
border: 1px solid black;
width: 350px;
background-color: white;
z-index: 99;
padding: 3px;
display: inline;
}
.blackboard_hide {
display: none;
}
.advanced-parameters {
margin-top: 5px;
}
.remove-margin-top {
margin-top: 0px;
}
.select-margin-top {
margin-top: -5px;
}
.input-width {
width: 170px;
}
.fleft {
float: left;
}
< / style > ';
< / script > ';
$this_section = 'tickets';
unset($_SESSION['this_section']);
@ -138,68 +70,69 @@ if ($table->per_page == 0) {
$table->per_page = 20;
}
if (isset($_GET['action'])) {
global $table;
$action = $_GET['action'];
switch ($action) {
case 'assign':
if ($isAdmin & & isset($_GET['ticket_id']))
TicketManager::assign_ticket_user($_GET['ticket_id'], $user_id);
break;
case 'unassign':
if ($isAdmin & & isset($_GET['ticket_id']))
TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
break;
case 'alert':
if (!$isAdmin & & isset($_GET['ticket_id']))
TicketManager::send_alert($_GET['ticket_id'], $user_id);
break;
case 'export':
$data = array(
array(
$plugin->get_lang('TicketNum'),
$plugin->get_lang('Date'),
$plugin->get_lang('DateLastEdition'),
$plugin->get_lang('Category'),
$plugin->get_lang('User'),
$plugin->get_lang('Program'),
$plugin->get_lang('Responsible'),
$plugin->get_lang('Status'),
$plugin->get_lang('Description')
)
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'assign':
if ($isAdmin & & isset($_GET['ticket_id'])) {
TicketManager::assign_ticket_user($_GET['ticket_id'], $user_id);
}
break;
case 'unassign':
if ($isAdmin & & isset($_GET['ticket_id'])) {
TicketManager::assign_ticket_user($_GET['ticket_id'], 0);
}
break;
case 'alert':
if (!$isAdmin & & isset($_GET['ticket_id'])) {
TicketManager::send_alert($_GET['ticket_id'], $user_id);
}
break;
case 'export':
$data = array(
array(
$plugin->get_lang('TicketNum'),
$plugin->get_lang('Date'),
$plugin->get_lang('DateLastEdition'),
$plugin->get_lang('Category'),
$plugin->get_lang('User'),
$plugin->get_lang('Program'),
$plugin->get_lang('Responsible'),
$plugin->get_lang('Status'),
$plugin->get_lang('Description')
)
);
$datos = $table->get_clean_html();
foreach ($datos as $ticket) {
$ticket[0] = substr(strip_tags($ticket[0]), 0, 12);
$ticket_rem = array(
utf8_decode(strip_tags($ticket[0])),
utf8_decode(api_html_entity_decode($ticket[1])),
utf8_decode(strip_tags($ticket[2])),
utf8_decode(strip_tags($ticket[3])),
utf8_decode(strip_tags($ticket[4])),
utf8_decode(strip_tags($ticket[5])),
utf8_decode(strip_tags($ticket[6])),
utf8_decode(strip_tags($ticket[7])),
utf8_decode(strip_tags(str_replace(' ', ' ', $ticket[9])))
);
$datos = $table->get_clean_html();
foreach ($datos as $ticket) {
$ticket[0] = substr(strip_tags($ticket[0]), 0, 12);
$ticket_rem = array(
utf8_decode(strip_tags($ticket[0])),
utf8_decode(api_html_entity_decode($ticket[1])),
utf8_decode(strip_tags($ticket[2])),
utf8_decode(strip_tags($ticket[3])),
utf8_decode(strip_tags($ticket[4])),
utf8_decode(strip_tags($ticket[5])),
utf8_decode(strip_tags($ticket[6])),
utf8_decode(strip_tags($ticket[7])),
utf8_decode(strip_tags(str_replace(' ', ' ', $ticket[9])))
);
$data[] = $ticket_rem;
}
Export::arrayToXls($data, $plugin->get_lang('Tickets'));
exit;
break;
case 'close_tickets':
TicketManager::close_old_tickets();
break;
default:
break;
}
$data[] = $ticket_rem;
}
Export::arrayToXls($data, $plugin->get_lang('Tickets'));
exit;
break;
case 'close_tickets':
TicketManager::close_old_tickets();
break;
default:
break;
}
// $nameTools = api_xml_http_response_encode($plugin->get_lang('MyTickets'));
$user_id = api_get_user_id();
$isAdmin = api_is_platform_admin();
Display::display_header($plugin->get_lang('MyTickets'));
if ($isAdmin) {
$getParameters = [
'keyword',
@ -236,50 +169,43 @@ if ($isAdmin) {
if (isset($_GET['submit_simple'])) {
$get_parameter .= "&submit_simple=";
}
//select categories
$select_types = '< select class = "chzn-select" name = "keyword_category" id = "keyword_category" " > ';
$select_types .= '< option value = "" > ---' . get_lang('Select') . '---< / option > ' ;
// Select categories
$selectTypes = [] ;
$types = TicketManager::get_all_tickets_categories();
foreach ($types as $type) {
$select_types.= "< option value = '" . $type[' category_id ' ] . " ' > " . $type['name'] . "< / option > " ;
$selectTypes[$type['category_id']] = $type['name'] ;
}
$select_types .= "< / select > ";
//select admins
$select_admins = '< select class = "chzn-select" name = "keyword_admin" id = "keyword_admin" " > ';
$select_admins .= '< option value = "" > ---' . get_lang('Select') . '---< / option > ';
$select_admins .= '< option value = "0" > ' . $plugin->get_lang('Unassigned') . '< / option > ';
$admins = UserManager::get_user_list_like(array("status" => "1"), array("username"), true);
$selectAdmins = [
0 => $plugin->get_lang('Unassigned')
];
foreach ($admins as $admin) {
$select_admins.= "< option value = '" . $admin[' user_id ' ] . " ' > " . $admin['lastname'] . " ," . $admin['firstname'] . "< / option > ";
$selectAdmins[$admin['user_id']] = $admin['complete_name'] ;
}
$select_admins .= "< / select > ";
//select status
$select_status = '< select class = "chzn-select" name = "keyword_status" id = "keyword_status" > ';
$select_status .= '< option value = "" > ---' . get_lang('Select') . '---< / option > ';
$status = TicketManager::get_all_tickets_status();
$selectStatus = [];
foreach ($status as $stat) {
$select_status.= "< option value = '" . $stat[' status_id ' ] . " ' > " . $stat['name'] . "< / option > " ;
$selectStatus[$stat['status_id']] = $stat['name'];
}
$select_status .= "< / select > ";
//select priority
$select_priority = '< select name = "keyword_priority" id = "keyword_priority" > ';
$select_priority .= '< option value = "" > ' . get_lang('All') . '< / option > ';
$select_priority .= '< option value = "NRM" > ' . $plugin->get_lang('PriorityNormal') . '< / option > ';
$select_priority .= '< option value = "HGH" > ' . $plugin->get_lang('PriorityHigh') . '< / option > ';
$select_priority .= '< option value = "LOW" > ' . $plugin->get_lang('PriorityLow') . '< / option > ';
$select_priority .= "< / select > ";
//select unread
$select_unread = '< select name = "keyword_unread" id = "keyword_unread" > ';
$select_unread .= '< option value = "" > ' . get_lang('All') . '< / option > ';
$select_unread .= '< option value = "yes" > ' . $plugin->get_lang('Unread') . '< / option > ';
$select_unread .= '< option value = "no" > ' . $plugin->get_lang('Read') . '< / option > ';
$select_unread .= "< / select > ";
$selectPriority = [
'' => get_lang('All'),
TicketManager::PRIORITY_NORMAL => $plugin->get_lang('PriorityNormal'),
TicketManager::PRIORITY_HIGH => $plugin->get_lang('PriorityHigh'),
TicketManager::PRIORITY_LOW => $plugin->get_lang('PriorityLow')
];
$selectStatusUnread = [
'' => get_lang('All'),
'yes' => $plugin->get_lang('Unread'),
'no' => $plugin->get_lang('Read')
];
// Create a search-box
$form = new FormValidator('search_simple', 'get', '', '', null, false);
$renderer = & $form->defaultRenderer();
$renderer->setCustomElementTemplate('< span > {element}< / span > ');
$form->addElement('text', 'keyword', get_lang('Keyword'), 'size="25"');
$form = new FormValidator('search_simple', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
$form->addText('keyword', get_lang('Keyword'), 'size="25"');
$form->addButtonSearch(get_lang('Search'), 'submit_simple');
$form->addElement('static', 'search_advanced_link', null,
'< a href = "javascript://" class = "advanced-parameters" onclick = "display_advanced_search_form();" > '
@ -291,11 +217,9 @@ if ($isAdmin) {
if (api_is_platform_admin()) {
echo '< span class = "left" > ' .
'< a href = "' . api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/new_ticket.php" > ' .
Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32' ) . '< / a > ' .
Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', ICON_SIZE_MEDIUM ) . '< / a > ' .
'< a href = "' . api_get_self() . '?action=export' . $get_parameter . $get_parameter2 . '" > ' .
Display::return_icon('export_excel.png', get_lang('Export'), '', '32') . '< / a > ';
Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_MEDIUM) . '< / a > ';
if ($plugin->get('allow_category_edition')) {
echo Display::url(
Display::return_icon('folder_document.gif'),
@ -308,87 +232,26 @@ if ($isAdmin) {
}
$form->display();
echo '< / div > ';
echo '< form action = "' . api_get_self() . '" method = "get" name = "advanced_search" id = "advanced_search" display: " none " >
< div id = "advanced_search_form" style = "display: block;" >
< div >
< div class = "form_header" > ' . get_lang('AdvancedSearch') . '< / div >
< / div >
< table >
< tbody >
< tr >
< td >
< div >
< div class = "label2" > ' . get_lang('Category') . ': < / div >
< div class = "formw2" style = "margin-top: -5px;" > ' . $select_types . '< / div >
< / div >
< / td >
< td >
< div >
< div class = "label3" > ' . get_lang('User') . ': < / div >
< div class = "formw2" > < input class = "input-width" id = "keyword_request_user" name = "keyword_request_user" type = "text" > < / div >
< / div >
< / td >
< td >
< div >
< div class = "label3" > ' . $plugin->get_lang('RegisterDate') . ': < / div >
< div class = "formw2" > < input class = "input-width" id = "keyword_start_date_start" name = "keyword_start_date_start" type = "text" > < / div >
< / div >
< / td >
< td >
< div >
< div class = "label3" > < input type = "checkbox" name = "keyword_dates" value = "1" > ' . $plugin->get_lang('Untill') . '< / div >
< div class = "formw2" > < input class = "input-width" id = "keyword_start_date_end" name = "keyword_start_date_end" type = "text" > < / div >
< / div >
< / td >
< / tr >
< tr >
< td >
< div >
< div class = "label2" > ' . $plugin->get_lang('AssignedTo') . ': < / div >
< div class = "formw2 select-margin-top" > ' . $select_admins . '< / div >
< / div >
< / td >
< td >
< div >
< div class = "label3 remove-margin-top" > ' . get_lang('Status') . ':< / div >
< div class = "formw2 select-margin-top" > ' . $select_status . '< / div >
< / div >
< / td >
< td >
< div >
< div >
< div class = "label3" > ' . $plugin->get_lang('Priority') . ': < / div >
< div class = "formw2" > ' . $select_priority . '< / div >
< / div >
< / td >
< td >
< div >
< div >
< div class = "label3" > ' . get_lang('Status') . ': < / div >
< div class = "formw2" > ' . $select_unread . '< / div >
< / div >
< / td >
< / tr >
< tr >
< td >
< div >
< div class = "label4" > ' . get_lang('Course') . ': < / div >
< div class = "formw2" >
< input id = "keyword_course" style = "width: 170px;" name = "keyword_course" type = "text" > < / div >
< / div >
< / td >
< td colspan = "3" >
< div >
< button name = "submit_advanced" type = "submit" > ' . get_lang('AdvancedSearch') . '< / button >
< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
< input name = "_qf__advanced_search" type = "hidden" value = "" >
< div class = "clear" > < / div >
< / form > ';
$advancedSearchForm = new FormValidator(
'advanced_search',
'get',
api_get_self(),
null,
['style' => 'display:"none"', 'id' => 'advanced_search_form']
);
$advancedSearchForm->addHeader(get_lang('AdvancedSearch'));
$advancedSearchForm->addSelect('keyword_category', get_lang('Category'), $selectTypes, ['placeholder' => get_lang('Select')]);
//$advancedSearchForm->addText('keyword_request_user', get_lang('User'), false);
$advancedSearchForm->addDateTimePicker('keyword_start_date_start', $plugin->get_lang('RegisterDate'));
$advancedSearchForm->addDateTimePicker('keyword_start_date_end', $plugin->get_lang('Untill'));
$advancedSearchForm->addSelect('keyword_admin', $plugin->get_lang('AssignedTo') , $selectAdmins, ['placeholder' => get_lang('All')]);
$advancedSearchForm->addSelect('keyword_status', get_lang('Status'), $selectStatus, ['placeholder' => get_lang('Select')]);
$advancedSearchForm->addSelect('keyword_priority', $plugin->get_lang('Priority'), $selectPriority, ['placeholder' => get_lang('All')]);
$advancedSearchForm->addSelect('keyword_unread', get_lang('Status'), $selectStatusUnread, ['placeholder' => get_lang('All')]);
$advancedSearchForm->addText('keyword_course', get_lang('Course'), false);
$advancedSearchForm->addButtonSearch(get_lang('AdvancedSearch'), 'submit_advanced');
$advancedSearchForm->display();
} else {
if ($plugin->get('allow_student_add') == 'true') {
echo '< div class = "actions" > ';
@ -397,8 +260,6 @@ if ($isAdmin) {
Display::return_icon('add.png', $plugin->get_lang('TckNew'), '', '32') .
'< / a > ' .
'< / span > ';
echo '< span style = "float:right;" > ' .
'< / span > ';
echo '< / div > ';
}
}
@ -408,11 +269,10 @@ if ($isAdmin) {
$table->set_header(1, $plugin->get_lang('Date'), true);
$table->set_header(2, $plugin->get_lang('DateLastEdition'), true);
$table->set_header(3, $plugin->get_lang('Category'), true);
$table->set_header(4, $plugin->get_lang('User '), true);
$table->set_header(5, $plugin->get_lang('Responsible '), true);
$table->set_header(4, $plugin->get_lang('CreatedBy '), true);
$table->set_header(5, $plugin->get_lang('AssignedTo '), true);
$table->set_header(6, $plugin->get_lang('Status'), true);
$table->set_header(7, $plugin->get_lang('Message'), true);
$table->set_header(8, get_lang('Actions'), true);
} else {
echo '< center > < h1 > ' . $plugin->get_lang('MyTickets') . '< / h1 > < / center > ';
echo '< center > < p > ' . $plugin->get_lang('MsgWelcome') . '< / p > < / center > ';
@ -424,8 +284,7 @@ if ($isAdmin) {
$table->set_header(2, $plugin->get_lang('DateLastEdition'), true);
$table->set_header(3, $plugin->get_lang('Category'));
$table->set_header(4, $plugin->get_lang('Status'), false);
$table->set_header(5, get_lang('Actions'), false);
}
}
$table->display();
Display::display_footer();