[open-ils-commits] [GIT] Evergreen ILS branch master updated. 292ad799ed84127026534e351bdd16663f76b1f8

Evergreen Git git at git.evergreen-ils.org
Wed Aug 24 08:52:51 EDT 2011


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  292ad799ed84127026534e351bdd16663f76b1f8 (commit)
      from  cb3125afa53716ae6642e5510e37a92f79f1ed53 (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 292ad799ed84127026534e351bdd16663f76b1f8
Author: Bill Erickson <berick at esilibrary.com>
Date:   Tue Aug 23 17:03:28 2011 -0400

    Add to existing PO (by ID) from related items page
    
    In the View/Place orders page for a bib record, it's now possible to add
    a lineitem representing the bib record to an existing purchase order.
    
    Includes a new general API call for adding a LI to a PO.
    
    Signed-off-by: Bill Erickson <berick at esilibrary.com>
    Signed-off-by: Mike Rylander <mrylander at gmail.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
index dafa288..8530709 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm
@@ -3173,5 +3173,54 @@ sub clone_distrib_form {
     return $new_form->id;
 }
 
+__PACKAGE__->register_method(
+	method => 'add_li_to_po',
+	api_name	=> 'open-ils.acq.purchase_order.add_lineitem',
+	signature => {
+        desc => q/Adds a lineitem to an existing purchase order/,
+        params => [
+            {desc => 'Authentication token', type => 'string'},
+            {desc => 'The purchase order id', type => 'number'},
+            {desc => 'The lineitem ID', type => 'number'},
+        ],
+        return => {desc => 'Streams a total versus completed counts object, event on error'}
+    }
+);
+
+sub add_li_to_po {
+    my($self, $conn, $auth, $po_id, $li_id) = @_;
+
+    my $e = new_editor(authtoken => $auth, xact => 1);
+    return $e->die_event unless $e->checkauth;
+
+    my $mgr = OpenILS::Application::Acq::BatchManager->new(editor => $e, conn => $conn);
+
+    my $po = $e->retrieve_acq_purchase_order($po_id)
+        or return $e->die_event;
+
+    my $li = $e->retrieve_acq_lineitem($li_id)
+        or return $e->die_event;
+
+    return $e->die_event unless 
+        $e->allowed('CREATE_PURCHASE_ORDER', $po->ordering_agency);
+
+    unless ($po->state =~ /new|pending/) {
+        $e->rollback;
+        return {success => 0, po => $po, error => 'bad-po-state'};
+    }
+
+    unless ($li->state =~ /new|order-ready|pending-order/) {
+        $e->rollback;
+        return {success => 0, li => $li, error => 'bad-li-state'};
+    }
+
+    $li->purchase_order($po_id);
+    $li->state('pending-order');
+    update_lineitem($mgr, $li) or return $e->die_event;
+    
+    $e->commit;
+    return {success => 1};
+}
+
 1;
 
diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
index 2d89f12..0525d48 100644
--- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
+++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
@@ -78,5 +78,8 @@
     "LOAD_TERMS_FIRST" : "You can't retrieve records until you've loaded a CSV file\nwith bibliographic IDs in the first column.",
     "SELECT_SEARCH_FIELD": "Select Search Field",
     "LIBRARY_INITIATED": "Library Initiated",
-    "DEL_LI_FROM_PO": "That item has already been ordered!  Deleting it now will not revoke or modify any order that has been placed with a vendor.  Deleting the item may put the system's idea of your purchase order in a state that is inconsistent with reality.  Are you sure you mean to do this?"
+    "DEL_LI_FROM_PO": "That item has already been ordered!  Deleting it now will not revoke or modify any order that has been placed with a vendor.  Deleting the item may put the system's idea of your purchase order in a state that is inconsistent with reality.  Are you sure you mean to do this?",
+    "ADD_LI_TO_PO_BAD_PO_STATE" : "The selected PO has already been activated",
+    "ADD_LI_TO_PO_BAD_LI_STATE" : "The selected lineitem is not in a state that can be added to a purchase order"
+
 }
diff --git a/Open-ILS/web/js/ui/default/acq/lineitem/related.js b/Open-ILS/web/js/ui/default/acq/lineitem/related.js
index c898314..0f3b91b 100644
--- a/Open-ILS/web/js/ui/default/acq/lineitem/related.js
+++ b/Open-ILS/web/js/ui/default/acq/lineitem/related.js
@@ -6,6 +6,9 @@ dojo.require("openils.PermaCrud");
 dojo.require('openils.BibTemplate');
 dojo.require('fieldmapper.OrgUtils');
 
+dojo.requireLocalization('openils.acq', 'acq');
+var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
+
 var liTable;
 var identTarget;
 var bibRecord;
@@ -112,6 +115,11 @@ function prepareButtons() {
             acqLitSavePlDialog.show();
         }
     );
+    addToPoButton.onClick = createLi(
+        function() { /* oncomplete */
+            addToPoDialog.show();
+        }
+    );
     createPoButton.onClick = createLi(
         function() { /* oncomplete */
             liTable._loadPOSelect();
@@ -139,6 +147,44 @@ function load() {
 
     prepareButtons();
     fetchRelated();
+    dojo.connect(addToPoSave, 'onClick', addToPo)
+    openils.Util.registerEnterHandler(addToPoInput.domNode, addToPo);
+}
+
+var _addToPoHappened = false;
+function addToPo(args) {
+    var poId = addToPoInput.attr('value');
+    if (!poId) return false;
+    if (_addToPoHappened) return false;
+
+    var liId =  liTable.getSelected()[0].id();
+    console.log("adding li " + liId + " to PO " + poId);
+
+    // hmm, addToPo is invoked twice for some reason...
+    _addToPoHappened = true;
+
+    fieldmapper.standardRequest(
+        ['open-ils.acq', 'open-ils.acq.purchase_order.add_lineitem'],
+        {   async : true,
+            params : [openils.User.authtoken, poId, liId],
+            oncomplete : function(r) {
+                var resp = openils.Util.readResponse(r);
+                if (resp.success) {
+                    location.href = oilsBasePath + '/acq/po/view/' + poId;
+                } else {
+                    _addToPoHappened = false;
+                    if (resp.error == 'bad-po-state') {
+                        alert(localeStrings.ADD_LI_TO_PO_BAD_PO_STATE);
+                    } else if (resp.error == 'bad-li-state') {
+                        alert(localeStrings.ADD_LI_TO_PO_BAD_LI_STATE);
+                    }
+                }
+            }
+        }
+    );
+
+    addToPoDialog.hide();
+    return false; // prevent form submission
 }
 
 openils.Util.addOnLoad(load);
diff --git a/Open-ILS/web/templates/default/acq/lineitem/related.tt2 b/Open-ILS/web/templates/default/acq/lineitem/related.tt2
index 6d47ec9..61ee19f 100644
--- a/Open-ILS/web/templates/default/acq/lineitem/related.tt2
+++ b/Open-ILS/web/templates/default/acq/lineitem/related.tt2
@@ -40,11 +40,30 @@
         <button jsId="addToPlButton" dojoType="dijit.form.Button">
             Add to Selection List
         </button>
+        <button jsId="addToPoButton" dojoType="dijit.form.Button">
+            Add to Purchase Order
+        </button>
         <button jsId="createPoButton" dojoType="dijit.form.Button">
             Create Purchase Order
         </button>
     </div>
 
+    <div class="hidden">
+        <div dojoType="dijit.Dialog" jsId='addToPoDialog'>
+            <table class='dijitTooltipTable'>
+                <tr>
+                    <td><label>Enter the PO #: </label></td>
+                    <td><input jsId='addToPoInput' dojoType="dijit.form.TextBox" /></td>
+                </tr>
+                <tr>
+                    <td colspan='2' align='center'>
+                        <button dojoType='dijit.form.Button' jsId='addToPoSave' type="submit">Save</button>
+                    </td>
+                </tr>
+            </table>
+        </div>
+    </div>
+
 </div>
 [% INCLUDE "default/acq/common/info.tt2" which = "Related" %]
 [% INCLUDE "default/acq/common/li_table.tt2" %]

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

Summary of changes:
 .../perlmods/lib/OpenILS/Application/Acq/Order.pm  |   49 ++++++++++++++++++++
 Open-ILS/web/js/dojo/openils/acq/nls/acq.js        |    5 ++-
 Open-ILS/web/js/ui/default/acq/lineitem/related.js |   46 ++++++++++++++++++
 .../web/templates/default/acq/lineitem/related.tt2 |   19 ++++++++
 4 files changed, 118 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list