adding status/copy_location filter support to call number browse
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 7 Jul 2010 00:29:37 +0000 (00:29 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 7 Jul 2010 00:29:37 +0000 (00:29 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16863 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm

index d8d2571..da60519 100644 (file)
@@ -244,6 +244,8 @@ sub cn_browse {
        my $ou = shift;
        my $page_size = shift || 9;
        my $page = shift || 0;
+       my $statuses = shift || [];
+       my $copy_locations = shift || [];
 
        my ($before_limit,$after_limit) = (0,0);
        my ($before_offset,$after_offset) = (0,0);
@@ -278,12 +280,28 @@ sub cn_browse {
 
        my @list = ();
 
+    my @cp_filter = ();
+    if (@$statuses || @$copy_locations) {
+        @cp_filter = (
+            '-exists' => {
+                from  => 'acp',
+                               where => {
+                    call_number => { '=' => { '+acn' => 'id' } },
+                    deleted     => 'f',
+                    ((@$statuses)       ? ( status   => $statuses)       : ()),
+                                   ((@$copy_locations) ? ( location => $copy_locations) : ())
+                }
+            }
+        );
+    }
+
        if ($page <= 0) {
                my $before = $_storage->request(
                        "open-ils.cstore.direct.asset.call_number.search.atomic",
                        { label         => { "<" => { transform => "upper", value => ["upper", $label] } },
                          owning_lib    => \@ou_ids,
               deleted => 'f',
+              @cp_filter
                        },
                        { flesh         => 1,
                          flesh_fields  => { acn => [qw/record owning_lib/] },
@@ -301,6 +319,7 @@ sub cn_browse {
                        { label         => { ">=" => { transform => "upper", value => ["upper", $label] } },
                          owning_lib    => \@ou_ids,
               deleted => 'f',
+              @cp_filter
                        },
                        { flesh         => 1,
                          flesh_fields  => { acn => [qw/record owning_lib/] },
@@ -337,6 +356,12 @@ Returns the XML representation of the requested bibliographic record's holdings
                                { name => 'page',
                                  desc => 'The page of call numbers to retrieve, calculated based on page_size.  Can be positive, negative or 0.',
                                  type => 'number' },
+                               { name => 'statuses',
+                                 desc => 'Array of statuses to filter copies by, optional and can be undef.',
+                                 type => 'array' },
+                               { name => 'locations',
+                                 desc => 'Array of copy locations to filter copies by, optional and can be undef.',
+                                 type => 'array' },
                        ],
                  'return' =>
                        { desc => 'Call numbers with owning_lib and record fleshed',
index 65d4eae..a8a4c6e 100644 (file)
@@ -1432,7 +1432,7 @@ sub string_browse {
 
        unless ($string and $axis and grep { $axis eq $_ } keys %browse_types) {
                warn "something's wrong...";
-               warn " >>> $format -> $axis -> $site -> $string -> $page -> $page_size ";
+               warn " >>> format: $format -> axis: $axis -> site: $site -> string: $string -> page: $page -> page_size: $page_size ";
                return undef;
        }