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

(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+20 lines)
Lines 2204-2209 li { Link Here
2204
    }
2204
    }
2205
}
2205
}
2206
2206
2207
#patron_search_selected {
2208
    background-color: #F9FEFF;
2209
    border: 1px solid #B9D8D9;
2210
    border-color: #A2CBCC #CEE0E3 #CEE0E3 #A2CBCC;
2211
    border-radius: 3px;
2212
    color: #333;
2213
    display: inline-block;
2214
    font-size: 11px;
2215
    line-height: 1.5;
2216
    padding: 5px 10px;
2217
    text-align: center;
2218
    vertical-align: middle;
2219
    white-space: nowrap;
2220
}
2221
2222
#clear-patron-selection {
2223
    display: inline-block;
2224
    margin-left: 1em;
2225
}
2226
2207
#search-facets {
2227
#search-facets {
2208
    border: 1px solid #B9D8D9;
2228
    border: 1px solid #B9D8D9;
2209
    border-radius: 5px 5px 0 0;
2229
    border-radius: 5px 5px 0 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-33 / +89 lines)
Lines 99-104 Link Here
99
                    [% IF CAN_user_borrowers_edit_borrowers %]
99
                    [% IF CAN_user_borrowers_edit_borrowers %]
100
                          <button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button>
100
                          <button id="merge-patrons" class="btn btn-sm btn-default disabled" disabled="disabled" type="submit"><i class="fa fa-compress" aria-hidden="true"></i> Merge selected patrons</button>
101
                    [% END %]
101
                    [% END %]
102
                    <div id="patron_search_selected" class="btn-group" style="display:none;">
103
                        <span></span>
104
                        <a href="#" id="clear-patron-selection"><i class="fa fa-remove"></i> Clear</a>
105
                    </div>
102
                  </div>
106
                  </div>
103
                </div>
107
                </div>
104
            [% END %]
108
            [% END %]
Lines 245-253 Link Here
245
            getSearchByLocation( false );
249
            getSearchByLocation( false );
246
        });
250
        });
247
251
252
        function showPatronSelections( number ){
253
            $("#patron_search_selected").show().find("span").text(_("Patrons selected: " + number ) );
254
        }
255
248
        $(document).ready(function() {
256
        $(document).ready(function() {
249
            $('#merge-patrons').prop('disabled', true);
257
            $('#merge-patrons').prop('disabled', true);
250
            $('#memberresultst').on('change', 'input.selection', function() {
258
            $('#memberresultst').on('change', 'input.selection', function() {
259
                var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
260
                var borrowernumber = $(this).val();
261
                if( $(this).prop("checked") ){
262
                    patron_search_selections.push( $(this).val() );
263
                    localStorage.setItem('patron_search_selections', JSON.stringify( patron_search_selections ));
264
                    showPatronSelections( patron_search_selections.length );
265
                } else {
266
                    var filtered = patron_search_selections.filter(function( value ){
267
                        return value !== borrowernumber;
268
                    });
269
                    if( filtered.length > 0 ){
270
                        localStorage.setItem('patron_search_selections', JSON.stringify( filtered ));
271
                        showPatronSelections( filtered.length );
272
                    } else {
273
                        localStorage.removeItem('patron_search_selections');
274
                        $("#patron_search_selected").hide();
275
                    }
276
                }
251
                if ( $('.selection:checked').length > 1 ) {
277
                if ( $('.selection:checked').length > 1 ) {
252
                    /* More than one checkbox has been checked */
278
                    /* More than one checkbox has been checked */
253
                    $('#merge-patrons').prop('disabled', false).removeClass("disabled");
279
                    $('#merge-patrons').prop('disabled', false).removeClass("disabled");
Lines 264-280 Link Here
264
            });
290
            });
265
291
266
            $('#merge-patrons').on('click', function() {
292
            $('#merge-patrons').on('click', function() {
267
                var merge_patrons_url = 'merge-patrons.pl?' + $('.selection:checked')
293
                var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
268
                    .map(function() {
294
                var merge_patrons_url = 'merge-patrons.pl?id=' + patron_search_selections.join("&id=");
269
                       return "id=" + $(this).val()
270
                    }).get().join('&');
271
                window.location.href = merge_patrons_url;
295
                window.location.href = merge_patrons_url;
272
            });
296
            });
273
297
274
            $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){
298
            $("#clear-patron-selection").on("click", function(e){
275
                e.preventDefault();
299
                e.preventDefault();
300
                $(".selection").prop("checked", false).change();
301
                localStorage.removeItem("patron_search_selections");
302
                $("#patron_search_selected").hide();
303
            });
276
304
277
                if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
305
            $("#patronlist-dropdown").on("click", ".patron-list-add", function(e){
306
                e.preventDefault();
307
                var patron_search_selections = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
308
                if ( patron_search_selections.length == 0 ) {
278
                    alert( _("You have not selected any patrons to add to a list!") );
309
                    alert( _("You have not selected any patrons to add to a list!") );
279
                    $(".btn-group").removeClass("open"); /* Close button menu */
310
                    $(".btn-group").removeClass("open"); /* Close button menu */
280
                    return false;
311
                    return false;
Lines 496-501 Link Here
496
                        stickTo: "#searchresults",
527
                        stickTo: "#searchresults",
497
                        stickyClass: "floating"
528
                        stickyClass: "floating"
498
                    });
529
                    });
530
                },
531
                "drawCallback": function(){
532
                    prepSelections();
499
                }
533
                }
500
            }, columns_settings);
534
            }, columns_settings);
501
            update_searched();
535
            update_searched();
Lines 505-539 Link Here
505
        });
539
        });
506
540
507
        function patronListAdd(){
541
        function patronListAdd(){
508
            var borrowernumbers = [];
542
            var borrowernumbers = JSON.parse( localStorage.getItem("patron_search_selections") ) || [];
509
            $("#memberresultst").find("input:checkbox:checked").each(function(){
543
            if ( borrowernumbers.length > 0 ){
510
                borrowernumbers.push($(this).val());
544
                var data = {
511
            });
545
                    add_to_patron_list: $("#add_to_patron_list").val(),
512
            var data = {
546
                    new_patron_list: $("#new_patron_list").val(),
513
                add_to_patron_list: $("#add_to_patron_list").val(),
547
                    borrowernumbers: borrowernumbers
514
                new_patron_list: $("#new_patron_list").val(),
548
                };
515
                borrowernumbers: borrowernumbers
549
                $.ajax({
516
            };
550
                    data: data,
517
            $.ajax({
551
                    type: 'POST',
518
                data: data,
552
                    url: '/cgi-bin/koha/svc/members/add_to_list',
519
                type: 'POST',
553
                    success: function(data) {
520
                url: '/cgi-bin/koha/svc/members/add_to_list',
554
                        $("#patron_list_dialog").show();
521
                success: function(data) {
555
                        $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
522
                    $("#patron_list_dialog").show();
556
                        $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
523
                    $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
557
                        $("#patron_list_dialog > a").html(data.patron_list.name);
524
                    $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
558
525
                    $("#patron_list_dialog > a").html(data.patron_list.name);
559
                        if ( $('#add_to_patron_list').val() == 'new' ) {
526
560
                            /* Add a new entry to the menu */
527
                    if ( $('#add_to_patron_list').val() == 'new' ) {
561
                            $("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>');
528
                        /* Add a new entry to the menu */
562
                        }
529
                        $("#patronlist-dropdown .divider").before('<li><a class="patron-list-add" href="#" data-listid="' + data.patron_list.patron_list_id + '">' + data.patron_list.name + '</li>');
563
                    },
564
                    error: function() {
565
                        alert( _("An error occurred. Patron list could not be updated.") );
530
                    }
566
                    }
531
                },
567
                });
532
                error: function() {
568
                return true;
533
                    alert( _("An error occurred. Patron list could not be updated.") );
569
            } else {
570
                alert( _("You have not selected any patrons to add to a list!") );
571
                return false;
572
            }
573
        }
574
575
        function prepSelections(){
576
            var selected_patrons = JSON.parse( localStorage.getItem("patron_search_selections") );
577
            if( selected_patrons && selected_patrons.length > 0 ){
578
                showPatronSelections( selected_patrons.length );
579
580
                $('#merge-patrons').prop('disabled', true);
581
                $("input.selection").each(function(){
582
                    var cardnumber = $(this).val();
583
                    if( selected_patrons.indexOf( cardnumber ) >= 0 ){
584
                        $(this).prop("checked", true );
585
                    }
586
                });
587
588
                if( selected_patrons.length > 1 ){
589
                    $('#merge-patrons').removeClass("disabled").prop('disabled', false);
590
                    $('#patronlist-menu').removeClass("disabled").prop('disabled', false);
534
                }
591
                }
535
            });
592
            }
536
            return true;
537
        }
593
        }
538
594
539
        function getSearchByLocation( setstate ){
595
        function getSearchByLocation( setstate ){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt (-1 / +1 lines)
Lines 14-20 Link Here
14
            {
14
            {
15
                [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
15
                [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
16
                "dt_borrowernumber":
16
                "dt_borrowernumber":
17
                    "<label for='check[% data.borrowernumber | html %]' class='content_hidden'>Select patron</label><input type='checkbox' id='check[% data.borrowernumber | html %]' class='selection' name='borrowernumber' value='[% data.borrowernumber | html %]' />",
17
                    "<label for='check[% data.borrowernumber | html %]' class='content_hidden'>Select patron</label><input type='checkbox' id='check[% data.borrowernumber | html %]' data-cardnumber='[% data.cardnumber | html %]' class='selection' name='borrowernumber' value='[% data.borrowernumber | html %]' />",
18
                [% END %]
18
                [% END %]
19
                "dt_cardnumber":
19
                "dt_cardnumber":
20
                "[% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]<a href='/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% data.borrowernumber | html %]' title=\"[% I18N.t("Check out") | html %]\">[% data.cardnumber | html | $To %]</a>[% ELSE %][% data.cardnumber | html | $To %][% END %]",
20
                "[% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]<a href='/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% data.borrowernumber | html %]' title=\"[% I18N.t("Check out") | html %]\">[% data.cardnumber | html | $To %]</a>[% ELSE %][% data.cardnumber | html | $To %][% END %]",
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +1 lines)
Lines 205-210 function logOut(){ Link Here
205
    removeLastBorrower();
205
    removeLastBorrower();
206
    localStorage.removeItem("sql_reports_activetab");
206
    localStorage.removeItem("sql_reports_activetab");
207
    localStorage.removeItem("searches");
207
    localStorage.removeItem("searches");
208
    localStorage.removeItem("patron_search_selections");
208
}
209
}
209
210
210
function openHelp(){
211
function openHelp(){
211
- 

Return to bug 29971