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 77-86 $results = C4::Utils::DataTables::Members::search( Link Here
77
        searchtype => $searchtype,
78
        searchtype => $searchtype,
78
        searchfieldstype => $searchfieldstype,
79
        searchfieldstype => $searchfieldstype,
79
        dt_params => \%dt_params,
80
        dt_params => \%dt_params,
80
81
    }
81
    }
82
) unless $results;
82
) unless $results;
83
83
84
# It is not recommanded to use the has_permission param if you use the pagination
85
# The filter is done AFTER requested the data
86
if ($has_permission) {
87
    my ( $permission, $subpermission ) = split /\./, $has_permission;
88
    my @patrons_with_permission;
89
    for my $patron ( @{ $results->{patrons} } ) {
90
        my $perms = haspermission( $patron->{userid} );
91
        if (   $perms->{superlibrarian} == 1
92
            or $perms->{$permission} == 1 )
93
        {
94
            push @patrons_with_permission, $patron;
95
            next;
96
        }
97
98
        if ($subpermission) {
99
            my $subperms = get_user_subpermissions( $patron->{userid} );
100
            push @patrons_with_permission, $patron
101
              if $subperms->{$permission}->{$subpermission};
102
        }
103
    }
104
    $results->{patrons} = \@patrons_with_permission;
105
    $results->{iTotalDisplayRecords} = scalar( @patrons_with_permission );
106
}
107
84
$template->param(
108
$template->param(
85
    sEcho => $sEcho,
109
    sEcho => $sEcho,
86
    iTotalRecords => $results->{iTotalRecords},
110
    iTotalRecords => $results->{iTotalRecords},
87
- 

Return to bug 12648