Patch from Joe Atzberger to add a line item 'worksheet' print template and a helper...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Feb 2010 17:49:46 +0000 (17:49 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 10 Feb 2010 17:49:46 +0000 (17:49 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15494 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.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/0158.data.titles_received_worksheet.sql [new file with mode: 0644]

index 222b002..936e570 100644 (file)
@@ -15,7 +15,6 @@ sub NOOP_False { return 0 }
 
 
 
-
 # helper functions inserted into the TT environment
 my $_TT_helpers = {
 
@@ -87,6 +86,18 @@ my $_TT_helpers = {
         my($org_id, $setting) = @_;
         return $U->ou_ancestor_setting_value($org_id, $setting);
     },
+
+    # returns matching line item attribute, or undef
+    get_li_attr => sub {
+        my ($name, $type, $attr) = @_;
+        # use Data::Dumper; $logger->warn("get_li_attr: " . Dumper($attr));
+        ($name and @$attr) or return;
+        foreach (@$attr) {
+            $_->attr_name eq $name or next;
+            return $_->attr_value if (! $type) or $type eq $_->attr_type;
+        }
+        return;
+    },
 };
 
 
index 3572bfa..2984191 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0157'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0158'); -- atz
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index dd4a1e8..00613fe 100644 (file)
@@ -3815,6 +3815,82 @@ $$
 $$
 );
 
+INSERT INTO action_trigger.hook (key, core_type, description, passive) 
+    VALUES (
+        'format.acqli.html',
+        'jub',
+        'Formats lineitem worksheet for titles received',
+        TRUE
+    );
+
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, granularity, template)
+    VALUES (
+        14,
+        TRUE,
+        1,
+        'Titles Received Lineitem Worksheet',
+        'format.acqli.html',
+        'NOOP_True',
+        'ProcessTemplate',
+        'print-on-demand',
+$$
+[%- USE date -%]
+[%- SET li = target; -%]
+<div class="wrapper">
+    <div class="summary">
+        <div class="lineid">Lineitem ID: [% li.id %]</div>
+        <div class="count"><span id="countno">[% li.lineitem_details.size %]</span> items</div>
+        [% IF detail.recv_time %]<div class="dateformat">Expected: [% li.expected_recv_time %]</div>[% END %]
+    </div>
+    <table>
+        <thead>
+            <tr>
+                <th>Title</th>
+                <th>Recd.</th>
+                <th>Barcode</th>
+                <th>Call Number</th>
+                <th>Distribution</th>
+                <th>Notes</th>
+            </tr>
+        </thead>
+        <tbody>
+    [% FOREACH detail IN li.lineitem_details %]
+            <tr>
+                [% IF loop.first %]
+                <td rowspan='[% li.lineitem_details.size %]'>
+                 [%- helpers.get_li_attr("title", "", li.attributes) -%]
+                </td>
+                [% END %]
+                <!-- acq.lineitem_detail.id = [%- detail.id -%] -->
+                <td>[% IF detail.recv_time %]<span class="recv_time">[% detail.recv_time %]</span>[% END %]</td>
+                <td>[% IF detail.barcode   %]<span class="barcode"  >[% detail.barcode   %]</span>[% END %]</td>
+                <td>[% IF detail.cn_label  %]<span class="cn_label" >[% detail.cn_label  %]</span>[% END %]</td>
+                <td>
+                    ==&gt; [% detail.owning_lib.shortname %] ([% detail.owning_lib.name %])
+                    [% IF detail.note %]( [% detail.note %] )[% END %]
+                </td>
+                <td>
+                    [%- SET notelist = []             -%]
+                    [%- FOR note IN li.lineitem_notes -%]
+                    [%-     notelist.push(note.value) -%]
+                    [%- END                           -%]
+                    [%- notelist.join('<br/>')        -%]
+                </td>
+            </tr>
+    [% END %]
+        </tbody>
+    </table>
+</div>
+$$
+);
+
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    ( 14, 'attributes' ),
+    ( 14, 'lineitem_details' ),
+    ( 14, 'lineitem_details.owning_lib' ),
+    ( 14, 'lineitem_notes' )
+;
 
 INSERT INTO action_trigger.environment ( event_def, path) VALUES
     ( 13, 'open_billable_transactions_summary.circulation' );
diff --git a/Open-ILS/src/sql/Pg/upgrade/0158.data.titles_received_worksheet.sql b/Open-ILS/src/sql/Pg/upgrade/0158.data.titles_received_worksheet.sql
new file mode 100644 (file)
index 0000000..23f515f
--- /dev/null
@@ -0,0 +1,83 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0158');  -- atz
+
+INSERT INTO action_trigger.hook (key, core_type, description, passive) 
+    VALUES (
+        'format.acqli.html',
+        'jub',
+        'Formats lineitem worksheet for titles received',
+        TRUE
+    );
+
+INSERT INTO action_trigger.event_definition (id, active, owner, name, hook, validator, reactor, granularity, template)
+    VALUES (
+        14,
+        TRUE,
+        1,
+        'Titles Received Lineitem Worksheet',
+        'format.acqli.html',
+        'NOOP_True',
+        'ProcessTemplate',
+        'print-on-demand',
+$$
+[%- USE date -%]
+[%- SET li = target; -%]
+<div class="wrapper">
+    <div class="summary">
+        <div class="lineid">Lineitem ID: [% li.id %]</div>
+        <div class="count"><span id="countno">[% li.lineitem_details.size %]</span> items</div>
+        [% IF detail.recv_time %]<div class="dateformat">Expected: [% li.expected_recv_time %]</div>[% END %]
+    </div>
+    <table>
+        <thead>
+            <tr>
+                <th>Title</th>
+                <th>Recd.</th>
+                <th>Barcode</th>
+                <th>Call Number</th>
+                <th>Distribution</th>
+                <th>Notes</th>
+            </tr>
+        </thead>
+        <tbody>
+    [% FOREACH detail IN li.lineitem_details %]
+            <tr>
+                [% IF loop.first %]
+                <td rowspan='[% li.lineitem_details.size %]'>
+                 [%- helpers.get_li_attr("title", "", li.attributes) -%]
+                </td>
+                [% END %]
+                <!-- acq.lineitem_detail.id = [%- detail.id -%] -->
+                <td>[% IF detail.recv_time %]<span class="recv_time">[% detail.recv_time %]</span>[% END %]</td>
+                <td>[% IF detail.barcode   %]<span class="barcode"  >[% detail.barcode   %]</span>[% END %]</td>
+                <td>[% IF detail.cn_label  %]<span class="cn_label" >[% detail.cn_label  %]</span>[% END %]</td>
+                <td>
+                    ==&gt; [% detail.owning_lib.shortname %] ([% detail.owning_lib.name %])
+                    [% IF detail.note %]( [% detail.note %] )[% END %]
+                </td>
+                <td>
+                    [%- SET notelist = []             -%]
+                    [%- FOR note IN li.lineitem_notes -%]
+                    [%-     notelist.push(note.value) -%]
+                    [%- END                           -%]
+                    [%- notelist.join('<br/>')        -%]
+                </td>
+            </tr>
+    [% END %]
+        </tbody>
+    </table>
+</div>
+$$
+);
+
+
+INSERT INTO action_trigger.environment (event_def, path) VALUES
+    ( 14, 'attributes' ),
+    ( 14, 'lineitem_details' ),
+    ( 14, 'lineitem_details.owning_lib' ),
+    ( 14, 'lineitem_notes' )
+;
+
+COMMIT;
+