215 lines
7.5 KiB
PHP
215 lines
7.5 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-report";
|
|
$CurrentTable = "user_account";
|
|
$FormFile = "";
|
|
$TitleText = getLanguageText('TEXT-PAYMENT-SUMMARY-REPORT');
|
|
$OrderBy = "transaction_datetime";
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = "$TitleText";
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Financial','Financial Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
|
|
$school_num = $school_record['record_num'];
|
|
|
|
$report_title = $TitleText . "<br>\n";
|
|
|
|
// Handle selected date ranges
|
|
$start_date = date("Y-m-d 00:00:00",time());
|
|
$end_date = date("Y-m-d 23:59:59",time());
|
|
$summarize_by = 'PayMethod';
|
|
if (array_key_exists('summarize_by',$_POST) && strlen($_POST['summarize_by']) > 0) $summarize_by = $_POST['summarize_by'];
|
|
|
|
|
|
if (array_key_exists('start_date',$_POST) && strlen($_POST['start_date']) > 0) $start_date = date("Y-m-d 00:00:00",strtotime($_POST['start_date']));
|
|
if (array_key_exists('end_date',$_POST) && strlen($_POST['end_date']) > 0) {
|
|
$end_date = $_POST['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' ";
|
|
if (!isset($uwhere)) $uwhere = '';
|
|
|
|
|
|
// View only selected payment methods
|
|
unset($selected_payment_method);
|
|
if (array_key_exists('selected_payment_method',$_POST) && strlen($_POST['selected_payment_method']) > 0) {
|
|
$selected_payment_method = $_POST['selected_payment_method'];
|
|
$uwhere .= "AND payment_method = '$selected_payment_method' ";
|
|
$report_title .= "$selected_payment_method Transactions ";
|
|
}
|
|
|
|
|
|
// View only selected schedule
|
|
$selected_schedule_num = 0;
|
|
if (array_key_exists('selected_schedule_num',$_POST) && strlen($_POST['selected_schedule_num']) > 0) {
|
|
$selected_schedule_num = intval($_POST['selected_schedule_num']);
|
|
$uwhere .= "AND schedule_num = '$selected_schedule_num' ";
|
|
}
|
|
|
|
|
|
if (!isset($selected_payment_method)) $selected_payment_method = '';
|
|
|
|
|
|
$message_width = 400;
|
|
include "form.messages.php";
|
|
|
|
?>
|
|
<form method='post' name='transactions'>
|
|
<table width='400' cellpadding='3' class='content-table'>
|
|
<tr>
|
|
<td align='right'><?php displayLanguageText('TEXT-START-DATE'); ?>: </td>
|
|
<td align='left'><input type='text' name='start_date' value='<?php echo($sdate) ?>' size='15' class='date-field'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'><?php displayLanguageText('TEXT-END-DATE'); ?>: </td>
|
|
<td align='left'><input type='text' name='end_date' value='<?php echo($edate) ?>' size='15' class='date-field'></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-SUMMARY'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<input type='radio' name='summarize_by' value='PayMethod' <?php if ($summarize_by == 'PayMethod') echo("checked='checked'") ?>> <?php displayLanguageText('TEXT-PAYMENT-METHOD'); ?>
|
|
<input type='radio' name='summarize_by' value='Date' <?php if ($summarize_by == 'Date') echo("checked='checked'") ?>> <?php displayLanguageText('TEXT-DATE'); ?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<tr>
|
|
<td align='right' valign='top'><?php displayLanguageText('TEXT-PAYMENT-METHOD'); ?>: </td>
|
|
<td align='left' valign='top'>
|
|
<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='right' valign='top'></td>
|
|
<td align='center' valign='top'><a href='#' class='btn btn--primary btn--xsmall' onClick='document.transactions.submit();'><span><?php displayLanguageText('TEXT-VIEW'); ?></span></a></td>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='action' value='user-account-payment-summary'>
|
|
</form>
|
|
<?php
|
|
|
|
|
|
//
|
|
// List all requested records
|
|
//
|
|
if ($summarize_by == 'PayMethod') {
|
|
$query = "SELECT payment_method as col1,sum(transaction_amount) as amount " .
|
|
"FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND transaction_type = 'Payment' " .
|
|
$uwhere . $twhere .
|
|
"AND (deleted != 'Y' OR deleted IS NULL) " .
|
|
"GROUP BY 1 " .
|
|
"ORDER BY transaction_type";
|
|
$transactions = db_query($query);
|
|
$ColumnTitle = getLanguageText('TEXT-PAYMENT-METHOD');
|
|
$report_title .= "$sdate - $edate<br>\n- " . $ColumnTitle . " -";
|
|
}
|
|
else {
|
|
$query = "SELECT substr(transaction_datetime,1,10) as col1,sum(transaction_amount) as amount " .
|
|
"FROM user_account " .
|
|
"WHERE school_num = $school_num " .
|
|
"AND transaction_type = 'Payment' " .
|
|
$uwhere . $twhere .
|
|
"AND (deleted != 'Y' OR deleted IS NULL) " .
|
|
"GROUP BY 1 " .
|
|
"ORDER BY transaction_type";
|
|
$transactions = db_query($query);
|
|
$ColumnTitle = getLanguageText('TEXT-PAYMENT-DATE');
|
|
$report_title .= "$sdate - $edate<br>\n- " . $ColumnTitle . " -";
|
|
}
|
|
|
|
$RowClasses = array("data-odd","data-even");
|
|
|
|
if (db_num_rows($transactions) > 0) {
|
|
?>
|
|
<br>
|
|
<p><b><?php echo($report_title) ?></b></p>
|
|
<table width='400' id='data-table' class='content-table'>
|
|
<tr>
|
|
<td align='left' valign='top' class='data-header'><b><?php echo($ColumnTitle) ?></b></td>
|
|
<td align='right' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-AMOUNT') ?></b></td>
|
|
</tr>
|
|
<?php
|
|
$count = 0;
|
|
$total = 0;
|
|
while ($row = db_fetch_array($transactions)) {
|
|
extract($row);
|
|
|
|
$bgclass = $RowClasses[$count % 2];
|
|
$count++;
|
|
|
|
if ($col1 == 'Check') $col1 = getLanguageText('TEXT-CHECK');
|
|
|
|
if ($amount < 0) $amount_str = "- $currencySymbol" . number_format(-1 * $amount,2);
|
|
else $amount_str = $currencySymbol . number_format($amount,2);
|
|
|
|
$total += $amount;
|
|
?>
|
|
<tr>
|
|
<td align='left' valign='top' class='<?php echo($bgclass) ?>'><?php echo($col1) ?></td>
|
|
<td align='right' valign='top' class='<?php echo($bgclass) ?>'><?php echo($amount_str) ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
if ($total < 0) $amount_str = "- $currencySymbol" . number_format(-1 * $total,2);
|
|
else $amount_str = $currencySymbol . number_format($total,2);
|
|
|
|
$print_cmd = "&query=" . urlencode($query) . "&title=" . urlencode($report_title) . "&col1=" . urlencode($ColumnTitle);
|
|
?>
|
|
<tr>
|
|
<td align='left' valign='top' class='data-header'> </td>
|
|
<td align='right' valign='top' class='data-header'><b><?php echo($amount_str) ?></b></td>
|
|
</tr>
|
|
</table>
|
|
<table width='400'>
|
|
<tr>
|
|
<td align='right'>
|
|
<table align='right'>
|
|
<tr>
|
|
<td align='center'><a href='?action=user-account-payment-summary-print<?php echo($print_cmd) ?>' class='btn btn--primary btn--xsmall'><span>Print</span></a></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php
|
|
}
|
|
|
|
endTemplate();
|
|
?>
|