From 25c3145703b2995f1014693c6da9e8e2ca877157 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 25 Aug 2005 20:43:48 +0000 Subject: [PATCH] adding slim status count method git-svn-id: svn://svn.open-ils.org/ILS/trunk@1742 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../Application/Storage/Publisher/biblio.pm | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm index 59b344c224..e46e4eaa63 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm @@ -241,4 +241,60 @@ __PACKAGE__->register_method( cachable => 1, ); +sub record_copy_status_count { + my $self = shift; + my $client = shift; + + my $rec = shift; + + my $cn_table = asset::call_number->table; + my $cp_table = asset::copy->table; + my $cl_table = asset::copy_location->table; + my $cs_table = config::copy_status->table; + + my $copies_visible = 'AND cp.opac_visible IS TRUE AND cs.holdable IS TRUE AND cl.opac_visible IS TRUE'; + $copies_visible = '' if ($self->api_name =~ /staff/o); + + my $sql = <<" SQL"; + + SELECT cp.circ_lib, cn.label, cp.status, count(cp.id) + FROM $cp_table cp, + $cn_table cn, + $cl_table cl, + $cs_table cs, + WHERE cn.record = ? + AND cp.call_number = cn.id + AND cp.location = cl.id + AND cp.status = cs.id + AND cl.opac_visible IS TRUE + AND cp.opac_visible IS TRUE + AND cs.holdable + GROUP BY 1,2,3 + ORDER BY 1,2,3 + SQL + + my $sth = biblio::record_entry->db_Main->prepare_cached($sql); + $sth->execute("$rec", "$rec"); + + my ($ou,$cn) = (0,''); + my @data = (); + for my $row (@{$sth->fetchall_arrayref}) { + if ($cn and $cn ne $$row[1]) { + $client->respond( [$ou, $cn, @data] ); + @data = (); + } + ($ou,$cn) = ($$row[0],$$row[1]); + push @data, $$row[3]; + } + return [$ou, $cn, @data] if ($ou); + return undef; +} +__PACKAGE__->register_method( + api_name => 'open-ils.storage.biblio.record_entry.status_copy_count', + method => 'global_record_copy_count', + api_level => 1, + stream => 1, + cachable => 1, +); + 1; -- 2.43.2