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

(-)a/cataloguing/addbiblio.pl (-43 / +60 lines)
Lines 56-61 use Koha::Patrons; Link Here
56
use MARC::File::USMARC;
56
use MARC::File::USMARC;
57
use MARC::File::XML;
57
use MARC::File::XML;
58
use URI::Escape qw( uri_escape_utf8 );
58
use URI::Escape qw( uri_escape_utf8 );
59
use Business::ISBN qw( valid_isbn_checksum );
59
60
60
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
61
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
61
    MARC::File::XML->default_record_format('UNIMARC');
62
    MARC::File::XML->default_record_format('UNIMARC');
Lines 862-869 if ( $op eq "addbiblio" ) { Link Here
862
        ( $duplicatebiblionumber, $duplicatetitle ) = FindDuplicate($record);
863
        ( $duplicatebiblionumber, $duplicatetitle ) = FindDuplicate($record);
863
    }
864
    }
864
    my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
865
    my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
866
    my @input_isbns = ( C4::Context->preference('marcflavour') eq "UNIMARC" ) ? $record->subfield('010','a') : $record->subfield('020','a');
867
    my $valid_isbn = 1;
868
    if ( C4::Context->preference('ValidateISBN') ) {
869
        foreach my $input_isbn ( @input_isbns ) {
870
            $valid_isbn = valid_isbn_checksum( $input_isbn );
871
            unless ( $valid_isbn ) {
872
                last;
873
            }
874
        }
875
    }
876
    my $bypass_isbn = C4::Context->preference('ValidateISBN') ? $input->param('bypass_isbn') : 1;
865
    # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
877
    # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
866
    if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
878
    if ( ( !$duplicatebiblionumber or $confirm_not_duplicate ) and ( $valid_isbn or $bypass_isbn ) ) {
867
        my $oldbibitemnum;
879
        my $oldbibitemnum;
868
        if ( $is_a_modif ) {
880
        if ( $is_a_modif ) {
869
            my $member = Koha::Patrons->find($loggedinuser);
881
            my $member = Koha::Patrons->find($loggedinuser);
Lines 884-910 if ( $op eq "addbiblio" ) { Link Here
884
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
896
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
885
        }
897
        }
886
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
898
        if ($redirect eq "items" || ($mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save")){
887
	    if ($frameworkcode eq 'FA'){
899
            if ($frameworkcode eq 'FA'){
888
		print $input->redirect(
900
                print $input->redirect(
889
            '/cgi-bin/koha/cataloguing/additem.pl?'
901
                    '/cgi-bin/koha/cataloguing/additem.pl?'
890
            .'biblionumber='.$biblionumber
902
                    .'biblionumber='.$biblionumber
891
            .'&frameworkcode='.$frameworkcode
903
                    .'&frameworkcode='.$frameworkcode
892
            .'&circborrowernumber='.$fa_circborrowernumber
904
                    .'&circborrowernumber='.$fa_circborrowernumber
893
            .'&branch='.$fa_branch
905
                    .'&branch='.$fa_branch
894
            .'&barcode='.uri_escape_utf8($fa_barcode)
906
                    .'&barcode='.uri_escape_utf8($fa_barcode)
895
            .'&stickyduedate='.$fa_stickyduedate
907
                    .'&stickyduedate='.$fa_stickyduedate
896
            .'&duedatespec='.$fa_duedatespec
908
                    .'&duedatespec='.$fa_duedatespec
897
		);
909
                );
898
		exit;
910
                exit;
899
	    }
911
            }
900
	    else {
912
            else {
901
		print $input->redirect(
913
                print $input->redirect(
902
                "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"
914
                    "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"
903
		);
915
                );
904
		exit;
916
                exit;
905
	    }
917
            }
906
        }
918
        }
907
    elsif(($is_a_modif || $redirect eq "view") && $redirect ne "just_save"){
919
        elsif(($is_a_modif || $redirect eq "view") && $redirect ne "just_save"){
908
            my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
920
            my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
909
            my $views = { C4::Search::enabled_staff_search_views };
921
            my $views = { C4::Search::enabled_staff_search_views };
910
            if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
922
            if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
Lines 917-945 if ( $op eq "addbiblio" ) { Link Here
917
                print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&searchid=$searchid");
929
                print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber&searchid=$searchid");
918
            }
930
            }
919
            exit;
931
            exit;
920
921
    }
922
    elsif ($redirect eq "just_save"){
923
        my $tab = $input->param('current_tab');
924
        print $input->redirect("/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber&framework=$frameworkcode&tab=$tab&searchid=$searchid");
925
    }
926
    else {
927
          $template->param(
928
            biblionumber => $biblionumber,
929
            done         =>1,
930
            popup        =>1
931
          );
932
          if ( $record ne '-1' ) {
933
              my $title = C4::Context->preference('marcflavour') eq "UNIMARC" ? $record->subfield('200', 'a') : $record->title;
934
              $template->param( title => $title );
935
          }
936
          $template->param(
937
            popup => $mode,
938
            itemtype => $frameworkcode,
939
          );
940
          output_html_with_http_headers $input, $cookie, $template->output;
941
          exit;     
942
        }
932
        }
933
        elsif ($redirect eq "just_save"){
934
            my $tab = $input->param('current_tab');
935
            print $input->redirect("/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=$biblionumber&framework=$frameworkcode&tab=$tab&searchid=$searchid");
936
        }
937
        else {
938
            $template->param(
939
                biblionumber => $biblionumber,
940
                done         =>1,
941
                popup        =>1
942
            );
943
            if ( $record ne '-1' ) {
944
                my $title = C4::Context->preference('marcflavour') eq "UNIMARC" ? $record->subfield('200', 'a') : $record->title;
945
                $template->param( title => $title );
946
            }
947
            $template->param(
948
                popup => $mode,
949
                itemtype => $frameworkcode,
950
            );
951
            output_html_with_http_headers $input, $cookie, $template->output;
952
            exit;
953
        }
954
    } elsif ( !$valid_isbn ) {
955
        build_tabs ($template, $record, $dbh,$encoding,$input);
956
        $template->param(
957
            biblionumber => $biblionumber,
958
            invalid_isbn => 1,
959
        );
943
    } else {
960
    } else {
944
    # it may be a duplicate, warn the user and do nothing
961
    # it may be a duplicate, warn the user and do nothing
945
        build_tabs ($template, $record, $dbh,$encoding,$input);
962
        build_tabs ($template, $record, $dbh,$encoding,$input);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-1 / +17 lines)
Lines 436-441 function PopupMARCFieldDoc(field) { Link Here
436
        Check();
436
        Check();
437
    }
437
    }
438
438
439
    function bypass_isbn(redirect){
440
        $("#bypass_isbn").attr("value","1");
441
        $("#redirect").attr("value",redirect);
442
        Check();
443
    }
444
439
    function Dopop(link,i) {
445
    function Dopop(link,i) {
440
        defaultvalue = document.getElementById(i).value;
446
        defaultvalue = document.getElementById(i).value;
441
        window.open(link+"&result="+defaultvalue,"valuebuilder",'width=700,height=550,toolbar=false,scrollbars=yes');
447
        window.open(link+"&result="+defaultvalue,"valuebuilder",'width=700,height=550,toolbar=false,scrollbars=yes');
Lines 838-843 function PopupMARCFieldDoc(field) { Link Here
838
                            </form>
844
                            </form>
839
                        </div> <!-- /.dialog.alert -->
845
                        </div> <!-- /.dialog.alert -->
840
                    [% END # /IF duplicatebiblionumber %]
846
                    [% END # /IF duplicatebiblionumber %]
847
848
                    [% IF ( invalid_isbn ) %]
849
                        <div class="dialog alert">
850
                            <h3>Invalid ISBN detected</h3>
851
                            <p>An invalid ISBN has been detected [% IF Koha.Preference('marcflavour') == "UNIMARC" %](010$a)[% ELSE %](020$a)[% END %]. Fix the record and Save again, or Continue to save the current record.</p>
852
                            <form action="/cgi-bin/koha/cataloguing/addbiblio.pl" method="get">
853
                                <button type="submit" class="new" onclick="bypass_isbn('view'); return false;"><i class="fa fa-fw fa-save"></i> Continue</button>
854
                            </form>
855
                        </div> <!-- /.dialog.alert -->
856
                    [% END # /IF invalid_isbn %]
841
                [% END # /UNLESS number %]
857
                [% END # /UNLESS number %]
842
858
843
                [% IF ( done ) %]
859
                [% IF ( done ) %]
Lines 851-856 function PopupMARCFieldDoc(field) { Link Here
851
                        <input type="hidden" value="[% IF ( biblionumber ) %]view[% ELSE %]items[% END %]" id="redirect" name="redirect" />
867
                        <input type="hidden" value="[% IF ( biblionumber ) %]view[% ELSE %]items[% END %]" id="redirect" name="redirect" />
852
                        <input type="hidden" value="" id="current_tab" name="current_tab" />
868
                        <input type="hidden" value="" id="current_tab" name="current_tab" />
853
                        <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
869
                        <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
870
                        <input type="hidden" value="0" id="bypass_isbn" name="bypass_isbn" />
854
                [% END %]
871
                [% END %]
855
872
856
                <div id="toolbar" class="btn-toolbar">
873
                <div id="toolbar" class="btn-toolbar">
857
- 

Return to bug 29980