445 lines
15 KiB
Plaintext
445 lines
15 KiB
Plaintext
<script>
|
|
$(document).ready(function() {
|
|
|
|
var authCode = '<?php echo($authCode) ?>';
|
|
var today = '<?php echo(date("Y-m-d",time())) ?>';
|
|
|
|
$(".date-field").datepicker({ dateFormat: 'yy-mm-dd' });
|
|
$(".datetime-field").datetimepicker({ dateFormat: 'yy-mm-dd', timeFormat: 'HH:mm' });
|
|
|
|
$("#receipt-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 750,
|
|
modal: true,
|
|
position: ['center',100],
|
|
<?php if (isset($action) && $action == 'receipt') { ?>
|
|
close: function(event, ui) {
|
|
location.assign("/");
|
|
}
|
|
<?php } ?>
|
|
});
|
|
|
|
$("#content-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 950,
|
|
modal: true,
|
|
position: ['center','top']
|
|
});
|
|
|
|
$("#unallocated-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 500,
|
|
modal: true,
|
|
position: ['center',200]
|
|
});
|
|
|
|
$("#payment-edit-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 300,
|
|
modal: true,
|
|
position: ['center',200]
|
|
});
|
|
|
|
<?php if (isset($schedule_num) || (isset($_GET['schedule_num']) && $_GET['schedule_num'] > 0)) { ?>
|
|
|
|
$("#sibling-discounts-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 500,
|
|
modal: true,
|
|
position: ['center',100]
|
|
});
|
|
<?php } ?>
|
|
|
|
$(".form-field").tooltip({
|
|
position: { my: "left+5 top+5", at: "left bottom", collision: "flipfit" },
|
|
show: { effect: "fade", delay: 200 },
|
|
hide: false
|
|
});
|
|
|
|
<?php if (!isset($action) || $action != 'receipt-print') { ?>
|
|
CKEDITOR.replace( 'content_field', {
|
|
filebrowserBrowseUrl : '/FileManager/index.html',
|
|
filebrowserImageBrowseUrl : '/FileManager/index.html',
|
|
filebrowserFlashBrowseUrl : '/FileManager/index.html',
|
|
}
|
|
);
|
|
|
|
$("#edit-description").click(function(e) {
|
|
e.preventDefault();
|
|
var content = $("#description").val();
|
|
CKEDITOR.instances['content_field'].resize('100%',400);
|
|
CKEDITOR.instances['content_field'].setData(content);
|
|
$("#content-dialog").dialog("open");
|
|
$("#content-dialog").dialog("close");
|
|
$("#content-dialog").dialog("open");
|
|
});
|
|
|
|
$("#save-content-btn").click(function(e) {
|
|
e.preventDefault();
|
|
var content = CKEDITOR.instances.content_field.getData();
|
|
$("#description").val(content);
|
|
$("#content-dialog").dialog("close");
|
|
});
|
|
|
|
$("#close-content-btn").click(function(e) {
|
|
e.preventDefault();
|
|
$("#content-dialog").dialog("close");
|
|
});
|
|
<?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&auth=" + authCode +
|
|
"&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();
|
|
}
|
|
);
|
|
});
|
|
|
|
<?php if (isset($action) && $action == 'receipt') { ?>
|
|
$(window).bind('load', function() {
|
|
loadReceipt(<?php echo($trx_num) ?>);
|
|
});
|
|
<?php } ?>
|
|
|
|
<?php if (isset($action) && $action == 'receipt-print') { ?>
|
|
loadReceipt(<?php echo($trx_num) ?>);
|
|
<?php } ?>
|
|
|
|
$(document).on("click", ".print-receipt", function(e) {
|
|
e.preventDefault();
|
|
var trxnum = $(this).attr('trx-num');
|
|
|
|
loadReceipt(trxnum);
|
|
});
|
|
|
|
function loadReceipt(trxnum) {
|
|
var data = "table_name=user_accout"+
|
|
"&sequence_flag=N"+
|
|
"&action=trx-receipt"+
|
|
"&table_id="+
|
|
"&trxnum="+trxnum+
|
|
"&auth="+authCode;
|
|
|
|
// Get receipt text
|
|
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
|
function(results) {
|
|
$("#receipt-content").html(results.content);
|
|
<?php if (!isset($action) || $action != 'receipt-print') { ?>
|
|
$("#receipt-dialog").dialog("open");
|
|
$("#receipt-content").printElement();
|
|
<?php } ?>
|
|
<?php if (isset($action) && $action == 'receipt-print') { ?>
|
|
window.print();
|
|
<?php } ?>
|
|
}
|
|
);
|
|
}
|
|
|
|
$("#print-receipt-btn").click(function(e) {
|
|
$("#receipt-content").printElement();
|
|
});
|
|
|
|
$("#close-receipt-btn").click(function(e) {
|
|
e.preventDefault();
|
|
$("#receipt-dialog").dialog("close");
|
|
<?php if (isset($action) && $action == 'receipt') { ?>
|
|
location.assign("/");
|
|
<?php } ?>
|
|
});
|
|
|
|
<?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 (mysql_num_rows($unallocated)) {
|
|
$row = mysql_fetch_array($unallocated,MYSQL_ASSOC);
|
|
$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 = "auth=" + authCode +
|
|
"&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();
|
|
}
|
|
);
|
|
});
|
|
<?
|
|
}
|
|
}
|
|
?>
|
|
|
|
$("#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));
|
|
echo(" case '$entry':\n");
|
|
}
|
|
?>
|
|
break;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
<?php } ?>
|
|
});
|
|
<?php } ?>
|
|
|
|
//
|
|
// Form processing
|
|
//
|
|
$("#submit-form-btn").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var errorFlag = false;
|
|
|
|
// Validate text fields
|
|
$(".text-required").each(function() {
|
|
var data = $(this).val();
|
|
$(this).parent().removeClass("form-field-div-error");
|
|
if (data.length == 0) {
|
|
errorFlag = true;
|
|
$(this).parent().addClass("form-field-div-error");
|
|
}
|
|
});
|
|
|
|
if (errorFlag) {
|
|
var msg = "Data is missing from form";
|
|
alert(msg);
|
|
return(false);
|
|
}
|
|
});
|
|
|
|
$(".text-required").blur(function() {
|
|
var data = $(this).val();
|
|
if (data.length > 0) {
|
|
$(this).parent().removeClass("form-field-div-error");
|
|
}
|
|
else {
|
|
$(this).parent().addClass("form-field-div-error");
|
|
}
|
|
});
|
|
|
|
$(".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,
|
|
auth: authCode
|
|
},
|
|
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&auth=" + authCode +
|
|
"&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+"&auth="+authCode;
|
|
|
|
$.ajax({
|
|
url: "ajax.ToggleReporting.php",
|
|
data: data
|
|
});
|
|
|
|
});
|
|
|
|
|
|
<?php if (isset($schedule_num) || (isset($_GET['schedule_num']) && $_GET['schedule_num'] > 0)) { ?>
|
|
// Sibling discounts code
|
|
$("#sibling-discounts-button").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var schedule_num = $(this).attr('schedule_num');
|
|
|
|
$("#sibling-discounts-dialog").dialog("open");
|
|
});
|
|
|
|
$("#save-sibling-discount-btn").click(function(e) {
|
|
e.preventDefault();
|
|
var record_num = $("#sd_record_num").val();
|
|
var data = $("#sibling-discount-form").serialize();
|
|
data += "&table_name=hotlunch_schedules_sibling_discounts&auth="+authCode+"&record_num="+record_num;
|
|
|
|
$.getJSON("ajax.DataRecord.Update.php", data,
|
|
function(results) {
|
|
var rnum = results.record_num;
|
|
$("#sd_record_num").val(rnum);
|
|
$("#sibling-discounts-dialog").dialog("close");
|
|
}
|
|
);
|
|
});
|
|
|
|
<?php } ?>
|
|
|
|
});
|
|
</script>
|