added distribution formula admin UI
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Mar 2009 19:09:58 +0000 (19:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Mar 2009 19:09:58 +0000 (19:09 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12670 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js [new file with mode: 0644]
Open-ILS/web/templates/default/conify/global/acq/distribution_formula.tt2 [new file with mode: 0644]
Open-ILS/web/templates/default/menu.tt2

diff --git a/Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js b/Open-ILS/web/js/ui/default/conify/global/acq/distribution_formula.js
new file mode 100644 (file)
index 0000000..61077af
--- /dev/null
@@ -0,0 +1,68 @@
+dojo.require('openils.widget.AutoGrid');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('openils.PermaCrud');
+var formula;
+var formCache = [];
+function draw() {
+    if(formulaId) {
+        openils.Util.hide('formula-list-div');
+        drawFormulaSummary();
+    } else {
+        openils.Util.hide('formula-entry-div');
+        fListGrid.onPostCreate = function(fmObject) {
+            location.href = location.href + '/' + fmObject.id();
+        }
+ fieldmapper.standardRequest(
+                ['open-ils.acq', 'open-ils.acq.distribution_formula.ranged.retrieve'],
+                {   async: true,
+                    params: [openils.User.authtoken],
+                    onresponse: function (r) { 
+                        var form = openils.Util.readResponse(r);
+                        formCache[form.id()] = form;
+                        fListGrid.store.newItem(form.toStoreItem());
+                        }
+                    }
+                             );
+     
+    }
+}
+openils.Util.addOnLoad(draw);
+
+/*function getFormulaId (rowIndex, item) {
+    if(!item) return '';
+    var pcrud = new openils.PermaCrud;
+    var formulaName = pcrud.retrieve('acqdf', formulaId);
+    return formulaName.name();
+    
+
+}
+*/
+function drawFormulaSummary() {
+    openils.Util.show('formula-entry-div');
+    dfeListGrid.overrideEditWidgets.formula = new
+        dijit.form.TextBox({style:'display:none', value: formulaId});
+    dfeListGrid.loadAll({order_by:{acqdfe : 'formula'}}, {formula : formulaId});
+    var pcrud = new openils.PermaCrud;
+    var formulaName = pcrud.retrieve('acqdf', formulaId);
+    dojo.byId('formula_head').innerHTML = formulaName.name();
+}
+
+function getItemCount(rowIndex, item) {
+    if(!item) return '';
+    var form = formCache[this.grid.store.getValue(item, "id")];
+    var count = 0;
+    dojo.forEach(form.entries(),
+                 function(e) {
+                     count = count + e.item_count();
+                 }
+                 );
+    return count;
+}
+
+function getFormulaName(rowIndex, item) {
+    if(!item) return '';
+    return '<a href="' + location.href + '/' +
+        this.grid.store.getValue(item, 'id') + '">' +
+        this.grid.store.getValue(item, 'name') + '</a>';
+}
+
diff --git a/Open-ILS/web/templates/default/conify/global/acq/distribution_formula.tt2 b/Open-ILS/web/templates/default/conify/global/acq/distribution_formula.tt2
new file mode 100644 (file)
index 0000000..38acefa
--- /dev/null
@@ -0,0 +1,57 @@
+[% WRAPPER default/base.tt2 %]
+<script src='[% ctx.media_prefix %]/js/ui/default/conify/global/acq/distribution_formula.js'> </script>
+<script> var formulaId = '[% ctx.page_args.0 %]';</script>
+
+
+<div id='formula-list-div'>
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+        <div>Distribution Formulas</div>
+        <div><button dojoType='dijit.form.Button' onClick='fListGrid.showCreateDialog()'>New Formula</button></div>
+        </div>
+        <table  jsId="fListGrid"
+                dojoType="openils.widget.AutoGrid"
+                fieldOrder="['id', 'name', 'owner', 'item_count', 'skip_count']"
+                query="{id: '*'}"
+                defaultCellWidth='12'
+                fmClass='acqdf'
+                editOnEnter='true'>
+            <thead>
+                <tr><th field='name' get='getFormulaName'/>
+                   
+                    <th field='item_count'  get='getItemCount'/
+                </tr>
+            </thead>
+        </table>
+    </div>
+</div>
+
+
+
+<div id='formula-entry-div'>
+    <div dojoType="dijit.layout.ContentPane" layoutAlign="top">
+        <div id='formula-summary-pane'/>
+    </div>
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="top" class='oils-header-panel'>
+            <div id="formula_head"></div>
+           <div> <button dojoType='dijit.form.Button' onClick='dfeListGrid.showCreateDialog()'>New Formula Entry</button></div>
+        </div>
+        <div dojoType="dijit.layout.ContentPane" layoutAlign="client" style='height:400px'>
+            <table  jsId="dfeListGrid"
+                    dojoType="openils.widget.AutoGrid"
+                    fieldOrder="['id','formula', 'owning_lib', 'location', 'item_count', 'position']"
+                    suppressFields="['formula']"
+                    query="{id: '*'}"
+                    defaultCellWidth='12'
+                    fmClass='acqdfe'
+                    editOnEnter='true'>
+                <thead>
+                    <tr> <th field='formula' get='getFormulaId'/>
+                    </tr>
+                </thead>
+            </table>
+        </div>
+    </div>
+</div>
+[% END %]
+
index 8282fe1..d05b2d5 100644 (file)
@@ -85,6 +85,8 @@
                                 onClick="location.href = '[% ctx.base_uri %]/acq/currency_type/list';">Currency Types</div>
                         <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy" 
                                 onClick="location.href = '[% ctx.base_uri %]/acq/exchange_rate';">Exchange Rates</div>
+                        <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy" 
+                                onClick="location.href = '[% ctx.base_uri %]/conify/global/acq/distribution_formula';">Distribution Formulas</div>
                     </div>
                 </div>
                 <div dojoType="dijit.PopupMenuItem" iconClass="dijitEditorIcon dijitEditorIconCopy">