Addin new features;

New settings: warn_admin_no_user_in_category, send_warning_to_all_admins, WarningCategoryXDoesntHaveUsers,
allow_category_edition  and relate users to categories
ofaj
Julio 9 years ago
parent 83dcda110b
commit a46bf3aa8e
  1. 6
      plugin/ticket/lang/english.php
  2. 1
      plugin/ticket/src/categories.php
  3. 7
      plugin/ticket/src/categories_add_user.php
  4. 1
      plugin/ticket/src/course_user_list.php
  5. 2
      plugin/ticket/src/myticket.php
  6. 24
      plugin/ticket/src/new_ticket.php
  7. 74
      plugin/ticket/src/ticket.class.php
  8. 6
      plugin/ticket/src/ticket_plugin.class.php

@ -85,6 +85,10 @@ $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Please select a user bef
$strings['RequestConfirmation'] = "Request confirmation"; $strings['RequestConfirmation'] = "Request confirmation";
$strings['TicketUpdated'] = "Ticket updated"; $strings['TicketUpdated'] = "Ticket updated";
$strings['TicketClosed'] = "Ticket closed"; $strings['TicketClosed'] = "Ticket closed";
$strings['allow_category_edition'] = "Allow category edition"; $strings['allow_category_edition'] = "Allow category edition";
$strings['warn_admin_no_user_in_category'] = "Warn admin if category doesn't have users related";
$strings['send_warning_to_all_admins'] = "Send warning to all admins, if category doesn't have users related";
$strings['WarningCategoryXDoesntHaveUsers'] = "Warning: The category '%s' doesn't have users assigned";
$strings['TicketInformation'] = 'Ticket information';

@ -104,7 +104,6 @@ function modify_filter($id, $params, $row)
return $result; return $result;
} }
Display::display_header($plugin->get_lang('MyTickets')); Display::display_header($plugin->get_lang('MyTickets'));
$table->set_header(0, '', false); $table->set_header(0, '', false);
$table->set_header(1, $plugin->get_lang('Title'), true); $table->set_header(1, $plugin->get_lang('Title'), true);

@ -5,7 +5,7 @@
* *
* @package chamilo.plugin.ticket * @package chamilo.plugin.ticket
*/ */
$cidReset = true;
require_once '../config.php'; require_once '../config.php';
$plugin = TicketPlugin::create(); $plugin = TicketPlugin::create();
@ -17,10 +17,7 @@ if (empty($categoryId)) {
} }
$form = new FormValidator('edit', 'post', api_get_self().'?id='.$categoryId); $form = new FormValidator('edit', 'post', api_get_self().'?id='.$categoryId);
$users = UserManager::get_user_list([], ['firstname']); $users = UserManager::get_user_list([], ['firstname']);
$users = array_column($users, 'complete_name', 'user_id'); $users = array_column($users, 'complete_name', 'user_id');
$form->addElement( $form->addElement(
@ -48,5 +45,7 @@ if ($form->validate()) {
header("Location: ".api_get_self()."?id=".$categoryId); header("Location: ".api_get_self()."?id=".$categoryId);
exit; exit;
} }
$interbreadcrumb[] = array('url' => 'categories.php', 'name' => get_lang('Categories'));
Display::display_header(); Display::display_header();
$form->display(); $form->display();

@ -31,7 +31,6 @@ $userInput = Display::tag(
) )
); );
$userControl = Display::div($userInput, array('class' => 'controls')); $userControl = Display::div($userInput, array('class' => 'controls'));
$courseLabel = Display::tag('label', get_lang('Course'), array('class' => 'control-label')); $courseLabel = Display::tag('label', get_lang('Course'), array('class' => 'control-label'));
$courseSelect = Display::select('course_id', $arrCourseList, 0, array(), false); $courseSelect = Display::select('course_id', $arrCourseList, 0, array(), false);
$courseControl = Display::div($courseSelect, array('class' => 'controls')); $courseControl = Display::div($courseSelect, array('class' => 'controls'));

@ -298,7 +298,7 @@ if ($isAdmin) {
if ($plugin->get('allow_category_edition')) { if ($plugin->get('allow_category_edition')) {
echo Display::url( echo Display::url(
Display::return_icon('document.png'), Display::return_icon('folder_document.gif'),
api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/categories.php' api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/categories.php'
); );
} }

@ -132,7 +132,7 @@ function add_image_form() {
}); });
img_remove = $("<img/>", { img_remove = $("<img/>", {
src: "' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif" src: "' . Display::returnIconPath('delete.png') . '"
}); });
new_filepath_id = $("#filepath_" + counter_image); new_filepath_id = $("#filepath_" + counter_image);
@ -317,8 +317,7 @@ function show_form_send_ticket()
) )
); );
$form->addElement( $form->addLabel('',
'html',
Display::div( Display::div(
'', '',
array( array(
@ -394,18 +393,15 @@ function show_form_send_ticket()
'for' => 'priority_id' 'for' => 'priority_id'
) )
); );
$form->addElement('html', '<span id="filepaths">');
$form->addElement('html', '<div id="filepath_1">');
$form->addElement('file', 'attach_1', get_lang('FilesAttachment')); $form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
$form->addElement('html', '</div>'); $form->addLabel('', '<span id="filepaths"><div id="filepath_1"></div></span>');
$form->addElement('html', '</span>');
$form->addElement('html', '<div class="controls">'); $form->addLabel('',
$form->addElement('html', '<span id="link-more-attach" >'); '<span id="link-more-attach">
$form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>'); <span class="btn btn-success" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>
$form->addElement('html', '</span>'); </span>
$form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); ('.sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))).')
');
$form->addElement('html', '<br/>'); $form->addElement('html', '<br/>');
$form->addElement( $form->addElement(
@ -415,7 +411,7 @@ function show_form_send_ticket()
null, null,
null, null,
null, null,
'save', 'btn btn-primary',
array( array(
'id' => 'btnsubmit' 'id' => 'btnsubmit'
) )

@ -152,6 +152,8 @@ class TicketManager
/** /**
* @param int $userId * @param int $userId
* @param int $categoryId * @param int $categoryId
*
* @return bool
*/ */
public static function userIsAssignedToCategory($userId, $categoryId) public static function userIsAssignedToCategory($userId, $categoryId)
{ {
@ -166,6 +168,8 @@ class TicketManager
/** /**
* @param int $categoryId * @param int $categoryId
*
* @return array
*/ */
public static function getUsersInCategory($categoryId) public static function getUsersInCategory($categoryId)
{ {
@ -272,7 +276,8 @@ class TicketManager
if ($request_user == '' && $source == 'VRT') { if ($request_user == '' && $source == 'VRT') {
$request_user = $user_id; $request_user = $user_id;
} }
$sql_insert_ticket = "INSERT INTO $table_support_tickets // insert_ticket
$sql = "INSERT INTO $table_support_tickets
( (
project_id, project_id,
category_id, category_id,
@ -302,7 +307,7 @@ class TicketManager
'$now', '$now',
'$source' '$source'
)"; )";
Database::query($sql_insert_ticket); Database::query($sql);
$ticket_id = Database::insert_id(); $ticket_id = Database::insert_id();
if ($assigned_user != 0) { if ($assigned_user != 0) {
@ -313,20 +318,22 @@ class TicketManager
$ticket_code = "A" . str_pad( $ticket_code = "A" . str_pad(
(int) $ticket_id, 11, "0", STR_PAD_LEFT (int) $ticket_id, 11, "0", STR_PAD_LEFT
); );
$sql_update_code = "UPDATE $table_support_tickets // Update code
$sql = "UPDATE $table_support_tickets
SET ticket_code = '$ticket_code' SET ticket_code = '$ticket_code'
WHERE ticket_id = '$ticket_id'"; WHERE ticket_id = '$ticket_id'";
Database::query($sql_update_code); Database::query($sql);
$data_files = array(); $data_files = array();
$sql_update_total = "UPDATE $table_support_category // Update total
$sql = "UPDATE $table_support_category
SET total_tickets = total_tickets +1 SET total_tickets = total_tickets +1
WHERE category_id = '$category_id';"; WHERE category_id = '$category_id';";
Database::query($sql_update_total); Database::query($sql);
if (self::insert_message($ticket_id, $subject, $content, $file_attachments, $request_user)) { if (self::insert_message($ticket_id, $subject, $content, $file_attachments, $request_user)) {
global $data_files;
if ($other_area) {
$user = api_get_user_info($request_user); $user = api_get_user_info($request_user);
$helpDeskMessage = '<table> $helpDeskMessage =
'<table>
<tr> <tr>
<td width="100px"><b>' . get_lang('User') . '</b></td> <td width="100px"><b>' . get_lang('User') . '</b></td>
<td width="400px">' . $user['firstname']. ' ' . $user['lastname'] . '</td> <td width="400px">' . $user['firstname']. ' ' . $user['lastname'] . '</td>
@ -335,6 +342,14 @@ class TicketManager
<td width="100px"><b>' . get_lang('Username') . '</b></td> <td width="100px"><b>' . get_lang('Username') . '</b></td>
<td width="400px">' . $user['username'] . '</td> <td width="400px">' . $user['username'] . '</td>
</tr> </tr>
<tr>
<td width="100px"><b>' . get_lang('Email') . '</b></td>
<td width="400px">' . $user['email'] . '</td>
</tr>
<tr>
<td width="100px"><b>' . get_lang('Phone') . '</b></td>
<td width="400px">' . $user['phone'] . '</td>
</tr>
<tr> <tr>
<td width="100px"><b>' . get_lang('Date') . '</b></td> <td width="100px"><b>' . get_lang('Date') . '</b></td>
<td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . '</td> <td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . '</td>
@ -349,6 +364,9 @@ class TicketManager
</tr> </tr>
</table>'; </table>';
global $data_files;
if ($other_area) {
// Send email to "other area" email // Send email to "other area" email
api_mail_html( api_mail_html(
$plugin->get_lang('VirtualSupport'), $plugin->get_lang('VirtualSupport'),
@ -380,6 +398,44 @@ class TicketManager
); );
} }
if (!empty($category_id)) {
$categoryInfo = TicketManager::getCategory($category_id);
if ($plugin->get('warn_admin_no_user_in_category')) {
$usersInCategory = TicketManager::getUsersInCategory($category_id);
if (empty($usersInCategory)) {
$subject = sprintf(
$plugin->get_lang('WarningCategoryXDoesntHaveUsers'),
$categoryInfo['name']
);
$message = '<h2>'.$plugin->get_lang('TicketInformation').'</h2><br />'.$helpDeskMessage;
if ($plugin->get('send_warning_to_all_admins')) {
$admins = UserManager::get_all_administrators();
foreach ($admins as $userId => $data) {
if ($data['active']) {
MessageManager::send_message_simple(
$userId,
$subject,
$message
);
}
}
} else {
MessageManager::send_message_simple(
api_get_user_id(),
$subject,
$message
);
}
}
}
}
return true; return true;
} else { } else {

@ -28,11 +28,13 @@ class TicketPlugin extends Plugin
$settings = array( $settings = array(
'tool_enable' => 'boolean', 'tool_enable' => 'boolean',
'allow_student_add' => 'boolean', 'allow_student_add' => 'boolean',
'allow_category_edition' => 'boolean' 'allow_category_edition' => 'boolean',
'warn_admin_no_user_in_category' => 'boolean',
'send_warning_to_all_admins' => 'boolean'
); );
parent::__construct( parent::__construct(
'1.0', '2.0',
'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier, Julio Montoya', 'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier, Julio Montoya',
$settings $settings
); );

Loading…
Cancel
Save