[open-ils-commits] r11095 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 7 10:24:19 EST 2008
Author: miker
Date: 2008-11-07 10:24:18 -0500 (Fri, 07 Nov 2008)
New Revision: 11095
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm
Log:
adding per-location version of copy status summmary table
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm 2008-11-07 14:38:21 UTC (rev 11094)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/biblio.pm 2008-11-07 15:24:18 UTC (rev 11095)
@@ -427,4 +427,66 @@
cachable => 1,
);
+
+sub record_copy_status_location_count {
+ my $self = shift;
+ my $client = shift;
+
+ my $rec = shift;
+ my $ou = shift || 1;
+ my $depth = shift || 0;
+
+
+ my $descendants = "actor.org_unit_descendants(?,?)";
+
+ 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 $sql = <<" SQL";
+
+ SELECT cp.circ_lib, cn.label, cl.name, cp.status, count(cp.id)
+ FROM $cp_table cp,
+ $cn_table cn,
+ $cl_table cl,
+ $cs_table cs,
+ $descendants d
+ WHERE cn.record = ?
+ AND cp.call_number = cn.id
+ AND cp.location = cl.id
+ AND cp.circ_lib = d.id
+ AND cp.status = cs.id
+ AND cl.opac_visible IS TRUE
+ AND cp.opac_visible IS TRUE
+ AND cp.deleted IS FALSE
+ AND cs.opac_visible IS TRUE
+ GROUP BY 1,2,3,4;
+ SQL
+
+ my $sth = biblio::record_entry->db_Main->prepare_cached($sql);
+ $sth->execute($ou, $depth, "$rec" );
+
+ my %data = ();
+ for my $row (@{$sth->fetchall_arrayref}) {
+ $data{$$row[0]}{$$row[1]}{$$row[2]}{$$row[3]} += $$row[4];
+ }
+
+ for my $ou (keys %data) {
+ for my $cn (keys %{$data{$ou}}) {
+ for my $cl (keys %{$data{$ou}{$cn}}) {
+ $client->respond( [$ou, $cn, $cl, $data{$ou}{$cn}{$cl}] );
+ }
+ }
+ }
+ return undef;
+}
+__PACKAGE__->register_method(
+ api_name => 'open-ils.storage.biblio.record_entry.status_copy_location_count',
+ method => 'record_copy_status_location_count',
+ api_level => 1,
+ stream => 1,
+ cachable => 1,
+);
+
1;
More information about the open-ils-commits
mailing list