@EXPORT = qw(
&GetBookSeller &GetBooksellersWithLateOrders
&ModBookseller
+ &DelBookseller
&AddBookseller
);
my $sth =$dbh->prepare($query);
$sth->execute("$searchstring%", $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=?");
while ( my $data = $sth->fetchrow_hashref ) {
+ $sth2->execute($data->{id});
+ ($data->{basketcount}) = $sth2->fetchrow();
+ warn "COUNT : ".$data->{basketcount};
push( @results, $data );
}
$sth->finish;
$sth->finish;
}
+=head2 DelBookseller
+
+&DelBookseller($booksellerid);
+
+delete the supplier identified by $booksellerid
+This sub can be called only if the supplier has no order.
+
+=cut
+sub DelBookseller {
+ my ($id) = @_;
+ my $dbh=C4::Context->dbh;
+ my $sth=$dbh->prepare("DELETE FROM aqbooksellers WHERE id=?");
+ $sth->execute($id);
+}
END { } # module clean-up code here (global destructor)
1;
invoiceprice=>$booksellers[0]->{'invoiceprice'},
listprice=>$booksellers[0]->{'listprice'},
GST => C4::Context->preference("gist"),
+ basketcount =>$booksellers[0]->{'basketcount'},
);
-}else{
+} elsif ($op eq 'delete') {
+ &DelBookseller($id);
+ print $query->redirect("/cgi-bin/koha/acqui/acqui-home.pl");
+ exit;
+} else {
my @currencies = GetCurrencies();
my $count = scalar @currencies;
<!--TMPL_ELSE-->
<h1>Information for : <!-- TMPL_VAR NAME="name" --></h1>
<div id="action">
- <a href="supplier.pl?supplierid=<!--TMPL_VAR Name="id"-->&op=enter">
- Edit Supplier
- </a>
- <a href="booksellers.pl?supplier=<!--TMPL_VAR Name="id"-->">
- Manage Orders
- </a>
- <a href="parcels.pl?supplierid=<!--TMPL_VAR Name="id"-->">
- Receive Parcel
- </a>
+ <div class="edit">
+ <a href="supplier.pl?supplierid=<!--TMPL_VAR Name="id"-->&op=enter">
+ Edit Supplier
+ </a>
+ <!-- TMPL_UNLESS name="basketcount" -->
+ <a href="javascript:confirm_deletion()">
+ Delete Supplier
+ </a>
+ <!-- /TMPL_UNLESS -->
+ </div>
+ <div class="view">
+ <a href="booksellers.pl?supplier=<!--TMPL_VAR Name="id"-->">
+ Manage Orders
+ </a>
+ <a href="parcels.pl?supplierid=<!--TMPL_VAR Name="id"-->">
+ Receive Parcel
+ </a>
+ </div>
</div>
<fieldset>
<legend>Company details</legend>
</fieldset>
</div>
<!--/TMPL_IF-->
-
+<script>
+function confirm_deletion() {
+ if (confirm("Confirm deletion of this supplier ?")) {
+ window.location="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!--TMPL_VAR Name="id"-->&op=delete";
+ }
+}
+</script>
<!-- TMPL_INCLUDE name="intranet-bottom.inc" -->