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                                     xtype : 'HttpProxy',
116                                     method : 'GET',
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 : 'crdate', 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                                         header : 'ID#',
184                                         width : 75,
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                                         width : 150,
194                                         header : 'Code',
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                                         header : 'Description',
204                                         width : 150,
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                                         width : 75,
214                                         header : 'Type',
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                                         width : 100,
228                                         header : 'Due Days',
229                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
230                                         xns : Roo.grid,
231                                         sortable : true,
232                                         dataIndex : 'terms_duedays'
233                                     },
234 {
235                                         '|xns' : 'Roo.grid',
236                                         xtype : 'ColumnModel',
237                                         width : 100,
238                                         header : 'Discount Days',
239                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
240                                         xns : Roo.grid,
241                                         sortable : true,
242                                         dataIndex : 'terms_discdays'
243                                     },
244 {
245                                         '|xns' : 'Roo.grid',
246                                         xtype : 'ColumnModel',
247                                         width : 100,
248                                         header : 'Cut Off Days',
249                                         renderer : function(v) { return String.format('{0}', v ? v : ''); },
250                                         xns : Roo.grid,
251                                         sortable : true,
252                                         dataIndex : 'terms_cutoffday'
253                                     },
254 {
255                                         '|xns' : 'Roo.grid',
256                                         xtype : 'ColumnModel',
257                                         width : 150,
258                                         header : 'Used in Payables',
259                                         renderer : function(v) {  
260                                             var state = v  ?  '-checked' : '';
261                                         
262                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
263                                                         
264                                          },
265                                         xns : Roo.grid,
266                                         sortable : true,
267                                         dataIndex : 'terms_ap'
268                                     },
269 {
270                                         '|xns' : 'Roo.grid',
271                                         xtype : 'ColumnModel',
272                                         header : 'Used in Receivables',
273                                         width : 150,
274                                         renderer : function(v) {  
275                                             var state = v  ?  '-checked' : '';
276                                         
277                                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
278                                                         
279                                          },
280                                         xns : Roo.grid,
281                                         sortable : true,
282                                         dataIndex : 'terms_ar'
283                                     }
284                             ],
285                             listeners : {
286                                 rowdblclick : function (_self, rowIndex, e)
287                                    {
288                                        var id = this.getDataSource().getAt(rowIndex).data.terms_id * 1;
289                                        Roo.log(id);
290                                        if(id < 1){
291                                            Roo.MessageBox.alert('Error', 'Please select a row');
292                                            return;
293                                        }
294                                        
295                                        Pman.Dialog.XtupleTerms.show( {id : id}, function() {
296                                            _this.grid.footer.onClick('refresh');
297                                        }); 
298                                    },
299                                 render : function() 
300                                    {
301                                        _this.grid = this; 
302                                        
303                                        if (_this.panel.active) {
304                                           this.footer.onClick('first');
305                                        }
306                                    }
307                             },
308                             items : [
309
310                             ]
311
312                         },
313                         '|xns' : 'Roo',
314                         fitToframe : true,
315                         background : false,
316                         region : 'center',
317                         title : "Terms",
318                         xtype : 'GridPanel',
319                         fitContainer : true,
320                         xns : Roo,
321                         tableName : 'terms',
322                         listeners : {
323                                 activate : function() {
324                                        _this.panel = this;
325                                        if (_this.grid) {
326                                            _this.grid.footer.onClick('first');
327                                        }
328                                    }
329                         },
330                         items : [
331
332                         ]
333
334                     }
335                 ]
336
337             },
338             '|xns' : 'Roo',
339             background : false,
340             region : 'center',
341             title : "Terms",
342             xtype : 'NestedLayoutPanel',
343             xns : Roo,
344             items : [
345
346             ]
347
348         };    }
349 });