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                     afteredit : function (e)
46                     {
47                         if(e.originalValue == e.value || !e.value.length){
48                             return false;
49                         }
50                         
51                         e.record.commit();
52                     }
53                 },
54                 autoExpandColumn : 'metric_value',
55                 clicksToEdit : 1,
56                 loadMask : true,
57                 dataSource : {
58                     xtype: 'Store',
59                     xns: Roo.data,
60                     listeners : {
61                         beforeload : function (_self, o){
62                             o.params = o.params || {};
63                             
64                             var s = _this.searchBox.getValue();
65                             
66                             if(!s || !s.length){
67                                 return;
68                             }
69                             
70                             o.params['search[name]'] = s;
71                         },
72                         update : function (_self, record, operation)
73                         {
74                             if (operation != Roo.data.Record.COMMIT) {
75                                 return;
76                             }
77                         
78                             if (!record.data.metric_name.length || !record.data.metric_value.length) {
79                                 return;
80                             }
81                             
82                             new Pman.Request({
83                                 url : baseURL + '/Roo/Metric',
84                                 method : 'POST',
85                                 params : record.data,
86                                 success : function(res) {
87                                     _this.grid.footer.onClick('refresh');
88                                 }
89                             });
90                             
91                         }
92                     },
93                     remoteSort : true,
94                     sortInfo : { field : 'metric_name', direction: 'ASC' },
95                     proxy : {
96                         xtype: 'HttpProxy',
97                         xns: Roo.data,
98                         method : 'GET',
99                         timeout : 90000,
100                         url : baseURL + '/Xtuple/Roo/Metric.php'
101                     },
102                     reader : {
103                         xtype: 'JsonReader',
104                         xns: Roo.data,
105                         id : 'metric_id',
106                         root : 'data',
107                         totalProperty : 'total',
108                         fields : [
109                             {
110                                 'name': 'metric_id',
111                                 'type': 'int'
112                             },
113                             {
114                                 'name': 'metric_name',
115                                 'type': 'string'
116                             },
117                             {
118                                 'name': 'metric_value',
119                                 'type': 'string'
120                             },
121                             {
122                                 'name': 'metric_module',
123                                 'type': 'string'
124                             }
125                         ]
126                     }
127                 },
128                 toolbar : {
129                     xtype: 'Toolbar',
130                     xns: Roo,
131                     items : [
132                         {
133                             xtype: 'TextField',
134                             xns: Roo.form,
135                             listeners : {
136                                 specialkey : function (_self, e)
137                                 {
138                                   _this.grid.footer.onClick('first');
139                                 },
140                                 render : function (_self)
141                                 {
142                                     _this.searchBox = _self;
143                                 }
144                             }
145                         },
146                         {
147                             xtype: 'Button',
148                             xns: Roo.Toolbar,
149                             listeners : {
150                                 click : function (_self, e)
151                                 {
152                                     _this.grid.footer.onClick('first');
153                                 }
154                             },
155                             cls : 'x-btn-icon',
156                             icon : rootURL + '/Pman/templates/images/search.gif'
157                         },
158                         {
159                             xtype: 'Button',
160                             xns: Roo.Toolbar,
161                             listeners : {
162                                 click : function (_self, e)
163                                 {
164                                     _this.searchBox.setValue('');
165                                     _this.grid.footer.onClick('first');\r
166                                 }
167                             },
168                             cls : 'x-btn-icon',
169                             icon : rootURL + '/Pman/templates/images/edit-clear.gif'
170                         },
171                         {
172                             xtype: 'Fill',
173                             xns: Roo.Toolbar
174                         },
175                         {
176                             xtype: 'Button',
177                             xns: Roo.Toolbar,
178                             listeners : {
179                                 click : function()
180                                 {
181                                     
182                                     var nr = _this.grid.ds.reader.newRow({
183                                         metric_id : 0,
184                                         metric_name : '',
185                                         metric_value : '',
186                                         metric_module : ''
187                                     });
188                                     
189                                     _this.grid.stopEditing();
190                                     _this.grid.ds.insert(0, nr); 
191                                     _this.grid.startEditing(0, 0);
192                                 }
193                             },
194                             cls : 'x-btn-text-icon',
195                             text : "Add",
196                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
197                         },
198                         {
199                             xtype: 'Button',
200                             xns: Roo.Toolbar,
201                             listeners : {
202                                 click : function ()
203                                 {
204                                 
205                                      var sel  = _this.invgrid.getSelectionModel().getSelected();
206                                     if (!sel) {
207                                         Roo.MessageBox.alert("Error", "Select a invoice");
208                                         return;
209                                     }
210                                     // check current status of shipment..
211                                     
212                                     var params =  {
213                                 //        cobmisc_id : sel.data.cobmisc_id,
214                                         _void : 1
215                                     };
216                                     if (sel.data.cobmisc_id * 1) {
217                                         params.cobmisc_id = sel.data.cobmisc_id * 1 ;
218                                     }
219                                     if (sel.data.cobmisc_invchead_id_invchead_id * 1) {    
220                                         params.invchead_id  =  sel.data.cobmisc_invchead_id_invchead_id * 1;
221                                     }
222                                     
223                                     Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
224                                         function(r) {
225                                             if (r != 'yes') {
226                                                 return;
227                                             }
228                                             new Pman.Request({
229                                                 mask : 'Sending',
230                                                 url : baseURL + '/Roo/cobmisc',
231                                                 method : 'POST',
232                                                 params :  params,
233                                                 success : function() {
234                                                     _this.invgrid.ds.load({});
235                                                 }
236                                             })
237                                             
238                                         }
239                                     );
240                                             
241                                             
242                                    
243                                 }
244                             },
245                             cls : 'x-btn-text-icon',
246                             text : "Remove",
247                             icon : rootURL + '/Pman/templates/images/trash.gif'
248                         }
249                     ]
250                 },
251                 footer : {
252                     xtype: 'PagingToolbar',
253                     xns: Roo,
254                     displayInfo : true,
255                     emptyMsg : "No Metric found",
256                     pageSize : 50
257                 },
258                 colModel : [
259                     {
260                         xtype: 'ColumnModel',
261                         xns: Roo.grid,
262                         dataIndex : 'metric_name',
263                         header : 'Name',
264                         width : 250,
265                         renderer : function(v) { return String.format('{0}', v); },
266                         editor : {
267                             xtype: 'GridEditor',
268                             xns: Roo.grid,
269                             field : {
270                                 xtype: 'TextField',
271                                 xns: Roo.form,
272                                 allowBlank : false
273                             }
274                         }
275                     },
276                     {
277                         xtype: 'ColumnModel',
278                         xns: Roo.grid,
279                         dataIndex : 'metric_value',
280                         header : 'Value',
281                         width : 150,
282                         renderer : function(v) { return String.format('{0}', v); },
283                         editor : {
284                             xtype: 'GridEditor',
285                             xns: Roo.grid,
286                             field : {
287                                 xtype: 'TextField',
288                                 xns: Roo.form,
289                                 allowBlank : false
290                             }
291                         }
292                     },
293                     {
294                         xtype: 'ColumnModel',
295                         xns: Roo.grid,
296                         dataIndex : 'metric_module',
297                         header : 'Module',
298                         width : 100,
299                         renderer : function(v) { return String.format('{0}', v); },
300                         editor : {
301                             xtype: 'GridEditor',
302                             xns: Roo.grid,
303                             field : {
304                                 xtype: 'TextField',
305                                 xns: Roo.form,
306                                 allowBlank : false
307                             }
308                         }
309                     }
310                 ]
311             }
312         };
313     }
314 });