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

(-)a/C4/Members.pm (-1 / +1 lines)
Lines 275-281 sub Search { Link Here
275
                else {
275
                else {
276
                    $filter = { '' => $filter, branchcode => $branch };
276
                    $filter = { '' => $filter, branchcode => $branch };
277
                }
277
                }
278
            }      
278
            }
279
        }
279
        }
280
    }
280
    }
281
281
(-)a/C4/Utils/DataTables/Members.pm (+213 lines)
Line 0 Link Here
1
package C4::Utils::DataTables::Members;
2
3
use C4::Branch qw/onlymine/;
4
use C4::Context;
5
use C4::Members qw/GetMemberIssuesAndFines/;
6
use C4::Utils::DataTables;
7
use Modern::Perl;
8
9
sub search {
10
    my ( $params ) = @_;
11
    my $searchmember = $params->{searchmember};
12
    my $firstletter = $params->{firstletter};
13
    my $categorycode = $params->{categorycode};
14
    my $branchcode = $params->{branchcode};
15
    my $searchtype = $params->{searchtype};
16
    my $searchfieldstype = $params->{searchfieldstype};
17
    my $dt_params = $params->{dt_params};
18
19
    my ($iTotalRecords, $iTotalDisplayRecords);
20
21
    # If branches are independant and user is not superlibrarian
22
    # The search has to be only on the user branch
23
    if ( C4::Branch::onlymine ) {
24
        my $userenv = C4::Context->userenv;
25
        $branchcode = $userenv->{'branch'};
26
27
    }
28
29
    my $dbh = C4::Context->dbh;
30
    my $select = "SELECT
31
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname, borrowers.address,
32
        borrowers.address2, borrowers.city, borrowers.zipcode, borrowers.country,
33
        CAST(borrowers.cardnumber AS UNSIGNED) AS cardnumber, borrowers.dateexpiry,
34
        borrowers.borrowernotes, borrowers.branchcode,
35
        categories.description AS category_description, categories.category_type,
36
        branches.branchname";
37
    my $from = "FROM borrowers
38
        LEFT JOIN branches ON borrowers.branchcode = branches.branchcode
39
        LEFT JOIN categories ON borrowers.categorycode = categories.categorycode";
40
    my @where_args;
41
    my @where_strs;
42
    if(defined $firstletter and $firstletter ne '') {
43
        push @where_strs, "borrowers.surname LIKE ?";
44
        push @where_args, "$firstletter%";
45
    }
46
    if(defined $categorycode and $categorycode ne '') {
47
        push @where_strs, "borrowers.categorycode = ?";
48
        push @where_args, $categorycode;
49
    }
50
    if(defined $branchcode and $branchcode ne '') {
51
        push @where_strs, "borrowers.branchcode = ?";
52
        push @where_args, $branchcode;
53
    }
54
55
    # split on coma
56
    $searchmember =~ s/,/ /g if $searchmember;
57
    my @where_strs_or;
58
    my $searchfields = {
59
        standard => 'surname,firstname,othernames,cardnumber',
60
        email => 'email,emailpro,B_email',
61
        borrowernumber => 'borrowernumber',
62
        phone => 'phone,phonepro,B_phone,altcontactphone,mobile',
63
        address => 'streettype,address,address2,city,state,zipcode,country',
64
        dateofbirth => 'dateofbirth',
65
        sort1 => 'sort1',
66
        sort2 => 'sort2',
67
    };
68
    for my $searchfield ( split /,/, $searchfields->{$searchfieldstype} ) {
69
        foreach my $term ( split / /, $searchmember) {
70
            next unless $term;
71
            $searchmember =~ s/\*/%/g; # * is replaced with % for sql
72
            $term .= '%' # end with anything
73
                if $term !~ /%$/;
74
            $term = "%$term" # begin with anythin unless start_with
75
                if $term !~ /^%/
76
                    and $searchtype eq "contain";
77
            push @where_strs_or, "borrowers." . $dbh->quote_identifier($searchfield) . " LIKE ?";
78
            push @where_args, $term;
79
        }
80
    }
81
    push @where_strs, '('. join (' OR ', @where_strs_or) . ')'
82
        if @where_strs_or;
83
84
    my $where;
85
    $where = " WHERE " . join (" AND ", @where_strs) if @where_strs;
86
    my $orderby = dt_build_orderby($dt_params);
87
88
    my $limit;
89
    # If iDisplayLength == -1, we want to display all patrons
90
    if ( $dt_params->{iDisplayLength} > -1 ) {
91
        # In order to avoid sql injection
92
        $dt_params->{iDisplayStart} =~ s/\D//g;
93
        $dt_params->{iDisplayLength} =~ s/\D//g;
94
        $dt_params->{iDisplayStart} //= 0;
95
        $dt_params->{iDisplayLength} //= 20;
96
        $limit = "LIMIT $dt_params->{iDisplayStart},$dt_params->{iDisplayLength}";
97
    }
98
99
    my $query = join(
100
        " ",
101
        ($select ? $select : ""),
102
        ($from ? $from : ""),
103
        ($where ? $where : ""),
104
        ($orderby ? $orderby : ""),
105
        ($limit ? $limit : "")
106
    );
107
    my $sth = $dbh->prepare($query);
108
    $sth->execute(@where_args);
109
    my $patrons = $sth->fetchall_arrayref({});
110
111
    # Get the iTotalDisplayRecords DataTable variable
112
    $query = "SELECT COUNT(borrowers.borrowernumber) " . $from . ($where ? $where : "");
113
    $sth = $dbh->prepare($query);
114
    $sth->execute(@where_args);
115
    ($iTotalDisplayRecords) = $sth->fetchrow_array;
116
117
    # Get the iTotalRecords DataTable variable
118
    $query = "SELECT COUNT(borrowers.borrowernumber) FROM borrowers";
119
    $sth = $dbh->prepare($query);
120
    $sth->execute;
121
    ($iTotalRecords) = $sth->fetchrow_array;
122
123
    # Get some information on patrons
124
    foreach my $patron (@$patrons) {
125
        ($patron->{overdues}, $patron->{issues}, $patron->{fines}) =
126
            GetMemberIssuesAndFines($patron->{borrowernumber});
127
        if($patron->{dateexpiry} and $patron->{dateexpiry} ne '0000-00-00') {
128
            $patron->{dateexpiry} = C4::Dates->new($patron->{dateexpiry}, "iso")->output();
129
        } else {
130
            $patron->{dateexpiry} = '';
131
        }
132
        $patron->{fines} = sprintf("%.2f", $patron->{fines} || 0);
133
    }
134
135
    return {
136
        iTotalRecords => $iTotalRecords,
137
        iTotalDisplayRecords => $iTotalDisplayRecords,
138
        patrons => $patrons
139
    }
140
}
141
142
1;
143
__END__
144
145
=head1 NAME
146
147
C4::Utils::DataTables::Members - module for using DataTables with patrons
148
149
=head1 SYNOPSIS
150
151
This module provides (one for the moment) routines used by the patrons search
152
153
=head2 FUNCTIONS
154
155
=head3 search
156
157
    my $dt_infos = C4::Utils::DataTables::Members->search($params);
158
159
$params is a hashref with some keys:
160
161
=over 4
162
163
=item searchmember
164
165
  String to search in the borrowers sql table
166
167
=item firstletter
168
169
  Introduced to contain 1 letter but can contain more.
170
  The search will done on the borrowers.surname field
171
172
=item categorycode
173
174
  Search patrons with this categorycode
175
176
=item branchcode
177
178
  Search patrons with this branchcode
179
180
=item searchtype
181
182
  Can be 'contain' or 'start_with'. Used for the searchmember parameter.
183
184
=item searchfieldstype
185
186
  Can be 'standard', 'email', 'borrowernumber', 'phone', 'address' or 'dateofbirth', 'sort1', 'sort2'
187
188
=item dt_params
189
190
  Is the reference of C4::Utils::DataTables::dt_get_params($input);
191
192
=cut
193
194
=back
195
196
=head1 LICENSE
197
198
Copyright 2013 BibLibre
199
200
This file is part of Koha.
201
202
Koha is free software; you can redistribute it and/or modify it under the
203
terms of the GNU General Public License as published by the Free Software
204
Foundation; either version 2 of the License, or (at your option) any later
205
version.
206
207
Koha is distributed in the hope that it will be useful, but WITHOUT ANY
208
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
209
A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
210
211
You should have received a copy of the GNU General Public License along
212
with Koha; if not, write to the Free Software Foundation, Inc.,
213
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/home-search.inc (-1 / +2 lines)
Lines 15-21 Link Here
15
<div id="patron_search" class="residentsearch">
15
<div id="patron_search" class="residentsearch">
16
    <p class="tip">Enter patron card number or partial name:</p>
16
    <p class="tip">Enter patron card number or partial name:</p>
17
    <form action="/cgi-bin/koha/members/member.pl" method="post">
17
    <form action="/cgi-bin/koha/members/member.pl" method="post">
18
        <input name="member" id="searchmember" size="40" type="text"/>
18
        <input name="searchmember" id="searchmember" size="40" type="text"/>
19
        <input type="hidden" name="quicksearch" value="1" />
19
        <input value="Submit" class="submit" type="submit" />
20
        <input value="Submit" class="submit" type="submit" />
20
    </form>
21
    </form>
21
</div>[% END %]
22
</div>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-58 / +89 lines)
Lines 5-73 Link Here
5
	<div id="patron_search" class="residentsearch">
5
	<div id="patron_search" class="residentsearch">
6
	<p class="tip">Enter patron card number or partial name:</p>
6
	<p class="tip">Enter patron card number or partial name:</p>
7
	<form action="/cgi-bin/koha/members/member.pl" method="post">
7
	<form action="/cgi-bin/koha/members/member.pl" method="post">
8
    <input id="searchmember" data-toggle="tooltip" size="25" class="focus" name="member" type="text" value="[% member %]"/>
8
    <input id="searchmember" data-toggle="tooltip" size="25" class="focus" name="searchmember" type="text" value="[% searchmember %]"/>
9
    <input type="hidden" name="quicksearch" value="1" />
9
	<span class="filteraction" id="filteraction_off"> <a href="#" onclick="$('#filters').toggle();$('.filteraction').toggle();">[-]</a></span>
10
	<span class="filteraction" id="filteraction_off"> <a href="#" onclick="$('#filters').toggle();$('.filteraction').toggle();">[-]</a></span>
10
	<span class="filteraction" id="filteraction_on"> <a href="#" onclick="$('#filters').toggle();$('.filteraction').toggle();">[+]</a></span>
11
	<span class="filteraction" id="filteraction_on"> <a href="#" onclick="$('#filters').toggle();$('.filteraction').toggle();">[+]</a></span>
11
12
12
    <input value="Search" class="submit" type="submit" />
13
      <label for="searchfieldstype">Search fields:</label>
14
      <select name="searchfieldstype" id="searchfieldstype">
15
        [% IF searchfieldstype == "standard" %]
16
          <option selected="selected" value='standard'>Standard</option>
17
        [% ELSE %]
18
          <option value='standard'>Standard</option>
19
        [% END %]
20
        [% IF searchfieldstype == "email" %]
21
          <option selected="selected" value='email'>Email</option>
22
        [% ELSE %]
23
          <option value='email'>Email</option>
24
        [% END %]
25
        [% IF searchfieldstype == "borrowernumber" %]
26
          <option selected="selected" value='borrowernumber'>Borrower number</option>
27
        [% ELSE %]
28
          <option value='borrowernumber'>Borrower number</option>
29
        [% END %]
30
        [% IF searchfieldstype == "phone" %]
31
          <option selected="selected" value='phone'>Phone number</option>
32
        [% ELSE %]
33
          <option value='phone'>Phone number</option>
34
        [% END %]
35
        [% IF searchfieldstype == "address" %]
36
          <option selected="selected" value='address'>Street Address</option>
37
        [% ELSE %]
38
          <option value='address'>Street Address</option>
39
        [% END %]
40
        [% IF searchfieldstype == "dateofbirth" %]
41
          <option selected="selected" value='dateofbirth'>Date of birth</option>
42
        [% ELSE %]
43
          <option value='dateofbirth'>Date of birth</option>
44
        [% END %]
45
        [% IF searchfieldstype == "sort1" %]
46
          <option selected="selected" value='sort1'>Sort field 1</option>
47
        [% ELSE %]
48
          <option value='sort1'>Sort field 1</option>
49
        [% END %]
50
        [% IF searchfieldstype == "sort2" %]
51
          <option selected="selected" value='sort2'>Sort field 2</option>
52
        [% ELSE %]
53
          <option value='sort2'>Sort field 2</option>
54
        [% END %]
55
      </select>
56
57
      <script type="text/javascript">
58
          [% SET dateformat = Koha.Preference('dateformat') %]
59
          $("#searchfields").change(function() {
60
              if ( $(this).val() == 'dateofbirth' ) {
61
                  [% IF dateformat == 'us' %]
62
                      var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
63
                  [% ELSIF dateformat == 'iso' %]
64
                      var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
65
                  [% ELSIF dateformat == 'metric' %]
66
                      var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
67
                  [% END %]
68
                  $('#searchmember').attr("title",MSG_DATE_FORMAT).tooltip('show');
69
              } else {
70
                  $('#searchmember').tooltip('destroy');
71
              }
72
          });
73
74
      </script>
13
75
14
  <div id="filters">
76
      <label for="searchtype">Search type:</label>
15
      <p><label for="searchfields">Search fields:</label>
77
      <select name="searchtype" id="searchtype">
16
            <select name="searchfields" id="searchfields">
78
          <option selected="selected" value='start_with'>Starts with</option>
17
                <option selected="selected" value=''>Standard</option>
79
          <option value='contain'>Contains</option>
18
                <option value='email,emailpro,B_email,'>Email</option>
80
      </select>
19
                <option value='borrowernumber'>Borrower number</option>
20
                <option value='phone,phonepro,B_phone,altcontactphone,mobile'>Phone number</option>
21
                <option value='streettype,address,address2,city,state,zipcode,country'>Street Address</option>
22
                <option value='dateofbirth'>Date of birth</option>
23
                <option value='sort1'>Sort field 1</option>
24
                <option value='sort2'>Sort field 2</option>
25
            </select>
26
            <script type="text/javascript">
27
                [% SET dateformat = Koha.Preference('dateformat') %]
28
                $("#searchfields").change(function() {
29
                    if ( $(this).val() == 'dateofbirth' ) {
30
                        [% IF dateformat == 'us' %]
31
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
32
                        [% ELSIF dateformat == 'iso' %]
33
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
34
                        [% ELSIF dateformat == 'metric' %]
35
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
36
                        [% END %]
37
                        $('#searchmember').attr("title",MSG_DATE_FORMAT).tooltip('show');
38
                    } else {
39
                        $('#searchmember').tooltip('destroy');
40
                    }
41
                });
42
            </script>
43
        </p>
44
        <p><label for="searchtype">Search type:</label>
45
                <select name="searchtype" id="searchtype">
46
                    <option selected="selected" value=''>Starts with</option>
47
                    <option value='contain'>Contains</option>
48
                </select></p>
49
81
50
      <p><label for="searchorderby">Order by:</label>
82
    <input value="Search" class="submit" type="submit" />
51
            <select name="orderby" id="searchorderby">
83
    [% IF ( branchloop ) %]
52
            <option value="">Surname, Firstname</option>
84
    <p id="filters"> <label for="branchcode">Library: </label>
53
            <option value="cardnumber,0">Cardnumber</option>
85
    <select name="branchcode" id="branchcode">
54
            </select></p>
86
        [% IF branchloop.size != 1 %]
55
        [% IF ( branchloop ) %] <p><label for="branchcode">Library: </label><select name="branchcode" id="branchcode">
87
          <option value="">Any</option>
56
                <option value="">Any</option>[% FOREACH branchloo IN branchloop %]
88
        [% END %]
57
                [% IF ( branchloo.selected ) %]
89
        [% FOREACH branchloo IN branchloop %]
58
                <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]
90
        [% IF ( branchloo.selected ) %]
59
                <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
91
        <option value="[% branchloo.value %]" selected="selected">[% branchloo.branchname %]</option>[% ELSE %]
60
              [% END %]</select></p>
92
        <option value="[% branchloo.value %]">[% branchloo.branchname %]</option>[% END %]
61
      [% END %]
93
      [% END %]</select>
62
      [% IF ( categories ) %]
94
                 <label for="categorycode">Category: </label><select name="categorycode" id="categorycode">
63
        <p><label for="categorycode">Category: </label><select name="categorycode" id="categorycode">
95
        <option value="">Any</option>[% FOREACH categorie IN categories %]
64
                <option value="">Any</option>[% FOREACH categorie IN categories %]
96
        [% IF ( categorie.selected ) %]
65
                [% IF ( categorie.selected ) %]
97
        <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description |html_entity %]</option>[% ELSE %]
66
                <option value="[% categorie.categorycode %]" selected="selected">[% categorie.description |html_entity %]</option>[% ELSE %]
98
        <option value="[% categorie.categorycode %]">[% categorie.description |html_entity %]</option>[% END %]
67
                <option value="[% categorie.categorycode %]">[% categorie.description |html_entity %]</option>[% END %]
99
      [% END %]</select>
68
                [% END %]</select></p>
100
    </p>
69
      [% END %]
101
    [% END %]
70
  </div>
71
</form>
102
</form>
72
	</div>
103
	</div>
73
104
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc (-22 / +22 lines)
Lines 1-23 Link Here
1
[% IF ( borrower.borrowernumber ) %]
1
[%- IF ( borrower.borrowernumber ) %]
2
    [% IF borrower.category_type == 'I' %]
2
    [%- IF borrower.category_type == 'I' %]
3
        [% borrower.surname %] [% IF borrower.othernames %] ([% borrower.othernames %]) [% END %]
3
        [%- borrower.surname %] [% IF borrower.othernames %] ([% borrower.othernames %]) [% END %]
4
    [% ELSE %]
4
    [%- ELSE %]
5
        [% IF invert_name %]
5
        [%- IF invert_name %]
6
            [% borrower.surname %], [% borrower.firstname %] [% IF borrower.othernames %] ([% borrower.othernames %]) [% END %]
6
            [%- borrower.surname %], [% borrower.firstname %] [% IF borrower.othernames %] ([% borrower.othernames %]) [% END %]
7
        [% ELSE %]
7
        [%- ELSE %]
8
            [% borrower.firstname %] [% IF borrower.othernames %] ([% borrower.othernames %]) [% END %] [% borrower.surname %]
8
            [%- borrower.firstname %] [% IF borrower.othernames %] ([% borrower.othernames %]) [% END %] [% borrower.surname %]
9
        [% END %]
9
        [%- END -%]
10
    [% END %]
10
    [%- END -%]
11
    ([% borrower.cardnumber %])
11
    ([% borrower.cardnumber %])
12
[% ELSIF ( borrowernumber ) %]
12
[%- ELSIF ( borrowernumber ) %]
13
    [% IF category_type == 'I' %]
13
    [%- IF category_type == 'I' %]
14
        [% surname %] [% IF othernames %] ([% othernames %]) [% END %]
14
        [%- surname %] [% IF othernames %] ([% othernames %]) [% END %]
15
    [% ELSE %]
15
    [%- ELSE %]
16
        [% IF invert_name %]
16
        [%- IF invert_name %]
17
            [% surname %], [% firstname %] [% IF othernames %] ([% othernames %]) [% END %]
17
            [%- surname %], [% firstname %] [% IF othernames %] ([% othernames %]) [% END %]
18
        [% ELSE %]
18
        [%- ELSE %]
19
            [% firstname %] [% IF othernames %] ([% othernames %]) [% END %] [% surname %]
19
            [%- firstname %] [% IF othernames %] ([% othernames %]) [% END %] [% surname %]
20
        [% END %]
20
        [%- END %]
21
    [% END %]
21
    [%- END -%]
22
    ([% cardnumber %])
22
    ([% cardnumber -%])
23
[% END %]
23
[%- END -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js (-1 / +1 lines)
Lines 23-29 var dataTablesDefaults = { Link Here
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
23
        "sSearch"           : window.MSG_DT_SEARCH || "Search:",
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found"
24
        "sZeroRecords"      : window.MSG_DT_ZERO_RECORDS || "No matching records found"
25
    },
25
    },
26
    "sDom": '<"top pager"ilpf>t<"bottom pager"ip>',
26
    "sDom": '<"top pager"ilpf>tr<"bottom pager"ip>',
27
    "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
27
    "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, window.MSG_DT_ALL || "All"]],
28
    "iDisplayLength": 20
28
    "iDisplayLength": 20
29
};
29
};
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt (-178 / +425 lines)
Lines 1-7 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
2
<title>Koha &rsaquo; Patrons [% IF ( searching ) %]&rsaquo; Search results[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'datatables.inc' %]
5
<script type="text/javascript">
6
<script type="text/javascript">
6
//<![CDATA[
7
//<![CDATA[
7
$(document).ready(function() {
8
$(document).ready(function() {
Lines 21-27 $(document).ready(function() { Link Here
21
            $('#new_patron_list').hide();
22
            $('#new_patron_list').hide();
22
            $('#add_to_patron_list_submit').attr('disabled', 'disabled');
23
            $('#add_to_patron_list_submit').attr('disabled', 'disabled');
23
        }
24
        }
24
25
    });
25
    });
26
26
27
    $('#new_patron_list').on('input', function() {
27
    $('#new_patron_list').on('input', function() {
Lines 31-73 $(document).ready(function() { Link Here
31
            $('#add_to_patron_list_submit').attr('disabled', 'disabled');
31
            $('#add_to_patron_list_submit').attr('disabled', 'disabled');
32
        }
32
        }
33
    });
33
    });
34
35
    $("#patron_list_dialog").hide();
36
    $("#add_to_patron_list_submit").on('click', function(e){
37
        if ( $('#add_to_patron_list').val() == 'new' ) {
38
            if ( $('#new_patron_list').val() ) {
39
                $("#add_to_patron_list option").each(function() {
40
                    if ( $(this).text() == $('#new_patron_list').val() ) {
41
                        alert( _("You already have a list with that name!") );
42
                        return false;
43
                    }
44
                });
45
            } else {
46
                alert( _("You must give your new patron list a name!") );
47
                return false;
48
            }
49
        }
50
51
        if ( $("#memberresultst input:checkbox:checked").length == 0 ) {
52
            alert( _("You have not selected any patrons to add to a list!") );
53
            return false;
54
        }
55
56
        var borrowernumbers = [];
57
        $("#memberresultst").find("input:checkbox:checked").each(function(){
58
            borrowernumbers.push($(this).val());
59
        });
60
        var data = {
61
            add_to_patron_list: encodeURIComponent($("#add_to_patron_list").val()),
62
            new_patron_list: encodeURIComponent($("#new_patron_list").val()),
63
            borrowernumbers: borrowernumbers
64
        };
65
        $.ajax({
66
            data: data,
67
            type: 'POST',
68
            url: '/cgi-bin/koha/svc/members/add_to_list',
69
            success: function(data) {
70
                $("#patron_list_dialog").show();
71
                $("#patron_list_dialog > span.patrons-length").html(data.patrons_added_to_list);
72
                $("#patron_list_dialog > a").attr("href", "/cgi-bin/koha/patron_lists/list.pl?patron_list_id=" + data.patron_list.patron_list_id);
73
                $("#patron_list_dialog > a").html(data.patron_list.name);
74
            },
75
            error: function() {
76
                alert("an error occurred");
77
            }
78
        });
79
        return true;
80
    });
34
});
81
});
35
82
36
function CheckForm() {
83
var dtMemberResults;
37
    if ( $('#add_to_patron_list').val() == 'new' ) {
84
var search = 1;
38
        if ( $('#new_patron_list').val() ) {
85
$(document).ready(function() {
39
            var exists = false;
86
    [% IF searchmember %]
40
            $("#add_to_patron_list option").each(function() {
87
        $("#searchmember_filter").val("[% searchmember %]");
41
                if ( $(this).text() == $('#new_patron_list').val() ) {
88
    [% END %]
42
                    exists = true;
89
    [% IF searchfieldstype %]
43
                    return false;
90
        $("searchfieldstype_filter").val("[% searchfieldstype %]");
91
    [% END %]
92
    [% IF searchtype %]
93
        $("#searchtype_filter").val("[% searchtype %]");
94
    [% END %]
95
    [% IF categorycode %]
96
        $("#categorycode_filter").val("[% categorycode %]");
97
    [% END %]
98
    [% IF branchcode %]
99
        $("#branchcode_filter").val("[% branchcode %]");
100
    [% END %]
101
102
    [% IF view != "show_results" %]
103
        $("#searchresults").hide();
104
        search = 0;
105
    [% END %]
106
107
    // Build the aLengthMenu
108
    var aLengthMenu = [
109
        [%PatronsPerPage %], 10, 20, 50, 100, -1
110
    ];
111
    jQuery.unique(aLengthMenu);
112
    aLengthMenu.sort(function( a, b ){
113
        // Put "All" at the end
114
        if ( a == -1 ) {
115
            return 1;
116
        } else if ( b == -1 ) {
117
            return -1;
118
        }
119
        return parseInt(a) < parseInt(b) ? -1 : 1;}
120
    );
121
    var aLengthMenuLabel = [];
122
    $(aLengthMenu).each(function(){
123
        if ( this == -1 ) {
124
            // Label for -1 is "All"
125
            aLengthMenuLabel.push("All");
126
        } else {
127
            aLengthMenuLabel.push(this);
128
        }
129
    });
130
131
    // Apply DataTables on the results table
132
    dtMemberResults = $("#memberresultst").dataTable($.extend(true, {}, dataTablesDefaults, {
133
        'bServerSide': true,
134
        'sAjaxSource': "/cgi-bin/koha/svc/members/search",
135
        'fnServerData': function(sSource, aoData, fnCallback) {
136
            if ( ! search ) {
137
                return;
138
            }
139
            aoData.push({
140
                'name': 'searchmember',
141
                'value': $("#searchmember_filter").val()
142
            },{
143
                'name': 'firstletter',
144
                'value': $("#firstletter_filter").val()
145
            },{
146
                'name': 'searchfieldstype',
147
                'value': $("#searchfieldstype_filter").val()
148
            },{
149
                'name': 'searchtype',
150
                'value': $("#searchtype_filter").val()
151
            },{
152
                'name': 'categorycode',
153
                'value': $("#categorycode_filter").val()
154
            },{
155
                'name': 'branchcode',
156
                'value': $("#branchcode_filter").val()
157
            },{
158
                'name': 'name_sorton',
159
                'value': 'borrowers.surname borrowers.firstname'
160
            },{
161
                'name': 'category_sorton',
162
                'value': 'categories.description',
163
            },{
164
                'name': 'branch_sorton',
165
                'value': 'branches.branchname'
166
            },{
167
                'name': 'template_path',
168
                'value': 'members/tables/members_results.tt',
169
            });
170
            $.ajax({
171
                'dataType': 'json',
172
                'type': 'POST',
173
                'url': sSource,
174
                'data': aoData,
175
                'success': function(json){
176
                    // redirect if there is only 1 result.
177
                    if ( json.aaData.length == 1 ) {
178
                        var borrowernumber = json.aaData[0].borrowernumber;
179
                        document.location.href="/cgi-bin/koha/members/moremember.pl?borrowernumber="+borrowernumber;
180
                        return false;
181
                    }
182
                    fnCallback(json);
44
                }
183
                }
45
            });
184
            });
185
        },
186
        'aoColumns':[
187
            [% IF CAN_user_tools_manage_patron_lists %]
188
              { 'mDataProp': 'dt_borrowernumber' },
189
            [% END %]
190
            { 'mDataProp': 'dt_cardnumber' },
191
            { 'mDataProp': 'dt_name' },
192
            { 'mDataProp': 'dt_category' },
193
            { 'mDataProp': 'dt_branch' },
194
            { 'mDataProp': 'dt_dateexpiry' },
195
            { 'mDataProp': 'dt_od_checkouts', 'bSortable': false },
196
            { 'mDataProp': 'dt_fines', 'bSortable': false },
197
            { 'mDataProp': 'dt_borrowernotes' },
198
            { 'mDataProp': 'dt_action', 'bSortable': false }
199
        ],
200
        'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
201
            /* Center text for 6th column */
202
            $("td:eq(5)", nRow).css("text-align", "center");
46
203
47
            if ( exists ) {
204
            return nRow;
48
                alert( _("You already have a list with that name!") );
205
        },
49
                return false;
206
        'bFilter': false,
50
            }
207
        'bAutoWidth': false,
208
        [% IF orderby_cardnumber_0 %]
209
            'aaSorting': [[0, 'asc']],
210
        [% ELSE %]
211
            'aaSorting': [[1, 'asc']],
212
        [% END %]
213
        "aLengthMenu": [aLengthMenu, aLengthMenuLabel],
214
        'sPaginationType': 'full_numbers',
215
        "iDisplayLength": [% PatronsPerPage %],
216
    }));
217
    update_searched();
218
});
219
220
// Update the string "Results found ..."
221
function update_searched(){
222
    var searched = "";
223
    searched += "on " + $("#searchfieldstype_filter").find("option:selected").text().toLowerCase() + " fields";
224
    if ( $("#searchmember_filter").val() ) {
225
        if ( $("#searchtype_filter").val() == 'start_with' ) {
226
            searched += _(" starting with ");
51
        } else {
227
        } else {
52
            alert( _("You must give your new patron list a name!") );
228
            searched += _(" containing ");
53
            return false;
54
        }
229
        }
230
        searched += $("#searchmember_filter").val();
231
    }
232
    if ( $("#firstletter_filter").val() ) {
233
        searched += _(" begin with ") + $("#firstletter_filter").val();
234
    }
235
    if ( $("#categorycode_filter").val() ) {
236
        searched += _(" with category ") + $("#categorycode_filter").find("option:selected").text();
237
    }
238
    if ( $("#branchcode_filter").val() ) {
239
        searched += _(" in library ") + $("#branchcode_filter").find("option:selected").text();
55
    }
240
    }
241
    $("#searchpattern").text("for patron " + searched);
242
}
243
244
// Redraw the table
245
function filter() {
246
    $("#firstletter_filter").val('');
247
    update_searched();
248
    search = 1;
249
    $("#searchresults").show();
250
    dtMemberResults.fnDraw();
251
    return false;
252
}
56
253
57
    if ( $('#add_to_patron_list_which').val() == 'all' ) {
254
// User has clicked on the Clear button
58
        return confirm( _("Are you sure you want to add the entire set of patron results to this list ( including results on other pages )?") );
255
function clearFilters(redraw) {
59
    } else {
256
    $("#searchform select").val('');
60
         if ( $("#add-patrons-to-list-form input:checkbox:checked").length == 0 ) {
257
    $("#firstletter_filter").val('');
61
             alert( _("You have not selected any patrons to add to a list!") );
258
    $("#searchmember_filter").val('');
62
             return false;
259
    if(redraw) {
63
         }
260
        search = 1;
261
        $("#searchresults").show();
262
        dtMemberResults.fnDraw();
64
    }
263
    }
264
}
65
265
66
    return true;
266
// User has clicked on a letter
267
function filterByFirstLetterSurname(letter) {
268
    clearFilters(false);
269
    $("#firstletter_filter").val(letter);
270
    update_searched();
271
    search = 1;
272
    $("#searchresults").show();
273
    dtMemberResults.fnDraw();
67
}
274
}
68
//]]>
275
//]]>
69
</script>
276
</script>
70
71
</head>
277
</head>
72
<body id="pat_member" class="pat">
278
<body id="pat_member" class="pat">
73
[% INCLUDE 'header.inc' %]
279
[% INCLUDE 'header.inc' %]
Lines 75-237 function CheckForm() { Link Here
75
281
76
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; [% IF ( searching ) %]<a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Search results[% ELSE %]Patrons[% END %]</div>
282
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; [% IF ( searching ) %]<a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; Search results[% ELSE %]Patrons[% END %]</div>
77
283
78
<div id="doc2" class="yui-t7">
284
<div id="doc3" class="yui-t2">
285
  <div id="bd">
286
    <div id="yui-main">
287
      <div class="yui-b">
288
        <div class="yui-g">
289
          [% IF CAN_user_tools_manage_patron_lists %]
290
            <div id="patron_list_dialog" class="dialog alert">
291
              Added <span class="patrons-length"></span> patrons to <a></a>.
292
            </div>
293
          [% END %]
79
294
80
   <div id="bd">
295
          [% INCLUDE 'patron-toolbar.inc' %]
81
		<div id="yui-main">
296
          [% IF ( no_add ) %]
82
		    <div class="yui-b">
297
            <div class="dialog alert">
83
				<div class="yui-g">
298
              <h3>Cannot add patron</h3>
299
              [% IF ( no_branches ) %]
300
                <p>There are <strong>no libraries defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.[% ELSE %]An administrator must define at least one library.[% END %]</p>
301
              [% END %]
302
              [% IF ( no_categories ) %]
303
                <p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.[% END %]</p>
304
              [% END %]
305
            </div>
306
          [% END %]
307
          <div class="browse">
308
            Browse by last name:
309
            [% FOREACH letter IN alphabet.split(' ') %]
310
              <a style="cursor:pointer" onclick="filterByFirstLetterSurname('[% letter %]');">[% letter %]</a>
311
            [% END %]
312
          </div>
84
313
85
                [% IF patron_list %]
314
          [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
86
                    <div class="dialog alert">
315
            <div class="pending-info" id="patron_updates_pending">
87
                        Added [% patrons_added_to_list.size %] patrons to <a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% patron_list.patron_list_id %]">[% patron_list.name %]</a>.
316
              <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
88
                    </div>
317
              <span class="holdcount"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
89
                [% END %]
318
            </div>
319
          [% END %]
320
321
          <div id="searchresults">
322
            <div id="searchheader">
323
              <h3>Results found <span id="searchpattern">[% IF searchmember %] for '[% searchmember %]'[% END %]</span></h3>
324
            </div>
325
            [% IF CAN_user_tools_manage_patron_lists %]
326
              <div id="searchheader">
327
                  <div>
328
                      <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
329
                      |
330
                      <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
331
                      |
332
                      <span>
333
                          Add selected patrons
334
                          <label for="add_to_patron_list">to:</label>
335
                          <select id="add_to_patron_list" name="add_to_patron_list">
336
                              <option value=""></option>
337
                              [% IF patron_lists %]
338
                                  <optgroup label="Patron lists:">
339
                                      [% FOREACH pl IN patron_lists %]
340
                                          <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
341
                                      [% END %]
342
                                  </optgroup>
343
                              [% END %]
344
345
                              <option value="new">[ New list ]</option>
346
                          </select>
347
348
                          <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
90
349
91
				[% INCLUDE 'patron-toolbar.inc' %]
350
                          <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
92
351
                      </span>
93
	[% IF ( no_add ) %]<div class="dialog alert"><h3>Cannot add patron</h3>
352
                  </div>
94
		[% IF ( no_branches ) %]<p>There are <strong>no libraries defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/branches.pl">add a library</a>.[% ELSE %]An administrator must define at least one library.[% END %]</p>[% END %]
353
              </div>
95
		[% IF ( no_categories ) %]<p>There are <strong>no patron categories defined</strong>. [% IF ( CAN_user_parameters ) %]Please <a href="/cgi-bin/koha/admin/categorie.pl">add a patron category</a>.[% ELSE %]An administrator must define at least one patron category.[% END %]</p>[% END %]</div>
354
            [% END %]
96
	[% END %]
97
98
						<div class="browse">
99
							Browse by last name:
100
                            [% FOREACH letter IN alphabet.split(' ') %]
101
                                <a href="/cgi-bin/koha/members/member.pl?quicksearch=1&amp;surname=[% letter %]">[% letter %]</a>
102
							[% END %]
103
						</div>
104
105
                    [% IF ( CAN_user_borrowers && pending_borrower_modifications ) %]
106
                        <div class="pending-info" id="patron_updates_pending">
107
                            <a href="/cgi-bin/koha/members/members-update.pl">Patrons requesting modifications</a>:
108
                            <span class="holdcount"><a href="/cgi-bin/koha/members/members-update.pl">[% pending_borrower_modifications %]</a></span>
109
                        </div>
110
                    [% END %]
111
112
                    [% IF ( resultsloop ) %]
113
                    [% IF (CAN_user_tools_manage_patron_lists) %]
114
                    <form id="add-patrons-to-list-form" method="post" action="member.pl" onsubmit="return CheckForm()">
115
                    [% END %]
116
                        <div id="searchheader">
117
                            <h3>Results [% from %] to [% to %] of [% numresults %] found for [% IF ( member ) %]'<span class="ex">[% member %]</span>'[% END %][% IF ( surname ) %]'<span class="ex">[% surname %]</span>'[% END %]</h3>
118
119
                            [% IF (CAN_user_tools_manage_patron_lists) %]
120
                            <div>
121
                                <a href="javascript:void(0)" onclick="$('.selection').prop('checked', true)">Select all</a>
122
                                |
123
                                <a href="javascript:void(0)" onclick="$('.selection').prop('checked', false)">Clear all</a>
124
                                |
125
                                <span>
126
                                    <label for="add_to_patron_list_which">Add:</label>
127
                                    <select id="add_to_patron_list_which" name="add_to_patron_list_which">
128
                                        <option value="selected">Selected patrons</option>
129
                                        <option value="all">All resultant patrons</option>
130
                                    </select>
131
132
                                    <label for="add_to_patron_list">to:</label>
133
                                    <select id="add_to_patron_list" name="add_to_patron_list">
134
                                        <option value=""></option>
135
                                        [% IF patron_lists %]
136
                                            <optgroup label="Patron lists:">
137
                                                [% FOREACH pl IN patron_lists %]
138
                                                    <option value="[% pl.patron_list_id %]">[% pl.name %]</option>
139
                                                [% END %]
140
                                            </optgroup>
141
                                        [% END %]
142
143
                                        <option value="new">[ New list ]</option>
144
                                    </select>
145
146
                                    <input type="text" id="new_patron_list" name="new_patron_list" id="new_patron_list" />
147
148
                                    [% FOREACH key IN search_parameters.keys %]
149
                                        <input type="hidden" name="[% key %]" value="[% search_parameters.$key %]" />
150
                                    [% END %]
151
152
                                    <input id="add_to_patron_list_submit" type="submit" class="submit" value="Save">
153
                                </span>
154
                            </div>
155
                            [% END %]
156
                        </div>
157
						<div class="searchresults">
158
159
							<table id="memberresultst">
160
							<thead>
161
							<tr>
162
                            [% IF (CAN_user_tools_manage_patron_lists) %]
163
                            <th>&nbsp</th>
164
                            [% END %]
165
							<th>Card</th>
166
							<th>Name</th>
167
							<th>Cat</th>
168
							<th>Library</th>
169
							<th>Expires on</th>
170
							<th>OD/Checkouts</th>
171
							<th>Fines</th>
172
							<th>Circ note</th>
173
							<th>&nbsp;</th>
174
							</tr>
175
							</thead>
176
							<tbody>
177
							[% FOREACH resultsloo IN resultsloop %]
178
							[% IF ( resultsloo.overdue ) %]
179
							<tr class="problem">
180
							[% ELSE %]
181
							[% UNLESS ( loop.odd ) %]
182
							<tr class="highlight">
183
							[% ELSE %]
184
							<tr>
185
							[% END %]
186
							[% END %]
187
                            [% IF (CAN_user_tools_manage_patron_lists) %]
188
                            <td><input type="checkbox" class="selection" name="borrowernumber" value="[% resultsloo.borrowernumber %]" /></td>
189
                            [% END %]
190
							<td>[% resultsloo.cardnumber %]</td>
191
                            <td style="white-space: nowrap;">
192
                            <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% resultsloo.borrowernumber %]">
193
                            [% INCLUDE 'patron-title.inc' borrowernumber = resultsloo.borrowernumber category_type = resultsloo.category_type firstname = resultsloo.firstname surname = resultsloo.surname othernames = resultsloo.othernames cardnumber = resultsloo.cardnumber invert_name = 1%]
194
                            </a> <br />
195
                            [% IF ( resultsloo.streetnumber ) %][% resultsloo.streetnumber %] [% END %][% resultsloo.address %][% IF ( resultsloo.address2 ) %]<br />[% resultsloo.address2 %][% END %][% IF ( resultsloo.city ) %]<br />[% resultsloo.city %][% IF ( resultsloo.state ) %],[% END %][% END %][% IF ( resultsloo.state ) %] [% resultsloo.state %][% END %] [% IF ( resultsloo.zipcode ) %]  [% resultsloo.zipcode %][% END %][% IF ( resultsloo.country ) %], [% resultsloo.country %][% END %]
196
                            [% IF (resultsloo.email ) %]<br/>Email: <a href="mailto:[% resultsloo.email %]">[% resultsloo.email %]</a>[% END %]
197
                            </td>
198
							<td>[% resultsloo.category_description %] ([% resultsloo.category_type %])</td>
199
							<td>[% resultsloo.branchname %]</td>
200
							<td>[% resultsloo.dateexpiry %]</td>
201
							<td>[% IF ( resultsloo.overdues ) %]<span class="overdue"><strong>[% resultsloo.overdues %]</strong></span>[% ELSE %][% resultsloo.overdues %][% END %]/[% resultsloo.issues %]</td>
202
							<td>[% IF ( resultsloo.fines < 0 ) %]<span class="credit">[% resultsloo.fines %]</span> [% ELSIF resultsloo.fines > 0 %] <span class="debit"><strong>[% resultsloo.fines %]</strong></span> [% ELSE %] [% resultsloo.fines %] [% END %]</td>
203
							<td>[% resultsloo.borrowernotes %]</td>
204
							<td>[% IF ( resultsloo.category_type ) %]
205
									<a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% resultsloo.borrowernumber %]&amp;category_type=[% resultsloo.category_type %]">Edit</a>
206
						[% ELSE %] <!-- try with categorycode if no category_type -->
207
							[% IF ( resultsloo.categorycode ) %]
208
									<a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% resultsloo.borrowernumber %]&amp;categorycode=[% resultsloo.categorycode %]">Edit</a>
209
							[% ELSE %] <!-- if no categorycode, set category_type to A by default -->
210
									<a href="/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% resultsloo.borrowernumber %]&amp;category_type=A">Edit</a>
211
							[% END %]
212
						[% END %]</td>
213
							</tr>
214
							[% END %]
215
							</tbody>
216
							</table>
217
							<div class="pages">[% IF ( multipage ) %][% paginationbar %][% END %]</div>
218
						</div>
219
                    [% IF (CAN_user_tools_manage_patron_lists) %]
220
                    </form>
221
                    [% END %]
222
                    [% ELSE %]
223
                        [% IF ( searching ) %]
224
                            <div class="dialog alert">No results found</div>
225
                        [% END %]
226
                    [% END %]
227
228
					</div>
229
				</div>
230
231
				<div class="yui-g">
232
				[% INCLUDE 'members-menu.inc' %]
233
			</div>
234
355
356
            <table id="memberresultst">
357
              <thead>
358
                <tr>
359
                  <th>&nbsp;</th>
360
                  <th>Card</th>
361
                  <th>Name</th>
362
                  <th>Category</th>
363
                  <th>Library</th>
364
                  <th>Expires on</th>
365
                  <th>OD/Checkouts</th>
366
                  <th>Fines</th>
367
                  <th>Circ note</th>
368
                  <th>&nbsp;</th>
369
                </tr>
370
              </thead>
371
              <tbody></tbody>
372
            </table>
373
          </div>
374
        </div>
375
      </div>
376
    </div>
377
    <div class="yui-b">
378
      <form onsubmit="return filter();" id="searchform">
379
        <input type="hidden" id="firstletter_filter" value="" />
380
        <fieldset class="brief">
381
          <h3>Filters</h3>
382
          <ol>
383
            <li>
384
              <label for="searchmember_filter">Search:</label>
385
              <input type="text" id="searchmember_filter" value="[% searchmember %]"/>
386
            </li>
387
            <li>
388
              <label for="searchfieldstype_filter">Search fields:</label>
389
              <select name="searchfieldstype" id="searchfieldstype_filter">
390
                [% IF searchfieldstype == "standard" %]
391
                  <option selected="selected" value='standard'>Standard</option>
392
                [% ELSE %]
393
                  <option value='standard'>Standard</option>
394
                [% END %]
395
                [% IF searchfieldstype == "email" %]
396
                  <option selected="selected" value='email'>Email</option>
397
                [% ELSE %]
398
                  <option value='email'>Email</option>
399
                [% END %]
400
                [% IF searchfieldstype == "borrowernumber" %]
401
                  <option selected="selected" value='borrowernumber'>Borrower number</option>
402
                [% ELSE %]
403
                  <option value='borrowernumber'>Borrower number</option>
404
                [% END %]
405
                [% IF searchfieldstype == "phone" %]
406
                  <option selected="selected" value='phone'>Phone number</option>
407
                [% ELSE %]
408
                  <option value='phone'>Phone number</option>
409
                [% END %]
410
                [% IF searchfieldstype == "address" %]
411
                  <option selected="selected" value='address'>Street address</option>
412
                [% ELSE %]
413
                  <option value='address'>Street address</option>
414
                [% END %]
415
                [% IF searchfieldstype == "dateofbirth" %]
416
                  <option selected="selected" value='dateofbirth'>Date of birth</option>
417
                [% ELSE %]
418
                  <option value='dateofbirth'>Date of birth</option>
419
                [% END %]
420
                [% IF searchfieldstype == "sort1" %]
421
                  <option selected="selected" value='sort1'>Sort field 1</option>
422
                [% ELSE %]
423
                  <option value='sort1'>Sort field 1</option>
424
                [% END %]
425
                [% IF searchfieldstype == "sort2" %]
426
                  <option selected="selected" value='sort2'>Sort field 2</option>
427
                [% ELSE %]
428
                  <option value='sort2'>Sort field 2</option>
429
                [% END %]
430
              </select>
431
            </li>
432
            <li>
433
              <label for="searchtype_filter">Search type:</label>
434
              <select name="searchtype" id="searchtype_filter">
435
                <option value='start_with'>Starts with</option>
436
                [% IF searchtype == "contain" %]
437
                  <option value="contain" selected="selected">Contains</option>
438
                [% ELSE %]
439
                  <option value="contain" selected="selected">Contains</option>
440
                [% END %]
441
              </select>
442
            </li>
443
            <li>
444
              <label for="categorycode_filter">Category:</label>
445
              <select id="categorycode_filter">
446
                <option value="">Any</option>
447
                [% FOREACH cat IN categories %]
448
                  [% IF cat.selected %]
449
                    <option selected="selected" value="[% cat.categorycode %]">[% cat.description %]</option>
450
                  [% ELSE %]
451
                    <option value="[% cat.categorycode %]">[% cat.description %]</option>
452
                  [% END %]
453
                [% END %]
454
              </select>
455
            </li>
456
            <li>
457
              <label for="branchcode_filter">Branch:</label>
458
              <select id="branchcode_filter">
459
                [% IF branchloop.size != 1 %]
460
                  <option value="">Any</option>
461
                [% END %]
462
                [% FOREACH b IN branchloop %]
463
                  [% IF b.selected %]
464
                    <option selected="selected" value="[% b.branchcode %]">[% b.branchname %]</option>
465
                  [% ELSE %]
466
                    <option value="[% b.branchcode %]">[% b.branchname %]</option>
467
                  [% END %]
468
                [% END %]
469
              </select>
470
            </li>
471
          </ol>
472
          <fieldset class="action">
473
            <input type="submit" value="Search" />
474
            <input type="button" value="Clear" onclick="clearFilters(true);" />
475
          </fieldset>
476
        </fieldset>
477
      </form>
235
    </div>
478
    </div>
479
  </div>
480
  <div class="yui-g">
481
    [% INCLUDE 'members-menu.inc' %]
482
  </div>
236
</div>
483
</div>
237
[% INCLUDE 'intranet-bottom.inc' %]
484
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/tables/members_results.tt (+35 lines)
Line 0 Link Here
1
{
2
    "sEcho": [% sEcho %],
3
    "iTotalRecords": [% iTotalRecords %],
4
    "iTotalDisplayRecords": [% iTotalDisplayRecords %],
5
    "aaData": [
6
        [% FOREACH data IN aaData %]
7
            {
8
                [% IF CAN_user_tools_manage_patron_lists %]
9
                "dt_borrowernumber":
10
                    "<input type='checkbox' class='selection' name='borrowernumber' value='[% data.borrowernumber %]' />",
11
                [% END %]
12
                "dt_cardnumber":
13
                    "[% data.cardnumber %]",
14
                "dt_name":
15
                    "<span style='white-space:nowrap'><a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=[% data.borrowernumber %]'>[% INCLUDE 'patron-title.inc' borrowernumber = data.borrowernumber category_type = data.category_type firstname = data.firstname surname = data.surname othernames = data.othernames cardnumber = data.cardnumber invert_name = 1%]</a><br />[% IF ( data.streetnumber ) %][% data.streetnumber %] [% END %][% data.address %][% IF ( data.address2 ) %]<br />[% data.address2 %][% END %][% IF ( data.city ) %]<br />[% data.city %][% IF ( data.state ) %],[% END %][% END %][% IF ( data.state ) %] [% data.state %][% END %] [% IF ( data.zipcode ) %]  [% data.zipcode %][% END %][% IF ( data.country ) %], [% data.country %][% END %]</span>",
16
                "dt_category":
17
                    "[% data.category_description |html %]([% data.category_type |html %])",
18
                "dt_branch":
19
                    "[% data.branchname |html %]",
20
                "dt_dateexpiry":
21
                    "[% data.dateexpiry %]",
22
                "dt_od_checkouts":
23
                    "[% IF data.overdues %]<span class='overdue'><strong>[% data.overdues %]</strong></span>[% ELSE %][% data.overdues %][% END %] / [% data.issues %]",
24
                "dt_fines":
25
                    "[% IF data.fines < 0 %]<span class='credit'>[% data.fines |html %]</span> [% ELSIF data.fines > 0 %] <span class='debit'><strong>[% data.fines |html %]</strong></span> [% ELSE %] [% data.fines |html%] [% END %]</td>",
26
                "dt_borrowernotes":
27
                    "[% data.borrowernotes |html |html_line_break |collapse %]",
28
                "dt_action":
29
                    "[% IF data.category_type %]<a href='/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% data.borrowernumber %]&amp;category_type=[% data.category_type %]'>Edit</a>[% ELSE %][% IF data.categorycode %]<a href='/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% data.borrowernumber %]&amp;categorycode=[% data.categorycode %]'>Edit</a>[% ELSE %]<a href='/cgi-bin/koha/members/memberentry.pl?op=modify&amp;destination=circ&amp;borrowernumber=[% data.borrowernumber %]&amp;category_type=A'>Edit</a>[% END %][% END %]",
30
                "borrowernumber":
31
                    "[% data.borrowernumber %]"
32
            }[% UNLESS loop.last %],[% END %]
33
        [% END %]
34
    ]
35
}
(-)a/members/member.pl (-167 / +63 lines)
Lines 6-12 Link Here
6
6
7
7
8
# Copyright 2000-2002 Katipo Communications
8
# Copyright 2000-2002 Katipo Communications
9
# Copyright 2010 BibLibre
9
# Copyright 2013 BibLibre
10
#
10
#
11
# This file is part of Koha.
11
# This file is part of Koha.
12
#
12
#
Lines 27-46 use Modern::Perl; Link Here
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Output;
28
use C4::Output;
29
use CGI;
29
use CGI;
30
use C4::Members;
31
use C4::Branch;
30
use C4::Branch;
32
use C4::Category;
31
use C4::Category;
32
use C4::Members qw( GetMember );
33
use Koha::DateUtils;
33
use Koha::DateUtils;
34
use File::Basename;
34
use File::Basename;
35
use Koha::List::Patron;
35
use Koha::List::Patron;
36
36
37
my $input = new CGI;
37
my $input = new CGI;
38
my $quicksearch = $input->param('quicksearch') || '';
39
my $startfrom = $input->param('startfrom') || 1;
40
my $resultsperpage = $input->param('resultsperpage') || C4::Context->preference("PatronsPerPage") || 20;
41
38
42
my ($template, $loggedinuser, $cookie)
39
my ($template, $loggedinuser, $cookie)
43
    = get_template_and_user({template_name => "members/member.tmpl",
40
    = get_template_and_user({template_name => "members/member.tt",
44
                 query => $input,
41
                 query => $input,
45
                 type => "intranet",
42
                 type => "intranet",
46
                 authnotrequired => 0,
43
                 authnotrequired => 0,
Lines 49-237 my ($template, $loggedinuser, $cookie) Link Here
49
46
50
my $theme = $input->param('theme') || "default";
47
my $theme = $input->param('theme') || "default";
51
48
52
my $add_to_patron_list       = $input->param('add_to_patron_list');
53
my $add_to_patron_list_which = $input->param('add_to_patron_list_which');
54
my $new_patron_list          = $input->param('new_patron_list');
55
my @borrowernumbers          = $input->param('borrowernumber');
56
$input->delete(
57
    'add_to_patron_list', 'add_to_patron_list_which',
58
    'new_patron_list',    'borrowernumber',
59
);
60
61
my $patron = $input->Vars;
49
my $patron = $input->Vars;
62
foreach (keys %$patron){
50
foreach (keys %$patron){
63
	delete $$patron{$_} unless($$patron{$_});
51
    delete $patron->{$_} unless($patron->{$_});
64
}
65
my @categories=C4::Category->all;
66
67
my $branches = GetBranches;
68
my @branchloop;
69
70
foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
71
  my $selected;
72
  $selected = 1 if $patron->{branchcode} && $branches->{$_}->{branchcode} eq $patron->{branchcode};
73
  my %row = ( value => $_,
74
        selected => $selected,
75
        branchname => $branches->{$_}->{branchname},
76
      );
77
  push @branchloop, \%row;
78
}
79
80
my %categories_dislay;
81
82
foreach my $category (@categories){
83
	my $hash={
84
			category_description=>$$category{description},
85
			category_type=>$$category{category_type}
86
			 };
87
	$categories_dislay{$$category{categorycode}} = $hash;
88
}
52
}
89
my $AddPatronLists = C4::Context->preference("AddPatronLists") || '';
90
$template->param( 
91
        "AddPatronLists_$AddPatronLists" => "1",
92
            );
93
if ($AddPatronLists=~/code/){
94
    $categories[0]->{'first'}=1;
95
}  
96
97
my $member=$input->param('member') || '';
98
my $orderbyparams=$input->param('orderby') || '';
99
my @orderby;
100
if ($orderbyparams){
101
	my @orderbyelt=split(/,/,$orderbyparams);
102
	push @orderby, {$orderbyelt[0]=>$orderbyelt[1]||0};
103
}
104
else {
105
	@orderby = ({surname=>0},{firstname=>0});
106
}
107
108
$member =~ s/,//g;   #remove any commas from search string
109
$member =~ s/\*/%/g;
110
53
111
my $from = ( $startfrom - 1 ) * $resultsperpage;
54
my $searchmember = $input->param('searchmember');
112
my $to   = $from + $resultsperpage;
55
my $quicksearch = $input->param('quicksearch') // 0;
113
56
114
my ($count,$results);
57
if ( $quicksearch ) {
115
if ($member || keys %$patron) {
58
    my $branchcode;
116
    my $searchfields = $input->param('searchfields') || '';
59
    if ( C4::Branch::onlymine ) {
117
    my @searchfields = $searchfields ? split( ',', $searchfields ) : ( "firstname", "surname", "othernames", "cardnumber", "userid", "email" );
60
        my $userenv = C4::Context->userenv;
118
61
        $branchcode = $userenv->{'branch'};
119
    if ( $searchfields eq "dateofbirth" ) {
62
    }
120
        $member = output_pref({dt => dt_from_string($member), dateformat => 'iso', dateonly => 1});
63
    my $member = GetMember(
64
        cardnumber => $searchmember,
65
        ( $branchcode ? ( branchcode => $branchcode ) : () ),
66
    );
67
    if( $member ){
68
        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $member->{borrowernumber});
69
        exit;
121
    }
70
    }
71
}
122
72
123
    my $searchtype = $input->param('searchtype');
73
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
124
    my $search_scope =
125
        $quicksearch ? "field_start_with"
126
      : $searchtype  ? $searchtype
127
      :                "start_with";
128
74
129
    ($results) = Search( $member || $patron, \@orderby, undef, undef, \@searchfields, $search_scope );
75
if ( $searchfieldstype eq "dateofbirth" ) {
76
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
130
}
77
}
131
78
132
if ($add_to_patron_list) {
79
my $branches = C4::Branch::GetBranches;
133
    my $patron_list;
80
my @branches_loop;
134
81
if ( C4::Branch::onlymine ) {
135
    if ( $add_to_patron_list eq 'new' ) {
82
    my $userenv = C4::Context->userenv;
136
        $patron_list = AddPatronList( { name => $new_patron_list } );
83
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
137
    }
84
    push @branches_loop, {
138
    else {
85
        value => $branch->{branchcode},
139
        $patron_list =
86
        branchcode => $branch->{branchcode},
140
          [ GetPatronLists( { patron_list_id => $add_to_patron_list } ) ]->[0];
87
        branchname => $branch->{branchname},
88
        selected => 1
141
    }
89
    }
142
90
} else {
143
    if ( $add_to_patron_list_which eq 'all' ) {
91
    foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
144
        @borrowernumbers = map { $_->{borrowernumber} } @$results;
92
        my $selected = 0;
93
        $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_);
94
        push @branches_loop, {
95
            value => $_,
96
            branchcode => $_,
97
            branchname => $branches->{$_}->{branchname},
98
            selected => $selected
99
        };
145
    }
100
    }
146
147
    my @patrons_added_to_list = AddPatronsToList( { list => $patron_list, borrowernumbers => \@borrowernumbers } );
148
149
    $template->param(
150
        patron_list           => $patron_list,
151
        patrons_added_to_list => \@patrons_added_to_list,
152
      )
153
}
101
}
154
102
155
if ($results) {
103
my @categories = C4::Category->all;
156
	for my $field ('categorycode','branchcode'){
104
if ( $patron->{categorycode} ) {
157
		next unless ($patron->{$field});
105
    foreach my $category ( grep { $_->{categorycode} eq $patron->{categorycode} } @categories ) {
158
		@$results = grep { $_->{$field} eq $patron->{$field} } @$results; 
106
        $category->{selected} = 1;
159
	}
107
    }
160
    $count = scalar(@$results);
161
} else {
162
    $count = 0;
163
}
108
}
164
109
165
if($count == 1){
110
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
166
    print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . @$results[0]->{borrowernumber});
167
    exit;
168
}
169
111
170
my @resultsdata;
112
my $orderby = $input->param('orderby') // '';
171
$to=($count>$to?$to:$count);
113
if(defined $orderby and $orderby ne '') {
172
my $index=$from;
114
    $orderby =~ s/[, ]/_/g;
173
foreach my $borrower(@$results[$from..$to-1]){
174
  #find out stats
175
  my ($od,$issue,$fines)=GetMemberIssuesAndFines($$borrower{'borrowernumber'});
176
  $fines ||= 0;
177
  $$borrower{'dateexpiry'}= C4::Dates->new($$borrower{'dateexpiry'},'iso')->output('syspref');
178
179
  my %row = (
180
    count => $index++,
181
    %$borrower,
182
    (defined $categories_dislay{ $borrower->{categorycode} }?   %{ $categories_dislay{ $borrower->{categorycode} } }:()),
183
    overdues => $od,
184
    issues => $issue,
185
    odissue => "$od/$issue",
186
    fines =>  sprintf("%.2f",$fines),
187
    branchname => $branches->{$borrower->{branchcode}}->{branchname},
188
    );
189
  push(@resultsdata, \%row);
190
}
115
}
191
116
192
if ($$patron{categorycode}){
117
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
193
	foreach my $category (grep{$_->{categorycode} eq $$patron{categorycode}}@categories){
194
		$$category{selected}=1;
195
	}
196
}
197
my %parameters=
198
        (  %$patron
199
		, 'orderby'			=> $orderbyparams 
200
		, 'resultsperpage'	=> $resultsperpage 
201
        , 'type'=> 'intranet'); 
202
my $base_url =
203
    'member.pl?&amp;'
204
  . join(
205
    '&amp;',
206
    map { "$_=$parameters{$_}" } (keys %parameters)
207
  );
208
209
my @letters = map { {letter => $_} } ( 'A' .. 'Z');
210
118
211
$template->param(
119
$template->param(
212
    %$patron,
213
    letters       => \@letters,
214
    paginationbar => pagination_bar(
215
        $base_url,
216
        int( $count / $resultsperpage ) + ( $count % $resultsperpage ? 1 : 0 ),
217
        $startfrom,
218
        'startfrom'
219
    ),
220
    startfrom    => $startfrom,
221
    from         => ( $startfrom - 1 ) * $resultsperpage + 1,
222
    to           => $to,
223
    multipage    => ( $count != $to || $startfrom != 1 ),
224
    advsearch    => ( $$patron{categorycode} || $$patron{branchcode} ),
225
    branchloop   => \@branchloop,
226
    categories   => \@categories,
227
    searching    => "1",
228
    actionname   => basename($0),
229
    numresults   => $count,
230
    resultsloop  => \@resultsdata,
231
    results_per_page => $resultsperpage,
232
    member => $member,
233
    search_parameters => \%parameters,
234
    patron_lists => [ GetPatronLists() ],
120
    patron_lists => [ GetPatronLists() ],
121
    searchmember        => $searchmember,
122
    branchloop          => \@branches_loop,
123
    categories          => \@categories,
124
    branchcode          => $patron->{branchcode},
125
    categorycode        => $patron->{categorycode},
126
    searchtype          => $input->param('searchtype') || 'start_with',
127
    searchfieldstype    => $searchfieldstype,
128
    "orderby_$orderby"  => 1,
129
    PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
130
    view                => $view,
235
);
131
);
236
132
237
output_html_with_http_headers $input, $cookie, $template->output;
133
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/members/members-home.pl (-6 / +21 lines)
Lines 45-56 my ($template, $loggedinuser, $cookie) Link Here
45
45
46
my $branches = GetBranches;
46
my $branches = GetBranches;
47
my @branchloop;
47
my @branchloop;
48
foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
48
if ( C4::Branch::onlymine ) {
49
    my $userenv = C4::Context->userenv;
50
    my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
49
    push @branchloop, {
51
    push @branchloop, {
50
        value      => $_,
52
        value => $branch->{branchcode},
51
        selected   => ($branches->{$_}->{branchcode} eq $branch),
53
        branchcode => $branch->{branchcode},
52
        branchname => $branches->{$_}->{branchname},
54
        branchname => $branch->{branchname},
53
    };
55
        selected => 1
56
    }
57
} else {
58
    foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
59
        push @branchloop, {
60
            value      => $_,
61
            selected   => ($branches->{$_}->{branchcode} eq $branch),
62
            branchname => $branches->{$_}->{branchname},
63
        };
64
    }
54
}
65
}
55
66
56
my @categories;
67
my @categories;
Lines 86-91 $template->param( Link Here
86
        no_add => $no_add,
97
        no_add => $no_add,
87
        pending_borrower_modifications => $pending_borrower_modifications,
98
        pending_borrower_modifications => $pending_borrower_modifications,
88
            );
99
            );
89
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
100
101
$template->param(
102
    alphabet => C4::Context->preference('alphabet') || join (' ', 'A' .. 'Z'),
103
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
104
);
90
105
91
output_html_with_http_headers $query, $cookie, $template->output;
106
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/members/moremember.pl (-10 / +10 lines)
Lines 52-59 use C4::Form::MessagingPreferences; Link Here
52
use List::MoreUtils qw/uniq/;
52
use List::MoreUtils qw/uniq/;
53
use C4::Members::Attributes qw(GetBorrowerAttributes);
53
use C4::Members::Attributes qw(GetBorrowerAttributes);
54
use Koha::Borrower::Debarments qw(GetDebarments);
54
use Koha::Borrower::Debarments qw(GetDebarments);
55
#use Smart::Comments;
55
56
#use Data::Dumper;
57
use DateTime;
56
use DateTime;
58
use Koha::DateUtils;
57
use Koha::DateUtils;
59
58
Lines 81-101 my $template_name; Link Here
81
my $quickslip = 0;
80
my $quickslip = 0;
82
81
83
my $flagsrequired;
82
my $flagsrequired;
84
if ($print eq "page") {
83
if (defined $print and $print eq "page") {
85
    $template_name = "members/moremember-print.tmpl";
84
    $template_name = "members/moremember-print.tmpl";
86
    # circ staff who process checkouts but can't edit
85
    # circ staff who process checkouts but can't edit
87
    # patrons still need to be able to access print view
86
    # patrons still need to be able to access print view
88
    $flagsrequired = { circulate => "circulate_remaining_permissions" };
87
    $flagsrequired = { circulate => "circulate_remaining_permissions" };
89
} elsif ($print eq "slip") {
88
} elsif (defined $print and $print eq "slip") {
90
    $template_name = "members/moremember-receipt.tmpl";
89
    $template_name = "members/moremember-receipt.tmpl";
91
    # circ staff who process checkouts but can't edit
90
    # circ staff who process checkouts but can't edit
92
    # patrons still need to be able to print receipts
91
    # patrons still need to be able to print receipts
93
    $flagsrequired =  { circulate => "circulate_remaining_permissions" };
92
    $flagsrequired =  { circulate => "circulate_remaining_permissions" };
94
} elsif ($print eq "qslip") {
93
} elsif (defined $print and $print eq "qslip") {
95
    $template_name = "members/moremember-receipt.tmpl";
94
    $template_name = "members/moremember-receipt.tmpl";
96
    $quickslip = 1;
95
    $quickslip = 1;
97
    $flagsrequired =  { circulate => "circulate_remaining_permissions" };
96
    $flagsrequired =  { circulate => "circulate_remaining_permissions" };
98
} elsif ($print eq "brief") {
97
} elsif (defined $print and $print eq "brief") {
99
    $template_name = "members/moremember-brief.tmpl";
98
    $template_name = "members/moremember-brief.tmpl";
100
    $flagsrequired = { borrowers => 1 };
99
    $flagsrequired = { borrowers => 1 };
101
} else {
100
} else {
Lines 156-162 if ($debar) { Link Here
156
}
155
}
157
156
158
$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
157
$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} );
159
$data->{ "sex_".$data->{'sex'}."_p" } = 1;
158
$data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex};
160
159
161
my $catcode;
160
my $catcode;
162
if ( $category_type eq 'C') {
161
if ( $category_type eq 'C') {
Lines 283-295 if ($borrowernumber) { Link Here
283
        $getreserv{barcodereserv}  = $getiteminfo->{'barcode'};
282
        $getreserv{barcodereserv}  = $getiteminfo->{'barcode'};
284
        $getreserv{itemtype}  = $itemtypeinfo->{'description'};
283
        $getreserv{itemtype}  = $itemtypeinfo->{'description'};
285
284
286
        # 		check if we have a waitin status for reservations
285
        # check if we have a waitin status for reservations
287
        if ( $num_res->{'found'} eq 'W' ) {
286
        if ( defined $num_res->{found} and $num_res->{'found'} eq 'W' ) {
288
            $getreserv{color}   = 'reserved';
287
            $getreserv{color}   = 'reserved';
289
            $getreserv{waiting} = 1;
288
            $getreserv{waiting} = 1;
290
        }
289
        }
291
290
292
        # 		check transfers with the itemnumber foud in th reservation loop
291
        # check transfers with the itemnumber foud in th reservation loop
293
        if ($transfertwhen) {
292
        if ($transfertwhen) {
294
            $getreserv{color}      = 'transfered';
293
            $getreserv{color}      = 'transfered';
295
            $getreserv{transfered} = 1;
294
            $getreserv{transfered} = 1;
Lines 436-441 $template->param( Link Here
436
    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
435
    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
437
    RoutingSerials => C4::Context->preference('RoutingSerials'),
436
    RoutingSerials => C4::Context->preference('RoutingSerials'),
438
    debarments => GetDebarments({ borrowernumber => $borrowernumber }),
437
    debarments => GetDebarments({ borrowernumber => $borrowernumber }),
438
    PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
439
);
439
);
440
$template->param( $error => 1 ) if $error;
440
$template->param( $error => 1 ) if $error;
441
441
(-)a/svc/members/add_to_list (+63 lines)
Line 0 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 under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use CGI;
22
23
use C4::Auth qw( check_cookie_auth );
24
use JSON qw( to_json );
25
use Koha::List::Patron;
26
27
my $input = new CGI;
28
29
my ( $auth_status, $sessionID ) = check_cookie_auth(
30
    $input->cookie('CGISESSID'),
31
    { tools => 'manage_patron_lists' },
32
);
33
34
exit 0 if $auth_status ne "ok";
35
my $add_to_patron_list       = $input->param('add_to_patron_list');
36
my $new_patron_list          = $input->param('new_patron_list');
37
my @borrowernumbers          = $input->param('borrowernumbers[]');
38
39
my $response;
40
if ($add_to_patron_list) {
41
    my $patron_list = [];
42
43
    if ( $add_to_patron_list eq 'new' ) {
44
        $patron_list = AddPatronList( { name => $new_patron_list } );
45
    }
46
    else {
47
        $patron_list =
48
          [ GetPatronLists( { patron_list_id => $add_to_patron_list } ) ]->[0];
49
    }
50
51
    my @patrons_added_to_list = AddPatronsToList( { list => $patron_list, borrowernumbers => \@borrowernumbers } );
52
53
    $response->{patron_list} = { patron_list_id => $patron_list->patron_list_id, name => $patron_list->name };
54
    $response->{patrons_added_to_list} = scalar( @patrons_added_to_list );
55
}
56
57
binmode STDOUT, ":encoding(UTF-8)";
58
print $input->header(
59
    -type => 'application/json',
60
    -charset => 'UTF-8'
61
);
62
63
print to_json( $response );
(-)a/svc/members/search (+119 lines)
Line 0 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 under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
use CGI;
22
23
use C4::Auth qw( get_template_and_user );
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
28
my $input = new CGI;
29
30
exit unless $input->param('template_path');
31
32
my ($template, $user, $cookie) = get_template_and_user({
33
    template_name   => $input->param('template_path'),
34
    query           => $input,
35
    type            => "intranet",
36
    authnotrequired => 0,
37
    flagsrequired   => { borrowers => 1 }
38
});
39
40
my $searchmember = $input->param('searchmember');
41
my $firstletter  = $input->param('firstletter');
42
my $categorycode = $input->param('categorycode');
43
my $branchcode = $input->param('branchcode');
44
my $searchtype = $input->param('searchtype');
45
my $searchfieldstype = $input->param('searchfieldstype');
46
47
# variable information for DataTables (id)
48
my $sEcho = $input->param('sEcho');
49
50
my %dt_params = dt_get_params($input);
51
foreach (grep {$_ =~ /^mDataProp/} keys %dt_params) {
52
    $dt_params{$_} =~ s/^dt_//;
53
}
54
55
# Perform the patrons search
56
my $results = C4::Utils::DataTables::Members::search(
57
    {
58
        searchmember => $searchmember,
59
        firstletter => $firstletter,
60
        categorycode => $categorycode,
61
        branchcode => $branchcode,
62
        searchtype => $searchtype,
63
        searchfieldstype => $searchfieldstype,
64
        dt_params => \%dt_params,
65
66
    }
67
);
68
69
$template->param(
70
    sEcho => $sEcho,
71
    iTotalRecords => $results->{iTotalRecords},
72
    iTotalDisplayRecords => $results->{iTotalDisplayRecords},
73
    aaData => $results->{patrons}
74
);
75
76
output_with_http_headers $input, $cookie, $template->output, 'json';
77
78
__END__
79
80
=head1 NAME
81
82
search - a search script for finding patrons
83
84
=head1 SYNOPSIS
85
86
This script provides a service for template for patron search using DataTables
87
88
=head2 Performing a search
89
90
Call this script from a DataTables table my $searchmember = $input->param('searchmember');
91
All following params are optional:
92
    searchmember => the search terms
93
    firstletter => search patrons with surname begins with this pattern (currently only used for 1 letter)
94
    categorycode and branchcode => search patrons belong to a given categorycode or a branchcode
95
    searchtype: can be 'contain' or 'start_with'
96
    searchfieldstype: Can be 'standard', 'email', 'borrowernumber', 'phone' or 'address'
97
98
=cut
99
100
=back
101
102
=head1 LICENSE
103
104
Copyright 2013 BibLibre
105
106
This file is part of Koha.
107
108
Koha is free software; you can redistribute it and/or modify it under the
109
terms of the GNU General Public License as published by the Free Software
110
Foundation; either version 2 of the License, or (at your option) any later
111
version.
112
113
Koha is distributed in the hope that it will be useful, but WITHOUT ANY
114
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
115
A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
116
117
You should have received a copy of the GNU General Public License along
118
with Koha; if not, write to the Free Software Foundation, Inc.,
119
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
(-)a/t/DataTables/Members.t (-1 / +14 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
use Test::More tests => 4;
3
4
use_ok( "C4::Utils::DataTables::Members" );
5
6
my $patrons = C4::Utils::DataTables::Members::search({
7
    searchmember => "Doe",
8
    searchfieldstype => 'standard',
9
    searchtype => 'contains'
10
});
11
12
isnt( $patrons->{iTotalDisplayRecords}, undef, "The iTotalDisplayRecords key is defined");
13
isnt( $patrons->{iTotalRecords}, undef, "The iTotalRecords key is defined");
14
is( ref $patrons->{patrons}, 'ARRAY', "The patrons key is an arrayref");

Return to bug 9811