[% WRAPPER 'base.tt2' %]
[% ctx.page_title = 'Invoicing' %]
-<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>
<div dojoType="dijit.layout.ContentPane" layoutAlign="client">
- <table class='oils-acq-invoice-table'>
+ <button dojoType='dijit.form.Button' onClick='renderUnifiedSearch()'>Search</button>
+ <table id='oils-acq-invoice-table' class='oils-acq-invoice-table'>
<thead/>
<tbody id='acq-invoice-entry-header' class='hidden'>
<tr>
<td colspan='0'>
- <h3>Bibliographic Items</h3>
+ <h3>
+ [% l('Bibliographic Items') %]
+ </h3>
</td>
</tr>
</tbody>
</tbody>
</table>
</div>
+
+ <!-- slim, inline unified search UI -->
+ <div id='oils-acq-invoice-search' class='hidden'>
+
+ <div id="acq-unified-form">
+ <div>
+ <label for="acq-unified-result-type">Search for</label>
+ <select id="acq-unified-result-type">
+ <option value="lineitem">line items</option>
+ <option value="lineitem_and_bib">
+ line items & catalog records
+ </option>
+ <option value="picklist">selection lists</option>
+ <option value="purchase_order">purchase orders</option>
+ <option value="invoice">invoices</option>
+ </select>
+ <label for="acq-unified-conjunction">matching</label>
+ <select id="acq-unified-conjunction">
+ <option value="and">all</option>
+ <option value="or">any</option>
+ </select>
+ <label for="acq-unified-conjunction">
+ of the following terms:
+ </label>
+ </div>
+ <div id="acq-unified-terms">
+ <table id="acq-unified-terms-table">
+ <tbody id="acq-unified-terms-tbody">
+ <tr id="acq-unified-terms-row-tmpl"
+ class="acq-unified-terms-row">
+ <td name="selector"
+ class="acq-unified-terms-selector"></td>
+ <td name="match"
+ class="acq-unified-terms-match">
+ <select>
+ <option value="">is</option>
+ <option value="__not">is NOT</option>
+ <option value="__fuzzy" disabled="disabled">
+ contains
+ </option>
+ <option value="__not,__fuzzy"
+ disabled="disabled">
+ does NOT contain
+ </option>
+ <option value="__lte" disabled="disabled">
+ is on or BEFORE
+ </option>
+ <option value="__gte" disabled="disabled">
+ is on or AFTER
+ </option>
+ <option value="__in" disabled="disabled">
+ matches a term from a file
+ </option>
+ </select>
+ </td>
+ <td name="widget"
+ class="acq-unified-terms-widget"></td>
+ <td name="remove"
+ class="acq-unified-terms-remove"></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ <div id="acq-unified-add-term">
+ <button onclick="termManager.addRow()">Add Search Term</button>
+ </div>
+ <div>
+ <button
+ onclick="resultManager.go(termManager.buildSearchObject())">
+ Search
+ </button>
+ </div>
+ </div> <!-- end search form -->
+ <div id='acq-invoice-search-results-div'>
+ <button dojoType='dijit.form.Button'>Add Selected Items</button><br/>
+ </div>
+ </div>
</div>
<div dojoType='openils.widget.ProgressDialog' jsId='progressDialog'></div>
<div jsId='extraItemsDialog' dojoType="dijit.Dialog" title="Extra Items">
<button dojoType='dijit.form.Button' jsId='extraCopiesGo'>Add New Items</button>
</div>
</div>
+<script type="text/javascript">
+ var invoiceId = '[% ctx.page_args.0 %]';
+ var unifiedSearchMode = 'invoice';
+</script>
+<script type="text/javascript" src="[% ctx.media_prefix %]/js/ui/default/acq/search/unified.js"></script>
<script type="text/javascript" src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/common.js'> </script>
<script type="text/javascript" src='[% ctx.media_prefix %]/js/ui/default/acq/invoice/view.js'> </script>
[% END %]
dojo.require('dojo.date.locale');
dojo.require('dojo.date.stamp');
dojo.require('dijit.form.CheckBox');
+dojo.require('dijit.form.Button');
dojo.require('dijit.form.CurrencyTextBox');
dojo.require('dijit.form.NumberTextBox');
dojo.require('openils.User');
var extraCopies = {};
var extraCopiesFund;
var widgetRegistry = {acqie : {}, acqii : {}};
+var searchInitDone = false;
+var termManager;
+var resultManager;
function nodeByName(name, context) {
return dojo.query('[name='+name+']', context)[0];
);
}
+function renderUnifiedSearch() {
+
+ if (!searchInitDone) {
+ searchInitDone = true;
+ termManager = new TermManager();
+ resultManager = new ResultManager();
+ termManager.addRow();
+ resultsLoader = new searchResultsLoader();
+
+ // define custom lineitem result handler
+ resultManager.result_types = {
+ "lineitem": {
+ "search_options": {
+ },
+ "revealer": function() {
+ },
+ "finisher": function() {
+ resultsLoader.batch_length = resultManager.count_results;
+ },
+ "adder": function(li) {
+ resultsLoader.addLineitem(li);
+ },
+ "interface": resultsLoader
+ }
+ };
+
+ }
+
+ dojo.addClass(dojo.byId('oils-acq-invoice-table'), 'hidden');
+ dojo.removeClass(dojo.byId('oils-acq-invoice-search'), 'hidden');
+}
+
+function searchResultsLoader() {
+ console.log('creating searchResultsLoader...');
+
+ this.displayOffset = 0;
+ this.displayLimit = 10;
+
+ this.addLineitem = function(li) {
+ console.log('adding lineitem ' + li);
+ dojo.byId('acq-invoice-search-results-div').appendChild(
+ dojo.create('div', {innerHTML : '<input type="checkbox"/> Some Book About Stuff ' + li}));
+ }
+}
+
function updateTotalCost() {
var totalCost = 0;
var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
}
+if (typeof unifiedSearchMode == 'undefined') {
+ unifiedSearchMode = '';
+}
+
var termSelectorFactory;
var termManager;
var resultManager;
this.plCache = {};
this.invCache = {};
+ if (unifiedSearchMode == 'invoice') {
+
+ } else {
+
this.result_types = {
"lineitem": {
"search_options": {
"no_results": {
"revealer": function() { alert(localeStrings.NO_RESULTS); }
}
+ }
};
this._dataLoader = function(opts) {
};
this.go = function(search_object) {
+
+ if (unifiedSearchMode == 'invoice') {
+ var self = this;
+ dojo.forEach([1,2,3,4,5], function(idx) {self.add('lineitem', 'foo ' + idx)});
+ } else {
location.href = oilsBasePath + "/acq/search/unified?" +
"so=" + base64Encode(search_object) +
"&rt=" + dojo.byId("acq-unified-result-type").getValue() +
"&c=" + dojo.byId("acq-unified-conjunction").getValue();
+ }
};
this.search = function(uriManager, termManager) {
/* onload */
openils.Util.addOnLoad(
function() {
+
+ // onload handled by invoice UI
+ if (unifiedSearchMode == 'invoice') return;
+
termManager = new TermManager();
+
resultManager = new ResultManager(
new LiTablePager(null, new AcqLiTable()),
dijit.byId("acq-unified-po-grid"),