Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Colorize refunds and show refunded total.

Red: Refunded/Pending Settlement
Green: Refunded/Settled
Black: Cancelled

Backported from HEAD(1.25-1.26)
  • Loading branch information...
commit 7ecefcb090bcde3c00c8cde1fdf37b028e43a399 1 parent 7a23b4d
ethem authored
Showing with 35 additions and 10 deletions.
  1. +35 −10 enrol/authorize/locallib.php
View
45 enrol/authorize/locallib.php
@@ -450,13 +450,13 @@ function authorize_print_order_details($orderno)
print_table($table);
if ($settled) { // show refunds.
$t2 = new stdClass;
- $t2->size = array('15%', '15%', '20%', '35%', '15%');
+ $t2->size = array('45%', '15%', '20%', '10%', '10%');
$t2->align = array('right', 'right', 'right', 'right', 'right');
- $t2->head = array($authstrs->transid,
- $authstrs->amount,
+ $t2->head = array($authstrs->settlementdate,
+ $authstrs->transid,
$strs->status,
- $authstrs->settlementdate,
- $strs->action);
+ $strs->action,
+ $authstrs->amount);
$sql = "SELECT R.*, E.courseid FROM {$CFG->prefix}enrol_authorize_refunds R " .
"INNER JOIN {$CFG->prefix}enrol_authorize E ON R.orderid = E.id " .
@@ -464,6 +464,7 @@ function authorize_print_order_details($orderno)
$refunds = get_records_sql($sql);
if ($refunds) {
+ $sumrefund = floatval(0.0);
foreach ($refunds as $rf) {
$substatus = authorize_get_status_action($rf);
$subactions = ' ';
@@ -476,12 +477,36 @@ function authorize_print_order_details($orderno)
"<a href='index.php?$vl=y&amp;sesskey=$USER->sesskey&amp;order=$orderno&amp;suborder=$rf->id'>{$authstrs->$vl}</a> ";
}
}
- $t2->data[] = array($rf->transid,
- $rf->amount,
- $authstrs->{$substatus->status},
- userdate($rf->settletime),
- $subactions);
+ $sign = '';
+ $color = '';
+ switch ($substatus->status) {
+ case 'cancelled':
+ $color = 'black';
+ break;
+
+ case 'refunded':
+ $sign = '-';
+ $color = 'red';
+ $sumrefund += floatval($rf->amount);
+ break;
+
+ case 'settled':
+ default:
+ $sign = '-';
+ $color = 'green';
+ $sumrefund += floatval($rf->amount);
+ break;
+ }
+
+ $t2->data[] = array(
+ userdate($rf->settletime),
+ $rf->transid,
+ $authstrs->{$substatus->status},
+ $subactions,
+ "<font color='$color'>" . format_float($sign . $rf->amount, 2) . "</font>"
+ );
}
+ $t2->data[] = array('','',get_string('total'),$order->currency,format_float('-'.$sumrefund, 2));
}
else {
$t2->data[] = array('','',get_string('noreturns', 'enrol_authorize'),'','');
Please sign in to comment.
Something went wrong with that request. Please try again.