diff --git a/action.php b/action.php
index e4d7d21..5487e49 100644
--- a/action.php
+++ b/action.php
@@ -140,15 +140,16 @@ switch ($VARS['action']) {
$itemhtml = "";
$items = $database->select('lines', ['amount', 'name', 'itemid', 'qty'], ['txid' => $txid]);
$total = 0.0;
+ $paid = 0.0;
foreach ($items as $i) {
$itemhtml .= "\n";
$itemhtml .= '
';
$itemhtml .= '
' . $i['name'] . '
';
- $itemhtml .= '
$' . $i['amount'] . '
';
- $itemhtml .= '
x' . $i['qty'] . '
';
- $itemhtml .= '
$' . ($i['qty'] * $i['amount']) . '
';
+ $itemhtml .= '
$' . number_format($i['amount'], 2) . '
';
+ $itemhtml .= '
x' . (float) $i['qty'] . '
';
+ $itemhtml .= '
$' . number_format($i['qty'] * $i['amount'] * 1.0, 2) . '
';
$itemhtml .= '
';
- $total += ($i['qty'] * $i['amount']);
+ $total += $i['qty'] * $i['amount'] * 1.0;
}
$paymenthtml = "";
@@ -163,11 +164,20 @@ switch ($VARS['action']) {
$paymenthtml .= "\n";
$paymenthtml .= '';
$paymenthtml .= '
' . lang($p['text'], false) . '
';
- $paymenthtml .= '
$' . $p['amount'] . '
';
+ $paymenthtml .= '
$' . number_format($p['amount'] * 1.0, 2) . '
';
$paymenthtml .= '
';
+ $paid += $p['amount'] * 1.0;
}
-
+ $change = $paid - $total;
+ if ($change <= 0) {
+ $change = 0.0;
+ }
+
+ $totalstr = number_format($total, 2);
+ $paidstr = number_format($paid, 2);
+ $changestr = number_format($change, 2);
+
$html = <<
@@ -177,6 +187,7 @@ switch ($VARS['action']) {
.flexrow {
display: flex;
justify-content: space-between;
+ margin: 0;
}
@@ -193,7 +204,9 @@ $itemhtml
$paymenthtml
-Total: $$total
+Total: $$totalstr
+Paid: $$paidstr
+Change: $$changestr
END;
exit($html);
break;