1 package Koha
::Patron
::Modifications
;
3 # Copyright 2012 ByWater Solutions
4 # This file is part of Koha.
6 # Koha is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
21 Koha::Patron::Modifications
29 use Koha
::Patron
::Modification
;
33 use base
qw(Koha::Objects);
37 $count = Koha::Patron::Modifications->pending_count();
39 Returns the number of pending modifications for existing patrons.
44 my ( $self, $branchcode ) = @_;
46 my $dbh = C4
::Context
->dbh;
48 SELECT COUNT(*) AS count
49 FROM borrower_modifications, borrowers
50 WHERE borrower_modifications.borrowernumber > 0
51 AND borrower_modifications.borrowernumber = borrowers.borrowernumber
56 $query .= " AND borrowers.branchcode = ? ";
57 push( @params, $branchcode );
60 my $sth = $dbh->prepare($query);
61 $sth->execute(@params);
62 my $result = $sth->fetchrow_hashref();
64 return $result->{count
};
69 $arrayref = Koha::Patron::Modifications->pending();
71 Returns an arrayref of hashrefs for all pending modifications for existing patrons.
76 my ( $self, $branchcode ) = @_;
78 my $dbh = C4
::Context
->dbh;
80 SELECT borrower_modifications.*
81 FROM borrower_modifications, borrowers
82 WHERE borrower_modifications.borrowernumber > 0
83 AND borrower_modifications.borrowernumber = borrowers.borrowernumber
88 $query .= " AND borrowers.branchcode = ? ";
89 push( @params, $branchcode );
91 $query .= " ORDER BY borrowers.surname, borrowers.firstname";
92 my $sth = $dbh->prepare($query);
93 $sth->execute(@params);
96 while ( my $row = $sth->fetchrow_hashref() ) {
97 foreach my $key ( keys %$row ) {
98 if ( defined $row->{$key} && $key eq 'extended_attributes' ) {
99 $row->{$key} = from_json
($row->{$key});
101 delete $row->{$key} unless defined $row->{$key};
111 return 'BorrowerModification';
119 return 'Koha::Patron::Modification';