From 8d3ee81b149be67c14a2e560da9e50e0fbb806b3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 23 Mar 2015 10:43:11 +0100 Subject: [PATCH] Bug 13891: DataTables server-side processing - Fix regressions This patch fixes the regressions introduced by the previous patches. If you have tested all in once, you didn't see them. It introduces library, category and "first letter" filters. Test plan: 1/ On all pages impacted by previous patches + new order empty (link patron to an order) + guarantor search 2/ Add / Select patron to the list 3/ Use the filters 4/ Confirm there is no regression Tested together with other patches. Signed-off-by: Marc Veron Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- acqui/add_user_search.pl | 8 ++ admin/add_user_search.pl | 8 ++ .../prog/en/modules/common/patron_search.tt | 88 ++++++++++++++----- members/guarantor_search.pl | 8 ++ patroncards/add_user_search.pl | 16 +++- serials/add_user_search.pl | 8 ++ 6 files changed, 108 insertions(+), 28 deletions(-) diff --git a/acqui/add_user_search.pl b/acqui/add_user_search.pl index e86b0e498f..7b8b9697fc 100755 --- a/acqui/add_user_search.pl +++ b/acqui/add_user_search.pl @@ -21,6 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; +use C4::Branch qw( GetBranches ); +use C4::Category; use C4::Output; use C4::Members; @@ -49,11 +51,17 @@ my $search_patrons_with_acq_perm_only = ( $referer =~ m|acqui/basket.pl| ) ? 1 : 0; +my $onlymine = C4::Branch::onlymine; +my $branches = C4::Branch::GetBranches( $onlymine ); + $template->param( patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only, view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", columns => ['cardnumber', 'name', 'branch', 'category', 'action'], json_template => 'acqui/tables/members_results.tt', selection_type => 'add', + alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), + categories => [ C4::Category->all ], + branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ], ); output_html_with_http_headers( $input, $cookie, $template->output ); diff --git a/admin/add_user_search.pl b/admin/add_user_search.pl index 33fb6ac930..bafc9e1561 100755 --- a/admin/add_user_search.pl +++ b/admin/add_user_search.pl @@ -21,6 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; +use C4::Branch qw( GetBranches ); +use C4::Category; use C4::Output; use C4::Members; @@ -50,11 +52,17 @@ my $search_patrons_with_acq_perm_only = ( $referer =~ m|admin/aqbudgets.pl| ) ? 1 : 0; +my $onlymine = C4::Branch::onlymine; +my $branches = C4::Branch::GetBranches( $onlymine ); + $template->param( patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only, view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", columns => ['cardnumber', 'name', 'branch', 'category', 'action'], json_template => 'acqui/tables/members_results.tt', selection_type => $selection_type, + alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), + categories => [ C4::Category->all ], + branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ], ); output_html_with_http_headers( $input, $cookie, $template->output ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt index e182688b58..b65d3f8e35 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt @@ -18,9 +18,6 @@ $(document).ready(function(){ search = 0; [% END %] - $("#searchmember_filter").on('keyup', function(){ - filter(); - }); // Apply DataTables on the results table dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, { 'bServerSide': true, @@ -32,6 +29,15 @@ $(document).ready(function(){ aoData.push({ 'name': 'searchmember', 'value': $("#searchmember_filter").val() + },{ + 'name': 'firstletter', + 'value': $("#firstletter_filter").val() + },{ + 'name': 'categorycode', + 'value': $("#categorycode_filter").val() + },{ + 'name': 'branchcode', + 'value': $("#branchcode_filter").val() },{ 'name': 'name_sorton', 'value': 'borrowers.surname borrowers.firstname' @@ -87,31 +93,27 @@ $(document).ready(function(){ 'bFilter': false, 'bProcessing': true, })); - dtMemberResults.fnAddFilters("filter", 750); -}); -var delay = (function(){ - var timer = 0; - return function(callback, ms){ - clearTimeout (timer); - timer = setTimeout(callback, ms); - }; -})(); + $("#searchform").on('submit', filter); +}); function filter() { search = 1; - + $("#firstletter_filter").val(''); $("#searchresults").show(); - - if ( $("#searchmember_filter").val().length > 0 ) { - delay(function(){ - dtMemberResults.fnDraw(); - }, 1000); - } - + dtMemberResults.fnDraw(); return false; } +// User has clicked on a letter +function filterByFirstLetterSurname(letter) { + $("#firstletter_filter").val(letter); + search = 1; + $("#searchresults").show(); + dtMemberResults.fnDraw(); +} + + // modify parent window owner element [% IF selection_type == 'add' %] function add_user(borrowernumber, borrowername) { @@ -152,18 +154,56 @@ function filter() {
-

Search for patron

- - - +
+
+

Search for patron

+
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
+
+ +
+
+ [% IF patrons_with_acq_perm_only %]
Only staff with superlibrarian or acquisitions permissions (or order_manage permission if granular permissions are enabled) are returned in the search results
[% END %] +
+ Browse by last name: + [% FOREACH letter IN alphabet.split(' ') %] + [% letter %] + [% END %] +
+
+
diff --git a/members/guarantor_search.pl b/members/guarantor_search.pl index 6e4e6ab282..ac9d1ceac3 100755 --- a/members/guarantor_search.pl +++ b/members/guarantor_search.pl @@ -21,6 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; +use C4::Branch qw( GetBranches ); +use C4::Category; use C4::Output; use C4::Members; @@ -42,10 +44,16 @@ my $op = $input->param('op') || ''; my $referer = $input->referer(); +my $onlymine = C4::Branch::onlymine; +my $branches = C4::Branch::GetBranches( $onlymine ); + $template->param( view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", columns => ['cardnumber', 'name', 'dateofbirth', 'address', 'action' ], json_template => 'members/tables/guarantor_search.tt', selection_type => 'select', + alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), + categories => [ C4::Category->all ], + branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ], ); output_html_with_http_headers( $input, $cookie, $template->output ); diff --git a/patroncards/add_user_search.pl b/patroncards/add_user_search.pl index 2953dcf39e..bc860766ea 100755 --- a/patroncards/add_user_search.pl +++ b/patroncards/add_user_search.pl @@ -21,6 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; +use C4::Branch qw( GetBranches ); +use C4::Category; use C4::Output; use C4::Members; @@ -42,10 +44,16 @@ my $op = $input->param('op') || ''; my $referer = $input->referer(); +my $onlymine = C4::Branch::onlymine; +my $branches = C4::Branch::GetBranches( $onlymine ); + $template->param( - view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", - columns => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'], - json_template => 'patroncards/tables/members_results.tt', - selection_type => 'add', + view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", + columns => ['cardnumber', 'name', 'category', 'branch', 'dateexpiry', 'borrowernotes', 'action'], + json_template => 'patroncards/tables/members_results.tt', + selection_type => 'add', + alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), + categories => [ C4::Category->all ], + branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ], ); output_html_with_http_headers( $input, $cookie, $template->output ); diff --git a/serials/add_user_search.pl b/serials/add_user_search.pl index 50d63bd585..8fc15af128 100755 --- a/serials/add_user_search.pl +++ b/serials/add_user_search.pl @@ -21,6 +21,8 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth; +use C4::Branch qw( GetBranches ); +use C4::Category; use C4::Output; use C4::Members; @@ -42,10 +44,16 @@ my $op = $input->param('op') || ''; my $referer = $input->referer(); +my $onlymine = C4::Branch::onlymine; +my $branches = C4::Branch::GetBranches( $onlymine ); + $template->param( view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", columns => ['cardnumber', 'name', 'branch', 'action'], json_template => 'serials/tables/members_results.tt', selection_type => 'add', + alphabet => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ), + categories => [ C4::Category->all ], + branches => [ map { { branchcode => $_->{branchcode}, branchname => $_->{branchname} } } values %$branches ], ); output_html_with_http_headers( $input, $cookie, $template->output ); -- 2.20.1