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

Return to bug 12648