diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index 5102006684..c69616a13e 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -27,6 +27,7 @@ use C4::Interface::CGI::Output; use C4::Biblio; use C4::Context; use C4::Koha; # XXX subfield_is_koha_internal_p +use C4::Search; use HTML::Template; use MARC::File::USMARC; @@ -58,6 +59,7 @@ my $tagslib = &MARCgettagslib($dbh,1); my $record = MARCgetbiblio($dbh,$bibid); my $itemrecord; my $nextop="additem"; +my @errors; # store errors found while checking data BEFORE saving item. #------------------------------------------------------------------------------------------------------------------------------ if ($op eq "additem") { #------------------------------------------------------------------------------------------------------------------------------ @@ -73,9 +75,20 @@ if ($op eq "additem") { $indicators{$ind_tag[$i]} = $indicator[$i]; } my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); +# check for item barcode # being unique + my $oldbibid = MARCmarc2koha($dbh,$record); + my $exists = itemdata($oldbibid->{'barcode'}); + push @errors,"barcode_not_unique" if($exists); # MARC::Record builded => now, record in DB - my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid); - $nextop = "additem"; + # if barcode exists, don't create, but report The problem. + my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid) unless ($exists); + if ($exists) { + $nextop = "additem"; + $itemrecord = $record; + warn "==>".$record->as_formatted; + } else { + $nextop = "additem"; + } #------------------------------------------------------------------------------------------------------------------------------ } elsif ($op eq "edititem") { #------------------------------------------------------------------------------------------------------------------------------ @@ -253,4 +266,7 @@ $template->param(item_loop => \@item_value_loop, itemtagsubfield =>$itemtagsubfield, op => $nextop, opisadd => ($nextop eq "saveitem")?0:1); +foreach my $error (@errors) { + $template->param($error => 1); +} output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl index 81fa86cc77..455ad2dfa7 100644 --- a/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/acqui.simple/additem.tmpl @@ -24,6 +24,7 @@
+
/images/background-mem.gif"> @@ -43,6 +44,7 @@


+ /images/background-mem.gif"> @@ -63,6 +65,9 @@
New Item
"> + +
ERROR : Barcode already exists !
+
diff --git a/koha-tmpl/intranet-tmpl/default/en/includes/common-style.css b/koha-tmpl/intranet-tmpl/default/en/includes/common-style.css index 2f3742dd72..ef0d3a35fb 100644 --- a/koha-tmpl/intranet-tmpl/default/en/includes/common-style.css +++ b/koha-tmpl/intranet-tmpl/default/en/includes/common-style.css @@ -13,6 +13,10 @@ background-image:url("/intranet-tmpl/default/en/images/background-mem.gif"); } +#problem { + color: red; + font-weight:bold; +} #menubar { border-top:1px solid #666666; font: 1.2em sans-serif; diff --git a/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl b/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl index 34665eb5be..e86a52b48d 100644 --- a/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl +++ b/koha-tmpl/intranet-tmpl/default/fr/acqui.simple/additem.tmpl @@ -63,6 +63,9 @@ "> + +
ERROR : Barcode already exists !
+