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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+4 lines)
Lines 2863-2868 td.bundle { Link Here
2863
    background: #FFF url( "../img/spinner-small.gif" ) right center no-repeat;
2863
    background: #FFF url( "../img/spinner-small.gif" ) right center no-repeat;
2864
}
2864
}
2865
2865
2866
.patron-detail-autocomplete-selection {
2867
    padding: 0.3em;
2868
}
2869
2866
.toptabs {
2870
.toptabs {
2867
    margin: 1rem 0;
2871
    margin: 1rem 0;
2868
}
2872
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/duplicate_orders.tt (-24 / +5 lines)
Lines 323-329 Link Here
323
            $("input[name='ordernumbers']").val(ordernumbers.join(','));
323
            $("input[name='ordernumbers']").val(ordernumbers.join(','));
324
        }
324
        }
325
325
326
        var MSG_REMOVE_PATRON = _("Remove");
327
        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
326
        var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
328
        var MSG_NO_FUND_SELECTED = _("No fund selected.");
327
        var MSG_NO_FUND_SELECTED = _("No fund selected.");
329
        $(document).ready(function() {
328
        $(document).ready(function() {
Lines 333-366 Link Here
333
            });
332
            });
334
333
335
            [% IF op == 'search' OR op == 'select' %]
334
            [% IF op == 'search' OR op == 'select' %]
336
                function AddPatron( patron_name, value, container, input_name ) {
337
                    div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
338
                    $(container).append( div );
339
340
                    $(container).parent().show( 800 );
341
                }
342
                function RemovePatron( cardnumber, container ) {
343
                    $( '#borrower_' + cardnumber ).remove();
344
345
                    if ( ! $(container).html() ) {
346
                        $(container).parent("fieldset").hide( 800 );
347
                    }
348
                }
349
                patron_autocomplete($("#find_patron"), {
335
                patron_autocomplete($("#find_patron"), {
350
                    'on-select-callback': function( event, ui ) {
336
                    "on-select-add-to": {
351
                        var field = ui.item.patron_id;
337
                        container: $("#basket_creators"),
352
                        AddPatron( ui.item.firstname + " " + ( ui.item.middle_name || "" ) + " " + ui.item.surname, field, $("#basket_creators"), 'created_by' );
338
                        input_name: 'created_by'
339
                    },
340
                    "on-select-callback": function( event, ui ) {
353
                        $("#find_patron").val('').focus();
341
                        $("#find_patron").val('').focus();
354
                        return false;
342
                        return false;
355
                    }
343
                    }
356
                });
344
                });
357
                $("body").on("click",".removePatron",function(e){
358
                    e.preventDefault();
359
                    var divid = $(this).parent().attr("id");
360
                    var cardnumber = divid.replace("borrower_","");
361
                    RemovePatron(cardnumber, $("#basket_creators"));
362
                });
363
364
            [% END %]
345
            [% END %]
365
346
366
            $("#show_orders_filters, #hide_orders_filters").on('click', function(e) {
347
            $("#show_orders_filters, #hide_orders_filters").on('click', function(e) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/histsearch.tt (-22 / +1 lines)
Lines 168-174 Link Here
168
    [% INCLUDE 'calendar.inc' %]
168
    [% INCLUDE 'calendar.inc' %]
169
    [% INCLUDE 'datatables.inc' %]
169
    [% INCLUDE 'datatables.inc' %]
170
    <script>
170
    <script>
171
        var MSG_REMOVE_PATRON = _("Remove");
172
        $(document).ready(function() {
171
        $(document).ready(function() {
173
            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
172
            var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'histsearch', 'histsearcht', 'json' ) | $raw %];
174
            $("#histsearcht").kohaTable(
173
            $("#histsearcht").kohaTable(
Lines 178-210 Link Here
178
                table_settings
177
                table_settings
179
            );
178
            );
180
179
181
            function AddPatron( patron_name, value, container, input_name ) {
182
                div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
183
                $(container).append( div );
184
185
                $(container).parent().show( 800 );
186
            }
187
            function RemovePatron( cardnumber, container ) {
188
                $( '#borrower_' + cardnumber ).remove();
189
190
                if ( ! $(container).html() ) {
191
                    $(container).parent("fieldset").hide( 800 );
192
                }
193
            }
194
            patron_autocomplete($("#find_patron"), {
180
            patron_autocomplete($("#find_patron"), {
181
                'on-select-add-to': {container: $("#basket_creators"), input_name: 'created_by' },
195
                'on-select-callback': function( event, ui ) {
182
                'on-select-callback': function( event, ui ) {
196
                    var field = ui.item.patron_id;
197
                    AddPatron( ui.item.firstname + " " + ( ui.item.middle_name || "" ) + " " + ui.item.surname, field, $("#basket_creators"), 'created_by' );
198
                    $("#find_patron").val('').focus();
183
                    $("#find_patron").val('').focus();
199
                    return false;
184
                    return false;
200
                }
185
                }
201
            });
186
            });
202
            $("body").on("click",".removePatron",function(e){
203
                e.preventDefault();
204
                var divid = $(this).parent().attr("id");
205
                var cardnumber = divid.replace("borrower_","");
206
                RemovePatron(cardnumber, $("#basket_creators"));
207
            });
208
187
209
        });
188
        });
210
    </script>
189
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course.tt (-42 / +7 lines)
Lines 19-27 Link Here
19
    #course_instructors {
19
    #course_instructors {
20
        float: left;
20
        float: left;
21
    }
21
    }
22
    .instructor_line {
23
        padding: 0.3em;
24
    }
25
    fieldset.rows label[for="find_instructor"] {
22
    fieldset.rows label[for="find_instructor"] {
26
        text-align: left;
23
        text-align: left;
27
        margin: 0;
24
        margin: 0;
Lines 131-143 Link Here
131
                        <div id="course_instructors">
128
                        <div id="course_instructors">
132
                            <div id="instructors">
129
                            <div id="instructors">
133
                                [% FOREACH i IN instructors %]
130
                                [% FOREACH i IN instructors %]
134
                                    <div class="instructor_line" id="borrower_[% i.borrowernumber | html %]"
131
                                    <div class="patron-detail-autocomplete-selection" id="patron-detail-[% i.borrowernumber | html %]">
135
                                        >[% i.surname | html %], [% i.firstname | html %] ( <a href="#" class="removeInstructor"><i class="fa fa-trash-can"></i> Remove </a> )
132
                                        [% INCLUDE 'patron-title.inc' patron=i no_cardnumber=1 %] (<a href="#" class="removePatron"><i class="fa fa-trash-can"></i> Remove </a>)
136
                                        <input type="hidden" name="instructors" value="[% i.borrowernumber | html %]" />
133
                                        <input type="hidden" name="instructors" value="[% i.borrowernumber | html %]" />
137
                                    </div>
134
                                    </div>
138
                                [% END %]
135
                                [% END %]
139
                            </div>
136
                            </div>
140
                            <div id="instructor_search" class="instructor_line">
137
                            <div id="instructor_search" class="patron-detail-autocomplete-selection">
141
                                <label for="find_instructor">Instructor search:</label>
138
                                <label for="find_instructor">Instructor search:</label>
142
                                <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit" />
139
                                <input autocomplete="off" id="find_instructor" type="text" style="width:150px" class="noEnterSubmit" />
143
                            </div>
140
                            </div>
Lines 198-245 Link Here
198
        <script>
195
        <script>
199
            $(document).ready(function () {
196
            $(document).ready(function () {
200
                patron_autocomplete($("#find_instructor"), {
197
                patron_autocomplete($("#find_instructor"), {
198
                    "on-select-add-to": { container: $("#instructors"), input_name: "instructors" },
201
                    "on-select-callback": function (event, ui) {
199
                    "on-select-callback": function (event, ui) {
202
                        AddInstructor(ui.item.surname + ", " + ui.item.firstname, ui.item.patron_id);
200
                        $("#find_instructor").val("").focus();
203
                        return false;
204
                    },
201
                    },
205
                });
202
                });
206
203
                $(".removePatron").on("click", function (e) {
207
                if (!$("#instructors").html()) {
208
                    $("#course_instructors").hide();
209
                }
210
211
                $("body").on("click", ".removeInstructor", function (e) {
212
                    e.preventDefault();
204
                    e.preventDefault();
213
                    var divid = $(this).parent().attr("id");
205
                    $(this).closest('div[id^="patron-detail-"]').remove();
214
                    var borrowernumber = divid.replace("borrower_", "");
215
                    RemoveInstructor(borrowernumber);
216
                });
206
                });
217
            });
207
            });
218
219
            function AddInstructor(name, borrowernumber) {
220
                div =
221
                    "<div class='instructor_line' id='borrower_" +
222
                    borrowernumber +
223
                    "'>" +
224
                    (name ? name.escapeHtml() : "") +
225
                    " ( <a href='#' class='removeInstructor'><i class='fa fa-trash-can'></i> " +
226
                    _("Remove") +
227
                    " </a> ) <input type='hidden' name='instructors' value='" +
228
                    borrowernumber +
229
                    "' /></div>";
230
                $("#instructors").append(div);
231
232
                $("#find_instructor").val("").focus();
233
                $("#course_instructors").show();
234
            }
235
236
            function RemoveInstructor(borrowernumber) {
237
                $("#borrower_" + borrowernumber).remove();
238
239
                if (!$("#instructors").html()) {
240
                    $("#course_instructors").hide(800);
241
                }
242
            }
243
        </script>
208
        </script>
244
    [% END %]
209
    [% END %]
245
[% END %]
210
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt (-16 / +5 lines)
Lines 235-241 Link Here
235
    [% Asset.js("js/tools-menu.js") | $raw %]
235
    [% Asset.js("js/tools-menu.js") | $raw %]
236
    [% INCLUDE 'datatables.inc' %]
236
    [% INCLUDE 'datatables.inc' %]
237
    <script>
237
    <script>
238
        var MSG_REMOVE_PATRON = _("Remove");
239
        $(document).ready(function() {
238
        $(document).ready(function() {
240
            $('#patrons_to_add_fieldset').hide();
239
            $('#patrons_to_add_fieldset').hide();
241
240
Lines 247-258 Link Here
247
                    table_settings
246
                    table_settings
248
                );
247
                );
249
248
250
            function AddPatron( patron_name, value, container, input_name ) {
251
                div = "<div id='borrower_" + value + "'>" + patron_name + " ( <a href='#' class='removePatron'><i class='fa fa-trash-can' aria-hidden='true'></i> " + MSG_REMOVE_PATRON + " </a> ) <input type='hidden' name='" + input_name + "' value='" + value + "' /></div>";
252
                $(container).append( div );
253
254
                $(container).parent().show( 800 );
255
            }
256
            function RemovePatron( cardnumber, container ) {
249
            function RemovePatron( cardnumber, container ) {
257
                $( '#borrower_' + cardnumber ).remove();
250
                $( '#borrower_' + cardnumber ).remove();
258
251
Lines 261-279 Link Here
261
                }
254
                }
262
            }
255
            }
263
            patron_autocomplete($("#find_patron"), {
256
            patron_autocomplete($("#find_patron"), {
264
                'on-select-callback': function( event, ui ) {
257
                "on-select-add-to": {
265
                    var field = ui.item.cardnumber;
258
                    container: $("#patrons_to_add"),
266
                    AddPatron( ( ui.item.firstname || "" ) + " " + ( ui.item.middle_name || "" ) + " " + ( ui.item.surname || "" ), field, $("#patrons_to_add"), 'patrons_to_add' );
259
                    input_name: 'patrons_to_add',
260
                },
261
                "on-select-callback": function( event, ui ) {
267
                    $("#find_patron").val('').focus();
262
                    $("#find_patron").val('').focus();
268
                    return false;
263
                    return false;
269
                }
264
                }
270
            });
265
            });
271
            $("body").on("click",".removePatron",function(e){
272
                e.preventDefault();
273
                var divid = $(this).parent().attr("id");
274
                var cardnumber = divid.replace("borrower_","");
275
                RemovePatron(cardnumber, $("#patrons_to_add"));
276
            });
277
266
278
            $("body").on("click", "#CheckAll", function(e){
267
            $("body").on("click", "#CheckAll", function(e){
279
                e.preventDefault();
268
                e.preventDefault();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-16 / +20 lines)
Lines 219-225 Link Here
219
                <div>
219
                <div>
220
                    <label for="find_patron">New owner: </label>
220
                    <label for="find_patron">New owner: </label>
221
                    <span id="new_owner_name"></span>
221
                    <span id="new_owner_name"></span>
222
                    <input type="hidden" id="new_owner" name="new_owner" value="" />
223
                </div>
222
                </div>
224
223
225
                <br />
224
                <br />
Lines 958-982 Link Here
958
             });
957
             });
959
958
960
        [% END %]
959
        [% END %]
960
    </script>
961
    [% IF op == 'transfer' %]
962
        <script>
963
            $(document).ready(function () {
964
                patron_autocomplete($("#find_patron"), {
965
                    "on-select-add-to": {
966
                        container: $("#new_owner_name"),
967
                        input_name: "new_owner",
968
                    },
969
                    "on-select-callback": function (event, ui) {
970
                        $("#find_patron").val("").focus();
971
                        return false;
972
                    },
973
                });
961
974
962
        [% IF op == 'transfer' %]
975
                $("#transferform").submit(function () {
963
            $(document).ready(function() {
976
                    if (!$('input[name="new_owner"]').val()) {
964
                patron_autocomplete( $("#find_patron"), { 'on-select-callback': function( event, ui ) {
977
                        alert(_("Please select a new owner first"));
965
                    $('#new_owner_name').html( ui.item.firstname + " " + ui.item.surname );
966
                    $('#new_owner').val( ui.item.patron_id );
967
                    $('#find_patron').val('').focus();
968
                    return false;
969
                }});
970
971
                $('#transferform').submit(function() {
972
                    if( $('#new_owner').val() == '' ) {
973
                        alert( _("Please select a new owner first") );
974
                        return false;
978
                        return false;
975
                    }
979
                    }
976
                    return true;
980
                    return true;
977
                });
981
                });
978
             });
982
            });
979
        [% END %]
983
        </script>
980
    </script>
984
    [% END %]
981
[% END %]
985
[% END %]
982
[% INCLUDE 'intranet-bottom.inc' %]
986
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-2 / +27 lines)
Lines 691-696 function patron_autocomplete(node, options) { Link Here
691
    let link_to;
691
    let link_to;
692
    let url_params;
692
    let url_params;
693
    let on_select_callback;
693
    let on_select_callback;
694
    let on_select_add_to;
694
695
695
    if (options) {
696
    if (options) {
696
        if (options["link-to"]) {
697
        if (options["link-to"]) {
Lines 702-707 function patron_autocomplete(node, options) { Link Here
702
        if (options["on-select-callback"]) {
703
        if (options["on-select-callback"]) {
703
            on_select_callback = options["on-select-callback"];
704
            on_select_callback = options["on-select-callback"];
704
        }
705
        }
706
        if (options["on-select-add-to"]) {
707
            on_select_add_to = options["on-select-add-to"];
708
        }
705
    }
709
    }
706
    return (node
710
    return (node
707
        .autocomplete({
711
        .autocomplete({
Lines 738-746 function patron_autocomplete(node, options) { Link Here
738
            },
742
            },
739
            minLength: 3,
743
            minLength: 3,
740
            select: function (event, ui) {
744
            select: function (event, ui) {
741
                if (ui.item.link) {
745
                if (on_select_add_to) {
746
                    let container = on_select_add_to.container;
747
748
                    const patron_name = $patron_to_html(ui.item);
749
                    const node = `
750
                      <div id='patron-detail-${ui.item.patron_id}' class='patron-detail-autocomplete-selection'>
751
                        ${patron_name}
752
                        (<a href='#' class='removePatron'>
753
                          <i class='fa fa-trash-can' aria-hidden='true'></i> ${__("Remove")}
754
                        </a>)
755
                        <input type='hidden' name='${on_select_add_to.input_name}' value='${ui.item.patron_id}' />
756
                      </div>
757
                    `;
758
759
                    $(container).append(node).parent().show(800);
760
761
                    $(container).on("click", ".removePatron", function (e) {
762
                        e.preventDefault();
763
                        $(this).closest('div[id^="patron-detail-"]').remove();
764
                    });
765
                } else if (ui.item.link) {
742
                    window.location.href = ui.item.link;
766
                    window.location.href = ui.item.link;
743
                } else if (on_select_callback) {
767
                }
768
                if (on_select_callback) {
744
                    return on_select_callback(event, ui);
769
                    return on_select_callback(event, ui);
745
                }
770
                }
746
            },
771
            },
(-)a/patron_lists/list.pl (-2 / +1 lines)
Lines 74-80 if ( $op eq 'cud-add' && $patrons_by_id ) { Link Here
74
74
75
my @patrons_to_add = $cgi->multi_param('patrons_to_add');
75
my @patrons_to_add = $cgi->multi_param('patrons_to_add');
76
if ( $op eq 'cud-add' && @patrons_to_add ) {
76
if ( $op eq 'cud-add' && @patrons_to_add ) {
77
    AddPatronsToList( { list => $list, cardnumbers => \@patrons_to_add } );
77
    AddPatronsToList( { list => $list, borrowernumbers => \@patrons_to_add } );
78
}
78
}
79
79
80
my @patrons_to_remove = $cgi->multi_param('patrons_to_remove');
80
my @patrons_to_remove = $cgi->multi_param('patrons_to_remove');
81
- 

Return to bug 32176