From 98ea8a08578f590d17120317f14447abe0edded6 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 | 54 +++----------- tools/notices.pl | 72 +++++++++---------- 2 files changed, 45 insertions(+), 81 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 8ae7fe0f48c..9f0e0d90d7d 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 %] › [% t("Tools") | html %] › @@ -50,9 +46,16 @@ <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.count == 0 %] + + <div class="page-section bg-info"> + No sent notices were found with those search parameters. + </div> + + [% ELSE %] - [% IF notices && notices.count > 0 %] <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> <form id="print_multiple" action="/cgi-bin/koha/tools/print_notice.pl" method="post" target="_blank"> @@ -92,30 +95,6 @@ </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> @@ -124,9 +103,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> @@ -248,7 +225,6 @@ [% INCLUDE 'datatables.inc' %] <script> - table_settings = [% TablesSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]; $(document).ready(function() { $("#notices").dataTable($.extend(true, {}, dataTablesDefaults, { "aoColumnDefs": [ @@ -273,13 +249,6 @@ $("#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){ var selected_notices = $("#print_multiple").find("input[name='message_ids']:checked"); if ( selected_notices.length == 0 ) { @@ -304,9 +273,6 @@ }); }); </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' %] diff --git a/tools/notices.pl b/tools/notices.pl index a241593636b..4e687ae2c37 100755 --- 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.47.1