diff --git a/plugin/ticket/lang/english.php b/plugin/ticket/lang/english.php
index 6fe6258dda..f331a6791a 100755
--- a/plugin/ticket/lang/english.php
+++ b/plugin/ticket/lang/english.php
@@ -85,6 +85,10 @@ $strings['PleaseBeforeRegisterATicketSelectOneUser'] = "Please select a user bef
$strings['RequestConfirmation'] = "Request confirmation";
$strings['TicketUpdated'] = "Ticket updated";
$strings['TicketClosed'] = "Ticket closed";
-
$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';
+
diff --git a/plugin/ticket/src/categories.php b/plugin/ticket/src/categories.php
index 4ddbbb99c9..b2314a5d0f 100644
--- a/plugin/ticket/src/categories.php
+++ b/plugin/ticket/src/categories.php
@@ -104,7 +104,6 @@ function modify_filter($id, $params, $row)
return $result;
}
-
Display::display_header($plugin->get_lang('MyTickets'));
$table->set_header(0, '', false);
$table->set_header(1, $plugin->get_lang('Title'), true);
diff --git a/plugin/ticket/src/categories_add_user.php b/plugin/ticket/src/categories_add_user.php
index c562e2f190..5e7af2d84a 100644
--- a/plugin/ticket/src/categories_add_user.php
+++ b/plugin/ticket/src/categories_add_user.php
@@ -5,7 +5,7 @@
*
* @package chamilo.plugin.ticket
*/
-
+$cidReset = true;
require_once '../config.php';
$plugin = TicketPlugin::create();
@@ -17,10 +17,7 @@ if (empty($categoryId)) {
}
$form = new FormValidator('edit', 'post', api_get_self().'?id='.$categoryId);
-
-
$users = UserManager::get_user_list([], ['firstname']);
-
$users = array_column($users, 'complete_name', 'user_id');
$form->addElement(
@@ -48,5 +45,7 @@ if ($form->validate()) {
header("Location: ".api_get_self()."?id=".$categoryId);
exit;
}
+
+$interbreadcrumb[] = array('url' => 'categories.php', 'name' => get_lang('Categories'));
Display::display_header();
$form->display();
diff --git a/plugin/ticket/src/course_user_list.php b/plugin/ticket/src/course_user_list.php
index af80af6c42..1a5a380f0c 100755
--- a/plugin/ticket/src/course_user_list.php
+++ b/plugin/ticket/src/course_user_list.php
@@ -31,7 +31,6 @@ $userInput = Display::tag(
)
);
$userControl = Display::div($userInput, array('class' => 'controls'));
-
$courseLabel = Display::tag('label', get_lang('Course'), array('class' => 'control-label'));
$courseSelect = Display::select('course_id', $arrCourseList, 0, array(), false);
$courseControl = Display::div($courseSelect, array('class' => 'controls'));
diff --git a/plugin/ticket/src/myticket.php b/plugin/ticket/src/myticket.php
index 1e8052af6e..febdcdcacd 100755
--- a/plugin/ticket/src/myticket.php
+++ b/plugin/ticket/src/myticket.php
@@ -298,8 +298,8 @@ if ($isAdmin) {
if ($plugin->get('allow_category_edition')) {
echo Display::url(
- Display::return_icon('document.png'),
- api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/categories.php'
+ Display::return_icon('folder_document.gif'),
+ api_get_path(WEB_PLUGIN_PATH) . 'ticket/src/categories.php'
);
}
diff --git a/plugin/ticket/src/new_ticket.php b/plugin/ticket/src/new_ticket.php
index 1dd3a3e95c..911b2c78a1 100755
--- a/plugin/ticket/src/new_ticket.php
+++ b/plugin/ticket/src/new_ticket.php
@@ -132,7 +132,7 @@ function add_image_form() {
});
img_remove = $("", {
- src: "' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif"
+ src: "' . Display::returnIconPath('delete.png') . '"
});
new_filepath_id = $("#filepath_" + counter_image);
@@ -317,8 +317,7 @@ function show_form_send_ticket()
)
);
- $form->addElement(
- 'html',
+ $form->addLabel('',
Display::div(
'',
array(
@@ -394,18 +393,15 @@ function show_form_send_ticket()
'for' => 'priority_id'
)
);
-
- $form->addElement('html', '');
- $form->addElement('html', '');
$form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
- $form->addElement('html', '
');
- $form->addElement('html', '');
+ $form->addLabel('', '');
- $form->addElement('html', '
');
- $form->addElement('html', '
');
- $form->addElement('html', '' . get_lang('AddOneMoreFile') . '');
- $form->addElement('html', '');
- $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
+ $form->addLabel('',
+ '
+ ' . get_lang('AddOneMoreFile') . '
+
+ ('.sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))).')
+ ');
$form->addElement('html', '
');
$form->addElement(
@@ -415,7 +411,7 @@ function show_form_send_ticket()
null,
null,
null,
- 'save',
+ 'btn btn-primary',
array(
'id' => 'btnsubmit'
)
diff --git a/plugin/ticket/src/ticket.class.php b/plugin/ticket/src/ticket.class.php
index 69e79fe2d6..4e61b6ad69 100755
--- a/plugin/ticket/src/ticket.class.php
+++ b/plugin/ticket/src/ticket.class.php
@@ -152,6 +152,8 @@ class TicketManager
/**
* @param int $userId
* @param int $categoryId
+ *
+ * @return bool
*/
public static function userIsAssignedToCategory($userId, $categoryId)
{
@@ -166,6 +168,8 @@ class TicketManager
/**
* @param int $categoryId
+ *
+ * @return array
*/
public static function getUsersInCategory($categoryId)
{
@@ -272,7 +276,8 @@ class TicketManager
if ($request_user == '' && $source == 'VRT') {
$request_user = $user_id;
}
- $sql_insert_ticket = "INSERT INTO $table_support_tickets
+ // insert_ticket
+ $sql = "INSERT INTO $table_support_tickets
(
project_id,
category_id,
@@ -302,7 +307,7 @@ class TicketManager
'$now',
'$source'
)";
- Database::query($sql_insert_ticket);
+ Database::query($sql);
$ticket_id = Database::insert_id();
if ($assigned_user != 0) {
@@ -313,41 +318,54 @@ class TicketManager
$ticket_code = "A" . str_pad(
(int) $ticket_id, 11, "0", STR_PAD_LEFT
);
- $sql_update_code = "UPDATE $table_support_tickets
- SET ticket_code = '$ticket_code'
- WHERE ticket_id = '$ticket_id'";
- Database::query($sql_update_code);
+ // Update code
+ $sql = "UPDATE $table_support_tickets
+ SET ticket_code = '$ticket_code'
+ WHERE ticket_id = '$ticket_id'";
+ Database::query($sql);
$data_files = array();
- $sql_update_total = "UPDATE $table_support_category
- SET total_tickets = total_tickets +1
- WHERE category_id = '$category_id';";
- Database::query($sql_update_total);
+ // Update total
+ $sql = "UPDATE $table_support_category
+ SET total_tickets = total_tickets +1
+ WHERE category_id = '$category_id';";
+ Database::query($sql);
if (self::insert_message($ticket_id, $subject, $content, $file_attachments, $request_user)) {
+
+ $user = api_get_user_info($request_user);
+ $helpDeskMessage =
+ '
+
+ ' . get_lang('User') . ' |
+ ' . $user['firstname']. ' ' . $user['lastname'] . ' |
+
+
+ ' . get_lang('Username') . ' |
+ ' . $user['username'] . ' |
+
+
+ ' . get_lang('Email') . ' |
+ ' . $user['email'] . ' |
+
+
+ ' . get_lang('Phone') . ' |
+ ' . $user['phone'] . ' |
+
+
+ ' . get_lang('Date') . ' |
+ ' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . ' |
+
+
+ ' . get_lang('Topic') . ' |
+ ' . $subject . ' |
+
+
+ ' . get_lang('Description') . ' |
+ ' . $content . ' |
+
+
';
+
global $data_files;
if ($other_area) {
- $user = api_get_user_info($request_user);
- $helpDeskMessage = '
-
- ' . get_lang('User') . ' |
- ' . $user['firstname']. ' ' . $user['lastname'] . ' |
-
-
- ' . get_lang('Username') . ' |
- ' . $user['username'] . ' |
-
-
- ' . get_lang('Date') . ' |
- ' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . ' |
-
-
- ' . get_lang('Topic') . ' |
- ' . $subject . ' |
-
-
- ' . get_lang('Description') . ' |
- ' . $content . ' |
-
-
';
// Send email to "other area" email
api_mail_html(
@@ -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 = '
'.$plugin->get_lang('TicketInformation').'
'.$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;
} else {
diff --git a/plugin/ticket/src/ticket_plugin.class.php b/plugin/ticket/src/ticket_plugin.class.php
index ae4b06e0e8..e50b3ed3d7 100755
--- a/plugin/ticket/src/ticket_plugin.class.php
+++ b/plugin/ticket/src/ticket_plugin.class.php
@@ -28,11 +28,13 @@ class TicketPlugin extends Plugin
$settings = array(
'tool_enable' => '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(
- '1.0',
+ '2.0',
'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier, Julio Montoya',
$settings
);