X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=acqui%2Fbasket.pl;h=e5469480cc8c15790135d4d8b3495a70cde6e664;hb=fb4025b67b45e60154f67b9acca3d56e4f5eb7c5;hp=df377887e4c3e7fcd97e74dc2101ca17cb4d887a;hpb=09953f836de01a68a3117227965719b74f543844;p=koha_fer diff --git a/acqui/basket.pl b/acqui/basket.pl index df377887e4..e5469480cc 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -115,20 +115,36 @@ if ( $op eq 'delete_confirm' ) { #Delete all orders included in that basket, and all items received. foreach my $myorder (@orders){ DelOrder($myorder->{biblionumber},$myorder->{ordernumber}); - warn "suppression de ".$myorder->{biblionumber}.' '.$myorder->{ordernumber}; } # if $delbiblio = 1, delete the records if possible if ((defined $delbiblio)and ($delbiblio ==1)){ + my @cannotdelbiblios ; foreach my $myorder (@orders){ my $biblionumber = $myorder->{'biblionumber'}; my $countbiblio = CountBiblioInOrders($biblionumber); my $ordernumber = $myorder->{'ordernumber'}; - my @subscriptions = GetSubscriptionsId ($biblionumber); + my $subscriptions = scalar GetSubscriptionsId ($biblionumber); my $itemcount = GetItemsCount($biblionumber); - DelBiblio($myorder->{biblionumber}) if ($countbiblio == 0 && $itemcount == 0 && !(@subscriptions)); - warn "suppression de la notice ".$myorder->{biblionumber}}; + my $error; + if ($countbiblio == 0 && $itemcount == 0 && $subscriptions == 0) { + $error = DelBiblio($myorder->{biblionumber}) } + else { + push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}), + title=> $myorder->{'title'}, + author=> $myorder->{'author'}, + countbiblio=> $countbiblio, + itemcount=>$itemcount, + subscriptions=>$subscriptions}; + } + if ($error) { + push @cannotdelbiblios, {biblionumber=> ($myorder->{biblionumber}), + title=> $myorder->{'title'}, + author=> $myorder->{'author'}, + othererror=> $error}; + } + } + $template->param( cannotdelbiblios => \@cannotdelbiblios ); } - # delete the basket DelBasket($basketno,); $template->param( delete_confirmed => 1 ); @@ -138,7 +154,7 @@ if ( $op eq 'delete_confirm' ) { $template->param( delete_confirm => 1 ); if ( C4::Context->preference("IndependentBranches") ) { my $userenv = C4::Context->userenv; - unless ( $userenv->{flags} == 1 ) { + unless ( C4::Context->IsSuperLibrarian() ) { my $validtest = ( $basket->{creationdate} eq '' ) || ( $userenv->{branch} eq $basket->{branch} ) || ( $userenv->{branch} eq '' ) @@ -241,7 +257,7 @@ if ( $op eq 'delete_confirm' ) { # get librarian branch... if ( C4::Context->preference("IndependentBranches") ) { my $userenv = C4::Context->userenv; - unless ( $userenv->{flags} == 1 ) { + unless ( C4::Context->IsSuperLibrarian() ) { my $validtest = ( $basket->{creationdate} eq '' ) || ( $userenv->{branch} eq $basket->{branch} ) || ( $userenv->{branch} eq '' )