Fix legacy code UI

pull/3890/head
Julio Montoya 4 years ago
parent fc000a1a41
commit fda7d46712
  1. 458
      public/main/session/add_users_to_session_course.php
  2. 8
      public/main/session/resume_session.php

@ -644,270 +644,266 @@ if ('multiple' == $add_type) {
'<a href="'.api_get_self().'?course_id='.$courseId.'&id_session='.$id_session.'&amp;add='.$addProcess.'&amp;add_type=multiple">'
.Display::return_icon('multiple.gif').get_lang('Multiple registration').'</a>';
}
echo Display::toolbarAction('users_to_session', [$link_add_type_unique.$link_add_type_multiple]);
echo Display::page_header($tool_name.' ('.$session_info['name'].') - '.$courseInfo['title']);
?>
<div class="actions">
<?php
echo $link_add_type_unique;
echo $link_add_type_multiple;
?>
</div>
<form name="formulaire" method="post"
action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&course_id=<?php echo $courseId; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($addProcess)) {
echo '&add=true';
} ?>" <?php if ($ajax_search) {
echo ' onsubmit="valide();"';
} ?>>
<?php echo '<legend>'.$tool_name.' ('.$session_info['name'].') - '.$courseInfo['title'].' </legend>'; ?>
<?php
if ('multiple' == $add_type) {
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list) > 0) {
echo '<h3>'.get_lang('Filter users').'</h3>';
foreach ($new_field_list as $new_field) {
echo $new_field['name'];
$varname = 'field_'.$new_field['variable'];
$fieldtype = $new_field['type'];
echo '&nbsp;<select name="'.$varname.'">';
echo '<option value="0">--'.get_lang('Select').'--</option>';
foreach ($new_field['data'] as $option) {
$checked = '';
if (ExtraField::FIELD_TYPE_TAG == $fieldtype) {
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option['tag']) {
$checked = 'selected="true"';
}
<form name="formulaire" method="post"
action="<?php echo api_get_self(); ?>?page=<?php echo $page; ?>&course_id=<?php echo $courseId; ?>&id_session=<?php echo $id_session; ?><?php if (!empty($addProcess)) {
echo '&add=true';
} ?>" <?php if ($ajax_search) {
echo ' onsubmit="valide();"';
} ?>>
<?php
if ('multiple' === $add_type) {
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list) > 0) {
echo '<h3>'.get_lang('Filter users').'</h3>';
foreach ($new_field_list as $new_field) {
echo $new_field['name'];
$varname = 'field_'.$new_field['variable'];
$fieldtype = $new_field['type'];
echo '&nbsp;<select name="'.$varname.'">';
echo '<option value="0">--'.get_lang('Select').'--</option>';
foreach ($new_field['data'] as $option) {
$checked = '';
if (ExtraField::FIELD_TYPE_TAG == $fieldtype) {
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option['tag']) {
$checked = 'selected="true"';
}
echo '<option value="'.$option['tag'].'" '.$checked.'>'.$option['tag'].'</option>';
} else {
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option[1]) {
$checked = 'selected="true"';
}
}
echo '<option value="'.$option['tag'].'" '.$checked.'>'.$option['tag'].'</option>';
} else {
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option[1]) {
$checked = 'selected="true"';
}
echo '<option value="'.$option[1].'" '.$checked.'>'.$option[2].'</option>';
}
echo '<option value="'.$option[1].'" '.$checked.'>'.$option[2].'</option>';
}
echo '</select>';
$extraHidden =
ExtraField::FIELD_TYPE_TAG == $fieldtype ? '<input type="hidden" name="field_id" value="'
.$option['field_id'].'" />' : '';
echo $extraHidden;
echo '&nbsp;&nbsp;';
}
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />';
echo '</select>';
$extraHidden =
ExtraField::FIELD_TYPE_TAG == $fieldtype ? '<input type="hidden" name="field_id" value="'
.$option['field_id'].'" />' : '';
echo $extraHidden;
echo '&nbsp;&nbsp;';
}
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />';
}
}
?>
<input type="hidden" name="form_sent" value="1"/>
<input type="hidden" name="add_type"/>
}
?>
<input type="hidden" name="form_sent" value="1"/>
<input type="hidden" name="add_type"/>
<?php
if (!empty($errorMsg)) {
echo Display::return_message($errorMsg); //main API
}
?>
<div id="multiple-add-session" class="row">
<div class="col-md-4">
<div class="form-group">
<label><?php echo get_lang('Portal users list'); ?> </label>
<?php
if (!empty($errorMsg)) {
echo Display::return_message($errorMsg); //main API
}
?>
<div id="multiple-add-session" class="grid grid-cols-3">
<div class="col-md-4">
<div class="form-group">
<label><?php echo get_lang('Portal users list'); ?> </label>
<?php
if (!('multiple' == $add_type)) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')"
class="form-control"/>
<div id="ajax_list_users_single" class="select-list-ajax"></div>
<?php
if (!('multiple' == $add_type)) {
?>
<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')"
class="form-control"/>
<div id="ajax_list_users_single" class="select-list-ajax"></div>
<?php
} else {
?>
<div id="ajax_list_users_multiple">
<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15"
class="form-control">
<?php
foreach ($nosessionUsersList as $uid => $enreg) {
?>
<option value="<?php echo $uid; ?>" <?php if (in_array($uid, $UserList)) {
echo 'selected="selected"';
} ?>>
<?php
$personName = $enreg['ln'].' '.$enreg['fn'].' ('.$enreg['un'].') '
.$enreg['official_code'];
if ($showOfficialCode) {
$officialCode =
!empty($enreg['official_code']) ? $enreg['official_code'].' - '
: '? - ';
$personName =
$officialCode.$enreg['ln'].' '.$enreg['fn'].' ('.$enreg['un'].')';
}
echo $personName; ?>
</option>
<?php
} ?>
</select>
</div>
<?php
}
unset($nosessionUsersList);
} else {
?>
</div>
<div id="ajax_list_users_multiple">
<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15"
class="form-control">
<?php
foreach ($nosessionUsersList as $uid => $enreg) {
?>
<option value="<?php echo $uid; ?>" <?php if (in_array($uid, $UserList)) {
echo 'selected="selected"';
} ?>>
<?php
$personName = $enreg['ln'].' '.$enreg['fn'].' ('.$enreg['un'].') '
.$enreg['official_code'];
if ($showOfficialCode) {
$officialCode =
!empty($enreg['official_code']) ? $enreg['official_code'].' - '
: '? - ';
$personName =
$officialCode.$enreg['ln'].' '.$enreg['fn'].' ('.$enreg['un'].')';
}
echo $personName; ?>
</option>
<?php
} ?>
</select>
</div>
<?php
}
unset($nosessionUsersList);
?>
</div>
</div>
<div class="col-md-4">
<?php if ('multiple' == $add_type) {
?>
<?php echo get_lang('First letter (last name)'); ?> :
<select id="first_letter_user" name="firstLetterUser" onchange="change_select(this.value);">
<option value="%">--</option>
<?php
echo Display:: get_alphabet_options(); ?>
</select>
<br/>
<br/>
<div class="col-md-4">
<?php if ('multiple' == $add_type) {
?>
<?php echo get_lang('First letter (last name)'); ?> :
<select id="first_letter_user" name="firstLetterUser" onchange="change_select(this.value);">
<option value="%">--</option>
<?php
echo Display:: get_alphabet_options(); ?>
</select>
<br/>
<br/>
<?php
} ?>
<div class="control-course">
<?php
} ?>
<div class="control-course">
if ($ajax_search) {
?>
<div class="separate-action">
<button name="remove_user" class="btn btn-primary" type="button"
onclick="remove_item(document.getElementById('destination_users'))">
<em class="fa fa-chevron-left"></em>
</button>
</div>
<?php
if ($ajax_search) {
?>
<div class="separate-action">
<button name="remove_user" class="btn btn-primary" type="button"
onclick="remove_item(document.getElementById('destination_users'))">
<em class="fa fa-chevron-left"></em>
</button>
</div>
<?php
} else {
?>
<div class="separate-action">
<button name="add_user" class="btn btn-primary" type="button"
onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))"
onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))">
<em class="fa fa-chevron-right"></em>
</button>
</div>
<div class="separate-action">
<button name="remove_user" class="btn btn-primary" type="button"
onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))"
onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))">
<em class="fa fa-chevron-left"></em>
</button>
</div>
<?php
}
if (!empty($addProcess)) {
echo '<button name="next" class="btn btn-success" type="button" value="" onclick="valide()" >'
.get_lang('Finish session creation').'</button>';
} else {
echo '<button name="next" class="btn btn-success" type="button" value="" onclick="valide()" >'
.get_lang('Subscribe users to this session').'</button>';
}
} else {
?>
</div>
</div>
<div class="separate-action">
<button name="add_user" class="btn btn-primary" type="button"
onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))"
onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))">
<em class="fa fa-chevron-right"></em>
</button>
</div>
<div class="separate-action">
<button name="remove_user" class="btn btn-primary" type="button"
onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))"
onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))">
<em class="fa fa-chevron-left"></em>
</button>
</div>
<div class="col-md-4">
<label><?php echo get_lang('List of users registered in this session'); ?> :</label>
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15"
class="form-control">
<?php
foreach ($sessionUsersList as $enreg) {
?>
<option value="<?php echo $enreg['id']; ?>">
<?php
$personName = $enreg['lastname'].' '.$enreg['firstname'].' ('.$enreg['username'].') '
.$enreg['official_code'];
if ($showOfficialCode) {
$officialCode =
!empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - ';
$personName =
$officialCode.$enreg['lastname'].' '.$enreg['firstname'].' ('.$enreg['username']
.')';
}
echo $personName; ?>
</option>
<?php
}
unset($sessionUsersList);
?>
</select>
}
if (!empty($addProcess)) {
echo '<button name="next" class="btn btn-success" type="button" value="" onclick="valide()" >'
.get_lang('Finish session creation').'</button>';
} else {
echo '<button name="next" class="btn btn-success" type="button" value="" onclick="valide()" >'
.get_lang('Subscribe users to this session').'</button>';
}
?>
</div>
</div>
</form>
<script>
function moveItem(origin, destination) {
for (var i = 0; i < origin.options.length; i++) {
if (origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text, origin.options[i].value);
origin.options[i] = null;
i = i - 1;
<div class="col-md-4">
<label><?php echo get_lang('List of users registered in this session'); ?> :</label>
<select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15"
class="form-control">
<?php
foreach ($sessionUsersList as $enreg) {
?>
<option value="<?php echo $enreg['id']; ?>">
<?php
$personName = $enreg['lastname'].' '.$enreg['firstname'].' ('.$enreg['username'].') '
.$enreg['official_code'];
if ($showOfficialCode) {
$officialCode =
!empty($enreg['official_code']) ? $enreg['official_code'].' - ' : '? - ';
$personName =
$officialCode.$enreg['lastname'].' '.$enreg['firstname'].' ('.$enreg['username']
.')';
}
echo $personName; ?>
</option>
<?php
}
unset($sessionUsersList);
?>
</select>
</div>
</div>
</form>
<script>
function moveItem(origin, destination) {
for (var i = 0; i < origin.options.length; i++) {
if (origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text, origin.options[i].value);
origin.options[i] = null;
i = i - 1;
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0; i < options.length; i++)
newOptions[i] = options[i];
function sortOptions(options) {
newOptions = new Array();
for (i = 0; i < options.length; i++)
newOptions[i] = options[i];
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0; i < newOptions.length; i++)
options[i] = newOptions[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0; i < newOptions.length; i++)
options[i] = newOptions[i];
}
function mysort(a, b) {
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
function mysort(a, b) {
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
function valide() {
var options = document.getElementById('destination_users').options;
for (i = 0; i < options.length; i++)
options[i].selected = true;
document.forms.formulaire.submit();
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
}
function loadUsersInSelect(select) {
var xhr_object = null;
if (window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if (window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('origin_users'));
sessionUsers = makepost(document.getElementById('destination_users'));
nosessionClasses = makepost(document.getElementById('origin_classes'));
sessionClasses = makepost(document.getElementById('destination_classes'));
xhr_object.send("nosessionusers=" + nosessionUsers + "&sessionusers=" + sessionUsers + "&nosessionclasses=" + nosessionClasses + "&sessionclasses=" + sessionClasses);
xhr_object.onreadystatechange = function () {
if (xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
}
function valide() {
var options = document.getElementById('destination_users').options;
for (i = 0; i < options.length; i++)
options[i].selected = true;
document.forms.formulaire.submit();
}
function loadUsersInSelect(select) {
var xhr_object = null;
if (window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if (window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr_object.open("POST", "loadUsersInSelect.ajax.php");
xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
nosessionUsers = makepost(document.getElementById('origin_users'));
sessionUsers = makepost(document.getElementById('destination_users'));
nosessionClasses = makepost(document.getElementById('origin_classes'));
sessionClasses = makepost(document.getElementById('destination_classes'));
xhr_object.send("nosessionusers=" + nosessionUsers + "&sessionusers=" + sessionUsers + "&nosessionclasses=" + nosessionClasses + "&sessionclasses=" + sessionClasses);
xhr_object.onreadystatechange = function () {
if (xhr_object.readyState == 4) {
document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
}
}
}
function makepost(select) {
var options = select.options;
var ret = "";
for (i = 0; i < options.length; i++)
ret = ret + options[i].value + '::' + options[i].text + ";;";
return ret;
}
</script>
function makepost(select) {
var options = select.options;
var ret = "";
for (i = 0; i < options.length; i++)
ret = ret + options[i].value + '::' + options[i].text + ";;";
return ret;
}
</script>
<?php
Display::display_footer();

@ -241,7 +241,9 @@ if (0 === $session->getNbrCourses()) {
Display::return_icon('teacher.png', get_lang('Edit coach')),
$codePath."session/session_course_edit.php?id_session=$sessionId&page=resume_session.php&course_code={$courseCode}$orig_param"
);
$courseItem .= Display::url(
// @todo
/*$courseItem .= Display::url(
Display::return_icon('folder_document.png', get_lang('File upload')),
'#',
[
@ -249,7 +251,7 @@ if (0 === $session->getNbrCourses()) {
'data-session' => $sessionId,
'data-course' => $courseId,
]
);
);*/
$courseItem .= Display::url(
Display::return_icon('delete.png', get_lang('Delete')),
api_get_self()."?id_session=$sessionId&action=delete&idChecked[]={$courseCode}",
@ -278,7 +280,7 @@ $url .= Display::url(
$codePath."user/user_export.php?file_type=csv&session=$sessionId&addcsvheader=1"
);
$userListToShow = Display::page_subheader(get_lang('User list').$url);
$userListToShow = Display::page_subheader(get_lang('User list').Display::toolbarAction('users', [$url]));
$sessionRelUsers = Container::getSessionRepository()->getUsersByAccessUrl($session, api_get_url_entity());
if (!empty($sessionRelUsers)) {

Loading…
Cancel
Save