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': '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]",
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                             "dataIndex": "metric_id",
100                             "header": "ID",
101                             "width": 75,
102                             "xtype": "ColumnModel",
103                             "|renderer": "function(v) { return String.format('{0}', v); }",
104                             "|xns": "Roo.grid"
105                         },
106                         {
107                             "*prop": "colModel[]",
108                             "dataIndex": "metric_name",
109                             "header": "Name",
110                             "width": 150,
111                             "xtype": "ColumnModel",
112                             "|renderer": "function(v) { return String.format('{0}', v); }",
113                             "|xns": "Roo.grid"
114                         },
115                         {
116                             "*prop": "colModel[]",
117                             "dataIndex": "metric_value",
118                             "header": "Value",
119                             "width": 150,
120                             "xtype": "ColumnModel",
121                             "|renderer": "function(v) { return String.format('{0}', v); }",
122                             "|xns": "Roo.grid"
123                         },
124                         {
125                             "*prop": "colModel[]",
126                             "dataIndex": "metric_module",
127                             "header": "Module",
128                             "width": 100,
129                             "xtype": "ColumnModel",
130                             "|renderer": "function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }",
131                             "|xns": "Roo.grid"
132                         },
133                         {
134                             "*prop": "colModel[]",
135                             "align": "right",
136                             "dataIndex": "poitem_qty_ordered",
137                             "header": "Ordered",
138                             "width": 75,
139                             "xtype": "ColumnModel",
140                             "|renderer": "function(v) { return String.format('{0}', v); }",
141                             "|xns": "Roo.grid",
142                             "items": [
143                                 {
144                                     "|xns": "Roo.grid",
145                                     "xtype": "GridEditor",
146                                     "*prop": "editor",
147                                     "items": [
148                                         {
149                                             "*prop": "field",
150                                             "allowDecimals": false,
151                                             "decimalPrecision": 0,
152                                             "minValue": 1,
153                                             "style": "text-align:right",
154                                             "xtype": "NumberField",
155                                             "|xns": "Roo.form"
156                                         }
157                                     ]
158                                 }
159                             ]
160                         },
161                         {
162                             "*prop": "colModel[]",
163                             "align": "right",
164                             "dataIndex": "poitem_qty_received",
165                             "header": "Received",
166                             "width": 75,
167                             "xtype": "ColumnModel",
168                             "|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}",
169                             "|xns": "Roo.grid"
170                         },
171                         {
172                             "*prop": "colModel[]",
173                             "align": "right",
174                             "dataIndex": "poitem_qty_vouchered",
175                             "header": "Vouchered",
176                             "width": 65,
177                             "xtype": "ColumnModel",
178                             "|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}",
179                             "|xns": "Roo.grid"
180                         },
181                         {
182                             "*prop": "colModel[]",
183                             "align": "right",
184                             "dataIndex": "poitem_unitprice",
185                             "header": "Unit price",
186                             "width": 100,
187                             "xtype": "ColumnModel",
188                             "|renderer": "function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); }",
189                             "|xns": "Roo.grid",
190                             "items": [
191                                 {
192                                     "|xns": "Roo.grid",
193                                     "xtype": "GridEditor",
194                                     "*prop": "editor",
195                                     "items": [
196                                         {
197                                             "*prop": "field",
198                                             "allowBlank": false,
199                                             "allowDecimals": false,
200                                             "decimalPrecision": 0,
201                                             "minValue": 1,
202                                             "style": "text-align:right",
203                                             "xtype": "NumberField",
204                                             "|xns": "Roo.form"
205                                         }
206                                     ]
207                                 }
208                             ]
209                         }
210                     ]
211                 }
212             ]
213         }
214     ],
215     "permname": "",
216     "modOrder": "900"
217 }