-=head2 GetBookSeller
-
-@results = GetBookSeller($searchstring);
-
-Looks up a book seller. C<$searchstring> may be either a book seller
-ID, or a string to look for in the book seller's name.
-
-C<@results> is an array of hash_refs whose keys are the fields of of the
-aqbooksellers table in the Koha database.
-
-=cut
-
-sub GetBookSeller {
- my $searchstring = shift;
- $searchstring = q{%} . $searchstring . q{%};
- my $query =
-'select aqbooksellers.*, count(*) as basketcount from aqbooksellers left join aqbasket '
- . 'on aqbasket.booksellerid = aqbooksellers.id where name like ? group by aqbooksellers.id order by name';
-
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare($query);
- $sth->execute($searchstring);
- my $resultset_ref = $sth->fetchall_arrayref( {} );
- return @{$resultset_ref};
-}
-
-sub GetBookSellerFromId {
- my $id = shift or return;
- my $dbh = C4::Context->dbh;
- my $vendor =
- $dbh->selectrow_hashref( 'SELECT * FROM aqbooksellers WHERE id = ?',
- {}, $id );
- if ($vendor) {
- ( $vendor->{basketcount} ) = $dbh->selectrow_array(
- 'SELECT count(*) FROM aqbasket where booksellerid = ?',
- {}, $id );
- ( $vendor->{subscriptioncount} ) = $dbh->selectrow_array(
- 'SELECT count(*) FROM subscription WHERE aqbooksellerid = ?',
- {}, $id );
- }
- return $vendor;
-}
-
-#-----------------------------------------------------------------#
-