var self = this;
this.liCache = {};
+ this.plCache = {};
+ this.poCache = {};
this.toggleState = false;
this.tbody = dojo.byId('acq-lit-tbody');
this.selectors = [];
self._savePl(acqLitSavePlDialog.getValues());
}
+ acqLitCancelLiStateButton.onClick = function() {
+ acqLitChangeLiStateDialog.hide();
+ }
+ acqLitSaveLiStateButton.onClick = function() {
+ acqLitChangeLiStateDialog.hide();
+ self._updateLiState(acqLitChangeLiStateDialog.getValues(), acqLitChangeLiStateDialog.attr('state'));
+ }
+
//dojo.byId('acq-lit-notes-new-button').onclick = function(){acqLitCreateLiNoteDialog.show();}
dojo.query('[name=notes_count]', row)[0].innerHTML = li.lineitem_notes().length;
dojo.query('[name=noteslink]', row)[0].onclick = function() {self.drawLiNotes(li)};
+ // show which PO this lineitem is a member of
if(li.purchase_order() && !this.isPO) {
- openils.Util.show(nodeByName('po', row), 'inline');
- nodeByName('po_link', row).setAttribute('href', oilsBasePath + '/acq/po/view/' + li.purchase_order());
+ var po =
+ this.poCache[li.purchase_order()] =
+ this.poCache[li.purchase_order()] ||
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.purchase_order.retrieve'],
+ {params: [this.authtoken, li.purchase_order()]});
+ if(po) {
+ openils.Util.show(nodeByName('po', row), 'inline');
+ var link = nodeByName('po_link', row);
+ link.setAttribute('href', oilsBasePath + '/acq/po/view/' + li.purchase_order());
+ link.innerHTML = 'PO: ' + po.name(); // TODO i18n
+ }
+ }
+
+ // show which picklist this lineitem is a member of
+ if(li.picklist() && this.isPO) {
+ var pl =
+ this.plCache[li.picklist()] =
+ this.plCache[li.picklist()] ||
+ fieldmapper.standardRequest(
+ ['open-ils.acq', 'open-ils.acq.picklist.retrieve'],
+ {params: [this.authtoken, li.picklist()]});
+ if(pl) {
+ openils.Util.show(nodeByName('pl', row), 'inline');
+ var link = nodeByName('pl_link', row);
+ link.setAttribute('href', oilsBasePath + '/acq/picklist/view/' + li.picklist());
+ link.innerHTML = 'PL: '+pl.name(); // TODO i18n
+ }
}
var countNode = nodeByName('count', row);
// lineitem state
nodeByName('li_state', row).innerHTML = li.state(); // TODO i18n state labels
+ openils.Util.addCSSClass(row, 'oils-acq-li-state-' + li.state());
// lineitem price
var priceInput = dojo.query('[name=price]', row)[0];
acqLitSavePlDialog.show();
break;
+ case 'selector_ready':
+ case 'order_ready':
+ acqLitChangeLiStateDialog.attr('state', action.replace('_', '-'));
+ acqLitChangeLiStateDialog.show();
+ break;
+
case 'print_po':
this.printPO();
break;
}
}
+ this._updateLiState = function(values, state) {
+ var self = this;
+ var selected = this.getSelected( (values.which == 'all') );
+ if(!selected.length) return;
+ dojo.forEach(selected, function(li) {li.state(state);});
+ self._updateLiList(null, selected, 0,
+ // TODO consider inline updates for efficiency
+ function() { location.href = location.href }
+ );
+ }
+
this._updateLiList = function(pl, list, idx, oncomplete) {
if(idx >= list.length) return oncomplete();
var li = list[idx];
- li.picklist(pl);
+ if(pl != null) li.picklist(pl);
litGenericProgress.update({maximum: list.length, progress: idx});
new openils.acq.Lineitem({lineitem:li}).update(
function(r) {
<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>
+ <span name='pl' class='hidden'>(<a name='pl_link' href='javascript:void(0);'></a>)</span>
<span name='po' class='hidden'>(<a name='po_link' href='javascript:void(0);'>PO</a>)</span>
</td>
<td rowspan='2' style='text-align:right'>
<button jsId='acqLitCreateLiNoteSubmit' dojoType='dijit.form.Button' type="submit">Create</button>
</div>
</div>
-
<div dojoType='dijit.form.Button' id='acq-lit-notes-save-button'>Save Changes</div>
</td>
</tr>
</table>
</div>
+ <div dojoType="dijit.Dialog" jsId='acqLitChangeLiStateDialog'>
+ <table class='dijitTooltipTable'>
+ <tr>
+ <td>
+ <input dojoType="dijit.form.RadioButton" name="which" type='radio' checked='checked' value='selected'/>
+ <label for="name">Mark selected</label>
+ <input dojoType="dijit.form.RadioButton" name="which" type='radio' value='all'/>
+ <label for="name">Mark all</label>
+ </td>
+ </tr>
+ <tr>
+ <td colspan='2' align='center'>
+ <button dojoType='dijit.form.Button' type="submit" jsId='acqLitCancelLiStateButton'>Cancel</button>
+ <button dojoType='dijit.form.Button' type="submit" jsId='acqLitSaveLiStateButton'>Go</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+
<div class='hidden'>
<div dojoType='openils.widget.ProgressDialog' jsId='progressDialog'/>
</div>