From html form to FormValidator and some JS improvements - refs #6715

1.9.x
Francis Gonzales 12 years ago
parent 7bb3d41a76
commit f85aed2010
  1. 468
      plugin/ticket/src/new_ticket.php
  2. 312
      plugin/ticket/src/ticket_details.php

@ -31,19 +31,19 @@ if (api_is_platform_admin()) {
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<script> <script>
function load_course_list (div_course, my_user_id, user_email) { function load_course_list (div_course, my_user_id, user_email) {
$.ajax({ $.ajax({
contentType: "application/x-www-form-urlencoded", contentType: "application/x-www-form-urlencoded",
type: "GET", type: "GET",
url: "course_user_list.php", url: "course_user_list.php",
data: "user_id="+my_user_id, data: "user_id="+my_user_id,
success: function(datos) { success: function(datos) {
$("div#user_request").html(datos); $("#user_request").html(datos);
$("#user_id_request").val(my_user_id); $("#user_id_request").val(my_user_id);
$("#personal_email").val(user_email); $("#personal_email").val(user_email);
$("#btnsubmit").attr("disabled", false); $("#btnsubmit").attr("disabled", false);
' . $scrollTol . ' ' . $scrollTol . '
} }
}); });
} }
function changeType() { function changeType() {
var selected = document.getElementById("category_id").selectedIndex; var selected = document.getElementById("category_id").selectedIndex;
@ -98,31 +98,55 @@ function validate() {
} }
var counter_image = 1; var counter_image = 1;
function remove_image_form(id_elem1) {
var elem1 = document.getElementById(id_elem1); function remove_image_form(element_id) {
elem1.parentNode.removeChild(elem1); $("#" + element_id).remove();
counter_image = counter_image - 1; counter_image = counter_image - 1;
$("#link-more-attach").css("display", "block");
} }
function add_image_form() { function add_image_form() {
// Multiple filepaths for image form // Multiple filepaths for image form
var filepaths = document.getElementById("filepaths"); var filepaths = $("#filepaths");
if (document.getElementById("filepath_"+counter_image)) { var new_elem, input_file, link_remove, img_remove, new_filepath_id;
counter_image = counter_image + 1;
} else { if ($("#filepath_"+counter_image)) {
counter_image = counter_image; counter_image = counter_image + 1;
} } else {
var elem1 = document.createElement("div"); counter_image = counter_image;
elem1.setAttribute("id","filepath_"+counter_image); }
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image; new_elem = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif\"></a>"; $("<div/>", {
if (filepaths.childNodes.length == 6) { id: new_elem,
var link_attach = document.getElementById("link-more-attach"); class: "controls"
if (link_attach) { }).appendTo(filepaths);
link_attach.innerHTML="";
} input_file = $("<input/>", {
} type: "file",
name: "attach_" + counter_image,
size: 20
});
link_remove = $("<a/>", {
onclick: "remove_image_form(\'" + new_elem + "\')",
style: "cursor: pointer"
});
img_remove = $("<img/>", {
src: "' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif"
});
new_filepath_id = $("#filepath_" + counter_image);
new_filepath_id.append(input_file, link_remove.append(img_remove));
if (counter_image === 6) {
var link_attach = $("#link-more-attach");
if (link_attach) {
$(link_attach).css("display", "none");
}
}
} }
</script> </script>
@ -136,19 +160,16 @@ div.row div.formw2 {
float:left float:left
} }
div.divTicket { div.divTicket {
width: 70%;
float: center;
margin-left: 15%;
padding-top: 100px; padding-top: 100px;
} }
</style>'; </style>';
$types = TicketManager::get_all_tickets_categories(); $types = TicketManager::get_all_tickets_categories();
$htmlHeadXtra[] = '<script language="javascript"> $htmlHeadXtra[] = '<script language="javascript">
var projects = ' . js_array($types, 'projects', 'project_id') . ' var projects = ' . js_array($types, 'projects', 'project_id') . '
var course_required = ' . js_array($types, 'course_required', 'course_required') . ' var course_required = ' . js_array($types, 'course_required', 'course_required') . '
var other_area = ' . js_array($types, 'other_area', 'other_area') . ' var other_area = ' . js_array($types, 'other_area', 'other_area') . '
var email = ' . js_array($types, 'email', 'email') . ' var email = ' . js_array($types, 'email', 'email') . '
</script>'; </script>';
$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>'; $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" />'; $htmlHeadXtra[] = '<link href="' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
@ -184,158 +205,225 @@ function show_form_send_ticket()
{ {
global $types, $plugin; global $types, $plugin;
echo '<div class="divTicket">'; echo '<div class="divTicket">';
echo '<form enctype="multipart/form-data" action="' . api_get_self() . '" method="post" name="send_ticket" id="send_ticket"
onsubmit="return validate()" style="width:100%">'; //Category List
echo '<input name="user_id_request" id="user_id_request" type="hidden" value="">'; $categoryList = array();
// Category
$select_types = '<div class="row">
<div class="label2">' . get_lang('Category') . ': </div>
<div class="formw2">';
$select_types .= '<select style="width: 95%; " name = "category_id" id="category_id" onChange="changeType();">';
$select_types .= '<option value="0">---' . get_lang('Select') . '---</option>';
foreach ($types as $type) { foreach ($types as $type) {
$select_types.= "<option value = '" . $type['category_id'] . "'>" . $type['name'] . ": <br/>" . $type['description'] . "</option>"; $categoryList[$type['category_id']] = $type['name'] . ": " . $type['description'];
} }
$select_types .= "</select>"; //End Category List
$select_types .= '</div></div>';
echo $select_types; //Status List
$statusList = array();
$select_course = '<div id="user_request" > $statusAttributes = array(
</div>'; 'style' => 'display: none;',
echo $select_course; 'id' => 'status_id',
'for' => 'status_id'
// Status );
$status = array(); $statusList[NEWTCK] = $plugin->get_lang('StsNew');
$status[NEWTCK] = $plugin->get_lang('StsNew');
$showStatus = "style='display: none;'";
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$showStatus = ""; $statusAttributes = array(
$status[PENDING] = $plugin->get_lang('StsPending'); 'id' => 'status_id',
$status[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed'); 'for' => 'status_id',
$status[CLOSE] = $plugin->get_lang('StsClose'); 'style' => 'width: 562px;'
$status[REENVIADO] = $plugin->get_lang('StsForwarded'); );
} $statusList[PENDING] = $plugin->get_lang('StsPending');
$select_status = ' $statusList[UNCONFIRMED] = $plugin->get_lang('StsUnconfirmed');
<div class="row" ' . $showStatus . ' > $statusList[CLOSE] = $plugin->get_lang('StsClose');
<div class="label2" >' . get_lang('Status') . ': </div> $statusList[REENVIADO] = $plugin->get_lang('StsForwarded');
<div class="formw2">
<select style="width: 95%; " name = "status_id" id="status_id">';
//$status = TicketManager::get_all_tickets_status();
foreach ($status as $sts_key => $sts_name) {
if ($sts_key == 'PND') {
$select_status .= "<option value = '" . $sts_key . "' selected >" . $sts_name . "</option>";
} else {
$select_status.= "<option value = '" . $sts_key . "'>" . $sts_name . "</option>";
}
} }
$select_status .= ' //End Status List
</select>
</div> //Source List
</div>'; $sourceList = array();
echo $select_status; $sourceAttributes = array(
'style' => 'display: none;',
// Source 'id' => 'source_id',
$source = array(); 'for' => 'source_id'
);
$sourceList[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform');
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$showBlock = ""; $sourceAttributes = array(
$source[SRC_EMAIL] = $plugin->get_lang('SrcEmail'); 'id' => 'source_id',
$source[SRC_PHONE] = $plugin->get_lang('SrcPhone'); 'for' => 'source_id',
$source[SRC_PRESC] = $plugin->get_lang('SrcPresential'); 'style' => 'width: 562px;'
} else { );
$showBlock = "style='display: none;'"; $sourceList[SRC_EMAIL] = $plugin->get_lang('SrcEmail');
$source[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform'); $sourceList[SRC_PHONE] = $plugin->get_lang('SrcPhone');
} $sourceList[SRC_PRESC] = $plugin->get_lang('SrcPresential');
$select_source = '
<div class="row" ' . $showBlock . '>
<div class="label2">' . $plugin->get_lang('Source') . ':</div>
<div class="formw2">
<select style="width: 95%; " name="source_id" id="source_id" >';
foreach ($source as $src_key => $src_name) {
$select_source.= "<option value = '" . $src_key . "'>" . $src_name . "</option>";
} }
$select_source .=' //End Source List
</select>
</div> //Priority List
</div>'; $priorityList = array();
echo $select_source; $priorityList[NORMAL] = $plugin->get_lang('PriorityNormal');
$priorityList[HIGH] = $plugin->get_lang('PriorityHigh');
// Subject $priorityList[LOW] = $plugin->get_lang('PriorityLow');
echo '<div class="row" ><div class ="label2">' . get_lang('Subject') . ':</div> //End Priority List
<div class="formw2"><input type = "text" id ="subject" name="subject" value="" required ="" style="width:94%"/></div>
</div>'; $form = new FormValidator('send_ticket',
'POST',
// Email api_get_self(),
echo '<div class="row" id="divEmail" ><div class ="label2">' . $plugin->get_lang('PersonalEmail') . ':</div> "",
<div class="formw2"><input type = "email" id ="personal_email" name="personal_email" value="" style="width:94%"/></div> array(
</div>'; 'enctype' => 'multipart/form-data',
echo '<input name="project_id" id="project_id" type="hidden" value="">'; 'onsubmit' => 'return validate()',
echo '<input name="other_area" id="other_area" type="hidden" value="">'; 'class' => 'span8 offset1 form-horizontal'
echo '<input name="email" id="email" type="hidden" value="">'; )
);
// Message
echo '<div class="row"> $form->addElement(
<div class="label2">' . get_lang('Message') . ':</div> 'hidden',
<div class="formw2"> 'user_id_request',
<input type="hidden" id="content" name="content" value="" style="display:none"> '',
<input type="hidden" id="content___Config" value="&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [ [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [ ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath='.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS='.api_get_path(WEB_PATH).'main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS='.api_get_path(WEB_CODE_PATH).'main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none"> array(
<iframe id="content___Frame" src="' . api_get_path(WEB_CODE_PATH) . 'inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;"> 'id' => 'user_id_request'
</iframe> )
</div> );
</div>';
$form->addElement(
// Phone 'hidden',
echo '<div class="row" ><div class ="label2">' . get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . '):</div> 'project_id',
<div class="formw2"><input type = "text" id ="phone" name="phone" value="" style="width:94%"/></div> '',
</div>'; array(
'id' => 'project_id'
// Priority )
$select_priority = '<div class="row" > );
<div class="label2" >' . $plugin->get_lang('Priority') . ':</div>
<div class="formw2">'; $form->addElement(
'hidden',
$priority = array(); 'other_area',
$priority[NORMAL] = $plugin->get_lang('PriorityNormal'); '',
$priority[HIGH] = $plugin->get_lang('PriorityHigh'); array(
$priority[LOW] = $plugin->get_lang('PriorityLow'); 'id' => 'other_area'
)
$select_priority .= '<select style="width: 85px; " name = "priority_id" id="priority_id">'; );
foreach ($priority as $prty_key => $prty_name) {
if ($sts_key == NORMAL) { $form->addElement(
$select_priority .= "<option value = '" . $prty_key . "' selected >" . $prty_name . "</option>"; 'hidden',
} else { 'email',
$select_priority.= "<option value = '" . $prty_key . "'>" . $prty_name . "</option>"; '',
} array(
} 'id' => 'email'
$select_priority .= "</select>"; )
$select_priority .= '</div></div>'; );
echo $select_priority;
$form->addElement(
// Input file attach 'select',
echo '<div class="row"> 'category_id',
<div class="label2">' . get_lang('FilesAttachment') . ':</div> get_lang('Category'),
<div class="formw2"> $categoryList,
<span id="filepaths"> array(
<div id="filepath_1"> 'onchange' => 'changeType()',
<input type="file" name="attach_1" id="attach_1" size="20" style="width:94%;"/> 'id' => 'category_id',
</div></span> 'for' => 'category_id',
</div> 'style' => 'width: 562px;'
</div>'; )
echo '<div class="row"> );
<div class="formw2">
<span id="link-more-attach"> $form->addElement(
<a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span>&nbsp; 'html',
(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ') Display::div(
</div> '',
</div>'; array(
echo '<div class="row"> 'id' => 'user_request'
<div class="label2"> )
</div> )
<div class="formw2"><button class="save" name="compose" type="submit" id="btnsubmit">' . get_lang('SendMessage') . '</button> );
</div>
</div>'; $form->addElement(
echo '</form></div>'; 'select',
'status_id',
get_lang('Status'),
$statusList,
$statusAttributes
);
$form->addElement(
'select',
'source_id',
$plugin->get_lang('Source'),
$sourceList,
$sourceAttributes
);
$form->addElement(
'text',
'subject',
get_lang('Subject'),
array(
'id' => 'subject',
'style' => 'width: 550px;'
)
);
$form->addElement(
'text',
'personal_email',
$plugin->get_lang('PersonalEmail'),
array(
'id' => 'personal_email',
'style' => 'width: 550px;'
)
);
$form->add_html_editor(
'content',
get_lang('Message'),
false,
false,
array(
'ToolbarSet' => 'Profile',
'Width' => '600',
'Height' => '250'
)
);
$form->addElement(
'text',
'phone',
get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . ')',
array(
'id' => 'phone'
)
);
$form->addElement(
'select',
'priority_id',
$plugin->get_lang('Priority'),
$priorityList,
array(
'id' => 'priority_id',
'for' => 'priority_id'
)
);
$form->addElement('html', '<span id="filepaths">');
$form->addElement('html', '<div id="filepath_1">');
$form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
$form->addElement('html', '</div>');
$form->addElement('html', '</span>');
$form->addElement('html', '<div class="controls">');
$form->addElement('html', '<span id="link-more-attach" >');
$form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
$form->addElement('html', '</span>');
$form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
$form->addElement('html', '<br/>');
$form->addElement(
'button',
'compose',
get_lang('SendMessage'),
array(
'class' => 'save',
'id' => 'btnsubmit'
)
);
$form->display();
} }
/** /**

@ -29,84 +29,114 @@ if ($isAdmin) {
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<script language="javascript"> <script language="javascript">
$(document).ready(function(){ $(document).ready(function(){
$( "#dialog-form" ).dialog({ $("#dialog-form").dialog({
autoOpen: false, autoOpen: false,
height: 450, height: 450,
width: 600, width: 600,
modal: true, modal: true,
buttons: { buttons: {
Asignar: function(){ Asignar: function(){
$("#genesis").submit() $("#genesis").submit()
}, },
Close: function() { Close: function() {
$( this ).dialog( "close" ); $(this).dialog("close");
}
}
});
$("a#assign").click(function () {
$( "#dialog-form" ).dialog( "open" );
});
$("input#responseyes").click(function () {
if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. ' . $plugin->get_lang('IfYouAreSureTheTicketWillBeClosed') . '")){
return false;
} }
} });
});
$("a#assign").click(function () {
$( "#dialog-form" ).dialog( "open" );
}); $("input#responseno").click(function () {
$("input#responseyes").click(function () {
if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('Yes')) . '. ' . $plugin->get_lang('IfYouAreSureTheTicketWillBeClosed') . '")){
return false;
}
});
$("input#responseno").click(function () {
if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('No')) . '")){ if(!confirm("' . $plugin->get_lang('AreYouSure') . ' : ' . strtoupper(get_lang('No')) . '")){
return false; return false;
} }
}); });
$("#unassign").click(function () {
if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToUnassignTheTicket') . '")) {
return false
}
});
$("#close").click(function () { $("#unassign").click(function () {
if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToCloseTheTicket') . '")) { if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToUnassignTheTicket') . '")) {
return false return false;
} }
}); });
$("#close").click(function () {
if (!confirm("' . $plugin->get_lang('AreYouSureYouWantToCloseTheTicket') . '")) {
return false;
}
});
' . $disableReponseButtons . ' ' . $disableReponseButtons . '
}); });
function validate() { function validate() {
fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML(); fckEditor1val = FCKeditorAPI.__Instances["content"].GetHTML();
document.getElementById("content").value= fckEditor1val; document.getElementById("content").value= fckEditor1val;
if(fckEditor1val == ""){ if(fckEditor1val == ""){
alert("' . $plugin->get_lang('YouMustWriteAMessage') . '"); alert("' . $plugin->get_lang('YouMustWriteAMessage') . '");
return false; return false;
} }
} }
var counter_image = 1; var counter_image = 1;
function remove_image_form(id_elem1) {
var elem1 = document.getElementById(id_elem1); function remove_image_form(element_id) {
elem1.parentNode.removeChild(elem1); $("#" + element_id).remove();
counter_image = counter_image - 1; counter_image = counter_image - 1;
$("#link-more-attach").css("display", "block");
} }
function add_image_form() { function add_image_form() {
// Multiple filepaths for image form // Multiple filepaths for image form
var filepaths = document.getElementById("filepaths"); var filepaths = $("#filepaths");
if (document.getElementById("filepath_"+counter_image)) { var new_elem, input_file, link_remove, img_remove, new_filepath_id;
counter_image = counter_image + 1;
} else { if ($("#filepath_"+counter_image)) {
counter_image = counter_image; counter_image = counter_image + 1;
} } else {
var elem1 = document.createElement("div"); counter_image = counter_image;
elem1.setAttribute("id","filepath_"+counter_image); }
filepaths.appendChild(elem1);
id_elem1 = "filepath_"+counter_image; new_elem = "filepath_"+counter_image;
id_elem1 = "\'"+id_elem1+"\'";
document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\" size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif\"></a>"; $("<div/>", {
if (filepaths.childNodes.length == 6) { id: new_elem,
var link_attach = document.getElementById("link-more-attach"); class: "controls"
if (link_attach) { }).appendTo(filepaths);
link_attach.innerHTML="";
} input_file = $("<input/>", {
} type: "file",
name: "attach_" + counter_image,
size: 20
});
link_remove = $("<a/>", {
onclick: "remove_image_form(\'" + new_elem + "\')",
style: "cursor: pointer"
});
img_remove = $("<img/>", {
src: "' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif"
});
new_filepath_id = $("#filepath_" + counter_image);
new_filepath_id.append(input_file, link_remove.append(img_remove));
if (counter_image === 6) {
var link_attach = $("#link-more-attach");
if (link_attach) {
$(link_attach).css("display", "none");
}
}
} }
</script>'; </script>';
$htmlHeadXtra[] = ' $htmlHeadXtra[] = '
<style> <style>
div.row div.label2 { div.row div.label2 {
@ -147,7 +177,14 @@ div.row div.formw2 {
float: right; float: right;
border-radius:15px; border-radius:15px;
} }
.attachment-link {
margin: 12px;
}
#link-more-attach {
color: white;
cursor: pointer;
width: 120px;
}
</style>'; </style>';
$ticket_id = $_GET['ticket_id']; $ticket_id = $_GET['ticket_id'];
@ -190,6 +227,7 @@ if (isset($_REQUEST['action'])) {
break; break;
} }
} }
if (!isset($_POST['compose'])) { if (!isset($_POST['compose'])) {
if (isset($_POST['close'])) { if (isset($_POST['close'])) {
$_GET['ticket_id'] = $_POST['ticket_id']; $_GET['ticket_id'] = $_POST['ticket_id'];
@ -294,26 +332,35 @@ if (!isset($_POST['compose'])) {
echo "<div class='row'>"; echo "<div class='row'>";
echo "<div class='span8 offset2'>"; echo "<div class='span8 offset2'>";
foreach ($messages as $message) { foreach ($messages as $message) {
$class = "alert alert-info"; $type = "success";
if ($message['admin']) { if ($message['admin']) {
$class = "alert alert-success"; $type = "normal";
if ($isAdmin) { if ($isAdmin) {
$message['message'].='<br/><b>' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>"; $message['message'].='<br/><b>' . $plugin->get_lang('AttendedBy') . ': ' . $message['user_created'] . " - " . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
} }
}else { }else {
$message['message'].='<b>' . get_lang('Sent') . ': ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>"; $message['message'].='<b>' . get_lang('Sent') . ': ' . api_convert_and_format_date(api_get_local_time($message['sys_insert_datetime']), DATE_TIME_FORMAT_LONG, _api_get_timezone()) . "</b>";
} }
echo '<div class="' . $class . '" ><b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/> <b>' . get_lang('Message') . ':</b>' . $message['message'] . '<br/>';
$receivedMessage = '<b>' . get_lang('Subject') . ': </b> ' . $message['subject'] . '<br/> <b>' . get_lang('Message') . ':</b>' . $message['message'] . '<br/>';
$attachementLinks = "";
if (isset($message['atachments'])) { if (isset($message['atachments'])) {
$attributeClass = array(
'class' => 'attachment-link'
);
foreach ($message['atachments'] as $attach) { foreach ($message['atachments'] as $attach) {
echo $attach['attachment_link']; $attachementLinks .= Display::tag('div', $attach['attachment_link'], $attributeClass);
} }
} }
echo '</div>';
$entireMessage = $receivedMessage . $attachementLinks;
echo Display::return_message($entireMessage, $type, false);
} }
echo "</div>"; echo "</div>";
echo "</div>"; echo "</div>";
$asunto = "RE: " . $message['subject']; $subject = "RE: " . $message['subject'];
$user_admin = api_is_platform_admin(); $user_admin = api_is_platform_admin();
if ($ticket['ticket']['status_id'] != 'REE' AND $ticket['ticket']['status_id'] != 'CLS') { if ($ticket['ticket']['status_id'] != 'REE' AND $ticket['ticket']['status_id'] != 'CLS') {
if (!$isAdmin && $ticket['ticket']['status_id'] != 'XCF') { if (!$isAdmin && $ticket['ticket']['status_id'] != 'XCF') {
@ -340,73 +387,80 @@ function show_form_send_message()
{ {
global $isAdmin; global $isAdmin;
global $ticket; global $ticket;
global $asunto; global $subject;
global $plugin; global $plugin;
echo '<div class="row">
<div class="span8 offset2"> Display::div('', array('span2'));
<form enctype="multipart/form-data"
action="' . api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'] . '" $form = new FormValidator(
method="post" name="send_ticket" id="send_ticket" 'send_ticket',
onsubmit="return validate()" class="form-horizontal">'; 'POST',
echo '<div class="control-group"> api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'],
<label for="subject" class="control-label"> "",
' . get_lang('Subject') . ': array(
</label> 'enctype' => 'multipart/form-data',
<div class="controls"> 'onsubmit' => 'return validate()',
<input type = "text" id ="subject" name="subject" value="' . $asunto . '" required ="" style="width:60%"/> 'class' => 'span9 offset1 form-horizontal'
</div> )
</div>'; );
echo '<div class="control-group">
<label class="control-label"> $form->addElement(
' . get_lang('Message') . ': 'text',
</label> 'subject',
<div class="controls"> get_lang('Subject'),
<input type="hidden" id="content" name="content" value="" style="display:none"> array(
<input type="hidden" id="content___Config" value="ToolbarSet=Messages&amp;Width=95%25&amp;Height=250&amp;ToolbarSets={ %22Messages%22: [ [ %22Bold%22,%22Italic%22,%22-%22,%22InsertOrderedList%22,%22InsertUnorderedList%22,%22Link%22,%22RemoveLink%22 ] ], %22MessagesMaximized%22: [ ] }&amp;LoadPlugin=[%22customizations%22]&amp;EditorAreaStyles=body { background: #ffffff; }&amp;ToolbarStartExpanded=false&amp;CustomConfigurationsPath='.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/myconfig.js&amp;EditorAreaCSS='.api_get_path(WEB_PATH).'main/css/chamilo/default.css&amp;ToolbarComboPreviewCSS='.api_get_path(WEB_PATH).'main/css/chamilo/default.css&amp;DefaultLanguage=es&amp;ContentLangDirection=ltr&amp;AdvancedFileManager=true&amp;BaseHref=' . api_get_path(WEB_PLUGIN_PATH) . PLUGIN_NAME . '/s/&amp;&amp;UserIsCourseAdmin=true&amp;UserIsPlatformAdmin=true" style="display:none"> 'for' => 'subject',
<iframe id="content___Frame" src="'.api_get_path(WEB_CODE_PATH).'inc/lib/fckeditor/editor/fckeditor.html?InstanceName=content&amp;Toolbar=Messages" width="95%" height="250" frameborder="0" scrolling="no" style="margin: 0px; padding: 0px; border: 0px; background-color: transparent; background-image: none; width: 95%; height: 250px;"> 'value' => $subject,
</iframe> 'style' => 'width: 540px;'
</div> )
</div> );
';
echo '<input type="hidden" id="ticket_id" name="ticket_id" value="' . $_GET['ticket_id'] . '">'; $form->addElement('hidden', 'ticket_id', $_GET['ticket_id']);
echo '<div class="control-group">
<label for="attach_1" class="control-label"> $form->add_html_editor(
' . get_lang('FilesAttachment') . ': 'content',
</label> get_lang('Message'),
<div class="controls"> false,
<span id="filepaths"> false,
<div id="filepath_1"> array(
<input type="file" name="attach_1" id="attach_1" size="20" style="width:59%;"/> 'ToolbarSet' => 'Profile',
</div> 'Width' => '550',
</span> 'Height' => '250'
</div> )
<div class="controls"> );
<span id="link-more-attach">
<a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '
</a>
</span>
(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')
</div>
</div>';
if ($isAdmin) { if ($isAdmin) {
echo '<div class="control-group"> $form->addElement(
<label for="confirmation" class="control-label"> 'checkbox',
' . $plugin->get_lang('RequestConfirmation') . ': 'confirmation',
</label> null,
<div class="controls"> $plugin->get_lang('RequestConfirmation')
<input type="checkbox" id="confirmation" name="confirmation"/> );
</div>
</div>';
} }
echo '<div class="formw"> $form->addElement('html', '<span id="filepaths">');
<button class="save" name="compose" type="submit">' . get_lang('SendMessage') . '</button> $form->addElement('html', '<div id="filepath_1">');
</div>'; $form->addElement('file', 'attach_1', get_lang('FilesAttachment'));
echo '</div> $form->addElement('html', '</div>');
</div> $form->addElement('html', '</span>');
</form>';
$form->addElement('html', '<div class="controls">');
$form->addElement('html', '<span id="link-more-attach" >');
$form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
$form->addElement('html', '</span>');
$form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
$form->addElement('html', '<br/>');
$form->addElement(
'button',
'compose',
get_lang('SendMessage'),
array(
'class' => 'save'
)
);
$form->display();
} }
Display::display_footer(); Display::display_footer();

Loading…
Cancel
Save