ACQ: Add open holds count to lineitem worksheet
authorBill Erickson <berick@esilibrary.com>
Tue, 20 Sep 2011 19:44:12 +0000 (15:44 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 19 Oct 2011 16:11:53 +0000 (12:11 -0400)
Includes a generic bre_open_holds_count reactor utility method

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/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/0642.data.acq-worksheet-hold-count.sql [new file with mode: 0644]

index 0f6262f..5f07972 100644 (file)
@@ -237,6 +237,15 @@ my $_TT_helpers = {
         return $str;
     },
 
         return $str;
     },
 
+
+    bre_open_hold_count => sub {
+        my $bre_id = shift;
+        return 0 unless $bre_id;
+        return $U->simplereq(
+            'open-ils.circ',
+            'open-ils.circ.bre.holds.count', $bre_id);
+    },
+
     xml_doc => sub {
         my ($str) = @_;
         return $str ? (new XML::LibXML)->parse_string($str) : undef;
     xml_doc => sub {
         my ($str) = @_;
         return $str ? (new XML::LibXML)->parse_string($str) : undef;
index acccf52..02ba712 100644 (file)
@@ -86,7 +86,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0641', :eg_version); -- tsbere/phasefx
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0642', :eg_version); -- berick/senator
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 637a014..9ea1baa 100644 (file)
@@ -7570,6 +7570,7 @@ $$
         <div>Author: [% helpers.get_li_attr("author", "", li.attributes) %]</div>
         <div class="count">Item Count: [% li.lineitem_details.size %]</div>
         <div class="lineid">Lineitem ID: [% li.id %]</div>
         <div>Author: [% helpers.get_li_attr("author", "", li.attributes) %]</div>
         <div class="count">Item Count: [% li.lineitem_details.size %]</div>
         <div class="lineid">Lineitem ID: [% li.id %]</div>
+        <div>Open Holds: [% helpers.bre_open_hold_count(li.eg_bib_id) %]</div>
 
         [% IF li.distribution_formulas.size > 0 %]
             [% SET forms = [] %]
 
         [% IF li.distribution_formulas.size > 0 %]
             [% SET forms = [] %]
diff --git a/Open-ILS/src/sql/Pg/upgrade/0642.data.acq-worksheet-hold-count.sql b/Open-ILS/src/sql/Pg/upgrade/0642.data.acq-worksheet-hold-count.sql
new file mode 100644 (file)
index 0000000..ad90989
--- /dev/null
@@ -0,0 +1,85 @@
+-- Evergreen DB patch 0642.data.acq-worksheet-hold-count.sql
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0642', :eg_version);
+
+UPDATE action_trigger.event_definition SET template = 
+$$
+[%- USE date -%]
+[%- SET li = target; -%]
+<div class="wrapper">
+    <div class="summary" style='font-size:110%; font-weight:bold;'>
+
+        <div>Title: [% helpers.get_li_attr("title", "", li.attributes) %]</div>
+        <div>Author: [% helpers.get_li_attr("author", "", li.attributes) %]</div>
+        <div class="count">Item Count: [% li.lineitem_details.size %]</div>
+        <div class="lineid">Lineitem ID: [% li.id %]</div>
+        <div>Open Holds: [% helpers.bre_open_hold_count(li.eg_bib_id) %]</div>
+
+        [% IF li.distribution_formulas.size > 0 %]
+            [% SET forms = [] %]
+            [% FOREACH form IN li.distribution_formulas; forms.push(form.formula.name); END %]
+            <div>Distribution Formulas: [% forms.join(',') %]</div>
+        [% END %]
+
+        [% IF li.lineitem_notes.size > 0 %]
+            Lineitem Notes:
+            <ul>
+                [%- FOR note IN li.lineitem_notes -%]
+                    <li>
+                    [% IF note.alert_text %]
+                        [% note.alert_text.code -%] 
+                        [% IF note.value -%]
+                            : [% note.value %]
+                        [% END %]
+                    [% ELSE %]
+                        [% note.value -%] 
+                    [% END %]
+                    </li>
+                [% END %]
+            </ul>
+        [% END %]
+    </div>
+    <br/>
+    <table>
+        <thead>
+            <tr>
+                <th>Branch</th>
+                <th>Barcode</th>
+                <th>Call Number</th>
+                <th>Fund</th>
+                <th>Shelving Location</th>
+                <th>Recd.</th>
+                <th>Notes</th>
+            </tr>
+        </thead>
+        <tbody>
+        [% FOREACH detail IN li.lineitem_details.sort('owning_lib') %]
+            [% 
+                IF detail.eg_copy_id;
+                    SET copy = detail.eg_copy_id;
+                    SET cn_label = copy.call_number.label;
+                ELSE; 
+                    SET copy = detail; 
+                    SET cn_label = detail.cn_label;
+                END 
+            %]
+            <tr>
+                <!-- acq.lineitem_detail.id = [%- detail.id -%] -->
+                <td style='padding:5px;'>[% detail.owning_lib.shortname %]</td>
+                <td style='padding:5px;'>[% IF copy.barcode   %]<span class="barcode"  >[% detail.barcode   %]</span>[% END %]</td>
+                <td style='padding:5px;'>[% IF cn_label %]<span class="cn_label" >[% cn_label  %]</span>[% END %]</td>
+                <td style='padding:5px;'>[% IF detail.fund %]<span class="fund">[% detail.fund.code %] ([% detail.fund.year %])</span>[% END %]</td>
+                <td style='padding:5px;'>[% copy.location.name %]</td>
+                <td style='padding:5px;'>[% IF detail.recv_time %]<span class="recv_time">[% detail.recv_time %]</span>[% END %]</td>
+                <td style='padding:5px;'>[% detail.note %]</td>
+            </tr>
+        [% END %]
+        </tbody>
+    </table>
+</div>
+$$
+WHERE id = 14;
+
+COMMIT;