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

(-)a/C4/Utils/DataTables/Members.pm (+1 lines)
Lines 37-42 sub search { Link Here
37
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
37
        borrowers.address2, borrowers.city, borrowers.state, borrowers.zipcode,
38
        borrowers.country, cardnumber, borrowers.dateexpiry,
38
        borrowers.country, cardnumber, borrowers.dateexpiry,
39
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
39
        borrowers.borrowernotes, borrowers.branchcode, borrowers.email,
40
        borrowers.userid,
40
        categories.description AS category_description, categories.category_type,
41
        categories.description AS category_description, categories.category_type,
41
        branches.branchname";
42
        branches.branchname";
42
    my $from = "FROM borrowers
43
    my $from = "FROM borrowers
(-)a/acqui/add_user_search.pl (-40 lines)
Lines 49-94 my $search_patrons_with_acq_perm_only = Link Here
49
    ( $referer =~ m|acqui/basket.pl| )
49
    ( $referer =~ m|acqui/basket.pl| )
50
        ? 1 : 0;
50
        ? 1 : 0;
51
51
52
if( $op eq "do_search" ) {
53
    my $results = C4::Members::Search( $q, "surname");
54
55
    my @users_loop;
56
    my $nresults = 0;
57
    foreach my $res (@$results) {
58
        my $should_be_returned = 1;
59
60
        if ( $search_patrons_with_acq_perm_only ) {
61
            $should_be_returned = 0;
62
            my $perms = haspermission( $res->{userid} );
63
            my $subperms = get_user_subpermissions( $res->{userid} );
64
65
            if( $perms->{superlibrarian} == 1
66
             || $perms->{acquisition} == 1
67
             || $subperms->{acquisition}->{'order_manage'} ) {
68
                $should_be_returned = 1;
69
            }
70
        }
71
        if ( $should_be_returned ) {
72
            my %row = (
73
                borrowernumber  => $res->{borrowernumber},
74
                cardnumber      => $res->{cardnumber},
75
                surname         => $res->{surname},
76
                firstname       => $res->{firstname},
77
                categorycode    => $res->{categorycode},
78
                branchcode      => $res->{branchcode},
79
            );
80
            push( @users_loop, \%row );
81
            $nresults ++;
82
        }
83
    }
84
85
    $template->param(
86
        q           => $q,
87
        nresults    => $nresults,
88
        users_loop  => \@users_loop,
89
    );
90
}
91
92
$template->param(
52
$template->param(
93
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
53
    patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only,
94
);
54
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/add_user_search.tt (-4 / +16 lines)
Lines 19-25 $(document).ready(function(){ Link Here
19
            aoData.push({
19
            aoData.push({
20
                'name': 'template_path',
20
                'name': 'template_path',
21
                'value': 'acqui/tables/members_results.tt',
21
                'value': 'acqui/tables/members_results.tt',
22
            });
22
            }
23
            [% IF patrons_with_acq_perm_only %]
24
            ,{
25
                'name': 'has_permission',
26
                'value': 'acquisition.order_manage',
27
            }
28
            [% END %]
29
            );
23
            $.ajax({
30
            $.ajax({
24
                'dataType': 'json',
31
                'dataType': 'json',
25
                'type': 'POST',
32
                'type': 'POST',
Lines 38-46 $(document).ready(function(){ Link Here
38
            { 'mDataProp': 'dt_action', 'bSortable': false }
45
            { 'mDataProp': 'dt_action', 'bSortable': false }
39
        ],
46
        ],
40
        'bAutoWidth': false,
47
        'bAutoWidth': false,
41
        'sPaginationType': 'full_numbers',
48
        [% IF patrons_with_acq_perm_only %]
42
        "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
49
            'bPaginate': false,
43
        "bProcessing": true,
50
        [% ELSE %]
51
            'sPaginationType': 'full_numbers',
52
            "iDisplayLength": [% Koha.Preference('PatronsPerPage') %],
53
            "bProcessing": true,
54
        [% END %]
55
        'bProcessing': true,
44
    }));
56
    }));
45
    dtMemberResults.fnAddFilters("filter", 750);
57
    dtMemberResults.fnAddFilters("filter", 750);
46
});
58
});
(-)a/svc/members/search (-3 / +26 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use CGI;
21
use CGI;
22
22
23
use C4::Auth qw( get_template_and_user );
23
use C4::Auth qw( get_template_and_user haspermission get_user_subpermissions );
24
use C4::Output qw( output_with_http_headers );
24
use C4::Output qw( output_with_http_headers );
25
use C4::Utils::DataTables qw( dt_get_params );
25
use C4::Utils::DataTables qw( dt_get_params );
26
use C4::Utils::DataTables::Members qw( search );
26
use C4::Utils::DataTables::Members qw( search );
Lines 44-49 my $categorycode = $input->param('categorycode'); Link Here
44
my $branchcode = $input->param('branchcode');
44
my $branchcode = $input->param('branchcode');
45
my $searchtype = $input->param('searchtype');
45
my $searchtype = $input->param('searchtype');
46
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
46
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
47
my $has_permission = $input->param('has_permission');
47
48
48
if ( $searchfieldstype eq "dateofbirth" ) {
49
if ( $searchfieldstype eq "dateofbirth" ) {
49
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
50
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
Lines 82-91 $results = C4::Utils::DataTables::Members::search( Link Here
82
        searchtype => $searchtype,
83
        searchtype => $searchtype,
83
        searchfieldstype => $searchfieldstype,
84
        searchfieldstype => $searchfieldstype,
84
        dt_params => \%dt_params,
85
        dt_params => \%dt_params,
85
86
    }
86
    }
87
) unless $results;
87
) unless $results;
88
88
89
# It is not recommanded to use the has_permission param if you use the pagination
90
# The filter is done AFTER requested the data
91
if ($has_permission) {
92
    my ( $permission, $subpermission ) = split /\./, $has_permission;
93
    my @patrons_with_permission;
94
    for my $patron ( @{ $results->{patrons} } ) {
95
        my $perms = haspermission( $patron->{userid} );
96
        if (   $perms->{superlibrarian} == 1
97
            or $perms->{$permission} == 1 )
98
        {
99
            push @patrons_with_permission, $patron;
100
            next;
101
        }
102
103
        if ($subpermission) {
104
            my $subperms = get_user_subpermissions( $patron->{userid} );
105
            push @patrons_with_permission, $patron
106
              if $subperms->{$permission}->{$subpermission};
107
        }
108
    }
109
    $results->{patrons} = \@patrons_with_permission;
110
    $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
111
}
112
89
$template->param(
113
$template->param(
90
    sEcho => $sEcho,
114
    sEcho => $sEcho,
91
    iTotalRecords => $results->{iTotalRecords},
115
    iTotalRecords => $results->{iTotalRecords},
92
- 

Return to bug 12648