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

(-)a/C4/Reserves.pm (+71 lines)
Lines 2168-2173 sub ReserveSlip { Link Here
2168
    );
2168
    );
2169
}
2169
}
2170
2170
2171
=head2 GetMandatoryNoteReason
2172
2173
  my $reason= GetMandatoryNoteReason( $biblionumber, $marcrecord )
2174
2175
  Returns an integer representing the reason for a mandatory holds note.
2176
  Returns zero if the note is not mandatory or OPACHoldNotes is disabled.
2177
2178
  The reasons are listed in the opac-reserve template.
2179
2180
=cut
2181
2182
sub GetMandatoryNoteReason {
2183
    my ($biblionumber, $marcrecord) = @_;
2184
2185
    my $mandatoryReasons= C4::Context->preference('OPACMandatoryHoldNotes');
2186
    my $shownotes= C4::Context->preference('OPACHoldNotes');
2187
    return 0 if !$mandatoryReasons || !$shownotes;
2188
2189
    my ($res,$first);
2190
    my @subexpr= split ',',$mandatoryReasons;
2191
    #contains a list of numbered reasons in the form of 1,3&4,2,5&4,6
2192
    #meaning check 1, or 3 and 4, or 2, or 5 and 4, or 6 ..
2193
    #for a combined check 3&4, the firstmentioned reason (3) is returned
2194
    foreach my $expr (@subexpr) {
2195
        my @checks= split '&', $expr;
2196
        $first=0;
2197
        foreach my $check (@checks) {
2198
            next if $check!~/(\d+)/;
2199
            $first=$1 if !$first;
2200
            $res= _CheckReason($biblionumber, $marcrecord, $1);
2201
            last if !$res;
2202
        }
2203
        return $first if $res;
2204
    }
2205
    return 0; #nothing found to justify a mandatory note
2206
}
2207
2208
sub _CheckReason {
2209
#Returns false if the condition is not met or an error occurred
2210
    my ($biblionumber, $marcrecord, $check)= @_;
2211
2212
    if($check==1) { #MARC21: 300a contains ref to multiple parts/volumes
2213
        if(my $f=$marcrecord->field('300') ) {
2214
            if($f->subfield('a') && $f->subfield('a')=~ /(\d+)\s*(v\.|vol|dl|delen|bd|tle|parts|pts|t\.|tome)/i) {
2215
            #FIXME: Actually a cataloging language dependent test
2216
                return 1 if $1>1;
2217
            }
2218
        }
2219
    }
2220
    elsif($check==2) { #Number of items==1
2221
        my $sql="select count(*) from items where biblionumber=?";
2222
        my $dbh= C4::Context->dbh;
2223
        my @c=$dbh->selectrow_array($sql,undef,($biblionumber));
2224
        return 1 if @c && $c[0]==1;
2225
        #if @c does not have rows, something went very wrong: return false
2226
    }
2227
    elsif($check==3) { #Added for UNIMARC testing: Title contains test
2228
        if(my $f=$marcrecord->field('200') ) {
2229
            if($f->subfield('a')) {
2230
                return 1 if $f->subfield('a')=~/test/i;
2231
            }
2232
        }
2233
    }
2234
    elsif($check==4) { #MARC21: Leader pos 07 equals c (collection)
2235
        if(my $ldr=$marcrecord->leader) {
2236
            return 1 if substr($ldr,7,1) eq 'c';
2237
        }
2238
    }
2239
    return 0;
2240
}
2241
2171
=head1 AUTHOR
2242
=head1 AUTHOR
2172
2243
2173
Koha Development Team <http://koha-community.org/>
2244
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 / +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 132-142 Link Here
132
136
133
        // Find the items with the 'Hold' box checked
137
        // Find the items with the 'Hold' box checked
134
        var badBib = null;
138
        var badBib = null;
139
        var emptyMandNote=0;
135
        $(".confirmjs:checked").each(function() {
140
        $(".confirmjs:checked").each(function() {
136
            var biblioNum = $(this).val();
141
            var biblioNum = $(this).val();
137
            biblionumbers += biblioNum + "/";
142
            biblionumbers += biblioNum + "/";
138
            selections += biblioNum + "/";
143
            selections += biblioNum + "/";
139
144
145
            // Check mandatory notes
146
            if($("#notesmandatory_"+biblioNum).val()>0) {
147
                if($.trim($("#notes_"+biblioNum).val())==='') {
148
                    emptyMandNote= biblioNum;
149
                    return false;
150
                }
151
            }
152
140
            // If the 'specific copy' radio button is checked
153
            // If the 'specific copy' radio button is checked
141
            if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
154
            if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
142
                // Find the selected copy
155
                // Find the selected copy
Lines 163-168 Link Here
163
            alert(MSG_NO_COPY_SELECTED);
176
            alert(MSG_NO_COPY_SELECTED);
164
            return false;
177
            return false;
165
        }
178
        }
179
        else if(emptyMandNote>0) {
180
            alert(MSG_EMPTY_MAND_NOTE);
181
            $(".notesrow").hide();
182
            $("#notesrow_"+emptyMandNote).show();
183
            return false;
184
        }
166
185
167
        $("#selections").val(selections);
186
        $("#selections").val(selections);
168
        $("#biblionumbers").val(biblionumbers);
187
        $("#biblionumbers").val(biblionumbers);
Lines 444-450 Link Here
444
                      <td colspan="[% itemtable_colspan %]">
463
                      <td colspan="[% itemtable_colspan %]">
445
                          <label for="holdnotes">Hold notes:</label>&nbsp;
464
                          <label for="holdnotes">Hold notes:</label>&nbsp;
446
                          <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
465
                          <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
447
                          <textarea name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
466
                          <textarea id="notes_[% bibitemloo.biblionumber %]" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
448
                          <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
467
                          <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
449
                      </td>
468
                      </td>
450
                  </tr>
469
                  </tr>
(-)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