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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-5 / +11 lines)
Lines 25-30 var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo Link Here
25
[% END %][% END %][% END %]
25
[% END %][% END %][% END %]
26
};
26
};
27
var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
27
var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
28
var MSG_EXCEEDED_HOLDS_PER_RECORD = _("Patron has exceeded the number of holds for this record.");
29
var remainingHolds = "[% remaining_holds_for_record %]";
28
30
29
$(document).ready(function() {
31
$(document).ready(function() {
30
    function ToggleHoldsToPlace() {
32
    function ToggleHoldsToPlace() {
Lines 149-165 function checkMultiHold() { Link Here
149
        }
151
        }
150
    });
152
    });
151
    $("input[name=checkitem]").click(function() {
153
    $("input[name=checkitem]").click(function() {
152
        onechecked = 0;
154
        numchecked = 0;
153
        $("input[name=checkitem]").each(function() {
155
        $("input[name=checkitem]").each(function() {
154
            if(this.checked){
156
            if(this.checked){
155
                onechecked = 1;
157
                numchecked = 1;
156
            }
158
            }
157
        });
159
        });
158
        if(onechecked == 1){
160
        if(numchecked > 0){
159
            $("#requestany").prop("checked", false);
161
            $("#requestany").prop("checked", false);
160
        } else {
162
        } else {
161
            $("#requestany").prop("checked",true);
163
            $("#requestany").prop("checked",true);
162
        }
164
        }
165
166
        if (remainingHolds - numchecked < 0) {
167
            alert(MSG_EXCEEDED_HOLDS_PER_RECORD);
168
        }
163
    });
169
    });
164
170
165
    $(".clear-date").on("click",function(e){
171
    $(".clear-date").on("click",function(e){
Lines 493-501 function checkMultiHold() { Link Here
493
                        Hold must be record level
499
                        Hold must be record level
494
                    </span>
500
                    </span>
495
                [% ELSIF ( itemloo.available ) %]
501
                [% ELSIF ( itemloo.available ) %]
496
                    <input type="radio" name="checkitem" value="[% itemloo.itemnumber %]" />
502
                    <input type="checkbox" name="checkitem" value="[% itemloo.itemnumber %]" />
497
                [% ELSIF ( itemloo.override ) %]
503
                [% ELSIF ( itemloo.override ) %]
498
                    <input type="radio" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber %]" />
504
                    <input type="checkbox" name="checkitem" class="needsoverride" value="[% itemloo.itemnumber %]" />
499
                    <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" alt="Requires override of hold policy"/></i>
505
                    <i class="fa fa-exclamation-triangle fa-lg" style="color:gold" alt="Requires override of hold policy"/></i>
500
                [% ELSE %]
506
                [% ELSE %]
501
                    <span class="error">
507
                    <span class="error">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-101 / +91 lines)
Lines 138-157 Link Here
138
                        <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
138
                        <form action="/cgi-bin/koha/opac-reserve.pl" method="post" id="hold-request-form">
139
                            <input type="hidden" name="place_reserve" value="1"/>
139
                            <input type="hidden" name="place_reserve" value="1"/>
140
                            <!-- These values are set dynamically by js -->
140
                            <!-- These values are set dynamically by js -->
141
                            <input type="hidden" name="biblionumbers" id="biblionumbers"/>
142
                            <input type="hidden" name="selecteditems" id="selections"/>
143
                            <div id="bigloop">
141
                            <div id="bigloop">
144
142
145
                                [% FOREACH bibitemloo IN bibitemloop %]
143
                                [% FOREACH bibitemloo IN bibitemloop %]
146
                                    <div class="holdrow">
144
                                    <div class="holdrow">
145
                                        <input id="remaining_holds_[% bibitemloo.biblionumber %]" type="hidden" value="[% bibitemloo.remaining_holds_for_record %]"/>
147
                                        <p>
146
                                        <p>
148
                                            [% IF ( bibitemloo.holdable ) %]
147
                                            [% IF ( bibitemloo.holdable ) %]
149
                                                <input class="reserve_mode" name="reserve_mode" type="hidden" value="single"/>
148
                                                <span title="[% bibitemloo.biblionumber %]" style="padding:.3em">
150
                                                <input class="single_bib" name="single_bib" type="hidden" value="[% bibitemloo.biblionumber %]"/>
149
                                                    <label>
151
                                                <span class="confirmjs_hold" title="[% bibitemloo.biblionumber %]" style="padding:.3em"></span>
150
                                                        <input class="biblionumbers" name="biblionumbers" type="checkbox" value="[% bibitemloo.biblionumber %]" checked="checked">
152
                                                <span class="confirm_nonjs">
151
                                                        Place a hold on
153
                                                    <input type="radio" class="confirmbox checkitem [% bibitemloo.biblionumber %]" name="[% bibitemloo.biblionumber %]" checked="checked" id="single_[% bibitemloo.biblionumber %]" value="any" />
152
                                                    </label>
154
                                                    <label class="confirm_label" for="single_[% bibitemloo.biblionumber %]">Place a hold on </label>
155
                                                </span>
153
                                                </span>
156
                                            [% END # / bibitemloo.holdable %]
154
                                            [% END # / bibitemloo.holdable %]
157
155
Lines 218-224 Link Here
218
                                                            <li class="branch">
216
                                                            <li class="branch">
219
                                                                <label for="branch_[% bibitemloo.biblionumber %]">Pick up location:</label>
217
                                                                <label for="branch_[% bibitemloo.biblionumber %]">Pick up location:</label>
220
                                                                [% UNLESS ( bibitemloo.holdable ) %]
218
                                                                [% UNLESS ( bibitemloo.holdable ) %]
221
                                                                    <select name="branch" id="branch_[% bibitemloo.biblionumber %]" disabled="disabled">
219
                                                                    <select name="branch_[% bibitemloo.biblionumber %]" id="branch_[% bibitemloo.biblionumber %]" disabled="disabled">
222
                                                                        [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
220
                                                                        [% PROCESS options_for_libraries libraries => Branches.all( selected => branch ) %]
223
                                                                    </select>
221
                                                                    </select>
224
                                                                [% ELSE %]
222
                                                                [% ELSE %]
Lines 292-320 Link Here
292
                                                            </li>
290
                                                            </li>
293
                                                        [% END # / IF OpacHoldNotes %]
291
                                                        [% END # / IF OpacHoldNotes %]
294
292
295
                                                        [% IF bibitemloo.itemholdable %]
293
                                                        <!-- ITEM HOLDS -->
296
                                                            <!-- ITEM HOLDS -->
294
                                                        <li class="lradio place_on_type" style="display:none;">
297
                                                            <li class="lradio place_on_type" style="display:none;">
295
                                                                <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
298
                                                                [% IF NOT bibitemloo.force_hold %]
299
                                                                    <label class="radio inline" for="reqany_[% bibitemloo.biblionumber %]">Next available item</label>
300
                                                                    <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
301
                                                                            id="reqany_[% bibitemloo.biblionumber %]"
302
                                                                            class="selectany"
303
                                                                            value="Any"
304
                                                                            checked="checked"
305
                                                                    />
306
                                                                [% END %]
307
                                                                <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
308
                                                                <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
296
                                                                <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
309
                                                                       id="reqspecific_[% bibitemloo.biblionumber %]"
297
                                                                        id="reqany_[% bibitemloo.biblionumber %]"
310
                                                                       class="selectspecific"
298
                                                                        class="selectany"
311
                                                                       value="Specific"
299
                                                                        value="Any"
300
                                                                        checked="checked"
312
                                                                />
301
                                                                />
313
                                                            </li>
302
                                                            <label class="radio inline" for="reqspecific_[% bibitemloo.biblionumber %]">A specific item</label>
314
                                                        [% END # / IF bibitemloo.itemholdable %]
303
                                                            <input type="radio" name="reqtype_[% bibitemloo.biblionumber %]"
304
                                                                   id="reqspecific_[% bibitemloo.biblionumber %]"
305
                                                                   class="selectspecific"
306
                                                                   value="Specific"
307
                                                            />
308
                                                        </li>
315
                                                    </ul>
309
                                                    </ul>
316
310
317
                                                    [% IF bibitemloo.itemholdable %]
311
                                                    [% IF bibitemloo.remaining_holds_for_record > 1 %]
312
                                                        [% SET count = 1 %]
313
                                                        <div id="holds_to_place_[% bibitemloo.biblionumber %]" class="hold-options holds-to-place">
314
                                                            <label>Holds to place (count)</label>
315
                                                            <select name="holds_to_place_count_[% bibitemloo.biblionumber %]">
316
                                                            [% WHILE count <= bibitemloo.remaining_holds_for_record %]
317
                                                                <option value="[% count %]">[% count %]</option>
318
                                                                [% SET count = count + 1 %]
319
                                                            [% END %]
320
                                                            </select>
321
                                                        </div>
322
                                                    [% ELSE %]
323
                                                        <input type="hidden" name="holds_to_place_count_[% bibitemloo.biblionumber %]" value="1" />
324
                                                    [% END %]
325
318
                                                        <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
326
                                                        <table class="copiesrow table table-bordered table-striped" id="copiesrow_[% bibitemloo.biblionumber %]">
319
                                                            <caption>Select a specific item:</caption>
327
                                                            <caption>Select a specific item:</caption>
320
                                                            <tr>
328
                                                            <tr>
Lines 338-346 Link Here
338
                                                                <tr class="[% itemLoo.backgroundcolor %]">
346
                                                                <tr class="[% itemLoo.backgroundcolor %]">
339
                                                                    <td class="copynumber">
347
                                                                    <td class="copynumber">
340
                                                                        [% IF ( itemLoo.available ) %]
348
                                                                        [% IF ( itemLoo.available ) %]
341
                                                                            <input type="radio" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]" value="[% itemLoo.itemnumber %]" />
349
                                                                            <input type="checkbox" class="checkitem checkitem_[% bibitemloo.biblionumber %]" name="checkitem_[% bibitemloo.biblionumber %]" value="[% itemLoo.itemnumber %]" />
342
                                                                        [% ELSE %]
350
                                                                        [% ELSE %]
343
                                                                            <input disabled="disabled" type="radio" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]"
351
                                                                            <input disabled="disabled" type="checkbox" class="checkitem" name="checkitem" value="[% itemLoo.itemnumber %]"
344
                                                                                   style="display:none;" />
352
                                                                                   style="display:none;" />
345
                                                                            <img src="[% interface %]/lib/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
353
                                                                            <img src="[% interface %]/lib/famfamfam/silk/cross.png" alt="Cannot be put on hold" title="Cannot be put on hold" />
346
                                                                        [% END %]
354
                                                                        [% END %]
Lines 414-420 Link Here
414
                                                                </tr>
422
                                                                </tr>
415
                                                            [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
423
                                                            [% END # / FOREACH itemLoo IN bibitemloo.itemLoop%]
416
                                                        </table> <!-- / #copiesrow_[% bibitemloo.biblionumber %] -->
424
                                                        </table> <!-- / #copiesrow_[% bibitemloo.biblionumber %] -->
417
                                                    [% END # / IF ( bibitemloo.itemholdable )%]
418
                                                </div> <!-- / #hold-options-[% bibitemloo.biblionumber %] -->
425
                                                </div> <!-- / #hold-options-[% bibitemloo.biblionumber %] -->
419
                                            </fieldset>
426
                                            </fieldset>
420
                                        [% END # / IF ( bibitemloo.holdable ) %]
427
                                        [% END # / IF ( bibitemloo.holdable ) %]
Lines 437-442 Link Here
437
<script type="text/javascript">
444
<script type="text/javascript">
438
// <![CDATA[
445
// <![CDATA[
439
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
446
    var MSG_NO_ITEM_SELECTED = _("Expecting a specific item selection.");
447
    var MSG_MAX_HOLDS_EXCEEDED = _("Maximum number of reserve exceded.");
440
448
441
        // Clear the contents of an input field
449
        // Clear the contents of an input field
442
        $(".clearfield").on("click",function(e){
450
        $(".clearfield").on("click",function(e){
Lines 446-453 Link Here
446
454
447
    // Select the first item available
455
    // Select the first item available
448
    function select_first_available(id){
456
    function select_first_available(id){
449
        var radios = $("input:radio[name='checkitem_" + id + "']");
457
        var checkboxes = $("input:checkbox[name='checkitem_" + id + "']");
450
        $(radios).first().attr("checked", "checked");
458
        $(checkboxes).first().attr("checked", "checked");
451
    }
459
    }
452
460
453
    $(document).ready(function() {
461
    $(document).ready(function() {
Lines 468-481 Link Here
468
            }
476
            }
469
        });
477
        });
470
478
471
        // click on a first td check the confirmjs checkbox
479
        $('.checkitem').click(function(e) {
472
        $("td.hold").click(function(e){
480
            var bibNum = suffixOf($(this).attr("name"), "_");
473
          if(e.target.tagName.toLowerCase() == 'td'){
481
            var nbCheked = $("input[name='checkitem_"+bibNum+"']:checked").length;
474
            $(this).find("input.confirmjs").each( function() {
482
            var remaining = $("input[id='remaining_holds_"+bibNum+"']").val();
475
               $(this).attr('checked', !$(this).attr('checked'));
483
            if (nbCheked >= remaining) {
476
               $(this).change();
484
                $("input[name='checkitem_"+bibNum+"']:not(:checked)").attr('disabled', 'disabled');
477
            });
485
            }
478
          }
486
            else {
487
                $('.checkitem_'+bibNum).attr('disabled', false);
488
            }
479
        });
489
        });
480
490
481
        $(".toggle-hold-options").on("click",function(e){
491
        $(".toggle-hold-options").on("click",function(e){
Lines 490-504 Link Here
490
        // Hides all 'specific copy' table rows on load.
500
        // Hides all 'specific copy' table rows on load.
491
        $(".copiesrow").hide();
501
        $(".copiesrow").hide();
492
502
503
        $(".holds-to-place").show();
493
        [% FOREACH bibitemloo IN bibitemloop %]
504
        [% FOREACH bibitemloo IN bibitemloop %]
494
          [% IF bibitemloo.force_hold %]
505
            [% IF bibitemloo.force_hold %]
495
            $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
506
                [% IF bibitemloo.force_hold == 'item' %]
496
            $("#reqspecific_[% bibitemloo.biblionumber %]").click();
507
                    $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
497
            $("#copiesrow_[% bibitemloo.biblionumber %]").show();
508
                    $("#reqspecific_[% bibitemloo.biblionumber %]").attr('checked', true);
498
          [% END %]
509
                    $("#holds_to_place_[% bibitemloo.biblionumber %]").hide();
499
          [% IF bibitemloo.reqholdnotes %]
510
                    $("#copiesrow_[% bibitemloo.biblionumber %]").show();
500
              $("#holdnotes_[% bibitemloo.biblionumber %]").attr( 'required', true );
511
                [% ELSIF bibitemloo.force_hold == 'record' %]
501
          [% END %]
512
                    $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
513
                    $("#reqany_[% bibitemloo.biblionumber %]").attr('checked', true);
514
                [% END %]
515
                $("#reqany_[% bibitemloo.biblionumber %]").attr('disabled', 'disabled');
516
                $("#reqspecific_[% bibitemloo.biblionumber %]").attr('disabled', 'disabled');
517
            [% END %]
518
            [% IF bibitemloo.reqholdnotes %]
519
                $("#holdnotes_[% bibitemloo.biblionumber %]").attr( 'required', true );
520
            [% END %]
502
        [% END %]
521
        [% END %]
503
522
504
        $(".date-format").each(function(){
523
        $(".date-format").each(function(){
Lines 515-554 Link Here
515
            $("#" + op + fieldID).val("");
534
            $("#" + op + fieldID).val("");
516
        });
535
        });
517
536
518
        // Replace non-JS single-selection with multi-selection capability.
519
        $(".reserve_mode").val("multi");
520
        $(".confirm_nonjs").remove();
521
        $(".confirmjs_hold").each(function(){
522
            var bib = $(this).attr("title");
523
            var html = "<label><input type =\"checkbox\" class=\"confirmjs\" checked=\"checked\"";
524
            html += "value=\"" + bib + "\" id=\"" + bib + "\" /> " + _("Place a hold on") + " </label> ";
525
            $(this).html(html);
526
        });
527
        $(".confirmjs_nohold").each(function(){
528
            var bib = $(this).attr("title");
529
            var html = "<label><input type =\"checkbox\" class=\"confirmjs\" disabled=\"disabled\"";
530
            html += "value=\"" + bib + "\" id=\"" + bib + "\" />" + _("Place a hold on: ") + "</label>";
531
            $(this).html(html);
532
        });
533
534
        // expand or collapse the copiesrow tr
537
        // expand or collapse the copiesrow tr
535
        function toggle_copiesrow(biblioNum) {
538
        function toggle_copiesrow(biblioNum) {
536
            var checkbox = $("input:checkbox[value='"+biblioNum+"']");
539
            var checkbox = $("input:checkbox[value='"+biblioNum+"']");
537
            newCopiesRowId = "#copiesrow_" + biblioNum;
540
            newCopiesRowId = "#copiesrow_" + biblioNum;
541
            holdsToPlaceCountId = "#holds_to_place_" + biblioNum;
538
            var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
542
            var select_specific = $("#reqspecific_"+biblioNum).is(":checked");
539
            // If the checkbox is checked AND we want a specific item, we display the items block
543
            // If the checkbox is checked AND we want a specific item, we display the items block
540
            if ( $(checkbox).is(":checked") && select_specific ) {
544
            if ( $(checkbox).is(":checked") && select_specific ) {
541
                $(newCopiesRowId).show();
545
                $(newCopiesRowId).show();
546
                $(holdsToPlaceCountId).hide();
542
            } else {
547
            } else {
543
                $(newCopiesRowId).hide();
548
                $(newCopiesRowId).hide();
549
                $(holdsToPlaceCountId).show();
544
             }
550
             }
545
        };
551
        };
546
552
547
        $("#place_on_hdr").show();
553
        function total_requested() {
554
            var total = 0;
555
            $("input[name='biblionumbers']:checked").each(function() {
556
                var biblioNum = $(this).val();
557
                if ($("#reqspecific_" + biblioNum + ":checked").size() > 0) {
558
                    total += parseInt($("input[name='checkitem_'"+biblioNum+"]:checked").length);
559
                } else {
560
                    total += parseInt($("select[name='holds_to_place_count_"+biblioNum+"']").val());
561
                }
562
            });
563
            return total;
564
        }
548
565
549
        $(".place_on_type").show();
566
        $(".place_on_type").show();
550
        // onload, selectany is checked
567
        // onload, selectany is checked
551
        $(".selectany").attr("checked", "checked");
552
568
553
        // If the user is *allowed* to choose a specific item
569
        // If the user is *allowed* to choose a specific item
554
        // The first one is preselected
570
        // The first one is preselected
Lines 557-564 Link Here
557
            select_first_available(id);
573
            select_first_available(id);
558
        });
574
        });
559
575
560
        // On confirmsjs change
576
        // On biblionumbers change
561
        $(".confirmjs").change(function(){
577
        $(".biblionumbers").change(function(){
562
            var id = suffixOf($(this).attr("id"), "_");
578
            var id = suffixOf($(this).attr("id"), "_");
563
            // If I m checked, I enable radio buttons
579
            // If I m checked, I enable radio buttons
564
            if ( $(this).is(":checked") ) {
580
            if ( $(this).is(":checked") ) {
Lines 580-614 Link Here
580
            toggle_copiesrow(id);
596
            toggle_copiesrow(id);
581
        });
597
        });
582
598
583
        // Show or hide holds notes
584
        $(".shownotes").click(function(){
585
            biblioNum = suffixOf($(this).attr("id"), "_");
586
            $("#notesrow_"+biblioNum).toggle();
587
        });
588
589
        // When 'Place Hold' button is clicked
599
        // When 'Place Hold' button is clicked
590
        $(".placehold").click(function(){
600
        $(".placehold").click(function(){
591
            var biblionumbers = "";
601
            if (total_requested() + [% reserves_count %] > [% maxreserves %]) {
592
            var selections = "";
602
                alert(MSG_MAX_HOLDS_EXCEEDED);
593
603
                return false;
594
            [% IF new_reserves_allowed %]
604
            }
595
                if ($(".confirmjs:checked").size() > [% new_reserves_allowed %] ) {
596
                    alert(MSG_MAX_HOLDS_EXCEEDED);
597
                    return false;
598
                }
599
            [% END %]
600
605
601
            if ($(".confirmjs:checked").size() == 0) {
606
            if ($("input[name='biblionumbers']:checked").size() == 0) {
602
                alert(MSG_NO_RECORD_SELECTED);
607
                alert(MSG_NO_RECORD_SELECTED);
603
                return false;
608
                return false;
604
            }
609
            }
605
610
606
            // Find the items with the 'Hold' box checked
611
            // Find the items with the 'Hold' box checked
607
            var badBib = null;
612
            var badBib = null;
608
            $(".confirmjs:checked").each(function() {
613
            $("input[name='biblionumbers']:checked").each(function() {
609
                var biblioNum = $(this).val();
614
                var biblioNum = $(this).val();
610
                biblionumbers += biblioNum + "/";
611
                selections += biblioNum + "/";
612
615
613
                // If required hold note is empty, make it visible
616
                // If required hold note is empty, make it visible
614
                if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) {
617
                if( $("#holdnotes_"+biblioNum).attr( 'required' ) && $("#holdnotes_"+biblioNum).val() == '' ) {
Lines 625-642 Link Here
625
                        alert(MSG_NO_ITEM_SELECTED);
628
                        alert(MSG_NO_ITEM_SELECTED);
626
                        badBib = biblioNum;
629
                        badBib = biblioNum;
627
                        return false;
630
                        return false;
628
                    } else {
629
                      selections += $(item).val();
630
                    }
631
                    }
631
                }
632
                }
632
                selections += "/";
633
634
                // Add the pickup location
635
                var branchSel = $("#branch_" + biblioNum);
636
                if (branchSel.size() > 0) {
637
                    selections += $(branchSel).val();
638
                }
639
                selections += "/";
640
                return true;
633
                return true;
641
            });
634
            });
642
635
Lines 644-652 Link Here
644
                return false;
637
                return false;
645
            }
638
            }
646
639
647
            $("#selections").val(selections);
648
            $("#biblionumbers").val(biblionumbers);
649
650
            return true;
640
            return true;
651
        });
641
        });
652
642
(-)a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less (+3 lines)
Lines 2389-2394 td img { Link Here
2389
    margin: 1em 0;
2389
    margin: 1em 0;
2390
    padding: .5em;
2390
    padding: .5em;
2391
}
2391
}
2392
.hold-option select {
2393
    width: auto;
2394
}
2392
.copiesrow {
2395
.copiesrow {
2393
    clear : both;
2396
    clear : both;
2394
}
2397
}
(-)a/opac/opac-reserve.pl (-98 / +83 lines)
Lines 103-136 if ( $reservefee > 0){ Link Here
103
103
104
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
104
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
105
105
106
# There are two ways of calling this script, with a single biblio num
106
# Coming from opac-search biblionumbers param is a string, coming from
107
# or multiple biblio nums.
107
# opac-reserve, it's an array.
108
my $biblionumbers = $query->param('biblionumbers');
108
my @biblionumbers = ref($query->param('biblionumbers')) eq 'Array'
109
my $reserveMode = $query->param('reserve_mode');
109
    ? $query->param('biblionumbers')
110
if ($reserveMode && ($reserveMode eq 'single')) {
110
    : split(/\//, $query->param('biblionumbers'));
111
    my $bib = $query->param('single_bib');
111
112
    $biblionumbers = "$bib/";
112
unless (@biblionumbers) {
113
}
113
    push(@biblionumbers, $query->param('biblionumber'));
114
if (! $biblionumbers) {
115
    $biblionumbers = $query->param('biblionumber');
116
}
117
118
if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
119
    $template->param(message=>1, no_biblionumber=>1);
120
    &get_out($query, $cookie, $template->output);
121
}
114
}
122
115
123
# Pass the numbers to the page so they can be fed back
116
# Pass the numbers to the page so they can be fed back
124
# when the hold is confirmed. TODO: Not necessary?
117
# when the hold is confirmed. TODO: Not necessary?
125
$template->param( biblionumbers => $biblionumbers );
118
$template->param( biblionumbers => @biblionumbers );
126
127
# Each biblio number is suffixed with '/', e.g. "1/2/3/"
128
my @biblionumbers = split /\//, $biblionumbers;
129
if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
130
    # TODO: New message?
131
    $template->param(message=>1, no_biblionumber=>1);
132
    &get_out($query, $cookie, $template->output);
133
}
134
119
135
120
136
# pass the pickup branch along....
121
# pass the pickup branch along....
Lines 202-240 if ( $query->param('place_reserve') ) { Link Here
202
        $reserve_cnt = GetReservesFromBorrowernumber( $borrowernumber );
187
        $reserve_cnt = GetReservesFromBorrowernumber( $borrowernumber );
203
    }
188
    }
204
189
205
    # List is composed of alternating biblio/item/branch
206
    my $selectedItems = $query->param('selecteditems');
207
208
    if ($query->param('reserve_mode') eq 'single') {
209
        # This indicates non-JavaScript mode, so there was
210
        # only a single biblio number selected.
211
        my $bib = $query->param('single_bib');
212
        my $item = $query->param("checkitem_$bib");
213
        if ($item eq 'any') {
214
            $item = '';
215
        }
216
        my $branch = $query->param('branch');
217
        $selectedItems = "$bib/$item/$branch/";
218
    }
219
220
    $selectedItems =~ s!/$!!;
221
    my @selectedItems = split /\//, $selectedItems, -1;
222
223
    # Make sure there is a biblionum/itemnum/branch triplet for each item.
224
    # The itemnum can be 'any', meaning next available.
225
    my $selectionCount = @selectedItems;
226
    if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
227
        $template->param(message=>1, bad_data=>1);
228
        &get_out($query, $cookie, $template->output);
229
    }
230
231
    my $failed_holds = 0;
190
    my $failed_holds = 0;
232
    while (@selectedItems) {
191
    foreach my $biblioNum (@biblionumbers) {
233
        my $biblioNum = shift(@selectedItems);
192
        my $itemNum = $query->param("checkitem_$biblioNum");
234
        my $itemNum   = shift(@selectedItems);
193
        my @itemnumbers = $query->param("checkitem_$biblioNum");
235
        my $branch    = shift(@selectedItems);    # i.e., branch code, not name
194
        my $branch = $query->param("branch_$biblioNum");
236
195
        my $reqtype = $query->param("reqtype_$biblioNum");
237
        my $canreserve = 0;
196
        my $holds_to_place_count = $query->param("holds_to_place_count_$biblioNum") || 1;
197
        my $notes = $query->param('notes_'.$biblioNum) || '';
198
        my $nbRequested = $reqtype eq 'Specific' ? @itemnumbers : $holds_to_place_count;
199
200
        my $canreserve = 1;
201
        if (   $maxreserves
202
            && $reserve_cnt + $nbRequested >= $maxreserves )
203
        {
204
            $canreserve = 0;
205
        }
238
206
239
        my $singleBranchMode = Koha::Libraries->search->count == 1;
207
        my $singleBranchMode = Koha::Libraries->search->count == 1;
240
        if ( $singleBranchMode || !$OPACChooseBranch )
208
        if ( $singleBranchMode || !$OPACChooseBranch )
Lines 242-255 if ( $query->param('place_reserve') ) { Link Here
242
            $branch = $borr->{'branchcode'};
210
            $branch = $borr->{'branchcode'};
243
        }
211
        }
244
212
245
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
246
        if ( $itemNum ne '' ) {
247
            my $hostbiblioNum = GetBiblionumberFromItemnumber($itemNum);
248
            if ( $hostbiblioNum ne $biblioNum ) {
249
                $biblioNum = $hostbiblioNum;
250
            }
251
        }
252
253
        my $biblioData = $biblioDataHash{$biblioNum};
213
        my $biblioData = $biblioDataHash{$biblioNum};
254
        my $found;
214
        my $found;
255
215
Lines 263-293 if ( $query->param('place_reserve') ) { Link Here
263
223
264
        my $expiration_date = $query->param("expiration_date_$biblioNum");
224
        my $expiration_date = $query->param("expiration_date_$biblioNum");
265
225
266
      # If a specific item was selected and the pickup branch is the same as the
226
        # If a specific item was selected and the pickup branch is the same as the
267
      # holdingbranch, force the value $rank and $found.
227
        # holdingbranch, force the value $rank and $found.
268
        my $rank = $biblioData->{rank};
228
        my $rank = $biblioData->{rank};
269
        if ( $itemNum ne '' ) {
229
        if ( $reqtype eq 'Specific') {
270
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum ) eq 'OK';
230
            foreach my $itemnumber (@itemnumbers) {
271
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
231
                my $biblionumber = $biblioNum;
272
            my $item = GetItem($itemNum);
232
273
            if ( $item->{'holdingbranch'} eq $branch ) {
233
                #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
274
                $found = 'W'
234
                my $hostbiblioNum = GetBiblionumberFromItemnumber($itemnumber);
275
                  unless C4::Context->preference('ReservesNeedReturns');
235
                if ( $hostbiblioNum ne $biblioNum ) {
276
            }
236
                    $biblionumber = $hostbiblioNum;
277
        }
237
                }
278
        else {
279
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK';
280
238
281
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
239
                $canreserve = 0 unless CanItemBeReserved( $borrowernumber, $itemnumber ) eq 'OK';
282
            $itemNum = undef;
240
                $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
283
        }
241
                my $item = GetItem($itemnumber);
284
        my $notes = $query->param('notes_'.$biblioNum)||'';
242
                if ( $item->{'holdingbranch'} eq $branch ) {
243
                    $found = 'W'
244
                      unless C4::Context->preference('ReservesNeedReturns');
245
                }
285
246
286
        if (   $maxreserves
247
                if ($canreserve) {
287
            && $reserve_cnt >= $maxreserves )
248
                    my $reserve_id = AddReserve(
288
        {
249
                        $branch,         $borrowernumber,
289
            $canreserve = 0;
250
                        $biblionumber,
251
                        [$biblionumber], $rank,
252
                        $startdate,      $expiration_date,
253
                        $notes,          $biblioData->{title},
254
                        $itemnumber,     $found
255
                    );
256
                    $failed_holds++ unless $reserve_id;
257
                    ++$reserve_cnt;
258
                }
259
            }
260
            print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
261
            exit;
290
        }
262
        }
263
        $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK';
291
264
292
        unless ( $can_place_hold_if_available_at_pickup ) {
265
        unless ( $can_place_hold_if_available_at_pickup ) {
293
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
266
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
Lines 303-316 if ( $query->param('place_reserve') ) { Link Here
303
276
304
        # Here we actually do the reserveration. Stage 3.
277
        # Here we actually do the reserveration. Stage 3.
305
        if ($canreserve) {
278
        if ($canreserve) {
306
            my $reserve_id = AddReserve(
279
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
307
                $branch,          $borrowernumber, $biblioNum,
280
                my $reserve_id = AddReserve(
308
                [$biblioNum],     $rank,           $startdate,
281
                    $branch,          $borrowernumber, $biblioNum,
309
                $expiration_date, $notes,          $biblioData->{title},
282
                    [$biblioNum],     $rank,           $startdate,
310
                $itemNum,         $found,          $itemtype,
283
                    $expiration_date, $notes,          $biblioData->{title},
311
            );
284
                    $itemNum,         $found,          $itemtype,
312
            $failed_holds++ unless $reserve_id;
285
                );
313
            ++$reserve_cnt;
286
                $failed_holds++ unless $reserve_id;
287
                ++$reserve_cnt;
288
            }
314
        }
289
        }
315
    }
290
    }
316
291
Lines 370-375 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) { Link Here
370
}
345
}
371
346
372
unless ( $noreserves ) {
347
unless ( $noreserves ) {
348
    $template->param(
349
        maxreserves => $maxreserves,
350
        reserves_count => $reserves_count
351
    );
373
    my $requested_reserves_count = scalar( @biblionumbers );
352
    my $requested_reserves_count = scalar( @biblionumbers );
374
    if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
353
    if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
375
        $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
354
        $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
Lines 538-544 foreach my $biblioNum (@biblionumbers) { Link Here
538
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $borr ) ) {
517
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $borr ) ) {
539
                $itemLoopIter->{available} = 1;
518
                $itemLoopIter->{available} = 1;
540
                $numCopiesOPACAvailable++;
519
                $numCopiesOPACAvailable++;
541
                $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';
520
                $biblioLoopIter{force_hold} = 'item' if $hold_allowed eq 'F';
542
            }
521
            }
543
            $numCopiesAvailable++;
522
            $numCopiesAvailable++;
544
523
Lines 598-615 foreach my $biblioNum (@biblionumbers) { Link Here
598
    # patron placed a record level hold, all the holds the patron places must
577
    # patron placed a record level hold, all the holds the patron places must
599
    # be record level. If the patron placed an item level hold, all holds
578
    # be record level. If the patron placed an item level hold, all holds
600
    # the patron places must be item level
579
    # the patron places must be item level
601
    my $forced_hold_level = Koha::Holds->search(
580
    my $holds = Koha::Holds->search(
602
        {
581
        {
603
            borrowernumber => $borrowernumber,
582
            borrowernumber => $borrowernumber,
604
            biblionumber   => $biblioNum,
583
            biblionumber   => $biblioNum,
605
            found          => undef,
584
            found          => undef,
606
        }
585
        }
607
    )->forced_hold_level();
586
    );
587
    my $forced_hold_level = $holds->forced_hold_level();
608
    if ($forced_hold_level) {
588
    if ($forced_hold_level) {
609
        $biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
589
        #$biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
610
        $biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
590
        #$biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
591
        $biblioLoopIter{force_hold} = $forced_hold_level;
611
    }
592
    }
612
593
594
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowernumber, $biblioNum );
595
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
596
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
597
613
598
614
    push @$biblioLoop, \%biblioLoopIter;
599
    push @$biblioLoop, \%biblioLoopIter;
615
600
(-)a/reserve/placerequest.pl (-21 / +14 lines)
Lines 47-53 my $startdate = $input->param('reserve_date') || ''; Link Here
47
my @rank           = $input->multi_param('rank-request');
47
my @rank           = $input->multi_param('rank-request');
48
my $type           = $input->param('type');
48
my $type           = $input->param('type');
49
my $title          = $input->param('title');
49
my $title          = $input->param('title');
50
my $checkitem      = $input->param('checkitem');
50
my @checkitems     = $input->param('checkitem');
51
my $expirationdate = $input->param('expiration_date');
51
my $expirationdate = $input->param('expiration_date');
52
my $itemtype       = $input->param('itemtype') || undef;
52
my $itemtype       = $input->param('itemtype') || undef;
53
53
Lines 57-62 my $multi_hold = $input->param('multi_hold'); Link Here
57
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
57
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
58
my $bad_bibs = $input->param('bad_bibs');
58
my $bad_bibs = $input->param('bad_bibs');
59
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
59
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
60
$holds_to_place_count = scalar(@checkitems) if scalar(@checkitems);
60
61
61
my %bibinfos = ();
62
my %bibinfos = ();
62
my @biblionumbers = split '/', $biblionumbers;
63
my @biblionumbers = split '/', $biblionumbers;
Lines 67-83 foreach my $bibnum (@biblionumbers) { Link Here
67
    $bibinfos{$bibnum} = \%bibinfo;
68
    $bibinfos{$bibnum} = \%bibinfo;
68
}
69
}
69
70
70
my $found;
71
my @found;
71
72
72
# if we have an item selectionned, and the pickup branch is the same as the holdingbranch
73
foreach my $checkitem (@checkitems) {
73
# of the document, we force the value $rank and $found .
74
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
74
if (defined $checkitem && $checkitem ne ''){
75
    # of the document, we force the value $rank and $found .
75
    $holds_to_place_count = 1;
76
    $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
76
    $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
77
    my $item = $checkitem;
77
    my $item = GetItem($checkitem);
78
    $item = GetItem($item);
79
    if ( $item->{'holdingbranch'} eq $branch ){
78
    if ( $item->{'holdingbranch'} eq $branch ){
80
        $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
79
        push @found, 'W' unless C4::Context->preference('ReservesNeedReturns');
81
    }
80
    }
82
}
81
}
83
82
Lines 97-119 if ( $type eq 'str8' && $borrower ) { Link Here
97
            }
96
            }
98
        }
97
        }
99
98
100
        if ( defined $checkitem && $checkitem ne '' ) {
101
            my $item = GetItem($checkitem);
102
            if ( $item->{'biblionumber'} ne $biblionumber ) {
103
                $biblionumber = $item->{'biblionumber'};
104
            }
105
        }
106
107
        if ($multi_hold) {
99
        if ($multi_hold) {
108
            my $bibinfo = $bibinfos{$biblionumber};
100
            my $bibinfo = $bibinfos{$biblionumber};
109
            AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,[$biblionumber],
101
            AddReserve( $branch, $borrower->{'borrowernumber'},
110
                       $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
102
                        $biblionumber, [$biblionumber],
103
                        $bibinfo->{rank}, $startdate, $expirationdate, $notes,$bibinfo->{title});
111
        } else {
104
        } else {
112
            # place a request on 1st available
105
            # place a request on 1st available
113
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
106
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
107
                my $item = GetItem($checkitems[$i]);
114
                AddReserve( $branch, $borrower->{'borrowernumber'},
108
                AddReserve( $branch, $borrower->{'borrowernumber'},
115
                    $biblionumber, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title,
109
                    $item->{biblionumber}, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title,
116
                    $checkitem, $found, $itemtype );
110
                    $checkitems[$i], $found[$i] );
117
            }
111
            }
118
        }
112
        }
119
    }
113
    }
120
- 

Return to bug 15565