265 lines
8.0 KiB
JavaScript
265 lines
8.0 KiB
JavaScript
|
|
$(document).on('click touch', '#users-view-all', function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#custom-where").val("");
|
|
loadRecords();
|
|
});
|
|
|
|
$(document).on('click touch', '#users-view-admin', function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#custom-where").val("AND type NOT IN ('Parent','Guest','Staff','Supplier')");
|
|
loadRecords();
|
|
});
|
|
|
|
$(document).on('click touch', '#users-view-staff', function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#custom-where").val("AND type IN ('Staff')");
|
|
loadRecords();
|
|
});
|
|
|
|
$(document).on('click touch', '#users-view-registrants', function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#custom-where").val("AND type IN ('Parent')");
|
|
loadRecords();
|
|
});
|
|
|
|
$(document).on('click touch', '#users-view-guests', function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#custom-where").val("AND type IN ('Guest')");
|
|
loadRecords();
|
|
});
|
|
|
|
$(document).on('click touch', '#users-view-suppliers', function(e) {
|
|
e.preventDefault();
|
|
|
|
$("#custom-where").val("AND type IN ('Supplier')");
|
|
loadRecords();
|
|
});
|
|
|
|
$(document).on('click touch', '#users-csv-file', function(e) {
|
|
e.preventDefault();
|
|
|
|
window.location = "?action=users-csv";
|
|
});
|
|
|
|
$(document).on('click touch', '.insert-new', function() {
|
|
$('.notype').hide();
|
|
});
|
|
|
|
$(document).on('change', '#edit-form #type', function() {
|
|
adjustFormFields();
|
|
});
|
|
|
|
function adjustFormFields() {
|
|
var type = $('#edit-form #type').val();
|
|
|
|
$('.notype').hide();
|
|
|
|
switch (type) {
|
|
case 'Parent':
|
|
case 'Guest':
|
|
$('.parent').show();
|
|
$("#can_order").val('Y');
|
|
$("#email_reminders").val('Y');
|
|
$("#receive_emails").val('Y');
|
|
$("#email_flag").val('Y');
|
|
$("#available_to_volunteer").val('Y');
|
|
$("#school_directory").val('Y');
|
|
$("#email_list").val('Y');
|
|
break;
|
|
|
|
case 'Supplier':
|
|
$('.supplier').show();
|
|
$("#can_order").val('N');
|
|
$("#email_reminders").val('N');
|
|
$("#receive_emails").val('N');
|
|
$("#email_flag").val('N');
|
|
$("#available_to_volunteer").val('N');
|
|
$("#school_directory").val('N');
|
|
$("#email_list").val('N');
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
$(document).on('click touch', '.status-data-span', function(e) {
|
|
e.preventDefault();
|
|
|
|
var value = $(this).html();
|
|
var rnum = $(this).attr('rnum');
|
|
var fid = $(this).attr('id');
|
|
var new_value = '';
|
|
var new_index = 0;
|
|
|
|
const options = ['Pending', 'Active', 'Inactive', 'Suspended', 'Deleted'];
|
|
var num_options = options.length;
|
|
|
|
for (let i = 0; i < num_options; i++) {
|
|
if (new_value == '' && new_index == 0) {
|
|
if (value == options[i]) {
|
|
new_index = i + 1;
|
|
if (new_index == num_options) new_index = 0;
|
|
new_value = options[new_index];
|
|
}
|
|
}
|
|
}
|
|
|
|
$.ajax({
|
|
url: 'ajax.UpdateDBField.php',
|
|
data: {
|
|
table_name: 'users',
|
|
field_name: 'status',
|
|
field_value: new_value,
|
|
field_type: 'text',
|
|
record_num: rnum
|
|
},
|
|
dataType: 'json'
|
|
}).done(function(results) {
|
|
$("#"+fid).html(new_value);
|
|
});
|
|
});
|
|
|
|
$(document).on('click touch', '.can-order-data-span', function(e) {
|
|
e.preventDefault();
|
|
|
|
var value = $(this).html();
|
|
var rnum = $(this).attr('rnum');
|
|
var fid = $(this).attr('id');
|
|
var new_value = '';
|
|
var display = '';
|
|
var new_index = 0;
|
|
|
|
const options = ['Y', 'N', 'B'];
|
|
const dvalues = ['Yes', 'No', 'Balance'];
|
|
var num_options = options.length;
|
|
|
|
for (let i = 0; i < num_options; i++) {
|
|
if (new_value == '' && new_index == 0) {
|
|
if (value == dvalues[i]) {
|
|
new_index = i + 1;
|
|
if (new_index == num_options) new_index = 0;
|
|
new_value = options[new_index];
|
|
display = dvalues[new_index];
|
|
}
|
|
}
|
|
}
|
|
|
|
$.ajax({
|
|
url: 'ajax.UpdateDBField.php',
|
|
data: {
|
|
table_name: 'users',
|
|
field_name: 'can_order',
|
|
field_value: new_value,
|
|
field_type: 'text',
|
|
record_num: rnum
|
|
},
|
|
dataType: 'json'
|
|
}).done(function(results) {
|
|
$("#"+fid).html(display);
|
|
});
|
|
});
|
|
|
|
$(document).on('click touch', '.user-students', function(e) {
|
|
e.preventDefault();
|
|
|
|
var unum = $(this).attr('rnum');
|
|
var num_students = $("#linked-to-num-data-span-id-"+unum).html();
|
|
|
|
if (num_students == '' || num_students == '0') {
|
|
alert('<?php displayLanguageText('ERRORMSG-NO-STUDENTS-WITH-ACCOUNT'); ?>');
|
|
return;
|
|
}
|
|
|
|
location.href = '/?action=table.student-people&account_num='+unum;
|
|
});
|
|
|
|
$(document).on('click touch', '.send-login-reminder', function(e) {
|
|
e.preventDefault();
|
|
|
|
var unum = $(this).attr('rnum');
|
|
|
|
$.ajax({
|
|
url: "ajax.DataRecord.Fetch.php",
|
|
data: {
|
|
table_name: "users",
|
|
record_num: unum,
|
|
},
|
|
dataType: "json",
|
|
error:
|
|
function(jqXHR, exception) {
|
|
alert("Exception: "+jqXHR.status+' '+jqXHR.statusText);
|
|
}
|
|
}).done(
|
|
function(results) {
|
|
var email = results['email'];
|
|
if (email == '') {
|
|
msg = '<?php displayLanguageText('ERRORMSG-UNABLE-TO-SEND-EMAIL'); ?>\n'+
|
|
'<?php displayLanguageText('TEXT-NO-EMAIL-ADDRESS'); ?>';
|
|
alert(msg);
|
|
return;
|
|
}
|
|
alert('Email to: '+email);
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).on('click touch', '.send-menu-reminder', function(e) {
|
|
alert('send-menu-reminder');
|
|
});
|
|
|
|
$(document).on('click touch', '.user-info', function(e) {
|
|
e.preventDefault();
|
|
|
|
var unum = $(this).attr('rnum');
|
|
|
|
$.getJSON("ajax.DataTable.Fetch.php",
|
|
{
|
|
table_name: 'users',
|
|
action: 'user-info',
|
|
sequence_flag: 'N',
|
|
user_num: unum,
|
|
exclude: 'Exclude School'
|
|
},
|
|
function(results) {
|
|
var display_data = '';
|
|
display_data += "<center><table><tr><td class='ltext'>" +
|
|
results.content +
|
|
"</td></tr></table></center>";
|
|
|
|
$("#info-dialog-data-div").html(display_data);
|
|
$("#info-dialog").dialog('open');
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).on('click touch', '#reset-user-password', function(e) {
|
|
e.preventDefault();
|
|
|
|
var user_num = $(this).attr('unum');
|
|
var school_num = $(this).attr('snum');
|
|
var userid = $(this).attr('userid');
|
|
var last_login = $(this).attr('last');
|
|
|
|
$("#user-id").val(userid);
|
|
$("#user-id").select();
|
|
document.execCommand("copy");
|
|
|
|
var ans = confirm("Reset User Password?\n\nUser ID: "+userid+"\nNew Password: "+userid+"\n\nLast Login: "+last_login);
|
|
if (ans) {
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: "ajax.UserPassword.Update.php",
|
|
data: { school_num: school_num, record_num: user_num }
|
|
}).done(function() {
|
|
alert("User Password Updated");
|
|
});
|
|
}
|
|
});
|
|
|
|
|