450 lines
16 KiB
PHP
450 lines
16 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to list and edit records
|
|
//
|
|
$action = "user-account-detail";
|
|
$CurrentTable = "user_account_detail";
|
|
$FormFile = "";
|
|
$TitleText = getLanguageText('TEXT-USER-PAYMENT-DETAIL');
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = $TitleText;
|
|
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
if (!in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Financial','Financial Team'))) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
$school_num = $school_record['record_num'];
|
|
|
|
// Refresh the user account detail
|
|
// adjustUserAccountDetails(0);
|
|
|
|
|
|
$print_cmd = "";
|
|
|
|
// Handle selected date ranges
|
|
$start_date = date("Y-m-d 00:00:00",time());
|
|
$end_date = date("Y-m-d 23:59:59",time());
|
|
|
|
if (array_key_exists('start_date',$_REQUEST) && strlen($_REQUEST['start_date']) > 0) $start_date = date("Y-m-d 00:00:00",strtotime($_REQUEST['start_date']));
|
|
if (array_key_exists('end_date',$_REQUEST) && strlen($_REQUEST['end_date']) > 0) {
|
|
$end_date = $_REQUEST['end_date'];
|
|
if ($end_date < substr($start_date,0,10)) {
|
|
$end_date = substr($start_date,0,10);
|
|
$error_message = getLanguageText('ERRORMSG-INVALID-DATE-RANGE');
|
|
}
|
|
|
|
$end_date = date("Y-m-d 23:59:59",strtotime($end_date));
|
|
}
|
|
|
|
$sdate = substr($start_date,0,10);
|
|
$edate = substr($end_date,0,10);
|
|
|
|
$twhere .= "AND transaction_datetime BETWEEN '$start_date' AND '$end_date' ";
|
|
$print_cmd .= "&start_date=$sdate&end_date=$edate";
|
|
|
|
|
|
// View only a selected userid
|
|
$uwhere = "";
|
|
unset($selected_usernum);
|
|
if (array_key_exists('selected_usernum',$_REQUEST) && strlen($_REQUEST['selected_usernum']) > 0) {
|
|
$selected_usernum = intval($_REQUEST['selected_usernum']);
|
|
$userid = db_getVal("SELECT userid FROM users WHERE record_num = $selected_usernum");
|
|
$uwhere = "AND ua.user_num = $selected_usernum ";
|
|
$print_cmd .= "&selected_usernum=$selected_usernum";
|
|
}
|
|
|
|
|
|
// View only selected transaction types
|
|
unset($selected_transaction_type);
|
|
if (array_key_exists('selected_transaction_type',$_REQUEST) && strlen($_REQUEST['selected_transaction_type']) > 0) {
|
|
$selected_transaction_type = $_REQUEST['selected_transaction_type'];
|
|
$uwhere .= "AND ua.transaction_type = '$selected_transaction_type' ";
|
|
$print_cmd .= "&selected_transaction_type=$selected_transaction_type";
|
|
}
|
|
|
|
|
|
// View only selected payment methods
|
|
unset($selected_payment_method);
|
|
if (array_key_exists('selected_payment_method',$_REQUEST) && strlen($_REQUEST['selected_payment_method']) > 0) {
|
|
if (isset($selected_transaction_type) && $selected_transaction_type != 'Payment') unset($selected_payment_method);
|
|
else {
|
|
$selected_payment_method = $_REQUEST['selected_payment_method'];
|
|
$uwhere .= "AND ua.payment_method = '$selected_payment_method' ";
|
|
$print_cmd .= "&selected_payment_method=$selected_payment_method";
|
|
}
|
|
}
|
|
|
|
|
|
// View only selected schedule
|
|
$swhere = "";
|
|
$selected_schedule_num = 0;
|
|
if (array_key_exists('selected_schedule_num',$_REQUEST) && strlen($_REQUEST['selected_schedule_num']) > 0) {
|
|
$selected_schedule_num = intval($_REQUEST['selected_schedule_num']);
|
|
$uwhere .= "AND ud.posted_schedule = $selected_schedule_num ";
|
|
$print_cmd .= "&posted_schedule=$selected_schedule_num";
|
|
}
|
|
|
|
|
|
|
|
// Process an optional type parameter
|
|
unset($deleteType);
|
|
if (array_key_exists('type',$_REQUEST) && strlen($_REQUEST['type']) > 0 && $_REQUEST['type'] == 'deleted') {
|
|
$deleteType = $_REQUEST['type'];
|
|
$uwhere .= "AND ua.deleted = 'Y' ";
|
|
$print_cmd .= "&type=$deleteType";
|
|
}
|
|
else {
|
|
$deleteType = "active";
|
|
$uwhere .= "AND (ua.deleted != 'Y' OR ua.deleted IS NULL) ";
|
|
}
|
|
|
|
|
|
// Set query sort order
|
|
$order_by = "ORDER BY transaction_datetime,ua.record_num,ud.record_num";
|
|
$sort = "Date";
|
|
if (array_key_exists('sort',$_REQUEST) && strlen($_REQUEST['sort'])) {
|
|
$sort = $_REQUEST['sort'];
|
|
if ($sort == 'Name') $order_by = "ORDER BY last_name,first_name,transaction_datetime,ua.record_num,ud.record_num";
|
|
}
|
|
$print_cmd .= "&sort=$sort";
|
|
|
|
|
|
|
|
|
|
$message_width = 600;
|
|
include "form.messages.php";
|
|
|
|
?>
|
|
<form method='post' name='transactions'>
|
|
<table width='750' cellpadding='3' class='content-table'>
|
|
<tr>
|
|
<td align='center'>
|
|
<table>
|
|
<tr>
|
|
<td align='left'><?php displayLanguageText('TEXT-START-DATE'); ?>:<br>
|
|
<input type='text' name='start_date' id='start_date' value='<?php echo($sdate) ?>' size='15' class='date-field'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left'><?php displayLanguageText('TEXT-END-DATE'); ?>:<br>
|
|
<input type='text' name='end_date' id='end_date' value='<?php echo($edate) ?>' size='15' class='date-field'></td>
|
|
</tr>
|
|
<!--
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-USER'); ?>:<br>
|
|
<select name='selected_usernum'>
|
|
<option value=''><?php displayLanguageText('TEXT-VIEW-ALL'); ?></option>
|
|
<?php
|
|
// List userid's from users table
|
|
$results = db_query("select userid,concat_ws(' ',first_name,last_name) as name,type,record_num from users where school_num = $base_school_num order by last_name,first_name");
|
|
while ($row = db_fetch_array($results)) {
|
|
$userid = $row['userid'];
|
|
$name = $row['name'];
|
|
$type = $row['type'];
|
|
$rnum = $row['record_num'];
|
|
|
|
$selected = "";
|
|
if (isset($selected_usernum) && $selected_usernum == $rnum) $selected = " selected='selected'";
|
|
echo(" <option value='$rnum'$selected>$name ($type - $userid)</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-TRANSACTION-TYPE'); ?>:<br>
|
|
<select name='selected_transaction_type'>
|
|
<option value=''><?php displayLanguageText('TEXT-VIEW-ALL'); ?></option>
|
|
<optgroup label="<?php displayLanguageText('TEXT-CHARGES-AND-FEES'); ?>">
|
|
<?php BuildFileList("transaction_types_charges.txt",$selected_transaction_type) ?>
|
|
<?php
|
|
$r = db_query("SELECT * FROM user_account_trx_codes WHERE school_num = $base_school_num AND trx_category = 'Charge' ORDER BY sequence");
|
|
if (db_num_rows($r)) {
|
|
while ($row = db_fetch_assoc($r)) {
|
|
$transaction_type_code = $row['transaction_type_code'];
|
|
$selected = "";
|
|
if ($transaction_type_code == $selected_transaction_type) $selected = " selected='selected'";
|
|
echo("<option value='$transaction_type_code'$selected>$transaction_type_code</option>\n");
|
|
}
|
|
}
|
|
?>
|
|
</optgroup>
|
|
<optgroup label="<?php displayLanguageText('TEXT-PAYMENTS-AND-CREDITS'); ?>">
|
|
<?php BuildFileList("transaction_types_payments.txt",$selected_transaction_type) ?>
|
|
<?php if ($selected_transaction_type == 'Complimentary Credit') $selected = " selected='selected'"; ?>
|
|
<option value='Complimentary Credit'<?php echo($selected) ?>>Complimentary Credit</option>
|
|
<?php
|
|
$r = db_query("SELECT * FROM user_account_trx_codes WHERE school_num = $base_school_num AND trx_category = 'Credit' ORDER BY sequence");
|
|
if (db_num_rows($r)) {
|
|
while ($row = db_fetch_assoc($r)) {
|
|
$transaction_type_code = $row['transaction_type_code'];
|
|
$selected = "";
|
|
if ($transaction_type_code == $selected_transaction_type) $selected = " selected='selected'";
|
|
echo("<option value='$transaction_type_code'$selected>$transaction_type_code</option>\n");
|
|
}
|
|
}
|
|
?>
|
|
</optgroup>
|
|
<optgroup label="<?php displayLanguageText('TEXT-OTHER'); ?>">
|
|
<?php BuildFileList("transaction_types_other.txt",$selected_transaction_type) ?>
|
|
<?php
|
|
$r = db_query("SELECT * FROM user_account_trx_codes WHERE school_num = $base_school_num AND trx_category = 'Note' ORDER BY sequence");
|
|
if (db_num_rows($r)) {
|
|
while ($row = db_fetch_assoc($r)) {
|
|
$transaction_type_code = $row['transaction_type_code'];
|
|
$selected = "";
|
|
if ($transaction_type_code == $selected_transaction_type) $selected = " selected='selected'";
|
|
echo("<option value='$transaction_type_code'$selected>$transaction_type_code</option>\n");
|
|
}
|
|
}
|
|
?>
|
|
</optgroup>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-PAYMENT-METHOD'); ?>:<br>
|
|
<select name='selected_payment_method'>
|
|
<option value=''><?php displayLanguageText('TEXT-VIEW-ALL'); ?></option>
|
|
<?php BuildFileList("payment_method.pp.txt",$selected_payment_method) ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
-->
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-SCHEDULE'); ?>:<br>
|
|
<select name='selected_schedule_num'>
|
|
<option value=''><?php displayLanguageText('TEXT-VIEW-ALL'); ?></option>
|
|
<?php
|
|
$end_date = date("Y-m-d",time() - 60 * 60 * 24 * 240);
|
|
$query = "SELECT schedule_name,record_num FROM hotlunch_schedules " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND schedule_end_date >= '$end_date' " .
|
|
"AND status != 'Deleted' " .
|
|
"ORDER BY schedule_start_date DESC";
|
|
$schedules = db_query($query);
|
|
while ($row = db_fetch_array($schedules)) {
|
|
$sname = $row['schedule_name'];
|
|
$rnum = $row['record_num'];
|
|
$selected = "";
|
|
if ($selected_schedule_num == $rnum) $selected = " selected='selected'";
|
|
echo(" <option value='$rnum'$selected>$sname</option>\n");
|
|
}
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<!--
|
|
<tr>
|
|
<td align='left' valign='top'><?php displayLanguageText('TEXT-REPORT-SORT'); ?>:<br>
|
|
<?php BuildFileRadio("user_account.report.sort.txt","sort",$sort) ?>
|
|
</td>
|
|
</tr>
|
|
-->
|
|
<tr>
|
|
<td align='left' valign='top'><a href='#' class='btn btn--primary btn--xsmall' onClick='document.transactions.submit();'><span><?php displayLanguageText('TEXT-VIEW'); ?></span></a></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='action' value='user-account-payment-detail'>
|
|
</form>
|
|
<?php
|
|
|
|
//
|
|
// List all requested records
|
|
//
|
|
$columnHeaders = array("User ID","TRX Date","TRX Type","Amount","Method","Payment","Posted To");
|
|
$columnAlign = array('left','center','center','right','center','right','center','left');
|
|
$query = "SELECT u.userid,substring(transaction_datetime,1,10) as trx_date,transaction_type,transaction_amount,transaction_status,schedule_num,order_num," .
|
|
"payment_method,payment_reference,u.first_name,u.last_name,ua.user_num,posted_to_transaction,posted_amount,posted_schedule,ua.record_num AS trx_num " .
|
|
"FROM user_account as ua LEFT JOIN people as p ON (p.school_num = $base_school_num AND ua.people_num = p.record_num), users AS u, user_account_detail AS ud " .
|
|
"WHERE u.school_num = $base_school_num " .
|
|
"AND ua.school_num = $school_num " .
|
|
"AND ud.school_num = $school_num " .
|
|
"AND ua.record_num = ud.transaction_num " .
|
|
"AND ua.user_num = u.record_num " .
|
|
"AND ua.transaction_amount < 0 " .
|
|
$uwhere . $twhere . $swhere .
|
|
$order_by;
|
|
echo("<!--\n$query\n-->\n");
|
|
$transactions = db_query($query);
|
|
|
|
if (db_num_rows($transactions)) {
|
|
?>
|
|
<br>
|
|
<table width='95%' class='content-table'>
|
|
<tr class='data-header'>
|
|
<?php
|
|
for ($i = 0; $i < count($columnHeaders); $i++) {
|
|
$title = $columnHeaders[$i];
|
|
$align = $columnAlign[$i];
|
|
echo(" <td align='$align'>$title</td>\n");
|
|
}
|
|
?>
|
|
</tr>
|
|
<?php
|
|
$payment_totals = array();
|
|
|
|
$count = 1;
|
|
$prev_trx = 0;
|
|
while ($row = db_fetch_assoc($transactions)) {
|
|
extract($row);
|
|
|
|
$ptrxNum = $row['posted_to_transaction'];
|
|
$pAmt = number_format(abs($row['posted_amount']),2);
|
|
$reference = $row['payment_reference'];
|
|
|
|
$method = $payment_method;
|
|
if (strlen($method) == 0) $method = $transaction_type;
|
|
|
|
if (isset($payment_totals[$method])) $payment_totals[$method] += $row['posted_amount'];
|
|
else $payment_totals[$method] = $row['posted_amount'];
|
|
|
|
if ($method == 'Check') $method .= " #$payment_reference";
|
|
|
|
$results = db_query("SELECT * FROM user_account WHERE school_num = $school_num AND record_num = $ptrxNum");
|
|
$row = db_fetch_assoc($results);
|
|
|
|
$trx_type = $row['transaction_type'];
|
|
if ($trx_type == 'Order') {
|
|
$trx_type .= " #" . $row['order_num'];
|
|
}
|
|
|
|
if ($trx_num != $prev_trx) {
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
|
|
$prev_trx = $trx_num;
|
|
|
|
$amt = "-$currencySymbol" . number_format(abs($transaction_amount),2);
|
|
|
|
echo(" <tr class='$class'>\n");
|
|
echo(" <td align='left'><span class='user-account' unum='$user_num'>$userid</span></td>\n");
|
|
echo(" <td align='center'>$trx_date</td>\n");
|
|
echo(" <td align='center'>$transaction_type</td>\n");
|
|
echo(" <td align='right'>$amt</td>\n");
|
|
|
|
echo(" <td align='center'>$method</td>\n");
|
|
echo(" <td align='right'>-$currencySymbol$pAmt</td>\n");
|
|
echo(" <td align='center'>$trx_type</td>\n");
|
|
}
|
|
else {
|
|
echo(" <tr class='$class'>\n");
|
|
echo(" <td align='left'></td>\n");
|
|
echo(" <td align='left'></td>\n");
|
|
echo(" <td align='left'></td>\n");
|
|
echo(" <td align='left'></td>\n");
|
|
echo(" <td align='center'>$method</td>\n");
|
|
echo(" <td align='right'>-$currencySymbol$pAmt</td>\n");
|
|
echo(" <td align='center'>$trx_type</td>\n");
|
|
}
|
|
|
|
echo(" </tr>\n");
|
|
}
|
|
|
|
?>
|
|
</table>
|
|
|
|
<br>
|
|
<table width='40%' class='content-table'>
|
|
<tr class='data-header'>
|
|
<td align='center'><?php displayLanguageText('TEXT-PAYMENT-METHOD'); ?></td>
|
|
<td align='right'><?php displayLanguageText('TEXT-AMOUNT'); ?> </td>
|
|
</tr>
|
|
<?php
|
|
$count = 1;
|
|
foreach ($payment_totals AS $key => $value) {
|
|
$method = $key;
|
|
$pAmt = number_format(abs($value),2);
|
|
|
|
$class = 'data-even';
|
|
if ($count % 2) $class = 'data-odd';
|
|
$count++;
|
|
|
|
echo(" <tr class='$class'>\n");
|
|
echo(" <td align='center'>$method</td>\n");
|
|
echo(" <td align='right'>-$currencySymbol$pAmt </td>\n");
|
|
echo(" </tr>\n");
|
|
}
|
|
?>
|
|
</table>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
var schoolNum = '<?php echo($school_num) ?>';
|
|
var today = '<?php echo(date("Y-m-d",time())) ?>';
|
|
|
|
$("#trx-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 980,
|
|
minHeight: 600,
|
|
modal: true,
|
|
position: { my: 'center', at: 'center' }
|
|
});
|
|
|
|
$(document).on("click", ".user-account", function() {
|
|
var user_num = $(this).attr('unum');
|
|
var data = "table_name=user_account"+
|
|
"&sequence_flag=N"+
|
|
"&action=user-account-transactions"+
|
|
"&table_id="+
|
|
"&user_num="+user_num;
|
|
|
|
// Get user account transactions
|
|
$.getJSON( "ajax.DataTable.Fetch.php",data,
|
|
function(results) {
|
|
$("#user-account-div").html(results.content);
|
|
$("#trx-dialog").dialog("open");
|
|
if (results.count > 40) window.location = '#user-account-div';
|
|
}
|
|
);
|
|
});
|
|
|
|
$(document).on('click', '.trx-close-btn', function(e) {
|
|
e.preventDefault();
|
|
$("#trx-dialog").dialog("close");
|
|
});
|
|
|
|
$(document).on('click', '#edit-user-account-transactions', function(e) {
|
|
e.preventDefault();
|
|
|
|
var unum = $(this).attr('unum');
|
|
window.location = "?action=user-account&user_num="+unum;
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
<div id='trx-dialog' title="<?php displayLanguageText('TEXT-USER-ACCOUNT'); ?>">
|
|
<div id='user-account-div'></div>
|
|
<p><button id='trx-close-btn' class='btn btn--outline btn--xsmall'> <?php displayLanguageText('TEXT-CLOSE-WINDOW'); ?> </button></p>
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
|
|
endTemplate();
|
|
?>
|