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
110                             },
111                             dataSource : {
112                                 proxy : {
113                                     '|xns' : 'Roo.data',
114                                     url : baseURL + '/Roo/terms.php',
115                                     method : 'GET',
116                                     xtype : 'HttpProxy',
117                                     xns : Roo.data
118                                 },
119                                 reader : {
120                                     '|xns' : 'Roo.data',
121                                     id : 'id',
122                                     root : 'data',
123                                     xtype : 'JsonReader',
124                                     xns : Roo.data,
125                                     fields : [
126                                         {
127                                             'name': 'terms_id',
128                                             'type': 'int'
129                                         },
130                                         {
131                                             'name': 'terms_code',
132                                             'type': 'string'
133                                         },
134                                         {
135                                             'name': 'terms_descrip',
136                                             'type': 'string',
137                                         }
138                                     ],
139                                     totalProperty : 'total'
140                                 },
141                                 '|xns' : 'Roo.data',
142                                 xtype : 'Store',
143                                 remoteSort : true,
144                                 sortInfo : { field : 'id', direction: 'ASC' },
145                                 xns : Roo.data,
146                                 listeners : {
147                                         beforeload : function (_self, o)
148                                            {
149                                                o.params = o.params || {};
150                                                
151                                                var s = _this.searchBox.getValue();
152                                                
153                                                if(s.length){
154                                                    o.params['search[name]'] = s;
155                                                }
156                                                
157                                              
158                                            }
159                                 },
160                                 items : [
161
162                                 ]
163
164                             },
165                             footer : {
166                                 '|xns' : 'Roo',
167                                 pageSize : 25,
168                                 xtype : 'PagingToolbar',
169                                 emptyMsg : "No terms found",
170                                 xns : Roo,
171                                 displayInfo : true,
172                                 displayMsg : "Displaying Terms{0} - {1} of {2}"
173                             },
174                             '|xns' : 'Roo.grid',
175                             autoExpandColumn : 'terms_descrip',
176                             xtype : 'Grid',
177                             loadMask : true,
178                             xns : Roo.grid,
179                             cm : [
180                                  {
181                                         '|xns' : 'Roo.grid',
182                                         xtype : 'ColumnModel',
183                                         width : 75,
184                                         header : 'ID#',
185                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
186                                         xns : Roo.grid,
187                                         sortable : true,
188                                         dataIndex : 'terms_id'
189                                     },
190 {
191                                         '|xns' : 'Roo.grid',
192                                         xtype : 'ColumnModel',
193                                         header : 'Code',
194                                         width : 150,
195                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
196                                         xns : Roo.grid,
197                                         sortable : true,
198                                         dataIndex : 'terms_code'
199                                     },
200 {
201                                         '|xns' : 'Roo.grid',
202                                         xtype : 'ColumnModel',
203                                         width : 150,
204                                         header : 'Description',
205                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
206                                         xns : Roo.grid,
207                                         sortable : true,
208                                         dataIndex : 'terms_descrip'
209                                     },
210 {
211                                         '|xns' : 'Roo.grid',
212                                         xtype : 'ColumnModel',
213                                         header : 'Type',
214                                         width : 75,
215                                         renderer : function(v) { 
216                                             var t = (v == 'D') ? 'Days' : 'Proximo';
217                                             
218                                             return String.format('{0}', t); 
219                                         },
220                                         xns : Roo.grid,
221                                         sortable : true,
222                                         dataIndex : 'terms_type'
223                                     },
224 {
225                                         '|xns' : 'Roo.grid',
226                                         xtype : 'ColumnModel',
227                                         header : 'Due Days',
228                                         width : 100,
229                                         renderer : function(v) { 
230                                             return String.format('{0}', v); 
231                                             
232                                         },
233                                         xns : Roo.grid,
234                                         sortable : true,
235                                         dataIndex : 'terms_duedays'
236                                     },
237 {
238                                         '|xns' : 'Roo.grid',
239                                         xtype : 'ColumnModel',
240                                         header : 'Discount Days',
241                                         width : 100,
242                                         renderer : function(v) { 
243                                             return String.format('{0}', v); 
244                                             
245                                         },
246                                         xns : Roo.grid,
247                                         sortable : true,
248                                         dataIndex : 'terms_discdays'
249                                     },
250 {
251                                         '|xns' : 'Roo.grid',
252                                         xtype : 'ColumnModel',
253                                         header : 'Cut Off Days',
254                                         width : 100,
255                                         renderer : function(v) { 
256                                             return String.format('{0}', v); 
257                                             
258                                         },
259                                         xns : Roo.grid,
260                                         sortable : true,
261                                         dataIndex : 'terms_cutoffday'
262                                     },
263 {
264                                         '|xns' : 'Roo.grid',
265                                         xtype : 'ColumnModel',
266                                         header : 'Used in Payables',
267                                         width : 150,
268                                         renderer : function(v) {  
269                                             var state = v  ?  '-checked' : '';
270                                         
271                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
272                                                         
273                                          },
274                                         xns : Roo.grid,
275                                         sortable : true,
276                                         dataIndex : 'terms_ap'
277                                     },
278 {
279                                         '|xns' : 'Roo.grid',
280                                         xtype : 'ColumnModel',
281                                         width : 150,
282                                         header : 'Used in Receivables',
283                                         renderer : function(v) {  
284                                             var state = v  ?  '-checked' : '';
285                                         
286                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
287                                                         
288                                          },
289                                         xns : Roo.grid,
290                                         sortable : true,
291                                         dataIndex : 'terms_ar'
292                                     }
293                             ],
294                             listeners : {
295                                 rowdblclick : function (_self, rowIndex, e)
296                                    {
297                                        var id = this.getDataSource().getAt(rowIndex).data.terms_id * 1;
298                                    
299                                        if(id < 1){
300                                            Roo.MessageBox.alert('Error', 'Please select a row');
301                                            return;
302                                        }
303                                        
304                                        Pman.Dialog.XtupleTerms.show( {id : id}, function() {
305                                            _this.grid.footer.onClick('refresh');
306                                        }); 
307                                    },
308                                 render : function() 
309                                    {
310                                        _this.grid = this; 
311                                        
312                                        if (_this.panel.active) {
313                                           this.footer.onClick('first');
314                                        }
315                                    }
316                             },
317                             items : [
318
319                             ]
320
321                         },
322                         '|xns' : 'Roo',
323                         region : 'center',
324                         fitToframe : true,
325                         background : false,
326                         title : "Terms",
327                         xtype : 'GridPanel',
328                         fitContainer : true,
329                         xns : Roo,
330                         tableName : 'terms',
331                         listeners : {
332                                 activate : function() {
333                                        _this.panel = this;
334                                        if (_this.grid) {
335                                            _this.grid.footer.onClick('first');
336                                        }
337                                    }
338                         },
339                         items : [
340
341                         ]
342
343                     }
344                 ]
345
346             },
347             '|xns' : 'Roo',
348             background : false,
349             region : 'center',
350             title : "Terms",
351             xtype : 'NestedLayoutPanel',
352             xns : Roo,
353             items : [
354
355             ]
356
357         };    }
358 });