$(document).ready(function(){ document.getElementById("divEmail").style.display="none"; }); function load_course_list (div_course,my_user_id) { $.ajax({ contentType: "application/x-www-form-urlencoded", type: "GET", url: "course_user_list.php", data: "user_id="+my_user_id, success: function(datos) { $("div#user_request").html(datos); $("#user_id_request").val(my_user_id); $("#btnsubmit").attr("disabled", false); } }); } function changeType() { var selected = document.getElementById("category_id").selectedIndex; var id = document.getElementById("category_id").options[selected].value ; document.getElementById("project_id").value= projects[id]; document.getElementById("other_area").value= other_area[id]; document.getElementById("email").value= email[id]; document.getElementById("divEmail").style.display="none"; if(parseInt(course_required[id]) == 0){ document.getElementById("divCourse").style.display="none"; if( id != "CUR"){ document.getElementById("divEmail").style.display=""; document.getElementById("personal_email").required="required"; } document.getElementById("course_id").disabled=true; document.getElementById("course_id").value=0; }else{ document.getElementById("divCourse").style.display = ""; document.getElementById("course_id").disabled=false; document.getElementById("course_id").value=0; document.getElementById("personal_email").value=""; } } function handleClick2(myRadio) { var user_id = myRadio.value; document.getElementById("user_id_request").value = user_id; alert(document.getElementById("user_id_request").value); } function validate() { var re = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML(); document.getElementById("content").value= fckEditor1val; var selected = document.getElementById("category_id").selectedIndex; var id = document.getElementById("category_id").options[selected].value; if(document.getElementById("user_id_request").value == ""){ alert("'.$plugin->get_lang("ValidUser").'"); return false; }else if( id == 0){ alert("'.$plugin->get_lang("ValidType").'"); return false; }else if(document.getElementById("subject").value == ""){ alert("'.$plugin->get_lang("ValidSubject").'"); return false; }else if(parseInt(course_required[id]) == 1 && document.getElementById("course_id").value == 0){ alert("'.$plugin->get_lang("ValidCourse").'"); return false; }else if(id !="CUR" && parseInt(course_required[id]) != 1 && !re.test(document.getElementById("personal_email").value)){ alert("'.$plugin->get_lang("ValidEmail").'"); return false; }else if(fckEditor1val ==""){ alert("'.$plugin->get_lang("ValidMessage").'"); return false; } } var counter_image = 1; function remove_image_form(id_elem1) { var elem1 = document.getElementById(id_elem1); elem1.parentNode.removeChild(elem1); counter_image = counter_image - 1; } function add_image_form() { // Multiple filepaths for image form var filepaths = document.getElementById("filepaths"); if (document.getElementById("filepath_"+counter_image)) { counter_image = counter_image + 1; } else { counter_image = counter_image; } var elem1 = document.createElement("div"); elem1.setAttribute("id","filepath_"+counter_image); filepaths.appendChild(elem1); id_elem1 = "filepath_"+counter_image; id_elem1 = "\'"+id_elem1+"\'"; document.getElementById("filepath_"+counter_image).innerHTML = " "; //document.getElementById("filepath_"+counter_image).innerHTML = " "; if (filepaths.childNodes.length == 6) { var link_attach = document.getElementById("link-more-attach"); if (link_attach) { link_attach.innerHTML=""; } } } '; $types = TicketManager::get_all_tickets_categories(); $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; function js_str($s) { return '"'.addcslashes($s, "\0..\37\"\\").'"'; } function js_array($array,$name,$key) { $temp=array(); $return = "new Array(); "; foreach ($array as $value){ $return .= $name."['".$value['category_id']."'] ='".$value[$key]."'; "; } return $return; } function show_form_send_ticket(){ global $types, $plugin; echo '
'; echo '
'; echo ''; // Category $select_types = '
'.get_lang('Category').':
'; $select_types .= '"; $select_types .= '
'; echo $select_types; // Course $courses_list = CourseManager::get_courses_list_by_user_id($user_id,false,true); $select_course = '
'; echo $select_course; // Status $status = array(); $status[NEWTCK] = $plugin->get_lang('StsNew'); $status[PENDING] = $plugin->get_lang('StsPending'); $status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed'); $status[CLOSE] = $plugin->get_lang('StsClose'); $status[REENVIADO] = $plugin->get_lang('StsReenviado'); $select_status = '
'.get_lang('Status').':
'; echo $select_status; // Source $source = array(); $source[SRC_EMAIL] = $plugin->get_lang('SrcEmail'); $source[SRC_PHONE] = $plugin->get_lang('SrcPhone'); $source[SRC_PRESC] = $plugin->get_lang('SrcPresential'); $select_source = '
'.$plugin->get_lang('Source').':
'; echo $select_source; // Subject echo '
'.get_lang('Subject').':
'; // Email echo '
'.$plugin->get_lang('PersonalEmail').':
'; echo ''; echo ''; echo ''; // Message echo '
'.get_lang('Message').'
'; // Phone echo '
'.get_lang('Phone').' ('.$plugin->get_lang('Optional').'):
'; // Priority $select_priority = '
'.$plugin->get_lang('Priority').':
'; $priority = array(); $priority[NORMAL] = $plugin->get_lang('PriorityNormal'); $priority[HIGH] = $plugin->get_lang('PriorityHigh'); $priority[LOW] = $plugin->get_lang('PriorityLow'); $select_priority .= '"; $select_priority .= '
'; echo $select_priority; // Input file attach echo '
'.get_lang('FilesAttachment').'
'; echo '
'.get_lang('AddOneMoreFile').'  ('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')
'; echo '
'; echo '
'; } function save_ticket(){ global $plugin; $category_id = $_POST['category_id']; $content = $_POST['content']; if ($_POST['phone']!="") $content.= '

 '.get_lang('Phone').': '.$_POST['phone'].'

'; $course_id = $_POST['course_id']; $project_id = $_POST['project_id']; $subject = $_POST['subject']; $other_area = (int)$_POST['other_area']; $email = $_POST['email']; $personal_email = $_POST['personal_email']; $source = $_POST['source_id']; $user_id = $_POST['user_id_request']; $priority = $_POST['priority_id']; $status = $_POST['status_id']; $file_attachments = $_FILES; if(TicketManager::insert_new_ticket($category_id, $course_id, $project_id, $other_area, $email, $subject, $content,$personal_email, $file_attachments,$source,$priority,$status,$user_id,api_get_user_id())){ header('location:'.api_get_path(WEB_PLUGIN_PATH).PLUGIN_NAME.'/s/myticket.php?message=success'); }else{ Display::display_header(get_lang('ComposeMessage')); Display::display_error_message($plugin->get_lang('ErrorRegisterMessage')); } } /** * Get the total number of users on the platform * @see SortableTable#get_total_number_of_items() */ function get_number_of_users() { $user_table = Database :: get_main_table(TABLE_MAIN_USER); $sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u"; if ((api_is_platform_admin() || api_is_session_admin()) && api_get_multiple_access_url()) { $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)"; } if ( isset ($_GET['keyword'])) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%' OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' OR u.official_code LIKE '%".$keyword."%') "; } $res = Database::query($sql); $obj = Database::fetch_object($res); return $obj->total_number_of_items; } /** * Get the users to display on the current page (fill the sortable-table) * @param int offset of first user to recover * @param int Number of users to get * @param int Column to sort on * @param string Order (ASC,DESC) * @see SortableTable#get_table_data($from) */ function get_user_data($from, $number_of_items, $column, $direction) { $user_table = Database :: get_main_table(TABLE_MAIN_USER); $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN); $sql = "SELECT u.user_id AS col0, u.official_code AS col2, ".(api_is_western_name_order() ? "u.firstname AS col3, u.lastname AS col4," : "u.lastname AS col3, u.firstname AS col4,")." u.username AS col5, u.email AS col6, u.status AS col7, u.active AS col8, u.user_id AS col9 ". ", u.expiration_date AS exp ". " FROM $user_table u "; if (isset ($_GET['keyword']) ) { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR concat(u.firstname,' ',u.lastname) LIKE '%".$keyword."%' OR concat(u.lastname,' ',u.firstname) LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.official_code LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )"; } if (!in_array($direction, array('ASC','DESC'))) { $direction = 'ASC'; } $column = intval($column); $from = intval($from); $number_of_items = intval($number_of_items); $sql .= " ORDER BY col$column $direction "; $sql .= " LIMIT $from,$number_of_items"; $res = Database::query($sql); $users = array (); $t = time(); while ($user = Database::fetch_row($res)) { $image_path = UserManager::get_user_picture_path_by_id($user[0], 'web', false, true); $user_profile = UserManager::get_picture_user($user[0], $image_path['file'], 22, USER_IMAGE_SIZE_SMALL, ' width="22" height="22" '); if (!api_is_anonymous()) { $photo = '
'.api_get_person_name($user[2],$user[3]).'
'; } else { $photo = '
'.api_get_person_name($user[2], $user[3]).'
'; } $user_id= $user[0]; $button = ''.Display::return_icon('view_more_stats.gif', get_lang('Info')).''; $button= ' '.get_lang('Courses').'   '; $users[] = array($photo,$user[1],$user[2],$user[3],$user[4],$user[5],$button); } return $users; } if(!isset($_POST['compose'])){ Display::display_header(get_lang('ComposeMessage')); echo '
 
'; 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(); ?>