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

(-)a/Koha/Exceptions/Object.pm (+2 lines)
Lines 89-94 sub full_message { Link Here
89
        } elsif ( $self->isa('Koha::Exceptions::Object::NotInstantiated') ) {
89
        } elsif ( $self->isa('Koha::Exceptions::Object::NotInstantiated') ) {
90
            $msg =
90
            $msg =
91
                sprintf( "Tried to access the '%s' method, but %s is not instantiated", $self->method, $self->class );
91
                sprintf( "Tried to access the '%s' method, but %s is not instantiated", $self->method, $self->class );
92
        } elsif ( $self->isa('Koha::Exceptions::Object::DuplicateID') ) {
93
            $msg = sprintf( "Duplicate ID for key '%s'", $self->duplicate_id );
92
        }
94
        }
93
    }
95
    }
94
96
(-)a/Koha/Object.pm (-8 / +2 lines)
Lines 182-197 sub store { Link Here
182
                # FK constraints
182
                # FK constraints
183
                # FIXME: MySQL error, if we support more DB engines we should implement this for each
183
                # FIXME: MySQL error, if we support more DB engines we should implement this for each
184
                if ( $_->{msg} =~ /FOREIGN KEY \(`(?<column>.*?)`\)/ ) {
184
                if ( $_->{msg} =~ /FOREIGN KEY \(`(?<column>.*?)`\)/ ) {
185
                    Koha::Exceptions::Object::FKConstraint->throw(
185
                    Koha::Exceptions::Object::FKConstraint->throw( broken_fk => $+{column} );
186
                        error     => 'Broken FK constraint',
187
                        broken_fk => $+{column}
188
                    );
189
                }
186
                }
190
            } elsif ( $_->{msg} =~ /Duplicate entry '(.*?)' for key '(?<key>.*?)'/ ) {
187
            } elsif ( $_->{msg} =~ /Duplicate entry '(.*?)' for key '(?<key>.*?)'/ ) {
191
                Koha::Exceptions::Object::DuplicateID->throw(
188
                Koha::Exceptions::Object::DuplicateID->throw( duplicate_id => $+{key} );
192
                    error        => 'Duplicate ID',
193
                    duplicate_id => $+{key}
194
                );
195
            } elsif ( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column \W?(?<property>\S+)/ )
189
            } elsif ( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column \W?(?<property>\S+)/ )
196
            {    # The optional \W in the regex might be a quote or backtick
190
            {    # The optional \W in the regex might be a quote or backtick
197
                my $type     = $+{type};
191
                my $type     = $+{type};
(-)a/cataloguing/additem.pl (-4 / +2 lines)
Lines 646-652 if ( $op eq "cud-additem" ) { Link Here
646
        try {
646
        try {
647
            $item->store;
647
            $item->store;
648
        } catch {
648
        } catch {
649
            push @errors, $_->error;
649
            push @errors, $_;
650
        }
650
        }
651
    }
651
    }
652
652
Lines 838-844 if ( $frameworkcode eq 'FA' ) { Link Here
838
    );
838
    );
839
}
839
}
840
840
841
foreach my $error (@errors) {
841
$template->param( errors => \@errors );
842
    $template->param( $error => 1 );
843
}
844
output_html_with_http_headers $input, $cookie, $template->output;
842
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-12 / +26 lines)
Lines 89-106 Link Here
89
    <h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %]by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1>
89
    <h1>Items for [% biblio.title | html %] [% IF ( biblio.author ) %]by [% biblio.author | html %][% END %] (Record #[% biblio.biblionumber | html %])</h1>
90
    <a id="newitem_jump" href="#f"><i class="fa fa-arrow-down"></i> Jump to form</a>
90
    <a id="newitem_jump" href="#f"><i class="fa fa-arrow-down"></i> Jump to form</a>
91
91
92
    [% IF ( onloan_cannot_withdraw ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Onloan item cannot be withdrawn.</div>[% END %]
92
    [% FOREACH error IN errors %]
93
    [% IF ( intransit_cannot_withdraw ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: In transit item cannot be withdrawn.</div>[% END %]
93
        <div class="alert alert-warning">
94
    [% IF ( barcode_not_unique ) %]<div class="alert alert-warning"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
94
            [% IF error == 'onloan_cannot_withdraw' %]
95
    [% IF ( no_next_barcode ) %]<div class="alert alert-warning"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
95
                <strong>Error saving item</strong>: Onloan item cannot be withdrawn.
96
    [% IF ( book_on_loan ) %]<div class="alert alert-warning"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
96
            [% ELSIF error == 'intransit_cannot_withdraw' %]
97
    [% IF ( book_reserved ) %]<div class="alert alert-warning"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
97
                <strong>Error saving item</strong>: In transit item cannot be withdrawn.
98
    [% IF ( not_same_branch ) %]<div class="alert alert-warning"><strong>Cannot delete</strong>: The items do not belong to your library.</div>[% END %]
98
            [% ELSIF error == 'barcode_not_unique' %]
99
    [% IF ( linked_analytics ) %]
99
                <strong>Error saving item</strong>: Barcode must be unique.
100
        <div class="alert alert-warning"><strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]&amp;analyze=1">analytics.</a>.</div>
100
            [% ELSIF error == 'no_next_barcode' %]
101
                <strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.
102
            [% ELSIF error == 'book_on_loan' %]
103
                <strong>Cannot delete</strong>: item is checked out.
104
            [% ELSIF error == 'book_reserved' %]
105
                <strong>Cannot delete</strong>: item has a waiting hold.
106
            [% ELSIF error == 'not_same_branch' %]
107
                <strong>Cannot delete</strong>: The items do not belong to your library.
108
            [% ELSIF error == 'linked_analytics' %]
109
                <strong>Cannot delete</strong>: item has linked <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblio.biblionumber | uri %]&amp;analyze=1">analytics.</a>.
110
            [% ELSIF error == 'last_item_for_hold' %]
111
                <strong>Cannot delete</strong>: Last item for bibliographic record with biblio-level hold on it.
112
            [% ELSIF error == 'item_not_found' %]
113
                <strong>Cannot delete</strong>: Item not found.
114
            [% ELSE %]
115
                <strong>Error</strong>: [% error %].
116
            [% END %]
117
        </div>
101
    [% END %]
118
    [% END %]
102
    [% IF last_item_for_hold %]<div class="alert alert-warning"><strong>Cannot delete</strong>: Last item for bibliographic record with biblio-level hold on it.</div>[% END %]
103
    [% IF item_not_found %]<div class="alert alert-warning"><strong>Cannot delete</strong>: Item not found.</div>[% END %]
104
119
105
    <div id="cataloguing_additem_itemlist">
120
    <div id="cataloguing_additem_itemlist">
106
        [% IF items %]
121
        [% IF items %]
107
- 

Return to bug 41696