Pman.Tab.XtupleArAging.bjs
[Pman.Xtuple] / Pman.Tab.XtupleArAging.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.XtupleArAging = new Roo.XComponent({
6     part     :  ["Xtuple","ArAging"],
7     order    : '300-Pman.Tab.XtupleArAging',
8     region   : 'center',
9     parent   : 'Pman.Tab.XtupleAccountsTab',
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: 'NestedLayoutPanel',
19             xns: Roo,
20             background : true,
21             fitContainer : true,
22             fitToFrame : true,
23             region : 'center',
24             title : "Accounts Recievable",
25             layout : {
26                 xtype: 'BorderLayout',
27                 xns: Roo,
28                 items : [
29                     {
30                         xtype: 'GridPanel',
31                         xns: Roo,
32                         listeners : {
33                             activate : function() {
34                                 _this.panel = this;
35                                 if (_this.grid) {
36                                     _this.grid.footer.onClick('first');
37                                 }
38                             }
39                         },
40                         background : true,
41                         fitContainer : true,
42                         fitToframe : true,
43                         region : 'center',
44                         tableName : 'aropen',
45                         title : "ArAging",
46                         grid : {
47                             xtype: 'Grid',
48                             xns: Roo.grid,
49                             listeners : {
50                                 render : function() 
51                                 {
52                                     _this.grid = this; 
53                                     //_this.dialog = Pman.Dialog.FILL_IN
54                                     if (_this.panel.active) {
55                                        this.footer.onClick('first');
56                                     }
57                                 }
58                             },
59                             autoExpandColumn : 'araging_cust_name',
60                             loadMask : true,
61                             dataSource : {
62                                 xtype: 'Store',
63                                 xns: Roo.data,
64                                 listeners : {
65                                     beforeload : function (_self, o)
66                                     {
67                                         o.params = o.params || {};
68                                         
69                                     
70                                         
71                                         var dt = _this.relDate.getValue();
72                                         
73                                         var params = {
74                                             _group : 'arAging',
75                                             _name : 'bydate',
76                                             'relDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
77                                             'useDocDate:text' : false
78                                         };
79                                         
80                                         var cs = _this.customerSel.getValue();
81                                         if (cs*1) {
82                                             params['cust_id:number'] = cs;
83                                         
84                                         }
85                                         
86                                         
87                                         Roo.apply(o.params,params);
88                                     }
89                                 },
90                                 remoteSort : true,
91                                 proxy : {
92                                     xtype: 'HttpProxy',
93                                     xns: Roo.data,
94                                     method : 'GET',
95                                     timeout : 600000,
96                                     url : baseURL + '/Roo/Metasql.php'
97                                 },
98                                 reader : {
99                                     xtype: 'JsonReader',
100                                     xns: Roo.data,
101                                     id : 'id',
102                                     root : 'data',
103                                     totalProperty : 'total',
104                                     fields : [
105                                         {
106                                             'name': 'araging_apopen_id',
107                                             'type': 'int'
108                                         },
109                                         {
110                                             'name': 'araging_cust_id',
111                                             'type': 'int'
112                                         }
113                                     ]
114                                 }
115                             },
116                             toolbar : {
117                                 xtype: 'Toolbar',
118                                 xns: Roo,
119                                 items : [
120                                     {
121                                         xtype: 'ComboBox',
122                                         xns: Roo.form,
123                                         listeners : {
124                                             render : function (_self)
125                                             {
126                                                 _this.customerSel = _self;
127                                             },
128                                             select : function (combo, record, index)
129                                             {
130                                                 _this.grid.footer.onClick('first');
131                                             }
132                                         },
133                                         allowBlank : true,
134                                         displayField : 'cust_name',
135                                         editable : true,
136                                         emptyText : "Select customer",
137                                         fieldLabel : 'cust_name',
138                                         forceSelection : true,
139                                         hiddenName : 'cust_id',
140                                         listWidth : 400,
141                                         loadingText : "Searching...",
142                                         minChars : 2,
143                                         name : 'cust_name',
144                                         pageSize : 20,
145                                         qtip : "Select Customer",
146                                         queryParam : 'cust_name:text',
147                                         selectOnFocus : true,
148                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{cust_name}</b> </div>',
149                                         triggerAction : 'all',
150                                         typeAhead : true,
151                                         valueField : 'cust_id',
152                                         width : 300,
153                                         store : {
154                                             xtype: 'Store',
155                                             xns: Roo.data,
156                                             listeners : {
157                                                 beforeload : function (_self, o){
158                                                     o.params = o.params || {};
159                                                 
160                                                     if (!_this.relDate) {
161                                                         return false;
162                                                     }
163                                                     var dt = _this.relDate.getValue();    
164                                                     // set more here
165                                                     o.params['_group'] = 'arAging';
166                                                     o.params['_name'] = 'customers';
167                                                     o.params['relDate:text']  = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
168                                                     o.params['useDocDate:text'] = false    
169                                                 }
170                                             },
171                                             remoteSort : true,
172                                             sortInfo : { direction : 'ASC', field: 'cust_name' },
173                                             proxy : {
174                                                 xtype: 'HttpProxy',
175                                                 xns: Roo.data,
176                                                 method : 'GET',
177                                                 url : baseURL + '/Roo/metasql.php'
178                                             },
179                                             reader : {
180                                                 xtype: 'JsonReader',
181                                                 xns: Roo.data,
182                                                 id : 'cust_id',
183                                                 root : 'data',
184                                                 totalProperty : 'total',
185                                                 fields : [{"name":"cust_id","type":"int"},"cust_name"]
186                                             }
187                                         }
188                                     },
189                                     {
190                                         xtype: 'TextItem',
191                                         xns: Roo.Toolbar,
192                                         text : "as Of:"
193                                     },
194                                     {
195                                         xtype: 'DateField',
196                                         xns: Roo.form,
197                                         listeners : {
198                                             render : function (_self)\r
199                                             {\r
200                                                 _this.relDate = _self;\r
201                                                _self.setValue(  new Date() );\r
202                                             },
203                                             select : function (combo, date)
204                                             {
205                                                 _this.grid.footer.onClick('first');
206                                             }
207                                         },
208                                         allowBlank : false,
209                                         format : 'Y-m-d',
210                                         width : 100
211                                     }
212                                 ]
213                             },
214                             footer : {
215                                 xtype: 'PagingToolbar',
216                                 xns: Roo,
217                                 displayInfo : true,
218                                 displayMsg : "Displaying araging{0} - {1} of {2}",
219                                 emptyMsg : "Nothing found",
220                                 pageSize : 25
221                             },
222                             colModel : [
223                                 {
224                                     xtype: 'ColumnModel',
225                                     xns: Roo.grid,
226                                     dataIndex : 'araging_docdate',
227                                     header : 'Date',
228                                     width : 100,
229                                     renderer : function(v) { 
230                                         var d = Date.parseDate(v, 'Y-m-d');
231                                     
232                                         return String.format('{0}', d.format('d/M/Y')); 
233                                     }
234                                 },
235                                 {
236                                     xtype: 'ColumnModel',
237                                     xns: Roo.grid,
238                                     dataIndex : 'araging_cust_name',
239                                     header : 'Customer',
240                                     width : 200,
241                                     renderer : function(v) { return String.format('{0}', v); }
242                                 },
243                                 {
244                                     xtype: 'ColumnModel',
245                                     xns: Roo.grid,
246                                     dataIndex : 'araging_doctype',
247                                     header : 'Doc Type',
248                                     width : 120,
249                                     renderer : function(v) {
250                                         switch(v) {
251                                             case 'I':
252                                                 return "Invoice";
253                                             case 'C':
254                                                 return "Credit Memo";        
255                                             case 'D':
256                                                 return "Debit Memo";                    
257                                             case 'R':
258                                                 return "Cash Receipt";        
259                                             case 'V':
260                                                 return "Voucher";     
261                                             default:
262                                                  return String.format('{0}', v); 
263                                          }
264                                      }
265                                 },
266                                 {
267                                     xtype: 'ColumnModel',
268                                     xns: Roo.grid,
269                                     dataIndex : 'araging_docnumber',
270                                     header : 'Docnumber',
271                                     width : 120,
272                                     renderer : function(v) {
273                                         
274                                                  return String.format('{0}', v); 
275                                          
276                                      }
277                                 },
278                                 {
279                                     xtype: 'ColumnModel',
280                                     xns: Roo.grid,
281                                     dataIndex : 'araging_ponumber_pretty',
282                                     header : 'Order',
283                                     width : 150,
284                                     renderer : function(v) { return String.format('{0}', v); }
285                                 },
286                                 {
287                                     xtype: 'ColumnModel',
288                                     xns: Roo.grid,
289                                     dataIndex : 'araging_curr_symbol',
290                                     header : 'Currency',
291                                     width : 120,
292                                     renderer : function(v) {
293                                         
294                                                  return String.format('{0}', v); 
295                                          
296                                      }
297                                 },
298                                 {
299                                     xtype: 'ColumnModel',
300                                     xns: Roo.grid,
301                                     align : 'right',
302                                     dataIndex : 'araging_aropen_amount',
303                                     header : 'Value',
304                                     width : 100,
305                                     renderer : function(v) { 
306                                     
307                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
308                                                 Roo.util.Format.usMoney(v)); 
309                                         }
310                                 },
311                                 {
312                                     xtype: 'ColumnModel',
313                                     xns: Roo.grid,
314                                     align : 'right',
315                                     dataIndex : 'araging_cur_val',
316                                     header : '30 Days',
317                                     width : 100,
318                                     renderer : function(v) { 
319                                     
320                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
321                                                 Roo.util.Format.usMoney(v)); 
322                                         }
323                                 },
324                                 {
325                                     xtype: 'ColumnModel',
326                                     xns: Roo.grid,
327                                     align : 'right',
328                                     dataIndex : 'araging_sixty_val',
329                                     header : '60 Days',
330                                     width : 100,
331                                     renderer : function(v) { 
332                                     
333                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
334                                                 Roo.util.Format.usMoney(v)); 
335                                         }
336                                 },
337                                 {
338                                     xtype: 'ColumnModel',
339                                     xns: Roo.grid,
340                                     align : 'right',
341                                     dataIndex : 'araging_ninety_val',
342                                     header : '90 Days',
343                                     width : 100,
344                                     renderer : function(v) { 
345                                     
346                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
347                                                 Roo.util.Format.usMoney(v)); 
348                                         }
349                                 },
350                                 {
351                                     xtype: 'ColumnModel',
352                                     xns: Roo.grid,
353                                     align : 'right',
354                                     dataIndex : 'araging_plus_val',
355                                     header : 'Over 90 days',
356                                     width : 150,
357                                     renderer : function(v) { 
358                                     
359                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
360                                                 Roo.util.Format.usMoney(v)); 
361                                         }
362                                 },
363                                 {
364                                     xtype: 'ColumnModel',
365                                     xns: Roo.grid,
366                                     align : 'right',
367                                     dataIndex : 'araging_total_val',
368                                     header : 'Total',
369                                     width : 150,
370                                     renderer : function(v) { 
371                                     
372                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
373                                                 Roo.util.Format.usMoney(v)); 
374                                         }
375                                 },
376                                 {
377                                     xtype: 'ColumnModel',
378                                     xns: Roo.grid,
379                                     align : 'right',
380                                     dataIndex : 'araging_base_total',
381                                     header : 'Total (BASE)',
382                                     width : 150,
383                                     renderer : function(v) { 
384                                     
385                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
386                                                 Roo.util.Format.usMoney(v)); 
387                                         }
388                                 }
389                             ]
390                         }
391                     }
392                 ],
393                 center : {
394                     xtype: 'LayoutRegion',
395                     xns: Roo
396                 }
397             }
398         };
399     }
400 });