Follow-up patch : use the subfield associated with items.barcode
authorFrédérick Capovilla <frederick.capovilla@libeo.com>
Mon, 17 Oct 2011 20:01:29 +0000 (16:01 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 4 Nov 2011 09:22:52 +0000 (10:22 +0100)
Instead of using the 'p' subfield directly, use the subfield letter
associated with the items.barcode column.

http://bugs.koha-community.org/show_bug.cgi?id=6963
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Test cases tested:
- 1 item, barcode empty
- 2 items, barcodes both empty
- 1 item, existing barcode
- 1 item, new barcode
- 2 items, one barcode empty, one existing

All test cases worked nicely and gave correct error messages.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
acqui/neworderempty.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt

index 02b829a..459dfe8 100755 (executable)
@@ -333,6 +333,9 @@ if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) {
 my @itemtypes;
 @itemtypes = C4::ItemType->all unless C4::Context->preference('item-level_itypes');
 
+# Find the items.barcode subfield for barcode validations
+my (undef, $barcode_subfield) = GetMarcFromKohaField('items.barcode', '');
+
 # fill template
 $template->param(
     close        => $close,
@@ -386,6 +389,7 @@ $template->param(
     unitprice        => sprintf("%.2f", $data->{'unitprice'}),
     notes            => $data->{'notes'},
     publishercode    => $data->{'publishercode'},
+    barcode_subfield => $barcode_subfield,
     
     import_batch_id  => $import_batch_id,
 
index e6e5f62..68c290a 100644 (file)
@@ -53,7 +53,7 @@ function Check(ff) {
             if (ff.field_value[i].value.length == 0 && ff.mandatory[i].value == 1) {
                 empty_item_mandatory++;
             }
-            if(ff.subfield[i].value === 'p' && ff.field_value[i].value.length != 0) {
+            if(ff.subfield[i].value === '[% barcode_subfield %]' && ff.field_value[i].value.length != 0) {
                 barcodes.push(ff.field_value[i].value);
             }
         }