View | Details | Raw Unified | Return to bug 9743
Collapse All | Expand All

(-)a/C4/Reserves.pm (+71 lines)
Lines 2151-2156 sub ReserveSlip { Link Here
2151
    );
2151
    );
2152
}
2152
}
2153
2153
2154
=head2 GetMandatoryNoteReason
2155
2156
  my $reason= GetMandatoryNoteReason( $biblionumber, $marcrecord )
2157
2158
  Returns an integer representing the reason for a mandatory holds note.
2159
  Returns zero if the note is not mandatory or OPACShowHoldNotes is disabled.
2160
2161
  The reasons are listed in the opac-reserve template.
2162
2163
=cut
2164
2165
sub GetMandatoryNoteReason {
2166
    my ($biblionumber, $marcrecord) = @_;
2167
2168
    my $mandatoryReasons= C4::Context->preference('OPACMandatoryHoldNotes');
2169
    my $shownotes= C4::Context->preference('OPACShowHoldNotes');
2170
    return 0 if !$mandatoryReasons || !$shownotes;
2171
2172
    my ($res,$first);
2173
    my @subexpr= split ',',$mandatoryReasons;
2174
    #contains a list of numbered reasons in the form of 1,3&4,2,5&4,6
2175
    #meaning check 1, or 3 and 4, or 2, or 5 and 4, or 6 ..
2176
    #for a combined check 3&4, the firstmentioned reason (3) is returned
2177
    foreach my $expr (@subexpr) {
2178
        my @checks= split '&', $expr;
2179
        $first=0;
2180
        foreach my $check (@checks) {
2181
            next if $check!~/(\d+)/;
2182
            $first=$1 if !$first;
2183
            $res= _CheckReason($biblionumber, $marcrecord, $1);
2184
            last if !$res;
2185
        }
2186
        return $first if $res;
2187
    }
2188
    return 0; #nothing found to justify a mandatory note
2189
}
2190
2191
sub _CheckReason {
2192
#Returns false if the condition is not met or an error occurred
2193
    my ($biblionumber, $marcrecord, $check)= @_;
2194
2195
    if($check==1) { #MARC21: 300a contains ref to multiple parts/volumes
2196
        if(my $f=$marcrecord->field('300') ) {
2197
            if($f->subfield('a') && $f->subfield('a')=~ /(\d+)\s*(v\.|vol|dl|delen|bd|tle|parts|pts|t\.|tome)/i) {
2198
            #FIXME: Actually a cataloging language dependent test
2199
                return 1 if $1>1;
2200
            }
2201
        }
2202
    }
2203
    elsif($check==2) { #Number of items==1
2204
        my $sql="select count(*) from items where biblionumber=?";
2205
        my $dbh= C4::Context->dbh;
2206
        my @c=$dbh->selectrow_array($sql,undef,($biblionumber));
2207
        return 1 if @c && $c[0]==1;
2208
        #if @c does not have rows, something went very wrong: return false
2209
    }
2210
    elsif($check==3) { #Added for UNIMARC testing: Title contains test
2211
        if(my $f=$marcrecord->field('200') ) {
2212
            if($f->subfield('a')) {
2213
                return 1 if $f->subfield('a')=~/test/i;
2214
            }
2215
        }
2216
    }
2217
    elsif($check==4) { #MARC21: Leader pos 07 equals c (collection)
2218
        if(my $ldr=$marcrecord->leader) {
2219
            return 1 if substr($ldr,7,1) eq 'c';
2220
        }
2221
    }
2222
    return 0;
2223
}
2224
2154
=head1 AUTHOR
2225
=head1 AUTHOR
2155
2226
2156
Koha Development Team <http://koha-community.org/>
2227
Koha Development Team <http://koha-community.org/>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt (+18 lines)
Line 0 Link Here
1
The following reasons can be used:
2
3
1) MARC21 300$a contains a term indicating multiple volumes or parts (like v. or vol or pts).
4
2) The biblio record only has one item. This reason is only meant for use in combination with another reason like number 1.
5
3) UNIMARC 200$a contains the word 'test'. Added for test purposes.
6
4) MARC21 leader position 7 contains c for collection.
7
8
How do you specify the reasons you want to use?
9
Just add them in your preferred order between commas in preference OPACMandatoryHoldNotes.
10
When you want to include an additional subcondition like number 2, use an expression like 1&2 indicating that you check for 1 AND 2.
11
So, as an example, you could write 4,1&2,3 meaning check reason 4 first, then check on 1 and 2, and finally check 3.
12
13
For developers: How do you add a mandatory hold notes reason?
14
1) Pick the next free number from opac-reserves.tt: add an entry to the ForceHoldNotesReasons array.
15
2) Add your new reason to this documentation file: koha-tmpl/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt.
16
3) Add the code for this reason to sub _CheckReason in Reserves.pm.
17
4) Submit a patch!
18
5) Edit pref OPACMandatoryHoldNotes and add the new number.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+4 lines)
Lines 492-497 OPAC: Link Here
492
                  no: "Don't allow"
492
                  no: "Don't allow"
493
                  yes: Allow
493
                  yes: Allow
494
            - opac users to share private lists with other patrons. This feature is not active yet but will be released soon
494
            - opac users to share private lists with other patrons. This feature is not active yet but will be released soon
495
        -
496
            - You can specify which conditions make hold notes mandatory. This pref is only active when OPACShowHoldNotes is enabled. For more information, click <a href="/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt" target="_blank">here</a>.
497
            - pref: OPACMandatoryHoldNotes
498
              type: textarea
495
499
496
    Privacy:
500
    Privacy:
497
        -
501
        -
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt (-3 / +22 lines)
Lines 4-12 Link Here
4
<script type="text/javascript">
4
<script type="text/javascript">
5
// <![CDATA[
5
// <![CDATA[
6
 var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
6
 var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
7
 var MSG_EMPTY_MAND_NOTE = _("Please enter mandatory hold notes.");
7
 var ForceHoldNotesReasons=new Array(
8
 var ForceHoldNotesReasons=new Array(
8
    _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."),
9
    _("This title consists of multiple volumes/parts. Please indicate which part you need. Looking at the specific copy information may be helpful."), // R 1
9
    "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones.
10
    "This title has one item.", // R 2 (meant only for combining with R 1; no translation)
11
    "UNIMARC test: Title contains 'test'.", // R 3 (unimarc testing; no translation)
12
    _("This title represents a collection. Please indicate which part you need."), // R 4 (MARC21 leader: collection)
13
    "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones. Add the _() for translation!
10
14
11
 function prefixOf (s, tok) {
15
 function prefixOf (s, tok) {
12
     var index = s.indexOf(tok);
16
     var index = s.indexOf(tok);
Lines 137-147 Link Here
137
141
138
        // Find the items with the 'Hold' box checked
142
        // Find the items with the 'Hold' box checked
139
        var badBib = null;
143
        var badBib = null;
144
        var emptyMandNote=0;
140
        $(".confirmjs:checked").each(function() {
145
        $(".confirmjs:checked").each(function() {
141
            var biblioNum = $(this).val();
146
            var biblioNum = $(this).val();
142
            biblionumbers += biblioNum + "/";
147
            biblionumbers += biblioNum + "/";
143
            selections += biblioNum + "/";
148
            selections += biblioNum + "/";
144
149
150
            // Check mandatory notes
151
            if($("#notesmandatory_"+biblioNum).val()>0) {
152
                if($.trim($("#notes_"+biblioNum).val())==='') {
153
                    emptyMandNote= biblioNum;
154
                    return false;
155
                }
156
            }
157
145
            // If the 'specific copy' radio button is checked
158
            // If the 'specific copy' radio button is checked
146
            if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
159
            if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
147
                // Find the selected copy
160
                // Find the selected copy
Lines 168-173 Link Here
168
            alert(MSG_NO_COPY_SELECTED);
181
            alert(MSG_NO_COPY_SELECTED);
169
            return false;
182
            return false;
170
        }
183
        }
184
        else if(emptyMandNote>0) {
185
            alert(MSG_EMPTY_MAND_NOTE);
186
            $(".notesrow").hide();
187
            $("#notesrow_"+emptyMandNote).show();
188
            return false;
189
        }
171
190
172
        $("#selections").val(selections);
191
        $("#selections").val(selections);
173
        $("#biblionumbers").val(biblionumbers);
192
        $("#biblionumbers").val(biblionumbers);
Lines 449-455 Link Here
449
                      <td colspan="[% itemtable_colspan %]">
468
                      <td colspan="[% itemtable_colspan %]">
450
                          <label for="holdnotes">Hold notes:</label>&nbsp;
469
                          <label for="holdnotes">Hold notes:</label>&nbsp;
451
                          <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
470
                          <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
452
                          <textarea name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
471
                          <textarea id="notes_[% bibitemloo.biblionumber %]" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
453
                          <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
472
                          <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
454
                      </td>
473
                      </td>
455
                  </tr>
474
                  </tr>
(-)a/opac/opac-reserve.pl (-2 / +1 lines)
Lines 374-380 foreach my $biblioNum (@biblionumbers) { Link Here
374
    $biblioLoopIter{rank} = $biblioData->{rank};
374
    $biblioLoopIter{rank} = $biblioData->{rank};
375
    $biblioLoopIter{reservecount} = $biblioData->{reservecount};
375
    $biblioLoopIter{reservecount} = $biblioData->{reservecount};
376
    $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
376
    $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
377
    $biblioLoopIter{mandatorynotes}=0; #FIXME: For future use
377
    $biblioLoopIter{mandatorynotes}= C4::Reserves::GetMandatoryNoteReason($biblioNum, $record); #zero means that note is not mandatory
378
378
379
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
379
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
380
        $biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description};
380
        $biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description};
381
- 

Return to bug 9743