From: Zavier Banks Date: Wed, 13 May 2020 11:08:38 +0000 (+0000) Subject: LP1853006 TPAC: add limit to available option to item table X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2de97ef69877a3eec1edba918ed9d308c844e5b1;p=Evergreen.git LP1853006 TPAC: add limit to available option to item table This patch adds a new control to the item table in the TPAC public catalog only to specify that only items that are available should be displayed. Signed-off-by: Zavier Banks Signed-off-by: Michele Morgan Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm index 76ee00d6b8..f8e2f49dc1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/AppUtils.pm @@ -2088,7 +2088,8 @@ sub basic_opac_copy_query { ccs => [ {column => 'id', alias => 'status_code'}, {column => 'name', alias => 'copy_status'}, - {column => 'holdable', alias => 'status_holdable'} + {column => 'holdable', alias => 'status_holdable'}, + {column => 'is_available', alias => 'is_available'} ], acn => [ {column => 'label', alias => 'call_number_label'}, diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 0fa267b3bd..c4c14d04ae 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -35,6 +35,8 @@ sub load_record { my $org_name = $ctx->{get_aou}->($org)->shortname; my $pref_ou = $self->_get_pref_lib(); my $depth = $self->cgi->param('depth'); + my $available = $self->cgi->param('available') || 'false'; + $depth = $ctx->{get_aou}->($org)->ou_type->depth unless defined $depth; # can be 0 @@ -214,6 +216,7 @@ sub load_record { $self->timelog("past store copy retrieval call"); $ctx->{copy_limit} = $copy_limit; $ctx->{copy_offset} = $copy_offset; + $ctx->{available} = $available; $ctx->{have_holdings_to_show} = 0; $ctx->{have_mfhd_to_show} = 0; @@ -350,14 +353,27 @@ sub mk_copy_query { my $copy_offset = shift; my $pref_ou = shift; my $coords = shift; + my $staff = $self->ctx->{is_staff}; + my $available = $self->cgi->param('available') || 'false'; my $query = $U->basic_opac_copy_query( - $rec_id, undef, undef, $copy_limit, $copy_offset, $self->ctx->{is_staff} + $rec_id, undef, undef, $copy_limit, $copy_offset, $staff ); + if($available eq 'true') { + $query->{where} = { + '+acp' => { + deleted => 'f', + ($staff ? () : (opac_visible => 't')) + }, + '+ccs' => { is_available => 't'}, + ($staff ? () : ( '+aou' => { opac_visible => 't' } )) + }; + } + my $lasso_orgs = $self->search_lasso_orgs; - if($lasso_orgs || $org != $self->ctx->{aou_tree}->()->id) { + if($lasso_orgs || $org != $self->ctx->{aou_tree}->()->id) { # no need to add the org join filter if we're not actually filtering my $filter_orgs = $lasso_orgs || $org; diff --git a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 index 358b836b16..c70e356c0a 100644 --- a/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 +++ b/Open-ILS/src/templates/opac/parts/record/copy_table.tt2 @@ -12,6 +12,7 @@ IF serial_holdings; copies = copies.merge(units); END; END; +available=ctx.available; FOREACH copy_info IN copies; IF copy_info.call_number_label != '##URI##'; @@ -44,6 +45,7 @@ IF has_copies or ctx.foreign_copies; depth = CGI.param('copy_depth').defined ? CGI.param('copy_depth') : CGI.param('depth').defined ? CGI.param('depth') : ctx.copy_summary.last.depth; total_copies = ctx.copy_summary.$depth.count; %] + [% use_courses = (ctx.get_org_setting(ctx.aou_tree.id, 'circ.course_materials_opt_in') == 1) ? 1 : 0 %] [% IF ctx.geo_sort %]
@@ -69,6 +71,20 @@ IF has_copies or ctx.foreign_copies;
[% END %] [% END %] + +
+[% IF available == 'true'; %] + + Show All Copies + +[% END; %] + +[% IF available == 'false'; %] + + Show Only Available Copies + +[% END; %] + @@ -105,30 +121,30 @@ IF has_copies or ctx.foreign_copies; [%- FOREACH peer IN ctx.foreign_copies; - FOREACH bib IN peer.foreign_copy_maps; %] - - - - - - - [%- IF use_courses %] - - [%- END %] - [%- IF ctx.geo_sort && ctx.has_valid_coords %] - - [%- END %] - + FOREACH bib IN peer.foreign_copy_maps; %] + + + + + + + [%- IF use_courses %] + + [%- END %] + [%- IF ctx.geo_sort && ctx.has_valid_coords %] + + [%- END %] + [%- END; # FOREACH peer END; # FOREACH bib -%] @@ -148,149 +164,150 @@ END; # FOREACH bib END; -%] - [%- IF serial_holdings %] - [%- ELSE %][% END %] - - [%- IF has_parts == 'true' %] - - [%- END %] - + [%- ELSE %][% END %] + + [%- IF has_parts == 'true' %] + + [%- END %] + - - [% IF copy_info.courses.size > 0 || ctx.is_staff %] - - [% ELSIF use_courses %] - - [% END %] - [% IF ctx.is_staff %] - - + + + [% IF copy_info.courses.size > 0 || ctx.is_staff %] + + [% ELSIF use_courses %] + + [% END %] + [% IF ctx.is_staff %] + + + + [% END # is_staff %] + [% IF ctx.is_staff OR serial_holdings %] + - [% END # is_staff %] - [% IF ctx.is_staff OR serial_holdings %] - - [%- END %] - - - [%- IF use_courses %] - - [% END %] - [%- IF ctx.geo_sort && ctx.has_valid_coords %] - - [%- END %] - + hold_link; + ELSE; + l("Not holdable"); + END %] + [%- END %] + + + [%- IF use_courses %] + + [% END %] + [%- IF ctx.geo_sort && ctx.has_valid_coords %] + + [%- END %] + [% IF copy_info.notes; %] [% FOREACH note IN copy_info.notes; %] @@ -339,7 +356,6 @@ END; # FOREACH bib [%- END; # FOR copy_info %] - [%- IF ctx.copy_offset > 0 AND NOT serial_holdings; new_offset = ctx.copy_offset - ctx.copy_limit; IF new_offset < 0; new_offset = 0; END %] @@ -375,4 +391,5 @@ END; # FOREACH bib [%- END %]
- [%- bib_lib_name = ctx.get_aou(bib.target_copy.circ_lib).name | html; - l("[_1] (foreign item)", bib_lib_name); -%] - - [% bib.target_copy.call_number.label | html %][% bib.target_copy.barcode | html %][% bib.target_copy.location.name | html %][% bib.target_copy.status.name | html %][% date.format(ctx.parse_datetime(copy_info.due_date, copy_info.circ_circ_lib),DATE_FORMAT) %][% display_ou_distance(bib.target_copy.circ_lib) %]
+ [%- bib_lib_name = ctx.get_aou(bib.target_copy.circ_lib).name | html; + l("[_1] (foreign item)", bib_lib_name); -%] + + [% bib.target_copy.call_number.label | html %][% bib.target_copy.barcode | html %][% bib.target_copy.location.name | html %][% bib.target_copy.status.name | html %][% date.format(ctx.parse_datetime(copy_info.due_date, copy_info.circ_circ_lib),DATE_FORMAT) %][% display_ou_distance(bib.target_copy.circ_lib) %]
- [%- copy_info.holding_label | html; -%] - - [%- INCLUDE "opac/parts/library_name_link.tt2"; -%] - - - [% callnum | html %] [% IF ctx.get_org_setting(CGI.param('loc') - OR ctx.aou_tree.id, 'sms.enable') == 1 %](Text)[% END %][% copy_info.part_label | html %] - [% copy_info.barcode | html -%] - [% IF ctx.is_staff %] - [%- IF ctx.is_browser_staff %] - [% l('view') %] - [% IF ctx.has_perm('UPDATE_COPY', copy_info.circ_lib) - OR ctx.has_perm('UPDATE_COPY', copy_info.call_number_owning_lib) %] - | - [% l('edit') %] + [%- IF serial_holdings %] + [%- copy_info.holding_label | html; -%] + + [%- INCLUDE "opac/parts/library_name_link.tt2"; -%] + + + [% callnum | html %] [% IF ctx.get_org_setting(CGI.param('loc') + OR ctx.aou_tree.id, 'sms.enable') == 1 %](Text)[% END %][% copy_info.part_label | html %] + [% copy_info.barcode | html -%] + [% IF ctx.is_staff %] + [%- IF ctx.is_browser_staff %] + [% l('view') %] + [% IF ctx.has_perm('UPDATE_COPY', copy_info.circ_lib) + OR ctx.has_perm('UPDATE_COPY', copy_info.call_number_owning_lib) %] + | + [% l('edit') %] + [% END %] + [% ELSE %] + [% l('view') %] + [%# if the user can edit copies, show the copy edit link %] + [% IF ctx.has_perm('UPDATE_COPY', copy_info.circ_lib) + OR ctx.has_perm('UPDATE_COPY', copy_info.call_number_owning_lib) %] + | + + [% l(' edit') %] + + [% END %] [% END %] - [% ELSE %] - [% l('view') %] - [%# if the user can edit copies, show the copy edit link %] - [% IF ctx.has_perm('UPDATE_COPY', copy_info.circ_lib) - OR ctx.has_perm('UPDATE_COPY', copy_info.call_number_owning_lib) %] - | - - [% l(' edit') %] - [% END %] - [% END %] - [% END %] - [%- IF attrs.gtin13; - ''; - END; -%] - [%- INCLUDE "opac/parts/location_name_link.tt2"; -%][% copy_info.circ_modifier | html %] - [% copy_info.age_protect ? - ctx.get_crahp(copy_info.age_protect).name : l('None') | html %] - [% - IF ctx.get_org_setting(copy_info.circ_lib, 'circ.holds.age_protect.active_date') == 1; - disp_date = copy_info.active_date ? copy_info.active_date : copy_info.create_date; - ELSE; - disp_date = copy_info.create_date; - END; - - IF disp_date; - date.format( - ctx.parse_datetime(disp_date), - DATE_FORMAT + [%- IF attrs.gtin13; + ''; + END; -%] + [%- INCLUDE "opac/parts/location_name_link.tt2"; -%][% copy_info.circ_modifier | html %][% copy_info.circ_modifier | html %] + [% copy_info.age_protect ? + ctx.get_crahp(copy_info.age_protect).name : l('None') | html %] + [% + IF ctx.get_org_setting(copy_info.circ_lib, 'circ.holds.age_protect.active_date') == 1; + disp_date = copy_info.active_date ? copy_info.active_date : copy_info.create_date; + ELSE; + disp_date = copy_info.create_date; + END; + + IF disp_date; + date.format( + ctx.parse_datetime(disp_date), + DATE_FORMAT + ); + ELSE; + '-'; + END; + %][% # Show copy/volume hold links to staff (without + # checking whether they have permissions to do those). + overall_holdable = ( + copy_info.holdable == 't' AND + copy_info.location_holdable == 't' AND + copy_info.status_holdable == 't' ); - ELSE; - '-'; - END; - %][% # Show copy/volume hold links to staff (without - # checking whether they have permissions to do those). - overall_holdable = ( - copy_info.holdable == 't' AND - copy_info.location_holdable == 't' AND - copy_info.status_holdable == 't' - ); - IF overall_holdable; - hold_link = ''; - param_sep = l(" / "); + IF overall_holdable; + hold_link = ''; + param_sep = l(" / "); - # Only staff get to place copy or volume holds - IF ctx.is_staff; - hold_link = '' _ l('Copy hold') _ ''; - IF copy_info.call_number != last_cn; - last_cn = copy_info.call_number; - hold_link = hold_link _ param_sep; - hold_link = hold_link _ ' copy_info.call_number, - hold_type => 'V', + hold_target => copy_info.id, + hold_type => 'C', hold_source_page => mkurl() - }) _ '">' _ l('Volume hold') _ ''; - END; - IF serial_holdings; - hold_link = hold_link _ param_sep; + }) _ '">' _ l('Copy hold') _ ''; + IF copy_info.call_number != last_cn; + last_cn = copy_info.call_number; + hold_link = hold_link _ param_sep; + hold_link = hold_link _ '' _ l('Volume hold') _ ''; + END; + IF serial_holdings; + hold_link = hold_link _ param_sep; + END; + END; + IF serial_holdings; + hold_link = hold_link _ + '' _ l('Issue hold') _ ''; END; - END; - IF serial_holdings; - hold_link = hold_link _ - '' _ l('Issue hold') _ ''; - END; - - hold_link; - ELSE; - l("Not holdable"); - END %][%- - schema_copy_status.${copy_info.status_code}; - copy_info.copy_status | html; - -%][% - IF copy_info.due_date; - date.format( - ctx.parse_datetime(copy_info.due_date, copy_info.circ_circ_lib), - DATE_FORMAT - ); - ELSE; - '-'; - END %][%- FOREACH course IN copy_info.courses %] -
[% course.course_number %]
- [% END %]
[% display_ou_distance(copy_info.circ_lib) %]
[%- + schema_copy_status.${copy_info.status_code}; + copy_info.copy_status | html; + -%][% + IF copy_info.due_date; + date.format( + ctx.parse_datetime(copy_info.due_date, copy_info.circ_circ_lib), + DATE_FORMAT + ); + ELSE; + '-'; + END %][%- FOREACH course IN copy_info.courses %] +
[% course.course_number %]
+ [% END %]
[% display_ou_distance(copy_info.circ_lib) %]
 [% note.title | html %]: [% note.value | html %]
+
[% END; %]