Code cleanup for ticket plugin - refs #6715

1.9.x
Yannick Warnier 12 years ago
parent e6ac6258e6
commit d948cd803c
  1. 9
      plugin/ticket/config.install.php
  2. 20
      plugin/ticket/config.php
  3. 16
      plugin/ticket/database.php
  4. 2
      plugin/ticket/install.php
  5. 22
      plugin/ticket/lib/ticket.class.php
  6. 30
      plugin/ticket/lib/ticket_plugin.class.php
  7. 3
      plugin/ticket/plugin.php
  8. 94
      plugin/ticket/src/assign_tickets.php
  9. 12
      plugin/ticket/src/course_user_list.php
  10. 22
      plugin/ticket/src/download.php
  11. 11
      plugin/ticket/src/index.php
  12. 20
      plugin/ticket/src/myticket.php
  13. 78
      plugin/ticket/src/new_ticket.php
  14. 140
      plugin/ticket/src/report.php
  15. 9
      plugin/ticket/src/send_ticket.php
  16. 338
      plugin/ticket/src/ticket.class.php
  17. 7
      plugin/ticket/src/ticket_assign_log.php
  18. 12
      plugin/ticket/src/ticket_details.php
  19. 14
      plugin/ticket/src/tutor.php
  20. 336
      plugin/ticket/src/tutor_report.lib.php
  21. 29
      plugin/ticket/src/update_report.php
  22. 39
      plugin/ticket/start.php
  23. 2
      plugin/ticket/uninstall.php

@ -1,8 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/* bbb parameters that will be registered in the course settings */
/**
* @package chamilo.plugin.ticket
*/
/**
* Loading of necessary libs
*/
require_once '../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'plugin.class.php';

@ -1,16 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
/* Tables names constants */
define('PLUGIN_NAME', 'ticket');
define('TABLE_SUPPORT_ASSIGNED_LOG', 'plugin_ticket_assigned_log');
define('TABLE_SUPPORT_CATEGORY', 'plugin_ticket_category');
define('TABLE_SUPPORT_MESSAGE', 'plugin_ticket_message');
define('TABLE_SUPPORT_PRIORITY', 'plugin_ticket_priority');
define('TABLE_SUPPORT_PROJECT', 'plugin_ticket_project');
define('TABLE_SUPPORT_STATUS', 'plugin_ticket_status');
define('TABLE_SUPPORT_TICKET', 'plugin_ticket_ticket');
define('TABLE_SUPPORT_MESSAGE_ATTACHMENTS', 'plugin_ticket_message_attachments');
define('TABLE_TICKET_ASSIGNED_LOG', 'plugin_ticket_assigned_log');
define('TABLE_TICKET_CATEGORY', 'plugin_ticket_category');
define('TABLE_TICKET_MESSAGE', 'plugin_ticket_message');
define('TABLE_TICKET_PRIORITY', 'plugin_ticket_priority');
define('TABLE_TICKET_PROJECT', 'plugin_ticket_project');
define('TABLE_TICKET_STATUS', 'plugin_ticket_status');
define('TABLE_TICKET_TICKET', 'plugin_ticket_ticket');
define('TABLE_TICKET_MESSAGE_ATTACHMENTS', 'plugin_ticket_message_attachments');
/* Ticket status constants */
define('NEWTCK', 'NAT'); // New ticket unassigned responsible

@ -2,7 +2,7 @@
/**
* Contains the SQL for the tickets management plugin database structure
*/
$table = Database::get_main_table(TABLE_SUPPORT_ASSIGNED_LOG);
$table = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
ticket_id int UNSIGNED DEFAULT NULL,
@ -13,7 +13,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
KEY FK_ticket_assigned_log (ticket_id))";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_CATEGORY);
$table = Database::get_main_table(TABLE_TICKET_CATEGORY);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
category_id char(3) NOT NULL,
@ -29,7 +29,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
PRIMARY KEY (iid))";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_MESSAGE);
$table = Database::get_main_table(TABLE_TICKET_MESSAGE);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
message_id int UNSIGNED NOT NULL,
ticket_id int UNSIGNED NOT NULL,
@ -45,7 +45,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
KEY FK_tick_message (ticket_id) )";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_MESSAGE_ATTACHMENTS);
$table = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
message_attch_id char(2) NOT NULL,
@ -62,7 +62,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
KEY ticket_message_id_fk (message_id))";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_PRIORITY);
$table = Database::get_main_table(TABLE_TICKET_PRIORITY);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
priority_id char(3) NOT NULL,
@ -77,7 +77,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
PRIMARY KEY (iid))";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_PROJECT);
$table = Database::get_main_table(TABLE_TICKET_PROJECT);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
project_id char(3) NOT NULL,
@ -92,7 +92,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
PRIMARY KEY (iid))";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_STATUS);
$table = Database::get_main_table(TABLE_TICKET_STATUS);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
iid int unsigned not null,
status_id char(3) NOT NULL,
@ -101,7 +101,7 @@ $sql = "CREATE TABLE IF NOT EXISTS ".$table." (
PRIMARY KEY (iid))";
Database::query($sql);
$table = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table = Database::get_main_table(TABLE_TICKET_TICKET);
$sql = "CREATE TABLE IF NOT EXISTS ".$table." (
ticket_id int UNSIGNED NOT NULL AUTO_INCREMENT,
ticket_code char(12) DEFAULT NULL,

@ -3,7 +3,7 @@
/**
* This script is included by main/admin/settings.lib.php and generally
* includes things to execute in the main database (settings_current table)
* @package chamilo.plugin.bigbluebutton
* @package chamilo.plugin.ticket
*/
/**
* Initialization

@ -9,20 +9,21 @@
*/
class Ticket {
var $url;
var $salt;
var $api;
var $user_complete_name = null;
var $protocol = 'http://';
var $debug = false;
var $logout_url = null;
var $plugin_enabled = false;
public $url;
public $salt;
public $api;
public $user_complete_name = null;
public $protocol = 'http://';
private $debug = false;
public $logout_url = null;
public $plugin_enabled = false;
/**
* Constructor (generates a connection to the API and the Chamilo settings
* required for the connection to the videoconference server)
*/
function __construct() {
function __construct()
{
// initialize video server settings from global settings
$plugin = TicketPlugin::create();
@ -31,7 +32,8 @@ class Ticket {
* Checks whether a user is teacher in the current course
* @return bool True if the user can be considered a teacher in this course, false otherwise
*/
function is_teacher() {
function is_teacher()
{
return api_is_course_admin() || api_is_coach() || api_is_platform_admin();
}

@ -9,16 +9,19 @@
*/
class TicketPlugin extends Plugin
{
static function create() {
static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
protected function __construct() {
parent::__construct('1.0', 'Kenny Rodas Chavez', array('tool_enable' => 'boolean'));
protected function __construct()
{
parent::__construct('1.0', 'Kenny Rodas Chavez, Genesis Lopez, Francis Gonzales, Yannick Warnier', array('tool_enable' => 'boolean'));
}
function install() {
public function install()
{
// Create database tables
require_once api_get_path(SYS_PLUGIN_PATH).PLUGIN_NAME.'/database.php';
@ -64,18 +67,19 @@ class TicketPlugin extends Plugin
}
function uninstall() {
public function uninstall()
{
$tblSettings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$t_options = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS);
$t_tool = Database::get_course_table(TABLE_TOOL_LIST);
$tblTicketTicket = Database::get_main_table(TABLE_SUPPORT_TICKET);
$tblTicketStatus = Database::get_main_table(TABLE_SUPPORT_STATUS);
$tblTicketProject = Database::get_main_table(TABLE_SUPPORT_PROJECT);
$tblTicketPriority = Database::get_main_table(TABLE_SUPPORT_PRIORITY);
$tblTicketMesAttch = Database::get_main_table(TABLE_SUPPORT_MESSAGE_ATTACHMENTS);
$tblTicketMessage = Database::get_main_table(TABLE_SUPPORT_MESSAGE);
$tblTicketCategory = Database::get_main_table(TABLE_SUPPORT_CATEGORY);
$tblTicketAssgLog = Database::get_main_table(TABLE_SUPPORT_ASSIGNED_LOG);
$tblTicketTicket = Database::get_main_table(TABLE_TICKET_TICKET);
$tblTicketStatus = Database::get_main_table(TABLE_TICKET_STATUS);
$tblTicketProject = Database::get_main_table(TABLE_TICKET_PROJECT);
$tblTicketPriority = Database::get_main_table(TABLE_TICKET_PRIORITY);
$tblTicketMesAttch = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
$tblTicketMessage = Database::get_main_table(TABLE_TICKET_MESSAGE);
$tblTicketCategory = Database::get_main_table(TABLE_TICKET_CATEGORY);
$tblTicketAssgLog = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
//Delete settings
$sql = "DELETE FROM $tblSettings WHERE variable = 'ticket_tool_enable'";

@ -1,4 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
require_once dirname(__FILE__).'/config.php';
$plugin_info = TicketPlugin::create()->get_info();

@ -1,46 +1,68 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
/**
* Init section
*/
require_once '../config.php';
$plugin = TicketPlugin::create();
api_protect_course_script();
if (!api_is_allowed_to_edit()){
if (!api_is_allowed_to_edit()) {
api_not_allowed();
}
$course_info = api_get_course_info();
$course_code = $course_info['code'];
echo '<form action="tutor.php" name="asignar" id ="asignar">';
echo '<div id="confirmacion"></div>';
$id = $_GET['id'];
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$sql ="SELECT * FROM $table_reporte_semanas WHERE id = '$id'";
$sql_tareas = "SELECT id AS colid, title as coltitle FROM ".Database::get_course_table(TABLE_STUDENT_PUBLICATION , $course_info['dbName'])." WHERE parent_id = 0
AND id NOT IN (SELECT work_id FROM $table_reporte_semanas WHERE course_code = '$course_code' AND id != '$id')";
$sql_foros = "SELECT thread_id AS colid, thread_title AS coltitle FROM ".Database::get_course_table(TABLE_FORUM_THREAD, $course_info['dbName'])."
WHERE thread_id NOT IN (SELECT forum_id FROM $table_reporte_semanas WHERE course_code = '$course_code' AND id != '$id')";
$rs = Database::fetch_object(Database::query($sql));
$result_tareas = Database::query($sql_tareas);
$result_foros = Database::query($sql_foros);
echo '<div class="row">
<input type="hidden" id="rs_id" name ="rs_id" value="'.$id.'">
<div class="formw">Seleccione la Tarea</div>
</div>';
echo '<div class="row"><div class="formw"><select name ="work_id" id="work_id">';
echo '<option value="0"'.(($row['colid']==$rs->work_id)?"selected":"").'>'.'Seleccione'.'</option>';
while($row = Database::fetch_assoc($result_tareas)){
echo '<option value="'.$row['colid'].'"'.(($row['colid']==$rs->work_id)?"selected":"").'>'.$row['coltitle'].'</option>';
}
echo '</select></div><div>';
echo '<div class="row">
<div class="formw">Seleccione el tema</div>
</div>';
echo '<div class="row"><div class="formw"><select name ="forum_id" id="forum_id">';
echo '<option value="0"'.(($row['colid']==$rs->work_id)?"forum_id":"").'>'.'Seleccione'.'</option>';
while($row = Database::fetch_assoc($result_foros)){
echo '<option value="'.$row['colid'].'"'.(($row['colid']==$rs->forum_id)?"selected":"").'>'.$row['coltitle'].'</option>';
}
echo '</select></div><div>';
echo '<div class="row">
<div class="formw"><button class="save" name="editar" type="button" value="Editar" onClick="save('."$id".');">Editar</button></div>
</div>';
echo '</form>';
echo '<form action="tutor.php" name="assign" id ="assign">';
echo '<div id="confirmation"></div>';
$id = intval($_GET['id']);
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$sql ="SELECT * FROM $table_reporte_semanas WHERE id = '$id'";
$sql_tasks = "SELECT id AS colid, title as coltitle
FROM ".Database::get_course_table(TABLE_STUDENT_PUBLICATION , $course_info['dbName'])."
WHERE parent_id = 0
AND id NOT IN (
SELECT work_id
FROM $table_reporte_semanas
WHERE course_code = '$course_code'
AND id != '$id'
)";
$sql_forum = "SELECT thread_id AS colid, thread_title AS coltitle
FROM ".Database::get_course_table(TABLE_FORUM_THREAD, $course_info['dbName'])."
WHERE thread_id NOT IN (
SELECT forum_id
FROM $table_reporte_semanas
WHERE course_code = '$course_code'
AND id != '$id'
)";
$rs = Database::fetch_object(Database::query($sql));
$result_tareas = Database::query($sql_tasks);
$result_forum = Database::query($sql_forum);
echo '<div class="row">
<input type="hidden" id="rs_id" name ="rs_id" value="'.$id.'">
<div class="formw">'.get_lang('PleaseSelectTasks').'</div>
</div>';
echo '<div class="row"><div class="formw"><select name ="work_id" id="work_id">';
echo '<option value="0"'.(($row['colid']==$rs->work_id)?"selected":"").'>'.get_lang('PleaseSelect').'</option>';
while ($row = Database::fetch_assoc($result_tasks)){
echo '<option value="'.$row['colid'].'"'.(($row['colid']==$rs->work_id)?"selected":"").'>'.$row['coltitle'].'</option>';
}
echo '</select></div><div>';
echo '<div class="row">
<div class="formw">'.get_lang('PleaseSelectThread').'</div>
</div>';
echo '<div class="row"><div class="formw"><select name ="forum_id" id="forum_id">';
echo '<option value="0"'.(($row['colid']==$rs->work_id)?"forum_id":"").'>'.get_lang('PleaseSelect').'</option>';
while ($row = Database::fetch_assoc($result_forum)){
echo '<option value="'.$row['colid'].'"'.(($row['colid']==$rs->forum_id)?"selected":"").'>'.$row['coltitle'].'</option>';
}
echo '</select></div><div>';
echo '<div class="row">
<div class="formw"><button class="save" name="edit" type="button" value="'.get_lang('Edit').'" onClick="save('."$id".');">'.get_lang('Edit').'</button></div>
</div>';
echo '</form>';

@ -1,11 +1,19 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
/**
* Init section
*/
$language_file = array('registration');
require_once '../config.php';
$plugin = TicketPlugin::create();
$user_id=intval($_GET['user_id']);
$user_id = intval($_GET['user_id']);
$user_info = api_get_user_info($user_id);
$courses_list=CourseManager::get_courses_list_by_user_id($user_id,false,true);
$courses_list = CourseManager::get_courses_list_by_user_id($user_id,false,true);
?>
<div class="row">
<div class="label2"><?php echo get_lang('User')?>:</div>

@ -1,4 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
/**
* Init section
*/
require_once '../config.php';
$plugin = TicketPlugin::create();
@ -13,11 +21,9 @@ if (!isset($_GET['file']) || !isset($_GET['title']) || !isset($_GET['ticket_id']
}
if (!api_is_platform_admin()) {
$ticket_id = intval($_GET['ticket_id']);
$table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE);
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_message_attachments = Database::get_main_table(
TABLE_SUPPORT_MESSAGE_ATTACHMENTS
);
$table_support_messages = Database::get_main_table(TABLE_TICKET_MESSAGE);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
$sql = "SELECT DISTINCT ticket.request_user
FROM $table_support_tickets ticket,
$table_support_messages message,
@ -32,14 +38,16 @@ if (!api_is_platform_admin()) {
api_not_allowed();
}
}
// @todo replace by Security::check_abs_path()?
$file_url = $_GET['file'];
$file_url = str_replace('///', '&', $file_url);
$file_url = str_replace(' ', '+', $file_url);
$file_url = str_replace('/..', '', $file_url);
$file_url = Database::escape_string($file_url);
$title = $_GET['title'];
$path_attachment = api_get_path(SYS_PATH);
$path_message_attach = $path_attachment . 'tck_messageattch/';
$path_attachment = api_get_path(SYS_ARCHIVE_PATH);
$path_message_attach = $path_attachment . 'plugin_ticket_messageattch/';
$full_file_name = $path_message_attach . $file_url;
if (Security::check_abs_path($full_file_name, $path_message_attach)) {
DocumentManager::file_send_for_download($full_file_name, true, $title);

@ -1,4 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Redirects to "myticket.php"
* @package chamilo.plugin.ticket
*/
/**
* Code
*/
require_once '../config.php';
header('location:'.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/myticket.php?message=success');
?>
header('location:'.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/src/myticket.php?message=success');

@ -1,5 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script is the Tickets plugin main entry point
* @package chamilo.plugin.ticket
*/
/**
* Initialization
*/
$language_file = array('messages', 'userInfo', 'admin');
$cidReset = true;
@ -7,17 +14,20 @@ $course_plugin = 'ticket'; //needed in order to load the plugin lang variables
require_once '../config.php';
$plugin = TicketPlugin::create();
$tool_name = $plugin->get_lang('DateLastEdition');
$tool_name = $plugin->get_lang('LastEdit');
api_block_anonymous_users();
require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH) . 'group_portal_manager.lib.php';
$libPath = api_get_path(LIBRARY_PATH);
$webLibPath = api_get_path(WEB_LIBRARY_PATH);
require_once $libPath. 'formvalidator/FormValidator.class.php';
require_once $libPath . 'group_portal_manager.lib.php';
$htmlHeadXtra[] = '<script type="text/javascript">
function load_history_ticket (div_course,ticket_id) {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(object) {
$("div#"+div_course).html("<img src=\'../../../main/inc/lib/javascript/indicator.gif\' />"); },
$("div#"+div_course).html("<img src=\''.$webLibPath.'javascript/indicator.gif\' />"); },
type: "POST",
url: "ticket_assign_log.php",
data: "ticket_id="+ticket_id,

@ -1,5 +1,11 @@
<?php
/* INIT SECTION */
/* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
/**
* INIT SECTION
*/
$language_file = array('messages','userInfo', 'admin');
$cidReset = true;
require_once '../config.php';
@ -137,10 +143,20 @@ $htmlHeadXtra[] = '<script language="javascript">
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
$htmlHeadXtra[] = '<link href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
/**
* @param $s
* @return string
*/
function js_str($s) {
return '"'.addcslashes($s, "\0..\37\"\\").'"';
}
/**
* @param $array
* @param $name
* @param $key
* @return string
*/
function js_array($array,$name,$key) {
$temp=array();
$return = "new Array(); ";
@ -150,6 +166,9 @@ function js_array($array,$name,$key) {
return $return;
}
/**
*
*/
function show_form_send_ticket(){
global $types, $plugin;
echo '<div class="divTicket">';
@ -297,6 +316,10 @@ function show_form_send_ticket(){
</div>';
echo '</form></div>';
}
/**
*
*/
function save_ticket(){
global $plugin;
$category_id = $_POST['category_id'];
@ -405,9 +428,9 @@ function get_user_data($from, $number_of_items, $column, $direction)
if(!isset($_POST['compose'])){
Display::display_header(get_lang('ComposeMessage'));
echo '
if (!isset($_POST['compose'])) {
Display::display_header(get_lang('ComposeMessage'));
echo '
<div class="actions">
<span style="float: right;">&nbsp;</span>
<form id="search_simple" name="search_simple" method="get" action="'.api_get_self().'" class="form-search">
@ -418,30 +441,27 @@ function get_user_data($from, $number_of_items, $column, $direction)
</fieldset>
</form>
</div>';
if (isset($_GET['keyword'])){
$table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$table->set_header(0, '', false, 'width="18px"');
$table->set_header(0, get_lang('Photo'), false);
$table->set_header(1, get_lang('OfficialCode'));
if (api_is_western_name_order()) {
$table->set_header(2, get_lang('FirstName'));
$table->set_header(3, get_lang('LastName'));
} else {
$table->set_header(2, get_lang('LastName'));
$table->set_header(3, get_lang('FirstName'));
}
$table->set_header(4, get_lang('LoginName'));
$table->set_header(5, get_lang('Email'));
$table->set_header(6, get_lang('Action'));
$table->display();
}
//if(isset($_GET['user_request']))
show_form_send_ticket();
}else{
save_ticket();
}
if (isset($_GET['keyword'])){
$table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$table->set_header(0, '', false, 'width="18px"');
$table->set_header(0, get_lang('Photo'), false);
$table->set_header(1, get_lang('OfficialCode'));
if (api_is_western_name_order()) {
$table->set_header(2, get_lang('FirstName'));
$table->set_header(3, get_lang('LastName'));
} else {
$table->set_header(2, get_lang('LastName'));
$table->set_header(3, get_lang('FirstName'));
}
$table->set_header(4, get_lang('LoginName'));
$table->set_header(5, get_lang('Email'));
$table->set_header(6, get_lang('Action'));
$table->display();
}
//if(isset($_GET['user_request']))
show_form_send_ticket();
}else{
save_ticket();
}
Display::display_footer();
?>

@ -1,5 +1,11 @@
<?php
/* INIT SECTION */
/* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
/**
* INIT SECTION
*/
$language_file= array('messages','userInfo', 'admin','trad4all');
$cidReset = true;
require_once '../config.php';
@ -216,74 +222,72 @@ function get_user_data($from, $number_of_items, $column, $direction)
Display::display_header('Reportes');
echo '<div class="actions">
<form action="'.api_get_self().'" method="get" name="search_simple" id="search_simple">
<input name="user_id_request" id="user_id_request" type="hidden" value="">
<span><label for="keyword">B&uacute;squeda del usuario: </label><input size="25" name="keyword" type="text" id="keyword"></span>
<span><button class="search" name="submit" type="submit">Buscar</button></span>
<div class="clear">&nbsp;</div>
</form></div>';
if (isset($_GET['keyword'])){
$table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$table->set_header(0, '', false, 'width="18px"');
$table->set_header(0, get_lang('Photo'), false);
$table->set_header(1, get_lang('OfficialCode'));
if (api_is_western_name_order()) {
$table->set_header(2, get_lang('FirstName'));
$table->set_header(3, get_lang('LastName'));
} else {
$table->set_header(2, get_lang('LastName'));
$table->set_header(3, get_lang('FirstName'));
}
$table->set_header(4, get_lang('LoginName'));
$table->set_header(5, get_lang('Email'));
$table->set_header(6, get_lang('Action'));
$table->display();
}
//if(isset($_GET['user_request']))
if(isset($_POST['report'])){
$course_id = $_POST['course_id'];
$tool = $_POST['tool'];
$course_info = api_get_course_info_by_id($course_id);
$user_id = $_POST['user_id_request'];
$sql ="SELECT u.username , CONCAT(u.lastname, ' ', u.firstname) AS fullname, DATE_SUB(access.access_date,INTERVAL 5 HOUR) AS access_date, c.title AS curso, access_tool AS herramienta
FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS)." access
LEFT JOIN ".Database::get_main_table(TABLE_MAIN_USER)." u ON access.access_user_id = u.user_id
LEFT JOIN ".Database::get_main_table(TABLE_MAIN_COURSE)." c ON access.access_cours_code = c.CODE
WHERE access.access_cours_code = '".$course_info['code']."' AND u.user_id = '$user_id' ";
if($tool!= '') $sql.="AND access.access_tool = '$tool' ";
$start_date = $_POST['keyword_start_date_start'];
$end_date = $_POST['keyword_start_date_end'];
if ($start_date != '' || $end_date != ''){
$sql .= " HAVING ";
if ($start_date != '') $sql .= " access_date >= '$start_date' ";
if ($end_date != '') {
$sql = ($start_date == '')?$sql:($sql." AND ");
$sql .= " access_date <= '$end_date' ";
}
}
$result = Database::query($sql);
$table_result = new SortableTable();
$table_result->set_header(0, get_lang('User'), false);
$table_result->set_header(1, get_lang('Fullname'), false);
$table_result->set_header(2, get_lang('Fecha'), false);
$table_result->set_header(3, get_lang('curso'), false);
$table_result->set_header(4, get_lang('Herramienta'), false);
while ($row = Database::fetch_assoc($result)){
$row = array(0 =>$row['username'],1 =>$row['fullname'],2 => $row['access_date'],3 =>$row['curso'],4 =>get_lang($tools[$row['herramienta']]['name']));
$table_result->addRow($row);
}
$table_result->display();
}else{
show_form();
}
echo '<div class="actions">
<form action="'.api_get_self().'" method="get" name="search_simple" id="search_simple">
<input name="user_id_request" id="user_id_request" type="hidden" value="">
<span><label for="keyword">B&uacute;squeda del usuario: </label><input size="25" name="keyword" type="text" id="keyword"></span>
<span><button class="search" name="submit" type="submit">Buscar</button></span>
<div class="clear">&nbsp;</div>
</form></div>';
if (isset($_GET['keyword'])){
$table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$table->set_header(0, '', false, 'width="18px"');
$table->set_header(0, get_lang('Photo'), false);
$table->set_header(1, get_lang('OfficialCode'));
if (api_is_western_name_order()) {
$table->set_header(2, get_lang('FirstName'));
$table->set_header(3, get_lang('LastName'));
} else {
$table->set_header(2, get_lang('LastName'));
$table->set_header(3, get_lang('FirstName'));
}
$table->set_header(4, get_lang('LoginName'));
$table->set_header(5, get_lang('Email'));
$table->set_header(6, get_lang('Action'));
$table->display();
}
//if(isset($_GET['user_request']))
if (isset($_POST['report'])) {
$course_id = $_POST['course_id'];
$tool = $_POST['tool'];
$course_info = api_get_course_info_by_id($course_id);
$user_id = $_POST['user_id_request'];
$sql ="SELECT u.username , CONCAT(u.lastname, ' ', u.firstname) AS fullname, DATE_SUB(access.access_date,INTERVAL 5 HOUR) AS access_date, c.title AS curso, access_tool AS herramienta
FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS)." access
LEFT JOIN ".Database::get_main_table(TABLE_MAIN_USER)." u ON access.access_user_id = u.user_id
LEFT JOIN ".Database::get_main_table(TABLE_MAIN_COURSE)." c ON access.access_cours_code = c.CODE
WHERE access.access_cours_code = '".$course_info['code']."' AND u.user_id = '$user_id' ";
if($tool!= '') $sql.="AND access.access_tool = '$tool' ";
$start_date = $_POST['keyword_start_date_start'];
$end_date = $_POST['keyword_start_date_end'];
if ($start_date != '' || $end_date != ''){
$sql .= " HAVING ";
if ($start_date != '') $sql .= " access_date >= '$start_date' ";
if ($end_date != '') {
$sql = ($start_date == '')?$sql:($sql." AND ");
$sql .= " access_date <= '$end_date' ";
}
}
$result = Database::query($sql);
$table_result = new SortableTable();
$table_result->set_header(0, get_lang('User'), false);
$table_result->set_header(1, get_lang('Fullname'), false);
$table_result->set_header(2, get_lang('Fecha'), false);
$table_result->set_header(3, get_lang('curso'), false);
$table_result->set_header(4, get_lang('Herramienta'), false);
while ($row = Database::fetch_assoc($result)){
$row = array(0 =>$row['username'],1 =>$row['fullname'],2 => $row['access_date'],3 =>$row['curso'],4 =>get_lang($tools[$row['herramienta']]['name']));
$table_result->addRow($row);
}
$table_result->display();
Display::display_footer();
?>
}else{
show_form();
}
Display::display_footer();

@ -1,5 +1,12 @@
<?php
/* INIT SECTION */
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
/**
* INIT SECTION
*/
$language_file = array('messages','userInfo', 'admin');
$cidReset = true;
require_once '../config.php';

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Declaration of TicketManager class
* @package chamilo.plugin.ticket
*/
/**
* Class TicketManager
@ -22,10 +24,10 @@ class TicketManager
public static function get_all_tickets_categories()
{
$table_support_category = Database::get_main_table(
TABLE_SUPPORT_CATEGORY
TABLE_TICKET_CATEGORY
);
$table_support_project = Database::get_main_table(
TABLE_SUPPORT_PROJECT
TABLE_TICKET_PROJECT
);
$sql = "SELECT category.*, project.other_area , project.email
FROM " . $table_support_category . " category," . $table_support_project . " project
@ -39,9 +41,13 @@ class TicketManager
return $types;
}
/**
* Get all possible tickets statuses
* @return array
*/
public static function get_all_tickets_status()
{
$table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS);
$table_support_status = Database::get_main_table(TABLE_TICKET_STATUS);
$sql = "SELECT * FROM " . $table_support_status;
$result = Database::query($sql);
$types = array();
@ -51,6 +57,24 @@ class TicketManager
return $types;
}
/**
* Inserts a new ticket in the corresponding tables
* @param $category_id
* @param $course_id
* @param $project_id
* @param $other_area
* @param $email
* @param $subject
* @param $content
* @param string $personalEmail
* @param $file_attachments
* @param string $source
* @param string $priority
* @param string $status
* @param string $request_user
* @param int $assigned_user
* @return bool
*/
public static function insert_new_ticket(
$category_id,
$course_id,
@ -59,7 +83,7 @@ class TicketManager
$email,
$subject,
$content,
$personalemail = "",
$personalEmail = "",
$file_attachments,
$source = 'VRT',
$priority = 'NRM',
@ -67,10 +91,18 @@ class TicketManager
$request_user = '',
$assigned_user = 0
) {
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_category = Database::get_main_table(
TABLE_SUPPORT_CATEGORY
TABLE_TICKET_CATEGORY
);
$course_id = intval($course_id);
$category_id = intval($category_id);
$project_id = intval($project_id);
$subject = Database::escape_string($subject);
$content = Database::escape_string($content);
$personalEmail = Database::escape_string($personalEmail);
$status = Database::escape_string($status);
$now = api_get_utc_datetime();
$user_id = api_get_user_id();
if ($status == '') {
@ -83,7 +115,6 @@ class TicketManager
if ($request_user == '' && $source == 'VRT') {
$request_user = $user_id;
}
$course_id = intval($course_id);
$sql_insert_ticket = "INSERT INTO $table_support_tickets
(
project_id,
@ -105,7 +136,7 @@ class TicketManager
'$priority',
'$course_id',
'$request_user',
'$personalemail',
'$personalEmail',
'$status',
'" . $now . "',
$user_id,
@ -133,40 +164,30 @@ class TicketManager
$sql_update_total = "UPDATE $table_support_category
SET total_tickets = total_tickets +1 WHERE category_id = '$category_id';";
Database::query($sql_update_total);
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 = UserManager::get_user_info_by_id($request_user);
$mensaje_helpdesk = '<table>
$helpDeskMessage = '<table>
<tr>
<td width="100px"><b>Cliente:</b></td>
<td width="100px"><b>'.get_lang('User').'</b></td>
<td width="400px">' . $user['firstname']
. ' ' . $user['lastname'] . '</td>
</tr>
<tr>
<td width="100px"><b>Usuario:</b></td>
<td width="100px"><b>'.get_lang('Username').'</b></td>
<td width="400px">' . $user['username'] . '</td>
</tr>
<tr>
<td width="100px"><b>Fecha:</b></td>
<td width="400px">' . api_convert_and_format_date(
$now,
DATE_TIME_FORMAT_LONG
) . '</td>
<td width="100px"><b>'.get_lang('Date').'</b></td>
<td width="400px">' . api_convert_and_format_date($now, DATE_TIME_FORMAT_LONG) . '</td>
</tr>
<tr>
<td width="100px"><b>Asunto:</b></td>
<td width="100px"><b>'.get_lang('Topic').'</b></td>
<td width="400px">' . $subject . '</td>
</tr>
<tr>
<td width="100px"><b>Descripci&oacute;n:</b></td>
<td width="100px"><b>'.get_lang('Description').'</b></td>
<td width="400px">' . $content . '</td>
</tr>
</table>';
@ -174,18 +195,18 @@ class TicketManager
'Soporte virtual',
$email,
"[SOPORTE] Incidente Reenviado de Soporte Virtual",
$mensaje_helpdesk,
$helpDeskMessage,
$user['firstname'] . ' ' . $user['lastname'],
$personalemail,
$personalEmail,
array('cc' => 'soportevirtual@usil.edu.pe'),
$data_files
);
$mensaje_alumno = '<p>Su consulta fue reenviada al area responsable : <a href="mailto:' . $email . '">' . $email . '</a></p>';
$mensaje_alumno .= '<p>La respuesta a su consulta ser&aacute; enviada al correo : <a href="#">' . $personalemail . '</a></p>';
$studentMessage = '<p>Su consulta fue reenviada al area responsable : <a href="mailto:' . $email . '">' . $email . '</a></p>';
$studentMessage .= '<p>La respuesta a su consulta ser&aacute; enviada al correo : <a href="#">' . $personalEmail . '</a></p>';
self::insert_message(
$ticket_id,
"Mensaje Reenviado",
$mensaje_alumno,
get_lang('MessageResent'),
$studentMessage,
null,
1
);
@ -202,15 +223,21 @@ class TicketManager
}
}
/**
* @param $ticket_id
* @param $user_id
*/
public static function assign_ticket_user($ticket_id, $user_id)
{
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_assigned_log = Database::get_main_table(
TABLE_SUPPORT_ASSIGNED_LOG
);
$ticket_id = intval($ticket_id);
$user_id = intval($user_id);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_assigned_log = Database::get_main_table(TABLE_TICKET_ASSIGNED_LOG);
$now = api_get_utc_datetime();
$sql_update = "UPDATE $table_support_tickets
SET assigned_last_user = '$user_id' WHERE ticket_id = '$ticket_id' ";
SET assigned_last_user = '$user_id'
WHERE ticket_id = '$ticket_id'";
Database::query($sql_update);
if (Database::affected_rows() > 0) {
$insert_id = api_get_user_id();
@ -226,26 +253,37 @@ class TicketManager
'$insert_id'
);";
Database::query($sql);
if ($insert_id != $user_id) {
$info = api_get_user_info($user_id);
$mensaje = '<p>Estimado(a):</p><p>' . $info['firstname'] . " " . $info['lastname'] . "</p>
$sender = api_get_user_info($insert_id);
$message = '<p>Estimado(a):</p><p>' . $info['firstname'] . " " . $info['lastname'] . "</p>
<p>Te asignaron el ticket $ticket_id " . '<a href="' . api_get_path(
WEB_PLUGIN_PATH
) . PLUGIN_NAME . '/s/ticket_details.php?ticket_id=' . $ticket_id . '">Ticket</a></p>
<p>Centro de Educaci&oacute;n Virtual</p>';
) . 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 ",
$mensaje,
'Plataforma Virtual',
'plataformavirtual@usil.edu.pe',
array('cc' => 'plataformavirtual@usil.edu.pe')
$message,
null, // sender name
null, // sender e-mail
array('cc' => $sender['email']) // should be support e-mail (platform admin) here
);
}
}
}
/**
* @param $ticket_id
* @param $subject
* @param $content
* @param $file_attachments
* @param $user_id
* @param string $status
* @param bool $sendConfirmation
* @return bool
*/
public static function insert_message(
$ticket_id,
$subject,
@ -253,37 +291,62 @@ class TicketManager
$file_attachments,
$user_id,
$status = 'NOL',
$envioconfirmacion = false
) {
$sendConfirmation = false
)
{
global $data_files;
$ticket_id = intval($ticket_id);
$subject = Database::escape_string($subject);
$content = Database::escape_string($content);
$user_id = intval($user_id);
$status = Database::escape_string($status);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
);
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_message_attachments = Database::get_main_table(
TABLE_SUPPORT_MESSAGE_ATTACHMENTS
TABLE_TICKET_MESSAGE
);
if ($envioconfirmacion) {
$formulario = '<form action="ticket_details.php?ticket_id=' . $ticket_id . '" id="confirmticket" method="POST" >
<p>Esta respuesta le result&oacute; satisfactoria</p>
<input id="respuestasi" type="submit" value="si" name="respuesta" />
<input id="respuestano" type="submit" value="no" name="respuesta" />
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_message_attachments = Database::get_main_table(TABLE_TICKET_MESSAGE_ATTACHMENTS);
if ($sendConfirmation) {
$form = '<form action="ticket_details.php?ticket_id=' . $ticket_id . '" id="confirmticket" method="POST" >
<p>'.get_lang('TicketWasThisAnswerSatisfying').'</p>
<input id="responseyes" type="submit" value="'.get_lang('Yes').'" name="response" />
<input id="responseno" type="submit" value="'.get_lang('No').'" name="response" />
</form>';
$content .= $formulario;
$content .= $form;
Database::query(
"UPDATE $table_support_tickets SET status_id='XCF' WHERE ticket_id = '$ticket_id'"
);
}
$sql_message_id = "SELECT COUNT(*) as total_messages FROM $table_support_messages
$sql_message_id = "SELECT COUNT(*) as total_messages
FROM $table_support_messages
WHERE ticket_id ='$ticket_id'";
$result = Database::query($sql_message_id);
$obj = Database::fetch_object($result);
$message_id = $obj->total_messages + 1;
$now = api_get_utc_datetime();
$sql_insert_message = "INSERT INTO $table_support_messages (
ticket_id,message_id,subject, message,ip_address,sys_insert_user_id,sys_insert_datetime,sys_lastedit_user_id,sys_lastedit_datetime,status
ticket_id,
message_id,
subject,
message,
ip_address,
sys_insert_user_id,
sys_insert_datetime,
sys_lastedit_user_id,
sys_lastedit_datetime,
status
) VALUES (
'$ticket_id','$message_id','$subject','$content','" . Database::escape_string($_SERVER['REMOTE_ADDR']) . "','$user_id','" . $now . "','$user_id','" . $now . "','$status'
'$ticket_id',
'$message_id',
'$subject',
'$content',
'" . Database::escape_string($_SERVER['REMOTE_ADDR']) . "',
'$user_id',
'" . $now . "',
'$user_id',
'" . $now . "',
'$status'
)";
Database::query($sql_insert_message);
$sql_update_total_message = "UPDATE $table_support_tickets
@ -295,11 +358,13 @@ class TicketManager
WHERE ticket_id ='$ticket_id'
) WHERE ticket_id ='$ticket_id' ";
Database::query($sql_update_total_message);
$sql_message_att_id = "SELECT COUNT(*) as total_attach
FROM $table_support_message_attachments
WHERE ticket_id ='$ticket_id' AND message_id = '$message_id'";
$result = Database::query($sql_message_att_id);
$obj = Database::fetch_object($result);
$message_attch_id = $obj->total_attach + 1;
if (is_array($file_attachments)) {
foreach ($file_attachments as $file_attach) {
@ -318,24 +383,34 @@ class TicketManager
}
}
}
return true;
}
/**
* @param $file_attach
* @param $ticket_id
* @param $message_id
* @param $message_attch_id
* @return array
*/
public static function save_message_attachment_file(
$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']
);
$file_name = $file_attach['name'];
$table_support_message_attachments = Database::get_main_table(
TABLE_SUPPORT_MESSAGE_ATTACHMENTS
TABLE_TICKET_MESSAGE_ATTACHMENTS
);
if (!filter_extension($new_file_name)) {
Display :: display_error_message(
@ -343,8 +418,8 @@ class TicketManager
);
} else {
$new_file_name = uniqid('');
$path_attachment = api_get_path(SYS_PATH);
$path_message_attach = $path_attachment . 'tck_messageattch/';
$path_attachment = api_get_path(SYS_ARCHIVE_PATH);
$path_message_attach = $path_attachment . 'plugin_ticket_messageattch/';
if (!file_exists($path_message_attach)) {
@mkdir(
$path_message_attach,
@ -389,6 +464,14 @@ class TicketManager
}
}
/**
* @param $from
* @param $number_of_items
* @param $column
* @param $direction
* @param null $user_id
* @return array
*/
public static function get_tickets_by_user_id(
$from,
$number_of_items,
@ -397,15 +480,15 @@ class TicketManager
$user_id = null
) {
$table_support_category = Database::get_main_table(
TABLE_SUPPORT_CATEGORY
TABLE_TICKET_CATEGORY
);
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_priority = Database::get_main_table(
TABLE_SUPPORT_PRIORITY
TABLE_TICKET_PRIORITY
);
$table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS);
$table_support_status = Database::get_main_table(TABLE_TICKET_STATUS);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$table_main_user = Database::get_main_table(TABLE_MAIN_USER);
$table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
@ -597,9 +680,9 @@ class TicketManager
) . 'main/admin/user_information.php?user_id=' . $row['responsable']['user_id'] . '">' . $row['responsable']['firstname'] . ' ' . $row['responsable']['lastname'] . '</a>';
} else {
if ($row['status_id'] != 'REE') {
$row['responsable'] = '<span style="color:#ff0000;">Por Asignar</span>';
$row['responsable'] = '<span style="color:#ff0000;">'.get_lang('ToBeAssigned').'</span>';
} else {
$row['responsable'] = '<span style="color:#00ff00;">REENVIADO</span>';
$row['responsable'] = '<span style="color:#00ff00;">'.get_lang('MessageResent').'</span>';
}
}
switch ($row['source']) {
@ -624,7 +707,7 @@ class TicketManager
get_lang('Info')
) . '</a>&nbsp;&nbsp;';
if ($row['priority_id'] == 'ALT' && $row['status_id'] != 'CLS') {
$actions .= '<img src="../../../main/img/exclamation.png" border="0" />';
$actions .= '<img src="'.api_get_path(WEB_CODE_PATH).'img/exclamation.png" border="0" />';
}
$row['col0'] = Display::return_icon(
$img_source,
@ -668,7 +751,7 @@ class TicketManager
$actions .= '<a href="myticket.php?ticket_id=' . $row['ticket_id'] . '&amp;action=alert"><img src="../../../main/img/exclamation.png" border="0" /></a>';
}
if ($row['priority_id'] == 'ALT') {
$actions .= '<img src="../../../main/img/admin_star.png" border="0" />';
$actions .= '<img src="'.api_get_path(WEB_CODE_PATH).'img/admin_star.png" border="0" />';
}
$ticket = array(
$row['col0'],
@ -694,21 +777,27 @@ class TicketManager
}
$tickets[] = $ticket;
}
return $tickets;
}
/**
* @param null $user_id
* @return mixed
*/
public static function get_total_tickets_by_user_id($user_id = null)
{
$user_id = intval($user_id);
$table_support_category = Database::get_main_table(
TABLE_SUPPORT_CATEGORY
TABLE_TICKET_CATEGORY
);
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_priority = Database::get_main_table(
TABLE_SUPPORT_PRIORITY
TABLE_TICKET_PRIORITY
);
$table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS);
$table_support_status = Database::get_main_table(TABLE_TICKET_STATUS);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$table_main_user = Database::get_main_table(TABLE_MAIN_USER);
$table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
@ -809,24 +898,30 @@ class TicketManager
}
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total;
}
/**
* @param $ticket_id
* @param $user_id
* @return array
*/
public static function get_ticket_detail_by_id($ticket_id, $user_id)
{
$table_support_category = Database::get_main_table(
TABLE_SUPPORT_CATEGORY
TABLE_TICKET_CATEGORY
);
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_priority = Database::get_main_table(
TABLE_SUPPORT_PRIORITY
TABLE_TICKET_PRIORITY
);
$table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS);
$table_support_status = Database::get_main_table(TABLE_TICKET_STATUS);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$table_support_message_attachments = Database::get_main_table(
TABLE_SUPPORT_MESSAGE_ATTACHMENTS
TABLE_TICKET_MESSAGE_ATTACHMENTS
);
$sql = "SELECT ticket.* ,cat.name , status.name as status, priority.priority FROM " . $table_support_tickets . " ticket, " . $table_support_category . " cat ," . $table_support_priority . " priority , " . $table_support_status . " status
@ -891,7 +986,7 @@ class TicketManager
$message['user_created'] = '<a href="' . api_get_path(
WEB_PATH
) . 'main/admin/user_information.php?user_id=' . $row['user_id'] . '">' . $row['firstname'] . ' ' . $row['lastname'] . '</a>';
$sql_atachment = "SELECT * FROM " . TABLE_SUPPORT_MESSAGE_ATTACHMENTS . " WHERE message_id = " . $row['message_id'] . " AND ticket_id= '$ticket_id' ";
$sql_atachment = "SELECT * FROM " . TABLE_TICKET_MESSAGE_ATTACHMENTS . " WHERE message_id = " . $row['message_id'] . " AND ticket_id= '$ticket_id' ";
$result_attach = Database::query($sql_atachment);
while ($row2 = Database::fetch_assoc($result_attach)) {
$archiveURL = $archiveURL = api_get_path(
@ -903,13 +998,19 @@ class TicketManager
$ticket['messages'][] = $message;
}
}
return $ticket;
}
/**
* @param $ticket_id
* @param $user_id
* @return bool
*/
public static function update_message_status($ticket_id, $user_id)
{
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$now = api_get_utc_datetime();
$sql = "UPDATE " . $table_support_messages . " SET status = 'LEI' , sys_lastedit_user_id ='" . api_get_user_id(
@ -924,7 +1025,7 @@ class TicketManager
Database::query($sql);
if (Database::affected_rows() > 0) {
Database::query(
"UPDATE " . Database::get_main_table(TABLE_SUPPORT_TICKET) . " SET status_id = 'PND' WHERE ticket_id ='$ticket_id' AND status_id = 'NAT'"
"UPDATE " . Database::get_main_table(TABLE_TICKET_TICKET) . " SET status_id = 'PND' WHERE ticket_id ='$ticket_id' AND status_id = 'NAT'"
);
return true;
} else {
@ -932,14 +1033,20 @@ class TicketManager
}
}
/**
* @param $status_id
* @param $ticket_id
* @param $user_id
* @return bool
*/
public static function update_ticket_status(
$status_id,
$ticket_id,
$user_id
) {
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$now = api_get_utc_datetime();
$sql = "UPDATE " . $table_support_tickets . " SET status_id = '$status_id' , sys_lastedit_user_id ='$user_id' ,sys_lastedit_datetime ='" . $now . "' WHERE ticket_id ='$ticket_id'";
@ -951,11 +1058,14 @@ class TicketManager
}
}
/**
* @return mixed
*/
public static function get_number_of_messages()
{
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$table_main_user = Database::get_main_table(TABLE_MAIN_USER);
$table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN);
@ -974,37 +1084,52 @@ class TicketManager
}
/**
* @param $ticket_id
* @param $user_id
*/
public static function send_alert($ticket_id, $user_id)
{
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$now = api_get_utc_datetime();
$sql = "UPDATE " . $table_support_tickets . " SET priority_id = 'ALT', sys_lastedit_user_id ='$user_id' ,sys_lastedit_datetime ='" . $now . "' WHERE ticket_id = '$ticket_id'";
Database::query($sql);
}
/**
* @param $ticket_id
* @param $user_id
*/
public static function close_ticket($ticket_id, $user_id)
{
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$now = api_get_utc_datetime();
$sql = "UPDATE " . $table_support_tickets . " SET status_id = 'CLS' , sys_lastedit_user_id ='$user_id' ,sys_lastedit_datetime ='" . $now . "' ,end_date ='" . $now . "' WHERE ticket_id ='$ticket_id'";
Database::query($sql);
}
/**
*
*/
public static function close_old_tickets()
{
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$now = api_get_utc_datetime();
$sql = "UPDATE " . $table_support_tickets . " SET status_id = 'CLS' , sys_lastedit_user_id ='" . api_get_user_id(
) . "' ,sys_lastedit_datetime ='" . $now . "',end_date ='" . $now . "' WHERE DATEDIFF('$now',sys_lastedit_datetime) > 7 AND status_id != 'CLS' AND status_id != 'NAT' AND status_id != 'REE'";
Database::query($sql);
}
/**
* @param $ticket_id
* @return array
*/
public static function get_assign_log($ticket_id)
{
$table_support_assigned_log = Database::get_main_table(
TABLE_SUPPORT_ASSIGNED_LOG
TABLE_TICKET_ASSIGNED_LOG
);
$sql = "SELECT log.* FROM " . TABLE_SUPPORT_ASSIGNED_LOG . " log WHERE log.ticket_id = '$ticket_id' ORDER BY log.assigned_date";
$sql = "SELECT log.* FROM " . TABLE_TICKET_ASSIGNED_LOG . " log WHERE log.ticket_id = '$ticket_id' ORDER BY log.assigned_date";
$result = Database::query($sql);
$history = array();
while ($row = Database::fetch_assoc($result)) {
@ -1032,6 +1157,14 @@ class TicketManager
return $history;
}
/**
* @param $from
* @param $number_of_items
* @param $column
* @param $direction
* @param null $user_id
* @return array
*/
public static function export_tickets_by_user_id(
$from,
$number_of_items,
@ -1040,15 +1173,15 @@ class TicketManager
$user_id = null
) {
$table_support_category = Database::get_main_table(
TABLE_SUPPORT_CATEGORY
TABLE_TICKET_CATEGORY
);
$table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET);
$table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET);
$table_support_priority = Database::get_main_table(
TABLE_SUPPORT_PRIORITY
TABLE_TICKET_PRIORITY
);
$table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS);
$table_support_status = Database::get_main_table(TABLE_TICKET_STATUS);
$table_support_messages = Database::get_main_table(
TABLE_SUPPORT_MESSAGE
TABLE_TICKET_MESSAGE
);
$table_main_user = Database::get_main_table(TABLE_MAIN_USER);
if (is_null($direction)) {
@ -1184,8 +1317,7 @@ class TicketManager
$row['responsable'] = utf8_decode($row['responsable']);
$tickets[] = $row;
}
return $tickets;
}
}
?>

@ -1,4 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
/**
*
*/
$language_file = array ('registration');
require_once '../config.php';
$plugin = TicketPlugin::create();

@ -1,4 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
/**
*
*/
$language_file= array('messages','userInfo', 'admin');
$cidReset = true;
require_once '../config.php';
@ -303,7 +311,7 @@ if(!isset($_POST['compose'])){
$ticket_id = $_POST['ticket_id'];
$content = $_POST['content'];
$subject = $_POST['subject'];
$mensajeconfirmacion = isset($_POST['confirmacion'])?true:false ;
$mensajeconfirmacion = isset($_POST['confirmation'])?true:false ;
$file_attachments = $_FILES;
$user_id = api_get_user_id();
TicketManager::insert_message($ticket_id, $subject, $content, $file_attachments, $user_id,'NOL',$mensajeconfirmacion);
@ -348,7 +356,7 @@ function show_form_send_message(){
</div>';
echo '<div class="row">
<div class="label"></div>
<div class="formw"> <button class="save" name="compose" type="submit">Enviar mensaje</button>'.($isAdmin?'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="confirmacion"/>Solicitar confirmaci&oacute;n':"").
<div class="formw"> <button class="save" name="compose" type="submit">Enviar mensaje</button>'.($isAdmin?'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="confirmation"/>Solicitar confirmaci&oacute;n':"").
'</div>
</div>';
echo '</form>';

@ -1,4 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
/**
*
* @package chamilo.plugin.ticket
*/
/**
*
*/
require_once '../config.php';
$plugin = TicketPlugin::create();
@ -11,7 +19,7 @@ $(document).ready(function (){
var url = this.href;
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $("<div id=\"dialog\" style=\"display:hidden\"></div>").appendTo("body");
dialog = $("'.'<div id="dialog" style="display:hidden"></div>'.'").appendTo("body");
}
// load remote content
@ -49,12 +57,12 @@ function save() {
$.ajax({
contentType: "application/x-www-form-urlencoded",
beforeSend: function(objeto) {
$("div#confirmacion").html("<img src=\'../../../main/inc/lib/javascript/indicator.gif\' />"); },
$("div#confirmation").html("<img src=\'../../../main/inc/lib/javascript/indicator.gif\' />"); },
type: "POST",
url: "update_report.php",
data: "work_id="+work_id+"&forum_id="+forum_id+"&rs_id="+rs_id,
success: function(datos) {
$("div#confirmacion").html(datos);
$("div#confirmation").html(datos);
location.reload();
}
});

@ -1,5 +1,15 @@
<?php
function inicializarReporte($course_code){
/* For licensing terms, see /license.txt */
/**
* Helper library for weekly reports
* @package chamilo.plugin.ticket
*/
/**
* @param $course_code
* @return array|bool
*/
function inicializarReporte($course_code)
{
$course_info = api_get_course_info($course_code);
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$table_students_report = Database::get_main_table('rp_students_report');
@ -8,37 +18,37 @@ function inicializarReporte($course_code){
$table_post = Database::get_course_table(TABLE_FORUM_POST, $course_info['dbName']);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
$res = Database::query("SELECT COUNT(*) as cant FROM $table_reporte_semanas WHERE course_code = '".$course_code."'");
$sql_semanas = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'";
$res_semanas = Database::query($sql_semanas);
$semanas = Database::fetch_object($res_semanas);
$sqlWeeks = "SELECT semanas FROM $table_semanas_curso WHERE course_code = '$course_code'";
$resWeeks = Database::query($sqlWeeks);
$weeks = Database::fetch_object($resWeeks);
$obj = Database::fetch_object($res);
$numero_semanas = (!isset($_POST['numerosemanas']))?(($semanas->semanas==0)?7:$semanas->semanas):$_POST['numerosemanas'];
Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$numero_semanas')");
if(intval($obj->cant) != $numero_semanas){
$weeksCount = (!isset($_POST['numerosemanas']))?(($weeks->semanas==0)?7:$weeks->semanas):$_POST['numerosemanas'];
Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$weeksCount')");
if (intval($obj->cant) != $weeksCount) {
if(intval($obj->cant) > $numero_semanas){
$sql ="DELETE FROM $table_reporte_semanas WHERE week_id > $numero_semanas AND course_code = '$course_code'";
Database::query("DELETE FROM $table_reporte_semanas WHERE week_id > $numero_semanas AND course_code = '$course_code'");
}else{
for ($i = $obj->cant+1 ; $i <= $numero_semanas ; $i++){
if(!Database::query("INSERT INTO $table_reporte_semanas (week_id,course_code,forum_id,work_id,quiz_id,pc_id)
VALUES ('$i','$course_code','0','0','0','0' )")){
if (intval($obj->cant) > $weeksCount) {
$sql ="DELETE FROM $table_reporte_semanas WHERE week_id > $weeksCount AND course_code = '$course_code'";
Database::query("DELETE FROM $table_reporte_semanas WHERE week_id > $weeksCount AND course_code = '$course_code'");
} else {
for ($i = $obj->cant+1 ; $i <= $weeksCount ; $i++){
if (!Database::query("INSERT INTO $table_reporte_semanas (week_id, course_code, forum_id, work_id, quiz_id, pc_id)
VALUES ($i, '$course_code', '0', '0', '0', '0' )")) {
return false;
}
}
}
}
$sql = "REPLACE INTO $table_students_report (user_id,week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)
$sql = "REPLACE INTO $table_students_report (user_id, week_report_id, work_ok , thread_ok , quiz_ok , pc_ok)
SELECT cu.user_id, rs.id, 0, 0, 0, 0
FROM $table_course_rel_user cu
LEFT JOIN $table_reporte_semanas rs ON cu.course_code = rs.course_code
WHERE cu.status = '5' AND rs.course_code = '$course_code'
WHERE cu.status = 5 AND rs.course_code = '$course_code'
ORDER BY cu.user_id, rs.id";
if(!Database::query($sql)){
if (!Database::query($sql)) {
return false;
}else{
$pagina = (!isset($_GET['page']))?1:$_GET['page'];
} else {
$page = (!isset($_GET['page']))?1:$_GET['page'];
Database::query("UPDATE $table_students_report sr SET sr.work_ok = 1
WHERE CONCAT (sr.user_id,',',sr.week_report_id)
IN (SELECT DISTINCT CONCAT(w.user_id,',',rs.id)
@ -47,144 +57,162 @@ function inicializarReporte($course_code){
WHERE CONCAT (sr.user_id,',',sr.week_report_id)
IN (SELECT DISTINCT CONCAT(f.poster_id,',',rs.id)
FROM $table_post f JOIN $table_reporte_semanas rs ON f.thread_id = rs.forum_id)");
return mostrarResultados($course_info,$numero_semanas,$pagina);
return mostrarResultados($course_info,$weeksCount,$page);
}
}
function mostrarResultados($course_info,$numero_semanas, $pagina){
$course_code = $course_info['code'];
$table_reporte_semanas = Database::get_main_table('rp_reporte_semanas');
$table_students_report = Database::get_main_table('rp_students_report');
$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER );
$table_thread = Database::get_course_table(TABLE_FORUM_THREAD, $course_info['dbName']);
$table_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $course_info['dbName']);
$resultados = array();
$table_export = array();
$sql_encabezado = "SELECT rs.id as id,rs.week_id, w.title AS work_title, t.thread_title ,'EVALUACION' as eval_title ,'QUIZ' as pc_title
FROM $table_reporte_semanas rs
LEFT JOIN $table_thread t ON t.thread_id = rs.forum_id
LEFT JOIN $table_work w ON w.id = rs.work_id
WHERE rs.course_code = '$course_code'
ORDER BY rs.week_id";
$result_encabezado = Database::query($sql_encabezado) ;
$ids = array();
$fila = '<tr>
<th ></th>';
$fila_export_encabezado = array(null,null);
$fila_export_encabezado2 = array(null,ull);
while ($rowe = Database::fetch_assoc($result_encabezado)){
$fila_export_encabezado[] = utf8_decode('Tarea'.$rowe['week_id']);
$fila_export_encabezado[] = utf8_decode('Foro'.$rowe['week_id']);
//$fila_export_encabezado[] = utf8_decode('Eval'.$rowe['week_id']);
//$fila_export_encabezado[] = utf8_decode('PC'.$rowe['week_id']);
$fila_export_encabezado2[] = utf8_decode($rowe['work_title']);
$fila_export_encabezado2[] = utf8_decode($rowe['thread_title']);
//$fila_export_encabezado2[] = utf8_decode($rowe['eval_title']);
//$fila_export_encabezado2[] = utf8_decode($rowe['pc_title']);
$fila_export = array('Tarea'.$rowe['week_id'],'Foro'.$rowe['week_id'],'Eval'.$rowe['week_id'],'PC'.$rowe['week_id']);
if ($rowe['week_id'] > (($pagina-1)*7) && $rowe['week_id'] <= (7*$pagina)){
$ids[$rowe['week_id']] = $rowe['id'];
$fila.='<th>
<a href="#" onClick="mostrarContenido('."'tarea".$rowe['week_id']."'".');">Tarea'.$rowe['week_id'].'
<div class="blackboard_hide" id="tarea'.$rowe['week_id'].'">'.$rowe['work_title'].'</div>
</a></th>';
$fila.= '<th>
<a href="#" onClick="mostrarContenido('."'foro".$rowe['week_id']."'".');">Foro'.$rowe['week_id'].'
<div class="blackboard_hide" id="foro'.$rowe['week_id'].'">'.$rowe['thread_title'].'</div>
</a>
</th>';
/*$fila.= '<th>
<a href="#" onClick="mostrarContenido('."'eval".$rowe['week_id']."'".');">Eval'.$rowe['week_id'].'
<div class="blackboard_hide" id="eval'.$rowe['week_id'].'">'.$rowe['eval_title'].'</div>
</a>
</th>';
$fila.= '<th>
<a href="#" onClick="mostrarContenido('."'pc".$rowe['week_id']."'".');">PC'.$rowe['week_id'].'
<div class="blackboard_hide" id="pc'.$rowe['week_id'].'">'.$rowe['pc_title'].'</div>
</a>
</th>';*/
}
}
$table_export[] = $fila_export_encabezado;
$table_export[] = $fila_export_encabezado2;
$fila.= '</tr>';
$html = '<form action="tutor.php" name="semanas" id="semanas" method="POST">
<div class="row">
Seleccione cantidad de semanas:
<select name="numerosemanas" id="numerosemanas" onChange="submit();">
<option value="7" '.(($numero_semanas ==7)?'selected="selected"':"").'>7 Semanas</option>
<option value="14" '.(($numero_semanas ==14)?'selected="selected"':"").'>14 Semanas</option>
</select>';
if($numero_semanas == 14) {
$html .= '<span style="float:right;"><a href="tutor.php?page='.(($pagina == 1)?2:1).'">'.(($pagina == 1)?"Siguiente":"Anterior").'</a></span>';
}
$html .= '<span style="float:right;"><a href="'.api_get_self().'?action=export'.$get_parameter.$get_parameter2.'">'.Display::return_icon('import_excel.png',get_lang('Export'),'','32').'</a></span>';
$html .= '</form>';
$html .= '<table class="reportes">';
$html .= '<tr>
<th ></th>';
for ($i=(7*$pagina-6); $i <= $pagina*7;$i++){
$html .= '<th colspan="2">Semana '.$i.'<a href="assign_tickets.php?id='.$ids[$i].'" class="ajax">'.Display::return_icon('edit.png', get_lang('Edit'), array('width'=>'16','height'=>'16'), 22).'</a></th>';
}
$html .= '</tr>';
$html .= $fila;
$sql = "SELECT u.username , u.user_id , CONCAT(u.lastname,' ', u.firstname ) as fullname , rs.week_id , sr.work_ok ,sr.thread_ok , sr.quiz_ok , sr.pc_ok , rs.course_code
FROM $table_students_report sr
JOIN $table_reporte_semanas rs ON sr.week_report_id = rs.id
JOIN $table_user u ON u.user_id = sr.user_id
WHERE rs.course_code = '$course_code'
ORDER BY u.lastname , u.username , rs.week_id
";
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)){
$resultadose[$row['username']][$row['week_id']] = $row;
if ($row['week_id'] > (($pagina-1)*7) && $row['week_id'] <= (7*$pagina) ){
$resultados[$row['username']][$row['week_id']] = $row;
if(count($resultados[$row['username']]) == 7 ){
$html.= mostrarResultadoAlumno($resultados[$row['username']],$pagina);
}
}
if(count($resultadose[$row['username']]) == $numero_semanas ){
$table_export[] = mostrarResultadoAlumnoExportar($resultadose[$row['username']],$numero_semanas);
}
}
$html .= '
</table>';
return array('mostrar'=>$html,'exportar'=>$table_export);
/**
* @param $courseInfo
* @param $weeksCount
* @param $page
* @return array
*/
function mostrarResultados($courseInfo,$weeksCount, $page)
{
$course_code = $courseInfo['code'];
$tableWeeklyReport = Database::get_main_table('rp_reporte_semanas');
$tableStudentsReport = Database::get_main_table('rp_students_report');
//$table_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$tableUser = Database::get_main_table(TABLE_MAIN_USER );
$tableThread = Database::get_course_table(TABLE_FORUM_THREAD, $courseInfo['dbName']);
$tableWork = Database::get_course_table(TABLE_STUDENT_PUBLICATION, $courseInfo['dbName']);
$results = array();
$tableExport = array();
$sqlHeader = "SELECT rs.id as id,rs.week_id, w.title AS work_title, t.thread_title ,'EVALUATION' as eval_title ,'QUIZ' as pc_title
FROM $tableWeeklyReport rs
LEFT JOIN $tableThread t ON t.thread_id = rs.forum_id
LEFT JOIN $tableWork w ON w.id = rs.work_id
WHERE rs.course_code = '$course_code'
ORDER BY rs.week_id";
$resultHeader = Database::query($sqlHeader) ;
$ids = array();
$line = '<tr>
<th ></th>';
$lineHeaderExport = array(null,null);
$lineHeaderExport2 = array(null,ull);
while ($rowe = Database::fetch_assoc($resultHeader)){
$lineHeaderExport[] = utf8_decode('Work'.$rowe['week_id']);
$lineHeaderExport[] = utf8_decode('Forum'.$rowe['week_id']);
//$fila_export_encabezado[] = utf8_decode('Eval'.$rowe['week_id']);
//$fila_export_encabezado[] = utf8_decode('PC'.$rowe['week_id']);
$lineHeaderExport2[] = utf8_decode($rowe['work_title']);
$lineHeaderExport2[] = utf8_decode($rowe['thread_title']);
//$fila_export_encabezado2[] = utf8_decode($rowe['eval_title']);
//$fila_export_encabezado2[] = utf8_decode($rowe['pc_title']);
$fila_export = array('Work'.$rowe['week_id'],'Forum'.$rowe['week_id'],'Eval'.$rowe['week_id'],'PC'.$rowe['week_id']);
if ($rowe['week_id'] > (($page-1)*7) && $rowe['week_id'] <= (7*$page)){
$ids[$rowe['week_id']] = $rowe['id'];
$line.='<th>
<a href="#" onClick="mostrarContenido('."'tarea".$rowe['week_id']."'".');">Work'.$rowe['week_id'].'
<div class="blackboard_hide" id="tarea'.$rowe['week_id'].'">'.$rowe['work_title'].'</div>
</a></th>';
$line.= '<th>
<a href="#" onClick="mostrarContenido('."'foro".$rowe['week_id']."'".');">Forum'.$rowe['week_id'].'
<div class="blackboard_hide" id="foro'.$rowe['week_id'].'">'.$rowe['thread_title'].'</div>
</a>
</th>';
/*$fila.= '<th>
<a href="#" onClick="mostrarContenido('."'eval".$rowe['week_id']."'".');">Eval'.$rowe['week_id'].'
<div class="blackboard_hide" id="eval'.$rowe['week_id'].'">'.$rowe['eval_title'].'</div>
</a>
</th>';
$fila.= '<th>
<a href="#" onClick="mostrarContenido('."'pc".$rowe['week_id']."'".');">PC'.$rowe['week_id'].'
<div class="blackboard_hide" id="pc'.$rowe['week_id'].'">'.$rowe['pc_title'].'</div>
</a>
</th>';*/
}
}
$tableExport[] = $lineHeaderExport;
$tableExport[] = $lineHeaderExport2;
$line.= '</tr>';
$html = '<form action="tutor.php" name="semanas" id="semanas" method="POST">
<div class="row">
'.get_lang('SelectWeeksSpan').'
<select name="numerosemanas" id="numerosemanas" onChange="submit();">
<option value="7" '.(($weeksCount ==7)?'selected="selected"':"").'>7 weeks</option>
<option value="14" '.(($weeksCount ==14)?'selected="selected"':"").'>14 weeks</option>
</select>';
if ($weeksCount == 14) {
$html .= '<span style="float:right;"><a href="tutor.php?page='.(($page == 1)?2:1).'">'.(($page == 1)?"Siguiente":"Anterior").'</a></span>';
}
$html .= '<span style="float:right;"><a href="'.api_get_self().'?action=export'.$get_parameter.$get_parameter2.'">'.Display::return_icon('import_excel.png',get_lang('Export'),'','32').'</a></span>';
$html .= '</form>';
$html .= '<table class="reportes">';
$html .= '<tr>
<th ></th>';
for ($i=(7*$page-6); $i <= $page*7;$i++) {
$html .= '<th colspan="2">Semana '.$i.'<a href="assign_tickets.php?id='.$ids[$i].'" class="ajax">'.Display::return_icon('edit.png', get_lang('Edit'), array('width'=>'16','height'=>'16'), 22).'</a></th>';
}
$html .= '</tr>';
$html .= $line;
$sql = "SELECT u.username , u.user_id , CONCAT(u.lastname,' ', u.firstname ) as fullname , rs.week_id , sr.work_ok ,sr.thread_ok , sr.quiz_ok , sr.pc_ok , rs.course_code
FROM $tableStudentsReport sr
JOIN $tableWeeklyReport rs ON sr.week_report_id = rs.id
JOIN $tableUser u ON u.user_id = sr.user_id
WHERE rs.course_code = '$course_code'
ORDER BY u.lastname , u.username , rs.week_id
";
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
$resultadose[$row['username']][$row['week_id']] = $row;
if ($row['week_id'] > (($page-1)*7) && $row['week_id'] <= (7*$page) ) {
$results[$row['username']][$row['week_id']] = $row;
if (count($results[$row['username']]) == 7 ) {
$html.= mostrarResultadoAlumno($results[$row['username']],$page);
}
}
if (count($resultadose[$row['username']]) == $weeksCount ) {
$tableExport[] = mostrarResultadoAlumnoExportar($resultadose[$row['username']],$weeksCount);
}
}
$html .= '
</table>';
return array('mostrar'=>$html,'exportar'=>$tableExport);
}
function mostrarResultadoAlumno($datos,$pagina){
$inicio = (7*$pagina-6);
$fila = '<tr>';
$fila.= '<td><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&uInfo='.$datos[$inicio]['user_id'].'">'.$datos[$inicio]['username'].'</a></td>';
foreach ($datos as $dato){
$fila.= '<td align="center">'.(($dato['work_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
$fila.= '<td align="center">'.(($dato['thread_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
//$fila.= '<td>'.(($dato['quiz_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
//$fila.= '<td>'.(($dato['pc_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
}
$fila.= '</tr>';
return $fila;
/**
* @param $datos
* @param $pagina
* @return string
*/
function mostrarResultadoAlumno($datos,$pagina)
{
$inicio = (7*$pagina-6);
$fila = '<tr>';
$fila.= '<td><a href="'.api_get_path(WEB_CODE_PATH).'user/userInfo.php?'.api_get_cidreq().'&uInfo='.$datos[$inicio]['user_id'].'">'.$datos[$inicio]['username'].'</a></td>';
foreach ($datos as $dato){
$fila.= '<td align="center">'.(($dato['work_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
$fila.= '<td align="center">'.(($dato['thread_ok']==1)?Display::return_icon('check.png'):Display::return_icon('aspa.png')).'</td>';
}
$fila.= '</tr>';
return $fila;
}
function mostrarResultadoAlumnoExportar($datos ,$numero_semanas){
$fila = array();
$fila[] = utf8_decode($datos[1]['username']);
$fila[]= utf8_decode($datos[1]['fullname']);
foreach ($datos as $dato){
//if ($datos['week_id'] < $numero_semanas){
$fila[]= ($dato['work_ok']==1)?"SI":"NO";
$fila[]= ($dato['thread_ok']==1)?"SI":"NO";
//$fila[]= ($dato['quiz_ok']==1)?"SI":"NO";
//$fila[]= ($dato['pc_ok']==1)?"SI":"NO";
//}
}
return $fila;
/**
* @param $data
* @param $numero_semanas
* @return array
*/
function mostrarResultadoAlumnoExportar($data ,$numero_semanas)
{
$fila = array();
$fila[] = utf8_decode($data[1]['username']);
$fila[]= utf8_decode($data[1]['fullname']);
foreach ($data as $line) {
$fila[]= ($line['work_ok']==1)?get_lang('Yes'):get_lang('No');
$fila[]= ($line['thread_ok']==1)?get_lang('Yes'):get_lang('No');
}
return $fila;
}
?>

@ -1,16 +1,25 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
/**
*
*/
require_once '../config.php';
$plugin = TicketPlugin::create();
$work_id = $_POST['work_id'];
$forum_id = $_POST['forum_id'];
$rs_id = $_POST['rs_id'];
$work_id = intval($_POST['work_id']);
$forum_id = intval($_POST['forum_id']);
$rs_id = intval($_POST['rs_id']);
api_protect_course_script();
if (!api_is_allowed_to_edit()){
Display::display_error_message($plugin->get_lang("DeniedAccess"));
}else{
$sql ="UPDATE ".Database::get_main_table('rp_reporte_semanas')." SET work_id = '$work_id' , forum_id = '$forum_id' WHERE id ='$rs_id'";
Database::query($sql);
Display::display_confirmation_message("Se actualizo con exito");
if (!api_is_allowed_to_edit()) {
Display::display_error_message($plugin->get_lang("DeniedAccess"));
} else {
$sql ="UPDATE ".Database::get_main_table('rp_reporte_semanas')."
SET work_id = '$work_id', forum_id = '$forum_id'
WHERE id ='$rs_id'";
Database::query($sql);
Display::display_confirmation_message(get_lang('UpdatedSuccessfully'));
}
?>

@ -11,45 +11,6 @@ $course_plugin = 'ticket'; //needed in order to load the plugin lang variables
require_once dirname(__FILE__).'/config.php';
$tool_name = get_lang('Ticket');
$tpl = new Template($tool_name);
$bbb = new bbb();
if ($bbb->plugin_enabled) {
if ($bbb->is_server_running()) {
if (isset($_GET['launch']) && $_GET['launch'] == 1) {
$meeting_params = array();
$meeting_params['meeting_name'] = api_get_course_id();
if ($bbb->meeting_exists($meeting_params['meeting_name'])) {
$url = $bbb->join_meeting($meeting_params['meeting_name']);
if ($url) {
header('location: '.$url);
exit;
} else {
$url = $bbb->create_meeting($meeting_params);
header('location: '.$url);
exit;
}
} else {
if ($bbb->is_teacher()) {
$url = $bbb->create_meeting($meeting_params);
header('location: '.$url);
exit;
} else {
$url = 'listing.php';
header('location: '.$url);
exit;
}
}
} else {
$url = 'listing.php';
header('location: '.$url);
exit;
}
} else {
$message = Display::return_message(get_lang('ServerIsNotRunning'), 'warning');
}
} else {
$message = Display::return_message(get_lang('ServerIsNotConfigured'), 'warning');
}
$tpl->assign('message', $message);
$tpl->display_one_col_template();

@ -4,7 +4,7 @@
* This script is included by main/admin/settings.lib.php when unselecting a plugin
* and is meant to remove things installed by the install.php script in both
* the global database and the courses tables
* @package chamilo.plugin.bigbluebutton
* @package chamilo.plugin.ticket
*/
/**
* Queries

Loading…
Cancel
Save