Lines 74-80
the supplier this script have to display the basket.
Link Here
|
74 |
|
74 |
|
75 |
=cut |
75 |
=cut |
76 |
|
76 |
|
77 |
our $query = new CGI; |
77 |
our $query = CGI->new; |
78 |
our $basketno = $query->param('basketno'); |
78 |
our $basketno = $query->param('basketno'); |
79 |
our $ean = $query->param('ean'); |
79 |
our $ean = $query->param('ean'); |
80 |
our $booksellerid = $query->param('booksellerid'); |
80 |
our $booksellerid = $query->param('booksellerid'); |
Lines 128-172
if ( $op eq 'delete_confirm' ) {
Link Here
|
128 |
output_and_exit( $query, $cookie, $template, 'insufficient_permission' ) |
128 |
output_and_exit( $query, $cookie, $template, 'insufficient_permission' ) |
129 |
unless $logged_in_patron->has_permission( { acquisition => 'delete_baskets' } ); |
129 |
unless $logged_in_patron->has_permission( { acquisition => 'delete_baskets' } ); |
130 |
|
130 |
|
131 |
my $basketno = $query->param('basketno'); |
131 |
my $basketno = $query->param('basketno'); |
132 |
my $delbiblio = $query->param('delbiblio'); |
132 |
my $delbiblio = $query->param('delbiblio'); |
133 |
my @orders = GetOrders($basketno); |
133 |
my $basket_obj = Koha::Acquisition::Baskets->find($basketno); |
134 |
#Delete all orders included in that basket, and all items received. |
134 |
|
135 |
foreach my $myorder (@orders){ |
135 |
my $orders = $basket_obj->orders; |
136 |
DelOrder($myorder->{biblionumber},$myorder->{ordernumber}); |
136 |
|
137 |
} |
137 |
my @cannotdelbiblios; |
138 |
# if $delbiblio = 1, delete the records if possible |
138 |
|
139 |
if ((defined $delbiblio)and ($delbiblio ==1)){ |
139 |
while ( my $order = $orders->next ) { |
140 |
my @cannotdelbiblios ; |
140 |
# cancel the order |
141 |
foreach my $myorder (@orders){ |
141 |
$order->cancel({ delete_biblio => $delbiblio }); |
142 |
my $biblionumber = $myorder->{'biblionumber'}; |
142 |
my @messages = @{ $order->messages }; |
143 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
143 |
|
144 |
my $countbiblio = $biblio->active_orders->count; |
144 |
if ( scalar @messages > 0 ) { |
145 |
my $ordernumber = $myorder->{'ordernumber'}; |
145 |
|
146 |
my $cnt_subscriptions = $biblio->subscriptions->count; |
146 |
my $biblio = $order->biblio; |
147 |
my $itemcount = $biblio->items->count; |
147 |
|
148 |
my $error; |
148 |
push @cannotdelbiblios, { |
149 |
if ($countbiblio == 0 && $itemcount == 0 && not $cnt_subscriptions ) { |
149 |
biblionumber => $biblio->id, |
150 |
$error = DelBiblio($myorder->{biblionumber}) } |
150 |
title => $biblio->title // '', |
151 |
else { |
151 |
author => $biblio->author // '', |
152 |
push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}), |
152 |
countbiblio => $biblio->active_orders->count, |
153 |
title=> $myorder->{'title'}, |
153 |
itemcount => $biblio->items->count, |
154 |
author=> $myorder->{'author'}, |
154 |
subscriptions => $biblio->subscriptions->count, |
155 |
countbiblio=> $countbiblio, |
155 |
}; |
156 |
itemcount=>$itemcount, |
|
|
157 |
subscriptions => $cnt_subscriptions}; |
158 |
} |
159 |
if ($error) { |
160 |
push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}), |
161 |
title=> $myorder->{'title'}, |
162 |
author=> $myorder->{'author'}, |
163 |
othererror=> $error}; |
164 |
} |
165 |
} |
156 |
} |
166 |
$template->param( cannotdelbiblios => \@cannotdelbiblios ); |
|
|
167 |
} |
157 |
} |
168 |
# delete the basket |
158 |
|
169 |
DelBasket($basketno,); |
159 |
$template->param( cannotdelbiblios => \@cannotdelbiblios ); |
|
|
160 |
|
161 |
# delete the basket |
162 |
$basket_obj->delete; |
170 |
$template->param( |
163 |
$template->param( |
171 |
delete_confirmed => 1, |
164 |
delete_confirmed => 1, |
172 |
booksellername => $bookseller->name, |
165 |
booksellername => $bookseller->name, |