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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-212 / +213 lines)
Lines 4-9 Link Here
4
[% USE Branches %]
4
[% USE Branches %]
5
[% USE Categories %]
5
[% USE Categories %]
6
[% USE ItemTypes %]
6
[% USE ItemTypes %]
7
[% SET footerjs = 1 %]
7
[% INCLUDE 'doc-head-open.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
8
[% UNLESS ( multi_hold ) %]
9
[% UNLESS ( multi_hold ) %]
9
    <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on [% title |html %]</title>
10
    <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on [% title |html %]</title>
Lines 12-229 Link Here
12
[% END %]
13
[% END %]
13
[% INCLUDE 'doc-head-close.inc' %]
14
[% INCLUDE 'doc-head-close.inc' %]
14
[% Asset.css("css/datatables.css") %]
15
[% Asset.css("css/datatables.css") %]
15
[% INCLUDE 'datatables.inc' %]
16
[% INCLUDE 'calendar.inc' %]
17
[% Asset.js("js/circ-patron-search-results.js") %]
18
<script type="text/javascript">
19
    // <![CDATA[
20
var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
21
var patron_homebranch = "[% Branches.GetName( patron.branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
22
var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
23
    [% itemloo.itemnumber %]: {
24
        homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
25
        holdallowed: [% itemloo.holdallowed %]
26
    },
27
[% END %][% END %][% END %]
28
};
29
var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
30
31
$(document).ready(function() {
32
    function ToggleHoldsToPlace() {
33
        if ( $("#requestany").prop('checked') ) {
34
            $("#holds_to_place_count").prop('disabled', false);
35
        } else {
36
            $("#holds_to_place_count").prop('disabled', true);
37
        }
38
    }
39
    ToggleHoldsToPlace();
40
    $("#requestany").on('change', function(){
41
        ToggleHoldsToPlace();
42
    });
43
44
    [% IF AutoResumeSuspendedHolds %]
45
        $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
46
    [% END %]
47
48
    var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
49
        'bPaginate': false,
50
        "sDom": '<"top pager"ilf>t',
51
        "aoColumnDefs": [
52
            { "sType": "title-string", "aTargets" : [ "title-string" ] }
53
        ]
54
    }));
55
56
    //Override fieldset styling for dataTables search box
57
    $("div.top.pager").css("margin-left","1em");
58
    $(".dataTables_filter label").css({
59
        "width":"auto",
60
        "margin-right":"0em"
61
    });
62
63
});
64
65
function check() {
66
    var msg = "";
67
    var count_reserv = 0;
68
69
    // check if we have checkitem form
70
    if (document.form.checkitem){
71
        for (i=0;i<document.form.checkitem.length;i++){
72
            if (document.form.checkitem[i].checked == true) {
73
                count_reserv++ ;
74
            }
75
        }
76
        // for only one item, check the checkitem without consider the loop checkitem
77
        if (i==0){
78
            if (document.form.checkitem.checked == true) {
79
                count_reserv++;
80
            }
81
        }
82
    }
83
84
    if (document.form.requestany.checked == true){
85
        count_reserv++ ;
86
    }
87
88
    if (count_reserv == "0"){
89
        msg += (_("- Please select an item to place a hold") + "\n");
90
    }
91
92
    if (msg == "") {
93
        $('#hold-request-form').preventDoubleFormSubmit();
94
        return(true);
95
    } else {
96
        alert(msg);
97
        return(false);
98
    }
99
}
100
101
function checkMultiHold() {
102
    var spans = $(".multi_hold_item");
103
    if ($(spans).size() == 0) {
104
        alert(MSG_NO_ITEMS_AVAILABLE);
105
        return false;
106
    }
107
108
    var biblionumbers = "";
109
    $(spans).each(function() {
110
        var bibnum = $(this).attr("title");
111
        biblionumbers += bibnum + "/";
112
    });
113
114
    var badSpans = $(".not_holdable");
115
    var badBibs = "";
116
    $(badSpans).each(function() {
117
        var bibnum = $(this).attr("title");
118
        badBibs += bibnum + "/";
119
    });
120
121
    $("#multi_hold_bibs").val(biblionumbers);
122
    $("#bad_bibs").val(badBibs);
123
124
    $('#hold-request-form').preventDoubleFormSubmit();
125
126
    return true;
127
}
128
129
 $(document).ready(function() {
130
    $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
131
        var itemnumber = this.value;
132
        var msg = '';
133
134
        switch (override_items[itemnumber].holdallowed) {
135
            case 0: msg = _("This item normally cannot be put on hold."); break;
136
            case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
137
        }
138
139
        msg += "\n\n" + _("Place hold on this item?");
140
141
        return confirm(msg);
142
    });
143
    $("input.warning").click(function() {
144
        return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
145
    });
146
    $("#requestany").click(function() {
147
        if(this.checked){
148
            $("input[name=checkitem]").each(function() {
149
                $(this).prop("checked", false);
150
            });
151
        }
152
    });
153
    $("input[name=checkitem]").click(function() {
154
        onechecked = 0;
155
        $("input[name=checkitem]").each(function() {
156
            if(this.checked){
157
                onechecked = 1;
158
            }
159
        });
160
        if(onechecked == 1){
161
            $("#requestany").prop("checked", false);
162
        } else {
163
            $("#requestany").prop("checked",true);
164
        }
165
    });
166
    var prev_rank_request;
167
    $("select[name=rank-request]").on("focus", function() {
168
        prev_rank_request = $(this).val();
169
    }).change(function() {
170
        var row = $(this).parents("tr:first");
171
        var value = parseInt($(this).val());
172
        var after = row.parent().find("tr:nth-child("+(value+1)+")");
173
174
        if (prev_rank_request > value) {
175
            row.insertBefore(after);
176
        } else {
177
            row.insertAfter(after);
178
        }
179
180
        var next_priority = 1;
181
        $("select[name=rank-request]").each(function () {
182
            $(this).val(next_priority);
183
            next_priority++;
184
        });
185
    });
186
187
    $(".clear-date").on("click",function(e){
188
        e.preventDefault();
189
        var fieldID = this.id.replace("clear-date-","");
190
        $("#" + fieldID).val("");
191
    });
192
193
    // Confirm cancelation of hold
194
    $(".cancel-hold").on("click",function(e) {
195
        return confirmDelete(MSG_CONFIRM_DELETE_HOLD);
196
    });
197
198
199
[% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
200
    [% IF ( CircAutocompl ) %]
201
    $( "#patron" ).autocomplete({
202
        source: "/cgi-bin/koha/circ/ysearch.pl",
203
        minLength: 3,
204
        select: function( event, ui ) {
205
            $( "#patron" ).val( ui.item.cardnumber );
206
            $( "#holds_patronsearch" ).submit();
207
            return false;
208
        }
209
    })
210
    .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
211
        return $( "<li></li>" )
212
        .data( "ui-autocomplete-item", item )
213
        .append( "<a>" + item.surname + ", " + item.firstname +
214
                 " (" + item.cardnumber + ") <small>" + item.address +
215
                 " " + item.city + " " + item.zipcode + " " +
216
                 item.country + "</small></a>" )
217
        .appendTo( ul );
218
    };
219
    [% END %]
220
[% END %]
221
222
 });
223
224
// ]]>
225
</script>
226
</head>
16
</head>
17
227
<body id="circ_request" class="catalog">
18
<body id="circ_request" class="catalog">
228
[% INCLUDE 'header.inc' %]
19
[% INCLUDE 'header.inc' %]
229
[% INCLUDE 'circ-search.inc' %]
20
[% INCLUDE 'circ-search.inc' %]
Lines 921-924 function checkMultiHold() { Link Here
921
712
922
</div>
713
</div>
923
</div>
714
</div>
715
716
[% MACRO jsinclude BLOCK %]
717
    [% INCLUDE 'datatables.inc' %]
718
    [% INCLUDE 'calendar.inc' %]
719
    [% Asset.js("js/circ-patron-search-results.js") %]
720
    <script>
721
        var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
722
        var patron_homebranch = "[% Branches.GetName( patron.branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
723
        var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
724
        [% itemloo.itemnumber %]: {
725
            homebranch: "[% Branches.GetName( itemloo.homebranch ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]",
726
            holdallowed: [% itemloo.holdallowed %]
727
            },
728
            [% END %][% END %][% END %]
729
        };
730
        var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
731
732
        $(document).ready(function() {
733
            function ToggleHoldsToPlace() {
734
                if ( $("#requestany").prop('checked') ) {
735
                    $("#holds_to_place_count").prop('disabled', false);
736
                } else {
737
                    $("#holds_to_place_count").prop('disabled', true);
738
                }
739
            }
740
            ToggleHoldsToPlace();
741
            $("#requestany").on('change', function(){
742
                ToggleHoldsToPlace();
743
            });
744
745
            [% IF AutoResumeSuspendedHolds %]
746
                $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
747
            [% END %]
748
749
            var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
750
                'bPaginate': false,
751
                "sDom": '<"top pager"ilf>t',
752
                "aoColumnDefs": [
753
                    { "sType": "title-string", "aTargets" : [ "title-string" ] }
754
                ]
755
            }));
756
757
            //Override fieldset styling for dataTables search box
758
            $("div.top.pager").css("margin-left","1em");
759
            $(".dataTables_filter label").css({
760
                "width":"auto",
761
                "margin-right":"0em"
762
            });
763
764
        });
765
766
        function check() {
767
            var msg = "";
768
            var count_reserv = 0;
769
770
            // check if we have checkitem form
771
            if (document.form.checkitem){
772
                for (i=0;i<document.form.checkitem.length;i++){
773
                    if (document.form.checkitem[i].checked == true) {
774
                        count_reserv++ ;
775
                    }
776
                }
777
                // for only one item, check the checkitem without consider the loop checkitem
778
                if (i==0){
779
                    if (document.form.checkitem.checked == true) {
780
                        count_reserv++;
781
                    }
782
                }
783
            }
784
785
            if (document.form.requestany.checked == true){
786
                count_reserv++ ;
787
            }
788
789
            if (count_reserv == "0"){
790
                msg += (_("- Please select an item to place a hold") + "\n");
791
            }
792
793
            if (msg == "") {
794
                $('#hold-request-form').preventDoubleFormSubmit();
795
                return(true);
796
            } else {
797
                alert(msg);
798
                return(false);
799
            }
800
        }
801
802
        function checkMultiHold() {
803
            var spans = $(".multi_hold_item");
804
            if ($(spans).size() == 0) {
805
                alert(MSG_NO_ITEMS_AVAILABLE);
806
                return false;
807
            }
808
809
            var biblionumbers = "";
810
            $(spans).each(function() {
811
                var bibnum = $(this).attr("title");
812
                biblionumbers += bibnum + "/";
813
            });
814
815
            var badSpans = $(".not_holdable");
816
            var badBibs = "";
817
            $(badSpans).each(function() {
818
                var bibnum = $(this).attr("title");
819
                badBibs += bibnum + "/";
820
            });
821
822
            $("#multi_hold_bibs").val(biblionumbers);
823
            $("#bad_bibs").val(badBibs);
824
825
            $('#hold-request-form').preventDoubleFormSubmit();
826
827
            return true;
828
        }
829
830
         $(document).ready(function() {
831
            $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
832
                var itemnumber = this.value;
833
                var msg = '';
834
835
                switch (override_items[itemnumber].holdallowed) {
836
                    case 0: msg = _("This item normally cannot be put on hold."); break;
837
                    case 1: msg = _("This item normally cannot be put on hold except for patrons from %s.").format(override_items[itemnumber].homebranch); break;
838
                }
839
840
                msg += "\n\n" + _("Place hold on this item?");
841
842
                return confirm(msg);
843
            });
844
            $("input.warning").click(function() {
845
                return confirm( _("None of these items can normally be put on hold for this patron.") + "\n\n" + _("Place hold?") );
846
            });
847
            $("#requestany").click(function() {
848
                if(this.checked){
849
                    $("input[name=checkitem]").each(function() {
850
                        $(this).prop("checked", false);
851
                    });
852
                }
853
            });
854
            $("input[name=checkitem]").click(function() {
855
                onechecked = 0;
856
                $("input[name=checkitem]").each(function() {
857
                    if(this.checked){
858
                        onechecked = 1;
859
                    }
860
                });
861
                if(onechecked == 1){
862
                    $("#requestany").prop("checked", false);
863
                } else {
864
                    $("#requestany").prop("checked",true);
865
                }
866
            });
867
            var prev_rank_request;
868
            $("select[name=rank-request]").on("focus", function() {
869
                prev_rank_request = $(this).val();
870
            }).change(function() {
871
                var row = $(this).parents("tr:first");
872
                var value = parseInt($(this).val());
873
                var after = row.parent().find("tr:nth-child("+(value+1)+")");
874
875
                if (prev_rank_request > value) {
876
                    row.insertBefore(after);
877
                } else {
878
                    row.insertAfter(after);
879
                }
880
881
                var next_priority = 1;
882
                $("select[name=rank-request]").each(function () {
883
                    $(this).val(next_priority);
884
                    next_priority++;
885
                });
886
            });
887
888
            $(".clear-date").on("click",function(e){
889
                e.preventDefault();
890
                var fieldID = this.id.replace("clear-date-","");
891
                $("#" + fieldID).val("");
892
            });
893
894
            // Confirm cancelation of hold
895
            $(".cancel-hold").on("click",function(e) {
896
                return confirmDelete(MSG_CONFIRM_DELETE_HOLD);
897
            });
898
899
            [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems ) %]
900
                [% IF ( CircAutocompl ) %]
901
                $( "#patron" ).autocomplete({
902
                    source: "/cgi-bin/koha/circ/ysearch.pl",
903
                    minLength: 3,
904
                    select: function( event, ui ) {
905
                        $( "#patron" ).val( ui.item.cardnumber );
906
                        $( "#holds_patronsearch" ).submit();
907
                        return false;
908
                    }
909
                })
910
                .data( "ui-autocomplete" )._renderItem = function( ul, item ) {
911
                    return $( "<li></li>" )
912
                    .data( "ui-autocomplete-item", item )
913
                    .append( "<a>" + item.surname + ", " + item.firstname +
914
                             " (" + item.cardnumber + ") <small>" + item.address +
915
                             " " + item.city + " " + item.zipcode + " " +
916
                             item.country + "</small></a>" )
917
                    .appendTo( ul );
918
                };
919
                [% END %]
920
            [% END %]
921
922
        });
923
    </script>
924
[% END %]
925
924
[% INCLUDE 'intranet-bottom.inc' %]
926
[% INCLUDE 'intranet-bottom.inc' %]
925
- 

Return to bug 20220