View | Details | Raw Unified | Return to bug 27893
Collapse All | Expand All

(-)a/cataloguing/addbiblio.pl (-6 / +21 lines)
Lines 20-28 Link Here
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
21
22
use Modern::Perl;
22
use Modern::Perl;
23
24
use CGI;
23
use CGI;
25
use POSIX;
24
use POSIX;
25
use Try::Tiny qw(catch try);
26
26
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Auth qw( get_template_and_user haspermission );
28
use C4::Auth qw( get_template_and_user haspermission );
28
use C4::Biblio qw(
29
use C4::Biblio qw(
Lines 48-53 use C4::Charset qw( SetMarcUnicodeFlag ); Link Here
48
use Koha::BiblioFrameworks;
49
use Koha::BiblioFrameworks;
49
use Koha::DateUtils qw( dt_from_string );
50
use Koha::DateUtils qw( dt_from_string );
50
51
52
use Koha::Acquisition::Orders;
51
use Koha::Biblios;
53
use Koha::Biblios;
52
use Koha::ItemTypes;
54
use Koha::ItemTypes;
53
use Koha::Libraries;
55
use Koha::Libraries;
Lines 779-793 if ( $op eq "cud-addbiblio" ) { Link Here
779
        );
781
        );
780
    }
782
    }
781
}
783
}
782
elsif ( $op eq "cud-delete" ) {
783
    
784
    
784
    my $error = &DelBiblio($biblionumber);
785
elsif ( $op eq "cud-delete" ) {
786
787
    # Cancel attached order lines first before deleting biblio !
788
    my $error;
789
    try {
790
        my @result = Koha::Acquisition::Orders->search( { biblionumber => $biblionumber } )->cancel;
791
        my $warns  = @{ $result[1] };
792
        if ( $result[0] && $warns ) {    # warnings about order lines not removed
793
            warn sprintf( "%d order lines were deleted, but %d lines gave a warning\n", $result[0], $warns );
794
        }
795
        $error = &DelBiblio($biblionumber);
796
    } catch {
797
        $error = ref($_) ? 'Exception raised - ' . $_->error : $_;
798
    };
799
785
    if ($error) {
800
    if ($error) {
801
        #FIXME This should be handled in template alert
786
        warn "ERROR when DELETING BIBLIO $biblionumber : $error";
802
        warn "ERROR when DELETING BIBLIO $biblionumber : $error";
787
        print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
803
        print "Content-Type: text/html\n\n<html><body><h1>ERROR when DELETING BIBLIO $biblionumber : $error</h1></body></html>";
788
	exit;
804
        exit;
789
    }
805
    }
790
    
806
791
    print $input->redirect('/cgi-bin/koha/catalogue/search.pl' . ($searchid ? "?searchid=$searchid" : ""));
807
    print $input->redirect('/cgi-bin/koha/catalogue/search.pl' . ($searchid ? "?searchid=$searchid" : ""));
792
    exit;
808
    exit;
793
    
809
    
794
- 

Return to bug 27893