$picklist = $mgr->editor->retrieve_acq_picklist($picklist) unless ref $picklist;
$picklist->edit_time('now');
$picklist->editor($mgr->editor->requestor->id);
- $mgr->picklist($picklist);
- return $picklist if $mgr->editor->update_acq_picklist($picklist);
- return undef;
+ if ($mgr->editor->update_acq_picklist($picklist)) {
+ $picklist = $mgr->editor->retrieve_acq_picklist($mgr->editor->data);
+ $mgr->picklist($picklist);
+ return $picklist;
+ } else {
+ return undef;
+ }
}
sub delete_picklist {
# XXX perms on each picklist modified
+ $lead_pl = $e->retrieve_acq_picklist($lead_pl) or return $e->die_event;
# point all of the lineitems at the lead picklist
my $li_ids = $e->search_acq_lineitem({picklist => $pl_list}, {idlist => 1});
$e->delete_acq_picklist($pl) or return $e->die_event;
}
+ update_picklist($mgr, $lead_pl) or return $e->die_event;
+
$e->commit;
return $mgr->respond_complete;
}
--- /dev/null
+function getInvIdent(rowIndex, item) {
+ if (item) {
+ return {
+ "inv_ident": this.grid.store.getValue(item, "inv_ident") ||
+ this.grid.store.getValue(item, "id"),
+ "id": this.grid.store.getValue(item, "id")
+ };
+ }
+}
+
+function formatInvIdent(inv) {
+ if (inv) {
+ return "<a href='" + oilsBasePath + "/acq/invoice/view/" +
+ inv.id + "'>" + inv.inv_ident + "</a>";
+ }
+}
+
+function printInvoiceVouchers() {
+ var inv_ids = dijit.byId("acq-unified-inv-grid").
+ getSelectedItems().map(function(o) {return o.id[0];});
+
+ /* XXX this business about opening a window and populating its
+ * body should be wrapped up in a simple dijit or something.
+ * consolidate with claim_voucher.js maybe. */
+ if (inv_ids.length) {
+ var win = null;
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.invoice.print.html"], {
+ "params": [openils.User.authtoken, inv_ids],
+ "async": true,
+ "onresponse": function(r) {
+ if (r = openils.Util.readResponse(r)) {
+ if (!win) {
+ win = window.open(
+ "", "", "resizable,width=800," +
+ "height=600,scrollbars=1"
+ );
+ win.document.title = localeStrings.INVOICES;
+ win.document.body.innerHTML =
+ "<style type='text/css'>.acq-invoice-" +
+ "voucher {page-break-after:always;}" +
+ "</style>\n";
+ }
+ win.document.body.innerHTML +=
+ r.template_output().data();
+ }
+ },
+ "oncomplete": function() { win.print(); }
+ }
+ );
+ }
+}
--- /dev/null
+dojo.require("dojo.data.ItemFileWriteStore");
+dojo.require("dijit.Dialog");
+dojo.require("dijit.form.Button");
+dojo.require("dijit.form.TextBox");
+dojo.require("dijit.form.FilteringSelect");
+dojo.require("dijit.form.Button");
+dojo.require("dojox.grid.cells.dijit");
+dojo.require("openils.acq.Picklist");
+dojo.require("openils.widget.ProgressDialog");
+
+function getPlOwnerName(rowIndex, item) {
+ try {
+ return resultManager.plCache[this.grid.store.getValue(item, "id")].
+ owner().usrname();
+ } catch (E) {
+ return "";
+ }
+}
+
+function formatPlName(pl) {
+ if (pl) {
+ return "<a href='" + oilsBasePath + "/acq/picklist/view/" +
+ pl.id + "'>" + pl.name + "</a>";
+ }
+}
+
+function deleteSelectedPl() {
+ var grid = resultManager.result_types.picklist.interface;
+
+ progressDialog.show(true);
+
+ openils.acq.Picklist.deleteList(
+ grid.getSelectedItems().map(
+ function(item) {
+ var id = grid.store.getValue(item, "id");
+ grid.store.deleteItem(item);
+ return id;
+ }
+ ), function() { progressDialog.hide(); }
+ );
+}
+
+function cloneSelectedPl(fields) {
+ var grid = resultManager.result_types.picklist.interface;
+
+ var item = grid.getSelectedItems()[0];
+ if (!item) return;
+
+ var plId = grid.store.getValue(item, "id");
+ var entryCount = Number(grid.store.getValue(item, "entry_count"));
+
+ progressDialog.show();
+ progressDialog.update({"maximum": entryCount, "progress": 0});
+
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.picklist.clone"], {
+ "async": true,
+ "params": [openils.User.authtoken, plId, fields.name],
+ "onresponse": function(r) {
+ var resp = openils.Util.readResponse(r);
+ if (resp) {
+ progressDialog.update({"progress": resp.li});
+
+ if (resp.complete) {
+ progressDialog.hide();
+ var pl = resp.picklist;
+ pl.owner(openils.User.user);
+ pl.entry_count(entryCount);
+ resultManager.plCache[pl.id()] = pl;
+ grid.store.newItem(fieldmapper.acqpl.toStoreItem(pl));
+ }
+ }
+ }
+ }
+ );
+}
+
+function loadLeadPlSelector() {
+ var grid = resultManager.result_types.picklist.interface;
+ var data = acqpl.initStoreData();
+ var store = new dojo.data.ItemFileWriteStore({"data": data});
+
+ grid.getSelectedItems().forEach(
+ function(item) {
+ store.newItem(
+ fieldmapper.acqpl.toStoreItem(
+ resultManager.plCache[grid.store.getValue(item, "id")]
+ )
+ );
+ }
+ );
+
+ plMergeLeadSelector.store = store;
+ plMergeLeadSelector.startup();
+}
+
+function mergeSelectedPl(fields) {
+ var grid = resultManager.result_types.picklist.interface;
+
+ if (!fields.lead) return;
+
+ var ids = [];
+ var totalLi = 0;
+ var leadPl = resultManager.plCache[fields.lead];
+ var leadPlItem;
+
+ grid.getSelectedItems().forEach(
+ function(item) {
+ var id = grid.store.getValue(item, "id");
+ if (id == fields.lead) {
+ leadPlItem = item;
+ return;
+ }
+ totalLi += new Number(grid.store.getValue(item, "entry_count"));
+ ids.push(id);
+ }
+ );
+
+ progressDialog.show();
+ progressDialog.update({"maximum": totalLi, "progress": 0});
+
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.picklist.merge"], {
+ "async": true,
+ "params": [openils.User.authtoken, fields.lead, ids],
+ "onresponse": function(r) {
+ var resp = openils.Util.readResponse(r);
+ if (resp) {
+ if (resp.li)
+ progressDialog.update({"progress": resp.li});
+
+ if (resp.complete) {
+ progressDialog.hide();
+ leadPl.entry_count(leadPl.entry_count() + totalLi);
+
+ grid.store.setValue(
+ leadPlItem, "entry_count", leadPl.entry_count()
+ );
+ if (resp.picklist) {
+ grid.store.setValue(
+ leadPlItem, "edit_time",
+ resp.picklist.edit_time()
+ );
+ }
+
+ // remove the deleted lists from the grid
+ grid.getSelectedItems().filter(
+ function(o) {
+ return grid.store.getValue(o, "id") !=
+ fields.lead;
+ }
+ ).forEach(function(o) { grid.store.deleteItem(o); });
+ }
+ }
+ }
+ }
+ );
+}
+
+function createPl(fields) {
+ if (fields.name == '') return;
+
+ var grid = resultManager.result_types.picklist.interface;
+
+ openils.acq.Picklist.create(fields,
+ function(plId) {
+ fieldmapper.standardRequest(
+ ["open-ils.acq", "open-ils.acq.picklist.retrieve"], {
+ "async": true,
+ "params": [
+ openils.User.authtoken, plId,
+ {"flesh_lineitem_count": 1, "flesh_owner": 1}
+ ],
+ "oncomplete": function(r) {
+ var pl = openils.Util.readResponse(r);
+ if (pl) {
+ resultManager.plCache[pl.id()] = pl;
+ grid.store.newItem(
+ acqpl.toStoreData([pl]).items[0]
+ );
+ }
+ }
+ }
+ );
+ }
+ );
+}
+
--- /dev/null
+ function formatPoName(po) {
+ if (po) {
+ return "<a href='" + oilsBasePath + "/acq/po/view/" + po.id +
+ "'>" + po.name + "</a>";
+ }
+ }
+
}
}
+/* minor formatting function used by autogrids in unified.tt2 */
+function getName(rowIndex, item) {
+ if (item) {
+ return {
+ "name": this.grid.store.getValue(item, "name") ||
+ localeStrings.UNNAMED,
+ "id": this.grid.store.getValue(item, "id")
+ };
+ }
+}
+
/* quickly find elements by the value of a "name" attribute */
function nodeByName(name, root) {
return dojo.query("[name='" + name + "']", root)[0];
[% WRAPPER "default/base.tt2" %]
[% ctx.page_title = "Acquisitions Search" %]
-<script src="[% ctx.media_prefix %]/js/ui/default/acq/common/base64.js">
-</script>
-<script src="[% ctx.media_prefix %]/js/ui/default/acq/search/unified.js">
-</script>
-<script type="text/javascript">
- /* The functions in this <script> element are for formatting/getting
- fields for autogrids, and doing misc operations on specific
- result types. General unified search code is in unified.js. */
- function getName(rowIndex, item) {
- if (item) {
- return {
- "name": this.grid.store.getValue(item, "name") ||
- localeStrings.UNNAMED,
- "id": this.grid.store.getValue(item, "id")
- };
- }
- }
-
- function getInvIdent(rowIndex, item) {
- if (item) {
- return {
- "inv_ident": this.grid.store.getValue(item, "inv_ident") ||
- this.grid.store.getValue(item, "id"),
- "id": this.grid.store.getValue(item, "id")
- };
- }
- }
-
- function getPlOwnerName(rowIndex, item) {
- try {
- return resultManager.plCache[this.grid.store.getValue(item, "id")].
- owner().usrname();
- } catch (E) {
- return "";
- }
- }
-
- function formatPoName(po) {
- if (po) {
- return "<a href='" + oilsBasePath + "/acq/po/view/" + po.id +
- "'>" + po.name + "</a>";
- }
- }
-
- function formatPlName(pl) {
- if (pl) {
- return "<a href='" + oilsBasePath + "/acq/picklist/view/" +
- pl.id + "'>" + pl.name + "</a>";
- }
- }
-
- function formatInvIdent(inv) {
- if (inv) {
- return "<a href='" + oilsBasePath + "/acq/invoice/view/" +
- inv.id + "'>" + inv.inv_ident + "</a>";
- }
- }
-
- /* XXX consider separate per-result-type .js files to separate functions
- * like these into */
- function printInvoiceVouchers() {
- var inv_ids = dijit.byId("acq-unified-inv-grid").
- getSelectedItems().map(function(o) {return o.id[0];});
-
- /* XXX this business about opening a window and populating its
- * body should be wrapped up in a simple dijit or something.
- * consolidate with claim_voucher.js maybe. */
- if (inv_ids.length) {
- var win = null;
- fieldmapper.standardRequest(
- ["open-ils.acq", "open-ils.acq.invoice.print.html"], {
- "params": [openils.User.authtoken, inv_ids],
- "async": true,
- "onresponse": function(r) {
- if (r = openils.Util.readResponse(r)) {
- if (!win) {
- win = window.open(
- "", "", "resizable,width=800," +
- "height=600,scrollbars=1"
- );
- win.document.title = localeStrings.INVOICES;
- win.document.body.innerHTML =
- "<style type='text/css'>.acq-invoice-" +
- "voucher {page-break-after:always;}" +
- "</style>\n";
- }
- win.document.body.innerHTML +=
- r.template_output().data();
- }
- },
- "oncomplete": function() { win.print(); }
- }
- );
- }
- }
-
-</script>
-<!-- later: "[% ctx.page_args.0 %]" -->
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/common/base64.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/search/unified.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/search/invoice.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/search/picklist.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/acq/search/purchase_order.js"></script>
<div id="acq-unified-body" class="hidden">
<div id="acq-unified-heading">
<span id="acq-unified-heading-actual">Acquisitions Search</span>
</table>
</div>
<div id="acq-unified-results-picklist" class="hidden">
+ <div class="acq-unified-result-specific-controls">
+ <div dojoType="dijit.form.DropDownButton">
+ <span>New Selection List</span>
+ <div dojoType="dijit.TooltipDialog"
+ execute="createPl(arguments[0]);">
+ <table class="dijitTooltipTable">
+ <tr>
+ <td><label for="name">Name:</label></td>
+ <td><input dojoType="dijit.form.TextBox"
+ name="name"/></td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <button dojoType="dijit.form.Button"
+ type="submit">Create</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div dojoType="dijit.form.DropDownButton">
+ <span>Clone Selected</span>
+ <div dojoType="dijit.TooltipDialog"
+ execute="cloneSelectedPl(arguments[0]);">
+ <table class="dijitTooltipTable">
+ <tr>
+ <td><label for="name">New Name:</label></td>
+ <td><input dojoType="dijit.form.TextBox"
+ name="name"/></td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <button dojoType="dijit.form.Button"
+ type="submit">Clone</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div dojoType="dijit.form.DropDownButton">
+ <span>Merge Selected</span>
+ <div dojoType="dijit.TooltipDialog"
+ execute="mergeSelectedPl(arguments[0]);"
+ jsId="plMergeDialog">
+ <script type="dojo/connect" event="onOpen">
+ loadLeadPlSelector();
+ </script>
+ <table class="dijitTooltipTable">
+ <tr>
+ <td><label for="name">Choose the Lead
+ Selection List:</label></td>
+ <td><input jsId="plMergeLeadSelector"
+ dojoType="dijit.form.FilteringSelect"
+ name="lead" /></td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">
+ <button dojoType="dijit.form.Button"
+ type="submit">Merge</button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <button dojoType="dijit.form.Button"
+ onclick="deleteSelectedPl();">Delete Selected</button>
+ </div>
<table
id="acq-unified-pl-grid"
autoHeight="true"
[% INCLUDE "default/acq/common/li_table.tt2" %]
</div>
</div>
-
[% END %]
<command id="cmd_open_vandelay" />
<command id="cmd_acq_create_invoice" />
- <command id="cmd_acq_view_picklist" />
+ <!-- <command id="cmd_acq_view_picklist" /> -->
<command id="cmd_acq_upload" />
<command id="cmd_acq_view_po" />
<!-- <command id="cmd_acq_view_po_events" /> -->
<menuitem label="&staff.main.menu.acq.bib_search.label;" accesskey="&staff.main.menu.acq.bib_search.accesskey;" command="cmd_acq_bib_search"/>
<menuitem label="&staff.main.menu.acq.from_bib.label;" accesskey="&staff.main.menu.acq.from_bib.accesskey;" command="cmd_acq_from_bib"/>
<!-- <menuitem label="&staff.main.menu.acq.po.label;" accesskey="&staff.main.menu.acq.po.accesskey;" command="cmd_acq_view_po" /> -->
- <menuitem label="&staff.main.menu.acq.picklist.label;" accesskey="&staff.main.menu.acq.picklist.accesskey;" command="cmd_acq_view_picklist"/>
+ <!-- <menuitem label="&staff.main.menu.acq.picklist.label;" accesskey="&staff.main.menu.acq.picklist.accesskey;" command="cmd_acq_view_picklist"/> -->
<menuseparator />
<menuitem label="&staff.main.menu.acq.create_invoice.label;" accesskey="&staff.main.menu.acq.create_invoice.accesskey;" command="cmd_acq_create_invoice"/>
<menuitem label="&staff.main.menu.acq.upload.label;" accesskey="&staff.main.menu.acq.upload.accesskey;" command="cmd_acq_upload"/>