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 (-91 / +83 lines)
Lines 105-138 if ( $reservefee > 0){ Link Here
105
105
106
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
106
my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
107
107
108
# There are two ways of calling this script, with a single biblio num
108
# Coming from opac-search biblionumbers param is a string, coming from
109
# or multiple biblio nums.
109
# opac-reserve, it's an array.
110
my $biblionumbers = $query->param('biblionumbers');
110
my @biblionumbers = ref($query->param('biblionumbers')) eq 'Array'
111
my $reserveMode = $query->param('reserve_mode');
111
    ? $query->param('biblionumbers')
112
if ($reserveMode && ($reserveMode eq 'single')) {
112
    : split(/\//, $query->param('biblionumbers'));
113
    my $bib = $query->param('single_bib');
113
114
    $biblionumbers = "$bib/";
114
unless (@biblionumbers) {
115
}
115
    push(@biblionumbers, $query->param('biblionumber'));
116
if (! $biblionumbers) {
117
    $biblionumbers = $query->param('biblionumber');
118
}
119
120
if ((! $biblionumbers) && (! $query->param('place_reserve'))) {
121
    $template->param(message=>1, no_biblionumber=>1);
122
    &get_out($query, $cookie, $template->output);
123
}
116
}
124
117
125
# Pass the numbers to the page so they can be fed back
118
# Pass the numbers to the page so they can be fed back
126
# when the hold is confirmed. TODO: Not necessary?
119
# when the hold is confirmed. TODO: Not necessary?
127
$template->param( biblionumbers => $biblionumbers );
120
$template->param( biblionumbers => @biblionumbers );
128
129
# Each biblio number is suffixed with '/', e.g. "1/2/3/"
130
my @biblionumbers = split /\//, $biblionumbers;
131
if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
132
    # TODO: New message?
133
    $template->param(message=>1, no_biblionumber=>1);
134
    &get_out($query, $cookie, $template->output);
135
}
136
121
137
122
138
# pass the pickup branch along....
123
# pass the pickup branch along....
Lines 204-242 if ( $query->param('place_reserve') ) { Link Here
204
        $reserve_cnt = $patron->holds->count;
189
        $reserve_cnt = $patron->holds->count;
205
    }
190
    }
206
191
207
    # List is composed of alternating biblio/item/branch
208
    my $selectedItems = $query->param('selecteditems');
209
210
    if ($query->param('reserve_mode') eq 'single') {
211
        # This indicates non-JavaScript mode, so there was
212
        # only a single biblio number selected.
213
        my $bib = $query->param('single_bib');
214
        my $item = $query->param("checkitem_$bib");
215
        if ($item eq 'any') {
216
            $item = '';
217
        }
218
        my $branch = $query->param('branch');
219
        $selectedItems = "$bib/$item/$branch/";
220
    }
221
222
    $selectedItems =~ s!/$!!;
223
    my @selectedItems = split /\//, $selectedItems, -1;
224
225
    # Make sure there is a biblionum/itemnum/branch triplet for each item.
226
    # The itemnum can be 'any', meaning next available.
227
    my $selectionCount = @selectedItems;
228
    if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
229
        $template->param(message=>1, bad_data=>1);
230
        &get_out($query, $cookie, $template->output);
231
    }
232
233
    my $failed_holds = 0;
192
    my $failed_holds = 0;
234
    while (@selectedItems) {
193
    foreach my $biblioNum (@biblionumbers) {
235
        my $biblioNum = shift(@selectedItems);
194
        my $itemNum = $query->param("checkitem_$biblioNum");
236
        my $itemNum   = shift(@selectedItems);
195
        my @itemnumbers = $query->param("checkitem_$biblioNum");
237
        my $branch    = shift(@selectedItems);    # i.e., branch code, not name
196
        my $branch = $query->param("branch_$biblioNum");
238
197
        my $reqtype = $query->param("reqtype_$biblioNum");
239
        my $canreserve = 0;
198
        my $holds_to_place_count = $query->param("holds_to_place_count_$biblioNum") || 1;
199
        my $notes = $query->param('notes_'.$biblioNum) || '';
200
        my $nbRequested = $reqtype eq 'Specific' ? @itemnumbers : $holds_to_place_count;
201
202
        my $canreserve = 1;
203
        if (   $maxreserves
204
            && $reserve_cnt + $nbRequested >= $maxreserves )
205
        {
206
            $canreserve = 0;
207
        }
240
208
241
        my $singleBranchMode = Koha::Libraries->search->count == 1;
209
        my $singleBranchMode = Koha::Libraries->search->count == 1;
242
        if ( $singleBranchMode || !$OPACChooseBranch )
210
        if ( $singleBranchMode || !$OPACChooseBranch )
Lines 244-250 if ( $query->param('place_reserve') ) { Link Here
244
            $branch = $patron->branchcode;
212
            $branch = $patron->branchcode;
245
        }
213
        }
246
214
247
#item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
248
        if ( $itemNum ne '' ) {
215
        if ( $itemNum ne '' ) {
249
            my $item = Koha::Items->find( $itemNum );
216
            my $item = Koha::Items->find( $itemNum );
250
            my $hostbiblioNum = $item->biblio->biblionumber;
217
            my $hostbiblioNum = $item->biblio->biblionumber;
Lines 266-296 if ( $query->param('place_reserve') ) { Link Here
266
233
267
        my $expiration_date = $query->param("expiration_date_$biblioNum");
234
        my $expiration_date = $query->param("expiration_date_$biblioNum");
268
235
269
      # If a specific item was selected and the pickup branch is the same as the
236
        # If a specific item was selected and the pickup branch is the same as the
270
      # holdingbranch, force the value $rank and $found.
237
        # holdingbranch, force the value $rank and $found.
271
        my $rank = $biblioData->{rank};
238
        my $rank = $biblioData->{rank};
272
        if ( $itemNum ne '' ) {
239
        if ( $reqtype eq 'Specific') {
273
            $canreserve = 1 if CanItemBeReserved( $borrowernumber, $itemNum ) eq 'OK';
240
            foreach my $itemnumber (@itemnumbers) {
274
            $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
241
                my $biblionumber = $biblioNum;
275
            my $item = GetItem($itemNum);
242
276
            if ( $item->{'holdingbranch'} eq $branch ) {
243
                #item may belong to a host biblio, if yes change biblioNum to hosts bilbionumber
277
                $found = 'W'
244
                my $hostbiblioNum = GetBiblionumberFromItemnumber($itemnumber);
278
                  unless C4::Context->preference('ReservesNeedReturns');
245
                if ( $hostbiblioNum ne $biblioNum ) {
279
            }
246
                    $biblionumber = $hostbiblioNum;
280
        }
247
                }
281
        else {
282
            $canreserve = 1 if CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK';
283
248
284
            # Inserts a null into the 'itemnumber' field of 'reserves' table.
249
                $canreserve = 0 unless CanItemBeReserved( $borrowernumber, $itemnumber ) eq 'OK';
285
            $itemNum = undef;
250
                $rank = '0' unless C4::Context->preference('ReservesNeedReturns');
286
        }
251
                my $item = GetItem($itemnumber);
287
        my $notes = $query->param('notes_'.$biblioNum)||'';
252
                if ( $item->{'holdingbranch'} eq $branch ) {
253
                    $found = 'W'
254
                      unless C4::Context->preference('ReservesNeedReturns');
255
                }
288
256
289
        if (   $maxreserves
257
                if ($canreserve) {
290
            && $reserve_cnt >= $maxreserves )
258
                    my $reserve_id = AddReserve(
291
        {
259
                        $branch,         $borrowernumber,
292
            $canreserve = 0;
260
                        $biblionumber,
261
                        [$biblionumber], $rank,
262
                        $startdate,      $expiration_date,
263
                        $notes,          $biblioData->{title},
264
                        $itemnumber,     $found
265
                    );
266
                    $failed_holds++ unless $reserve_id;
267
                    ++$reserve_cnt;
268
                }
269
            }
270
            print $query->redirect("/cgi-bin/koha/opac-user.pl?" . ( $failed_holds ? "failed_holds=$failed_holds" : q|| ) . "#opac-user-holds");
271
            exit;
293
        }
272
        }
273
        $canreserve = 0 unless CanBookBeReserved( $borrowernumber, $biblioNum ) eq 'OK';
294
274
295
        unless ( $can_place_hold_if_available_at_pickup ) {
275
        unless ( $can_place_hold_if_available_at_pickup ) {
296
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
276
            my $items_in_this_library = Koha::Items->search({ biblionumber => $biblioNum, holdingbranch => $branch });
Lines 306-319 if ( $query->param('place_reserve') ) { Link Here
306
286
307
        # Here we actually do the reserveration. Stage 3.
287
        # Here we actually do the reserveration. Stage 3.
308
        if ($canreserve) {
288
        if ($canreserve) {
309
            my $reserve_id = AddReserve(
289
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
310
                $branch,          $borrowernumber, $biblioNum,
290
                my $reserve_id = AddReserve(
311
                [$biblioNum],     $rank,           $startdate,
291
                    $branch,          $borrowernumber, $biblioNum,
312
                $expiration_date, $notes,          $biblioData->{title},
292
                    [$biblioNum],     $rank,           $startdate,
313
                $itemNum,         $found,          $itemtype,
293
                    $expiration_date, $notes,          $biblioData->{title},
314
            );
294
                    $itemNum,         $found,          $itemtype,
315
            $failed_holds++ unless $reserve_id;
295
                );
316
            ++$reserve_cnt;
296
                $failed_holds++ unless $reserve_id;
297
                ++$reserve_cnt;
298
            }
317
        }
299
        }
318
    }
300
    }
319
301
Lines 373-378 if ( $maxreserves && ( $reserves_count >= $maxreserves ) ) { Link Here
373
}
355
}
374
356
375
unless ( $noreserves ) {
357
unless ( $noreserves ) {
358
    $template->param(
359
        maxreserves => $maxreserves,
360
        reserves_count => $reserves_count
361
    );
376
    my $requested_reserves_count = scalar( @biblionumbers );
362
    my $requested_reserves_count = scalar( @biblionumbers );
377
    if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
363
    if ( $maxreserves && ( $reserves_count + $requested_reserves_count > $maxreserves ) ) {
378
        $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
364
        $template->param( new_reserves_allowed => $maxreserves - $reserves_count );
Lines 542-548 foreach my $biblioNum (@biblionumbers) { Link Here
542
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $patron_unblessed ) ) {
528
            if ( my $hold_allowed = OPACItemHoldsAllowed( $itemInfo, $patron_unblessed ) ) {
543
                $itemLoopIter->{available} = 1;
529
                $itemLoopIter->{available} = 1;
544
                $numCopiesOPACAvailable++;
530
                $numCopiesOPACAvailable++;
545
                $biblioLoopIter{force_hold} = 1 if $hold_allowed eq 'F';
531
                $biblioLoopIter{force_hold} = 'item' if $hold_allowed eq 'F';
546
            }
532
            }
547
            $numCopiesAvailable++;
533
            $numCopiesAvailable++;
548
534
Lines 602-619 foreach my $biblioNum (@biblionumbers) { Link Here
602
    # patron placed a record level hold, all the holds the patron places must
588
    # patron placed a record level hold, all the holds the patron places must
603
    # be record level. If the patron placed an item level hold, all holds
589
    # be record level. If the patron placed an item level hold, all holds
604
    # the patron places must be item level
590
    # the patron places must be item level
605
    my $forced_hold_level = Koha::Holds->search(
591
    my $holds = Koha::Holds->search(
606
        {
592
        {
607
            borrowernumber => $borrowernumber,
593
            borrowernumber => $borrowernumber,
608
            biblionumber   => $biblioNum,
594
            biblionumber   => $biblioNum,
609
            found          => undef,
595
            found          => undef,
610
        }
596
        }
611
    )->forced_hold_level();
597
    );
598
    my $forced_hold_level = $holds->forced_hold_level();
612
    if ($forced_hold_level) {
599
    if ($forced_hold_level) {
613
        $biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
600
        #$biblioLoopIter{force_hold}   = 1 if $forced_hold_level eq 'item';
614
        $biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
601
        #$biblioLoopIter{itemholdable} = 0 if $forced_hold_level eq 'record';
602
        $biblioLoopIter{force_hold} = $forced_hold_level;
615
    }
603
    }
616
604
605
    my $max_holds_for_record = GetMaxPatronHoldsForRecord( $borrowernumber, $biblioNum );
606
    my $remaining_holds_for_record = $max_holds_for_record - $holds->count();
607
    $biblioLoopIter{remaining_holds_for_record} = $remaining_holds_for_record;
608
617
609
618
    push @$biblioLoop, \%biblioLoopIter;
610
    push @$biblioLoop, \%biblioLoopIter;
619
611
(-)a/reserve/placerequest.pl (-21 / +14 lines)
Lines 48-54 my $startdate = $input->param('reserve_date') || ''; Link Here
48
my @rank           = $input->multi_param('rank-request');
48
my @rank           = $input->multi_param('rank-request');
49
my $type           = $input->param('type');
49
my $type           = $input->param('type');
50
my $title          = $input->param('title');
50
my $title          = $input->param('title');
51
my $checkitem      = $input->param('checkitem');
51
my @checkitems     = $input->param('checkitem');
52
my $expirationdate = $input->param('expiration_date');
52
my $expirationdate = $input->param('expiration_date');
53
my $itemtype       = $input->param('itemtype') || undef;
53
my $itemtype       = $input->param('itemtype') || undef;
54
54
Lines 59-64 my $multi_hold = $input->param('multi_hold'); Link Here
59
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
59
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
60
my $bad_bibs = $input->param('bad_bibs');
60
my $bad_bibs = $input->param('bad_bibs');
61
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
61
my $holds_to_place_count = $input->param('holds_to_place_count') || 1;
62
$holds_to_place_count = scalar(@checkitems) if scalar(@checkitems);
62
63
63
my %bibinfos = ();
64
my %bibinfos = ();
64
my @biblionumbers = split '/', $biblionumbers;
65
my @biblionumbers = split '/', $biblionumbers;
Lines 69-85 foreach my $bibnum (@biblionumbers) { Link Here
69
    $bibinfos{$bibnum} = \%bibinfo;
70
    $bibinfos{$bibnum} = \%bibinfo;
70
}
71
}
71
72
72
my $found;
73
my @found;
73
74
74
# if we have an item selectionned, and the pickup branch is the same as the holdingbranch
75
foreach my $checkitem (@checkitems) {
75
# of the document, we force the value $rank and $found .
76
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
76
if (defined $checkitem && $checkitem ne ''){
77
    # of the document, we force the value $rank and $found .
77
    $holds_to_place_count = 1;
78
    $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
78
    $rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
79
    my $item = $checkitem;
79
    my $item = GetItem($checkitem);
80
    $item = GetItem($item);
81
    if ( $item->{'holdingbranch'} eq $branch ){
80
    if ( $item->{'holdingbranch'} eq $branch ){
82
        $found = 'W' unless C4::Context->preference('ReservesNeedReturns');
81
        push @found, 'W' unless C4::Context->preference('ReservesNeedReturns');
83
    }
82
    }
84
}
83
}
85
84
Lines 99-121 if ( $type eq 'str8' && $borrower ) { Link Here
99
            }
98
            }
100
        }
99
        }
101
100
102
        if ( defined $checkitem && $checkitem ne '' ) {
103
            my $item = GetItem($checkitem);
104
            if ( $item->{'biblionumber'} ne $biblionumber ) {
105
                $biblionumber = $item->{'biblionumber'};
106
            }
107
        }
108
109
        if ($multi_hold) {
101
        if ($multi_hold) {
110
            my $bibinfo = $bibinfos{$biblionumber};
102
            my $bibinfo = $bibinfos{$biblionumber};
111
            AddReserve($branch,$borrower->{'borrowernumber'},$biblionumber,[$biblionumber],
103
            AddReserve( $branch, $borrower->{'borrowernumber'},
112
                       $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
104
                        $biblionumber, [$biblionumber],
105
                        $bibinfo->{rank}, $startdate, $expirationdate, $notes,$bibinfo->{title});
113
        } else {
106
        } else {
114
            # place a request on 1st available
107
            # place a request on 1st available
115
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
108
            for ( my $i = 0 ; $i < $holds_to_place_count ; $i++ ) {
109
                my $item = GetItem($checkitems[$i]);
116
                AddReserve( $branch, $borrower->{'borrowernumber'},
110
                AddReserve( $branch, $borrower->{'borrowernumber'},
117
                    $biblionumber, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title,
111
                    $item->{biblionumber}, \@realbi, $rank[0], $startdate, $expirationdate, $notes, $title,
118
                    $checkitem, $found, $itemtype );
112
                    $checkitems[$i], $found[$i] );
119
            }
113
            }
120
        }
114
        }
121
    }
115
    }
122
- 

Return to bug 15565