From fb1e47e43584fe8459b4f87b444f75d1b3b6541e Mon Sep 17 00:00:00 2001 From: hdl Date: Wed, 25 Apr 2007 13:38:00 +0000 Subject: [PATCH] Deleting GetMembersFromSurname Using SearchMember instead. --- C4/Members.pm | 83 +++++++++++++--------------------------- serials/distributedto.pl | 2 +- 2 files changed, 27 insertions(+), 58 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 703a6ac651..3c95f88379 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -73,17 +73,16 @@ push @EXPORT, qw( &GetCities &GetRoadTypes &GetRoadTypeDetails + &GetSortDetails + &GetTitles &GetMemberAccountRecords + &GetBorNotifyAcctRecord &GetborCatFromCatType &GetBorrowercategory - &GetBorNotifyAcctRecord - &ExtendMemberSubscriptionTo - &GetSortDetails - &GetTitles &GetBorrowersWhoHaveNotBorrowedSince &GetBorrowersWhoHaveNeverBorrowed &GetBorrowersWithIssuesHistoryOlderThan @@ -95,7 +94,6 @@ push @EXPORT, qw( #Modify data push @EXPORT, qw( &ModMember - &fixup_cardnumber &changepassword ); @@ -106,16 +104,20 @@ push @EXPORT, qw( #Insert data push @EXPORT, qw( - &AddMember + &AddMember + &add_member_orgs + &MoveMemberToDeleted + &ExtendMemberSubscriptionTo +); + +#Check data +push @EXPORT, qw( &checkuniquemember &checkuserpassword &fixEthnicity ðnicitycategories - &add_member_orgs - - &MoveMemberToDeleted + &fixup_cardnumber ); - =item SearchMember ($count, $borrowers) = &SearchMember($searchstring, $type,$category_type); @@ -197,14 +199,10 @@ sub SearchMember { # warn "Q $orderby : $query"; $sth->execute(@bind); my @results; - my $cnt = $sth->rows; - while ( my $data = $sth->fetchrow_hashref ) { - push( @results, $data ); - } + my $data = $sth->fetchall_arrayref({}); - # $sth->execute; $sth->finish; - return ( $cnt, \@results ); + return ( scalar(@$data), $data ); } =head2 GetMemberDetails @@ -1352,7 +1350,9 @@ sub GetBorrowercategory { my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( -"SELECT description,dateofbirthrequired,upperagelimit,category_type FROM categories WHERE categorycode = ?" +"SELECT description,dateofbirthrequired,upperagelimit,category_type + FROM categories + WHERE categorycode = ?" ); $sth->execute($catcode); my $data = @@ -1486,39 +1486,6 @@ sub add_member_orgs { =head2 GetMembersFromSurname -=over 4 - -\@resutlts = GetMembersFromSurname($surname) -this function get the list of borrower names like $surname. -return : -the table of results in @results - -=back - -=cut - -sub GetMembersFromSurname { - my ($searchstring) = @_; - my $dbh = C4::Context->dbh; - $searchstring =~ s/\'/\\\'/g; - my @data = split( ' ', $searchstring ); - my $count = @data; - my $query = qq| - SELECT surname,firstname - FROM borrowers - WHERE (surname like ?) - ORDER BY surname - |; - my $sth = $dbh->prepare($query); - $sth->execute("$data[0]%"); - my @results; - $count = 0; - - my $data = $sth->fetchall_arrayref({}); - $sth->finish; - return ( scalar(@$data), $data ); -} - =head2 GetCities (OUEST-PROVENCE) ($id_cityarrayref, $city_hashref) = &GetCities(); @@ -1609,7 +1576,7 @@ sub MoveMemberToDeleted { my @data = $sth->fetchrow_array; $sth->finish; $sth = - $dbh->prepare( "Insert into deletedborrowers values (" + $dbh->prepare( "INSERT INTO deletedborrowers VALUES (" . ( "?," x ( scalar(@data) - 1 ) ) . "?)" ); $sth->execute(@data); @@ -1684,9 +1651,10 @@ codes, and a reference-to-hash, which maps the road type of the road . sub GetRoadTypes { my $dbh = C4::Context->dbh; - my $query = qq|SELECT roadtypeid,road_type - FROM roadtype - ORDER BY road_type|; + my $query = qq| +SELECT roadtypeid,road_type +FROM roadtype +ORDER BY road_type|; my $sth = $dbh->prepare($query); $sth->execute(); my %roadtype; @@ -1743,9 +1711,10 @@ C<&$roadtypeid>this is the value of roadtype s sub GetRoadTypeDetails { my ($roadtypeid) = @_; my $dbh = C4::Context->dbh; - my $query = qq|SELECT road_type - FROM roadtype - WHERE roadtypeid=?|; + my $query = qq| +SELECT road_type +FROM roadtype +WHERE roadtypeid=?|; my $sth = $dbh->prepare($query); $sth->execute($roadtypeid); my $roadtype = $sth->fetchrow; diff --git a/serials/distributedto.pl b/serials/distributedto.pl index d9550a9124..8cf6aa0816 100755 --- a/serials/distributedto.pl +++ b/serials/distributedto.pl @@ -79,7 +79,7 @@ my ($template, $borrowernumber, $cookie) debug => 1, }); -my ($count,$results)=GetMembersFromSurname($searchfield) if $searchfield; +my ($count,$results)=SearchMember($searchfield,"firstname","simple",) if $searchfield; my $toggle="0"; my @loop_data =(); for (my $i=0; $i < $count; $i++){ -- 2.20.1