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

(-)a/C4/Biblio.pm (-2 / +8 lines)
Lines 306-313 sub AddBiblio { Link Here
306
            $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
306
            $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
307
        }
307
        }
308
    } catch {
308
    } catch {
309
        warn $_;
309
        my $error = $_;
310
        ( $biblionumber, $biblioitemnumber ) = ( undef, undef );
310
        if ( ref($error) eq 'Koha::Exceptions::Metadata::Invalid' ) {
311
            ( $biblionumber, $biblioitemnumber ) = ( undef, undef );
312
            $error->rethrow;
313
        } else {
314
            warn $error;
315
            ( $biblionumber, $biblioitemnumber ) = ( undef, undef );
316
        }
311
    };
317
    };
312
    return ( $biblionumber, $biblioitemnumber );
318
    return ( $biblionumber, $biblioitemnumber );
313
}
319
}
(-)a/cataloguing/addbiblio.pl (-51 / +73 lines)
Lines 22-27 Link Here
22
use Modern::Perl;
22
use Modern::Perl;
23
23
24
use CGI;
24
use CGI;
25
use Try::Tiny;
26
25
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
26
use C4::Auth qw( get_template_and_user haspermission );
28
use C4::Auth qw( get_template_and_user haspermission );
27
use C4::Biblio qw(
29
use C4::Biblio qw(
Lines 665-710 if ( $op eq "addbiblio" ) { Link Here
665
    # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
667
    # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
666
    if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
668
    if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
667
        my $oldbibitemnum;
669
        my $oldbibitemnum;
668
        if ( $is_a_modif ) {
670
        my $encode_error = try {
669
            my $member = Koha::Patrons->find($loggedinuser);
671
            if ($is_a_modif) {
670
            ModBiblio(
672
                my $member = Koha::Patrons->find($loggedinuser);
671
                $record,
673
                ModBiblio(
672
                $biblionumber,
674
                    $record,
673
                $frameworkcode,
675
                    $biblionumber,
674
                {
676
                    $frameworkcode,
675
                    overlay_context => {
677
                    {
676
                        source       => $z3950 ? 'z3950' : 'intranet',
678
                        overlay_context => {
677
                        categorycode => $member->categorycode,
679
                            source       => $z3950 ? 'z3950' : 'intranet',
678
                        userid       => $member->userid
680
                            categorycode => $member->categorycode,
681
                            userid       => $member->userid
682
                        }
679
                    }
683
                    }
680
                }
684
                );
681
            );
685
            } else {
682
        }
686
                ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
683
        else {
687
            }
684
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
688
            return 0;
685
        }
689
        } catch {
686
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
690
            my $exception = $_;
691
            if ( ref($exception) eq 'Koha::Exceptions::Metadata::Invalid' ) {
692
                $template->param( INVALID_METADATA => $exception );
693
            } else {
694
                $exception->rethrow;
695
            }
696
            return 1;
697
        };
698
        if (!$encode_error && ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save"))){
687
	    if ($frameworkcode eq 'FA'){
699
	    if ($frameworkcode eq 'FA'){
688
		print $input->redirect(
700
		print $input->redirect(
689
            '/cgi-bin/koha/cataloguing/additem.pl?'
701
                '/cgi-bin/koha/cataloguing/additem.pl?'
690
            .'biblionumber='.$biblionumber
702
                .'biblionumber='.$biblionumber
691
            .'&frameworkcode='.$frameworkcode
703
                .'&frameworkcode='.$frameworkcode
692
            .'&circborrowernumber='.$fa_circborrowernumber
704
                .'&circborrowernumber='.$fa_circborrowernumber
693
            .'&branch='.$fa_branch
705
                .'&branch='.$fa_branch
694
            .'&barcode='.uri_escape_utf8($fa_barcode)
706
                .'&barcode='.uri_escape_utf8($fa_barcode)
695
            .'&stickyduedate='.$fa_stickyduedate
707
                .'&stickyduedate='.$fa_stickyduedate
696
            .'&duedatespec='.$fa_duedatespec
708
                .'&duedatespec='.$fa_duedatespec
697
		);
709
		);
698
		exit;
710
		exit;
699
	    }
711
	    }
700
	    else {
712
	    else {
701
		print $input->redirect(
713
		print $input->redirect(
702
                "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"
714
                    "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"
703
		);
715
		);
704
		exit;
716
		exit;
705
	    }
717
	    }
706
        }
718
        }
707
    elsif(($is_a_modif || $redirect eq "view") && $redirect ne "just_save"){
719
        elsif(!$encode_error && (($is_a_modif || $redirect eq "view") && $redirect ne "just_save")){
708
            my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
720
            my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
709
            my $views = { C4::Search::enabled_staff_search_views };
721
            my $views = { C4::Search::enabled_staff_search_views };
710
            if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
722
            if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
Lines 717-744 if ( $op eq "addbiblio" ) { Link Here
717
                print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&searchid=$searchid");
729
                print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&searchid=$searchid");
718
            }
730
            }
719
            exit;
731
            exit;
720
732
        }
721
    }
733
        elsif (!$encode_error && ($redirect eq "just_save")){
722
    elsif ($redirect eq "just_save"){
734
            my $tab = $input->param('current_tab');
723
        my $tab = $input->param('current_tab');
735
            print $input->redirect("/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber&framework=$frameworkcode&tab=$tab&searchid=$searchid");
724
        print $input->redirect("/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber&framework=$frameworkcode&tab=$tab&searchid=$searchid");
736
        }
725
    }
737
        elsif ($encode_error) {
726
    else {
738
            build_tabs ($template, $record, $dbh,$encoding,$input);
727
          $template->param(
739
            $template->param(
728
            biblionumber => $biblionumber,
740
                biblionumber             => $biblionumber,
729
            done         =>1,
741
                popup => $mode,
730
            popup        =>1
742
                frameworkcode => $frameworkcode,
731
          );
743
                itemtype => $frameworkcode,
732
          if ( $record ne '-1' ) {
744
                borrowernumber => $loggedinuser,
733
              my $title = C4::Context->preference('marcflavour') eq "UNIMARC" ? $record->subfield('200', 'a') : $record->title;
745
                tab => scalar $input->param('tab')
734
              $template->param( title => $title );
746
            );
735
          }
747
            output_html_with_http_headers $input, $cookie, $template->output;
736
          $template->param(
748
            exit;
737
            popup => $mode,
749
        } else {
738
            itemtype => $frameworkcode,
750
              $template->param(
739
          );
751
                biblionumber => $biblionumber,
740
          output_html_with_http_headers $input, $cookie, $template->output;
752
                done         =>1,
741
          exit;     
753
                popup        =>1
754
              );
755
              if ( $record ne '-1' ) {
756
                  my $title = C4::Context->preference('marcflavour') eq "UNIMARC" ? $record->subfield('200', 'a') : $record->title;
757
                  $template->param( title => $title );
758
              }
759
              $template->param(
760
                popup => $mode,
761
                itemtype => $frameworkcode,
762
              );
763
              output_html_with_http_headers $input, $cookie, $template->output;
764
              exit;
742
        }
765
        }
743
    } else {
766
    } else {
744
    # it may be a duplicate, warn the user and do nothing
767
    # it may be a duplicate, warn the user and do nothing
745
- 

Return to bug 35104