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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt (-44 lines)
Lines 1-44 Link Here
1
[% USE raw %]
2
[% USE I18N %]
3
[% USE To %]
4
[% USE AuthorisedValues %]
5
[% USE KohaDates %]
6
[% USE Price %]
7
[% PROCESS 'member-display-address-style.inc' %]
8
{
9
    "sEcho": [% sEcho | html %],
10
    "iTotalRecords": [% iTotalRecords | html %],
11
    "iTotalDisplayRecords": [% iTotalDisplayRecords | html %],
12
    "aaData": [
13
        [% FOREACH data IN aaData %]
14
            {
15
                [% IF CAN_user_borrowers_edit_borrowers || CAN_user_tools_manage_patron_lists %]
16
                "dt_borrowernumber":
17
                    "<label for='check[% data.borrowernumber | html %]' class='content_hidden'>Select patron</label><input type='checkbox' id='check[% data.borrowernumber | html %]' class='selection' name='borrowernumber' value='[% data.borrowernumber | html %]' />",
18
                [% END %]
19
                "dt_cardnumber":
20
                "[% IF ( CAN_user_circulate_circulate_remaining_permissions ) %]<a href='/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% data.borrowernumber | html %]' title=\"[% I18N.t("Check out") | html %]\">[% data.cardnumber | html | $To %]</a>[% ELSE %][% data.cardnumber | html | $To %][% END %]",
21
                "dt_name":
22
                    "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber | html %]\" class=\"patron_preview\" data-borrowernumber=\"[% data.borrowernumber | html %]\" style='white-space:nowrap' title=\"[% I18N.t("View") | html %]\">[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = data.firstname surname = data.surname othernames = data.othernames invert_name = 1 | $To %]</a><br /><div class='address'><ul>[%~ INCLUDE 'display-address-style' patron=data no_line_break=1 | $To ~%][% IF data.email %]<li>Email: <a href='mailto:[% data.email | html | $To %]'>[% data.email | html | $To %]</a></li>[% END %]</ul></div>",
23
    "dt_dateofbirth":
24
        "[% INCLUDE 'patron-age.inc' patron = data %]",
25
                "dt_category":
26
                    "[% data.category_description | html | $To %] <span class=\"patron_category_type\">([% data.category_type | html | $To %])</span>",
27
                "dt_branch":
28
                    "[% data.branchname | html | $To %]",
29
                "dt_dateexpiry":
30
                    "[% data.dateexpiry | html | $To %]",
31
                "dt_od_checkouts":
32
                    "[% IF data.overdues %]<span class='overdue'><strong>[% data.overdues | html %]</strong></span>[% ELSE %][% data.overdues | html %][% END %] / [% data.issues | html %]",
33
                "dt_fines":
34
                    "<span style='text-align: right; display: block;'><a href=\"/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% data.borrowernumber | html %]\">[% IF data.fines < 0 %]<span class='credit'>[% data.fines | $Price %]</span>[% ELSIF data.fines > 0 %]<span class='debit'><strong>[% data.fines | $Price %]</strong></span>[% ELSE %][% data.fines | $Price %][% END %]</a></span>",
35
                "dt_borrowernotes":
36
                    "[% data.borrowernotes | html_line_break | collapse | $To %]",
37
                "dt_action":
38
                "<a href='/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% data.borrowernumber | html %]' class='btn btn-default btn-xs'><i class='fa fa-pencil'></i> Edit</a>[% IF ( CAN_user_circulate_circulate_remaining_permissions ) %] <a class='btn btn-default btn-xs' href='/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% data.borrowernumber | html %]'><i class='fa fa-barcode'></i> Check out</a>[% END %]",
39
                "borrowernumber":
40
                    "[% data.borrowernumber | html %]"
41
            }[% UNLESS loop.last %],[% END %]
42
        [% END %]
43
    ]
44
}
(-)a/svc/members/search (-150 lines)
Lines 1-149 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2013 BibLibre
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI;
22
23
use C4::Auth qw( get_template_and_user haspermission get_user_subpermissions );
24
use C4::Output qw( output_with_http_headers );
25
use C4::Utils::DataTables qw( dt_get_params );
26
use C4::Utils::DataTables::Members qw( search );
27
use Koha::DateUtils qw( output_pref dt_from_string );
28
use Koha::Patrons;
29
30
my $input = CGI->new;
31
32
exit unless $input->param('template_path');
33
34
my ($template, $user, $cookie) = get_template_and_user({
35
    template_name   => scalar $input->param('template_path'),
36
    query           => $input,
37
    type            => "intranet",
38
    flagsrequired   => { borrowers => 'edit_borrowers' }
39
});
40
41
my $searchmember = $input->param('searchmember');
42
my $firstletter  = $input->param('firstletter');
43
my $categorycode = $input->param('categorycode');
44
my $branchcode = $input->param('branchcode');
45
my $searchtype = $input->param('searchtype');
46
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
47
my $has_permission = $input->param('has_permission');
48
my $selection_type = $input->param('selection_type');
49
50
# variable information for DataTables (id)
51
my $sEcho = $input->param('sEcho');
52
53
my %dt_params = dt_get_params($input);
54
foreach (grep {$_ =~ /^mDataProp/} keys %dt_params) {
55
    $dt_params{$_} =~ s/^dt_//;
56
}
57
58
my $results;
59
# If the user filled a term, maybe it's a cardnumber.
60
# This cannot be the case if a first letter is given.
61
if ( $searchmember
62
    and not $firstletter
63
    and $searchfieldstype
64
    and $searchfieldstype eq 'standard' )
65
{
66
    my $member = Koha::Patrons->find( { cardnumber => $searchmember } );
67
    $results = {
68
        iTotalRecords        => 1,
69
        iTotalDisplayRecords => 1,
70
        patrons              => [ $member->unblessed ],
71
    } if $member;
72
}
73
74
if ($has_permission) {
75
    my ( $permission, $subpermission ) = split /\./, $has_permission;
76
    $has_permission = {permission => $permission, subpermission => $subpermission};
77
}
78
79
# Perform the patrons search
80
$results = C4::Utils::DataTables::Members::search(
81
    {
82
        searchmember => $searchmember,
83
        firstletter => $firstletter,
84
        categorycode => $categorycode,
85
        branchcode => $branchcode,
86
        searchtype => $searchtype,
87
        searchfieldstype => $searchfieldstype,
88
        dt_params => \%dt_params,
89
        ( $has_permission ? ( has_permission => $has_permission ) : () ),
90
    }
91
) unless $results;
92
93
$template->param(
94
    sEcho => $sEcho,
95
    iTotalRecords => $results->{iTotalRecords},
96
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
97
    aaData => $results->{patrons},
98
    selection_type => $selection_type,
99
);
100
101
output_with_http_headers $input, $cookie, $template->output, 'json';
102
103
__END__
104
105
=head1 NAME
106
107
search - a search script for finding patrons
108
109
=head1 SYNOPSIS
110
111
This script provides a service for template for patron search using DataTables
112
113
=head2 Performing a search
114
115
Call this script from a DataTables table my $searchmember = $input->param('searchmember');
116
All following params are optional:
117
    searchmember => the search terms
118
    firstletter => search patrons with surname begins with this pattern (currently only used for 1 letter)
119
    categorycode and branchcode => search patrons belong to a given categorycode or a branchcode
120
    searchtype: can be 'contain' or 'start_with'
121
    searchfieldstype: Can be 'standard', 'email', 'borrowernumber', 'userid', 'phone' or 'address'
122
123
=cut
124
125
=back
126
127
=head1 LICENSE
128
129
Copyright 2013 BibLibre
130
131
This file is part of Koha.
132
133
Koha is free software; you can redistribute it and/or modify it under the
134
terms of the GNU General Public License as published by the Free Software
135
Foundation; either version 2 of the License, or (at your option) any later
136
version.
137
138
Koha is free software; you can redistribute it and/or modify it
139
under the terms of the GNU General Public License as published by
140
the Free Software Foundation; either version 3 of the License, or
141
(at your option) any later version.
142
143
Koha is distributed in the hope that it will be useful, but
144
WITHOUT ANY WARRANTY; without even the implied warranty of
145
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
146
GNU General Public License for more details.
147
148
You should have received a copy of the GNU General Public License
149
along with Koha; if not, see <http://www.gnu.org/licenses>.
150
- 

Return to bug 30063