another option for excluding certain items
authorJason Etheridge <jason@esilibrary.com>
Fri, 19 Dec 2014 21:02:33 +0000 (16:02 -0500)
committerJason Etheridge <jason@esilibrary.com>
Fri, 19 Dec 2014 21:10:01 +0000 (16:10 -0500)
this time by circ_modifier

    --exclude-item-circmod-file=<file containing list of circ modifier codes, one per line>

Works in conjunction with --exclude-itemless-bibs, so if that argument is in effect and
all items on a given bib are effectively filtered out via an --exclude-item argument,
then the bib itself will not be included in the output.

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/support-scripts/marc_export.in

index c7cfe89..cb09985 100755 (executable)
@@ -85,6 +85,7 @@ sub new {
                'exclude-itemless-bibs',
                'exclude-item-id-file=s',
                'exclude-item-barcode-file=s',
+               'exclude-item-circmod-file=s',
                'mfhd',
                'all',
                'replace_001',
@@ -132,8 +133,9 @@ Usage: $0 [options]
 
  Additional options for type = 'BIBLIO':
  --items or -i                 Include items (holdings) in the output
- --exclude-item-id-file        File containing list of item ids to exclude
- --exclude-item-barcode-file   File containing list of item barcodes to exclude
+ --exclude-item-id-file        Specify a file containing list of item ids to exclude
+ --exclude-item-barcode-file   Specify a file containing list of item barcodes to exclude
+ --exclude-item-circmod-file   Specify a file containing list of circmods to exclude
  --exclude-itemless-bibs       Don't output bibs without holdings (requires --items)
  --money                       Currency symbol to use in item price field [\$]
  --mfhd                        Export serial MFHD records for associated bib records
@@ -230,7 +232,19 @@ HELP
             die "Could not find file for exclude-item-barcode-file: " . $opts{'exclude-item-barcode-file'};
         }
     }
-
+    $opts{'exclude-item-circmods'} = {};
+    if ($opts{'exclude-item-circmod-file'}) {
+        if (-e $opts{'exclude-item-circmod-file'}) {
+            open FILE, $opts{'exclude-item-circmod-file'};
+            while (my $item_circmod = <FILE>) {
+                chomp $item_circmod;
+                $opts{'exclude-item-circmods'}->{$item_circmod} = 1;
+            }
+            close FILE;
+        } else {
+            die "Could not find file for exclude-item-circmod-file: " . $opts{'exclude-item-circmod-file'};
+        }
+    }
 
     if ($opts{mfhd}) {
         if ($opts{type} ne 'biblio') {
@@ -499,6 +513,7 @@ sub next {
                         next unless ($acp);
                         next if defined $Marque::config->option_value('exclude-item-ids')->{$acp->id()};
                         next if defined $Marque::config->option_value('exclude-item-barcodes')->{$acp->barcode()};
+                        next if defined $Marque::config->option_value('exclude-item-circmods')->{$acp->circ_modifier()};
                         $item_count++;
                         my $location = $Marque::config->option_value('location');
                         my $price = ($acp->price() ? $Marque::config->option_value('money').$acp->price() : '');