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