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 : 'poitem_linenumber', 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/Poitem.php'",
49                                     "|xns": "Roo.data"
50                                 },
51                                 {
52                                     "*prop": "reader",
53                                     "id": "poitem_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 Item found",
93                             "pageSize": 100,
94                             "xtype": "PagingToolbar",
95                             "|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",
96                             "|xns": "Roo"
97                         },
98                         {
99                             "*prop": "colModel[]",
100                             "align": "right",
101                             "dataIndex": "poitem_linenumber",
102                             "header": "Line#",
103                             "width": 50,
104                             "xtype": "ColumnModel",
105                             "|renderer": "function(v) { return String.format('{0}', v); }",
106                             "|xns": "Roo.grid"
107                         },
108                         {
109                             "*prop": "colModel[]",
110                             "dataIndex": "item_number",
111                             "header": "Item code",
112                             "width": 100,
113                             "xtype": "ColumnModel",
114                             "|renderer": "function(v) { return String.format('{0}', v); }",
115                             "|xns": "Roo.grid",
116                             "items": [
117                                 {
118                                     "|xns": "Roo.grid",
119                                     "xtype": "GridEditor",
120                                     "*prop": "editor",
121                                     "items": [
122                                         {
123                                             "listeners": {
124                                                 "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}"
125                                             },
126                                             "*prop": "field",
127                                             "allowBlank": false,
128                                             "displayField": "itemsite_item_id_item_number",
129                                             "editable": true,
130                                             "emptyText": "Select item",
131                                             "forceSelection": true,
132                                             "hiddenName": "itemsite_item_id_item_number",
133                                             "listWidth": 400,
134                                             "loadingText": "Searching...",
135                                             "minChars": 2,
136                                             "name": "item_number",
137                                             "pageSize": 20,
138                                             "qtip": "Select item",
139                                             "queryParam": "query[number]",
140                                             "selectOnFocus": true,
141                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>",
142                                             "triggerAction": "all",
143                                             "typeAhead": false,
144                                             "valueField": "item_number",
145                                             "xtype": "ComboBox",
146                                             "|xns": "Roo.form",
147                                             "items": [
148                                                 {
149                                                     "listeners": {
150                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {}; \n    o.params.itemsite_posupply = 1;\n}\n"
151                                                     },
152                                                     "*prop": "store",
153                                                     "remoteSort": true,
154                                                     "xtype": "Store",
155                                                     "|sortInfo": "{ direction : 'ASC', field: 'item_number' }",
156                                                     "|xns": "Roo.data",
157                                                     "items": [
158                                                         {
159                                                             "*prop": "proxy",
160                                                             "method": "GET",
161                                                             "xtype": "HttpProxy",
162                                                             "|url": "baseURL + '/Roo/itemsite.php'",
163                                                             "|xns": "Roo.data"
164                                                         },
165                                                         {
166                                                             "*prop": "reader",
167                                                             "id": "itemsite_id",
168                                                             "root": "data",
169                                                             "totalProperty": "total",
170                                                             "xtype": "JsonReader",
171                                                             "|fields": "[{\"name\":\"item_id\",\"type\":\"int\"},\"item_number\"]",
172                                                             "|xns": "Roo.data"
173                                                         }
174                                                     ]
175                                                 }
176                                             ]
177                                         }
178                                     ]
179                                 }
180                             ]
181                         },
182                         {
183                             "*prop": "colModel[]",
184                             "dataIndex": "item_descrip1",
185                             "header": "Item description",
186                             "width": 150,
187                             "xtype": "ColumnModel",
188                             "|renderer": "function(v) { return String.format('{0}', v); }",
189                             "|xns": "Roo.grid"
190                         },
191                         {
192                             "*prop": "colModel[]",
193                             "dataIndex": "poitem_duedate",
194                             "header": "Due date",
195                             "width": 100,
196                             "xtype": "ColumnModel",
197                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }",
198                             "|xns": "Roo.grid"
199                         },
200                         {
201                             "*prop": "colModel[]",
202                             "align": "right",
203                             "dataIndex": "poitem_qty_ordered",
204                             "header": "Ordered",
205                             "width": 75,
206                             "xtype": "ColumnModel",
207                             "|renderer": "function(v) { return String.format('{0}', v); }",
208                             "|xns": "Roo.grid",
209                             "items": [
210                                 {
211                                     "|xns": "Roo.grid",
212                                     "xtype": "GridEditor",
213                                     "*prop": "editor",
214                                     "items": [
215                                         {
216                                             "*prop": "field",
217                                             "allowDecimals": false,
218                                             "decimalPrecision": 0,
219                                             "minValue": 1,
220                                             "style": "text-align:right",
221                                             "xtype": "NumberField",
222                                             "|xns": "Roo.form"
223                                         }
224                                     ]
225                                 }
226                             ]
227                         },
228                         {
229                             "*prop": "colModel[]",
230                             "align": "right",
231                             "dataIndex": "poitem_qty_received",
232                             "header": "Received",
233                             "width": 75,
234                             "xtype": "ColumnModel",
235                             "|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}",
236                             "|xns": "Roo.grid"
237                         },
238                         {
239                             "*prop": "colModel[]",
240                             "align": "right",
241                             "dataIndex": "poitem_qty_vouchered",
242                             "header": "Vouchered",
243                             "width": 65,
244                             "xtype": "ColumnModel",
245                             "|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}",
246                             "|xns": "Roo.grid"
247                         },
248                         {
249                             "*prop": "colModel[]",
250                             "align": "right",
251                             "dataIndex": "poitem_unitprice",
252                             "header": "Unit price",
253                             "width": 100,
254                             "xtype": "ColumnModel",
255                             "|renderer": "function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }",
256                             "|xns": "Roo.grid",
257                             "items": [
258                                 {
259                                     "|xns": "Roo.grid",
260                                     "xtype": "GridEditor",
261                                     "*prop": "editor",
262                                     "items": [
263                                         {
264                                             "*prop": "field",
265                                             "allowBlank": false,
266                                             "allowDecimals": false,
267                                             "decimalPrecision": 0,
268                                             "minValue": 1,
269                                             "style": "text-align:right",
270                                             "xtype": "NumberField",
271                                             "|xns": "Roo.form"
272                                         }
273                                     ]
274                                 }
275                             ]
276                         }
277                     ]
278                 }
279             ]
280         }
281     ],
282     "permname": "",
283     "modOrder": "900"
284 }