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

(-)a/C4/Reserves.pm (+71 lines)
Lines 2217-2222 sub GetReservesControlBranch { Link Here
2217
    return $branchcode;
2217
    return $branchcode;
2218
}
2218
}
2219
2219
2220
=head2 GetMandatoryNoteReason
2221
2222
  my $reason= GetMandatoryNoteReason( $biblionumber, $marcrecord )
2223
2224
  Returns an integer representing the reason for a mandatory holds note.
2225
  Returns zero if the note is not mandatory or OPACHoldNotes is disabled.
2226
2227
  The reasons are listed in the opac-reserve template.
2228
2229
=cut
2230
2231
sub GetMandatoryNoteReason {
2232
    my ($biblionumber, $marcrecord) = @_;
2233
2234
    my $mandatoryReasons= C4::Context->preference('OPACMandatoryHoldNotes');
2235
    my $shownotes= C4::Context->preference('OPACHoldNotes');
2236
    return 0 if !$mandatoryReasons || !$shownotes;
2237
2238
    my ($res,$first);
2239
    my @subexpr= split ',',$mandatoryReasons;
2240
    #contains a list of numbered reasons in the form of 1,3&4,2,5&4,6
2241
    #meaning check 1, or 3 and 4, or 2, or 5 and 4, or 6 ..
2242
    #for a combined check 3&4, the firstmentioned reason (3) is returned
2243
    foreach my $expr (@subexpr) {
2244
        my @checks= split '&', $expr;
2245
        $first=0;
2246
        foreach my $check (@checks) {
2247
            next if $check!~/(\d+)/;
2248
            $first=$1 if !$first;
2249
            $res= _CheckReason($biblionumber, $marcrecord, $1);
2250
            last if !$res;
2251
        }
2252
        return $first if $res;
2253
    }
2254
    return 0; #nothing found to justify a mandatory note
2255
}
2256
2257
sub _CheckReason {
2258
#Returns false if the condition is not met or an error occurred
2259
    my ($biblionumber, $marcrecord, $check)= @_;
2260
2261
    if($check==1) { #MARC21: 300a contains ref to multiple parts/volumes
2262
        if(my $f=$marcrecord->field('300') ) {
2263
            if($f->subfield('a') && $f->subfield('a')=~ /(\d+)\s*(v\.|vol|dl|delen|bd|tle|parts|pts|t\.|tome)/i) {
2264
            #FIXME: Actually a cataloging language dependent test
2265
                return 1 if $1>1;
2266
            }
2267
        }
2268
    }
2269
    elsif($check==2) { #Number of items==1
2270
        my $sql="select count(*) from items where biblionumber=?";
2271
        my $dbh= C4::Context->dbh;
2272
        my @c=$dbh->selectrow_array($sql,undef,($biblionumber));
2273
        return 1 if @c && $c[0]==1;
2274
        #if @c does not have rows, something went very wrong: return false
2275
    }
2276
    elsif($check==3) { #Added for UNIMARC testing: Title contains test
2277
        if(my $f=$marcrecord->field('200') ) {
2278
            if($f->subfield('a')) {
2279
                return 1 if $f->subfield('a')=~/test/i;
2280
            }
2281
        }
2282
    }
2283
    elsif($check==4) { #MARC21: Leader pos 07 equals c (collection)
2284
        if(my $ldr=$marcrecord->leader) {
2285
            return 1 if substr($ldr,7,1) eq 'c';
2286
        }
2287
    }
2288
    return 0;
2289
}
2290
2220
=head1 AUTHOR
2291
=head1 AUTHOR
2221
2292
2222
Koha Development Team <http://koha-community.org/>
2293
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 510-515 OPAC: Link Here
510
                  no: "Don't allow"
510
                  no: "Don't allow"
511
                  yes: Allow
511
                  yes: Allow
512
            - opac users to share private lists with other patrons. This feature is not active yet but will be released soon
512
            - opac users to share private lists with other patrons. This feature is not active yet but will be released soon
513
        -
514
            - You can specify which conditions make hold notes mandatory. This pref is only active when OPACHoldNotes is enabled. For more information, click <a href="/intranet-tmpl/prog/en/modules/admin/mandatory-hold-notes.tt" target="_blank">here</a>.
515
            - pref: OPACMandatoryHoldNotes
516
              type: textarea
513
517
514
    Privacy:
518
    Privacy:
515
        -
519
        -
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt (-3 / +25 lines)
Lines 5-13 Link Here
5
<script type="text/javascript">
5
<script type="text/javascript">
6
// <![CDATA[
6
// <![CDATA[
7
 var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
7
 var MSG_NO_COPY_SELECTED = _("Expecting a specific copy selection.");
8
 var MSG_EMPTY_MAND_NOTE = _("Please enter additional information in the hold notes that have a red asterisk.");
8
 var ForceHoldNotesReasons=new Array(
9
 var ForceHoldNotesReasons=new Array(
9
    _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific copy information may be helpful."),
10
    _("This title consists of multiple volumes/parts. Please indicate which part you need. Looking at the specific copy information may be helpful."), // R 1
10
    "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones.
11
    "This title has one item.", // R 2 (meant only for combining with R 1; no translation)
12
    "UNIMARC test: Title contains 'test'.", // R 3 (unimarc testing; no translation)
13
    _("This title represents a collection. Please indicate which part you need."), // R 4 (MARC21 leader: collection)
14
    "*** Add a new reason above this line ***" ); // NOTE: Do not renumber reasons; this will affect use of existing ones. Add the _() for translation!
11
15
12
 function prefixOf (s, tok) {
16
 function prefixOf (s, tok) {
13
     var index = s.indexOf(tok);
17
     var index = s.indexOf(tok);
Lines 140-150 Link Here
140
144
141
        // Find the items with the 'Hold' box checked
145
        // Find the items with the 'Hold' box checked
142
        var badBib = null;
146
        var badBib = null;
147
        var emptyMandNote=0;
143
        $(".confirmjs:checked").each(function() {
148
        $(".confirmjs:checked").each(function() {
144
            var biblioNum = $(this).val();
149
            var biblioNum = $(this).val();
145
            biblionumbers += biblioNum + "/";
150
            biblionumbers += biblioNum + "/";
146
            selections += biblioNum + "/";
151
            selections += biblioNum + "/";
147
152
153
            // Check mandatory notes
154
            if($("#notesmandatory_"+biblioNum).val()>0) {
155
                if($.trim($("#holdnotes"+biblioNum).val())==='') {
156
                    emptyMandNote= biblioNum;
157
                    return false;
158
                }
159
            }
160
148
            // If the 'specific copy' radio button is checked
161
            // If the 'specific copy' radio button is checked
149
            if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
162
            if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
150
                // Find the selected copy
163
                // Find the selected copy
Lines 171-176 Link Here
171
            alert(MSG_NO_COPY_SELECTED);
184
            alert(MSG_NO_COPY_SELECTED);
172
            return false;
185
            return false;
173
        }
186
        }
187
        else if(emptyMandNote>0) {
188
            alert(MSG_EMPTY_MAND_NOTE);
189
            return false;
190
        }
174
191
175
        $("#selections").val(selections);
192
        $("#selections").val(selections);
176
        $("#biblionumbers").val(biblionumbers);
193
        $("#biblionumbers").val(biblionumbers);
Lines 208-213 Link Here
208
            }
225
            }
209
        });
226
        });
210
    [% END %]
227
    [% END %]
228
    [% IF bibitemloo.mandatorynotes %]
229
        // Show more options when hold notes are mandatory
230
        $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
231
    [% END %]
211
[% END %]
232
[% END %]
212
233
213
 });
234
 });
Lines 412-419 Link Here
412
                            <li>
433
                            <li>
413
                                <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
434
                                <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
414
                                  <label for="holdnotes[% bibitemloo.biblionumber %]">Hold notes:</label>
435
                                  <label for="holdnotes[% bibitemloo.biblionumber %]">Hold notes:</label>
415
                                  <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
416
                                  <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
436
                                  <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
437
                                  [% IF bibitemloo.mandatorynotes %]<span style="color:red;">* </span>[% END %]
438
                                  <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
417
                                  <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
439
                                  <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
418
                                </div>
440
                                </div>
419
                            </li>
441
                            </li>
(-)a/opac/opac-reserve.pl (-2 / +1 lines)
Lines 373-379 foreach my $biblioNum (@biblionumbers) { Link Here
373
    $biblioLoopIter{rank} = $biblioData->{rank};
373
    $biblioLoopIter{rank} = $biblioData->{rank};
374
    $biblioLoopIter{reservecount} = $biblioData->{reservecount};
374
    $biblioLoopIter{reservecount} = $biblioData->{reservecount};
375
    $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
375
    $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
376
    $biblioLoopIter{mandatorynotes}=0; #FIXME: For future use
376
    $biblioLoopIter{mandatorynotes}= C4::Reserves::GetMandatoryNoteReason($biblioNum, $record); #zero means that note is not mandatory
377
377
378
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
378
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
379
        $biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description};
379
        $biblioLoopIter{description} = $itemTypes->{$biblioData->{itemtype}}{description};
380
- 

Return to bug 9743