borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
borrowers.country, cardnumber, borrowers.dateexpiry,
borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
+ borrowers.userid,
categories.description AS category_description, categories.category_type,
branches.branchname";
my $from = "FROM borrowers
( $referer =~ m|acqui/basket.pl| )
? 1 : 0;
-if( $op eq "do_search" ) {
- my $results = C4::Members::Search( $q, "surname");
-
- my @users_loop;
- my $nresults = 0;
- foreach my $res (@$results) {
- my $should_be_returned = 1;
-
- if ( $search_patrons_with_acq_perm_only ) {
- $should_be_returned = 0;
- my $perms = haspermission( $res->{userid} );
- my $subperms = get_user_subpermissions( $res->{userid} );
-
- if( $perms->{superlibrarian} == 1
- || $perms->{acquisition} == 1
- || $subperms->{acquisition}->{'order_manage'} ) {
- $should_be_returned = 1;
- }
- }
- if ( $should_be_returned ) {
- my %row = (
- borrowernumber => $res->{borrowernumber},
- cardnumber => $res->{cardnumber},
- surname => $res->{surname},
- firstname => $res->{firstname},
- categorycode => $res->{categorycode},
- branchcode => $res->{branchcode},
- );
- push( @users_loop, \%row );
- $nresults ++;
- }
- }
-
- $template->param(
- q => $q,
- nresults => $nresults,
- users_loop => \@users_loop,
- );
-}
-
$template->param(
patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
);
aoData.push({
'name': 'template_path',
'value': 'acqui/tables/members_results.tt',
- });
+ }
+ [% IF patrons_with_acq_perm_only %]
+ ,{
+ 'name': 'has_permission',
+ 'value': 'acquisition.order_manage',
+ }
+ [% END %]
+ );
$.ajax({
'dataType': 'json',
'type': 'POST',
{ 'mDataProp': 'dt_action', 'bSortable': false }
],
'bAutoWidth': false,
- 'sPaginationType': 'full_numbers',
- "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
- "bProcessing": true,
+ [% IF patrons_with_acq_perm_only %]
+ 'bPaginate': false,
+ [% ELSE %]
+ 'sPaginationType': 'full_numbers',
+ "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
+ "bProcessing": true,
+ [% END %]
+ 'bProcessing': true,
}));
dtMemberResults.fnAddFilters("filter", 750);
});
use Modern::Perl;
use CGI;
-use C4::Auth qw( get_template_and_user );
+use C4::Auth qw( get_template_and_user haspermission get_user_subpermissions );
use C4::Output qw( output_with_http_headers );
use C4::Utils::DataTables qw( dt_get_params );
use C4::Utils::DataTables::Members qw( search );
my $branchcode = $input->param('branchcode');
my $searchtype = $input->param('searchtype');
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
+my $has_permission = $input->param('has_permission');
if ( $searchfieldstype eq "dateofbirth" ) {
$searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
searchtype => $searchtype,
searchfieldstype => $searchfieldstype,
dt_params => \%dt_params,
-
}
) unless $results;
+# It is not recommanded to use the has_permission param if you use the pagination
+# The filter is done AFTER requested the data
+if ($has_permission) {
+ my ( $permission, $subpermission ) = split /\./, $has_permission;
+ my @patrons_with_permission;
+ for my $patron ( @{ $results->{patrons} } ) {
+ my $perms = haspermission( $patron->{userid} );
+ if ( $perms->{superlibrarian} == 1
+ or $perms->{$permission} == 1 )
+ {
+ push @patrons_with_permission, $patron;
+ next;
+ }
+
+ if ($subpermission) {
+ my $subperms = get_user_subpermissions( $patron->{userid} );
+ push @patrons_with_permission, $patron
+ if $subperms->{$permission}->{$subpermission};
+ }
+ }
+ $results->{patrons} = \@patrons_with_permission;
+ $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
+}
+
$template->param(
sEcho => $sEcho,
iTotalRecords => $results->{iTotalRecords},