@@ -, +, @@ --- C4/Members.pm | 130 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 65 insertions(+), 65 deletions(-) --- a/C4/Members.pm +++ a/C4/Members.pm @@ -155,13 +155,13 @@ use C4::Members; =head1 DESCRIPTION -This module contains routines for adding, modifying and deleting members/patrons/borrowers +This module contains routines for adding, modifying and deleting members/patrons/borrowers =head1 FUNCTIONS =head2 Search - $borrowers_result_array_ref = &Search($filter,$orderby, $limit, + $borrowers_result_array_ref = &Search($filter,$orderby, $limit, $columns_out, $search_on_fields,$searchtype); Looks up patrons (borrowers) on filter. A wrapper for SearchInTable('borrowers'). @@ -379,7 +379,7 @@ sub GetMemberDetails { $borrower->{'authflags'} = $accessflagshash; # For the purposes of making templates easier, we'll define a - # 'showname' which is the alternate form the user's first name if + # 'showname' which is the alternate form the user's first name if # 'other name' is defined. if ($borrower->{category_type} eq 'I') { $borrower->{'showname'} = $borrower->{'othernames'}; @@ -441,7 +441,7 @@ The following will be set where applicable: $flags->{WAITING}->{message} Message -- deprecated $flags->{WAITING}->{itemlist} ref-to-array: list of available items -=over +=over =item C<$flags-E{ODUES}-E{itemlist}> is a reference-to-array listing the overdue items. Its elements are references-to-hash, each describing an @@ -457,7 +457,7 @@ fields from the reserves table of the Koha database. =back -All the "message" fields that include language generated in this function are deprecated, +All the "message" fields that include language generated in this function are deprecated, because such strings belong properly in the display layer. The "message" field that comes from the DB is OK. @@ -572,7 +572,7 @@ sub GetMember { my $dbh = C4::Context->dbh; my $select = q{SELECT borrowers.*, categories.category_type, categories.description - FROM borrowers + FROM borrowers LEFT JOIN categories on borrowers.categorycode=categories.categorycode WHERE }; my $more_p = 0; my @values = (); @@ -722,8 +722,8 @@ sub GetMemberIssuesAndFines { my $issue_count = $sth->fetchrow_arrayref->[0]; $sth = $dbh->prepare( - "SELECT COUNT(*) FROM issues - WHERE borrowernumber = ? + "SELECT COUNT(*) FROM issues + WHERE borrowernumber = ? AND date_due < now()" ); $sth->execute($borrowernumber); @@ -994,9 +994,9 @@ sub changepassword { $sth->execute( $uid, $digest, $member ); $resultcode=1; } - + logaction("MEMBERS", "CHANGE PASS", $member, "") if C4::Context->preference("BorrowersLog"); - return $resultcode; + return $resultcode; } @@ -1068,7 +1068,7 @@ sub fixup_cardnumber { my ($result) = $sth->fetchrow; return $result + 1; } - return $cardnumber; # just here as a fallback/reminder + return $cardnumber; # just here as a fallback/reminder } =head2 GetGuarantees @@ -1098,14 +1098,14 @@ sub GetGuarantees { $sth->execute($borrowernumber); my @dat; - my $data = $sth->fetchall_arrayref({}); + my $data = $sth->fetchall_arrayref({}); return ( scalar(@$data), $data ); } =head2 UpdateGuarantees &UpdateGuarantees($parent_borrno); - + C<&UpdateGuarantees> borrower data for an adult and updates all the guarantees with the modified information @@ -1118,7 +1118,7 @@ sub UpdateGuarantees { my $dbh = C4::Context->dbh; my ( $count, $guarantees ) = GetGuarantees( $data{'borrowernumber'} ); foreach my $guarantee (@$guarantees){ - my $guaquery = qq|UPDATE borrowers + my $guaquery = qq|UPDATE borrowers SET address=?,fax=?,B_city=?,mobile=?,city=?,phone=? WHERE borrowernumber=? |; @@ -1240,14 +1240,14 @@ sub GetAllIssues { my $dbh = C4::Context->dbh; my $query = 'SELECT *, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp - FROM issues + FROM issues LEFT JOIN items on items.itemnumber=issues.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber - WHERE borrowernumber=? + WHERE borrowernumber=? UNION ALL - SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp - FROM old_issues + SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp + FROM old_issues LEFT JOIN items on items.itemnumber=old_issues.itemnumber LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber @@ -1283,8 +1283,8 @@ sub GetMemberAccountRecords { my @acctlines; my $numlines = 0; my $strsth = qq( - SELECT * - FROM accountlines + SELECT * + FROM accountlines WHERE borrowernumber=?); $strsth.=" ORDER BY date desc,timestamp DESC"; my $sth= $dbh->prepare( $strsth ); @@ -1362,11 +1362,11 @@ sub GetBorNotifyAcctRecord { my @acctlines; my $numlines = 0; my $sth = $dbh->prepare( - "SELECT * - FROM accountlines - WHERE borrowernumber=? - AND notify_id=? - AND amountoutstanding != '0' + "SELECT * + FROM accountlines + WHERE borrowernumber=? + AND notify_id=? + AND amountoutstanding != '0' ORDER BY notify_id,accounttype "); @@ -1519,8 +1519,8 @@ sub getidcity { $email = GetFirstValidEmailAddress($borrowernumber); -Return the first valid email address for a borrower, given the borrowernumber. For now, the order -is defined as email, emailpro, B_email. Returns the empty string if the borrower has no email +Return the first valid email address for a borrower, given the borrowernumber. For now, the order +is defined as email, emailpro, B_email. Returns the empty string if the borrower has no email addresses. =cut @@ -1572,7 +1572,7 @@ sub GetNoticeEmailAddress { return $data->{'primaryemail'} || ''; } -=head2 GetExpiryDate +=head2 GetExpiryDate $expirydate = GetExpiryDate($categorycode, $dateenrolled); @@ -1668,16 +1668,16 @@ sub GetBorrowercategory { if ($catcode){ my $sth = $dbh->prepare( - "SELECT description,dateofbirthrequired,upperagelimit,category_type - FROM categories + "SELECT description,dateofbirthrequired,upperagelimit,category_type + FROM categories WHERE categorycode = ?" ); $sth->execute($catcode); my $data = $sth->fetchrow_hashref; return $data; - } - return; + } + return; } # sub getborrowercategory @@ -1880,7 +1880,7 @@ sub GetCities { Returns the authorized value details C<&$lib>return value of authorized value details -C<&$sortvalue>this is the value of authorized value +C<&$sortvalue>this is the value of authorized value C<&$category>this is the value of authorized value category =cut @@ -1888,8 +1888,8 @@ C<&$category>this is the value of authorized value category sub GetSortDetails { my ( $category, $sortvalue ) = @_; my $dbh = C4::Context->dbh; - my $query = qq|SELECT lib - FROM authorised_values + my $query = qq|SELECT lib + FROM authorised_values WHERE category=? AND authorised_value=? |; my $sth = $dbh->prepare($query); @@ -1937,8 +1937,8 @@ sub DelMember { #warn "in delmember with $borrowernumber"; return unless $borrowernumber; # borrowernumber is mandatory. - my $query = qq|DELETE - FROM reserves + my $query = qq|DELETE + FROM reserves WHERE borrowernumber=?|; my $sth = $dbh->prepare($query); $sth->execute($borrowernumber); @@ -1973,8 +1973,8 @@ sub ExtendMemberSubscriptionTo { $date = GetExpiryDate( $borrower->{'categorycode'}, $date ); } my $sth = $dbh->do(<prepare($query); $sth->execute($borrowernumber); - my $hidelostitems = $sth->fetchrow; - return $hidelostitems; + my $hidelostitems = $sth->fetchrow; + return $hidelostitems; } =head2 GetBorrowersToExpunge @@ -2105,11 +2105,11 @@ sub GetBorrowersToExpunge { my $filtercategory = $params->{'category_code'}; my $filterbranch = $params->{'branchcode'} || ((C4::Context->preference('IndependentBranches') - && C4::Context->userenv + && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch}) ? C4::Context->userenv->{branch} - : ""); + : ""); my $dbh = C4::Context->dbh; my $query = " @@ -2119,7 +2119,7 @@ sub GetBorrowersToExpunge { FROM borrowers JOIN categories USING (categorycode) LEFT JOIN old_issues USING (borrowernumber) - LEFT JOIN issues USING (borrowernumber) + LEFT JOIN issues USING (borrowernumber) WHERE category_type <> 'S' AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0) "; @@ -2144,13 +2144,13 @@ sub GetBorrowersToExpunge { warn $query if $debug; my $sth = $dbh->prepare($query); - if (scalar(@query_params)>0){ + if (scalar(@query_params)>0){ $sth->execute(@query_params); - } + } else { $sth->execute; - } - + } + my @results; while ( my $data = $sth->fetchrow_hashref ) { push @results, $data; @@ -2169,13 +2169,13 @@ I<$result> is a ref to an array which all elements are a hasref. =cut sub GetBorrowersWhoHaveNeverBorrowed { - my $filterbranch = shift || + my $filterbranch = shift || ((C4::Context->preference('IndependentBranches') - && C4::Context->userenv + && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch}) ? C4::Context->userenv->{branch} - : ""); + : ""); my $dbh = C4::Context->dbh; my $query = " SELECT borrowers.borrowernumber,max(timestamp) as latestissue @@ -2184,20 +2184,20 @@ sub GetBorrowersWhoHaveNeverBorrowed { WHERE issues.borrowernumber IS NULL "; my @query_params; - if ($filterbranch && $filterbranch ne ""){ + if ($filterbranch && $filterbranch ne ""){ $query.=" AND borrowers.branchcode= ?"; push @query_params,$filterbranch; } warn $query if $debug; - + my $sth = $dbh->prepare($query); - if (scalar(@query_params)>0){ + if (scalar(@query_params)>0){ $sth->execute(@query_params); - } + } else { $sth->execute; - } - + } + my @results; while ( my $data = $sth->fetchrow_hashref ) { push @results, $data; @@ -2219,25 +2219,25 @@ This hashref is containt the number of time this borrowers has borrowed before I sub GetBorrowersWithIssuesHistoryOlderThan { my $dbh = C4::Context->dbh; my $date = shift ||POSIX::strftime("%Y-%m-%d",localtime()); - my $filterbranch = shift || + my $filterbranch = shift || ((C4::Context->preference('IndependentBranches') - && C4::Context->userenv + && C4::Context->userenv && !C4::Context->IsSuperLibrarian() && C4::Context->userenv->{branch}) ? C4::Context->userenv->{branch} - : ""); + : ""); my $query = " SELECT count(borrowernumber) as n,borrowernumber FROM old_issues WHERE returndate < ? - AND borrowernumber IS NOT NULL - "; + AND borrowernumber IS NOT NULL + "; my @query_params; push @query_params, $date; if ($filterbranch){ $query.=" AND branchcode = ?"; push @query_params, $filterbranch; - } + } $query.=" GROUP BY borrowernumber "; warn $query if $debug; my $sth = $dbh->prepare($query); @@ -2263,10 +2263,10 @@ This hashref is containt the number of time this borrowers has borrowed before I sub GetBorrowersNamesAndLatestIssue { my $dbh = C4::Context->dbh; - my @borrowernumbers=@_; + my @borrowernumbers=@_; my $query = " SELECT surname,lastname, phone, email,max(timestamp) - FROM borrowers + FROM borrowers LEFT JOIN issues ON borrowers.borrowernumber=issues.borrowernumber GROUP BY borrowernumber "; --