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                                             default:
260                                                  return String.format('{0}', v); 
261                                          }
262                                      }
263                                 },
264                                 {
265                                     xtype: 'ColumnModel',
266                                     xns: Roo.grid,
267                                     dataIndex : 'araging_docnumber',
268                                     header : 'Docnumber',
269                                     width : 120,
270                                     renderer : function(v) {
271                                         
272                                                  return String.format('{0}', v); 
273                                          
274                                      }
275                                 },
276                                 {
277                                     xtype: 'ColumnModel',
278                                     xns: Roo.grid,
279                                     dataIndex : 'araging_ponumber_pretty',
280                                     header : 'Order',
281                                     width : 150,
282                                     renderer : function(v) { return String.format('{0}', v); }
283                                 },
284                                 {
285                                     xtype: 'ColumnModel',
286                                     xns: Roo.grid,
287                                     dataIndex : 'araging_curr_symbol',
288                                     header : 'Currency',
289                                     width : 120,
290                                     renderer : function(v) {
291                                         
292                                                  return String.format('{0}', v); 
293                                          
294                                      }
295                                 },
296                                 {
297                                     xtype: 'ColumnModel',
298                                     xns: Roo.grid,
299                                     align : 'right',
300                                     dataIndex : 'araging_aropen_amount',
301                                     header : 'Value',
302                                     width : 100,
303                                     renderer : function(v) { 
304                                     
305                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
306                                                 Roo.util.Format.usMoney(v)); 
307                                         }
308                                 },
309                                 {
310                                     xtype: 'ColumnModel',
311                                     xns: Roo.grid,
312                                     align : 'right',
313                                     dataIndex : 'araging_cur_val',
314                                     header : '30 Days',
315                                     width : 100,
316                                     renderer : function(v) { 
317                                     
318                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
319                                                 Roo.util.Format.usMoney(v)); 
320                                         }
321                                 },
322                                 {
323                                     xtype: 'ColumnModel',
324                                     xns: Roo.grid,
325                                     align : 'right',
326                                     dataIndex : 'araging_sixty_val',
327                                     header : '60 Days',
328                                     width : 100,
329                                     renderer : function(v) { 
330                                     
331                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
332                                                 Roo.util.Format.usMoney(v)); 
333                                         }
334                                 },
335                                 {
336                                     xtype: 'ColumnModel',
337                                     xns: Roo.grid,
338                                     align : 'right',
339                                     dataIndex : 'araging_ninety_val',
340                                     header : '90 Days',
341                                     width : 100,
342                                     renderer : function(v) { 
343                                     
344                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
345                                                 Roo.util.Format.usMoney(v)); 
346                                         }
347                                 },
348                                 {
349                                     xtype: 'ColumnModel',
350                                     xns: Roo.grid,
351                                     align : 'right',
352                                     dataIndex : 'araging_plus_val',
353                                     header : 'Over 90 days',
354                                     width : 150,
355                                     renderer : function(v) { 
356                                     
357                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
358                                                 Roo.util.Format.usMoney(v)); 
359                                         }
360                                 },
361                                 {
362                                     xtype: 'ColumnModel',
363                                     xns: Roo.grid,
364                                     align : 'right',
365                                     dataIndex : 'araging_total_val',
366                                     header : 'Total',
367                                     width : 150,
368                                     renderer : function(v) { 
369                                     
370                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
371                                                 Roo.util.Format.usMoney(v)); 
372                                         }
373                                 },
374                                 {
375                                     xtype: 'ColumnModel',
376                                     xns: Roo.grid,
377                                     align : 'right',
378                                     dataIndex : 'araging_base_total',
379                                     header : 'Total (BASE)',
380                                     width : 150,
381                                     renderer : function(v) { 
382                                     
383                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
384                                                 Roo.util.Format.usMoney(v)); 
385                                         }
386                                 }
387                             ]
388                         }
389                     }
390                 ],
391                 center : {
392                     xtype: 'LayoutRegion',
393                     xns: Roo
394                 }
395             }
396         };
397     }
398 });