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

(-)a/C4/Reserves.pm (-1 / +43 lines)
Lines 142-148 BEGIN { Link Here
142
142
143
        IsItemOnHoldAndFound
143
        IsItemOnHoldAndFound
144
    );
144
    );
145
    @EXPORT_OK = qw( MergeHolds );
145
    @EXPORT_OK = qw( MergeHolds IsHoldNoteRequired );
146
}
146
}
147
147
148
=head2 AddReserve
148
=head2 AddReserve
Lines 2471-2476 sub IsItemOnHoldAndFound { Link Here
2471
    return $found;
2471
    return $found;
2472
}
2472
}
2473
2473
2474
=head2 IsHoldNoteRequired
2475
2476
    my $boolean = IsHoldNoteRequired( $marc );
2477
2478
    Checks if a hold note is required for a given record.
2479
    Triggered by the pref HoldNoteReasons.
2480
    This pref may contain a list of reason codes to be checked.
2481
    So, it could look like: LEADER_SERIAL|MARC300A_PARTS
2482
2483
    This routine returns true if the note is required, undef otherwise.
2484
2485
=cut
2486
2487
sub IsHoldNoteRequired {
2488
    my ( $marcrecord ) = @_;
2489
    return if !$marcrecord || !C4::Context->preference( 'OPACHoldNotes' );
2490
    my $reasons = uc C4::Context->preference( 'HoldNoteReasons' );
2491
    return if !$reasons;
2492
    my $ldr = $marcrecord->leader;
2493
2494
    # check LEADER_SERIAL
2495
    if( $reasons =~ /LEADER_SERIAL/ && substr($ldr,7,1) eq 's' ) {
2496
        return 1;
2497
    }
2498
    # check LEADER_COLLECTION
2499
    if( $reasons =~ /LEADER_COLLECTION/ && substr($ldr,7,1) eq 'c' ) {
2500
        return 1;
2501
    }
2502
    # check MARC300A_PARTS
2503
    if( $reasons =~ /MARC300A_PARTS/ &&
2504
      ( my @fld = $marcrecord->field('300') )) {
2505
        my $re = qr/(\d+)\s*(v\.|vol|dl|delen|band|bd|tle|parts|pts|t\.|tome)/i;
2506
        foreach my $f ( @fld ) {
2507
            next if !$f->subfield('a');
2508
            # Check for something like 3 parts or 22 volumes in 300$a
2509
            return 1 if $f->subfield('a') =~ /$re/ && $1 > 1;
2510
        }
2511
    }
2512
    # next reason comes here..
2513
    return;
2514
}
2515
2474
=head1 AUTHOR
2516
=head1 AUTHOR
2475
2517
2476
Koha Development Team <http://koha-community.org/>
2518
Koha Development Team <http://koha-community.org/>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-19 / +17 lines)
Lines 237-246 Link Here
237
                                                        [% IF ( OpacHoldNotes ) %]
237
                                                        [% IF ( OpacHoldNotes ) %]
238
                                                            <li>
238
                                                            <li>
239
                                                                <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
239
                                                                <div class="notesrow" id="notesrow_[% bibitemloo.biblionumber %]">
240
                                                                    <label for="holdnotes[% bibitemloo.biblionumber %]">Hold notes:</label>
240
                                                                    <label for="holdnotes_[% bibitemloo.biblionumber %]">Hold notes:</label>
241
                                                                    <span id="forcenotesreason_[% bibitemloo.biblionumber %]" class="forcenotesreason"></span>
241
                                                                    [% IF bibitemloo.reqholdnotes %]
242
                                                                    <textarea id="holdnotes[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]">[% bibitemloo.holdnotes %]</textarea>
242
                                                                        <span id="reqholdnotes_[% bibitemloo.biblionumber %]">Please enter additional information about the requested item:</span>
243
                                                                    <input type="hidden" id="notesmandatory_[% bibitemloo.biblionumber %]" value="[% bibitemloo.mandatorynotes %]"/>
243
                                                                    [% END %]
244
                                                                    <textarea id="holdnotes_[% bibitemloo.biblionumber %]" rows="2" cols="30" name="notes_[% bibitemloo.biblionumber %]" >[% bibitemloo.holdnotes %]</textarea>
244
                                                                </div>
245
                                                                </div>
245
                                                            </li>
246
                                                            </li>
246
                                                        [% END # / IF OpacHoldNotes %]
247
                                                        [% END # / IF OpacHoldNotes %]
Lines 392-401 Link Here
392
<script type="text/javascript">
393
<script type="text/javascript">
393
// <![CDATA[
394
// <![CDATA[
394
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
395
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
395
    var ForceHoldNotesReasons=new Array(
396
       _("This title consists of multiple volumes/parts. Please indicate which part you need. Clicking on specific item information may be helpful."),
397
       "*** Add a new reason above this line ***" );
398
       // NOTE: Do not renumber reasons; this will affect use of existing ones.
399
396
400
        // Clear the contents of an input field
397
        // Clear the contents of an input field
401
        $(".clearfield").on("click",function(e){
398
        $(".clearfield").on("click",function(e){
Lines 455-471 Link Here
455
            $("#reqspecific_[% bibitemloo.biblionumber %]").click();
452
            $("#reqspecific_[% bibitemloo.biblionumber %]").click();
456
            $("#copiesrow_[% bibitemloo.biblionumber %]").show();
453
            $("#copiesrow_[% bibitemloo.biblionumber %]").show();
457
          [% END %]
454
          [% END %]
455
          [% IF bibitemloo.reqholdnotes %]
456
              $("#holdnotes_[% bibitemloo.biblionumber %]").attr( 'required', true );
457
          [% END %]
458
        [% END %]
458
        [% END %]
459
459
460
        // Insert reasons for forced hold notes
461
        $(".forcenotesreason").each(function(){
462
            biblioNum = suffixOf($(this).attr("id"), "_");
463
            var j=$("#notesmandatory_"+biblioNum).val();
464
            if(j>0) {
465
                $(this).html(ForceHoldNotesReasons[j-1]);
466
            }
467
        });
468
469
        $(".date-format").each(function(){
460
        $(".date-format").each(function(){
470
            if($(this).hasClass("to")){ var op = "to"; }
461
            if($(this).hasClass("to")){ var op = "to"; }
471
            if($(this).hasClass("from")){ var op = "from"; }
462
            if($(this).hasClass("from")){ var op = "from"; }
Lines 575-585 Link Here
575
                biblionumbers += biblioNum + "/";
566
                biblionumbers += biblioNum + "/";
576
                selections += biblioNum + "/";
567
                selections += biblioNum + "/";
577
568
569
                // If required hold note is empty, make it visible
570
                if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) {
571
                    if( !$("#hold-options-"+biblioNum).is(':visible')) {
572
                        $("#toggle-hold-options-"+biblioNum).click();
573
                    }
574
                }
575
578
                // If the 'specific copy' radio button is checked
576
                // If the 'specific copy' radio button is checked
579
                if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
577
                if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
580
                    // Find the selected copy
578
                    // Find the selected copy
581
                    var item = $(".checkitem_" + biblioNum + ":checked");
579
                    var item = $(".checkitem_" + biblioNum + ":checked");
582
                    if ($(item).size() == 0) {
580
                    if ($(item).size() == 0) {
581
                        alert(MSG_NO_ITEM_SELECTED);
583
                        badBib = biblioNum;
582
                        badBib = biblioNum;
584
                        return false;
583
                        return false;
585
                    } else {
584
                    } else {
Lines 597-604 Link Here
597
                return true;
596
                return true;
598
            });
597
            });
599
598
600
            if (badBib) {
599
            if (badBib) { // alert has been raised already
601
                alert(MSG_NO_ITEM_SELECTED);
602
                return false;
600
                return false;
603
            }
601
            }
604
602
(-)a/opac/opac-reserve.pl (-2 / +1 lines)
Lines 403-409 foreach my $biblioNum (@biblionumbers) { Link Here
403
    $biblioLoopIter{rank} = $biblioData->{rank};
403
    $biblioLoopIter{rank} = $biblioData->{rank};
404
    $biblioLoopIter{reservecount} = $biblioData->{reservecount};
404
    $biblioLoopIter{reservecount} = $biblioData->{reservecount};
405
    $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
405
    $biblioLoopIter{already_reserved} = $biblioData->{already_reserved};
406
    $biblioLoopIter{mandatorynotes}=0; #FIXME: For future use
406
    $biblioLoopIter{reqholdnotes} = C4::Reserves::IsHoldNoteRequired( $record );
407
407
408
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
408
    if (!$itemLevelTypes && $biblioData->{itemtype}) {
409
        $biblioLoopIter{translated_description} = $itemTypes->{$biblioData->{itemtype}}{translated_description};
409
        $biblioLoopIter{translated_description} = $itemTypes->{$biblioData->{itemtype}}{translated_description};
410
- 

Return to bug 15545