From bb164799440e3bf720e0b19a59567b8874a10968 Mon Sep 17 00:00:00 2001 From: senator Date: Fri, 9 Apr 2010 20:27:50 +0000 Subject: [PATCH] Acq: Improved invoice-linking and -viewing features in LI, PO interfaces Additional miscellany: removed menu entries for deprecated lineitem search interface, added uniqueness constraint around (provider, inv_ident) on the acq.invoice table, and made subtle improvements to unified search interface git-svn-id: svn://svn.open-ils.org/ILS/trunk@16197 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/200.schema.acq.sql | 3 +- ...233.schema.acq-invoice-inv_ident-constraint.sql | 8 ++++ Open-ILS/web/css/skin/default/acq.css | 2 +- Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 3 +- .../web/js/ui/default/acq/common/inv_dialog.js | 46 +++++++++++++++++++ Open-ILS/web/js/ui/default/acq/common/li_table.js | 12 +++-- Open-ILS/web/js/ui/default/acq/po/view_po.js | 53 ++++++++++++++++------ Open-ILS/web/js/ui/default/acq/search/unified.js | 15 ++++-- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 - .../templates/default/acq/common/inv_dialog.tt2 | 30 ++++++++++++ .../web/templates/default/acq/common/li_table.tt2 | 49 +++++++++++--------- Open-ILS/web/templates/default/acq/po/view.tt2 | 22 +++++++-- .../web/templates/default/acq/search/unified.tt2 | 2 +- .../xul/staff_client/chrome/content/main/menu.js | 4 -- .../chrome/content/main/menu_frame_menus.xul | 2 - .../chrome/locale/en-US/offline.properties | 1 - 17 files changed, 193 insertions(+), 63 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0233.schema.acq-invoice-inv_ident-constraint.sql create mode 100644 Open-ILS/web/js/ui/default/acq/common/inv_dialog.js create mode 100644 Open-ILS/web/templates/default/acq/common/inv_dialog.tt2 diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 8832aa2a59..0238984241 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -60,7 +60,7 @@ CREATE TABLE config.upgrade_log ( install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() ); -INSERT INTO config.upgrade_log (version) VALUES ('0232'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0233'); -- senator CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql index 7df769d47d..42291dfd2e 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -802,7 +802,8 @@ CREATE TABLE acq.invoice ( payment_auth TEXT, payment_method TEXT REFERENCES acq.invoice_payment_method (code) DEFERRABLE INITIALLY DEFERRED, - note TEXT + note TEXT, + CONSTRAINT inv_ident_once_per_provider UNIQUE(provider, inv_ident) ); CREATE TABLE acq.invoice_entry ( diff --git a/Open-ILS/src/sql/Pg/upgrade/0233.schema.acq-invoice-inv_ident-constraint.sql b/Open-ILS/src/sql/Pg/upgrade/0233.schema.acq-invoice-inv_ident-constraint.sql new file mode 100644 index 0000000000..f2a90bde4f --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0233.schema.acq-invoice-inv_ident-constraint.sql @@ -0,0 +1,8 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('0233'); -- senator + +ALTER TABLE acq.invoice + ADD CONSTRAINT inv_ident_once_per_provider UNIQUE(provider, inv_ident); + +COMMIT; diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index ffdb200b74..6cbc1fa3db 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -222,4 +222,4 @@ option[disabled="disabled"] { font-style: italic; } .acq-inoice-item-info { font-weight: bold; } .acq-invoice-row td { border-bottom: 1px solid #e0e0e0; } .acq-invoice-invalid-amount input { color: red; font-weight: bold; } - +.acq-link-invoice-dialog td,.acq-link-invoice-dialog th {padding-top: 10px;} 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 69111224af..dca18f6f7d 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -61,5 +61,6 @@ 'INVOICE_CONFIRM_ENTRY_DETACH' : "Remove $${0} charge for item '${1}, ${2} [${3}] from the invoice?", 'INVOICE_TITLE_DETAILS' : "
${0}, by ${1} (${2})
PO: ${11}${3} Ordered, ${4} Received, ${7} Invoiced
Estimated Cost Per Item $${5} / Total Estimated Cost $${6}
", 'INVOICE_CONFIRM_PRORATE' : "Prorate charges?\n\nAny subsequent changes to the invoice that would affect prorated amounts should be resolved manually.", - 'UNNAMED': "Unnamed" + 'UNNAMED': "Unnamed", + 'NO_FIND_INVOICE': "Could not find that invoice.\nNote that the Invoice # field is case-sensitive." } diff --git a/Open-ILS/web/js/ui/default/acq/common/inv_dialog.js b/Open-ILS/web/js/ui/default/acq/common/inv_dialog.js new file mode 100644 index 0000000000..b76aa97027 --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/common/inv_dialog.js @@ -0,0 +1,46 @@ +function InvoiceLinkDialogManager(which, target) { + var self = this; + this.inv = null; + + this.linkFoundInvoice = function(r) { + self.inv = openils.Util.readResponse(r); + location.href = oilsBasePath + "/acq/invoice/view/" + self.inv.id() + + "?attach_" + self.which + "=" + self.target.id(); + }; + + this.which = which; + if (target) + this.target = target; + + new openils.widget.AutoFieldWidget({ + "fmField": "provider", + "fmClass": "acqinv", + "parentNode": dojo.byId("acq-" + this.which + "-link-invoice-provider"), + "orgLimitPerms": ["VIEW_INVOICE"], + "forceSync": true + }).build(); + + dijit.byId("acq-" + this.which + "-link-invoice-link").onClick = + function() { + self.inv = null; + pcrud.search( + "acqinv", { + "provider": dijit.byId( + "acq-" + self.which + "-link-invoice-provider" + ).attr("value"), + "inv_ident": + dijit.byId( + "acq-" + self.which + "-link-invoice-inv_ident" + ).attr("value") + }, { + "async": true, + "streaming": true, + "onresponse": self.linkFoundInvoice, + "oncomplete": function() { + if (!self.inv) + alert(localeStrings.NO_FIND_INVOICE); + } + } + ); + }; +} diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 21020b8c49..7fcaaf356f 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -6,8 +6,6 @@ dojo.require('dijit.form.FilteringSelect'); dojo.require('dijit.form.Textarea'); dojo.require('dijit.Tooltip'); dojo.require('dijit.ProgressBar'); -dojo.require('openils.User'); -dojo.require('openils.Util'); dojo.require('openils.acq.Lineitem'); dojo.require('openils.acq.PO'); dojo.require('openils.acq.Picklist'); @@ -15,7 +13,6 @@ dojo.require('openils.widget.AutoFieldWidget'); dojo.require('dojo.data.ItemFileReadStore'); dojo.require('openils.widget.ProgressDialog'); dojo.require('openils.PermaCrud'); -dojo.require('openils.XUL'); dojo.requireLocalization('openils.acq', 'acq'); var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq'); @@ -68,6 +65,7 @@ function AcqLiTable() { this.realCopiesTbody = dojo.byId('acq-lit-real-copies-tbody'); this.realCopiesRow = this.realCopiesTbody.removeChild(dojo.byId('acq-lit-real-copies-row')); this._copy_fields_for_acqdf = ['owning_lib', 'location']; + this.invoiceLinkDialogManager = new InvoiceLinkDialogManager("li"); dojo.connect(acqLitLiActionsSelector, 'onChange', function() { @@ -380,11 +378,15 @@ function AcqLiTable() { nodeByName("action_none", row).selected = true; }; actLinkInvoice.onclick = function() { - // TODO: show inv #/vendor entry then relocate to invoice attach page + self.invoiceLinkDialogManager.target = li; + acqLitLinkInvoiceDialog.show(); nodeByName("action_none", row).selected = true; }; actViewInvoice.onclick = function() { - // TODO: go to invoice search page, with lineitem filter = li.id() + location.href = oilsBasePath + + "/acq/search/unified?so=" + + base64Encode({"jub":[{"id": li.id()}]}) + + "&rt=invoice"; nodeByName("action_none", row).selected = true; }; diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index dbf27902a3..2ca7de2d57 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -1,13 +1,12 @@ dojo.require("dojo.string"); dojo.require('dijit.layout.ContentPane'); -dojo.require('openils.User'); -dojo.require('openils.Util'); dojo.require('openils.PermaCrud'); var pcrud = new openils.PermaCrud(); var PO = null; var liTable; var poNoteTable; +var invoiceLinkDialogManager; function AcqPoNoteTable() { var self = this; @@ -260,6 +259,44 @@ function makeCancelWidget(node, labelnode) { } } +function prepareInvoiceFeatures() { + /* show the count of related invoices on the "view invoices" button */ + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.invoice.unified_search.atomic"], { + "params": [ + openils.User.authtoken, + {"acqpo":[{"id": PO.id()}]}, + null, + null, + {"id_list": true} + ], + "async": true, + "oncomplete": function(r) { + dojo.byId("acq-po-view-invoice-count").innerHTML = + openils.Util.readResponse(r).length; + } + } + ); + + /* view invoices button */ + dijit.byId("acq-po-view-invoice-link").onClick = function() { + location.href = oilsBasePath + "/acq/search/unified?so=" + + base64Encode({"jub":[{"purchase_order": PO.id()}]}) + + "&rt=invoice"; + }; + + /* create invoice button */ + dijit.byId("acq-po-create-invoice-link").onClick = function() { + location.href = oilsBasePath + + "/acq/invoice/view?create=1&attach_po=" + PO.id(); + }; + + if (!invoiceLinkDialogManager) + invoiceLinkDialogManager = new InvoiceLinkDialogManager("po", PO); + + openils.Util.show("acq-po-view-invoices", "table-row"); +} + function renderPo() { dojo.byId("acq-po-view-id").innerHTML = PO.id(); dojo.byId("acq-po-view-name").innerHTML = PO.name(); @@ -288,17 +325,7 @@ function renderPo() { openils.Util.show("acq-po-split"); } - dojo.byId('acq-po-create-invoice-link').onclick = - function() { - location.href = oilsBasePath + '/acq/invoice/view?create=1&attach_po=' + poId; - }; - - dojo.byId("acq-po-view-invoice-link").onclick = - function() { - location.href = oilsBasePath + "/acq/search/unified?so=" + - base64Encode({"jub":[{"purchase_order": PO.id()}]}) + - "&rt=invoice"; - }; + prepareInvoiceFeatures(); } diff --git a/Open-ILS/web/js/ui/default/acq/search/unified.js b/Open-ILS/web/js/ui/default/acq/search/unified.js index 0a856467ad..1413238127 100644 --- a/Open-ILS/web/js/ui/default/acq/search/unified.js +++ b/Open-ILS/web/js/ui/default/acq/search/unified.js @@ -299,14 +299,18 @@ function TermManager() { var selector = this.selectorFactory.make(uniq); dojo.attr( - selector, - "onchange", - function() { self.updateRowWidget(uniq); } + selector, "onchange", function() { self.updateRowWidget(uniq); } ); var match_how = dojo.query("select", nodeByName("match", row))[0]; dojo.attr(match_how, "id", "term-match-" + uniq); dojo.attr(match_how, "selectedIndex", 0); + dojo.attr( + match_how, "onchange", + function() { + if (self.widgets[uniq]) self.widgets[uniq].focus(); + } + ); nodeByName("selector", row).appendChild(selector); nodeByName("remove", row).appendChild(this.removerButton(uniq)); @@ -564,14 +568,15 @@ openils.Util.addOnLoad( dijit.byId("acq-unified-inv-grid") ); - openils.Util.show("acq-unified-body"); - uriManager = new URIManager(); if (uriManager.search_object) { + hideForm(); + openils.Util.show("acq-unified-body"); termManager.reflect(uriManager.search_object); resultManager.search(uriManager.search_object); } else { termManager.addRow(); + openils.Util.show("acq-unified-body"); } } ); diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index 4788f830f5..49c9f427e6 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -789,8 +789,6 @@ - - diff --git a/Open-ILS/web/templates/default/acq/common/inv_dialog.tt2 b/Open-ILS/web/templates/default/acq/common/inv_dialog.tt2 new file mode 100644 index 0000000000..e83214be0c --- /dev/null +++ b/Open-ILS/web/templates/default/acq/common/inv_dialog.tt2 @@ -0,0 +1,30 @@ + +Choose invoice + + + + + + + + + + + + + diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index 1a559cd6c9..4d42f380aa 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -1,3 +1,4 @@ +
+
+ [% INCLUDE "default/acq/common/inv_dialog.tt2" which = "li" %] +
+