@ -1,20 +1,24 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Declaration of TicketManager class
* @package chamilo.plugin.ticket
*/
/**
* Class TicketManager
*
*/
class TicketManager
{
/**
* Constructor
*/
function __construct()
{
}
/**
@ -76,21 +80,9 @@ class TicketManager
* @return bool
*/
public static function insert_new_ticket(
$category_id,
$course_id,
$project_id,
$other_area,
$email,
$subject,
$content,
$personalEmail = "",
$file_attachments,
$source = 'VRT',
$priority = 'NRM',
$status = '',
$request_user = '',
$assigned_user = 0
) {
$category_id, $course_id, $project_id, $other_area, $email, $subject, $content, $personalEmail = "", $file_attachments, $source = 'VRT', $priority = 'NRM', $status = '', $request_user = '', $assigned_user = 0
)
{
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY
@ -152,10 +144,7 @@ class TicketManager
}
if ($ticket_id != 0) {
$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
SET ticket_code = '$ticket_code' WHERE ticket_id = '$ticket_id'";
@ -192,23 +181,12 @@ class TicketManager
< / tr >
< / table > ';
api_mail_html(
'Soporte virtual',
$email,
"[SOPORTE] Incidente Reenviado de Soporte Virtual",
$helpDeskMessage,
$user['firstname'] . ' ' . $user['lastname'],
$personalEmail,
array('cc' => 'soportevirtual@usil.edu.pe'),
$data_files
'Soporte virtual', $email, "[SOPORTE] Incidente Reenviado de Soporte Virtual", $helpDeskMessage, $user['firstname'] . ' ' . $user['lastname'], $personalEmail, array('cc' => 'soportevirtual@usil.edu.pe'), $data_files
);
$studentMessage = '< p > Su consulta fue reenviada al area responsable : < a href = "mailto:' . $email . '" > ' . $email . '< / a > < / p > ';
$studentMessage .= '< p > La respuesta a su consulta será enviada al correo : < a href = "#" > ' . $personalEmail . '< / a > < / p > ';
self::insert_message(
$ticket_id,
get_lang('MessageResent'),
$studentMessage,
null,
1
$ticket_id, get_lang('MessageResent'), $studentMessage, null, 1
);
}
@ -262,11 +240,7 @@ class TicketManager
WEB_PLUGIN_PATH
) . PLUGIN_NAME . '/src/ticket_details.php?ticket_id=' . $ticket_id . '">Ticket< / a > < / p > ';
api_mail_html(
$info['firstname'] . " " . $info['lastname'],
$info['mail'],
"[TICKETS] Asignacion de Ticket #$ticket_id ",
$message,
null, // sender name
$info['firstname'] . " " . $info['lastname'], $info['mail'], "[TICKETS] Asignacion de Ticket #$ticket_id ", $message, null, // sender name
null, // sender e-mail
array('cc' => $sender['email']) // should be support e-mail (platform admin) here
);
@ -285,13 +259,7 @@ class TicketManager
* @return bool
*/
public static function insert_message(
$ticket_id,
$subject,
$content,
$file_attachments,
$user_id,
$status = 'NOL',
$sendConfirmation = false
$ticket_id, $subject, $content, $file_attachments, $user_id, $status = 'NOL', $sendConfirmation = false
)
{
global $data_files;
@ -370,10 +338,7 @@ class TicketManager
foreach ($file_attachments as $file_attach) {
if ($file_attach['error'] == 0) {
$data_files[] = self::save_message_attachment_file(
$file_attach,
$ticket_id,
$message_id,
$message_attch_id
$file_attach, $ticket_id, $message_id, $message_attch_id
);
$message_attch_id++;
} else {
@ -395,18 +360,14 @@ class TicketManager
* @return array
*/
public static function save_message_attachment_file(
$file_attach,
$ticket_id,
$message_id,
$message_attch_id
$file_attach, $ticket_id, $message_id, $message_attch_id
)
{
$now = api_get_utc_datetime();
$user_id = api_get_user_id();
$ticket_id = intval($ticket_id);
$new_file_name = add_ext_on_mime(
stripslashes($file_attach['name']),
$file_attach['type']
stripslashes($file_attach['name']), $file_attach['type']
);
$file_name = $file_attach['name'];
$table_support_message_attachments = Database::get_main_table(
@ -422,9 +383,7 @@ class TicketManager
$path_message_attach = $path_attachment . 'plugin_ticket_messageattch/';
if (!file_exists($path_message_attach)) {
@mkdir(
$path_message_attach,
api_get_permissions_for_new_directories(),
true
$path_message_attach, api_get_permissions_for_new_directories(), true
);
}
$new_path = $path_message_attach . $new_file_name;
@ -473,12 +432,9 @@ class TicketManager
* @return array
*/
public static function get_tickets_by_user_id(
$from,
$number_of_items,
$column,
$direction,
$user_id = null
) {
$from, $number_of_items, $column, $direction, $user_id = null
)
{
$table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY
);
@ -614,7 +570,6 @@ class TicketManager
)
)";
}
}
if ($keyword_unread == 'yes') {
$sql .= " AND ticket.ticket_id IN (SELECT ticket.ticket_id
@ -662,8 +617,7 @@ class TicketManager
$name = '< a href = "' . api_get_path (
WEB_PATH
) . 'main/admin/user_information.php?user_id=' . $row['user_id'] . '">' . api_get_person_name(
$userInfo['firstname'],
$userInfo['lastname']
$userInfo['firstname'], $userInfo['lastname']
) . '< / a > ';
$actions = "";
/* if($row['status_id']!='CLS' & & $row['status_id']!='REE'){
@ -703,15 +657,13 @@ class TicketManager
$row['col2'] = api_get_local_time($row['col2']);
if ($isAdmin) {
$actions .= '< a href = "ticket_details.php?ticket_id=' . $row['col0'] . '" > ' . Display::return_icon(
'synthese_view.gif',
get_lang('Info')
'synthese_view.gif', get_lang('Info')
) . '< / a > ';
if ($row['priority_id'] == 'ALT' & & $row['status_id'] != 'CLS') {
$actions .= '< img src = "' . api_get_path(WEB_CODE_PATH) . 'img/exclamation.png" border = "0" / > ';
}
$row['col0'] = Display::return_icon(
$img_source,
get_lang('Info')
$img_source, get_lang('Info')
) . '< a href = "ticket_details.php?ticket_id=' . $row['col0'] . '" > ' . $row['ticket_code'] . '< / a > ';
if ($row['col7'] == 'PENDIENTE') {
$row['col7'] = '< span style = "color: #f00; font-weight:bold;" > ' . $row['col7'] . '< / span > ';
@ -728,20 +680,16 @@ class TicketManager
$row['col8'],
$actions,
eregi_replace(
"[\n|\r|\n\r|\r\n]",
' ',
strip_tags($row['col9'])
"[\n|\r|\n\r|\r\n]", ' ', strip_tags($row['col9'])
)
);
} else {
$actions = "";
$actions .= '< a href = "ticket_details.php?ticket_id=' . $row['col0'] . '" > ' . Display::return_icon(
'synthese_view.gif',
get_lang('Info')
'synthese_view.gif', get_lang('Info')
) . '< / a > ';
$row['col0'] = Display::return_icon(
$img_source,
get_lang('Info')
$img_source, get_lang('Info')
) . '< a href = "ticket_details.php?ticket_id=' . $row['col0'] . '" > ' . $row['ticket_code'] . '< / a > ';
$now = api_strtotime(api_get_utc_datetime());
$last_edit_date = api_strtotime($row['sys_lastedit_datetime']);
@ -765,7 +713,6 @@ class TicketManager
if ($unread > 0) {
$ticket['0'] = $ticket['0'] . ' (' . $unread . ')< a href = "ticket_details.php?ticket_id=' . $row['ticket_id'] . '" > < img src = "../../../main/img/message_new.png" border = "0" title = "' . $unread . ' Nuevo(s) Mensajes" / > < / a > ';
}
if ($isAdmin) {
$ticket['0'] .= ' < a href = "javascript:void(0)" onclick = "load_history_ticket(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')" >
@ -887,7 +834,6 @@ class TicketManager
$sql .= " AND ticket.course_id IN ( ";
$sql .= "SELECT id FROM $course_table WHERE (title LIKE '%" . $keyword_course . "%' OR code LIKE '%" . $keyword_course . "%' OR visual_code LIKE '%" . $keyword_course . "%' )) ";
}
}
if ($keyword_unread == 'yes') {
$sql .= " AND ticket.ticket_id IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)";
@ -935,19 +881,13 @@ class TicketManager
while ($row = Database::fetch_assoc($result)) {
$row['course'] = null;
$row['start_date'] = api_convert_and_format_date(
api_get_local_time($row['start_date']),
DATE_TIME_FORMAT_LONG,
_api_get_timezone()
api_get_local_time($row['start_date']), DATE_TIME_FORMAT_LONG, _api_get_timezone()
);
$row['end_date'] = api_convert_and_format_date(
api_get_local_time($row['end_date']),
DATE_TIME_FORMAT_LONG,
_api_get_timezone()
api_get_local_time($row['end_date']), DATE_TIME_FORMAT_LONG, _api_get_timezone()
);
$row['sys_lastedit_datetime'] = api_convert_and_format_date(
api_get_local_time($row['sys_lastedit_datetime']),
DATE_TIME_FORMAT_LONG,
_api_get_timezone()
api_get_local_time($row['sys_lastedit_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()
);
$row['course_url'] = null;
if ($row['course_id'] != 0) {
@ -960,8 +900,7 @@ class TicketManager
$row['user_url'] = '< a href = "' . api_get_path (
WEB_PATH
) . 'main/admin/user_information.php?user_id=' . $row['request_user'] . '">' . api_get_person_name(
$userInfo['firstname'],
$userInfo['lastname']
$userInfo['firstname'], $userInfo['lastname']
) . '< / a > ';
$ticket['usuario'] = $userInfo;
$ticket['ticket'] = $row;
@ -1040,10 +979,9 @@ class TicketManager
* @return bool
*/
public static function update_ticket_status(
$status_id,
$ticket_id,
$user_id
) {
$status_id, $ticket_id, $user_id
)
{
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_messages = Database::get_main_table(
TABLE_TICKET_MESSAGE
@ -1081,7 +1019,6 @@ class TicketManager
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->unread;
}
/**
@ -1140,9 +1077,7 @@ class TicketManager
}
$insertuser = api_get_user_info($row['sys_insert_user_id']);
$row['assigned_date'] = api_convert_and_format_date(
api_get_local_time($row['assigned_date']),
'%d/%m/%y-%H:%M:%S',
_api_get_timezone()
api_get_local_time($row['assigned_date']), '%d/%m/%y-%H:%M:%S', _api_get_timezone()
);
$row['assignuser'] = ($row['user_id'] != 0) ? ('< a href = "' . api_get_path (
WEB_PATH
@ -1166,12 +1101,9 @@ class TicketManager
* @return array
*/
public static function export_tickets_by_user_id(
$from,
$number_of_items,
$column,
$direction,
$user_id = null
) {
$from, $number_of_items, $column, $direction, $user_id = null
)
{
$table_support_category = Database::get_main_table(
TABLE_TICKET_CATEGORY
);
@ -1278,7 +1210,6 @@ class TicketManager
$sql .= " AND ticket.ticket_id NOT IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.status != 1 AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)";
}
}
}
@ -1304,12 +1235,10 @@ class TicketManager
$row['responsable'] = $row['responsable']['firstname'] . ' ' . $row['responsable']['lastname'];
}
$row['sys_insert_datetime'] = api_format_date(
$row['sys_insert_datetime'],
'%d/%m/%y - %I:%M:%S %p'
$row['sys_insert_datetime'], '%d/%m/%y - %I:%M:%S %p'
);
$row['sys_lastedit_datetime'] = api_format_date(
$row['sys_lastedit_datetime'],
'%d/%m/%y - %I:%M:%S %p'
$row['sys_lastedit_datetime'], '%d/%m/%y - %I:%M:%S %p'
);
$row['category'] = utf8_decode($row['category']);
$row['programa'] = utf8_decode($row['fullname']);
@ -1320,4 +1249,5 @@ class TicketManager
return $tickets;
}
}