[open-ils-commits] ***SPAM*** [GIT] Evergreen ILS branch master updated. 48a44afbd82ac271c123903de2fa1351c2a0fa43

Evergreen Git git at git.evergreen-ils.org
Wed Sep 25 20:48:02 EDT 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  48a44afbd82ac271c123903de2fa1351c2a0fa43 (commit)
       via  6566aa8007d8156bbf8df2e1df5d38ee94c9ecaf (commit)
       via  e4e39e6777ab40ba1cf61728095a9fd34627f8c4 (commit)
       via  3448c226d400d104599a05770522e2b95bc30efd (commit)
       via  6785a4a3a1baed72f8bcff6110cff6288d9cea3b (commit)
      from  addfe15b6bcfb2636b01666c50ff2f84a79bff10 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 48a44afbd82ac271c123903de2fa1351c2a0fa43
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Wed Sep 18 14:14:16 2013 -0400

    Add PhoneList.pm stuff to Apache 2.4 config
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/examples/apache_24/eg.conf.in b/Open-ILS/examples/apache_24/eg.conf.in
index fb5e00b..67dfd53 100644
--- a/Open-ILS/examples/apache_24/eg.conf.in
+++ b/Open-ILS/examples/apache_24/eg.conf.in
@@ -19,6 +19,7 @@ PerlChildInitHandler OpenILS::WWW::Reporter::child_init
 PerlChildInitHandler OpenILS::WWW::SuperCat::child_init
 PerlChildInitHandler OpenILS::WWW::AddedContent::child_init
 PerlChildInitHandler OpenILS::WWW::AutoSuggest::child_init
+PerlChildInitHandler OpenILS::WWW::PhoneList::child_init
 
 # ----------------------------------------------------------------------------------
 # Set some defaults for our working directories
diff --git a/Open-ILS/examples/apache_24/eg_vhost.conf.in b/Open-ILS/examples/apache_24/eg_vhost.conf.in
index 57378c7..2e51116 100644
--- a/Open-ILS/examples/apache_24/eg_vhost.conf.in
+++ b/Open-ILS/examples/apache_24/eg_vhost.conf.in
@@ -551,6 +551,9 @@ RewriteRule . - [E=locale:%1]
     Options +ExecCGI
     PerlSendHeader On
     Require all granted 
+    <IfModule mod_headers.c>
+        Header onsuccess set Cache-Control no-cache
+    </IfModule>
 </Location>
 
 # ----------------------------------------------------------------------------------
@@ -577,6 +580,25 @@ RewriteRule ^/conify/([a-z]{2}-[A-Z]{2})/global/(.*)$ /conify/global/$2 [E=local
     Require all granted 
 </Location>
 
+# ----------------------------------------------------------------------------------
+# The PhoneList lives here
+# ----------------------------------------------------------------------------------
+<Location /phonelist>
+    SetHandler perl-script
+    AuthType Basic
+    AuthName "PhoneList Login"
+    require valid-user
+    PerlOptions +GlobalRequest
+    PerlSetVar OILSProxyPermissions "STAFF_LOGIN"
+    PerlHandler OpenILS::WWW::PhoneList
+    PerlAuthenHandler OpenILS::WWW::Proxy::Authen
+    Options +ExecCGI
+    PerlSendHeader On
+    allow from all
+    <IfModule mod_headers.c>
+        Header onsuccess set Cache-Control no-cache
+    </IfModule>
+</Location>
 <Location /vandelay-upload>
     SetHandler perl-script
     PerlHandler OpenILS::WWW::Vandelay::spool_marc

commit 6566aa8007d8156bbf8df2e1df5d38ee94c9ecaf
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Wed Sep 18 13:41:31 2013 -0400

    Add phonelist.txt release notes.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/docs/RELEASE_NOTES_NEXT/phonelist.txt b/docs/RELEASE_NOTES_NEXT/phonelist.txt
new file mode 100644
index 0000000..c753748
--- /dev/null
+++ b/docs/RELEASE_NOTES_NEXT/phonelist.txt
@@ -0,0 +1,193 @@
+Release Notes for the Phonelist.pm Module
+=========================================
+
+PhoneList.pm is a mod_perl module for Apache that works with Evergreen
+to generate callings lists for patron holds. It outputs a csv file
+that can be fed into an auto-dialer script to call patrons with little
+or no staff intervention.  It is accessed and configured via a special
+URL and passing any parameters as a ``Query String'' on the URL.  The
+parameters are listed in the table below.
+
+.Parameters for the phonelist program:
+|=====================================
+| user |  Your Evergreen login. Typically your library's circ account. If you leave this off, you will be prompted to login.
+| passwd | The password for your Evergreen login. If you leave this off you will be prompted to login.
+| ws_ou | The ID of the system or branch you want to generate the list for (optional). If your account does not have the appropriate permissions for the location whose ID number you have entered, you will get an error.
+| skipemail | If present, skip patrons with email notification (optional).
+| addcount | Add a count of items on hold (optional). Only makes sense for holds.
+| overdue | Makes a list of patrons with overdues instead of holds. If an additional, numeric parameter is supplied, it will be used as the number of days overdue. If no such extra parameter is supplied, then the default of 14 days is used.
+|=====================================
+
+The URL is
+
+`https://your.evergreen-server.tld/phonelist`
+
+A couple of examples follow:
+
+`https://your.evergreen-server.tld/phonelist?user=circuser&passwd=password&skipemail
+
+The above example would sign in as user circuser with password of
+``password'' and get a list of patrons with holds to call who do not
+have email notification turned on. It would run at whatever branch is
+normally associated with circuser, which would likely be MVC or
+central site. (Note: There is no actual circuser account, it is used
+here for illustration purposes only.)
+
+`https://your.evergreen-server.tld/phonelist?skipemail`
+
+The above example would do more or less the same, but you would be
+prompted by your browser for the user name and password.
+
+If your browser or download script support it, you may also use
+conventional HTTP authentication parameters.
+
+`https://user:password@your.evergreen-server.tld/phonelist?overdue&ws_ou=2`
+
+The above logs in as ``user'' with ``password'' and runs overdues for location ID 2.
+
+The following sections provide more information on getting what you want in your output.
+
+Adding Parameters
+-----------------
+
+If you are not familiar with HTTP/URL query strings, the format is
+quite simple.
+
+You add parameters to the end of the URL, the first parameter is
+separated from the URL page with a question mark (``?'') character. If
+the parameter is to be given an extra value, then that value follows
+the parameter name after an equals sign (``=''). Subsequent parameters
+are separated from the previous parameter by an ampersand (``&'').
+
+Here is an example with 1 parameter that has no value:
+
+`https://your.evergreen-server.tld/phonelist?skipemail`
+
+An example of 1 argument with a value:
+
+`https://your.evergreen-server.tld/phonelist?overdue=21`
+
+An example of 2 arguments, 1 with a value and 1 without:
+
+`https://your.evergreen-server.tld/phonelist?overdue=21&skipemail`
+
+Any misspelled or parameters not listed in the table above will be
+ignored by the program.
+
+Output
+------
+
+On a successful run, the program will return a CSV file named
+phone.csv. Depending on your browser or settings you will alternately
+be prompted to open or save the file. Your browser may also
+automatically save the file in your Downloads or other designated
+folder. You should be able to open this CSV file in Excel, LibreOffice
+Base, any other spread sheet program, or a text editor.
+
+If you have made a mistake and have mistyped your user name or
+password, or if you supply a ws_ou parameter with an ID where your
+user name does not have permission to look up holds or overdue
+information, then you will get an error returned in your browser.
+
+Should your browser appear to do absolutely nothing at all. This is
+normal. When there is no information for you to download, the server
+will return a 200 NO CONTENT message to your browser. Most browsers
+respond to this message by doing nothing at all. It is possible for
+there to be no information for you to retrieve if you added the
+`skipemail` option and all of your notices for that day were sent via
+email, or if you ran this in the morning and then again in the
+afternoon and there was no new information to gather.
+
+The program does indicate that it has already looked at a particular
+hold or overdue and will skip it on later runs. This prevents
+duplicates to the same patron in the same run. It will, however,
+create a ``duplicate'' for the same patron if a different copy is put
+on hold for that patron in between two runs.
+
+The specific content of the CSV file will vary if you are looking at
+holds or overdues. The specific contents are described in the
+appropriate sections below.
+
+Holds
+-----
+
+The `phonelist` program will return a list of patrons with copies on
+hold by default, so long as you do not use the `overdue`
+parameter. You may optionally get a number of items that patron
+currently has on hold by adding the `addcount` parameter.
+
+As always, you can add the skipemail parameter to skip patrons with
+email notifications of their overdues, [#0.5.Skipping patrons with
+email notification of holds|outline as described below].
+
+.Columns in the holds CSV file:
+|=====================================
+| Name | Patron's name first and last.
+| Phone | Patron's phone number.
+| Barcode | Patron's barcode.
+| Count | Number of copies on hold, if `addcount` parameter is used, otherwise this column is not present in the file.
+|=====================================
+
+Overdues
+--------
+
+If you add the `overdue` parameter, you can get a list of patrons with
+overdue copies instead of a list of patrons with copies on the hold
+shelf. By default, this will give you a list of patrons with copies
+that are 14 days overdue. If you'd like to specify a different number
+of days you can add the number after the parameter with an equals
+sign:
+
+`https://your.evergreen-server.tld/phonelist?overdue=21&ws_ou=2`
+
+The above will retrieve a list of patrons who have items that are 21
+days overdue at the location with ID of 2.
+
+The number of days is an exact lookup. This means that the program
+will look only at patrons who have items exactly 14 days or exactly
+the number of days specified overdue. It does not pull up any that are
+less than or greater than the number of days specified.
+
+As always, you can add the skipemail parameter to skip patrons with
+email notifications of their overdues, [#0.5.Skipping patrons with
+email notification of holds|outline as described below].
+
+.Columns in the overdues CSV file:
+|=================================
+| Name | Patron's name first and last.
+| Phone | Patron's phone number.
+| Barcode | Patron's barcode.
+| Titles | A colon-separated list of titles that the patron has overdue.
+|=================================
+
+Skipping patrons with email notification of holds
+-------------------------------------------------
+
+Skipping patrons who have email notification for their holds or
+overdues is very simple. You just need to add the `skipemail`
+parameter on the URL query string. Doing so will produce the list
+without the patrons who have email notification for overdues, or for
+all of their holds. Please note that if a patron has multiple holds
+available, and even one of these holds requests a phone-only
+notification, then that patron will still show on the list. For this
+option to exclude a patron from the holds list, the patron must
+request email notification on all of their current holds. In practice,
+we find that this is usually the case.
+
+Using the ws_ou parameter
+-------------------------
+
+Generally, you will not need to use the ws_ou parameter when using the
+phonelist program. The phonelist will look up the branch where your
+login account works and use that location when generating the list.
+However, if you are part of a multi-branch systems in a consortium,
+then the ws_ou parameter will be of interest to you.  You can use it
+to specify which branch, or the whole system, you wish to search when
+running the program.
+
+Automating the download
+-----------------------
+
+If you'd like to automate the download of these files, you should be
+able to do so using any HTTP programming toolkit. Your client must
+accept cookies and follow any redirects in order to function.

commit e4e39e6777ab40ba1cf61728095a9fd34627f8c4
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Mon Jul 23 10:19:13 2012 -0400

    Fix PhoneList.pm child_init method.
    
    child_init in an Apache module should return something, so it now
    returns the OK constant.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm
index a654f56..6e6c9fd 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm
@@ -54,6 +54,7 @@ sub child_init {
     my $idl = OpenSRF::Utils::SettingsClient->new->config_value("IDL");
     Fieldmapper->import(IDL => $idl);
     OpenILS::Utils::CStoreEditor->init;
+    return Apache2::Const::OK;
 }
 
 sub handler {

commit 3448c226d400d104599a05770522e2b95bc30efd
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Tue Mar 6 13:21:14 2012 -0500

    Strip out spaces as well as - from phone numbers in PhoneList::Holds.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm
index b5df719..5b1032c 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm
@@ -97,7 +97,7 @@ sub query {
             if ($i->{barcode} ne $bc || $i->{phone_notify} ne $pn) {
                 if ($count > 0 && $skipme == 0) {
                     my $phone = $pn;
-                    $phone =~ s/-//g;
+                    $phone =~ s/[- ]//g;
                     my $out = [$name, $phone, $bc];
                     push(@$out, $count) if ($self->addcount);
                     push(@{$self->{results}}, $out);

commit 6785a4a3a1baed72f8bcff6110cff6288d9cea3b
Author: Jason Stephenson <jstephenson at mvlc.org>
Date:   Thu May 26 10:30:10 2011 -0400

    Add PhoneList.pm.
    
    A simple WWW module to list patrons who have holds with their phone
    numbers and barcodes. The format is as requested by a specific library
    for their automated calling program.
    
    Future modifications may include the ability to rearrange the output
    columns and provide formats for some data.
    
    Signed-off-by: Jason Stephenson <jstephenson at mvlc.org>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>

diff --git a/Open-ILS/examples/apache/eg.conf.in b/Open-ILS/examples/apache/eg.conf.in
index acc495c..faa26a0 100644
--- a/Open-ILS/examples/apache/eg.conf.in
+++ b/Open-ILS/examples/apache/eg.conf.in
@@ -19,6 +19,7 @@ PerlChildInitHandler OpenILS::WWW::Reporter::child_init
 PerlChildInitHandler OpenILS::WWW::SuperCat::child_init
 PerlChildInitHandler OpenILS::WWW::AddedContent::child_init
 PerlChildInitHandler OpenILS::WWW::AutoSuggest::child_init
+PerlChildInitHandler OpenILS::WWW::PhoneList::child_init
 
 # ----------------------------------------------------------------------------------
 # Set some defaults for our working directories
diff --git a/Open-ILS/examples/apache/eg_startup.in b/Open-ILS/examples/apache/eg_startup.in
index 12f4ea5..1d77c05 100755
--- a/Open-ILS/examples/apache/eg_startup.in
+++ b/Open-ILS/examples/apache/eg_startup.in
@@ -13,6 +13,7 @@ use OpenILS::WWW::TemplateBatchBibUpdate qw( @sysconfdir@/opensrf_core.xml );
 use OpenILS::WWW::EGWeb;
 use OpenILS::WWW::IDL2js ('@sysconfdir@/opensrf_core.xml');
 use OpenILS::WWW::FlatFielder;
+use OpenILS::WWW::PhoneList ('@sysconfdir@/opensrf_core.xml');
 
 # - Uncomment the following 2 lines to make use of the IP redirection code
 # - The IP file should to contain a map with the following format:
diff --git a/Open-ILS/examples/apache/eg_vhost.conf.in b/Open-ILS/examples/apache/eg_vhost.conf.in
index 66819b8..1000461 100644
--- a/Open-ILS/examples/apache/eg_vhost.conf.in
+++ b/Open-ILS/examples/apache/eg_vhost.conf.in
@@ -546,6 +546,9 @@ RewriteRule . - [E=locale:%1]
     Options +ExecCGI
     PerlSendHeader On
     allow from all
+    <IfModule mod_headers.c>
+        Header onsuccess set Cache-Control no-cache
+    </IfModule>
 </Location>
 
 # ----------------------------------------------------------------------------------
@@ -571,6 +574,25 @@ RewriteRule ^/conify/([a-z]{2}-[A-Z]{2})/global/(.*)$ /conify/global/$2 [E=local
     allow from all
 </Location>
 
+# ----------------------------------------------------------------------------------
+# The PhoneList lives here
+# ----------------------------------------------------------------------------------
+<Location /phonelist>
+    SetHandler perl-script
+    AuthType Basic
+    AuthName "PhoneList Login"
+    require valid-user
+    PerlOptions +GlobalRequest
+    PerlSetVar OILSProxyPermissions "STAFF_LOGIN"
+    PerlHandler OpenILS::WWW::PhoneList
+    PerlAuthenHandler OpenILS::WWW::Proxy::Authen
+    Options +ExecCGI
+    PerlSendHeader On
+    allow from all
+    <IfModule mod_headers.c>
+        Header onsuccess set Cache-Control no-cache
+    </IfModule>
+</Location>
 <Location /vandelay-upload>
     SetHandler perl-script
     PerlHandler OpenILS::WWW::Vandelay::spool_marc
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm
new file mode 100644
index 0000000..a654f56
--- /dev/null
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm
@@ -0,0 +1,132 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2011 Merrimack Valley Library Consortium
+# Jason Stephenson <jstephenson at mvlc.org>
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# ---------------------------------------------------------------
+
+package OpenILS::WWW::PhoneList;
+use strict;
+use warnings;
+use bytes;
+
+use Apache2::Log;
+use Apache2::Const -compile => qw(OK FORBIDDEN HTTP_NO_CONTENT :log);
+use APR::Const    -compile => qw(:error SUCCESS);
+use APR::Table;
+
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+use Apache2::RequestUtil;
+use CGI;
+
+use OpenSRF::System;
+use OpenSRF::Utils::SettingsClient;
+use OpenSRF::Utils::Logger qw/$logger/;
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Application::AppUtils;
+
+use Text::CSV; # Still only support CSV output.
+
+# Our submodules.
+use OpenILS::WWW::PhoneList::Holds;
+use OpenILS::WWW::PhoneList::Overdues;
+
+my $U = 'OpenILS::Application::AppUtils';
+
+my $bootstrap;
+
+sub import {
+    my $self = shift;
+    $bootstrap = shift;
+}
+
+sub child_init {
+    OpenSRF::System->bootstrap_client(config_file => $bootstrap);
+    my $idl = OpenSRF::Utils::SettingsClient->new->config_value("IDL");
+    Fieldmapper->import(IDL => $idl);
+    OpenILS::Utils::CStoreEditor->init;
+}
+
+sub handler {
+    my $r = shift;
+    my $cgi = new CGI;
+    my $authid = $cgi->cookie('ses') || $cgi->param('ses');
+    my $user = $U->simplereq('open-ils.auth', 'open-ils.auth.session.retrieve', $authid);
+    if (!$user || (ref($user) eq 'HASH' && $user->{ilsevent} == 1001)) {
+        return Apache2::Const::FORBIDDEN;
+    }
+
+    my $ou_id = $cgi->cookie("ws_ou") || $cgi->param("ws_ou") || $user->home_ou;
+
+    # Look for optional addcount parameter. If it is present add a
+    # count column to the end of the csv ouput with a count of the
+    # patron's hold items.
+    my $addcount = defined($cgi->param('addcount'));
+
+    # Member staff asked for the option to ignore a patron's
+    # preference to receive both a phone and email notice, and skip
+    # them if it looks like they will get an email notice, too.
+    # So we made it an option on the query string.
+    my $skipemail = defined($cgi->param('skipemail'));
+
+    # Build the args hashref to initialize our functional submodule:
+    my $args = {
+                'authtoken' => $authid,
+                'user' => $user->id,
+                'work_ou' => $ou_id,
+               };
+
+    # Default module to load is Holds.
+    my $module = 'OpenILS::WWW::PhoneList::Holds';
+
+    # If the overdue parameter is specified, we us the Overdues module
+    # and get the number of days from the due date. If no number of
+    # days is given, or if the argument to overdue is not a number,
+    # then we use a default of 14.
+    if (defined($cgi->param('overdue'))) {
+        $module = 'OpenILS::WWW::PhoneList::Overdues';
+        $args->{'days'} =
+            ($cgi->param('overdue') =~ /^[0-9]+$/) ? $cgi->param('overdue')
+                : 14;
+        $args->{'skipemail'} = $skipemail;
+    } else {
+        $args->{'addcount'} = $addcount;
+        $args->{'skipemail'} = $skipemail;
+    }
+
+    # Load the module.
+    my $source = $module->new($args);
+
+    # check for user permissions:
+    return Apache2::Const::FORBIDDEN unless($source->checkperms);
+
+    # Tell the source to run its query.
+    if ($source->query()) {
+        my $csv = Text::CSV->new();
+        $r->headers_out->set("Content-Disposition" => "attachment; filename=phone.csv");
+        $r->content_type("text/plain");
+        # Print the columns
+        if ($csv->combine(@{$source->columns})) {
+            $r->print($csv->string . "\n");
+        }
+        # Print the results
+        $r->print($csv->string . "\n") while ($csv->combine(@{$source->next}));
+    }
+    else {
+        # Query failed, so we'll return no content error.
+        return Apache2::Const::HTTP_NO_CONTENT;
+    }
+
+    return Apache2::Const::OK;
+}
+
+1;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Base.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Base.pm
new file mode 100644
index 0000000..a33aef1
--- /dev/null
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Base.pm
@@ -0,0 +1,85 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2011 Merrimack Valley Library Consortium
+# Jason Stephenson <jstephenson at mvlc.org>
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# ---------------------------------------------------------------
+package OpenILS::WWW::PhoneList::Base;
+
+use strict;
+use warnings;
+use Carp;
+# A base class for generating phone list output.
+
+use OpenILS::Application::AppUtils;
+
+my %fields = (
+              columns => [],
+              perms => [],
+              user => undef,
+              authtoken => undef,
+              work_ou => undef,
+             );
+
+sub new {
+    my $invocant = shift;
+    my $args = shift;
+    my $class = ref($invocant) || $invocant;
+    my $self = {
+                _permitted => \%fields,
+                %fields,
+               };
+    bless($self, $class);
+    $self->authtoken($args->{authtoken});
+    $self->user($args->{user});
+    $self->work_ou($args->{work_ou});
+    return $self;
+}
+
+sub checkperms {
+    my $self = shift;
+    my $rv = 0;
+    if ($self->perms && $self->user && $self->authtoken && $self->work_ou) {
+        my $r = OpenILS::Application::AppUtils->simplereq('open-ils.actor', 'open-ils.actor.user.perm.check', $self->authtoken, $self->user, $self->work_ou, $self->perms);
+        $rv = 1 unless(@$r);
+    }
+    return $rv;
+}
+
+# Return empty array ref.
+sub next {
+    return [];
+}
+
+# Always return false.
+sub query {
+    return 0;
+}
+
+sub AUTOLOAD {
+    my $self = shift;
+    my $class = ref($self) or croak "$self is not an object";
+    my $name = our $AUTOLOAD;
+
+    $name =~ s/.*://;
+
+    unless (exists $self->{_permitted}->{$name}) {
+        croak "Can't access '$name' field of class '$class'";
+    }
+
+    if (@_) {
+        return $self->{$name} = shift;
+    } else {
+        return $self->{$name};
+    }
+}
+
+1;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm
new file mode 100644
index 0000000..b5df719
--- /dev/null
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm
@@ -0,0 +1,159 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2011 Merrimack Valley Library Consortium
+# Jason Stephenson <jstephenson at mvlc.org>
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# ---------------------------------------------------------------
+package OpenILS::WWW::PhoneList::Holds;
+
+use strict;
+use warnings;
+
+use OpenSRF::Utils::Logger qw/$logger/;
+use OpenSRF::Utils::JSON;
+use OpenILS::Application::AppUtils;
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+use OpenILS::WWW::PhoneList::Base;
+
+my $U = 'OpenILS::Application::AppUtils';
+
+BEGIN {
+    our @ISA = ('OpenILS::WWW::PhoneList::Base');
+}
+
+my %fields = (
+              addcount => 0,
+              skipemail => 0,
+             );
+
+sub new {
+    my $class = shift;
+    my $args = shift;
+    my $self = $class->SUPER::new($args);
+    foreach my $element (keys %fields) {
+        $self->{_permitted}->{$element} = $fields{$element};
+    }
+    @{$self}{keys %fields} = values %fields;
+    $self->perms(['VIEW_USER', 'VIEW_HOLD', 'VIEW_HOLD_NOTIFICATION', 'CREATE_HOLD_NOTIFICATION']);
+    $self->addcount($args->{addcount}) if (defined($args->{addcount}));
+    $self->skipemail($args->{skipemail}) if (defined($args->{skipemail}));
+    my $columns = ['Name', 'Phone', 'Barcode'];
+    push(@{$columns}, 'Count') if ($self->addcount);
+    $self->columns($columns);
+    return $self;
+}
+
+sub query {
+    my $self = shift;
+    my $ou_id = $self->work_ou;
+
+    # Hold results in an array ref.
+    $self->{results} = [];
+
+    my $raw_query =<<"    QUERY";
+{
+"select": { "au": [ "first_given_name", "family_name", "email" ],
+            "ac": [ "barcode" ],
+            "ahr": [ "phone_notify", "id", "email_notify" ] },
+
+"from": { "au" : { "ac" : { "fkey":"card", "field":"id" },
+                   "ahr": { "fkey":"id", "field":"usr" } } },
+
+"where": { "+ahr": { "pickup_lib": { "in": {"select": {"aou":[{"transform":"actor.org_unit_descendants","column":"id","result_field":"id","alias":"id"}]},
+                                            "from":"aou",
+                                            "where":{"id":$ou_id}}},
+                     "cancel_time":null,
+                     "fulfillment_time":null,
+                     "-and": [{"phone_notify": {"<>": null}}, {"phone_notify":{"<>":""}}],
+                     "shelf_time":{"<>":null},
+                     "capture_time":{"<>":null},
+                     "current_copy":{"<>":null},
+                     "id": { "not in": { "from":"ahn",
+                                         "select": { "ahn": [ "hold" ] },
+                                         "where": { "method":"phone" } } } } },
+"order_by": { "ac": [ "barcode" ], "ahr": [ "phone_notify" ] }
+}
+    QUERY
+
+    my $q = OpenSRF::Utils::JSON->JSON2perl($raw_query);
+    my $e = new_editor(authtoken=>$self->authtoken);
+    my $info = $e->json_query($q);
+    if ($info && @$info) {
+        my ($bc, $pn,$count,$name, $skipme);
+        $bc = "";
+        $pn = "";
+        $count = 0;
+        $skipme = 1; # Assume we skip until we have a notice w/out email.
+        foreach my $i (@$info) {
+            if ($i->{barcode} ne $bc || $i->{phone_notify} ne $pn) {
+                if ($count > 0 && $skipme == 0) {
+                    my $phone = $pn;
+                    $phone =~ s/-//g;
+                    my $out = [$name, $phone, $bc];
+                    push(@$out, $count) if ($self->addcount);
+                    push(@{$self->{results}}, $out);
+                    $count = 0;
+                }
+                if ($i->{first_given_name} eq 'N/A' || $i->{first_given_name} eq '') {
+                    $name = $i->{family_name};
+                }
+                else {
+                    $name = $i->{first_given_name} . ' ' . $i->{family_name};
+                }
+                $bc = $i->{barcode};
+                $pn = $i->{phone_notify};
+                $skipme = 1; # Assume we skip until we have a notice w/out email.
+            }
+            unless ($self->skipemail && $i->{email} && $i->{email_notify} eq 't') {
+                my $ahn = Fieldmapper::action::hold_notification->new;
+                $ahn->hold($i->{id});
+                $ahn->notify_staff($self->user);
+                $ahn->method('phone');
+                $ahn->note('PhoneList.pm');
+                $logger->activity("Attempting notification creation hold: " . $ahn->hold . " method: " . $ahn->method . " note: " . $ahn->note);
+                my $notification = $U->simplereq('open-ils.circ', 'open-ils.circ.hold_notification.create', $self->authtoken, $ahn);
+                if (ref($notification)) {
+                    $logger->error("Error creating notification: " . $notification->{textcode});
+                }
+                else {
+                    $logger->activity("Created ahn: $notification");
+                }
+                #patron has at least 1 phone-only notice, so we print.
+                $skipme = 0;
+            }
+            $count++;
+        }
+        # Get that last one, since we only print when barcode and/or
+        # phone changes.
+        if ($count > 0 && $skipme == 0) {
+            my $phone = $pn;
+            $phone =~ s/-//g;
+            my $out = [$name, $phone, $bc];
+            push(@$out, $count) if ($self->addcount);
+            push(@{$self->{results}}, $out);
+            $count = 0;
+        }
+    }
+    return scalar @{$self->{results}};
+}
+
+sub next {
+    my $self = shift;
+    if (@{$self->{results}}) {
+        return shift @{$self->{results}};
+    }
+    else {
+        return [];
+    }
+}
+
+1;
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Overdues.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Overdues.pm
new file mode 100644
index 0000000..eb98df2
--- /dev/null
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Overdues.pm
@@ -0,0 +1,174 @@
+# ---------------------------------------------------------------
+# Copyright (C) 2011 Merrimack Valley Library Consortium
+# Jason Stephenson <jstephenson at mvlc.org>
+
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# ---------------------------------------------------------------
+package OpenILS::WWW::PhoneList::Overdues;
+
+use strict;
+use warnings;
+
+use OpenSRF::Utils::Logger qw/$logger/;
+use OpenILS::Application::AppUtils;
+use OpenILS::Utils::Fieldmapper;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
+use OpenILS::WWW::PhoneList::Base;
+
+my $U = 'OpenILS::Application::AppUtils';
+
+BEGIN {
+    our @ISA = ('OpenILS::WWW::PhoneList::Base');
+}
+
+my %fields = (
+              skipemail => 0,
+              days => 14,
+             );
+
+sub new {
+    my $class = shift;
+    my $args = shift;
+    my $self = $class->SUPER::new($args);
+    foreach my $element (keys %fields) {
+        $self->{_permitted}->{$element} = $fields{$element};
+    }
+    @{$self}{keys %fields} = values %fields;
+    $self->perms(['VIEW_USER', 'VIEW_CIRCULATIONS']);
+    $self->skipemail($args->{skipemail}) if (defined($args->{skipemail}));
+    $self->days($args->{days});
+    my $columns = ['Name', 'Phone', 'Barcode', 'Titles'];
+    $self->columns($columns);
+
+    # Results in an array ref.
+    $self->{results} = [];
+
+    return $self;
+}
+
+sub query {
+    my $self = shift;
+    my $ou_id = $self->work_ou;
+
+    # Need a CStoreEditor to run some queries:
+    my $e = new_editor(authtoken => $self->{authtoken});
+
+    # Get org_unit and descendant ids for the main search:
+    my $query =
+        {
+         "select" =>
+         {
+          "aou"=>
+          [
+           {
+            "transform"=>"actor.org_unit_descendants",
+            "column"=>"id",
+            "result_field"=>"id",
+            "alias"=>"id"
+           }
+          ]
+         },
+         "from"=>"aou",
+         "where"=>{"id"=>$ou_id}
+        };
+
+    my $result = $e->json_query($query);
+    my $where = [];
+    if (defined($result) && ref($result) eq 'ARRAY') {
+        foreach my $r (@$result) {
+            push (@$where, $r->{id});
+        }
+    } else {
+        $where = $ou_id;
+    }
+
+    # Set the due date to $self->days() ago.
+    my $when = DateTime->now();
+    $when->subtract(days => $self->days());
+    # All due dates are set to 23:59:59 in Evergreen.
+    $when->set(hour => 23, minute => 59, second => 59);
+
+    # This is what we're here for, the main search call to get fleshed
+    # circulation information for items that were due $where $when
+    # days ago.
+    my $circs = $e->search_action_circulation(
+        [
+         {
+          circ_lib => $where,
+          checkin_time => undef,
+          due_date => $when->iso8601()
+         },
+         {
+          flesh => 4,
+          flesh_fields =>
+          {
+           circ => ['usr', 'target_copy'],
+           au => ['card'],
+           acp => ['call_number'],
+           acn => ['record'],
+           bre => ['simple_record']
+          }
+         }
+        ], {substream => 1});
+
+    # Add any results to our internal results array.
+    if (defined($circs) && ref($circs) eq 'ARRAY') {
+        my $stuff = {};
+        foreach my $circ (@$circs) {
+            next if ($self->skipemail() && $circ->usr->email());
+            next unless($circ->usr->day_phone());
+            my $barcode = $circ->usr->card->barcode();
+            my $title = $circ->target_copy->call_number->record->simple_record->
+                title();
+            if (defined($stuff->{$barcode})) {
+                $stuff->{$barcode}->{titles} .= ':' . $title;
+            } else {
+                my $phone = $circ->usr->day_phone();
+                my $name = $self->_get_usr_name($circ);
+                $stuff->{$barcode}->{phone} = $phone;
+                $stuff->{$barcode}->{name} = $name;
+                $stuff->{$barcode}->{titles} = $title;
+            }
+        }
+        foreach my $key (keys %$stuff) {
+            push (@{$self->{results}},
+                        [ $stuff->{$key}->{name}, $stuff->{$key}->{phone},
+                          $key, $stuff->{$key}->{titles} ]);
+        }
+    }
+
+    # Clean up?
+    $e->finish;
+
+    return scalar @{$self->{results}};
+}
+
+sub next {
+    my $self = shift;
+    if (@{$self->{results}}) {
+        return shift @{$self->{results}};
+    }
+    else {
+        return [];
+    }
+}
+
+# some helper functions:
+sub _get_usr_name {
+    my $self = shift;
+    my $circ = shift;
+    my $first_name = $circ->usr->first_given_name();
+    my $last_name = $circ->usr->family_name();
+    return ($first_name eq 'N/A' || $first_name eq '') ? $last_name
+        : $first_name . ' ' . $last_name;
+}
+
+1;

-----------------------------------------------------------------------

Summary of changes:
 Open-ILS/examples/apache/eg.conf.in                |    1 +
 Open-ILS/examples/apache/eg_startup.in             |    1 +
 Open-ILS/examples/apache/eg_vhost.conf.in          |   22 +++
 Open-ILS/examples/apache_24/eg.conf.in             |    1 +
 Open-ILS/examples/apache_24/eg_vhost.conf.in       |   22 +++
 Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm |  133 ++++++++++++++
 .../src/perlmods/lib/OpenILS/WWW/PhoneList/Base.pm |   85 +++++++++
 .../perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm    |  159 ++++++++++++++++
 .../perlmods/lib/OpenILS/WWW/PhoneList/Overdues.pm |  174 ++++++++++++++++++
 docs/RELEASE_NOTES_NEXT/phonelist.txt              |  193 ++++++++++++++++++++
 10 files changed, 791 insertions(+), 0 deletions(-)
 create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList.pm
 create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Base.pm
 create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Holds.pm
 create mode 100644 Open-ILS/src/perlmods/lib/OpenILS/WWW/PhoneList/Overdues.pm
 create mode 100644 docs/RELEASE_NOTES_NEXT/phonelist.txt


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list