X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Pman.Tab.XtupleMetric.js;h=ac138f603c29f4c9dfc7b7f8745dd60516862ce2;hb=HEAD;hp=283ee4a447543c0b30939ea8203ed21165b6db48;hpb=85ae8cb4ed8d1c2173610f05a03f43479e80f48e;p=Pman.Xtuple diff --git a/Pman.Tab.XtupleMetric.js b/Pman.Tab.XtupleMetric.js index 283ee4a4..ac138f60 100644 --- a/Pman.Tab.XtupleMetric.js +++ b/Pman.Tab.XtupleMetric.js @@ -6,7 +6,7 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ part : ["Xtuple","Metric"], order : '900-Pman.Tab.XtupleMetric', region : 'center', - parent : 'Pman.Admin', + parent : 'Pman.Tab.Admin', name : "unnamed module", disabled : false, permname : '', @@ -42,23 +42,13 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ this.footer.onClick('first'); } }, - beforeedit : function (e) + afteredit : function (e) { - var r = e.record.data.poitem_qty_received * 1; - - if(r > 0){ - Roo.MessageBox.alert("Error", "This item has been receipted"); - return false; - } - - var status = _this.form.findField('pohead_status').getValue(); - - if(status == 'C'){ - Roo.MessageBox.alert("Error", "This PO has been closed"); + if(e.originalValue == e.value || !e.value.length){ return false; } - + e.record.commit(); } }, autoExpandColumn : 'metric_value', @@ -71,6 +61,33 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ beforeload : function (_self, o){ o.params = o.params || {}; + var s = _this.searchBox.getValue(); + + if(!s || !s.length){ + return; + } + + o.params['search[name]'] = s; + }, + update : function (_self, record, operation) + { + if (operation != Roo.data.Record.COMMIT) { + return; + } + + if (!record.data.metric_name.length || !record.data.metric_value.length) { + return; + } + + new Pman.Request({ + url : baseURL + '/Roo/Metric', + method : 'POST', + params : record.data, + success : function(res) { + _this.grid.footer.onClick('refresh'); + } + }); + } }, remoteSort : true, @@ -112,38 +129,66 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ xtype: 'Toolbar', xns: Roo, items : [ + { + xtype: 'TextField', + xns: Roo.form, + listeners : { + specialkey : function (_self, e) + { + _this.grid.footer.onClick('first'); + }, + render : function (_self) + { + _this.searchBox = _self; + } + } + }, + { + xtype: 'Button', + xns: Roo.Toolbar, + listeners : { + click : function (_self, e) + { + _this.grid.footer.onClick('first'); + } + }, + cls : 'x-btn-icon', + icon : rootURL + '/Pman/templates/images/search.gif' + }, + { + xtype: 'Button', + xns: Roo.Toolbar, + listeners : { + click : function (_self, e) + { + _this.searchBox.setValue(''); + _this.grid.footer.onClick('first'); + } + }, + cls : 'x-btn-icon', + icon : rootURL + '/Pman/templates/images/edit-clear.gif' + }, + { + xtype: 'Fill', + xns: Roo.Toolbar + }, { xtype: 'Button', xns: Roo.Toolbar, listeners : { click : function() { - var status = _this.form.findField('pohead_status').getValue(); - - if(status == 'C'){ - Roo.MessageBox.alert("Error", "This PO has been closed"); - return; - } - - var ct = _this.grid.ds.getCount(); - - var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1; - - var dt = _this.form.findField('pohead_orderdate').getValue(); var nr = _this.grid.ds.reader.newRow({ - poitem_id : 0, - poitem_linenumber : last, - item_number : '', - item_descrip1 : '', - poitem_duedate : dt, - poitem_qty_ordered : 1, - poitem_unitprice : 0 + metric_id : 0, + metric_name : '', + metric_value : '', + metric_module : '' }); _this.grid.stopEditing(); - _this.grid.ds.insert(_this.grid.ds.getCount(), nr); - _this.grid.startEditing(_this.grid.ds.getCount()-1, 1); + _this.grid.ds.insert(0, nr); + _this.grid.startEditing(0, 0); } }, cls : 'x-btn-text-icon', @@ -155,30 +200,33 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ xns: Roo.Toolbar, listeners : { click : function () - { - var status = _this.form.findField('pohead_status').getValue(); - - if(status == 'C'){ - Roo.MessageBox.alert("Error", "This PO has been closed"); - return; - } - + { var cs = _this.grid.getSelectionModel().getSelectedCell(); + if (!cs) { Roo.MessageBox.alert("Error", "Select a cell"); return; } _this.grid.stopEditing(); + var r = _this.grid.ds.getAt(cs[0]); - if(r.data.poitem_qty_received * 1 > 0){ - Roo.MessageBox.alert("Error", "This item has been receipted"); - return; - } - - - _this.grid.ds.remove(r); - + Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete this metric?", function (v){ + if (v != 'yes') { + return; + } + + new Pman.Request({ + url : baseURL + '/Roo/Metric', + method : 'POST', + params : { + _delete : r.data.id + }, + success : function(res) { + _this.grid.footer.onClick('refresh'); + } + }); + }); } }, cls : 'x-btn-text-icon', @@ -195,21 +243,22 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ pageSize : 50 }, colModel : [ - { - xtype: 'ColumnModel', - xns: Roo.grid, - dataIndex : 'metric_id', - header : 'ID', - width : 75, - renderer : function(v) { return String.format('{0}', v); } - }, { xtype: 'ColumnModel', xns: Roo.grid, dataIndex : 'metric_name', header : 'Name', - width : 150, - renderer : function(v) { return String.format('{0}', v); } + width : 250, + renderer : function(v) { return String.format('{0}', v); }, + editor : { + xtype: 'GridEditor', + xns: Roo.grid, + field : { + xtype: 'TextField', + xns: Roo.form, + allowBlank : false + } + } }, { xtype: 'ColumnModel', @@ -217,82 +266,31 @@ Pman.Tab.XtupleMetric = new Roo.XComponent({ dataIndex : 'metric_value', header : 'Value', width : 150, - renderer : function(v) { return String.format('{0}', v); } - }, - { - xtype: 'ColumnModel', - xns: Roo.grid, - dataIndex : 'poitem_duedate', - header : 'Due date', - width : 100, - renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); } - }, - { - xtype: 'ColumnModel', - xns: Roo.grid, - align : 'right', - dataIndex : 'poitem_qty_ordered', - header : 'Ordered', - width : 75, renderer : function(v) { return String.format('{0}', v); }, editor : { xtype: 'GridEditor', xns: Roo.grid, field : { - xtype: 'NumberField', + xtype: 'TextField', xns: Roo.form, - allowDecimals : false, - decimalPrecision : 0, - minValue : 1, - style : 'text-align:right' + allowBlank : false } } }, { xtype: 'ColumnModel', xns: Roo.grid, - align : 'right', - dataIndex : 'poitem_qty_received', - header : 'Received', - width : 75, - renderer : function(v,x,r) { - return String.format( - r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '{0}': '{0}', - v - r.data.poitem_qty_returned); - } - }, - { - xtype: 'ColumnModel', - xns: Roo.grid, - align : 'right', - dataIndex : 'poitem_qty_vouchered', - header : 'Vouchered', - width : 65, - renderer : function(v,x,r) { - return String.format( - r.data.poitem_qty_ordered != v ? '{0}': '{0}', - v); - } - }, - { - xtype: 'ColumnModel', - xns: Roo.grid, - align : 'right', - dataIndex : 'poitem_unitprice', - header : 'Unit price', + dataIndex : 'metric_module', + header : 'Module', width : 100, - renderer : function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }, + renderer : function(v) { return String.format('{0}', v); }, editor : { xtype: 'GridEditor', xns: Roo.grid, field : { - xtype: 'NumberField', + xtype: 'TextField', xns: Roo.form, - allowBlank : false, - allowDecimals : false, - decimalPrecision : 0, - minValue : 1, - style : 'text-align:right' + allowBlank : false } } }