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 = $self->load_fines(undef, undef, [$self->cgi->param('xact')]);
+ return $r if $r;
+ return $self->load_extended_user_info || 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},
+ (ref $id_list eq 'ARRAY' ? ("id" => $id_list) : ()),
},
{
flesh => 4,
}
# XXX TODO switch to some money-safe non-fp library for math
- $ctx->{"fines"}->{$_} += $mobts->$_ for (
+ $self->ctx->{"fines"}->{$_} += $mobts->$_ for (
qw/total_paid total_owed balance_owed/
);
}
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;
-}
+ 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;