[open-ils-commits] r16136 - in trunk/Open-ILS/web: css/skin/default js/dojo/openils/acq/nls js/ui/default/acq js/ui/default/acq/invoice templates/default/acq templates/default/acq/invoice templates/default/acq/po (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Apr 5 14:58:53 EDT 2010
Author: erickson
Date: 2010-04-05 14:58:48 -0400 (Mon, 05 Apr 2010)
New Revision: 16136
Added:
trunk/Open-ILS/web/js/ui/default/acq/invoice/
trunk/Open-ILS/web/js/ui/default/acq/invoice/attach.js
trunk/Open-ILS/web/js/ui/default/acq/invoice/common.js
trunk/Open-ILS/web/js/ui/default/acq/invoice/view.js
trunk/Open-ILS/web/templates/default/acq/invoice/
trunk/Open-ILS/web/templates/default/acq/invoice/attach.tt2
trunk/Open-ILS/web/templates/default/acq/invoice/view.tt2
Modified:
trunk/Open-ILS/web/css/skin/default/acq.css
trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
trunk/Open-ILS/web/templates/default/acq/po/view.tt2
Log:
UI for creating a new invoice and attaching a lineitem.
Stub invoice viewing interface
Modified: trunk/Open-ILS/web/css/skin/default/acq.css
===================================================================
--- trunk/Open-ILS/web/css/skin/default/acq.css 2010-04-05 18:58:47 UTC (rev 16135)
+++ trunk/Open-ILS/web/css/skin/default/acq.css 2010-04-05 18:58:48 UTC (rev 16136)
@@ -194,3 +194,10 @@
text-align:center;
border:1px solid #888;
}
+
+
+/* INVOICING */
+#oils-acq-invoice-table td { padding: 5px; }
+#acq-invoice-new-msg { font-weight: bold; margin: 10px;}
+#acq-invoice-li-details { padding: 10px; font-weight: bold; border: 1px solid #888; margin: 10px; }
+#acq-invoice-create { margin: 10px; }
Modified: trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js 2010-04-05 18:58:47 UTC (rev 16135)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js 2010-04-05 18:58:48 UTC (rev 16136)
@@ -56,4 +56,5 @@
'PO_FUND_WARNING_CONFIRM': "Are you sure? Did you see the warning about over-encumbering a fund?",
'CONFIRM_FUNDS_AT_STOP': "One or more of the selected funds has a balance below its stop level.\nYou may not be able to activate purchase orders incorporating these copies.\nContinue?",
'CONFIRM_FUNDS_AT_WARNING': "One or more of the selected funds has a balance below its warning level.\nContinue?",
+ 'INVOICE_ITEM_DETAILS' : "${0} <br/> ${1} <br/> ${2}. <br/> Estimated Price: $${3}. <br/> Lineitem ID: ${4} <br/> PO: ${5} <br/> Order Date: ${6}",
}
Added: trunk/Open-ILS/web/js/ui/default/acq/invoice/attach.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/invoice/attach.js (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/acq/invoice/attach.js 2010-04-05 18:58:48 UTC (rev 16136)
@@ -0,0 +1,162 @@
+dojo.require('dojo.date.locale');
+dojo.require('dojo.date.stamp');
+dojo.require('dijit.layout.ContentPane');
+dojo.require('dijit.form.TextBox');
+dojo.require('dijit.form.NumberTextBox');
+dojo.require('dijit.form.CurrencyTextBox');
+dojo.require('openils.User');
+dojo.require('openils.Util');
+dojo.require('openils.PermaCrud');
+dojo.require('openils.widget.AutoFieldWidget');
+
+dojo.requireLocalization('openils.acq', 'acq');
+var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
+
+var pcrud = new openils.PermaCrud();
+var cgi = new openils.CGI();
+var doCreate = false;
+var invoiceId;
+var lineitem;
+var invoicePane;
+var entryPane;
+
+function init() {
+
+ invoiceId = cgi.param('invoice_id');
+ doCreate = cgi.param('create');
+ attachLi = cgi.param('attach_li');
+
+ invoicePane = drawInvoicePane(dojo.byId('acq-view-invoice-div'));
+
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.lineitem.retrieve"], {
+ async: true,
+ params: [openils.User.authtoken, attachLi, {
+ flesh_attrs: true,
+ flesh_li_details: true,
+ flesh_cancel_reason: true,
+ flesh_po : true,
+ flesh_pl : true
+ }],
+ oncomplete: function(r) {
+ lineitem = openils.Util.readResponse(r);
+ drawPage();
+ }
+ }
+ );
+
+ dojo.connect(createInvoiceButton, 'onClick', function() { createInvoice(); });
+}
+
+function liMarcAttr(name) {
+ var attr = lineitem.attributes().filter(
+ function(attr) {
+ if(
+ attr.attr_type() == 'lineitem_marc_attr_definition' &&
+ attr.attr_name() == name)
+ return attr
+ }
+ )[0];
+ return (attr) ? attr.attr_value() : '';
+}
+
+function drawPage() {
+
+ var idents = [];
+ if(liMarcAttr('isbn')) idents.push(liMarcAttr('isbn'));
+ if(liMarcAttr('upc')) idents.push(liMarcAttr('upc'));
+ if(liMarcAttr('issn')) idents.push(liMarcAttr('issn'));
+
+ var orderDate = '';
+ var po = lineitem.purchase_order();
+ if(po.order_date()) {
+ var dt = dojo.date.stamp.fromISOString(po.order_date());
+ orderDate = dojo.date.locale.format(dt, {selector:'date'});
+ }
+
+ dojo.byId('acq-invoice-li-details').innerHTML =
+ dojo.string.substitute(
+ localeStrings.INVOICE_ITEM_DETAILS,
+ [
+ liMarcAttr('title'),
+ liMarcAttr('author'),
+ idents.join(','),
+ lineitem.estimated_unit_price() || '',
+ lineitem.id(),
+ lineitem.purchase_order().name(),
+ orderDate
+ ]
+ );
+
+ //invoicePo.attr('value', lineitem.purchase_order().name());
+ //invoicePo.attr('disabled', true);
+
+ //numCopiesInvoiced.attr('value', lineitem.lineitem_details().length);
+
+ var numReceived = 0;
+ dojo.forEach(lineitem.lineitem_details(), function(lid) { if(lid.recv_time) numReceived++ });
+ //numCopiesReceived.attr('value', numReceived);
+
+ entryPane = new openils.widget.EditPane({
+ fmClass : 'acqie',
+ mode : 'create',
+ hideActionButtons : true,
+ existingTable : invoicePane.table,
+ overrideWidgetArgs : {
+ inv_item_count : {widgetValue : numReceived},
+ phys_item_count : {widgetValue : numReceived}
+ },
+ fieldOrder : [
+ 'purchase_order',
+ 'inv_item_count',
+ 'phys_item_count',
+ 'cost_billed',
+ 'note'
+ ],
+ suppressFields : [
+ 'invoice',
+ 'purchase_order',
+ 'lineitem',
+ 'actual_cost'
+ ]
+ });
+ entryPane.startup();
+
+}
+
+
+function createInvoice() {
+
+ var inv = new fieldmapper.acqinv();
+ dojo.forEach(invoicePane.fieldList,
+ function(field) {
+ inv[field.name]( field.widget.getFormattedValue() );
+ }
+ );
+
+ var entry = new fieldmapper.acqie();
+ dojo.forEach(entryPane.fieldList,
+ function(field) {
+ entry[field.name]( field.widget.getFormattedValue() );
+ }
+ );
+ entry.purchase_order(lineitem.purchase_order().id());
+ entry.lineitem(lineitem.id());
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.invoice.create'],
+ {
+ params : [openils.User.authtoken, inv, [entry]],
+ oncomplete : function(r) {
+ var resp = openils.Util.readResponse(r);
+ if(resp) {
+ location.href =
+ location.href.replace(/invoice\/attach.*/, 'invoice/view/' + resp.id());
+ }
+ }
+ }
+ );
+}
+
+openils.Util.addOnLoad(init);
+
Added: trunk/Open-ILS/web/js/ui/default/acq/invoice/common.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/invoice/common.js (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/acq/invoice/common.js 2010-04-05 18:58:48 UTC (rev 16136)
@@ -0,0 +1,36 @@
+dojo.require('dojo.date.stamp');
+dojo.require('openils.User');
+dojo.require('openils.widget.EditPane');
+
+function drawInvoicePane(parentNode, inv) {
+
+ var override;
+ if(!inv) {
+ override = {
+ recv_date : {widgetValue : dojo.date.stamp.toISOString(new Date())},
+ receiver : {widgetValue : openils.User.user.ws_ou()},
+ recv_method : {widgetValue : 'PPR'}
+ };
+ }
+
+ var pane = new openils.widget.EditPane({
+ fmObject : inv,
+ fmClass : 'acqinv',
+ mode : (inv) ? 'edit' : 'create',
+ hideActionButtons : true,
+ overrideWidgetArgs : override,
+ fieldOrder : [
+ 'inv_ident',
+ 'recv_date',
+ 'recv_method',
+ 'inv_type',
+ 'provider',
+ 'shipper'
+ ]
+ });
+
+ pane.startup();
+ parentNode.appendChild(pane.domNode);
+ return pane;
+}
+
Added: trunk/Open-ILS/web/js/ui/default/acq/invoice/view.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/invoice/view.js (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/acq/invoice/view.js 2010-04-05 18:58:48 UTC (rev 16136)
@@ -0,0 +1,30 @@
+dojo.require('dojo.date.locale');
+dojo.require('dojo.date.stamp');
+dojo.require('openils.User');
+dojo.require('openils.Util');
+dojo.require('openils.PermaCrud');
+dojo.require('openils.widget.EditPane');
+
+dojo.requireLocalization('openils.acq', 'acq');
+var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
+
+var pcrud = new openils.PermaCrud();
+var invoice;
+
+function init() {
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.invoice.retrieve'],
+ {
+ params : [openils.User.authtoken, invoiceId],
+ oncomplete : function(r) {
+ invoice = openils.Util.readResponse(r);
+ drawInvoicePane(dojo.byId('acq-view-invoice-div'), invoice);
+ }
+ }
+ );
+}
+
+openils.Util.addOnLoad(init);
+
+
Added: trunk/Open-ILS/web/templates/default/acq/invoice/attach.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/invoice/attach.tt2 (rev 0)
+++ trunk/Open-ILS/web/templates/default/acq/invoice/attach.tt2 2010-04-05 18:58:48 UTC (rev 16136)
@@ -0,0 +1,31 @@
+[% WRAPPER 'default/base.tt2' %]
+[% ctx.page_title = 'Attach Invoice Entry' %]
+<script src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/common.js'> </script>
+<script src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/attach.js'> </script>
+<script type="text/javascript">var invoiceId = '[% ctx.page_args.0 %]';</script>
+<div dojoType="dijit.layout.ContentPane" style="height:100%">
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" class='oils-header-panel'>
+ <div> Attach Invoice Entry </div>
+ <div> </div>
+ </div>
+
+ <div id='acq-invoice-li-details'>
+ </div>
+
+ <div id='acq-invoice-new-msg'>
+ This will create a new invoice. To link this item to an existing invoice,
+ click <a href='javascript:void(0);' id='acq-invoice-link-existing'>here</a>.
+ </div>
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+
+ <!-- load the generic invoice table -->
+ <div id='acq-invoice-create'>
+ <div><div id='acq-view-invoice-div'/></div>
+ <button dojoType='dijit.form.Button' jsId='createInvoiceButton'>Create & Continue</button>
+ </div>
+
+ </div>
+</div>
+[% END %]
Added: trunk/Open-ILS/web/templates/default/acq/invoice/view.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/invoice/view.tt2 (rev 0)
+++ trunk/Open-ILS/web/templates/default/acq/invoice/view.tt2 2010-04-05 18:58:48 UTC (rev 16136)
@@ -0,0 +1,18 @@
+[% WRAPPER 'default/base.tt2' %]
+[% ctx.page_title = 'Invoice' %]
+<script src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/common.js'> </script>
+<script src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/view.js'> </script>
+<script type="text/javascript">var invoiceId = '[% ctx.page_args.0 %]';</script>
+<div dojoType="dijit.layout.ContentPane" style="height:100%">
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client" class='oils-header-panel'>
+ <div> Invoice </div>
+ <div> </div>
+ </div>
+
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+ <div id='acq-view-invoice-div'/>
+ </div>
+
+</div>
+[% END %]
Modified: trunk/Open-ILS/web/templates/default/acq/po/view.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/po/view.tt2 2010-04-05 18:58:47 UTC (rev 16135)
+++ trunk/Open-ILS/web/templates/default/acq/po/view.tt2 2010-04-05 18:58:48 UTC (rev 16136)
@@ -50,6 +50,12 @@
</td>
</tr>
<tr><td><a class="hidden" id="acq-po-split" href="javascript:void(0);" onclick="if (confirm(localeStrings.CONFIRM_SPLIT_PO)) splitPo();">Split Order by Lineitems</a></td></tr>
+ <tr id='acq-po-invoices'> <!-- TODO: hidden until applicable -->
+ <td>Invoice(s)</td>
+ <td>
+ <a href="javascript:void(0);" id="acq-po-view-invoices">(0)</a>
+ </td>
+ </tr>
</table>
</div>
</div>
More information about the open-ils-commits
mailing list