Pman.Tab.XtupleMetric.bjs
[Pman.Xtuple] / Pman.Tab.XtupleMetric.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.XtupleMetric = new Roo.XComponent({
6     part     :  ["Xtuple","Metric"],
7     order    : '900-Pman.Tab.XtupleMetric',
8     region   : 'center',
9     parent   : 'Pman.Tab.Admin',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'GridPanel',
19             xns: Roo,
20             listeners : {
21                 activate : function() {
22                     _this.panel = this;
23                     if (_this.grid) {
24                         _this.grid.footer.onClick('first');
25                     }
26                 }
27             },
28             background : true,
29             fitContainer : true,
30             fitToframe : true,
31             region : 'center',
32             tableName : 'metric',
33             title : "Metric",
34             grid : {
35                 xtype: 'EditorGrid',
36                 xns: Roo.grid,
37                 listeners : {
38                     render : function() 
39                     {
40                         _this.grid = this; 
41                         if (_this.panel.active) {
42                            this.footer.onClick('first');
43                         }
44                     },
45                     beforeedit : function (e)
46                     {
47                         var r = e.record.data.poitem_qty_received * 1;
48                         
49                         if(r > 0){
50                             Roo.MessageBox.alert("Error", "This item has been receipted");
51                             return false;
52                         }
53                         
54                         var status = _this.form.findField('pohead_status').getValue();
55                         
56                         if(status == 'C'){
57                             Roo.MessageBox.alert("Error", "This PO has been closed");
58                             return false;
59                         }
60                         
61                         
62                     }
63                 },
64                 autoExpandColumn : 'metric_value',
65                 clicksToEdit : 1,
66                 loadMask : true,
67                 dataSource : {
68                     xtype: 'Store',
69                     xns: Roo.data,
70                     listeners : {
71                         beforeload : function (_self, o){
72                             o.params = o.params || {};
73                             
74                             var s = _this.searchBox.getValue();
75                             
76                             if(!s || !s.length){
77                                 return;
78                             }
79                             
80                             o.params['search[name]'] = s;
81                         }
82                     },
83                     remoteSort : true,
84                     sortInfo : { field : 'metric_name', direction: 'ASC' },
85                     proxy : {
86                         xtype: 'HttpProxy',
87                         xns: Roo.data,
88                         method : 'GET',
89                         timeout : 90000,
90                         url : baseURL + '/Xtuple/Roo/Metric.php'
91                     },
92                     reader : {
93                         xtype: 'JsonReader',
94                         xns: Roo.data,
95                         id : 'metric_id',
96                         root : 'data',
97                         totalProperty : 'total',
98                         fields : [
99                             {
100                                 'name': 'metric_id',
101                                 'type': 'int'
102                             },
103                             {
104                                 'name': 'metric_name',
105                                 'type': 'string'
106                             },
107                             {
108                                 'name': 'metric_value',
109                                 'type': 'string'
110                             },
111                             {
112                                 'name': 'metric_module',
113                                 'type': 'string'
114                             }
115                         ]
116                     }
117                 },
118                 toolbar : {
119                     xtype: 'Toolbar',
120                     xns: Roo,
121                     items : [
122                         {
123                             xtype: 'TextField',
124                             xns: Roo.form,
125                             listeners : {
126                                 specialkey : function (_self, e)
127                                 {
128                                   _this.grid.footer.onClick('first');
129                                 },
130                                 render : function (_self)
131                                 {
132                                     _this.searchBox = _self;
133                                 }
134                             }
135                         },
136                         {
137                             xtype: 'Button',
138                             xns: Roo.Toolbar,
139                             listeners : {
140                                 click : function (_self, e)
141                                 {
142                                     _this.grid.footer.onClick('first');
143                                 }
144                             },
145                             cls : 'x-btn-icon',
146                             icon : rootURL + '/Pman/templates/images/search.gif'
147                         },
148                         {
149                             xtype: 'Button',
150                             xns: Roo.Toolbar,
151                             listeners : {
152                                 click : function (_self, e)
153                                 {
154                                     _this.searchBox.setValue('');
155                                     _this.grid.footer.onClick('first');\r
156                                 }
157                             },
158                             cls : 'x-btn-icon',
159                             icon : rootURL + '/Pman/templates/images/edit-clear.gif'
160                         }
161                     ]
162                 },
163                 footer : {
164                     xtype: 'PagingToolbar',
165                     xns: Roo,
166                     displayInfo : true,
167                     emptyMsg : "No Metric found",
168                     pageSize : 50
169                 },
170                 colModel : [
171                     {
172                         xtype: 'ColumnModel',
173                         xns: Roo.grid,
174                         dataIndex : 'metric_id',
175                         header : 'ID',
176                         width : 75,
177                         renderer : function(v) { return String.format('{0}', v); }
178                     },
179                     {
180                         xtype: 'ColumnModel',
181                         xns: Roo.grid,
182                         dataIndex : 'metric_name',
183                         header : 'Name',
184                         width : 150,
185                         renderer : function(v) { return String.format('{0}', v); }
186                     },
187                     {
188                         xtype: 'ColumnModel',
189                         xns: Roo.grid,
190                         dataIndex : 'metric_value',
191                         header : 'Value',
192                         width : 150,
193                         renderer : function(v) { return String.format('{0}', v); }
194                     },
195                     {
196                         xtype: 'ColumnModel',
197                         xns: Roo.grid,
198                         dataIndex : 'metric_module',
199                         header : 'Module',
200                         width : 100,
201                         renderer : function(v) { return String.format('{0}', v); }
202                     }
203                 ]
204             }
205         };
206     }
207 });