sub load_myopac_payment_form {
my $self = shift;
- my $r = $self->load_fines(undef, undef, [$self->cgi->param('xact')]);
- return $r if $r;
- return $self->load_extended_user_info || Apache2::Const::OK;
+ my $r;
+
+ $r = $self->load_fines(undef, undef, [$self->cgi->param('xact')]) and return $r;
+
+ # total selected fines
+ foreach (
+ @{$self->ctx->{"fines"}->{"circulation"}},
+ @{$self->ctx->{"fines"}->{"grocery"}}
+ ) {
+ }
+
+ $r = $self->load_extended_user_info and return $r;
+
+ return Apache2::Const::OK;
}
# TODO: add other filter options as params/configs/etc.
}
);
+ my @total_keys = qw/total_paid total_owed balance_owed/;
+ $self->ctx->{"fines"}->{@total_keys} = (0, 0, 0);
+
while(my $resp = $req->recv) {
my $mobts = $resp->content;
my $circ = $mobts->circulation;
$last_billing = pop(@billings);
}
- # XXX TODO switch to some money-safe non-fp library for math
- $self->ctx->{"fines"}->{$_} += $mobts->$_ for (
- qw/total_paid total_owed balance_owed/
- );
+ # XXX TODO confirm that the following, and the later division by 100.0
+ # to get a floating point representation once again, is sufficiently
+ # "money-safe" math.
+ $self->ctx->{"fines"}->{$_} += int($mobts->$_ * 100) for (@total_keys);
my $marc_xml = undef;
if ($mobts->xact_type eq 'reservation' and
);
}
- return;
+ $self->ctx->{"fines"}->{$_} /= 100.0 for (@total_keys);
+ return;
}
sub load_myopac_main {
height: 166px;
}
+#myopac_sum_fines_placehold { float: right; width: 177px; height: 166px; }
+
.acct_holds_temp td {
text-align: left;
}
myopac_page = "main";
myopac_main_page = "payment_form";
%]
+[% IF ctx.fines.balance_owed <= 0 %]
+<div>
+ [% l("You either have no fines to pay or you have selected fines whose " _
+ "total is non-positive. We cannot process non-positive amounts.") %]
+</div>
+[% ELSE %]
<div id="pay_fines_now">
- <form action="[% ctx.opac_root %]/myopac/pay" method="POST">
+ <form action="[% ctx.opac_root %]/myopac/pay" method="POST"
+ onsubmit="return confirm('[% l("Are you sure you are ready to charge [_1] to your credit card?", money(ctx.fines.balance_owed)) %]');">
[% FOR xact IN CGI.param('xact') %]
<input type="hidden" name="xact" value="[% xact | html %]" />
[% END %]
</thead>
<tbody>
[%
- pay_total = 0.0;
FOR f IN ctx.fines.circulation;
NEXT IF CGI.param('xact').size &&
!CGI.param('xact').grep(f.xact.id).size;
PROCESS get_marc_attrs args=attrs;
ELSIF f.xact.reservation;
attrs.title = f.xact.reservation.target_resource_type.name;
- END;
- # XXX use fixed point math
- pay_total = pay_total + f.xact.balance_owed; %]
+ END %]
<tr>
<td>[% attrs.title %]</td>
<td class="text-right">[% money(f.xact.balance_owed) %]</td>
END;
FOR f IN ctx.fines.grocery;
NEXT IF CGI.param('xact').size &&
- !CGI.param('xact').grep(f.xact.id).size;
- # XXX use fixed point math
- pay_total = pay_total + f.xact.balance_owed; %]
+ !CGI.param('xact').grep(f.xact.id).size %]
<tr>
<td>[% f.xact.last_billing_type %]</td>
<td class="text-right">[% money(f.xact.balance_owed) %]</td>
<br />
<div>
[% l('Total amount to pay:') %]
- [%# XXX TODO: calculate pay_total not here in the
- template but rather in the mod_perl, and only
- proceed when that number is positive %]
- <strong>[% money(pay_total) %]</strong>
+ <strong>[% money(ctx.fines.balance_owed) %]</strong>
</div>
<br />
[% | l('<strong>', '</strong>') %]Click [_1]Cancel[_2] to go back and (un)select other fines.[% END %]
</form>
</div>
[% END %]
+[% END %]
<a href="http://example.com">[% l('Bottom Link 5') %]</a>
<div id="copyright_text" style="margin-top: 2em;">
- [% l('Copyright © 2006-2011 Georgia Public Library Service, and others') %]
+ [% l('Copyright © 2006-[_1] Georgia Public Library Service, and others', date.format(date.now, '%Y')) %]
</div>
<div id="footer_logo">
[% l('Powered by') %]
</div>
<!-- fines summary along the right of the page -->
+ [% IF myopac_main_page == "payment_form" %]
+ <div id="myopac_sum_fines_placehold"></div>
+ [% ELSE %]
<div id="myopac_sum_fines">
<div style="position:absolute;">
<div style="position:relative;top:-15px;left:-23px;">
src="[% ctx.media_prefix %]/images/pay-fines-btn.png"
class="pos-rel-top-5" /></form>
</div>
+ [% END %]
<div style="width:662px;">
<div style="float:left;">