1080 lines
35 KiB
PHP
1080 lines
35 KiB
PHP
<?php
|
|
include "include/config.php";
|
|
|
|
// Set userType
|
|
$userType = "Parent";
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'],$AllAdminUserTypes)) $userType = "Admin";
|
|
|
|
|
|
$action = '';
|
|
if (array_key_exists('action',$_GET)) $action = $_GET['action'];
|
|
if (array_key_exists('action',$_POST)) $action = $_POST['action'];
|
|
|
|
$schedule_num = 0;
|
|
if (array_key_exists('schedule_num',$_GET)) $schedule_num = $_GET['schedule_num'];
|
|
if (array_key_exists('schedule_num',$_POST)) $schedule_num = $_POST['schedule_num'];
|
|
|
|
|
|
$numNoClass = 0;
|
|
$usernum = 0;
|
|
if (array_key_exists('UserInfo',$_SESSION)) {
|
|
if (array_key_exists('type',$_SESSION['UserInfo']) && $_SESSION['UserInfo']['type'] == 'Parent') {
|
|
$user_num = $_SESSION['UserInfo']['record_num'];
|
|
$numStudents = intval(db_getVal("SELECT count(*) FROM people WHERE school_num = $school_num AND user_num = $user_num AND people_type = 'Student'"));
|
|
// $query = "SELECT * FROM people WHERE school_num = $school_num AND user_num = $user_num AND people_type = 'Student' AND (class_num IS NULL OR class_num = 0)";
|
|
// $noClass = db_query($query);
|
|
// $numNoClass = db_num_rows($noClass);
|
|
$numNoClass = 0;
|
|
}
|
|
|
|
if (array_key_exists('record_num',$_SESSION['UserInfo'])) $usernum = intval($_SESSION['UserInfo']['record_num']);
|
|
}
|
|
|
|
|
|
$sYear = date("Y",time() - 60 * 60 * 24 * 365 * 30);
|
|
$eYear = date("Y",time() + 60 * 60 * 24 * 365 * 5);
|
|
|
|
?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
//
|
|
// File: jquery.hl.php
|
|
//
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
var schoolNum = '<?php echo($school_num) ?>';
|
|
var today = '<?php echo(date("Y-m-d",time())) ?>';
|
|
var action = '<?php echo($action) ?>';
|
|
var scheduleNum = '<?php echo($schedule_num) ?>';
|
|
var currencySymbol = '<?php echo($school_record['currency_symbol']) ?>';
|
|
|
|
var usernum = <?php echo($usernum) ?>;
|
|
|
|
$(document).on('focus', '.date-field', function() {
|
|
$(this).datepicker({
|
|
dateFormat: 'yy-mm-dd',
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
yearRange: "<?php echo($sYear) ?>:<?php echo($eYear) ?>"
|
|
});
|
|
$(this).attr("readonly", "readonly");
|
|
});
|
|
|
|
$(document).on('focus', '.date-monthyear-field', function() {
|
|
$(this).datepicker({
|
|
dateFormat: 'yy-mm-dd',
|
|
yearRange: '1900:<?php echo(date("Y",time())) ?>',
|
|
changeMonth: true,
|
|
changeYear: true
|
|
});
|
|
});
|
|
|
|
$(document).on('focus', '.time-field', function() {
|
|
$(this).datepicker({ timeFormat: 'HH:mm' });
|
|
});
|
|
|
|
$(document).on('focus', '.datetime-field', function() {
|
|
$(this).datetimepicker({
|
|
dateFormat: 'yy-mm-dd', timeFormat: 'HH:mm',
|
|
changeMonth: true,
|
|
changeYear: true
|
|
});
|
|
});
|
|
|
|
$('.cssplayMenu > ul > li').on("touchstart", function (e) {
|
|
'use strict'; //satisfy code inspectors
|
|
var link = $(this); //preselect the link
|
|
if (link.hasClass('hover')) {
|
|
return true;
|
|
}
|
|
else {
|
|
link.addClass('hover');
|
|
$('ul > li').not(this).removeClass('hover');
|
|
e.preventDefault();
|
|
return false; //extra, and to make sure the function has consistent return points
|
|
}
|
|
});
|
|
|
|
|
|
|
|
$("#site-links").hide();
|
|
|
|
<?php if ($userType == 'Admin') { ?>
|
|
$("#content-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 950,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#unallocated-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 500,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#payment-edit-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#text-info-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 900,
|
|
minHeight: 500,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#clear-selected-balances-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 900,
|
|
minHeight: 500,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#supplier-sales-csv-dates-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#supplier-sales-csv-schedules-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 600,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
<?php if ($school_record['event_calendar'] == 'Y' && $school_record['reseller'] != 'hotlunch') { ?>
|
|
$("#event-copy-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
<?php } ?>
|
|
|
|
|
|
<?php
|
|
if (isset($printButtons) && $printButtons == 'Included') {
|
|
if ($schedule_num > 0) {
|
|
?>
|
|
$("#multi-order-discounts-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 500,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
|
|
<?php echo("// <" . $action . " jquery.hl.php >\n"); ?>
|
|
<?php if ($action == 'invoices') echo("// HERE\n"); ?>
|
|
|
|
<?php if (isset($schoolsList) || isset($action) && ($action == 'schools' || $action == 'schools-list' || $action == 'invoices')) { ?>
|
|
$("#expiry-date-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#reseller-expiry-date-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#status-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$("#configuration-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
<?php } ?>
|
|
|
|
<?php if (isset($action) && $action == 'user-balances') { ?>
|
|
$("#clear-selected-balances-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 400,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
<?php } ?>
|
|
|
|
$(".form-field").tooltip({
|
|
position: { my: "left+400 top-5", at: "left top", collision: "flipfit" },
|
|
show: { effect: "fade", delay: 200 },
|
|
hide: false,
|
|
content: function() { return $(this).prop('title'); }
|
|
});
|
|
|
|
$(".title-text").tooltip({
|
|
position: { my: "left+400 top-5", at: "left top", collision: "flipfit" },
|
|
show: { effect: "fade", delay: 200 },
|
|
hide: false,
|
|
content: function() { return $(this).prop('title'); }
|
|
});
|
|
|
|
<?php if (isset($action) && $action == 'user-account') { ?>
|
|
<?php
|
|
if ($school_record['select_transactions_on_post'] == 'Y' && $postToTRX > 0) {
|
|
// Check for any unallocated payment entries
|
|
$unallocated = db_query("SELECT * FROM user_account_detail AS uad, user_account AS ua " .
|
|
"WHERE uad.school_num = $school_num " .
|
|
"AND ua.school_num = $school_num " .
|
|
"AND uad.user_num = $user_num " .
|
|
"AND uad.posted_to_transaction = 0 " .
|
|
"AND uad.posted_amount > 0 " .
|
|
"AND uad.deleted != 'Y' " .
|
|
"AND uad.transaction_num = ua.record_num " .
|
|
"AND ua.deleted != 'Y' " .
|
|
"ORDER BY uad.record_num LIMIT 0,1");
|
|
if (db_num_rows($unallocated)) {
|
|
$row = db_fetch_assoc($unallocated);
|
|
$unallocated_amount = $row['posted_amount'];
|
|
$unallocated_trx = $row['transaction_num'];
|
|
?>
|
|
// $(window).bind('load', function() {
|
|
// var trx_num = <?php echo($unallocated_trx) ?>;
|
|
// var unallocated = <?php echo($unallocated_amount) ?>;
|
|
// var user_num = <?php echo($user_num) ?>;
|
|
//
|
|
// $("#unallocated_amt").val(unallocated);
|
|
// $("#unallocated_trx").val(trx_num);
|
|
// $("#user_num").val(user_num);
|
|
// $("#unallocated-dialog").dialog("open");
|
|
// });
|
|
|
|
$("#apply-unallocated-btn").click(function(e) {
|
|
e.preventDefault();
|
|
var trx_num = $("#unallocated_trx").val();
|
|
var unallocated_amt = $("#unallocated_amt").val();
|
|
var user_num = $("#user_num").val();
|
|
var amt = $("#selected_trx option:selected").attr('amt');
|
|
var trx = $("#selected_trx option:selected").val();
|
|
|
|
var data = "user_num=" + user_num +
|
|
"&payment_trx=" + trx_num +
|
|
"&unallocated_amt=" + unallocated_amt +
|
|
"&trx_amt=" + amt +
|
|
"&trx_num=" + trx;
|
|
|
|
$.getJSON("ajax.ApplyCredit.php", data,
|
|
function(results) {
|
|
// Refresh page
|
|
$("#unallocated-dialog").dialog("close");
|
|
alert("<?php displayLanguageText('TEXT-CREDIT-APPLIED'); ?>");
|
|
location.reload();
|
|
}
|
|
);
|
|
});
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
|
|
$("#transaction_type").change(function() {
|
|
var trxtype = $("#transaction_type").val();
|
|
|
|
<?php if ($school_record['select_transactions_on_post'] == 'Y') { ?>
|
|
switch (trxtype) {
|
|
<?php
|
|
$fp = fopen('transaction_types_payments.txt','r');
|
|
while (!feof($fp)) {
|
|
$entry = trim(fgets($fp,1000));
|
|
if (strlen($entry)) echo(" case '$entry':\n");
|
|
}
|
|
fclose($fp);
|
|
?>
|
|
return;
|
|
|
|
default:
|
|
$("#selected_transactions").val(0);
|
|
break;
|
|
}
|
|
<?php } ?>
|
|
});
|
|
|
|
$("#selected_transactions").change(function() {
|
|
var trxtype = $("#transaction_type").val();
|
|
var trxamt = $("#transaction_amount").val();
|
|
var amt = 0;
|
|
|
|
if (trxtype != 'Payment') return;
|
|
|
|
$("#selected_transactions option:selected").each(function() {
|
|
amt = Math.abs(amt) + Math.abs($(this).attr('amt'));
|
|
});
|
|
|
|
// $("#trx_total").val(amt.toFixed(2));
|
|
});
|
|
|
|
$("#paymentform").submit(function() {
|
|
// Validate form values
|
|
var trxtype = $("#transaction_type").val();
|
|
var payment_method = $("#payment_method").val();
|
|
var schedule_num = $("#schedule_num").val();
|
|
var reference = $("#payment_reference").val();
|
|
var trxamt = $("#transaction_amount").val();
|
|
var owing = $("#amt").val();
|
|
|
|
if (trxtype == '') {
|
|
alert("Transaction type has not been specified");
|
|
$("#transaction_type").focus();
|
|
return false;
|
|
}
|
|
|
|
if (trxtype == 'Payment' && payment_method == '') {
|
|
alert("Payment Method is required for transaction type of Payment");
|
|
$("#payment_method").focus();
|
|
return false;
|
|
}
|
|
|
|
if (payment_method == 'Check' && reference == '') {
|
|
alert("Please enter the <?php displayLanguageText('TEXT-CHECK'); ?> number");
|
|
$("#payment_reference").focus();
|
|
return false;
|
|
}
|
|
|
|
if (trxamt == 0) {
|
|
alert("Transaction amount cannot be zero");
|
|
return false;
|
|
}
|
|
|
|
<?php if ($school_record['schedule_required_on_post'] == 'Y') { ?>
|
|
if (schedule_num == 0) {
|
|
alert("Schedule has not been specified");
|
|
$("#schedule_num").focus();
|
|
return false;
|
|
}
|
|
|
|
<?php } ?>
|
|
<?php if ($school_record['select_transactions_on_post'] == 'Y') { ?>
|
|
switch (trxtype) {
|
|
<?php
|
|
$fp = fopen('transaction_types_payments.txt','r');
|
|
while (!feof($fp)) {
|
|
$entry = trim(fgets($fp,1000));
|
|
if (strlen($entry)) echo(" case '$entry':\n");
|
|
}
|
|
fclose($fp);
|
|
?>
|
|
if ($("#selected_transactions").length > 0) {
|
|
var selected_trx = $("#selected_transactions").val() || [];
|
|
if (selected_trx.length == 0) {
|
|
alert("Transactions are available for posting\nPlease select transactions");
|
|
return(false);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
<?php } ?>
|
|
});
|
|
<?php } ?>
|
|
|
|
$(".edit-payment-method").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var tableName = "user_account";
|
|
var rnum = $(this).attr('rnum');
|
|
$.getJSON("ajax.DataRecord.Fetch.php",
|
|
{
|
|
table_name: tableName,
|
|
record_num: rnum
|
|
},
|
|
function(results) {
|
|
// Check for errors
|
|
if (results.ajax_return_code == 0) {
|
|
alert("<?php displayLanguageText('RECORD-NOT-FOUND-MSG'); ?>");
|
|
return;
|
|
}
|
|
|
|
// Display data
|
|
$("#pu_payment_method").val(results.payment_method);
|
|
$("#pu_note").val(results.note);
|
|
$("#pu_payment_reference").val(results.payment_reference);
|
|
$("#pu_record_num").val(results.record_num);
|
|
$("#payment-edit-dialog").dialog("open");
|
|
}
|
|
);
|
|
|
|
});
|
|
|
|
$("#save-payment-info-btn").click(function(e) {
|
|
e.preventDefault();
|
|
savePaymentEdit();
|
|
});
|
|
|
|
$("#payment-edit-form").submit(function(e) {
|
|
savePaymentEdit();
|
|
});
|
|
|
|
function savePaymentEdit() {
|
|
var payment_method = $("#pu_payment_method").val();
|
|
var note = $("#pu_note").val();
|
|
var payment_reference = $("#pu_payment_reference").val();
|
|
var record_num = $("#pu_record_num").val();
|
|
|
|
var data = "table_name=user_account" +
|
|
"&action=edit-payment-method" +
|
|
"&record_num=" + record_num +
|
|
"¬e=" + note +
|
|
"&payment_method=" + payment_method +
|
|
"&payment_reference=" + payment_reference;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$("#note-"+record_num).html(note);
|
|
$("#payment-reference-"+record_num).html(payment_reference);
|
|
$("#payment-method-"+record_num).html(payment_method);
|
|
|
|
$("#payment-edit-dialog").dialog("close");
|
|
}
|
|
);
|
|
|
|
}
|
|
|
|
|
|
$(".toggle-reporting").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var schoolNum = $(this).attr('school_num');
|
|
var data = "&school_num="+schoolNum;
|
|
|
|
$.ajax({
|
|
url: "ajax.ToggleReporting.php",
|
|
data: data
|
|
});
|
|
|
|
});
|
|
|
|
|
|
<?php if (isset($schedule_num) && $schedule_num > 0) { ?>
|
|
// Multiple orders discounts code
|
|
$("#multi-order-discounts-button").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var schedule_num = $(this).attr('schedule_num');
|
|
var record_num = $("#sd_record_num").val();
|
|
|
|
$("#delete-button-span").show();
|
|
if (record_num == '0') $("#delete-button-span").hide();
|
|
|
|
$("#multi-order-discounts-dialog").dialog("open");
|
|
});
|
|
|
|
$("#save-multi-order-discount-btn").click(function(e) {
|
|
e.preventDefault();
|
|
var record_num = $("#sd_record_num").val();
|
|
|
|
var schedule_num1 = $("#schedule_num1").val();
|
|
var schedule_num2 = $("#schedule_num2").val();
|
|
var schedule_num3 = $("#schedule_num3").val();
|
|
var schedule_num4 = $("#schedule_num4").val();
|
|
|
|
var order2_percentage = $("#order2_percentage").val();
|
|
var order3_percentage = $("#order3_percentage").val();
|
|
var order4_percentage = $("#order4_percentage").val();
|
|
var order5_percentage = $("#order5_percentage").val();
|
|
|
|
if (schedule_num1 == 0 && schedule_num2 == 0 && schedule_num3 == 0 && schedule_num4 == 0) {
|
|
alert("<?php displayLanguageText('ERRORMSG-UNABLE-TO-SAVE'); ?>");
|
|
return;
|
|
}
|
|
|
|
if (order2_percentage == 0 && order3_percentage == 0 && order4_percentage == 0 && order5_percentage == 0) {
|
|
alert("<?php displayLanguageText('ERRORMSG-UNABLE-TO-SAVE'); ?>");
|
|
return;
|
|
}
|
|
|
|
var data = $("#multi-order-discount-form").serialize();
|
|
data += "&table_name=hotlunch_schedules_multi_order_discounts&record_num="+record_num;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
var rnum = results.record_num;
|
|
$("#sd_record_num").val(rnum);
|
|
$("#multi-order-discounts-dialog").dialog("close");
|
|
}
|
|
);
|
|
});
|
|
|
|
$("#delete-multi-order-discount-btn").click(function(e) {
|
|
e.preventDefault();
|
|
var record_num = $("#sd_record_num").val();
|
|
if (record_num == 0) return;
|
|
|
|
var ans = confirm("<?php displayLanguageText('TEXT-CONFIRM-DELETE'); ?>");
|
|
|
|
if (ans) {
|
|
// Delete entry
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: "ajax.DataRecord.Delete.php",
|
|
data: { table_name: "hotlunch_schedules_multi_order_discounts", record_num: record_num }
|
|
}).done(function(data) {
|
|
$("#schedule_num1").val(<?php echo($schedule_num) ?>);
|
|
$("#schedule_num2").val(0);
|
|
$("#schedule_num3").val(0);
|
|
$("#schedule_num4").val(0);
|
|
|
|
$("#order2_percentage").val(0);
|
|
$("#order3_percentage").val(0);
|
|
$("#order4_percentage").val(0);
|
|
$("#order5_percentage").val(0);
|
|
|
|
$("#sd_record_num").val(0);
|
|
|
|
$("#multi-order-discounts-dialog").dialog("close");
|
|
});
|
|
}
|
|
});
|
|
|
|
<?php } ?>
|
|
<?php if (isset($schoolsList) || isset($action) && ($action == 'schools' || $action == 'schools-list' || $action == 'invoices')) { ?>
|
|
// School expiry date
|
|
$(document).on("click", ".expiry-date", function(e) {
|
|
e.preventDefault();
|
|
|
|
var school_num = $(this).attr('snum');
|
|
var expiry_date = $(this).attr('edate');
|
|
|
|
$("#school_num").val(school_num);
|
|
$("#expiry_date").val(expiry_date);
|
|
|
|
$("#expiry-date-dialog").dialog("open");
|
|
});
|
|
|
|
// Update expiry_date
|
|
$("#save-expiry-date-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var record_num = $("#school_num").val();
|
|
var expiry_date = $("#expiry_date").val();
|
|
var data = "&table_name=schools&expiry_date="+expiry_date+"&record_num="+record_num;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
if ($("#info-ed-"+record_num).length) {
|
|
$("#info-ed-"+record_num).html(expiry_date);
|
|
$("#info-ed-"+record_num).attr('edate',expiry_date);
|
|
}
|
|
if ($("#ed-"+record_num).length) {
|
|
$("#ed-"+record_num).html(expiry_date);
|
|
$("#ed-"+record_num).attr('edate',expiry_date);
|
|
}
|
|
$("#expiry-date-dialog").dialog("close");
|
|
}
|
|
);
|
|
});
|
|
|
|
<?php
|
|
$yr = date("Y",time());
|
|
$mo = date("m",time());
|
|
if ($mo >= '05') $yr = intval($yr) + 1;;
|
|
$newDate = $yr . "-07-31";
|
|
?>
|
|
$("#update-reseller-renewal").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var rsid = $(this).attr('rsid');
|
|
|
|
$("#rsid").val(rsid);
|
|
$("#rsid-span").html(rsid);
|
|
$("#reseller_expiry_date").val('<?php echo($newDate) ?>');
|
|
$("#reseller-expiry-date-dialog").dialog("open");
|
|
});
|
|
|
|
|
|
// Update reseller expiry_date
|
|
$("#save-reseller-expiry-date-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var rsid = $("#rsid").val();
|
|
var expiry_date = $("#reseller_expiry_date").val();
|
|
var data = "&table_name=schools&expiry_date="+expiry_date+"&rsid="+rsid;
|
|
|
|
$.getJSON("ajax.ResellerRenewal.Update.php", data,
|
|
function(results) {
|
|
location.reload();
|
|
}
|
|
);
|
|
$("#reseller-expiry-date-dialog").dialog("close");
|
|
});
|
|
|
|
|
|
// School status
|
|
$(document).on("click", ".status", function(e) {
|
|
e.preventDefault();
|
|
|
|
var school_num = $(this).attr('snum');
|
|
var status = $(this).attr('status');
|
|
|
|
$("#school_num").val(school_num);
|
|
$("#status").val(status);
|
|
|
|
$("#status-dialog").dialog("open");
|
|
});
|
|
|
|
// Update status
|
|
$("#save-status-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var record_num = $("#school_num").val();
|
|
var status = $("#status").val();
|
|
var data = "&table_name=schools&status="+status+"&record_num="+record_num;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$("#status-"+record_num).html(status);
|
|
$("#status-"+record_num).attr('status',status);
|
|
$("#status-dialog").dialog("close");
|
|
}
|
|
);
|
|
});
|
|
|
|
// School support level
|
|
$(document).on("click", ".support", function(e) {
|
|
e.preventDefault();
|
|
|
|
var record_num = $(this).attr('snum');
|
|
var support = $(this).attr('support');
|
|
var new_support;
|
|
|
|
if (support == 'Full Support') {
|
|
new_support = 'No Support';
|
|
}
|
|
|
|
if (support == 'No Support') {
|
|
new_support = 'Full Support';
|
|
}
|
|
|
|
var data = "&table_name=schools&support_level="+new_support+"&record_num="+record_num;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$("#support-"+record_num).html(new_support);
|
|
$("#support-"+record_num).attr('support',new_support);
|
|
}
|
|
);
|
|
});
|
|
|
|
// School configuration
|
|
$(document).on("click", ".configuration", function(e) {
|
|
e.preventDefault();
|
|
|
|
var school_num = $(this).attr('snum');
|
|
var configuration = $(this).attr('config');
|
|
|
|
$("#school_num").val(school_num);
|
|
$("#configuration").val(configuration);
|
|
|
|
$("#configuration-dialog").dialog("open");
|
|
});
|
|
|
|
// Update configuration
|
|
$("#save-configuration-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var record_num = $("#school_num").val();
|
|
var configuration = $("#configuration").val();
|
|
|
|
if (configuration == 'Basic') {
|
|
configuration = 'Standard';
|
|
}
|
|
|
|
if (configuration == 'Full') {
|
|
var data = "&table_name=schools&system_configuration="+configuration+"&record_num="+record_num+"&email_system=Y&other_modules=Y&event_calendar=Y";
|
|
}
|
|
|
|
if (configuration == 'Standard') {
|
|
var data = "&table_name=schools&system_configuration="+configuration+"&record_num="+record_num+"&email_system=N&other_modules=N&event_calendar=N";
|
|
}
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
$("#config-"+record_num).html(configuration);
|
|
$("#config-"+record_num).attr('config',configuration);
|
|
$("#configuration-dialog").dialog("close");
|
|
}
|
|
);
|
|
});
|
|
<?php } ?>
|
|
|
|
<?php if (isset($action) && ($action == 'user-balances' || $action == 'user-account-list')) { ?>
|
|
// User balances update
|
|
$("#clear-selected-balances").click(function(e) {
|
|
e.preventDefault();
|
|
$("#selected_balance").val('All');
|
|
$("#posting_message").val("<?php displayLanguageText('TEXT-ACCOUNT-BALANCE-POSTED-TO-ZERO'); ?>");
|
|
$("#clear-selected-balances-dialog").dialog("open");
|
|
});
|
|
|
|
$("#clear-selected-user-balances-btn").click(function(e) {
|
|
e.preventDefault();
|
|
var selectedSchool = $("#selected_school_num").val();
|
|
var sname = $("#name"+selectedSchool).val();
|
|
var selectedBalance = $("#selected_balance").val();
|
|
var postingMessage = $("#posting_message").val();
|
|
|
|
if (postingMessage.length == 0) {
|
|
alert("<?php displayLanguageText('ERRORMSG-MISSING-DATA'); ?>\n-- "+sname+" --");
|
|
return;
|
|
}
|
|
|
|
var ans = confirm("<?php displayLanguageText('TEXT-CONFIRM-UPDATE'); ?>\n-- "+sname+" --\n-- "+selectedBalance+" --");
|
|
|
|
if (ans) {
|
|
var data = "&selected_school_num="+selectedSchool+"&selected_balance="+selectedBalance+"&posting_message="+postingMessage;
|
|
$.ajax({
|
|
url: "ajax.ClearUserBalances.php",
|
|
data: data
|
|
});
|
|
|
|
$("#clear-selected-balances-dialog").dialog("close");
|
|
}
|
|
});
|
|
|
|
$("#close-clear-selected-user-balances-btn").click(function(e) {
|
|
e.preventDefault();
|
|
$("#clear-selected-balances-dialog").dialog("close");
|
|
});
|
|
<?php } ?>
|
|
|
|
$(document).on('click','.update-staff-class',function() {
|
|
var fname = $(this).attr('fname');
|
|
var cnum = $(this).attr('cnum');
|
|
var tnum = $("#"+fname).val();
|
|
|
|
if (tnum > 0) {
|
|
var data = "table_name=people" +
|
|
"&record_num=" + tnum +
|
|
"&class_num=" + cnum;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
// Display message
|
|
alert("<?php displayLanguageText('RECORD-UPDATED-MSG'); ?>");
|
|
}
|
|
);
|
|
}
|
|
});
|
|
|
|
$(document).on('click', '.trx-history', function(e) {
|
|
e.preventDefault();
|
|
var rnum = $(this).attr('rnum');
|
|
|
|
var data = "table_name=user_account"+
|
|
"&sequence_flag=N"+
|
|
"&action=trx-history"+
|
|
"&table_id="+
|
|
"&rnum="+rnum;
|
|
|
|
// Get history text
|
|
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
|
function(results) {
|
|
$("#info-content").html(results.content);
|
|
$("#text-info-dialog").dialog("open");
|
|
}
|
|
);
|
|
});
|
|
|
|
$("#close-info-dialog-btn").click(function(e) {
|
|
$("#text-info-dialog").dialog("close");
|
|
});
|
|
|
|
$("#supplier-sales-csv").click(function(e) {
|
|
e.preventDefault();
|
|
$("#supplier-sales-csv-dates-dialog").dialog("open");
|
|
});
|
|
|
|
$("#generate-sales-csv-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var startMonth = $("#start_month").val();
|
|
var endMonth = $("#end_month").val();
|
|
|
|
$("#supplier-sales-csv-dates-dialog").dialog("close");
|
|
window.location.href = "?action=supplier-product-sales-csv&start_month="+startMonth+"&end_month="+endMonth;
|
|
});
|
|
|
|
$("#supplier-sales-schedule-csv").click(function(e) {
|
|
e.preventDefault();
|
|
$("#supplier-sales-csv-schedules-dialog").dialog("open");
|
|
});
|
|
|
|
$("#generate-schedule-sales-csv-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var formData = $("#supplier-sales-schedule-form").serialize();
|
|
|
|
window.location.href = "?action=supplier-sales-schedule-csv&"+formData;
|
|
$("#supplier-sales-csv-schedules-dialog").dialog("close");
|
|
});
|
|
|
|
<?php if ($school_record['event_calendar'] == 'Y' && $school_record['reseller'] != 'hotlunch') { ?>
|
|
$(document).on('click touch',"#event-copy", function(e) {
|
|
e.preventDefault();
|
|
$("#event-copy-dialog").dialog('open');
|
|
});
|
|
|
|
$("#copy-events").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var source = $("#source_school").val();
|
|
var start_date = $("#event_start_date").val();
|
|
|
|
var ans = confirm("<?php displayLanguageText('TEXT-CONFIRM-UPDATE'); ?>");
|
|
|
|
if (ans) {
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: "ajax.EventsCopy.php",
|
|
data: { source_school: source, start_date: start_date }
|
|
}).done(function(data) {
|
|
$("#event-copy-dialog").dialog('close');
|
|
alert("<?php displayLanguageText('TEXT-COMPLETED'); ?>");
|
|
});
|
|
}
|
|
});
|
|
|
|
$("#close-event-copy").click(function(e) {
|
|
e.preventDefault();
|
|
$("#event-copy-dialog").dialog('close');
|
|
});
|
|
<?php } ?>
|
|
|
|
<?php if ($action == 'schedule-cafeteria') { ?>
|
|
$("#cafeteria-order-dialog").dialog({
|
|
autoOpen: false,
|
|
width: 'auto',
|
|
maxWidth: 900,
|
|
height: 'auto',
|
|
minHeight: 600,
|
|
modal: true,
|
|
fluid: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$(document).on('click touch', '#cafeteria-view-students', function(e) {
|
|
e.preventDefault();
|
|
loadStudents();
|
|
});
|
|
|
|
$(document).on('change', '#selected_class', function() {
|
|
loadStudents();
|
|
});
|
|
|
|
function loadStudents() {
|
|
var menuNum = $("#menu_date").val();
|
|
var classNum = $("#selected_class").val();
|
|
|
|
var data = "table_name=students"+
|
|
"&sequence_flag=N"+
|
|
"&action=cafeteria-students"+
|
|
"&menuNum="+menuNum+
|
|
"&classNum="+classNum;
|
|
|
|
// Get history text
|
|
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
|
function(results) {
|
|
$("#manage-orders-span").html(results.content);
|
|
}
|
|
);
|
|
}
|
|
|
|
$(document).on('click touch', '.cafeteria-student-entry', function() {
|
|
var studentNum = $(this).attr('rnum');
|
|
var studentName = $(this).attr('name');
|
|
|
|
loadCafeteriaMenu(studentNum);
|
|
});
|
|
|
|
function loadCafeteriaMenu(studentNum) {
|
|
var menuNum = $("#menu_date").val();
|
|
var classNum = $("#selected_class").val();
|
|
var data = "table_name=hotlunch_order_items"+
|
|
"&sequence_flag=N"+
|
|
"&action=cafeteria-student-menu"+
|
|
"&scheduleNum="+scheduleNum+
|
|
"&menuNum="+menuNum+
|
|
"&classNum="+classNum+
|
|
"&studentNum="+studentNum;
|
|
|
|
// Get order menu
|
|
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
|
function(results) {
|
|
$("#order-content").html(results.content);
|
|
$("#cafeteria-order-dialog").dialog("open");
|
|
$("[tabindex=1]").select();
|
|
}
|
|
);
|
|
}
|
|
|
|
$("#close-cafeteria-order").click(function() {
|
|
$("#cafeteria-order-dialog").dialog("close");
|
|
});
|
|
|
|
$(document).on('click touch', '.minus', function(e) {
|
|
e.preventDefault();
|
|
|
|
var itemNum = $(this).attr('item_num');
|
|
var price = $(this).attr('price');
|
|
var qty = $("#qty_"+itemNum).val();
|
|
|
|
calcLine(itemNum,price,qty,'minus');
|
|
});
|
|
|
|
$(document).on('click touch', '.plus', function(e) {
|
|
e.preventDefault();
|
|
|
|
var itemNum = $(this).attr('item_num');
|
|
var price = $(this).attr('price');
|
|
var qty = $("#qty_"+itemNum).val();
|
|
|
|
calcLine(itemNum,price,qty,'plus');
|
|
});
|
|
|
|
$(document).on('blur', '.cafeteria-qty', function() {
|
|
var itemNum = $(this).attr('item_num');
|
|
var price = $(this).attr('price');
|
|
var qty = $("#qty_"+itemNum).val();
|
|
var prevQty = $("#prev_qty_"+itemNum).val();
|
|
|
|
if (qty != prevQty) {
|
|
calcLine(itemNum,price,qty,'amount');
|
|
}
|
|
});
|
|
|
|
$(document).on('click', '.cafeteria-checkbox', function() {
|
|
var itemNum = $(this).attr('item_num');
|
|
var price = $(this).attr('price');
|
|
var qty = 0;
|
|
if ($(this).prop('checked')) qty = 1;
|
|
|
|
calcLine(itemNum,price,qty,'amount');
|
|
});
|
|
|
|
function calcLine(itemNum,price,qty,action) {
|
|
var sign = '';
|
|
|
|
switch (action) {
|
|
case 'plus':
|
|
qty = parseInt(qty) + 1;
|
|
break;
|
|
|
|
case 'minus':
|
|
if (qty == '0') return;
|
|
qty = parseInt(qty) - 1;
|
|
break;
|
|
|
|
case 'amount':
|
|
break;
|
|
}
|
|
|
|
$("#qty_"+itemNum).val(qty);
|
|
$("#prev_qty_"+itemNum).val(qty);
|
|
|
|
if (parseFloat(price) < 0) sign = '- ';
|
|
|
|
var total = parseInt(qty) * Math.abs(price);
|
|
var lineTotal = "";
|
|
if (total != 0) lineTotal = sign+currencySymbol+total.toFixed(2);
|
|
$("#total_"+itemNum).html(lineTotal);
|
|
|
|
if (price < 0) $("#total-"+itemNum).val(-1 * total);
|
|
else $("#total-"+itemNum).val(total);
|
|
|
|
calcTotal();
|
|
<?php if (array_key_exists('UserInfo', $_SESSION) && $_SESSION['UserInfo']['type'] == 'SuperUser') { ?>
|
|
updateItem(itemNum,price,qty,total);
|
|
<?php } ?>
|
|
}
|
|
|
|
function calcTotal() {
|
|
var grandTotal = 0;
|
|
var lineTotal;
|
|
var sign = '';
|
|
|
|
$(".line-total").each(function(i, obj) {
|
|
lineTotal = $(this).val();
|
|
grandTotal = parseFloat(grandTotal) + parseFloat(lineTotal);
|
|
});
|
|
|
|
if (grandTotal < 0) sign = '- ';
|
|
|
|
$("#cafeteria-total").html(sign+currencySymbol+grandTotal.toFixed(2));
|
|
}
|
|
|
|
<?php if (array_key_exists('UserInfo', $_SESSION) && $_SESSION['UserInfo']['type'] == 'SuperUser') { ?>
|
|
function updateItem(itemNum,price,qty,total) {
|
|
var orderNum = $("#cafeteria_order_num").val();
|
|
var scheduleNum = $("#cafeteria_schedule_num").val();
|
|
var menuNum = $("#cafeteria_menu_num").val();
|
|
var studentNum = $("#cafeteria_student_num").val();
|
|
|
|
alert("Schedule: "+scheduleNum+"\nMenu: "+menuNum+"\nItem: "+itemNum+"\nQty: "+qty+"\nPrice: "+price+"\nLine Total: "+total+"\nStudent: "+studentNum+"\nOrder: "+orderNum);
|
|
}
|
|
<?php } ?>
|
|
<?php } ?>
|
|
|
|
<?php } ?>
|
|
|
|
$(".btn-apply-credit").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var order_num = $(this).attr('onum');
|
|
var order_total = $(this).attr('ototal');
|
|
var payment_method = "Account Credit";
|
|
|
|
var data = "table_name=hotlunch_order_header" +
|
|
"&record_num=" + order_num +
|
|
"&amount_paid=" + order_total +
|
|
"&payment_method=" + payment_method +
|
|
"&paid_date=" + today +
|
|
"&status=Paid"+
|
|
"&UpdateAll=Yes";
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
// Refresh page
|
|
alert("<?php displayLanguageText('TEXT-CREDIT-APPLIED'); ?>");
|
|
location.reload();
|
|
}
|
|
);
|
|
});
|
|
|
|
|
|
// Select list navigation
|
|
$(document).on('change','.navigation-select',function(e) {
|
|
e.preventDefault();
|
|
|
|
var nav = $(this).val();
|
|
window.location.href = nav;
|
|
});
|
|
|
|
|
|
// alert("Warning: the application is going down for system maintenance at 9:00pm PST\nPlease save any work and exit.");
|
|
|
|
});
|
|
</script>
|