Pman.Tab.XtupleTerms.bjs
[Pman.Xtuple] / Pman.Tab.XtupleTerms.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.XtupleTerms = new Roo.XComponent({
8     part     :  ["Xtuple", "Terms" ],
9     order    : '700-Pman.Tab.XtupleTerms',
10     region   : 'center',
11     parent   : 'Pman.Tab.XtupleAccountsTab',
12     name     : "unnamed module",
13     disabled : false, 
14     permname : '', 
15     _tree : function()
16     {
17         var _this = this;
18         var MODULE = this;
19         return {
20             layout : {
21                 center : {
22                     '|xns' : 'Roo',
23                     xtype : 'LayoutRegion',
24                     xns : Roo
25                 },
26                 '|xns' : 'Roo',
27                 xtype : 'BorderLayout',
28                 xns : Roo,
29                 items : [
30                         {
31                         grid : {
32                             sm : {
33                                 '|xns' : 'Roo.grid',
34                                 singleSelect : true,
35                                 xtype : 'RowSelectionModel',
36                                 xns : Roo.grid
37                             },
38                             toolbar : {
39                                 '|xns' : 'Roo',
40                                 xtype : 'Toolbar',
41                                 xns : Roo,
42                                 items : [
43                                         {
44                                         '|xns' : 'Roo.form',
45                                         xtype : 'TextField',
46                                         xns : Roo.form,
47                                         listeners : {
48                                                 specialkey : function (_self, e)
49                                                    {
50                                                      _this.grid.footer.onClick('first');
51                                                    },
52                                                 render : function (_self)
53                                                    {
54                                                        _this.searchBox = _self;
55                                                    }
56                                         }
57                                     },
58                                         {
59                                         '|xns' : 'Roo.Toolbar',
60                                         xtype : 'Button',
61                                         cls : 'x-btn-icon',
62                                         icon : rootURL + '/Pman/templates/images/search.gif',
63                                         xns : Roo.Toolbar,
64                                         listeners : {
65                                                 click : function (_self, e)
66                                                    {
67                                                        _this.grid.footer.onClick('first');
68                                                    }
69                                         }
70                                     },
71                                         {
72                                         '|xns' : 'Roo.Toolbar',
73                                         xtype : 'Button',
74                                         cls : 'x-btn-icon',
75                                         icon : rootURL + '/Pman/templates/images/edit-clear.gif',
76                                         xns : Roo.Toolbar,
77                                         listeners : {
78                                                 click : function (_self, e)
79                                                    {
80                                                        _this.searchBox.setValue('');\r
81                                                    \r
82                                                        _this.grid.footer.onClick('first');\r
83                                                    }
84                                         }
85                                     },
86                                         {
87                                         '|xns' : 'Roo.Toolbar',
88                                         xtype : 'Fill',
89                                         xns : Roo.Toolbar
90                                     },
91                                         {
92                                         '|xns' : 'Roo.Toolbar',
93                                         text : "Add",
94                                         xtype : 'Button',
95                                         cls : 'x-btn-text-icon',
96                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
97                                         xns : Roo.Toolbar,
98                                         listeners : {
99                                                 click : function()
100                                                    {
101                                                    
102                                                       Pman.Dialog.XtupleTerms.show( { id : 0 } , function() {
103                                                            _this.grid.footer.onClick('first');
104                                                       }); 
105                                                    }
106                                         }
107                                     },
108                                         {
109                                         '|xns' : 'Roo.Toolbar',
110                                         text : "Delete",
111                                         xtype : 'Button',
112                                         cls : 'x-btn-text-icon',
113                                         icon : rootURL + '/Pman/templates/images/trash.gif',
114                                         xns : Roo.Toolbar,
115                                         listeners : {
116                                                 click : function()
117                                                    {
118                                                         Pman.genericDelete(_this, 'ipshead'); 
119                                                    }
120                                         }
121                                     }
122                                 ]
123
124                             },
125                             dataSource : {
126                                 proxy : {
127                                     '|xns' : 'Roo.data',
128                                     url : baseURL + '/Roo/terms.php',
129                                     method : 'GET',
130                                     xtype : 'HttpProxy',
131                                     xns : Roo.data
132                                 },
133                                 reader : {
134                                     '|xns' : 'Roo.data',
135                                     id : 'id',
136                                     root : 'data',
137                                     xtype : 'JsonReader',
138                                     xns : Roo.data,
139                                     fields : [
140                                         {
141                                             'name': 'terms_id',
142                                             'type': 'int'
143                                         },
144                                         {
145                                             'name': 'terms_code',
146                                             'type': 'string'
147                                         },
148                                         {
149                                             'name': 'terms_descrip',
150                                             'type': 'string',
151                                         }
152                                     ],
153                                     totalProperty : 'total'
154                                 },
155                                 '|xns' : 'Roo.data',
156                                 xtype : 'Store',
157                                 remoteSort : true,
158                                 sortInfo : { field : 'terms_id', direction: 'ASC' },
159                                 xns : Roo.data,
160                                 listeners : {
161                                         beforeload : function (_self, o)
162                                            {
163                                                o.params = o.params || {};
164                                                
165                                                var s = _this.searchBox.getValue();
166                                                
167                                                if(s.length){
168                                                    o.params['search[name]'] = s;
169                                                }
170                                                
171                                              
172                                            }
173                                 },
174                                 items : [
175
176                                 ]
177
178                             },
179                             footer : {
180                                 '|xns' : 'Roo',
181                                 pageSize : 25,
182                                 xtype : 'PagingToolbar',
183                                 emptyMsg : "No terms found",
184                                 xns : Roo,
185                                 displayInfo : true,
186                                 displayMsg : "Displaying Terms{0} - {1} of {2}"
187                             },
188                             '|xns' : 'Roo.grid',
189                             autoExpandColumn : 'terms_descrip',
190                             xtype : 'Grid',
191                             loadMask : true,
192                             xns : Roo.grid,
193                             cm : [
194                                  {
195                                         '|xns' : 'Roo.grid',
196                                         xtype : 'ColumnModel',
197                                         width : 75,
198                                         header : 'ID#',
199                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
200                                         xns : Roo.grid,
201                                         sortable : true,
202                                         dataIndex : 'terms_id'
203                                     },
204 {
205                                         '|xns' : 'Roo.grid',
206                                         xtype : 'ColumnModel',
207                                         header : 'Code',
208                                         width : 150,
209                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
210                                         xns : Roo.grid,
211                                         sortable : true,
212                                         dataIndex : 'terms_code'
213                                     },
214 {
215                                         '|xns' : 'Roo.grid',
216                                         xtype : 'ColumnModel',
217                                         width : 150,
218                                         header : 'Description',
219                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
220                                         xns : Roo.grid,
221                                         sortable : true,
222                                         dataIndex : 'terms_descrip'
223                                     },
224 {
225                                         '|xns' : 'Roo.grid',
226                                         xtype : 'ColumnModel',
227                                         header : 'Type',
228                                         width : 75,
229                                         renderer : function(v) { 
230                                             var t = (v == 'D') ? 'Days' : 'Proximo';
231                                             
232                                             return String.format('{0}', t); 
233                                         },
234                                         xns : Roo.grid,
235                                         sortable : true,
236                                         dataIndex : 'terms_type'
237                                     },
238 {
239                                         '|xns' : 'Roo.grid',
240                                         xtype : 'ColumnModel',
241                                         header : 'Due Days',
242                                         width : 100,
243                                         renderer : function(v) { 
244                                             return String.format('{0}', v); 
245                                             
246                                         },
247                                         xns : Roo.grid,
248                                         sortable : true,
249                                         dataIndex : 'terms_duedays'
250                                     },
251 {
252                                         '|xns' : 'Roo.grid',
253                                         xtype : 'ColumnModel',
254                                         header : 'Discount Days',
255                                         width : 100,
256                                         renderer : function(v) { 
257                                             return String.format('{0}', v); 
258                                             
259                                         },
260                                         xns : Roo.grid,
261                                         sortable : true,
262                                         dataIndex : 'terms_discdays'
263                                     },
264 {
265                                         '|xns' : 'Roo.grid',
266                                         xtype : 'ColumnModel',
267                                         header : 'Cut Off Days',
268                                         width : 100,
269                                         renderer : function(v) { 
270                                             return String.format('{0}', v); 
271                                             
272                                         },
273                                         xns : Roo.grid,
274                                         sortable : true,
275                                         dataIndex : 'terms_cutoffday'
276                                     },
277 {
278                                         '|xns' : 'Roo.grid',
279                                         xtype : 'ColumnModel',
280                                         header : 'Used in Payables',
281                                         width : 150,
282                                         renderer : function(v) {  
283                                             var state = v  ?  '-checked' : '';
284                                         
285                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
286                                                         
287                                          },
288                                         xns : Roo.grid,
289                                         sortable : true,
290                                         dataIndex : 'terms_ap'
291                                     },
292 {
293                                         '|xns' : 'Roo.grid',
294                                         xtype : 'ColumnModel',
295                                         width : 150,
296                                         header : 'Used in Receivables',
297                                         renderer : function(v) {  
298                                             var state = v  ?  '-checked' : '';
299                                         
300                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
301                                                         
302                                          },
303                                         xns : Roo.grid,
304                                         sortable : true,
305                                         dataIndex : 'terms_ar'
306                                     }
307                             ],
308                             listeners : {
309                                 rowdblclick : function (_self, rowIndex, e)
310                                    {
311                                        var id = this.getDataSource().getAt(rowIndex).data.terms_id * 1;
312                                    
313                                        if(id < 1){
314                                            Roo.MessageBox.alert('Error', 'Please select a row');
315                                            return;
316                                        }
317                                        
318                                        Pman.Dialog.XtupleTerms.show( {id : id}, function() {
319                                            _this.grid.footer.onClick('refresh');
320                                        }); 
321                                    },
322                                 render : function() 
323                                    {
324                                        _this.grid = this; 
325                                        
326                                        if (_this.panel.active) {
327                                           this.footer.onClick('first');
328                                        }
329                                    }
330                             },
331                             items : [
332
333                             ]
334
335                         },
336                         '|xns' : 'Roo',
337                         region : 'center',
338                         fitToframe : true,
339                         background : false,
340                         title : "Terms",
341                         xtype : 'GridPanel',
342                         fitContainer : true,
343                         xns : Roo,
344                         tableName : 'terms',
345                         listeners : {
346                                 activate : function() {
347                                        _this.panel = this;
348                                        if (_this.grid) {
349                                            _this.grid.footer.onClick('first');
350                                        }
351                                    }
352                         },
353                         items : [
354
355                         ]
356
357                     }
358                 ]
359
360             },
361             '|xns' : 'Roo',
362             background : false,
363             region : 'center',
364             title : "Terms",
365             xtype : 'NestedLayoutPanel',
366             xns : Roo,
367             items : [
368
369             ]
370
371         };    }
372 });