Files
HotLunches/users.merge.php
2026-10-19 15:22:52 -07:00

127 lines
4.2 KiB
PHP

<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('TEXT-USER-ADMINISTRATION');
if ($action == 'user-account-list') $templatePageTitle = getLanguageText('TEXT-USER-ACCOUNT-LIST');
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator');
if (checkPermission($AllowedUserTypes) != 1) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
include "form.messages.php";
return;
}
include "users.options.php";
$message_width = $default_form_width;
include "form.messages.php";
?>
<script>
$(document).ready(function() {
$("#mergeButton").click(function (e) {
e.preventDefault();
var sval = $("#source_account").val();
var dval = $("#destination_account").val();
var n = sval.split(":");
var snum = n[0];
var sname = n[1];
var n = dval.split(":");
var dnum = n[0];
var dname = n[1];
if (snum == dnum) {
alert("<?php displayLanguageText('ERRORMSG-ERROR:-SOURCE-AND-DESTINATION-ACCOUNT-ARE-THE-SAME'); ?>");
return;
}
var msg = "<?php displayLanguageText('TEXT-MERGE-STUDENTS-AND-TRANSACTIONS'); ?>\n\n"+
"<?php displayLanguageText('TEXT-FROM-USER-ACCOUNT'); ?>: "+sname+"\n"+
"<?php displayLanguageText('TEXT-TO-USER-ACCOUNT'); ?>: "+dname;
r = confirm(msg);
if (r == true) {
location.href = '?action=users&naction=merge-accounts&source='+snum+'&destination='+dnum;
return;
}
});
});
</script>
<br>
<form method='post'>
<table width='<?php echo($default_form_width) ?>' class='content-table'>
<tr>
<td colspan='2' align='center' class='heading'><?php displayLanguageText('TEXT-MERGE-USER-ACCOUNTS'); ?></td>
</tr>
<tr>
<td align='center'>
<br>
<table width='100%' cellpadding='1' cellspacing='1' border='0' align='center'>
<tr>
<td align='right' valign='top' ><?php echo(getLanguageText('TEXT-SOURCE-USER-ACCOUNT')) ?>:</td>
<td align='left'>
<select name='source_account' id='source_account' class='select-width400'>
<?php
$query = "select * from users " .
"where school_num = $base_school_num " .
"and type in ('Staff','Parent','Guest','Administration Team') " .
"order by last_name,first_name";
$results = db_query($query);
while ($row = db_fetch_assoc($results)) {
$num = $row['record_num'];
$user = $row['userid'];
$name = $row['first_name'] . ' ' . $row['last_name'];
$ns = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND user_num = $num AND people_type = 'Student'");
echo(" <option value='$num:$name'>$name - ($user) - $ns " . $GlobalText['Students'] . "</option>\n");
}
?>
</select>
</td>
</tr>
<tr>
<td align='right' valign='top' ><?php echo(getLanguageText('TEXT-DESTINATION-USER-ACCOUNT')) ?>:</td>
<td align='left'>
<select name='destination_account' id='destination_account' class='select-width400'>
<?php
$query = "select * from users " .
"where school_num = $base_school_num " .
"and type in ('Staff','Parent','Guest','Administration Team') " .
"order by last_name,first_name";
$results = db_query($query);
while ($row = db_fetch_assoc($results)) {
$num = $row['record_num'];
$user = $row['userid'];
$name = $row['first_name'] . ' ' . $row['last_name'];
$ns = db_getVal("SELECT count(*) FROM people WHERE school_num = $base_school_num AND user_num = $num AND people_type = 'Student'");
echo(" <option value='$num:$name'>$name - ($user) - $ns " . $GlobalText['Students'] . "</option>\n");
}
?>
</select>
</td>
</tr>
</table>
<br>
<input type='submit' class='btn btn--primary' id='mergeButton' value='Merge Accounts' onclick='return false;'>
<br>
</td>
</tr>
</table>
</form>
<?php
endTemplate();
?>