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

(-)a/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss (-1 / +8 lines)
Lines 656-666 table { Link Here
656
            }
656
            }
657
        }
657
        }
658
658
659
        input {
659
        input,
660
        select {
660
            @extend .form-control;
661
            @extend .form-control;
661
            @extend .form-control-sm;
662
            @extend .form-control-sm;
662
663
663
            display: inline-block;
664
            display: inline-block;
665
            margin-left: 5px;
664
            width: auto;
666
            width: auto;
665
667
666
            &:focus {
668
            &:focus {
Lines 670-675 table { Link Here
670
    }
672
    }
671
}
673
}
672
674
675
.dataTables_info {
676
    font-size: 0.875rem;
677
    margin: 5px;
678
}
679
673
.table_entries {
680
.table_entries {
674
    color: #797979;
681
    color: #797979;
675
    font-size: 90%;
682
    font-size: 90%;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-46 / +60 lines)
Lines 338-373 Link Here
338
338
339
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
339
                            [% IF ( deleted ) %]<div class="alert alert-info">The selected suggestions have been deleted.</div>[% END %]
340
340
341
                            [% IF (Koha.Preference( 'OPACViewOthersSuggestions' ) || loggedinusername) && (suggestions.size > 0 OR title_filter) %]
342
                                [% SET can_delete_suggestion = 0 %]
343
                                <form action="/cgi-bin/koha/opac-suggestions.pl" class="row" id="search_suggestions_form" method="get">
344
                                        <div class="col-auto gx-2 ms-2 my-1">
345
                                            <label for="title_filter">Search for:</label>
346
                                        </div>
347
                                        <div class="col-auto gx-2 my-1">
348
                                            <input type="text" name="title_filter" id="title_filter" value="[% title_filter | html %]" size="30" class="form-control form-control-sm" />
349
                                        </div>
350
                                        [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) %]
351
                                            [% IF loggedinusername %]
352
                                                <div class="col-auto gx-2 my-1">
353
                                                    <label class="sr-only" for="suggested_by_anyone">Suggested by:</label>
354
                                                    <select class="form-select form-select-sm" name="suggested_by_anyone" id="suggested_by_anyone">
355
                                                        [% IF suggested_by_anyone %]
356
                                                            <option value="0">Suggested by me</option>
357
                                                            <option value="1" selected="selected">Suggested by anyone</option>
358
                                                        [% ELSE %]
359
                                                            <option value="0" selected="selected">Suggested by me</option>
360
                                                            <option value="1">Suggested by anyone</option>
361
                                                        [% END %]
362
                                                    </select>
363
                                                </div>
364
                                            [% END %]
365
                                        [% END %]
366
                                        <div class="col-auto gx-2 my-1">
367
                                            <button type="submit" class="btn btn-sm btn-primary">Go</button>
368
                                        </div>
369
                                </form>
370
                            [% END %]
371
                            [% IF suggestions.size > 0 %]
341
                            [% IF suggestions.size > 0 %]
372
                                [% SET can_delete_suggestion = 0 %]
342
                                [% SET can_delete_suggestion = 0 %]
373
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
343
                                <form action="/cgi-bin/koha/opac-suggestions.pl" method="post" id="delete_suggestions">
Lines 401-414 Link Here
401
371
402
                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 || loggedinusername %]
372
                                    [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 || loggedinusername %]
403
                                    <table id="suggestt" class="table table-bordered tabled">
373
                                    <table id="suggestt" class="table table-bordered tabled">
404
                                        <caption class="sr-only">Your purchase suggestions<caption>
374
                                        <caption class="sr-only">Your purchase suggestions</caption>
405
                                        <thead>
375
                                        <thead>
406
                                            <tr>
376
                                            <tr>
407
                                                [% IF ( loggedinusername ) %]<th>&nbsp;</th>[% END %]
377
                                                [% IF ( loggedinusername ) %]<th class="NoSort">&nbsp;</th>[% END %]
408
                                                <th class="all">Summary</th>
378
                                                <th class="all">Summary</th>
409
                                                <th>Suggested on</th>
379
                                                <th>Suggested on</th>
410
                                                <th>Note</th>
380
                                                <th>Note</th>
411
                                                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]<th>Suggested for</th>[% END %]
381
                                                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]
382
                                                    <th>Suggested for</th>
383
                                                    <th class="hidden"></th>
384
                                                [% END %]
412
                                                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
385
                                                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]<th>Managed by</th>[% END %]
413
                                                <th>Status</th>
386
                                                <th>Status</th>
414
                                                <th></th>
387
                                                <th></th>
Lines 425-431 Link Here
425
                                                            [% END %]
398
                                                            [% END %]
426
                                                        </td>
399
                                                        </td>
427
                                                    [% END %]
400
                                                    [% END %]
428
                                                    <td>
401
                                                    <td class="anti-the">
429
                                                        <p>
402
                                                        <p>
430
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
403
                                                            <label for="id[% suggestions_loo.suggestionid | html %]">
431
                                                                [% IF suggestion.biblionumber %]
404
                                                                [% IF suggestion.biblionumber %]
Lines 459-464 Link Here
459
                                                                [% Branches.GetName(suggestion.branchcode) | html %]
432
                                                                [% Branches.GetName(suggestion.branchcode) | html %]
460
                                                            [% END %]
433
                                                            [% END %]
461
                                                        </td>
434
                                                        </td>
435
                                                        <td>
436
                                                            [% IF logged_in_user.borrowernumber == suggestion.suggester.borrowernumber %]
437
                                                                1
438
                                                            [% ELSE %]
439
                                                                0
440
                                                            [% END %]
441
                                                        </td>
462
                                                    [% END %]
442
                                                    [% END %]
463
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
443
                                                    [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]
464
                                                    <td>
444
                                                    <td>
Lines 567-597 Link Here
567
    [% END %]
547
    [% END %]
568
548
569
    $(function() {
549
    $(function() {
570
        $("#suggestt").dataTable($.extend(true, {}, dataTablesDefaults, {
550
        dataTablesDefaults.buttons.splice(1,3); // Remove copy, print, csv from button set
551
        var suggestions_table = $("#suggestt").DataTable($.extend(true, {}, dataTablesDefaults, {
571
            "order": [[ 1, "asc" ]],
552
            "order": [[ 1, "asc" ]],
572
            "autoWidth": false,
553
            "autoWidth": false,
554
            "dom": '<"top"<"table_entries"i><"table_controls"fB>>t',
573
            "columnDefs": [
555
            "columnDefs": [
574
              [% IF ( loggedinusername ) %]{ "targets": [ 0 ], "sortable": false, "searchable": false }[% END %],
556
                { "targets": ["NoSort"], "sortable": false, "searchable": false },
557
                { "visible": false, "targets" : [ "hidden" ] },
575
                { "className": 'dtr-control', "orderable": false, "targets": -1 },
558
                { "className": 'dtr-control', "orderable": false, "targets": -1 },
559
                { "type": "anti-the", "targets" : [ "anti-the" ] },
576
                { responsivePriority: 1, targets: 1 }
560
                { responsivePriority: 1, targets: 1 }
577
            ],
561
            ],
578
            "columns": [
562
            "language": {
579
                [% IF ( loggedinusername ) %]null,[% END %]
563
                "search": "_INPUT_",
580
                { "type": "anti-the" },
564
                "searchPlaceholder": _("Search")
581
                null,
565
            },
582
                null,
583
                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 %]null,[% END %]
584
                [% IF Koha.Preference( 'OpacSuggestionManagedBy' ) %]null,[% END %]
585
                null,
586
                null
587
            ],
588
            "responsive": {
566
            "responsive": {
589
                details: {
567
                details: {
590
                    type: 'column',
568
                    type: 'column',
591
                    target: -1
569
                    target: -1
592
                }
570
                }
593
            },
571
            },
572
            initComplete: function (settings, json) {
573
                var tableId = settings.nTable.id;
574
                [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 && loggedinusername %]
575
                    // Add select filter
576
                    $('#suggestt_filter').append('<label for="suggested_by_user" class="sr-only">Filter:</label>').append('<select class="form-control form-control-sm" name="suggested_by_user" id="suggested_by_user"><option value="1" selected="selected">Suggested by me</option><option value="0">Suggested by anyone</option></select>');
577
                    // Filter results on select change
578
                    let suggested_by_user = $("#suggested_by_user");
579
                    suggested_by_user.on('change', function () {
580
                        suggestions_table.columns(5).search($(this).val()).draw();
581
                    });
582
                    $("body").on( 'search.dt', "#" + tableId, function ( e, settings ) {
583
                        if( settings.oPreviousSearch.sSearch == "" && suggested_by_user.val() == "1" ){
584
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled");
585
                        } else {
586
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
587
                        }
588
                    });
589
                [% ELSE %]
590
                    $("body").on( 'search.dt', "#" + tableId, function ( e, settings ) {
591
                        if( settings.oPreviousSearch.sSearch == "" ){
592
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled");
593
                        } else {
594
                            $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled");
595
                        }
596
                    });
597
                [% END %]
598
            }
594
        }));
599
        }));
600
        $("#usersuggestions").on("click", ".dt_button_clear_filter",function(){
601
            suggestions_table.search("").columns().search("").draw();
602
            $("#suggested_by_user").val(1).change();
603
            $(this).addClass("disabled");
604
        });
605
        [% IF Koha.Preference( 'OPACViewOthersSuggestions' ) == 1 && loggedinusername %]
606
            suggestions_table.columns(5).search( 1 ).draw();
607
        [% END %]
608
595
        [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
609
        [% IF ( loggedinusername ) %]$("span.clearall").html("<a id=\"CheckNone\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Clear all")+"<\/a>");
596
        $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
610
        $("span.checkall").html("<a id=\"CheckAll\" class=\"btn btn-link btn-sm\" href=\"#\">"+_("Select all")+"<\/a>");
597
        $("#CheckAll").on("click",function(e){
611
        $("#CheckAll").on("click",function(e){
(-)a/opac/opac-suggestions.pl (-9 / +2 lines)
Lines 105-114 my $suggested_by; Link Here
105
if ( $op eq 'else' ) {
105
if ( $op eq 'else' ) {
106
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
106
    if ( C4::Context->preference("OPACViewOthersSuggestions") ) {
107
        if ( $borrowernumber ) {
107
        if ( $borrowernumber ) {
108
            # A logged in user is able to see suggestions from others
108
            $suggested_by = undef;
109
            $suggested_by = $suggested_by_anyone
110
                ? undef
111
                : $borrowernumber;
112
        }
109
        }
113
        # else: Non logged in user is able to see all suggestions
110
        # else: Non logged in user is able to see all suggestions
114
    }
111
    }
Lines 136-142 $suggestion = { Link Here
136
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
133
        ( defined $p && $p ne '' ? ( $_ => $p ) : () )
137
    } keys %$suggestion
134
    } keys %$suggestion
138
};
135
};
139
$suggestion->{suggestedby} = $borrowernumber;
136
$suggestion->{suggestedby} = $suggested_by;
140
137
141
if ( $op eq "cud-add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates
138
if ( $op eq "cud-add_validate" && not $biblionumber ) { # If we are creating the suggestion from an existing record we do not want to search for duplicates
142
    $op = 'cud-add_confirm';
139
    $op = 'cud-add_confirm';
Lines 226-234 my $suggestions = [ Koha::Suggestions->search_limited( Link Here
226
        $suggestion->{suggestedby}
223
        $suggestion->{suggestedby}
227
        ? ( suggestedby => $suggestion->{suggestedby} )
224
        ? ( suggestedby => $suggestion->{suggestedby} )
228
        : (),
225
        : (),
229
        $title_filter
230
        ? ( title       => $title_filter )
231
        : (),
232
    }
226
    }
233
)->as_list ];
227
)->as_list ];
234
228
235
- 

Return to bug 36045