desc => "Retrieves all the holds, with hold transits attached, for the specified user. $ses_is_req_note",
params => [
{ desc => 'Authentication token', type => 'string' },
- { desc => 'User ID', type => 'integer' }
+ { desc => 'User ID', type => 'integer' },
+ { desc => 'Available Only', type => 'boolean' }
],
return => {
desc => 'list of holds, event on error',
desc => "Retrieves all the hold IDs, for the specified user. $ses_is_req_note",
params => [
{ desc => 'Authentication token', type => 'string' },
- { desc => 'User ID', type => 'integer' }
+ { desc => 'User ID', type => 'integer' },
+ { desc => 'Available Only', type => 'boolean' }
],
return => {
desc => 'list of holds, event on error',
sub retrieve_holds {
- my ($self, $client, $auth, $user_id) = @_;
+ my ($self, $client, $auth, $user_id, $available) = @_;
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
];
$holds_query->{where}->{cancel_time} = undef;
+ if($available) {
+ $holds_query->{where}->{shelf_time} = {'!=' => undef};
+ # Maybe?
+ $holds_query->{where}->{pickup_lib} = {'+ahr' => 'current_shelf_lib'};
+ }
}
my $hold_ids = $e->json_query($holds_query);
$hold_ids = $circ->request(
'open-ils.circ.holds.id_list.retrieve.authoritative',
$e->authtoken,
- $e->requestor->id
+ $e->requestor->id,
+ $available
)->gather(1);
$circ->kill_me;
-
- $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
}
+ my $all_ids = $hold_ids;
+ $hold_ids = [ grep { defined $_ } @$hold_ids[$offset..($offset + $limit - 1)] ] if $limit or $offset;
- return $hold_ids if $ids_only or @$hold_ids == 0;
+ return { ids => $hold_ids, all_ids => $all_ids } if $ids_only or @$hold_ids == 0;
my $args = {
suppress_notices => 1,
last if $first and not @ses;
if(@collected) {
- # If desired by the caller, filter any holds that are not available.
- if ($available) {
- @collected = grep { $_->{hold}->{status} == 4 } @collected;
- }
while(my $blob = pop(@collected)) {
my (undef, @data) = $self->get_records_and_facets(
[$blob->{hold}->{bre_id}], undef, {flesh => '{mra}'}
push @sorted, grep { $_->{hold}->{hold}->id == $id } @holds;
}
- return \@sorted;
+ return { holds => \@sorted, ids => $hold_ids, all_ids => $all_ids };
}
sub handle_hold_update {
my $url;
my @hold_ids = ($hold_ids) ? @$hold_ids : $self->cgi->param('hold_id'); # for non-_all actions
- @hold_ids = @{$self->fetch_user_holds(undef, 1)} if $action =~ /_all/;
+ @hold_ids = @{$self->fetch_user_holds(undef, 1)->{ids}} if $action =~ /_all/;
my $circ = OpenSRF::AppSession->create('open-ils.circ');
my $e = $self->editor;
my $ctx = $self->ctx;
- my $limit = $self->cgi->param('limit') || 0;
+ my $limit = $self->cgi->param('limit') || 15;
my $offset = $self->cgi->param('offset') || 0;
my $action = $self->cgi->param('action') || '';
my $hold_id = $self->cgi->param('id');
my $hold_handle_result;
$hold_handle_result = $self->handle_hold_update($action) if $action;
- $ctx->{holds} = $self->fetch_user_holds($hold_id ? [$hold_id] : undef, 0, 1, $available, $limit, $offset);
+ my $holds_object = $self->fetch_user_holds($hold_id ? [$hold_id] : undef, 0, 1, $available, $limit, $offset);
+ if($holds_object->{holds}) {
+ $ctx->{holds} = $holds_object->{holds};
+ }
+ $ctx->{holds_ids} = $holds_object->{all_ids};
+ $ctx->{holds_limit} = $limit;
+ $ctx->{holds_offset} = $offset;
return defined($hold_handle_result) ? $hold_handle_result : Apache2::Const::OK;
}
}]
},
from => 'au',
- where => {id => $e->requestor->id},
- limit => $limit,
- offset => $offset
+ where => {id => $e->requestor->id}
});
- $ctx->{holds} = $self->fetch_user_holds([map { $_->{id} } @$hold_ids], 0, 1, 0);
+ my $holds_object = $self->fetch_user_holds([map { $_->{id} } @$hold_ids], 0, 1, 0, $limit, $offset);
+ if($holds_object->{holds}) {
+ $ctx->{holds} = $holds_object->{holds};
+ }
+ $ctx->{hold_history_ids} = $holds_object->{all_ids};
+
return Apache2::Const::OK;
}
myopac_page = "holds";
limit = ctx.hold_history_limit;
offset = ctx.hold_history_offset;
+ count = ctx.hold_history_ids.size;
%]
<div id='myopac_holds_div'>
<div id="acct_holds_tabs">
<div class="align">
- <a href='[% mkurl('holds') %]'>[% l("Items on Hold") %]</a>
+ <a href='[% mkurl('holds',{},['limit','offset']) %]'>[% l("Items on Hold") %]</a>
</div>
<div class="align selected">
<a href="#">[% l("Holds History") %]</a>
<div class="header_middle">
<span style="float:left;">[% l("Previously Held Items") %]</span>
<span class='float-left' style='padding-left: 10px;'>
- <a href='[% mkurl(hold_history, {limit => limit,offset => (offset - limit)}) %]'
+ <a href='[% mkurl('hold_history', {limit => limit,offset => (offset - limit)}) %]'
[% IF offset == 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">◄</span>[% l('Previous') %]</a>
- [%# TODO: get total to prevent paging off then end of the list.. %]
- <a href='[% mkurl(hold_history, {limit => limit, offset => (offset + limit)}) %]'
- [% IF ctx.holds.size < limit %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">►</span></a>
+ [% IF offset > 0 || count > limit;
+ curpage = 0;
+ WHILE curpage * limit < count;
+ IF curpage * limit == offset;
+ %]
+ [% curpage + 1 %]
+ [%- ELSE %]
+ <a href='[% mkurl('holds_history', {limit => limit, offset => (curpage * limit)}) %]'>[% curpage + 1 %]</a>
+ [%- END;
+ curpage = curpage + 1;
+ END;
+ END %]
+ <a href='[% mkurl('hold_history', {limit => limit, offset => (offset + limit)}) %]'
+ [% IF count <= limit + offset %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">►</span></a>
</span>
<span style="float:right;">
<a class="hide_me" href="#">Export List</a>
PROCESS "opac/parts/misc_util.tt2";
PROCESS "opac/parts/hold_status.tt2";
WRAPPER "opac/parts/myopac/base.tt2";
- myopac_page = "holds" %]
+ myopac_page = "holds";
+ limit = ctx.holds_limit;
+ offset = ctx.holds_offset;
+ count = ctx.holds_ids.size;
+%]
<div id='myopac_holds_div'>
<div id="acct_holds_tabs">
<a href='#'>[% l("Items on Hold") %]</a>
</div>
<div class="align">
- <a href='[% mkurl('hold_history') %]'>[% l("Holds History") %]</a>
+ <a href='[% mkurl('hold_history', {}, ['limit','offset','available']) %]'>[% l("Holds History") %]</a>
</div>
</div>
END
%]
</span>
+ <span class='float-left' style='padding-left: 10px;'>
+ <a href='[% mkurl('holds', {limit => limit,offset => (offset - limit)}) %]'
+ [% IF offset <= 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">◄</span>[% l('Previous') %]</a>
+ [% IF offset > 0 || count > limit;
+ curpage = 0;
+ WHILE curpage * limit < count;
+ IF curpage * limit == offset;
+ %]
+ [% curpage + 1 %]
+ [%- ELSE %]
+ <a href='[% mkurl('holds', {limit => limit, offset => (curpage * limit)}) %]'>[% curpage + 1 %]</a>
+ [%- END;
+ curpage = curpage + 1;
+ END;
+ END %]
+ <a href='[% mkurl('holds', {limit => limit, offset => (offset + limit)}) %]'
+ [% IF count <= limit + offset %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">►</span></a>
+ </span>
+
<span style="float:right;">
<a class="hide_me" href="#">Export List</a>
</span>
<td align="right">
[% l("Show") %]
[% IF CGI.param("available") %]
- <a href="[% mkurl('holds', {}, ['available']) %]">[% l('all') %]</a> |
+ <a href="[% mkurl('holds', {},['limit','offset','available']) %]">[% l('all') %]</a> |
<strong>[% l("only available") %]</strong>
[% ELSE %]
<strong>[% l("all") %]</strong> |
- <a href="[% mkurl('holds', {available => 1}) %]">[% l("only available") %]</a>
+ <a href="[% mkurl('holds', {available => 1}, ['limit','offset']) %]">[% l("only available") %]</a>
[% END %]
[% l("holds") %]
<select class="hide_me" id="holds_sort">