[open-ils-commits] r12697 - in trunk/Open-ILS/web: js/ui/default/acq/common templates/default/acq/common (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 26 17:53:08 EDT 2009
Author: erickson
Date: 2009-03-26 17:53:04 -0400 (Thu, 26 Mar 2009)
New Revision: 12697
Modified:
trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
plugging in and tweaking PO creation. more to do
Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-03-26 20:29:26 UTC (rev 12696)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js 2009-03-26 21:53:04 UTC (rev 12697)
@@ -5,6 +5,7 @@
dojo.require('openils.User');
dojo.require('openils.Util');
dojo.require('openils.acq.Lineitem');
+dojo.require('openils.acq.PO');
dojo.require('openils.widget.AutoFieldWidget');
dojo.require('dojo.data.ItemFileReadStore');
@@ -27,6 +28,11 @@
acqLitLiActionsSelector.attr('value', '_');
});
+ acqLitCreatePoSubmit.onClick = function() {
+ acqLitPoCreateDialog.hide();
+ self._createPO(acqLitPoCreateDialog.getValues());
+ }
+
dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')};
dojo.byId('acq-lit-copies-back-button').onclick = function(){self.show('list')};
@@ -99,8 +105,8 @@
return selected;
};
- this.setRowAttr = function(td, liWrapper, field) {
- var val = liWrapper.findAttr(field, 'lineitem_marc_attr_definition') || '';
+ this.setRowAttr = function(td, liWrapper, field, type) {
+ var val = liWrapper.findAttr(field, type || 'lineitem_marc_attr_definition') || '';
td.appendChild(document.createTextNode(val));
};
@@ -110,17 +116,21 @@
var row = self.rowTemplate.cloneNode(true);
row.setAttribute('li', li.id());
var tds = dojo.query('[attr]', row);
- dojo.forEach(tds, function(td) {self.setRowAttr(td, liWrapper, td.getAttribute('attr'));});
+ dojo.forEach(tds, function(td) {self.setRowAttr(td, liWrapper, td.getAttribute('attr'), td.getAttribute('attr_type'));});
dojo.query('[name=source_label]', row)[0].appendChild(document.createTextNode(li.source_label()));
+
var isbn = liWrapper.findAttr('isbn', 'lineitem_marc_attr_definition');
if(isbn) {
// XXX media prefix for added content
dojo.query('[name=jacket]', row)[0].setAttribute('src', '/opac/extras/ac/jacket/small/' + isbn);
}
- //dojo.query('[name=infolink]', row)[0].onclick = function() {self.drawInfo(li.id())};
+
dojo.query('[attr=title]', row)[0].onclick = function() {self.drawInfo(li.id())};
dojo.query('[name=copieslink]', row)[0].onclick = function() {self.drawCopies(li.id())};
dojo.query('[name=count]', row)[0].appendChild(document.createTextNode(li.item_count()));
+ dojo.query('[name=estimated_price]', row)[0].value =
+ liWrapper.findAttr('estimated_price', 'lineitem_local_attr_definition');
+
self.tbody.appendChild(row);
self.selectors.push(dojo.query('[name=selectbox]', row)[0]);
};
@@ -389,13 +399,108 @@
}
this.applySelectedLiAction = function(action) {
+ var self = this;
switch(action) {
case 'delete_selected':
- self._deleteLiList(self.getSelected());
+ this._deleteLiList(self.getSelected());
break;
+ case 'create_order':
+
+ if(!this.createPoProviderSelector) {
+ var widget = new openils.widget.AutoFieldWidget({
+ fmField : 'provider',
+ fmClass : 'acqpo',
+ parentNode : dojo.byId('acq-lit-po-provider'),
+ orgLimitPerms : ['CREATE_PURCHASE_ORDER'],
+ });
+ widget.build(
+ function(w) { self.createPoProviderSelector = w; }
+ );
+ }
+
+ acqLitPoCreateDialog.show();
+ break;
}
}
+ this._createPO = function(fields) {
+ var po = new fieldmapper.acqpo();
+ po.provider(this.createPoProviderSelector.attr('value'));
+
+ var selected = this.getSelected( (fields.create_from == 'all') );
+ console.log("creating PO for " + selected.length + ' items');
+ if(selected.length == 0) return;
+
+ openils.acq.PO.create(po, function(poId) { po.id(poId); self.postPoCreateActions(po, selected) });
+ }
+
+ this.postPoCreateActions = function(po, liList) {
+ var self = this;
+ var count = liList.length;
+ var seen = 0;
+ console.log("Created PO " + po.id());
+
+ // Attach the lineitems to the PO
+ dojo.forEach(liList,
+ function(li) {
+ console.log("updatig LI " + li.id());
+ li.purchase_order(po.id());
+ li.provider(po.provider());
+ new openils.acq.Lineitem({lineitem:li}).update(
+ function(stat) {
+ console.log("LI update stat " + stat);
+ if(++seen == count)
+ self.createPoAssets(po);
+ }
+ );
+ }
+ );
+ }
+
+ this.createPoAssets = function(po) {
+
+ console.log("creating PO assets");
+
+ /*
+ searchProgress.update({progress: 0});
+ dojo.style('searchProgress', 'visibility', 'visible');
+ */
+
+ function onresponse(r) {
+ openils.Util.readResponse(r);
+ //searchProgress.update({maximum: stat.total, progress: stat.progress});
+ }
+
+ function oncomplete(r) {
+ //dojo.style('searchProgress', 'visibility', 'hidden');
+ self.createPoDebits(po);
+ }
+
+ fieldmapper.standardRequest(
+ ['open-ils.acq','open-ils.acq.purchase_order.assets.create'],
+ { async: true,
+ params: [openils.User.authtoken, po.id()],
+ onresponse : onresponse,
+ oncomplete : oncomplete
+ }
+ );
+ }
+
+ this.createPoDebits = function (po) {
+ console.log("Creating PO debits");
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.purchase_order.debits.create'],
+ { async: true,
+ params: [openils.User.authtoken, po.id(), {encumbrance:true}],
+ oncomplete : function(r) {
+ openils.Util.readResponse(r);
+ location.href = oilsBasePath + '/eg/acq/po/view/' + po.id();
+ }
+ }
+ );
+ }
+
+
this._deleteLiList = function(list, idx) {
if(idx == null) idx = 0;
if(idx >= list.length) return;
Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-03-26 20:29:26 UTC (rev 12696)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2 2009-03-26 21:53:04 UTC (rev 12697)
@@ -6,11 +6,10 @@
<table id='acq-lit-table'>
<thead>
<tr>
- <th colspan='0' style='border:1px solid #aaa;'>
- <table style='width:100%;'><tr>
- <td><a id='acq-lit-select-toggle' href='javascript:void(0);'>Select</a></td>
- <td>
- <div style='width:100%;text-align:right;'>
+ <th style='border:1px solid #aaa;' colspan='0'>
+ <table style='width:100%;'>
+ <tr>
+ <td>
<span>
<select dojoType='dijit.form.FilteringSelect' value='_' jsId='acqLitLiActionsSelector'>
<option value='_'>--Actions--</option>
@@ -20,16 +19,29 @@
<option value='create_order'>Create Purchase Order</option>
</select>
</span>
- <span style='padding-right:15px;'>
- <a href='javascript:void(0);' id='acq-lit-prev' style='visibility:hidden'>« Previous</a>
- <a href='javascript:void(0);' id='acq-lit-next' style='visibility:hidden'>Next »</a>
- </span>
- </div>
- </td>
- </tr></table>
+ </td>
+ <td>
+ <div style='width:100%;text-align:right;'>
+ <span style='padding-right:15px;'>
+ <a href='javascript:void(0);' id='acq-lit-prev' style='visibility:hidden'>« Previous</a>
+ <a href='javascript:void(0);' id='acq-lit-next' style='visibility:hidden'>Next »</a>
+ </span>
+ </div>
+ </td>
+ </tr>
+ </table>
</th>
</tr>
</thead>
+ <tbody><tr><td colspan='0' style='height:20px;'/></tr></tbody>
+ <tbody style='font-weight:bold;border:1px solid #aaa;'>
+ <tr>
+ <td><span><a id='acq-lit-select-toggle' href='javascript:void(0);'>Select</a></span></td>
+ <td>Line Items</td>
+ <td>Estimated Price</td>
+ <td>Copies</td>
+ </tr>
+ </tbody>
<tbody id='acq-lit-tbody'>
<tr id='acq-lit-row' class='acq-lit-row'>
<td name='selector'><input type='checkbox' name='selectbox'/></td>
@@ -40,11 +52,6 @@
<td rowspan='2' style='width:43px;'><img style='width:40px;height:65px;' name='jacket'></img></td>
<td style='width:70%;font-weight:bold;'><a attr='title' href='javascript:void(0);'></a></td>
<td rowspan='2' style='text-align:right'>
- <!--
- <a name='infolink' href='javascript:void(0);' style='margin-right:10px;'>Details</a>
- -->
- <a name='copieslink' href='javascript:void(0);'
- style='margin-right:20px;'>Copies(<span name='count'></span>)</a>
</td>
</tr>
<tr class='acq-lit-alt-row'>
@@ -61,6 +68,13 @@
</tbody>
</table>
</td>
+ <td>
+ <input type='text' size='8' name='estimated_price'/>
+ </td>
+ <td>
+ <a name='copieslink' href='javascript:void(0);'
+ style='margin-right:20px;'>Copies(<span name='count'></span>)</a>
+ </td>
</tr>
</tbody>
</table>
@@ -162,5 +176,29 @@
</table>
</div>
+ <div class='hidden'>
+ <div dojoType='dijit.Dialog' jsId='acqLitPoCreateDialog'>
+ <table class='oils-generic-table'>
+ <tr>
+ <td>Provider</td>
+ <td><div name='provider' id='acq-lit-po-provider'/></td>
+ </tr>
+ <tr>
+ <td>All Lineitems</td>
+ <td><button name='create_from' value='all' dojoType='dijit.form.RadioButton'/></td>
+ </tr>
+ <tr>
+ <td>Selected Lineitems</td>
+ <td><button name='create_from' value='selected' dojoType='dijit.form.RadioButton'/></td>
+ </tr>
+ <tr>
+ <td colspan='2'>
+ <div dojoType='dijit.form.Button' type='submit' jsId='acqLitCreatePoSubmit'>Submit</div>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+
</div>
More information about the open-ils-commits
mailing list