return $self->load_place_hold if $path =~ m|opac/place_hold|;
return $self->load_myopac_holds if $path =~ m|opac/myopac/holds|;
return $self->load_myopac_circs if $path =~ m|opac/myopac/circs|;
+ return $self->load_myopac_payment_form if $path =~ m|opac/myopac/main_payment_form|;
return $self->load_myopac_payments if $path =~ m|opac/myopac/main_payments|;
return $self->load_myopac_main if $path =~ m|opac/myopac/main|;
return $self->load_myopac_update_email if $path =~ m|opac/myopac/update_email|;
use OpenSRF::Utils::JSON;
my $U = 'OpenILS::Application::AppUtils';
-
-# context additions:
-# user : au object, fleshed
-sub load_myopac_prefs {
+sub load_extended_user_info {
my $self = shift;
$self->ctx->{user} = $self->editor->retrieve_actor_user([
{
flesh => 1,
flesh_fields => {
- au => [qw/card home_ou addresses ident_type/]
+ au => [qw/card home_ou addresses ident_type billing_address/]
# ...
}
}
- ]);
+ ]) or return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
- return Apache2::Const::OK;
+ return;
+}
+
+# context additions:
+# user : au object, fleshed
+sub load_myopac_prefs {
+ my $self = shift;
+ return $self->load_extended_user_info || Apache2::Const::OK;
}
sub load_myopac_prefs_notify {
sub load_myopac_prefs_settings {
my $self = shift;
-
- $self->ctx->{user} = $self->editor->retrieve_actor_user([
- $self->ctx->{user}->id,
- {
- flesh => 1,
- flesh_fields => {
- au => [qw/card home_ou addresses ident_type/]
- # ...
- }
- }
- ]);
-
- return Apache2::Const::OK;
+ return $self->load_extended_user_info || Apache2::Const::OK;
}
-
sub fetch_user_holds {
my $self = shift;
my $hold_ids = shift;
return Apache2::Const::OK;
}
+sub load_myopac_payment_form {
+ my $self = shift;
+ 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.
sub load_myopac_payments {
my $self = shift;
return Apache2::Const::OK;
}
+sub load_fines {
+ my ($self, $limit, $offset, $id_list) = @_;
+ # XXX TODO: check for failure after various network calls
-sub load_myopac_main {
- my $self = shift;
- my $limit = $self->cgi->param('limit') || 0;
- my $offset = $self->cgi->param('offset') || 0;
- my $e = $self->editor;
- my $ctx = $self->ctx;
-
- $ctx->{"fines"} = {
+ $self->ctx->{"fines"} = {
"circulation" => [],
"grocery" => [],
"total_paid" => 0,
"balance_owed" => 0
};
-
my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
# TODO: This should really be a ML call, but the existing calls
my $req = $cstore->request(
'open-ils.cstore.direct.money.open_billable_transaction_summary.search',
{
- usr => $e->requestor->id,
- balance_owed => {'!=' => 0}
+ usr => $self->editor->requestor->id,
+ balance_owed => {'!=' => 0},
+ ($id_list && @$id_list ? ("id" => $id_list) : ()),
},
{
flesh => 4,
}
);
+ 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
- $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
}
push(
- @{$ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}},
+ @{$self->ctx->{"fines"}->{$mobts->grocery ? "grocery" : "circulation"}},
{
xact => $mobts,
last_grocery_billing => $last_billing,
);
}
- return Apache2::Const::OK;
-}
+ $self->ctx->{"fines"}->{$_} /= 100.0 for (@total_keys);
+ return;
+}
+
+sub load_myopac_main {
+ my $self = shift;
+ my $limit = $self->cgi->param('limit') || 0;
+ my $offset = $self->cgi->param('offset') || 0;
+
+ return $self->load_fines($limit, $offset) || Apache2::Const::OK;
+}
sub load_myopac_update_email {
my $self = shift;
.opac-auto-145 { position: relative; top: -3px; left: 3px; }
.opac-auto-146 { position: relative; top: -3px; left: -5px; }
.opac-auto-147 { position: relative; top: -5px; }
-#learn_more { position: relative; top: 5px; }
+.pos-rel-top-5 { position: relative; top: 5px; }
.opac-auto-149 { position: relative; top: 5px; left: 25px; }
#util_print_btn { position: relative; top: 5px; left: 30px; }
.opac-auto-151 { position: relative; top: 75px; }
height: 166px;
}
+#myopac_sum_fines_placehold { float: right; width: 177px; height: 166px; }
+
.acct_holds_temp td {
text-align: left;
}
.hold-editor-controls { text-align: center; padding-top: 1em !important; }
.hold-editor-controls a { padding-left: 2em; }
-#rdetail_cn_browse_div { text-align: center; }
+.text-right { text-align: right; }
.rdetail-author-div { padding-bottom: 10px; }
.invisible { visibility: hidden; }
myopac_page = "main";
myopac_main_page = "main";
%]
-
+<form action="[% ctx.opac_root %]/myopac/main_payment_form" method="POST">
[% IF ctx.fines.circulation.size > 0 %]
<div id='myopac_circ_trans_div'>
<table width='100%' class='data_grid'>
<td>[% l("Due Date") %]</td>
<td>[% l("Date Returned") %]</td>
<td>[% l("Balance Owed") %]</td>
- <!-- TODO: hidden until pay-fines is implemented
<td nowrap="nowrap" style="white-space:nowrap;">
- <input id="pay_fines_box1" checked="checked"
+ <!-- XXX TODO select all js --><input id="pay_fines_box1" checked="checked"
type="checkbox" title="[% l('Click to (un)select all fines') %]" />
<label for="pay_fines_box1">[% l('Pay Fines') %]</label>
</td>
- -->
</tr>
</thead>
<tbody id='myopac_circ_trans_tbody'>
[% money(f.xact.balance_owed) %]
</strong>
</td>
- <!-- TODO: hidden until pay-fines is implemented
<td>
- <input type="checkbox" name="selector" title="[% l('Pay this fine') %]" />
+ <input type="checkbox" title="[% l('Pay this fine') %]"
+ name="xact" value="[% f.xact.id %]" />
</td>
- -->
</tr>
[% END %]
</tbody>
<td width='16%'>[% l("Total Amount Paid") %]</td>
<td width='16%'>[% l("Balance Owed") %]</td>
<td width='16%'>[% l("Billing Type") %]</td>
- <!-- TODO: hidden until pay-fines is implemented
<td width='4%' align="center" nowrap="nowrap"
style="white-space:nowrap;">
<input id="pay_fines_box2" checked="checked"
title="[% l('Click to (un)select all fines') %]" />
<label for="pay_fines_box2">[% l("Pay Fines") %]</label>
</td>
- -->
</tr>
</thead>
<tbody id='myopac_trans_tbody'>
</strong>
</td>
<td>[% f.xact.last_billing_type %]</td>
- <!-- TODO: hidden until pay-fines is implemented
<td>
- <input type="checkbox" name='selector' title='[% l("Pay this fine") %]'/>
+ <input type="checkbox" title='[% l("Pay this fine") %]'
+ name="xact" value="[% f.xact.id %]" />
</td>
- -->
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
-
-<!-- TODO: move payment form to its own page -->
-
-<div id="pay_fines_now" class="hide_me">
- <table id='oils-selfck-cc-payment-table'>
- <tbody>
- <tr>
- <td><div style="width:129px;"></div></td>
- <td><div style="width:195px;"></div></td>
- <td><div style="width:324px;"></div></td>
- </tr>
- <tr>
- <td colspan='2'><strong>Billing Information</strong></td>
- <td rowspan='13' valign='top'>
- Selected fines you are paying for:
- <table cellpadding="0" cellspacing="5" border="0">
- <thead>
- <tr>
- <td>
- <strong>Name</strong>
- </td>
- <td>
- <strong>Amount</strong>
- </td>
- </tr>
- </thead>
- <tbody id="selectedFines">
- </tbody>
- </table>
- <br />
- <div id='oils-selfck-cc-payment-summary'>
- Total amount to pay:
- <strong>$<span></span></strong>
- </div>
- <br />
- Click <strong>Cancel</strong> to go back and (un)select
- other fines.
- </td>
- </tr>
- <tr>
- <td>First Name</td>
- <td><input jsId='oilsSelfckCCFName' /></td>
- </tr>
- <tr>
- <td>Last Name</td>
- <td><input jsId='oilsSelfckCCLName' /></td>
- </tr>
- <tr>
- <td>Street Address</td>
- <td><input jsId='oilsSelfckCCStreet' /></td>
- </tr>
- <tr>
- <td>City</td>
- <td><input jsId='oilsSelfckCCCity' /></td>
- </tr>
- <tr>
- <td>State or Province</td>
- <td><input jsId='oilsSelfckCCState' /></td>
- </tr>
- <tr>
- <td>ZIP or Postal Code</td>
- <td><input jsId='oilsSelfckCCZip' /></td>
- </tr>
- <tr>
- <td colspan='2'><strong>Credit Card Information</strong></td>
- </tr>
- <!-- Technically not needed since card type is derived from the CC number
- <tr>
- <td>Type of Card</td>
- <td>
- <select jsId='oilsSelfckCCType' required='true'>
- <option value='VISA'>VISA</option>
- <option value='MasterCard'>MasterCard</option>
- <option value='American Express'>American Express</option>
- </select>
- </td>
- </tr>
- -->
- <tr>
- <td>Credit Card #</td>
- <td><input jsId='oilsSelfckCCNumber' /></td>
- </tr>
- <tr>
- <td>
- <div style="position:absolute;">
- <div style="position:relative;left:80px;">
- <a href="#"><img
- src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
- </div>
- </div>
- Security Code
- </td>
- <td>
- <input jsId='oilsSelfckCCCVV' />
- </td>
- </tr>
- <tr>
- <td>Exipration Month</td>
- <td>
- <select jsId='oilsSelfckCCMonth'>
- <option value='01' selected='selected'>January</option>
- <option value='02'>February</option>
- <option value='03'>March</option>
- <option value='04'>April</option>
- <option value='05'>May</option>
- <option value='06'>June</option>
- <option value='07'>July</option>
- <option value='08'>August</option>
- <option value='09'>September</option>
- <option value='10'>October</option>
- <option value='11'>November</option>
- <option value='12'>December</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Expiration Year</td>
- <td>
- <select jsId='oilsSelfckCCYear'>
- <option value='2011'>2011</option>
- <option value='2012'>2012</option>
- <option value='2013'>2013</option>
- <option value='2014'>2014</option>
- <option value='2015'>2015</option>
- <option value='2016'>2016</option>
- <option value='2017'>2017</option>
- <option value='2018'>2018</option>
- <option value='2019'>2019</option>
- </select>
- </td>
- </tr>
- <tr class="hide_me">
- <td>Edit Billing Address</td>
- <td>
- <input jsId='oilsSelfckEditDetails'/>
- </td>
- </tr>
- <tr>
- <td colspan='2' align="center">
- <button jsId='oilsSelfckCCSubmit'>
- Submit Payment
- </button>
- <button>
- Cancel
- </button>
- </td>
- </tr>
- [% INCLUDE "default/opac/myopac/main_refund_policy.tt2" %]
- </tbody>
- </table>
-</div>
+ <div class="text-right pad-top-ten">
+ <input type="image"
+ alt="[% l('Pay selected fines') %]"
+ title="[% l('Pay selected fines') %]"
+ onmouseover="this.src='[% ctx.media_prefix %]/images/pay-fines-btn-hover.png';"
+ onmouseout="this.src='[% ctx.media_prefix %]/images/pay-fines-btn.png';"
+ src="[% ctx.media_prefix %]/images/pay-fines-btn.png" />
+ </div>
+</form>
[% END %]
--- /dev/null
+[% PROCESS "default/opac/parts/header.tt2";
+ PROCESS "default/opac/parts/misc_util.tt2";
+ WRAPPER "default/opac/parts/myopac/main_base.tt2";
+ 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"
+ 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 %]
+ <table>
+ <tbody>
+ <tr>
+ <td colspan='2'><strong>[% l('Billing Information') %]</strong></td>
+ <td rowspan='13' valign='top'>
+ [% l('Selected fines you are paying for:') %]
+ <table cellpadding="0" cellspacing="5" border="0">
+ <thead>
+ <tr>
+ <th>[% l('Name') %]</th>
+ <th>[% l('Amount') %]</th>
+ </tr>
+ </thead>
+ <tbody>
+ [%
+ FOR f IN ctx.fines.circulation;
+ NEXT IF CGI.param('xact').size &&
+ !CGI.param('xact').grep(f.xact.id).size;
+ attrs = {marc_xml => f.marc_xml};
+ IF f.marc_xml;
+ PROCESS get_marc_attrs args=attrs;
+ ELSIF f.xact.reservation;
+ attrs.title = f.xact.reservation.target_resource_type.name;
+ END %]
+ <tr>
+ <td>[% attrs.title %]</td>
+ <td class="text-right">[% money(f.xact.balance_owed) %]</td>
+ </tr>
+ [%
+ END;
+ FOR f IN ctx.fines.grocery;
+ NEXT IF CGI.param('xact').size &&
+ !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>
+ </tr>
+ [% END %]
+ </tbody>
+ </table>
+ <br />
+ <div>
+ [% l('Total amount to pay:') %]
+ <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 %]
+ </td>
+ </tr>
+ <tr>
+ <td>[% l('First Name') %]</td>
+ <td><input type="text" name="billing_first" value="[% ctx.user.first_given_name | html %]" /></td>
+ </tr>
+ <tr>
+ <td>[% l('Last Name') %]</td>
+ <td><input type="text" name="billing_last" value="[% ctx.user.family_name | html %]" /></td>
+ </tr>
+ <tr>
+ <td>[% l('Street Address') %]</td>
+ <td><input type="text" name="billing_address" value="[% ctx.user.billing_address.street1 _ ctx.user.billing_address.street2 | html %]" /></td>
+ </tr>
+ <tr>
+ <td>[% l('City' )%]</td>
+ <td><input type="text" name="billing_city" value="[% ctx.user.billing_address.city | html %]" /></td>
+ </tr>
+ <tr>
+ <td>[% l('State or Province') %]</td>
+ <td><input type="text" name="billing_state" value="[% ctx.user.billing_address.state | html %]" /></td>
+ </tr>
+ <tr>
+ <td>[% l('ZIP or Postal Code') %]</td>
+ <td><input type="text" name="billing_zip" value="[% ctx.user.billing_address.post_code | html %]" /></td>
+ </tr>
+ <tr>
+ <td colspan='2'><strong>[% l('Credit Card Information') %]</strong></td>
+ </tr>
+ <!-- Technically not needed since card type is derived from the CC number
+ <tr>
+ <td>Type of Card</td>
+ <td>
+ <select name="type">
+ <option value='VISA'>VISA</option>
+ <option value='MasterCard'>MasterCard</option>
+ <option value='American Express'>American Express</option>
+ </select>
+ </td>
+ </tr>
+ -->
+ <tr>
+ <td>[% l('Credit Card #') %]</td>
+ <td><input type="text" name="number" maxlength="16" /></td>
+ </tr>
+ <tr>
+ <td>
+ <div style="position:absolute;">
+ <div style="position:relative;left:80px;">
+ <a href="#"><img
+ src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
+ </div>
+ </div>
+ [% l('Security Code') %]
+ </td>
+ <td>
+ <input type="text" size="4" maxlength="5" name="cvv2" />
+ </td>
+ </tr>
+ <tr>
+ <td>[% l('Exipration Month') %]</td>
+ <td>
+ <select name="expire_month">
+ <option value="01">[% l("January") %]</option>
+ <option value="02">[% l("February") %]</option>
+ <option value="03">[% l("March") %]</option>
+ <option value="04">[% l("April") %]</option>
+ <option value="05">[% l("May") %]</option>
+ <option value="06">[% l("June") %]</option>
+ <option value="07">[% l("July") %]</option>
+ <option value="08">[% l("August") %]</option>
+ <option value="09">[% l("September") %]</option>
+ <option value="10">[% l("October") %]</option>
+ <option value="11">[% l("November") %]</option>
+ <option value="12">[% l("December") %]</option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>[% l('Expiration Year') %]</td>
+ <td>
+ <select name="expire_year">
+ [% year = date.format(date.now, '%Y');
+ y = year;
+ WHILE y < year + 10; # show ten years starting now %]
+ <option value="[% y %]">[% y %]</option>
+ [% y = y + 1; END %]
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2' align="center">
+ <input type="submit" value="[% l('Submit Payment') %]" />
+ <input type="reset" value="[% l('Cancel') %]"
+ onclick="location.history.go(-1);" />
+ </td>
+ </tr>
+ [% INCLUDE "default/opac/myopac/main_refund_policy.tt2" %]
+ </tbody>
+ </table>
+ </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;">
[% money(ctx.user_stats.fines.balance_owed) %]
</span><br />
- [%# TODO %]
- <a class="hide_me" href="#" id="pay_fines_btn1"><img
- alt="[% l('Pay Fines') %]"
+ <form action="[% ctx.opac_root %]/myopac/main_payment_form" method="POST"><input
+ type="image" title="[% l('Pay Fines') %]" alt="[% l('Pay Fines') %]"
onmouseover="this.src='[% ctx.media_prefix %]/images/pay-fines-btn-hover.png';"
onmouseout="this.src='[% ctx.media_prefix %]/images/pay-fines-btn.png';"
src="[% ctx.media_prefix %]/images/pay-fines-btn.png"
- style="position:relative;top:5px;" /></a>
+ class="pos-rel-top-5" /></form>
</div>
+ [% END %]
<div style="width:662px;">
<div style="float:left;">