From fc1765b318ce981b38fc6201ae3d3873a5dffb44 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 12 Feb 2010 20:52:53 +0000 Subject: [PATCH] added a virtual use_count field for distrib formulas, populating value in ranged distrib form retrieve method git-svn-id: svn://svn.open-ils.org/ILS/trunk@15531 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/examples/fm_IDL.xml | 1 + .../src/perlmods/OpenILS/Application/Acq/Picklist.pm | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index f4849087dc..ca211a8fcd 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5532,6 +5532,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm index b49daef2fe..5f0b5fd382 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm @@ -441,10 +441,11 @@ __PACKAGE__->register_method( ); sub ranged_distrib_formulas { - my($self, $conn, $auth) = @_; + my($self, $conn, $auth, $org) = @_; my $e = new_editor(authtoken=>$auth); return $e->event unless $e->checkauth; my $orgs = $U->user_has_work_perm_at($e, 'CREATE_PICKLIST', {descendants =>1}); + my $forms = $e->search_acq_distribution_formula([ {owner => $orgs}, { @@ -453,7 +454,20 @@ sub ranged_distrib_formulas { order_by => {acqdfe => ['position']} } ]); - $conn->respond($_) for @$forms; + + for (@$forms) { + + # how many times has this DF been used + my $count = $e->json_query({ + select => {acqdfa => [{column => 'formula', aggregate => 1, transform => 'count', alias => 'count'}]}, + from => 'acqdfa', + where => {formula => $_->id} + })->[0]; + + $_->use_count($count->{count}); + $conn->respond($_); + } + return undef; } -- 2.11.0