217 lines
9.5 KiB
PHP
217 lines
9.5 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Get set of user account records
|
|
if (!isset($transactions)) {
|
|
if (in_array($_SESSION['UserInfo']['type'],array('Parent','Staff','Administration Team'))) $user_num = intval($_SESSION['UserInfo']['record_num']);
|
|
|
|
$query = "SELECT u.userid,substring(transaction_datetime,1,10) as trx_date,transaction_type,note,transaction_amount,transaction_fee,schedule_num,order_num," .
|
|
"payment_method,payment_reference,ua.user_num,people_num,p.people_type,entered_by_user_num,ua.record_num " .
|
|
"FROM user_account as ua LEFT JOIN people as p ON ua.people_num = p.record_num, users AS u " .
|
|
"WHERE u.school_num = $base_school_num " .
|
|
"AND ua.school_num = $school_num " .
|
|
"AND ua.user_num = $user_num " .
|
|
"AND ua.user_num = u.record_num " .
|
|
"AND (deleted != 'Y' OR deleted IS NULL) " .
|
|
"ORDER BY userid,transaction_datetime,record_num";
|
|
$transactions = db_query($query);
|
|
$mode = 'account';
|
|
|
|
$print_cmd = "&selected_usernum=$user_num";
|
|
}
|
|
|
|
echo("<center>\n");
|
|
|
|
|
|
$scheduleNames = array();
|
|
|
|
|
|
$num_transactions = db_num_rows($transactions);
|
|
if ($num_transactions == 0) {
|
|
if ($naction == 'list') echo("<p class='success'>No Transactions Found</p>\n");
|
|
echo("<br>\n");
|
|
}
|
|
else {
|
|
?>
|
|
<p><b><?php displayLanguageText('TEXT-ACCOUNT-TRANSACTIONS'); ?> - <?php echo($num_transactions) ?></b></p>
|
|
<table width='900' class='content-table'>
|
|
<?php if (isset($view) && $view == 'details') { ?>
|
|
<form method='post' action='/'>
|
|
<?php } ?>
|
|
<tr>
|
|
<td width='100' align='left' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-USER-ID'); ?></b></td>
|
|
<td align='left' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-TRX-DATE'); ?></b></td>
|
|
<td align='left' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-REFERENCE'); ?></b></td>
|
|
<td align='right' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-AMOUNT'); ?></b></td>
|
|
<td align='right' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-PAYPAL-FEE'); ?></b></td>
|
|
<td align='center' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-METHOD'); ?></b></td>
|
|
<td align='right' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-ACTUAL'); ?></b></td>
|
|
</tr>
|
|
<?php
|
|
$count = 1;
|
|
$balance = 0;
|
|
$total_credits = 0;
|
|
$total_fee = 0;
|
|
$total_actual = 0;
|
|
while ($row = db_fetch_array($transactions)) {
|
|
extract($row);
|
|
$bg = 'data-even';
|
|
if ($count % 2) $bg = 'data-odd';
|
|
$count++;
|
|
|
|
// Format the amounts
|
|
$credit = $currencySymbol . number_format(abs($transaction_amount),2);
|
|
$trx_fee = $currencySymbol . number_format($transaction_fee,2);
|
|
$actual = $currencySymbol . number_format(abs($transaction_amount) - $transaction_fee,2);
|
|
$total_credits += abs($transaction_amount);
|
|
$total_fee += $transaction_fee;
|
|
$total_actual += abs($transaction_amount) - $transaction_fee;
|
|
|
|
|
|
// Add userid link if the current user is admin or superuser
|
|
if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Schedule Team','Financial','Financial Team'))) {
|
|
$userid = "<a href='?action=user-account&naction=add&user_num=$user_num'>$userid</a>";
|
|
}
|
|
|
|
$payment_method = "<span class='trx-ref' rnum='$record_num' ref='$payment_reference' " .
|
|
"amt='" . abs($transaction_amount) . "' fee='" . abs($transaction_fee) . "'>$payment_method</span>";
|
|
$payment_reference = "<span id='trx-ref-$record_num' class='trx-ref' rnum='$record_num' ref='$payment_reference' " .
|
|
"amt='" . abs($transaction_amount) . "' fee='" . abs($transaction_fee) . "'>$payment_reference</span>";
|
|
|
|
if ($schedule_num > 0) {
|
|
if (array_key_exists($schedule_num, $scheduleNames)) $schedule_name = $scheduleNames[$schedule_num];
|
|
else {
|
|
$schedule_name = db_getVal("SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
|
$scheduleNames[$schedule_num] = $schedule_name;
|
|
}
|
|
$payment_reference .= "<br><span class='small'>$schedule_name</span>";
|
|
}
|
|
?>
|
|
<tr>
|
|
<td align='left' valign='top' class='<?php echo($bg) ?>'><?php echo($userid) ?></td>
|
|
<td align='left' valign='top' class='<?php echo($bg) ?>'><?php echo($trx_date) ?></td>
|
|
<td align='left' valign='top' class='<?php echo($bg) ?>'><?php echo($payment_reference) ?></td>
|
|
<td align='right' valign='top' class='<?php echo($bg) ?>'><span id='trx-amt-<?php echo($record_num) ?>'><?php echo($credit) ?></span></td>
|
|
<td align='right' valign='top' class='<?php echo($bg) ?>'><span id='trx-fee-<?php echo($record_num) ?>'><?php echo($trx_fee) ?></span></td>
|
|
<td align='center' valign='top' class='<?php echo($bg) ?>'><?php echo($payment_method) ?></td>
|
|
<td align='right' valign='top' class='<?php echo($bg) ?>'><nobr><?php echo($actual) ?></nobr></td>
|
|
</tr>
|
|
<?php
|
|
if (isset($view) && $view == 'details') {
|
|
$details = "";
|
|
|
|
if (isset($entered_by_user_num)) {
|
|
$details .= "Entered by User: ";
|
|
$details .= db_getVal("SELECT concat(userid,' - ',first_name,' ',last_name) FROM users WHERE school_num = $base_school_num AND record_num = $entered_by_user_num");
|
|
}
|
|
|
|
$sfield = "trx_schedule_$record_num";
|
|
?>
|
|
<tr>
|
|
<td align='left' valign='top' class='<?php echo($bg) ?>'> </td>
|
|
<td align='left' colspan='6' valign='top' class='<?php echo($bg) ?>'>
|
|
Posted to Schedule:
|
|
<select name='<?php echo($sfield) ?>'>
|
|
<?php if ($schedule_num == 0) { ?>
|
|
<option value='0'>Not Posted to a Schedule</option>
|
|
<?php } ?>
|
|
<?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'];
|
|
if ($rnum == $schedule_num) $selected = " selected='selected'";
|
|
echo(" <option value='$rnum'$selected>$sname</option>\n");
|
|
$selected = "";
|
|
}
|
|
?>
|
|
</select><br>
|
|
<?php echo($details) ?>
|
|
</td>
|
|
<?php if (in_array($_SESSION['UserInfo']['type'],array('SuperUser','System Administrator','Application Administrator','Administration Team','Schedule Team','Financial','Financial Team'))) { ?>
|
|
<?php if (!isset($deleteType) || $deleteType != 'deleted') { ?>
|
|
<td align='left' valign='top' class='<?php echo($bg) ?>'> </td>
|
|
<?php } ?>
|
|
<?php } ?>
|
|
</tr>
|
|
<?php
|
|
}
|
|
|
|
if (isset($deleteType) && $deleteType == 'deleted') {
|
|
$delete_userid = "superuser";
|
|
if ($deleted_by_user_num != 1) $delete_userid = db_getVal("SELECT userid FROM users WHERE school_num = $base_school_num AND record_num = $deleted_by_user_num");
|
|
$delete_info = "Deleted $deleted_datetime by $delete_userid - $delete_reason<br><br>";
|
|
?>
|
|
<tr>
|
|
<td align='left' valign='top' class='<?php echo($bg) ?>'> </td>
|
|
<td colspan='8' align='left' valign='top' class='<?php echo($bg) ?>'><?php echo($delete_info) ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
$total_credits = round($total_credits * 100) / 100;
|
|
$total_credits = $currencySymbol . number_format(abs($total_credits),2);
|
|
|
|
$total_fee = round($total_fee * 100) / 100;
|
|
$total_fee = $currencySymbol . number_format($total_fee,2);
|
|
|
|
$total_actual = round($total_actual * 100) / 100;
|
|
$total_actual = $currencySymbol . number_format($total_actual,2);
|
|
?>
|
|
<tr>
|
|
<td colspan='3' align='right' valign='top' class='data-header'><b><?php displayLanguageText('TEXT-TRX-TOTALS-FOR-PERIOD'); ?> :: </b></td>
|
|
<td align='right' valign='top' class='data-header'><b><nobr><?php echo($total_credits) ?></nobr></b></td>
|
|
<td align='right' valign='top' class='data-header'><b><nobr><?php echo($total_fee) ?></nobr></b></td>
|
|
<td align='center' class='data-header'> </td>
|
|
<td align='right' valign='top' class='data-header'><b><nobr><?php echo($total_actual) ?></nobr></b></td>
|
|
</tr>
|
|
<?php
|
|
|
|
$nCols = 9;
|
|
|
|
if (isset($view) && $view == 'details') {
|
|
?>
|
|
<tr>
|
|
<td colspan='<?php echo($nCols) ?>' align='center'>
|
|
<input type='submit' class='btn btn--primary' value='Update Transactions'>
|
|
<input type='hidden' name='action' value='user-account'>
|
|
<input type='hidden' name='naction' value='update-trx'>
|
|
<input type='hidden' name='user_num' value='<?php echo($selected_user_num) ?>'>
|
|
<input type='hidden' name='posted_user_num' value='<?php echo($selected_user_num) ?>'>
|
|
</td>
|
|
</tr>
|
|
</form>
|
|
<?php
|
|
}
|
|
|
|
if ((!isset($view) || $view != 'details') && isset($print_cmd) && strlen($print_cmd) > 0) {
|
|
?>
|
|
<tr>
|
|
<td colspan='<?php echo($nCols) ?>' align='right'>
|
|
<?php include "user_account.paypal.buttons.php" ?>
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
?>
|
|
</table>
|
|
</center>
|
|
<br>
|
|
<?php
|
|
}
|
|
|
|
?>
|