From ecf1ac62c6903605c82dca65b162db52bcd4c4c3 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 1 Oct 2024 09:24:23 +0100 Subject: [PATCH] Bug 33260: (follow-up) Remove patron search as primary action This is a 'Notices' display tool, it doesn't make sense to me to replicate the 'Patrons' search interface as the primary action of the tool. --- .../prog/en/modules/tools/notices.tt | 80 ++++++------------- tools/notices.pl | 72 ++++++++--------- 2 files changed, 59 insertions(+), 93 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt index 21341917d96..e8a5fc8e6bd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/notices.tt @@ -7,10 +7,6 @@ [% PROCESS 'i18n.inc' %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] -[% PROCESS "patron-search.inc" %] -[% SET libraries = Branches.all %] -[% SET categories = Categories.all.unblessed %] -[% SET columns = ['name', 'cardnumber', 'dateofbirth', 'category', 'branch', 'address', 'phone'] %] [% FILTER collapse %] [% t("Notices management") | html %] @@ -51,9 +47,11 @@ <h1>Notices management</h1> - <div class="dialog message">Printing a notice will mark it as sent.</div> + <div class="page-section bg-warning">Printing a notice will mark it as sent.</div> - [% IF notices && notices.count > 0 %] + [% IF notices.count == 0 %] + <div class="page-section bg-info"> No sent notices were found with those search parameters. </div> + [% ELSE %] <div class="page-section"> <span id="checkbox_actions" ><a href="#" class="select_all"><i class="fa fa-check"></i> Select all</a> | <a href="#" class="clear_all"><i class="fa fa-remove"></i> Clear all</a></span @@ -101,23 +99,6 @@ <input type="submit" class="btn btn-primary" value="Print selected notices" id="print_multiple_button" /> </form> </div> - [% ELSE %] - Use the search form on the left to find sent notices, or go directly to a patron's notices. - [% WRAPPER tabs id= "notices_patronsearch" %] - [% WRAPPER tabs_nav %] - [% WRAPPER tab_item tabname= "notices_patronsearch_pane" bt_active= 1 %]<span>Patrons</span>[% END %] - [% END %] - [% WRAPPER tab_panels %] - [% WRAPPER tab_panel tabname="notices_patronsearch_pane" bt_active= 1 %] - [% PROCESS patron_search_filters_simple %] - [% PROCESS patron_search_table table_id => 'table_borrowers', open_on_row_click => 1 %] - [% END %] - [% END %] - [% END %] - - [% IF notices && notices.count == 0 %] - <div class="dialog message"> No sent notices were found with those search parameters. </div> - [% END %] [% END %] </main> </div> @@ -126,9 +107,7 @@ <div class="col-md-2 order-md-1 order-sm-1"> <aside> <fieldset class="sidebar brief"> - <form id="notices-search" action="/cgi-bin/koha/tools/notices.pl" method="post"> - [% INCLUDE 'csrf-token.inc' %] - <input type="hidden" name="op" value="cud-search" /> + <form id="notices-search" action="/cgi-bin/koha/tools/notices.pl" method="get"> <h3>Search filters</h3> <ol> <li> @@ -252,65 +231,54 @@ [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] <script> - table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]; - $(document).ready(function() { - $("#notices").dataTable($.extend(true, {}, dataTablesDefaults, { - "aoColumnDefs": [ - { 'bSortable': false, 'aTargets': [ 'nosort' ] } - ], - "aaSorting": [[1, "desc" ]], - "sPaginationType": "full" - })); + $(document).ready(function () { + $("#notices").dataTable( + $.extend(true, {}, dataTablesDefaults, { + aoColumnDefs: [{ bSortable: false, aTargets: ["nosort"] }], + aaSorting: [[1, "desc"]], + sPaginationType: "full", + }) + ); - $("#notices").on("click", ".notice-title", function(e){ + $("#notices").on("click", ".notice-title", function (e) { e.preventDefault(); var title = $(this).text(); var noticeid = $(this).data("noticeid"); - var body = $("#notice" + noticeid ).attr("srcdoc"); - $("#noticeModalLabel").text( title ); - $("#noticeModal .modal-body").html( body ); + var body = $("#notice" + noticeid).attr("srcdoc"); + $("#noticeModalLabel").text(title); + $("#noticeModal .modal-body").html(body); $("#noticeModal").modal("show"); }); - $("#noticeModal").on("hide.bs.modal", function(){ + $("#noticeModal").on("hide.bs.modal", function () { $("#noticeModalLabel").text(""); $("#noticeModal .modal-body").html(""); }); - $("#notices_patronsearch").on("submit", filter); - [% UNLESS notices %] - [% IF ( Koha.Preference('PatronAutoComplete') ) %] - patron_autocomplete($(".search_patron_filter"), { 'link-to': 'notices' }); - [% END %] - [% END %] - - $("#print_multiple_button").click(function(e){ + $("#print_multiple_button").click(function (e) { var selected_notices = $("#print_multiple").find("input[name='message_ids']:checked"); - if ( selected_notices.length == 0 ) { + if (selected_notices.length == 0) { alert(_("Please select at least one sent notice.")); e.preventDefault(); return false; } }); - $(".select_all").click(function(e){ + $(".select_all").click(function (e) { e.preventDefault(); - $("input[name='message_ids']").each(function(){ + $("input[name='message_ids']").each(function () { $(this).prop("checked", true); }); }); - $(".clear_all").click(function(e){ + $(".clear_all").click(function (e) { e.preventDefault(); - $("input[name='message_ids']").each(function(){ + $("input[name='message_ids']").each(function () { $(this).prop("checked", false); }); }); }); </script> - [% SET search_results_block_id = 'notices_patronsearch_pane_panel' %] - [%# adjusting variable for patron-search.inc %] - [% PROCESS patron_search_js table_id => 'table_borrowers', categories => categories, libraries => libraries, columns => columns, open_on_row_click => 1, on_click_url => '/cgi-bin/koha/members/notices.pl?', redirect_if_one_result => 1, redirect_url => '/cgi-bin/koha/members/notices.pl?', redirect_if_attribute_equal => 'cardnumber' %] [% END %] [% INCLUDE 'intranet-bottom.inc' %]</div diff --git a/tools/notices.pl b/tools/notices.pl index a241593636b..4e687ae2c37 100644 --- a/tools/notices.pl +++ b/tools/notices.pl @@ -39,47 +39,45 @@ unless ( C4::Context->preference('NoticesManagement') ) { my $op = $query->param('op'); -if ( $op and $op eq 'cud-search' ) { - my $letter_code = $query->param('letter_code') || undef; - my $categorycode = $query->param('categorycode') || undef; - my $branchcode = $query->param('branchcode') || undef; - my $from = $query->param('from') || undef; - my $to = $query->param('to') || undef; - my $status = $query->param('status') || undef; +my $letter_code = $query->param('letter_code') || undef; +my $categorycode = $query->param('categorycode') || undef; +my $branchcode = $query->param('branchcode') || undef; +my $from = $query->param('from') || undef; +my $to = $query->param('to') || undef; +my $status = $query->param('status') || undef; - my %where = (); - $where{'me.letter_code'} = $letter_code if ($letter_code); - $where{'borrowernumber.categorycode'} = $categorycode if ($categorycode); - $where{'borrowernumber.branchcode'} = $branchcode if ($branchcode); - if ($from) { - if ($to) { - $where{'me.time_queued'} = [ - -and => { '<=', $to }, - { '>=', $from } - ]; - } else { - $where{'me.time_queued'} = { '>=', $from }; - } - } elsif ($to) { - $where{'me.time_queued'} = { '<=', $to }; +my %where = (); +$where{'me.letter_code'} = $letter_code if ($letter_code); +$where{'borrowernumber.categorycode'} = $categorycode if ($categorycode); +$where{'borrowernumber.branchcode'} = $branchcode if ($branchcode); +if ($from) { + if ($to) { + $where{'me.time_queued'} = [ + -and => { '<=', $to }, + { '>=', $from } + ]; + } else { + $where{'me.time_queued'} = { '>=', $from }; } - $where{'me.status'} = $status if ($status); +} elsif ($to) { + $where{'me.time_queued'} = { '<=', $to }; +} +$where{'me.status'} = $status if ($status); - my $notices = Koha::Notice::Messages->search_limited( - {%where}, - { order_by => { -desc => 'time_queued' } } - ); +my $notices = Koha::Notice::Messages->search_limited( + {%where}, + { order_by => { -desc => 'time_queued' } } +); - $template->param( - notices => $notices, - letter_code => $letter_code, - categorycode => $categorycode, - branchcode => $branchcode, - from => $from, - to => $to, - status => $status, - ); -} +$template->param( + notices => $notices, + letter_code => $letter_code, + categorycode => $categorycode, + branchcode => $branchcode, + from => $from, + to => $to, + status => $status, +); $template->param( letters => Koha::Notice::Templates->search( -- 2.48.1