|
|
|
@ -1,12 +1,13 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
use ChamiloSession as Session; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This script is the Tickets plugin main entry point |
|
|
|
|
* @package chamilo.plugin.ticket |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
$cidReset = true; |
|
|
|
|
// needed in order to load the plugin lang variables |
|
|
|
|
$course_plugin = 'ticket'; |
|
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
|
|
@ -17,6 +18,8 @@ $toolName = get_lang('Categories'); |
|
|
|
|
|
|
|
|
|
$libPath = api_get_path(LIBRARY_PATH); |
|
|
|
|
$webLibPath = api_get_path(WEB_LIBRARY_PATH); |
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
$isAdmin = api_is_platform_admin(); |
|
|
|
|
|
|
|
|
|
$this_section = 'tickets'; |
|
|
|
|
unset($_SESSION['this_section']); |
|
|
|
@ -34,84 +37,82 @@ if ($table->per_page == 0) { |
|
|
|
|
|
|
|
|
|
$formToString = ''; |
|
|
|
|
$id = isset($_GET['id']) ? intval($_GET['id']) : 0; |
|
|
|
|
$projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : ''; |
|
|
|
|
|
|
|
|
|
Session::write('project_id', $projectId); |
|
|
|
|
$action = isset($_GET['action']) ? $_GET['action'] : ''; |
|
|
|
|
|
|
|
|
|
$interbreadcrumb[] = array( |
|
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'ticket/tickets.php', |
|
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$projectId, |
|
|
|
|
'name' => get_lang('MyTickets') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (isset($_GET['action'])) { |
|
|
|
|
global $table; |
|
|
|
|
$action = $_GET['action']; |
|
|
|
|
switch ($action) { |
|
|
|
|
case 'delete': |
|
|
|
|
TicketManager::deleteCategory($id); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
|
|
|
|
header("Location: ".api_get_self()); |
|
|
|
|
break; |
|
|
|
|
case 'add': |
|
|
|
|
$toolName = get_lang('Add'); |
|
|
|
|
$interbreadcrumb[] = array( |
|
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'ticket/categories.php', |
|
|
|
|
'name' => get_lang('Categories') |
|
|
|
|
); |
|
|
|
|
$url = api_get_self().'?action=add'; |
|
|
|
|
$form = TicketManager::getCategoryForm($url); |
|
|
|
|
$formToString = $form->returnForm(); |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values =$form->getSubmitValues(); |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'name' => $values['name'], |
|
|
|
|
'description' => $values['description'], |
|
|
|
|
'total_tickets' => 0, |
|
|
|
|
'sys_insert_user_id' => api_get_user_id(), |
|
|
|
|
'sys_insert_datetime' => api_get_utc_datetime(), |
|
|
|
|
'course_required' => '' |
|
|
|
|
]; |
|
|
|
|
TicketManager::addCategory($params); |
|
|
|
|
|
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Added'))); |
|
|
|
|
|
|
|
|
|
header("Location: ".api_get_self()); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'edit': |
|
|
|
|
$toolName = get_lang('Edit'); |
|
|
|
|
$interbreadcrumb[] = array( |
|
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'ticket/categories.php', |
|
|
|
|
'name' => get_lang('Categories') |
|
|
|
|
); |
|
|
|
|
$url = api_get_self().'?action=edit&id='.$id; |
|
|
|
|
$form = TicketManager::getCategoryForm($url); |
|
|
|
|
|
|
|
|
|
$cat = TicketManager::getCategory($_GET['id']); |
|
|
|
|
$form->setDefaults($cat); |
|
|
|
|
$formToString = $form->returnForm(); |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values =$form->getSubmitValues(); |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'name' => $values['name'], |
|
|
|
|
'description' => $values['description'], |
|
|
|
|
'sys_lastedit_datetime' => api_get_utc_datetime(), |
|
|
|
|
'sys_lastedit_user_id' => api_get_user_id() |
|
|
|
|
]; |
|
|
|
|
$cat = TicketManager::updateCategory($_GET['id'], $params); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
|
|
|
header("Location: ".api_get_self()); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
switch ($action) { |
|
|
|
|
case 'delete': |
|
|
|
|
TicketManager::deleteCategory($id); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
|
|
|
|
header("Location: ".api_get_self()); |
|
|
|
|
break; |
|
|
|
|
case 'add': |
|
|
|
|
$toolName = get_lang('Add'); |
|
|
|
|
$interbreadcrumb[] = array( |
|
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'ticket/categories.php', |
|
|
|
|
'name' => get_lang('Categories') |
|
|
|
|
); |
|
|
|
|
$url = api_get_self().'?action=add&project_id='.$projectId; |
|
|
|
|
$form = TicketManager::getCategoryForm($url, $projectId); |
|
|
|
|
$formToString = $form->returnForm(); |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values =$form->getSubmitValues(); |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'name' => $values['name'], |
|
|
|
|
'description' => $values['description'], |
|
|
|
|
'total_tickets' => 0, |
|
|
|
|
'sys_insert_user_id' => api_get_user_id(), |
|
|
|
|
'sys_insert_datetime' => api_get_utc_datetime(), |
|
|
|
|
'course_required' => '', |
|
|
|
|
'project_id' => $projectId |
|
|
|
|
]; |
|
|
|
|
TicketManager::addCategory($params); |
|
|
|
|
|
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Added'))); |
|
|
|
|
|
|
|
|
|
header("Location: ".api_get_self().'?project_id='.$projectId); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case 'edit': |
|
|
|
|
$toolName = get_lang('Edit'); |
|
|
|
|
$interbreadcrumb[] = array( |
|
|
|
|
'url' => api_get_path(WEB_CODE_PATH).'ticket/categories.php?project_id='.$projectId, |
|
|
|
|
'name' => get_lang('Categories') |
|
|
|
|
); |
|
|
|
|
$url = api_get_self().'?action=edit&project_id='.$projectId.'&id='.$id; |
|
|
|
|
$form = TicketManager::getCategoryForm($url, $projectId); |
|
|
|
|
|
|
|
|
|
$cat = TicketManager::getCategory($_GET['id']); |
|
|
|
|
$form->setDefaults($cat); |
|
|
|
|
$formToString = $form->returnForm(); |
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values =$form->getSubmitValues(); |
|
|
|
|
|
|
|
|
|
$params = [ |
|
|
|
|
'name' => $values['name'], |
|
|
|
|
'description' => $values['description'], |
|
|
|
|
'sys_lastedit_datetime' => api_get_utc_datetime(), |
|
|
|
|
'sys_lastedit_user_id' => api_get_user_id() |
|
|
|
|
]; |
|
|
|
|
$cat = TicketManager::updateCategory($_GET['id'], $params); |
|
|
|
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
|
|
|
|
header("Location: ".api_get_self().'?project_id='.$projectId); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
$isAdmin = api_is_platform_admin(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Build the modify-column of the table |
|
|
|
|
* @param int The user id |
|
|
|
@ -121,19 +122,20 @@ $isAdmin = api_is_platform_admin(); |
|
|
|
|
*/ |
|
|
|
|
function modify_filter($id, $params, $row) |
|
|
|
|
{ |
|
|
|
|
$projectId = Session::read('project_id'); |
|
|
|
|
$result = Display::url( |
|
|
|
|
Display::return_icon('edit.png', get_lang('Edit')), |
|
|
|
|
"categories.php?action=edit&id={$row['id']}" |
|
|
|
|
"categories.php?action=edit&id={$row['id']}&project_id=".$projectId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$result .= Display::url( |
|
|
|
|
Display::return_icon('user.png', get_lang('AssignUser')), |
|
|
|
|
"categories_add_user.php?id={$row['id']}" |
|
|
|
|
"categories_add_user.php?id={$row['id']}&project_id=".$projectId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$result .= Display::url( |
|
|
|
|
Display::return_icon('delete.png', get_lang('Delete')), |
|
|
|
|
"categories.php?action=delete&id={$row['id']}" |
|
|
|
|
"categories.php?action=delete&id={$row['id']}&project_id=".$projectId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
@ -150,7 +152,7 @@ Display::display_header($toolName); |
|
|
|
|
|
|
|
|
|
$items = [ |
|
|
|
|
[ |
|
|
|
|
'url' => 'categories.php?action=add', |
|
|
|
|
'url' => 'categories.php?action=add&project_id='.$projectId, |
|
|
|
|
'content' => Display::return_icon('new_folder.png', null, null, ICON_SIZE_MEDIUM) |
|
|
|
|
] |
|
|
|
|
]; |
|
|
|
|