use OpenSRF::AppSession;
use OpenSRF::EX qw/:try/;
use OpenSRF::Utils qw/:datetime/;
+use OpenSRF::Utils::JSON;
use OpenSRF::Utils::Logger qw/$logger/;
use OpenILS::Application::AppUtils;
use OpenILS::Utils::CStoreEditor qw/:funcs/;
my $e = $self->editor;
my $ctx = $self->ctx;
- my $limit = $self->cgi->param('limit') || 10;
+ my $limit = $self->cgi->param('limit') || 0;
my $offset = $self->cgi->param('offset') || 0;
my $circ = OpenSRF::AppSession->create('open-ils.circ');
$e->requestor->id
)->gather(1);
- $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ];
+ $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
my $req = $circ->request(
'open-ils.circ.hold.details.batch.retrieve',
my $ctx = $self->ctx;
my @renew_ids = $self->cgi->param('circ');
- $self->apache->log->warn("renewal ids: @renew_ids");
- my $circs = $self->fetch_user_circs(1, ($action eq 'renew') ? [@renew_ids] : undef);
+ my $circs = $self->fetch_user_circs(0, ($action eq 'renew') ? [@renew_ids] : undef);
# TODO: fire off renewal calls in batches to speed things up
- $ctx->{renewal_responses} = [];
+ my @responses;
for my $circ (@$circs) {
- my $resp = $U->simplereq(
+ my $evt = $U->simplereq(
'open-ils.circ',
'open-ils.circ.renew',
$self->editor->authtoken,
{
patron_id => $self->editor->requestor->id,
- copy_id => $circ->{circ}->target_copy->id,
+ copy_id => $circ->{circ}->target_copy,
opac_renewal => 1
}
);
# TODO return these, then insert them into the circ data
# blob that is shoved into the template for each circ
# so the template won't have to match them
- push(@{$ctx->{renewal_responses}}, $resp);
+ push(@responses, {copy => $circ->{circ}->target_copy, evt => $evt});
}
- return undef;
+ return @responses;
}
my $ctx = $self->ctx;
$ctx->{circs} = [];
- my $limit = $self->cgi->param('limit') || 10;
+ my $limit = $self->cgi->param('limit') || 0; # 0 == unlimited
my $offset = $self->cgi->param('offset') || 0;
my $action = $self->cgi->param('action') || '';
# perform the renewal first if necessary
- $self->handle_circ_renew($action) if $action =~ /renew/;
+ my @results = $self->handle_circ_renew($action) if $action =~ /renew/;
$ctx->{circs} = $self->fetch_user_circs(1, undef, $limit, $offset);
+ my $success_renewals = 0;
+ my $failed_renewals = 0;
+ for my $data (@{$ctx->{circs}}) {
+ my ($resp) = grep { $_->{copy} == $data->{circ}->target_copy->id } @results;
+
+ if($resp) {
+ #$self->apache->log->warn("renewal response: " . OpenSRF::Utils::JSON->perl2JSON($resp));
+ my $evt = ref($resp->{evt}) eq 'ARRAY' ? $resp->{evt}->[0] : $resp->{evt};
+ $data->{renewal_response} = $evt;
+ $success_renewals++ if $evt->{textcode} eq 'SUCCESS';
+ $failed_renewals++ if $evt->{textcode} ne 'SUCCESS';
+ }
+ }
+
+ $ctx->{success_renewals} = $success_renewals;
+ $ctx->{failed_renewals} = $failed_renewals;
+
return Apache2::Const::OK;
}
my $ctx = $self->ctx;
$ctx->{transactions} = [];
- my $limit = $self->cgi->param('limit') || 10;
+ my $limit = $self->cgi->param('limit') || 0;
my $offset = $self->cgi->param('offset') || 0;
my $cstore = OpenSRF::AppSession->create('open-ils.cstore');
# TODO: This should really use a ML call, but the existing calls
# return an excessive amount of data and don't offer streaming
+ my %paging = ($limit or $offset) ? (limit => $limit, offset => $offset) : ();
+
my $req = $cstore->request(
'open-ils.cstore.direct.money.open_billable_transaction_summary.search',
{
acn => ['record']
},
order_by => { mobts => 'xact_start' },
- limit => $limit,
- offset => $offset
+ %paging
}
);
table { width: 100%; text-align: center; padding: 20px; margin-top: 30px; }
table { border-collapse: collapse; }
table { padding: 3px; border-bottom: 1px solid #ddd; text-align: left;}
- table tr:nth-child(odd) { background-color:#ded; }
- #action_div { width: 95%; text-align: right }
+ #action_div { width: 95%; }
+ .renew-summary { float:left; padding-right: 10px;}
+ #action-buttons { float:right; }
+ .circ-table-odd { background-color:#ded; }
+ .failure-text { font-weight: bold; color: red; }
+ #circ-form { margin-top: 20px; }
</style>
[% END %]
[% INCLUDE "default/opac/myopac/_links.tt2" myopac_page = "circs" %]
[% USE date %]
-<form method='POST'>
+
+<form method='POST' id='circ-form'>
<div id='action_div'>
- <button type='submit' value='renew' name='action'>Renew Selected</button>
- <button type='submit' value='renew_all' name='action'>Renew All</button>
+ [% IF ctx.success_renewals > 0 %]
+ <div class='renew-summary'><b>Successfully renewed [% ctx.success_renewals %] items.</b></div>
+ [% END %]
+ [% IF ctx.failed_renewals > 0 %]
+ <div class='renew-summary'><b>Failed to renew [% ctx.failed_renewals %] items.</b></div>
+ [% END %]
+ <div id='action-buttons'>
+ <button type='submit' value='renew' name='action'>Renew Selected</button>
+ <button type='submit' value='renew_all' name='action'>Renew All</button>
+ </div>
</div>
<table>
<thead>
[% FOR circ IN ctx.circs %]
[% attrs = {marc_xml => circ.marc_xml}; %]
[% PROCESS get_marc_attrs args=attrs; %]
- <tr>
+ <tr [% IF loop.count % 2 == 1 %] class='circ-table-odd' [% END %]>
<td>[% attrs.title %]</td>
<td>[% attrs.author %]</td>
<td>[% date.format(ctx.parse_datetime(circ.circ.due_date),'%Y-%m-%d') %]</td>
<td><em>[% circ.circ.renewal_remaining %]</em></td>
<td><input name='circ' value='[% circ.circ.id %]' type='checkbox'/></td>
</tr>
+ [% IF circ.renewal_response and circ.renewal_response.textcode != 'SUCCESS' %]
+ <tr [% IF loop.count % 2 == 1 %] class='circ-table-odd' [% END %]>
+ <td colspan='0'>
+ <div class='failure-text'>
+ [% circ.renewal_response.textcode %]
+ [% IF circ.renewal_response.payload.fail_part and circ.renewal_response.payload.fail_part != circ.renewal_response.textcode %]
+ [% circ.renewal_response.payload.fail_part %]
+ [% END %]
+ </div>
+ </td>
+ </tr>
+ [% END %]
[% END %]
</tbody>
</table>