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