Pman.Tab.XtupleMetric.bjs
[Pman.Xtuple] / Pman.Tab.XtupleMetric.bjs
1 {
2     "id": "roo-file-374",
3     "name": "Pman.Tab.XtupleMetric",
4     "parent": "Pman.Admin",
5     "title": "",
6     "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Tab.XtupleMetric.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
11             },
12             "background": true,
13             "fitContainer": true,
14             "fitToframe": true,
15             "region": "center",
16             "tableName": "metric",
17             "title": "Metric",
18             "xtype": "GridPanel",
19             "|xns": "Roo",
20             "items": [
21                 {
22                     "listeners": {
23                         "|render": "function() \n{\n    _this.grid = this; \n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
24                         "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}"
25                     },
26                     "*prop": "grid",
27                     "autoExpandColumn": "metric_value",
28                     "clicksToEdit": 1,
29                     "loadMask": true,
30                     "xtype": "EditorGrid",
31                     "|xns": "Roo.grid",
32                     "items": [
33                         {
34                             "listeners": {
35                                 "beforeload": "function (_self, o){\n    o.params = o.params || {};\n    \n}\n"
36                             },
37                             "*prop": "dataSource",
38                             "remoteSort": true,
39                             "xtype": "Store",
40                             "|sortInfo": "{ field : 'metric_name', direction: 'ASC' }",
41                             "|xns": "Roo.data",
42                             "items": [
43                                 {
44                                     "*prop": "proxy",
45                                     "method": "GET",
46                                     "timeout": 90000,
47                                     "xtype": "HttpProxy",
48                                     "|url": "baseURL + '/Xtuple/Roo/Metric.php'",
49                                     "|xns": "Roo.data"
50                                 },
51                                 {
52                                     "*prop": "reader",
53                                     "id": "metric_id",
54                                     "root": "data",
55                                     "totalProperty": "total",
56                                     "xtype": "JsonReader",
57                                     "|fields": "[\n    {\n        'name': 'poitem_id',\n        'type': 'int'\n    }\n]",
58                                     "|xns": "Roo.data"
59                                 }
60                             ]
61                         },
62                         {
63                             "|xns": "Roo",
64                             "xtype": "Toolbar",
65                             "*prop": "toolbar",
66                             "items": [
67                                 {
68                                     "listeners": {
69                                         "|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"
70                                     },
71                                     "cls": "x-btn-text-icon",
72                                     "text": "Add",
73                                     "xtype": "Button",
74                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
75                                     "|xns": "Roo.Toolbar"
76                                 },
77                                 {
78                                     "listeners": {
79                                         "|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}"
80                                     },
81                                     "cls": "x-btn-text-icon",
82                                     "text": "Remove",
83                                     "xtype": "Button",
84                                     "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
85                                     "|xns": "Roo.Toolbar"
86                                 }
87                             ]
88                         },
89                         {
90                             "*prop": "footer",
91                             "displayInfo": true,
92                             "emptyMsg": "No Metric found",
93                             "pageSize": 50,
94                             "xtype": "PagingToolbar",
95                             "|xns": "Roo"
96                         },
97                         {
98                             "*prop": "colModel[]",
99                             "align": "right",
100                             "dataIndex": "poitem_linenumber",
101                             "header": "Line#",
102                             "width": 50,
103                             "xtype": "ColumnModel",
104                             "|renderer": "function(v) { return String.format('{0}', v); }",
105                             "|xns": "Roo.grid"
106                         },
107                         {
108                             "*prop": "colModel[]",
109                             "dataIndex": "item_number",
110                             "header": "Item code",
111                             "width": 100,
112                             "xtype": "ColumnModel",
113                             "|renderer": "function(v) { return String.format('{0}', v); }",
114                             "|xns": "Roo.grid",
115                             "items": [
116                                 {
117                                     "|xns": "Roo.grid",
118                                     "xtype": "GridEditor",
119                                     "*prop": "editor",
120                                     "items": [
121                                         {
122                                             "listeners": {
123                                                 "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}"
124                                             },
125                                             "*prop": "field",
126                                             "allowBlank": false,
127                                             "displayField": "itemsite_item_id_item_number",
128                                             "editable": true,
129                                             "emptyText": "Select item",
130                                             "forceSelection": true,
131                                             "hiddenName": "itemsite_item_id_item_number",
132                                             "listWidth": 400,
133                                             "loadingText": "Searching...",
134                                             "minChars": 2,
135                                             "name": "item_number",
136                                             "pageSize": 20,
137                                             "qtip": "Select item",
138                                             "queryParam": "query[number]",
139                                             "selectOnFocus": true,
140                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>",
141                                             "triggerAction": "all",
142                                             "typeAhead": false,
143                                             "valueField": "item_number",
144                                             "xtype": "ComboBox",
145                                             "|xns": "Roo.form",
146                                             "items": [
147                                                 {
148                                                     "listeners": {
149                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {}; \n    o.params.itemsite_posupply = 1;\n}\n"
150                                                     },
151                                                     "*prop": "store",
152                                                     "remoteSort": true,
153                                                     "xtype": "Store",
154                                                     "|sortInfo": "{ direction : 'ASC', field: 'item_number' }",
155                                                     "|xns": "Roo.data",
156                                                     "items": [
157                                                         {
158                                                             "*prop": "proxy",
159                                                             "method": "GET",
160                                                             "xtype": "HttpProxy",
161                                                             "|url": "baseURL + '/Roo/itemsite.php'",
162                                                             "|xns": "Roo.data"
163                                                         },
164                                                         {
165                                                             "*prop": "reader",
166                                                             "id": "itemsite_id",
167                                                             "root": "data",
168                                                             "totalProperty": "total",
169                                                             "xtype": "JsonReader",
170                                                             "|fields": "[{\"name\":\"item_id\",\"type\":\"int\"},\"item_number\"]",
171                                                             "|xns": "Roo.data"
172                                                         }
173                                                     ]
174                                                 }
175                                             ]
176                                         }
177                                     ]
178                                 }
179                             ]
180                         },
181                         {
182                             "*prop": "colModel[]",
183                             "dataIndex": "item_descrip1",
184                             "header": "Item description",
185                             "width": 150,
186                             "xtype": "ColumnModel",
187                             "|renderer": "function(v) { return String.format('{0}', v); }",
188                             "|xns": "Roo.grid"
189                         },
190                         {
191                             "*prop": "colModel[]",
192                             "dataIndex": "poitem_duedate",
193                             "header": "Due date",
194                             "width": 100,
195                             "xtype": "ColumnModel",
196                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }",
197                             "|xns": "Roo.grid"
198                         },
199                         {
200                             "*prop": "colModel[]",
201                             "align": "right",
202                             "dataIndex": "poitem_qty_ordered",
203                             "header": "Ordered",
204                             "width": 75,
205                             "xtype": "ColumnModel",
206                             "|renderer": "function(v) { return String.format('{0}', v); }",
207                             "|xns": "Roo.grid",
208                             "items": [
209                                 {
210                                     "|xns": "Roo.grid",
211                                     "xtype": "GridEditor",
212                                     "*prop": "editor",
213                                     "items": [
214                                         {
215                                             "*prop": "field",
216                                             "allowDecimals": false,
217                                             "decimalPrecision": 0,
218                                             "minValue": 1,
219                                             "style": "text-align:right",
220                                             "xtype": "NumberField",
221                                             "|xns": "Roo.form"
222                                         }
223                                     ]
224                                 }
225                             ]
226                         },
227                         {
228                             "*prop": "colModel[]",
229                             "align": "right",
230                             "dataIndex": "poitem_qty_received",
231                             "header": "Received",
232                             "width": 75,
233                             "xtype": "ColumnModel",
234                             "|renderer": "function(v,x,r) { \n    return String.format(\n        r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style=\"color:red\">{0}</span>':  '{0}',\n         v - r.data.poitem_qty_returned);\n}",
235                             "|xns": "Roo.grid"
236                         },
237                         {
238                             "*prop": "colModel[]",
239                             "align": "right",
240                             "dataIndex": "poitem_qty_vouchered",
241                             "header": "Vouchered",
242                             "width": 65,
243                             "xtype": "ColumnModel",
244                             "|renderer": "function(v,x,r) { \n    return String.format(\n        r.data.poitem_qty_ordered != v ? '<span style=\"color:red\">{0}</span>':  '{0}',\n         v);\n}",
245                             "|xns": "Roo.grid"
246                         },
247                         {
248                             "*prop": "colModel[]",
249                             "align": "right",
250                             "dataIndex": "poitem_unitprice",
251                             "header": "Unit price",
252                             "width": 100,
253                             "xtype": "ColumnModel",
254                             "|renderer": "function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }",
255                             "|xns": "Roo.grid",
256                             "items": [
257                                 {
258                                     "|xns": "Roo.grid",
259                                     "xtype": "GridEditor",
260                                     "*prop": "editor",
261                                     "items": [
262                                         {
263                                             "*prop": "field",
264                                             "allowBlank": false,
265                                             "allowDecimals": false,
266                                             "decimalPrecision": 0,
267                                             "minValue": 1,
268                                             "style": "text-align:right",
269                                             "xtype": "NumberField",
270                                             "|xns": "Roo.form"
271                                         }
272                                     ]
273                                 }
274                             ]
275                         }
276                     ]
277                 }
278             ]
279         }
280     ],
281     "permname": "",
282     "modOrder": "900"
283 }