@@ -, +, @@
identified by a regular expression (MARC300A_PARTS).
Verify that the hold notes are required.
Verify that the hold notes are no longer required for the record in
the preceding step. (This actually depends on your 300$a..)
Cancel the hold you placed.
Try to place the hold again. The hold notes should be required again.
Click Place Hold while more-options is collapsed (blank notes).
Is the correct hold note made visible?
---
C4/Reserves.pm | 44 +++++++++++++++++++-
.../opac-tmpl/bootstrap/en/modules/opac-reserve.tt | 36 ++++++++--------
opac/opac-reserve.pl | 2 +-
3 files changed, 61 insertions(+), 21 deletions(-)
--- a/C4/Reserves.pm
+++ a/C4/Reserves.pm
@@ -142,7 +142,7 @@ BEGIN {
IsItemOnHoldAndFound
);
- @EXPORT_OK = qw( MergeHolds );
+ @EXPORT_OK = qw( MergeHolds IsHoldNoteRequired );
}
=head2 AddReserve
@@ -2471,6 +2471,48 @@ sub IsItemOnHoldAndFound {
return $found;
}
+=head2 IsHoldNoteRequired
+
+ my $boolean = IsHoldNoteRequired( $marc );
+
+ Checks if a hold note is required for a given record.
+ Triggered by the pref HoldNoteReasons.
+ This pref may contain a list of reason codes to be checked.
+ So, it could look like: LEADER_SERIAL|MARC300A_PARTS
+
+ This routine returns true if the note is required, undef otherwise.
+
+=cut
+
+sub IsHoldNoteRequired {
+ my ( $marcrecord ) = @_;
+ return if !$marcrecord || !C4::Context->preference( 'OPACHoldNotes' );
+ my $reasons = uc C4::Context->preference( 'HoldNoteReasons' );
+ return if !$reasons;
+ my $ldr = $marcrecord->leader;
+
+ # check LEADER_SERIAL
+ if( $reasons =~ /LEADER_SERIAL/ && substr($ldr,7,1) eq 's' ) {
+ return 1;
+ }
+ # check LEADER_COLLECTION
+ if( $reasons =~ /LEADER_COLLECTION/ && substr($ldr,7,1) eq 'c' ) {
+ return 1;
+ }
+ # check MARC300A_PARTS
+ if( $reasons =~ /MARC300A_PARTS/ &&
+ ( my @fld = $marcrecord->field('300') )) {
+ my $re = qr/(\d+)\s*(v\.|vol|dl|delen|band|bd|tle|parts|pts|t\.|tome)/i;
+ foreach my $f ( @fld ) {
+ next if !$f->subfield('a');
+ # Check for something like 3 parts or 22 volumes in 300$a
+ return 1 if $f->subfield('a') =~ /$re/ && $1 > 1;
+ }
+ }
+ # next reason comes here..
+ return;
+}
+
=head1 AUTHOR
Koha Development Team