Acq: Find PO from which copy originated
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Apr 2010 16:57:39 +0000 (16:57 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 27 Apr 2010 16:57:39 +0000 (16:57 +0000)
In the Item Status staff client interface there is now a new menu option that
will look for a PO from which a given item originated.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16321 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
Open-ILS/web/js/ui/default/acq/po/view_po.js
Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/web/templates/default/acq/po/view.tt2
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/circ/copy_status.js
Open-ILS/xul/staff_client/server/circ/copy_status.xul
Open-ILS/xul/staff_client/server/circ/copy_status_overlay.xul
Open-ILS/xul/staff_client/server/circ/util.js
Open-ILS/xul/staff_client/server/locale/en-US/circ.properties

index 5cde9d7..691771a 100644 (file)
@@ -958,4 +958,44 @@ sub ranged_line_item_alert_text {
 }
 
 
+__PACKAGE__->register_method(
+    method => "retrieve_lineitem_by_copy_id",
+    api_name => "open-ils.acq.lineitem.retrieve.by_copy_id",
+    signature => {
+        desc => q/Manage lineitem notes/,
+        params => [
+            {desc => "Authentication token", type => "string"},
+            {desc => "Evergreen internal copy ID", type => "number"},
+            {desc => "Hash of options (see open-ils.acq.lineitem.retrieve",
+                type => "object"}
+        ],
+        return => {
+            desc => "Lineitem associated with given copy",
+            type => "object", class => "jub"
+        }
+    }
+);
+
+sub retrieve_lineitem_by_copy_id {
+    my ($self, $conn, $auth, $object_id, $options) = @_;
+
+    my $e = new_editor("authtoken" => $auth);
+    return $e->die_event unless $e->checkauth;
+
+    my $result = $e->json_query({
+        "select" => {"acqlid" => ["lineitem"]},
+        "from" => "acqlid",
+        "where" => {"eg_copy_id" => $object_id}
+    })->[0] or do {
+        $e->disconnect;
+        return new OpenILS::Event("ACQ_LINEITEM_NOT_FOUND");
+    };
+
+    my $li = retrieve_lineitem_impl($e, $result->{"lineitem"}, $options) or
+        return $e->die_event;
+
+    $e->disconnect;
+    return $li;
+}
+
 1;
index dcbe8e9..8183cf7 100644 (file)
@@ -370,6 +370,7 @@ params: [openils.User.authtoken, {purchase_order:poId}, {flesh_attrs:true, flesh
 
             oncomplete : function() {
                 dojo.byId("acq-po-view-total-estimated").innerHTML = totalEstimated.toFixed(2);
+                if (liFocus) liTable.drawCopies(liFocus);
             }
         }
     );
index d2130ab..1993156 100644 (file)
 <!ENTITY staff.circ.copy_status_overlay.cmd_book_item_now.accesskey "N">
 <!ENTITY staff.circ.copy_status_overlay.cmd_create_brt.label "Make Item Bookable">
 <!ENTITY staff.circ.copy_status_overlay.cmd_create_brt.accesskey "K">
+<!ENTITY staff.circ.copy_status_overlay.cmd_find_acq_po.label "Find Originating Acquisition">
+<!ENTITY staff.circ.copy_status_overlay.cmd_find_acq_po.accesskey "F">
 <!ENTITY staff.circ.copy_status_overlay.sel_edit.label "Edit Item Attributes">
 <!ENTITY staff.circ.copy_status_overlay.sel_edit.accesskey "E">
 <!ENTITY staff.circ.copy_status_overlay.sel_mark_items_damaged.label "Mark Item Damaged">
index f253912..24d3e50 100644 (file)
         </div>
     </div>
     <script type="text/javascript">
-        var [poId, liFocus] = "[% ctx.page_args.0 %]".split(",");
+        var poId = "[% ctx.page_args.1 %]";
+        var liFocus = "[% ctx.page_args.0 %]";
+        if (liFocus && !poId) {
+            poId = liFocus;
+            liFocus = null;
+        }
     </script>
     [% INCLUDE 'default/acq/common/li_table.tt2' %]
     [% INCLUDE "default/acq/common/notes.tt2" which = "Po" %]
index d11b02f..0ac7b71 100644 (file)
@@ -416,5 +416,6 @@ var urls = {
     'CONIFY' : '/conify/' + LOCALE + '/global',
     'EG_WEB_BASE' : '/eg',
     'XUL_LOCAL_ADMIN_BASE' : '/xul/server/admin',
-    'XUL_REPORTS' : '/reports/oils_rpt.xhtml'
+    'XUL_REPORTS' : '/reports/oils_rpt.xhtml',
+    'EG_ACQ_PO_VIEW' : '/eg/acq/po/view'
 }
index ebf6180..1a7bf35 100644 (file)
@@ -67,6 +67,7 @@ circ.copy_status.prototype = {
                             obj.controller.view.cmd_triggered_events.setAttribute('disabled','true');
                             obj.controller.view.cmd_create_brt.setAttribute('disabled','true');
                             obj.controller.view.cmd_book_item_now.setAttribute('disabled','true');
+                            obj.controller.view.cmd_find_acq_po.setAttribute('disabled','true');
                             obj.controller.view.sel_spine.setAttribute('disabled','true');
                             obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
                             obj.controller.view.sel_clip.setAttribute('disabled','true');
@@ -98,6 +99,7 @@ circ.copy_status.prototype = {
                                 obj.controller.view.cmd_book_item_now.setAttribute('disabled','true');
                             }
                             obj.controller.view.cmd_create_brt.setAttribute('disabled','false');
+                            obj.controller.view.cmd_find_acq_po.setAttribute("disabled", obj.selection_list.length == 1 ? "false" : "true");
                             obj.controller.view.sel_spine.setAttribute('disabled','false');
                             obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
                             obj.controller.view.sel_clip.setAttribute('disabled','false');
@@ -230,6 +232,15 @@ circ.copy_status.prototype = {
                             }
                         }
                     ],
+                    "cmd_find_acq_po" : [
+                        ["command"],
+                        function() {
+                            JSAN.use("circ.util");
+                            circ.util.find_acq_po(
+                                ses(), obj.selection_list[0].copy_id
+                            );
+                        }
+                    ],
                     'sel_checkin' : [
                         ['command'],
                         function() {
index cd3402f..6cee443 100644 (file)
         <command id="cmd_alt_view" />
         <command id="cmd_triggered_events" />
         <command id="save_columns" />
+        <command id="cmd_find_acq_po" disabled="true"/>
         <command id="cmd_create_brt" disabled="true"/>
         <command id="cmd_book_item_now" disabled="true"/>
         <command id="sel_copy_details" disabled="true"/>
index 8036a67..00d7774 100644 (file)
@@ -21,6 +21,8 @@
         <menuitem command="cmd_create_brt" label="&staff.circ.copy_status_overlay.cmd_create_brt.label;" accesskey="&staff.circ.copy_status_overlay.cmd_create_brt.accesskey;"/>
         <menuitem command="cmd_book_item_now" label="&staff.circ.copy_status_overlay.cmd_book_item_now.label;" accesskey="&staff.circ.copy_status_overlay.cmd_book_item_now.accesskey;"/>
         <menuseparator/>
+        <menuitem command="cmd_find_acq_po" label="&staff.circ.copy_status_overlay.cmd_find_acq_po.label;" accesskey="&staff.circ.copy_status_overlay.cmd_find_acq_po.accesskey;"/>
+        <menuseparator/>
         <menuitem command="sel_edit" label="&staff.circ.copy_status_overlay.sel_edit.label;" accesskey="&staff.circ.copy_status_overlay.sel_edit.accesskey;" />
         <menuseparator/>
         <menuitem command="sel_mark_items_damaged" label="&staff.circ.copy_status_overlay.sel_mark_items_damaged.label;" accesskey="&staff.circ.copy_status_overlay.sel_mark_items_damaged.accesskey;"/>
             <menuitem command="cmd_create_brt" label="&staff.circ.copy_status_overlay.cmd_create_brt.label;" accesskey="&staff.circ.copy_status_overlay.cmd_create_brt.accesskey;"/>
             <menuitem command="cmd_book_item_now" label="&staff.circ.copy_status_overlay.cmd_book_item_now.label;" accesskey="&staff.circ.copy_status_overlay.cmd_book_item_now.accesskey;"/>
             <menuseparator />
+            <menuitem command="cmd_find_acq_po" label="&staff.circ.copy_status_overlay.cmd_find_acq_po.label;" accesskey="&staff.circ.copy_status_overlay.cmd_find_acq_po.accesskey;"/>
+            <menuseparator/>
             <menuitem command="sel_edit" label="&staff.circ.copy_status_overlay.sel_edit.label;" accesskey="&staff.circ.copy_status_overlay.sel_edit.accesskey;" />
             <menuseparator />
             <menuitem command="sel_mark_items_damaged" label="&staff.circ.copy_status_overlay.sel_mark_items_damaged.label;" accesskey="&staff.circ.copy_status_overlay.sel_mark_items_damaged.accesskey;"/>
index 4e8421d..01162bb 100644 (file)
@@ -3150,4 +3150,33 @@ circ.util.batch_hold_update = function ( hold_ids, field_changes, params ) {
     }
 };
 
+circ.util.find_acq_po = function(session, copy_id) {
+    dojo.require("openils.Util");
+    fieldmapper.standardRequest(
+        ["open-ils.acq", "open-ils.acq.lineitem.retrieve.by_copy_id"], {
+            "params": [session, copy_id, {"clear_marc": true}],
+            "onresponse": function(r) {
+                if (r = openils.Util.readResponse(r)) {
+                    if (r.purchase_order()) {
+                        /* XXX would prefer to use browser.xul to wrap this so
+                         * that we get back/forward/reload buttons, but that
+                         * doesn't work in this context. need to find out why.
+                         */
+                        xulG.new_tab(
+                            urls.EG_ACQ_PO_VIEW +
+                                "/" + r.purchase_order() + "/" + r.id(),
+                            {}, {}
+                        );
+                    } else {
+                        /* unlikely: got an LI with no PO */
+                        alert(dojo.byId("circStrings").getFormattedString(
+                            "staff.circ.utils.find_acq_po.no_po", [r.id()]
+                        ));
+                    }
+                }
+            }
+        }
+    );
+};
+
 dump('exiting circ/util.js\n');
index becfa55..b046070 100644 (file)
@@ -379,6 +379,7 @@ staff.circ.utils.estimated_wait=Estimated Wait Time
 staff.circ.utils.potential_copies=Potential Copies 
 staff.circ.utils.queue_position=Queue Position
 staff.circ.utils.total_holds=Total Number of Holds
+staff.circ.utils.find_acq_po.no_po=Lineitem found (%1$s), but without purchase order
 staff.circ.work_log_column.message=Message
 staff.circ.work_log_column.when=When
 # 1 - Staff Username  2 - Patron Family  3 - Patron Barcode  4 - Item Barcode