X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Pman.Tab.XtupleMetric.bjs;h=733f542ffa44be56216df62b31a0789a494c0183;hb=HEAD;hp=208f7c24c098ca9f504567183ea7dee6df4428c1;hpb=3ba059c5b43728ba5332915b1c63dce5ea233998;p=Pman.Xtuple diff --git a/Pman.Tab.XtupleMetric.bjs b/Pman.Tab.XtupleMetric.bjs index 208f7c24..733f542f 100644 --- a/Pman.Tab.XtupleMetric.bjs +++ b/Pman.Tab.XtupleMetric.bjs @@ -1,7 +1,7 @@ { "id": "roo-file-374", "name": "Pman.Tab.XtupleMetric", - "parent": "Pman.Admin", + "parent": "Pman.Tab.Admin", "title": "", "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleMetric.bjs", "items": [ @@ -21,7 +21,7 @@ { "listeners": { "|render": "function() \n{\n _this.grid = this; \n if (_this.panel.active) {\n this.footer.onClick('first');\n }\n}", - "beforeedit": "function (e)\n{\n var r = e.record.data.poitem_qty_received * 1;\n \n if(r > 0){\n Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n return false;\n }\n \n var status = _this.form.findField('pohead_status').getValue();\n \n if(status == 'C'){\n Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n return false;\n }\n \n \n}" + "afteredit": "function (e)\n{\n if(e.originalValue == e.value || !e.value.length){\n return false;\n }\n \n e.record.commit();\n}" }, "*prop": "grid", "autoExpandColumn": "metric_value", @@ -32,7 +32,8 @@ "items": [ { "listeners": { - "beforeload": "function (_self, o){\n o.params = o.params || {};\n \n}\n" + "beforeload": "function (_self, o){\n o.params = o.params || {};\n \n var s = _this.searchBox.getValue();\n \n if(!s || !s.length){\n return;\n }\n \n o.params['search[name]'] = s;\n}\n", + "update": "function (_self, record, operation)\n{\n if (operation != Roo.data.Record.COMMIT) {\n return;\n }\n\n if (!record.data.metric_name.length || !record.data.metric_value.length) {\n return;\n }\n \n new Pman.Request({\n url : baseURL + '/Roo/Metric',\n method : 'POST',\n params : record.data,\n success : function(res) {\n _this.grid.footer.onClick('refresh');\n }\n });\n \n}" }, "*prop": "dataSource", "remoteSort": true, @@ -45,16 +46,16 @@ "method": "GET", "timeout": 90000, "xtype": "HttpProxy", - "|url": "baseURL + '/Xtuple/Roo/Poitem.php'", + "|url": "baseURL + '/Xtuple/Roo/Metric.php'", "|xns": "Roo.data" }, { "*prop": "reader", - "id": "poitem_id", + "id": "metric_id", "root": "data", "totalProperty": "total", "xtype": "JsonReader", - "|fields": "[\n {\n 'name': 'poitem_id',\n 'type': 'int'\n }\n]", + "|fields": "[\n {\n 'name': 'metric_id',\n 'type': 'int'\n },\n {\n 'name': 'metric_name',\n 'type': 'string'\n },\n {\n 'name': 'metric_value',\n 'type': 'string'\n },\n {\n 'name': 'metric_module',\n 'type': 'string'\n }\n]", "|xns": "Roo.data" } ] @@ -66,7 +67,37 @@ "items": [ { "listeners": { - "|click": "function()\n{\n var status = _this.form.findField('pohead_status').getValue();\n \n if(status == 'C'){\n Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n return;\n }\n \n var ct = _this.grid.ds.getCount();\n \n var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;\n \n var dt = _this.form.findField('pohead_orderdate').getValue();\n \n var nr = _this.grid.ds.reader.newRow({\n poitem_id : 0,\n poitem_linenumber : last,\n item_number : '',\n item_descrip1 : '',\n poitem_duedate : dt,\n poitem_qty_ordered : 1,\n poitem_unitprice : 0\n });\n \n _this.grid.stopEditing();\n _this.grid.ds.insert(_this.grid.ds.getCount(), nr); \n _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);\n}\n" + "specialkey": "function (_self, e)\n{\n _this.grid.footer.onClick('first');\n}", + "render": "function (_self)\n{\n _this.searchBox = _self;\n}" + }, + "xtype": "TextField", + "|xns": "Roo.form" + }, + { + "listeners": { + "click": "function (_self, e)\n{\n _this.grid.footer.onClick('first');\n}" + }, + "cls": "x-btn-icon", + "xtype": "Button", + "|icon": "rootURL + '/Pman/templates/images/search.gif'", + "|xns": "Roo.Toolbar" + }, + { + "listeners": { + "click": "function (_self, e)\n{\n _this.searchBox.setValue('');\n _this.grid.footer.onClick('first');\r\n}" + }, + "cls": "x-btn-icon", + "xtype": "Button", + "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'", + "|xns": "Roo.Toolbar" + }, + { + "|xns": "Roo.Toolbar", + "xtype": "Fill" + }, + { + "listeners": { + "|click": "function()\n{\n \n var nr = _this.grid.ds.reader.newRow({\n metric_id : 0,\n metric_name : '',\n metric_value : '',\n metric_module : ''\n });\n \n _this.grid.stopEditing();\n _this.grid.ds.insert(0, nr); \n _this.grid.startEditing(0, 0);\n}\n" }, "cls": "x-btn-text-icon", "text": "Add", @@ -76,7 +107,7 @@ }, { "listeners": { - "|click": "function ()\n{\n var status = _this.form.findField('pohead_status').getValue();\n \n if(status == 'C'){\n Roo.MessageBox.alert(\"Error\", \"This PO has been closed\");\n return;\n }\n \n var cs = _this.grid.getSelectionModel().getSelectedCell();\n if (!cs) {\n Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n return;\n }\n _this.grid.stopEditing();\n var r = _this.grid.ds.getAt(cs[0]);\n \n if(r.data.poitem_qty_received * 1 > 0){\n Roo.MessageBox.alert(\"Error\", \"This item has been receipted\");\n return;\n }\n \n \n _this.grid.ds.remove(r);\n \n}" + "|click": "function ()\n{ \n var cs = _this.grid.getSelectionModel().getSelectedCell();\n \n if (!cs) {\n Roo.MessageBox.alert(\"Error\", \"Select a cell\");\n return;\n }\n _this.grid.stopEditing();\n \n var r = _this.grid.ds.getAt(cs[0]);\n \n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to delete this metric?\", function (v){\n if (v != 'yes') {\n return;\n }\n \n new Pman.Request({\n url : baseURL + '/Roo/Metric',\n method : 'POST',\n params : {\n _delete : r.data.id\n },\n success : function(res) {\n _this.grid.footer.onClick('refresh');\n }\n });\n });\n}" }, "cls": "x-btn-text-icon", "text": "Remove", @@ -89,27 +120,16 @@ { "*prop": "footer", "displayInfo": true, - "emptyMsg": "No Item found", - "pageSize": 100, + "emptyMsg": "No Metric found", + "pageSize": 50, "xtype": "PagingToolbar", - "|updateSummary": "function() {\n\r\n var f = this;\r\n new Pman.Request({\r\n url : baseURL + '/Xtuple/Roo/Poitem',\r\n method : 'GET',\r\n params : {\n _roo_office : _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2),\r\n _totals : 1,\r\n poitem_pohead_id : _this.form.findField('pohead_id').getValue()\r\n },\r\n success : function(d) {\n Roo.log(d);\r\n f.displayEl.update(String.format(\r\n \"{0} items | Total : {1} {2}\",\r\n d.data[0].count_item,\r\n _this.form.findField('pohead_curr_id').el.dom.value,\r\n d.data[0].totals\r\n ));\r\n \r\n }\r\n });\r\n\n}\n", "|xns": "Roo" }, { "*prop": "colModel[]", - "align": "right", - "dataIndex": "poitem_linenumber", - "header": "Line#", - "width": 50, - "xtype": "ColumnModel", - "|renderer": "function(v) { return String.format('{0}', v); }", - "|xns": "Roo.grid" - }, - { - "*prop": "colModel[]", - "dataIndex": "item_number", - "header": "Item code", - "width": 100, + "dataIndex": "metric_name", + "header": "Name", + "width": 250, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid", @@ -120,60 +140,10 @@ "*prop": "editor", "items": [ { - "listeners": { - "beforeselect": "function (combo, record, index)\n{\n var ar = _this.grid.activeEditor.record;\n \n (function() { \n ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);\n ar.set('poitem_itemsite_id', record.data.itemsite_id);\n }).defer(100);\n \n}" - }, "*prop": "field", "allowBlank": false, - "displayField": "itemsite_item_id_item_number", - "editable": true, - "emptyText": "Select item", - "forceSelection": true, - "hiddenName": "itemsite_item_id_item_number", - "listWidth": 400, - "loadingText": "Searching...", - "minChars": 2, - "name": "item_number", - "pageSize": 20, - "qtip": "Select item", - "queryParam": "query[number]", - "selectOnFocus": true, - "tpl": "
{itemsite_item_id_item_number} - {itemsite_item_id_item_descrip1}
", - "triggerAction": "all", - "typeAhead": false, - "valueField": "item_number", - "xtype": "ComboBox", - "|xns": "Roo.form", - "items": [ - { - "listeners": { - "|beforeload": "function (_self, o){\n o.params = o.params || {}; \n o.params.itemsite_posupply = 1;\n}\n" - }, - "*prop": "store", - "remoteSort": true, - "xtype": "Store", - "|sortInfo": "{ direction : 'ASC', field: 'item_number' }", - "|xns": "Roo.data", - "items": [ - { - "*prop": "proxy", - "method": "GET", - "xtype": "HttpProxy", - "|url": "baseURL + '/Roo/itemsite.php'", - "|xns": "Roo.data" - }, - { - "*prop": "reader", - "id": "itemsite_id", - "root": "data", - "totalProperty": "total", - "xtype": "JsonReader", - "|fields": "[{\"name\":\"item_id\",\"type\":\"int\"},\"item_number\"]", - "|xns": "Roo.data" - } - ] - } - ] + "xtype": "TextField", + "|xns": "Roo.form" } ] } @@ -181,30 +151,11 @@ }, { "*prop": "colModel[]", - "dataIndex": "item_descrip1", - "header": "Item description", + "dataIndex": "metric_value", + "header": "Value", "width": 150, "xtype": "ColumnModel", "|renderer": "function(v) { return String.format('{0}', v); }", - "|xns": "Roo.grid" - }, - { - "*prop": "colModel[]", - "dataIndex": "poitem_duedate", - "header": "Due date", - "width": 100, - "xtype": "ColumnModel", - "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }", - "|xns": "Roo.grid" - }, - { - "*prop": "colModel[]", - "align": "right", - "dataIndex": "poitem_qty_ordered", - "header": "Ordered", - "width": 75, - "xtype": "ColumnModel", - "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid", "items": [ { @@ -214,11 +165,8 @@ "items": [ { "*prop": "field", - "allowDecimals": false, - "decimalPrecision": 0, - "minValue": 1, - "style": "text-align:right", - "xtype": "NumberField", + "allowBlank": false, + "xtype": "TextField", "|xns": "Roo.form" } ] @@ -227,32 +175,11 @@ }, { "*prop": "colModel[]", - "align": "right", - "dataIndex": "poitem_qty_received", - "header": "Received", - "width": 75, - "xtype": "ColumnModel", - "|renderer": "function(v,x,r) { \n return String.format(\n r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '{0}': '{0}',\n v - r.data.poitem_qty_returned);\n}", - "|xns": "Roo.grid" - }, - { - "*prop": "colModel[]", - "align": "right", - "dataIndex": "poitem_qty_vouchered", - "header": "Vouchered", - "width": 65, - "xtype": "ColumnModel", - "|renderer": "function(v,x,r) { \n return String.format(\n r.data.poitem_qty_ordered != v ? '{0}': '{0}',\n v);\n}", - "|xns": "Roo.grid" - }, - { - "*prop": "colModel[]", - "align": "right", - "dataIndex": "poitem_unitprice", - "header": "Unit price", + "dataIndex": "metric_module", + "header": "Module", "width": 100, "xtype": "ColumnModel", - "|renderer": "function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }", + "|renderer": "function(v) { return String.format('{0}', v); }", "|xns": "Roo.grid", "items": [ { @@ -263,11 +190,7 @@ { "*prop": "field", "allowBlank": false, - "allowDecimals": false, - "decimalPrecision": 0, - "minValue": 1, - "style": "text-align:right", - "xtype": "NumberField", + "xtype": "TextField", "|xns": "Roo.form" } ]