From: pines Date: Thu, 14 Sep 2006 16:30:35 +0000 (+0000) Subject: adding storage version of checked_out[.count] X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f4e5b6c65af8507cb25f67ac31c99d8b878642d4;p=evergreen%2Fpines.git adding storage version of checked_out[.count] git-svn-id: svn://svn.open-ils.org/ILS/trunk@6097 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm index 6c4f24a822..8adf1aab71 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/actor.pm @@ -46,6 +46,79 @@ __PACKAGE__->register_method( method => 'usr_total_owed', ); +sub usr_breakdown_out { + my $self = shift; + my $client = shift; + my $usr = shift; + + my $out_sql = <<" SQL"; + SELECT id + FROM action.circulation + WHERE usr = ? AND checkin_time IS NULL AND (stop_fines IS NULL OR stop_fines NOT IN ('LOST','CLAIMSRETURNED','LONGOVERDUE')) + SQL + + my $out = actor::user->db_Main->selectcol_arrayref($out_sql, {}, $usr); + + my $od_sql = <<" SQL"; + SELECT id + FROM action.circulation + WHERE usr = ? AND checkin_time IS NULL AND due_date < 'today' + SQL + + my $od = actor::user->db_Main->selectcol_arrayref($od_sql, {}, $usr); + + my $lost_sql = <<" SQL"; + SELECT id + FROM action.circulation + WHERE usr = ? AND checkin_time IS NULL AND stop_fines = 'LOST' + SQL + + my $lost = actor::user->db_Main->selectcol_arrayref($lost_sql, {}, $usr); + + my $cl_sql = <<" SQL"; + SELECT id + FROM action.circulation + WHERE usr = ? AND checkin_time IS NULL AND stop_fines = 'CLAIMSRETURNED' + SQL + + my $cl = actor::user->db_Main->selectcol_arrayref($cl_sql, {}, $usr); + + my $lo_sql = <<" SQL"; + SELECT id + FROM action.circulation + WHERE usr = ? AND checkin_time IS NULL AND stop_fines = 'LONGOVERDUE' + SQL + + my $lo = actor::user->db_Main->selectcol_arrayref($lo_sql, {}, $usr); + + if ($self->api_name =~/count$/o) { + return { total => scalar(@$out) + scalar(@$od) + scalar(@$lost) + scalar(@$cl) + scalar(@$lo), + out => scalar(@$out), + overdue => scalar(@$od), + lost => scalar(@$lost), + claims_returned => scalar(@$cl), + long_overdue => scalar(@$lo), + }; + } + + return { out => $out, + overdue => $od, + lost => $lost, + claims_returned => $cl, + long_overdue => $lo, + }; +} +__PACKAGE__->register_method( + api_name => 'open-ils.storage.actor.user.checked_out', + api_level => 1, + method => 'usr_breakdown_out', +); +__PACKAGE__->register_method( + api_name => 'open-ils.storage.actor.user.checked_out.count', + api_level => 1, + method => 'usr_breakdown_out', +); + sub usr_total_out { my $self = shift; my $client = shift;