added holds pull list action/trigger template w/ API call for fetching the formatted...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 2 Sep 2010 16:21:45 +0000 (16:21 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 2 Sep 2010 16:21:45 +0000 (16:21 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17445 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0384.data.hold_pull_list_template.sql [new file with mode: 0644]

index 7a75ee9..4333f4c 100644 (file)
@@ -1284,6 +1284,46 @@ sub hold_pull_list {
 }
 
 __PACKAGE__->register_method(
+    method    => "print_hold_pull_list",
+    api_name  => "open-ils.circ.hold_pull_list.print",
+    signature => {
+        desc   => 'Returns an HTML-formatted holds pull list',
+        params => [
+            { desc => 'Authtoken', type => 'string'},
+            { desc => 'Org unit ID.  Optional, defaults to workstation org unit', type => 'number'},
+        ],
+        return => {
+            desc => 'HTML string',
+            type => 'string'
+        }
+    }
+);
+
+sub print_hold_pull_list {
+    my($self, $client, $auth, $org_id) = @_;
+
+    my $e = new_editor(authtoken=>$auth, xact=>1);
+    return $e->die_event unless $e->checkauth;
+
+    $org_id = (defined $org_id) ? $org_id : $e->requestor->ws_ou;
+    return $e->die_event unless $e->allowed('VIEW_HOLD', $org_id);
+
+    my $hold_ids = $U->storagereq(
+        'open-ils.storage.direct.action.hold_request.pull_list.id_list.current_copy_circ_lib.status_filtered.atomic',
+        $org_id, 10000);
+
+    return undef unless @$hold_ids;
+    $client->status(new OpenSRF::DomainObject::oilsContinueStatus);
+
+    my $holds = $e->search_action_hold_request({id => $hold_ids}, {substream => 1});
+    $client->status(new OpenSRF::DomainObject::oilsContinueStatus);
+
+    return $U->fire_object_event(undef, 'ahr.format.pull_list', $holds, $org_id);
+}
+
+
+
+__PACKAGE__->register_method(
     method        => 'fetch_hold_notify',
     api_name      => 'open-ils.circ.hold_notification.retrieve_by_hold',
     authoritative => 1,
index f0e2147..327ee54 100644 (file)
@@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0383'); -- phasefx
+INSERT INTO config.upgrade_log (version) VALUES ('0384'); -- berick
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 0074b31..a583377 100644 (file)
@@ -6742,4 +6742,108 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
         'bool'
 );
 
+-- 0384.data.hold_pull_list_template.sql
 
+INSERT INTO action_trigger.hook (key,core_type,description,passive) 
+    VALUES (   
+        'ahr.format.pull_list',
+        'ahr', 
+        oils_i18n_gettext(
+            'ahr.format.pull_list',
+            'Format holds pull list for printing',
+            'ath',
+            'description'
+        ), 
+        FALSE
+    );
+
+INSERT INTO action_trigger.event_definition (
+        id,
+        active,
+        owner,
+        name,
+        hook,
+        validator,
+        reactor,
+        group_field,
+        granularity,
+        template
+    ) VALUES (
+        35,
+        TRUE,
+        1,
+        'Holds Pull List',
+        'ahr.format.pull_list',
+        'NOOP_True',
+        'ProcessTemplate',
+        'pickup_lib',
+        'print-on-demand',
+$$
+[%- USE date -%]
+<style>
+    table { border-collapse: collapse; } 
+    td { padding: 5px; border-bottom: 1px solid #888; } 
+    th { font-weight: bold; }
+</style>
+[% 
+    # Sort the holds into copy-location buckets
+    # In the main print loop, sort each bucket by callnumber before printing
+    SET holds_list = [];
+    SET loc_data = [];
+    SET current_location = target.0.current_copy.location.id;
+    FOR hold IN target;
+        IF current_location != hold.current_copy.location.id;
+            SET current_location = hold.current_copy.location.id;
+            holds_list.push(loc_data);
+            SET loc_data = [];
+        END;
+        SET hold_data = {
+            'hold' => hold,
+            'callnumber' => hold.current_copy.call_number.label
+        };
+        loc_data.push(hold_data);
+    END;
+    holds_list.push(loc_data)
+%]
+<table>
+    <thead>
+        <tr>
+            <th>Title</th>
+            <th>Author</th>
+            <th>Shelving Location</th>
+            <th>Call Number</th>
+            <th>Barcode</th>
+            <th>Patron</th>
+        </tr>
+    </thead>
+    <tbody>
+    [% FOR loc_data IN holds_list  %]
+        [% FOR hold_data IN loc_data.sort('callnumber') %]
+            [% 
+                SET hold = hold_data.hold;
+                SET copy_data = helpers.get_copy_bib_basics(hold.current_copy.id);
+            %]
+            <tr>
+                <td>[% copy_data.title | truncate %]</td>
+                <td>[% copy_data.author | truncate %]</td>
+                <td>[% hold.current_copy.location.name %]</td>
+                <td>[% hold.current_copy.call_number.label %]</td>
+                <td>[% hold.current_copy.barcode %]</td>
+                <td>[% hold.usr.card.barcode %]</td>
+            </tr>
+        [% END %]
+    [% END %]
+    <tbody>
+</table>
+$$
+);
+
+INSERT INTO action_trigger.environment (
+        event_def,
+        path
+    ) VALUES
+        (35, 'current_copy.location'),
+        (35, 'current_copy.call_number'),
+        (35, 'usr.card'),
+        (35, 'pickup_lib')
+;
diff --git a/Open-ILS/src/sql/Pg/upgrade/0384.data.hold_pull_list_template.sql b/Open-ILS/src/sql/Pg/upgrade/0384.data.hold_pull_list_template.sql
new file mode 100644 (file)
index 0000000..bd38a28
--- /dev/null
@@ -0,0 +1,112 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0384');
+
+INSERT INTO action_trigger.hook (key,core_type,description,passive) 
+    VALUES (   
+        'ahr.format.pull_list',
+        'ahr', 
+        oils_i18n_gettext(
+            'ahr.format.pull_list',
+            'Format holds pull list for printing',
+            'ath',
+            'description'
+        ), 
+        FALSE
+    );
+
+INSERT INTO action_trigger.event_definition (
+        id,
+        active,
+        owner,
+        name,
+        hook,
+        validator,
+        reactor,
+        group_field,
+        granularity,
+        template
+    ) VALUES (
+        35,
+        TRUE,
+        1,
+        'Holds Pull List',
+        'ahr.format.pull_list',
+        'NOOP_True',
+        'ProcessTemplate',
+        'pickup_lib',
+        'print-on-demand',
+$$
+[%- USE date -%]
+<style>
+    table { border-collapse: collapse; } 
+    td { padding: 5px; border-bottom: 1px solid #888; } 
+    th { font-weight: bold; }
+</style>
+[% 
+    # Sort the holds into copy-location buckets
+    # In the main print loop, sort each bucket by callnumber before printing
+    SET holds_list = [];
+    SET loc_data = [];
+    SET current_location = target.0.current_copy.location.id;
+    FOR hold IN target;
+        IF current_location != hold.current_copy.location.id;
+            SET current_location = hold.current_copy.location.id;
+            holds_list.push(loc_data);
+            SET loc_data = [];
+        END;
+        SET hold_data = {
+            'hold' => hold,
+            'callnumber' => hold.current_copy.call_number.label
+        };
+        loc_data.push(hold_data);
+    END;
+    holds_list.push(loc_data)
+%]
+<table>
+    <thead>
+        <tr>
+            <th>Title</th>
+            <th>Author</th>
+            <th>Shelving Location</th>
+            <th>Call Number</th>
+            <th>Barcode</th>
+            <th>Patron</th>
+        </tr>
+    </thead>
+    <tbody>
+    [% FOR loc_data IN holds_list  %]
+        [% FOR hold_data IN loc_data.sort('callnumber') %]
+            [% 
+                SET hold = hold_data.hold;
+                SET copy_data = helpers.get_copy_bib_basics(hold.current_copy.id);
+            %]
+            <tr>
+                <td>[% copy_data.title | truncate %]</td>
+                <td>[% copy_data.author | truncate %]</td>
+                <td>[% hold.current_copy.location.name %]</td>
+                <td>[% hold.current_copy.call_number.label %]</td>
+                <td>[% hold.current_copy.barcode %]</td>
+                <td>[% hold.usr.card.barcode %]</td>
+            </tr>
+        [% END %]
+    [% END %]
+    <tbody>
+</table>
+$$
+);
+
+INSERT INTO action_trigger.environment (
+        event_def,
+        path
+    ) VALUES
+        (35, 'current_copy.location'),
+        (35, 'current_copy.call_number'),
+        (35, 'usr.card'),
+        (35, 'pickup_lib')
+;
+
+-- DELETE FROM config.upgrade_log WHERE version = 'tmp'; DELETE FROM action_trigger.event WHERE event_def IN (35); DELETE FROM action_trigger.environment WHERE event_def IN (35); DELETE FROM action_trigger.event_definition WHERE id IN (35); DELETE FROM action_trigger.hook WHERE key IN ( 'ahr.format.pull_list' );
+
+COMMIT;
+