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

(-)a/C4/Utils/DataTables/Members.pm (-10 / +21 lines)
Lines 20-26 sub search { Link Here
20
        $searchmember = $dt_params->{sSearch} // '';
20
        $searchmember = $dt_params->{sSearch} // '';
21
    }
21
    }
22
22
23
    my ($iTotalRecords, $iTotalDisplayRecords);
23
    my ($sth, $query, $iTotalRecords, $iTotalDisplayRecords);
24
    my $dbh = C4::Context->dbh;
25
    # Get the iTotalRecords DataTable variable
26
    $query = "SELECT COUNT(borrowers.borrowernumber) FROM borrowers";
27
    $sth = $dbh->prepare($query);
28
    $sth->execute;
29
    ($iTotalRecords) = $sth->fetchrow_array;
30
31
    if ( $searchfieldstype eq 'dateofbirth' ) {
32
        # Return an empty list if the date of birth is not correctly formatted
33
        $searchmember = eval { output_pref( { str => $searchmember, dateformat => 'iso', dateonly => 1 } ); };
34
        if ( $@ or not $searchmember ) {
35
            return {
36
                iTotalRecords        => 0,
37
                iTotalDisplayRecords => 0,
38
                patrons              => [],
39
            };
40
        }
41
    }
24
42
25
    # If branches are independent and user is not superlibrarian
43
    # If branches are independent and user is not superlibrarian
26
    # The search has to be only on the user branch
44
    # The search has to be only on the user branch
Lines 30-36 sub search { Link Here
30
48
31
    }
49
    }
32
50
33
    my $dbh = C4::Context->dbh;
34
    my $select = "SELECT
51
    my $select = "SELECT
35
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
52
        borrowers.borrowernumber, borrowers.surname, borrowers.firstname,
36
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
53
        borrowers.streetnumber, borrowers.streettype, borrowers.address,
Lines 126-132 sub search { Link Here
126
        $limit = "LIMIT $dt_params->{iDisplayStart},$dt_params->{iDisplayLength}";
143
        $limit = "LIMIT $dt_params->{iDisplayStart},$dt_params->{iDisplayLength}";
127
    }
144
    }
128
145
129
    my $query = join(
146
    $query = join(
130
        " ",
147
        " ",
131
        ($select ? $select : ""),
148
        ($select ? $select : ""),
132
        ($from ? $from : ""),
149
        ($from ? $from : ""),
Lines 134-140 sub search { Link Here
134
        ($orderby ? $orderby : ""),
151
        ($orderby ? $orderby : ""),
135
        ($limit ? $limit : "")
152
        ($limit ? $limit : "")
136
    );
153
    );
137
    my $sth = $dbh->prepare($query);
154
    $sth = $dbh->prepare($query);
138
    $sth->execute(@where_args);
155
    $sth->execute(@where_args);
139
    my $patrons = $sth->fetchall_arrayref({});
156
    my $patrons = $sth->fetchall_arrayref({});
140
157
Lines 144-155 sub search { Link Here
144
    $sth->execute(@where_args);
161
    $sth->execute(@where_args);
145
    ($iTotalDisplayRecords) = $sth->fetchrow_array;
162
    ($iTotalDisplayRecords) = $sth->fetchrow_array;
146
163
147
    # Get the iTotalRecords DataTable variable
148
    $query = "SELECT COUNT(borrowers.borrowernumber) FROM borrowers";
149
    $sth = $dbh->prepare($query);
150
    $sth->execute;
151
    ($iTotalRecords) = $sth->fetchrow_array;
152
153
    # Get some information on patrons
164
    # Get some information on patrons
154
    foreach my $patron (@$patrons) {
165
    foreach my $patron (@$patrons) {
155
        ($patron->{overdues}, $patron->{issues}, $patron->{fines}) =
166
        ($patron->{overdues}, $patron->{issues}, $patron->{fines}) =
(-)a/members/member.pl (-4 lines)
Lines 64-73 if ( $quicksearch and $searchmember ) { Link Here
64
64
65
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
65
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
66
66
67
if ( $searchfieldstype eq "dateofbirth" ) {
68
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
69
}
70
71
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
67
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
72
68
73
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
69
my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
(-)a/svc/members/search (-5 lines)
Lines 47-56 my $searchfieldstype = $input->param('searchfieldstype') || 'standard'; Link Here
47
my $has_permission = $input->param('has_permission');
47
my $has_permission = $input->param('has_permission');
48
my $selection_type = $input->param('selection_type');
48
my $selection_type = $input->param('selection_type');
49
49
50
if ( $searchfieldstype eq "dateofbirth" ) {
51
    $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
52
}
53
54
# variable information for DataTables (id)
50
# variable information for DataTables (id)
55
my $sEcho = $input->param('sEcho');
51
my $sEcho = $input->param('sEcho');
56
52
57
- 

Return to bug 17375