Fix for bug 1791
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
parent
1978babc9f
commit
18b8a1c659
|
|
@ -26,7 +26,7 @@ BEGIN {
|
|||
$VERSION = 3.01;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
&GetBookSeller &GetBooksellersWithLateOrders
|
||||
&GetBookSeller &GetBooksellersWithLateOrders &GetBookSellerFromId
|
||||
&ModBookseller
|
||||
&DelBookseller
|
||||
&AddBookseller
|
||||
|
|
@ -65,17 +65,13 @@ aqbooksellers table in the Koha database.
|
|||
sub GetBookSeller {
|
||||
my ($searchstring) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "
|
||||
SELECT *
|
||||
FROM aqbooksellers
|
||||
WHERE name LIKE ? OR id = ?
|
||||
";
|
||||
my $query = "SELECT * FROM aqbooksellers WHERE name LIKE ?";
|
||||
my $sth =$dbh->prepare($query);
|
||||
$sth->execute("$searchstring%", $searchstring );
|
||||
$sth->execute( "$searchstring%" );
|
||||
my @results;
|
||||
# count how many baskets this bookseller has.
|
||||
# if it has none, the bookseller can be deleted
|
||||
my $sth2 = $dbh->prepare("select count(*) from aqbasket where booksellerid=?");
|
||||
my $sth2 = $dbh->prepare("SELECT count(*) FROM aqbasket WHERE booksellerid=?");
|
||||
while ( my $data = $sth->fetchrow_hashref ) {
|
||||
$sth2->execute($data->{id});
|
||||
($data->{basketcount}) = $sth2->fetchrow();
|
||||
|
|
@ -86,6 +82,24 @@ sub GetBookSeller {
|
|||
}
|
||||
|
||||
|
||||
sub GetBookSellerFromId {
|
||||
my ($id) = @_;
|
||||
my $dbh = C4::Context->dbh();
|
||||
my $query = "SELECT * FROM aqbooksellers WHERE id = ?";
|
||||
my $sth =$dbh->prepare($query);
|
||||
$sth->execute( $id );
|
||||
if (my $data = $sth->fetchrow_hashref()){
|
||||
my $sth2 = $dbh->prepare("SELECT count(*) FROM aqbasket WHERE booksellerid=?");
|
||||
$sth2->execute($id);
|
||||
$data->{basketcount}=$sth2->fetchrow();
|
||||
$sth->finish;
|
||||
$sth2->finish;
|
||||
return ($data);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#-----------------------------------------------------------------#
|
||||
|
||||
=head2 GetBooksellersWithLateOrders
|
||||
|
|
|
|||
|
|
@ -86,13 +86,12 @@ my $basket = GetBasket($basketno);
|
|||
# if no booksellerid in parameter, get it from basket
|
||||
# warn "=>".$basket->{booksellerid};
|
||||
$booksellerid = $basket->{booksellerid} unless $booksellerid;
|
||||
my @booksellers = GetBookSeller($booksellerid);
|
||||
my $count2 = scalar @booksellers;
|
||||
# FIXME: do something with count2?
|
||||
# FIXME: how do you know the first BookSeller in the array is the one you want?
|
||||
# FIXME: GetBookSeller should be changing to reliably return 1 record based on ID,
|
||||
# but we still should give some kind of Error back to the user if it fails.
|
||||
my ($bookseller) = GetBookSellerFromId($booksellerid);
|
||||
|
||||
if (! $bookseller){
|
||||
$template->param( NO_BOOKSELLER => 1 );
|
||||
}
|
||||
else {
|
||||
# get librarian branch...
|
||||
if ( C4::Context->preference("IndependantBranches") ) {
|
||||
my $userenv = C4::Context->userenv;
|
||||
|
|
@ -164,7 +163,7 @@ my $prefgist = C4::Context->preference("gist");
|
|||
$gist = sprintf( "%.2f", $sub_total * $prefgist );
|
||||
$grand_total = $sub_total;
|
||||
$grand_total_est = $sub_total_est;
|
||||
unless ($booksellers[0]->{'listincgst'}) {
|
||||
unless ($bookseller->{'listincgst'}) {
|
||||
$grand_total += $gist;
|
||||
$grand_total_est += sprintf( "%.2f", $sub_total_est * $prefgist );
|
||||
}
|
||||
|
|
@ -176,13 +175,13 @@ $template->param(
|
|||
authorisedby => $basket->{authorisedby},
|
||||
authorisedbyname => $basket->{authorisedbyname},
|
||||
closedate => format_date( $basket->{closedate} ),
|
||||
active => $booksellers[0]->{'active'},
|
||||
booksellerid => $booksellers[0]->{'id'},
|
||||
name => $booksellers[0]->{'name'},
|
||||
address1 => $booksellers[0]->{'address1'},
|
||||
address2 => $booksellers[0]->{'address2'},
|
||||
address3 => $booksellers[0]->{'address3'},
|
||||
address4 => $booksellers[0]->{'address4'},
|
||||
active => $bookseller->{'active'},
|
||||
booksellerid => $bookseller->{'id'},
|
||||
name => $bookseller->{'name'},
|
||||
address1 => $bookseller->{'address1'},
|
||||
address2 => $bookseller->{'address2'},
|
||||
address3 => $bookseller->{'address3'},
|
||||
address4 => $bookseller->{'address4'},
|
||||
entrydate => format_date( $results[0]->{'entrydate'} ),
|
||||
books_loop => \@books_loop,
|
||||
count => $count,
|
||||
|
|
@ -193,8 +192,9 @@ $template->param(
|
|||
gist_est => $gist_est,
|
||||
grand_total_est => $grand_total_est,
|
||||
grand_total_rrp => $grand_total_rrp,
|
||||
currency => $booksellers[0]->{'listprice'},
|
||||
currency => $bookseller->{'listprice'},
|
||||
qty_total => $qty_total,
|
||||
GST => $prefgist,
|
||||
);
|
||||
}
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@
|
|||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
|
||||
<!-- TMPL_IF NAME="NO_BOOKSELLER" -->
|
||||
<h2>Supplier Not Found</h2>
|
||||
<!-- TMPL_ELSE -->
|
||||
<h1><!-- TMPL_UNLESS name="basketno" -->New <!-- /TMPL_UNLESS -->Basket <!-- TMPL_VAR NAME="basketno" --> for <a href="supplier.pl?supplierid=<!-- TMPL_VAR NAME="booksellerid" -->"><!-- TMPL_VAR NAME="name" --></a></h1>
|
||||
|
||||
<!-- TMPL_IF NAME="basketno" --><div id="acqui_basket_summary">
|
||||
|
|
@ -148,7 +150,7 @@
|
|||
</form>
|
||||
</div>
|
||||
<!-- /TMPL_UNLESS -->
|
||||
|
||||
<!-- /TMPL_IF -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui-b">
|
||||
|
|
|
|||
Loading…
Reference in New Issue