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