Pman.Tab.XtupleApAging.bjs
[Pman.Xtuple] / Pman.Tab.XtupleApAging.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.XtupleApAging = new Roo.XComponent({
6     part     :  ["Xtuple","ApAging"],
7     order    : '400-Pman.Tab.XtupleApAging',
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 Payable",
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 : 'apopen',
45                         title : "ApAging",
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 : 'apAging',
75                                             _name : 'bydate',
76                                             'relDate:text' : typeof(dt) == 'string' ? dt : dt.format('Y-m-d'),
77                                             'useDocDate:text' : false
78                                         };
79                                         
80                                         var vend = _this.vendSel.getValue();
81                                         if (vend*1) {
82                                             params['vend_id:number'] = vend;
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': 'apaging_doctype',
107                                             'type': 'string'
108                                         }
109                                     ]
110                                 }
111                             },
112                             toolbar : {
113                                 xtype: 'Toolbar',
114                                 xns: Roo,
115                                 items : [
116                                     {
117                                         xtype: 'ComboBox',
118                                         xns: Roo.form,
119                                         listeners : {
120                                             render : function (_self)
121                                             {
122                                                 _this.vendSel = _self;
123                                             },
124                                             select : function (combo, record, index)
125                                             {
126                                                 _this.grid.footer.onClick('first');
127                                             }
128                                         },
129                                         allowBlank : true,
130                                         displayField : 'vend_name',
131                                         editable : true,
132                                         emptyText : "Select Vendor",
133                                         fieldLabel : 'cust_name',
134                                         forceSelection : true,
135                                         hiddenName : 'vend_id',
136                                         listWidth : 400,
137                                         loadingText : "Searching...",
138                                         minChars : 2,
139                                         name : 'vend_name',
140                                         pageSize : 20,
141                                         qtip : "Select Vendor",
142                                         queryParam : 'vend_name:text',
143                                         selectOnFocus : true,
144                                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{vend_name}</b> </div>',
145                                         triggerAction : 'all',
146                                         typeAhead : true,
147                                         valueField : 'vend_id',
148                                         width : 300,
149                                         store : {
150                                             xtype: 'Store',
151                                             xns: Roo.data,
152                                             listeners : {
153                                                 beforeload : function (_self, o){
154                                                     o.params = o.params || {};
155                                                 
156                                                     if (!_this.relDate) {
157                                                         return false;
158                                                     }
159                                                     var dt = _this.relDate.getValue();    
160                                                     // set more here
161                                                     o.params['_group'] = 'apAging';
162                                                     o.params['_name'] = 'vendors';
163                                                     o.params['relDate:text']  = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
164                                                     o.params['useDocDate:text'] = false    
165                                                 }
166                                             },
167                                             remoteSort : true,
168                                             sortInfo : { direction : 'ASC', field: 'cust_name' },
169                                             proxy : {
170                                                 xtype: 'HttpProxy',
171                                                 xns: Roo.data,
172                                                 method : 'GET',
173                                                 url : baseURL + '/Roo/metasql.php'
174                                             },
175                                             reader : {
176                                                 xtype: 'JsonReader',
177                                                 xns: Roo.data,
178                                                 id : 'cust_id',
179                                                 root : 'data',
180                                                 totalProperty : 'total',
181                                                 fields : [{"name":"vend_id","type":"int"},"vend_name"]
182                                             }
183                                         }
184                                     },
185                                     {
186                                         xtype: 'TextItem',
187                                         xns: Roo.Toolbar,
188                                         text : "as Of:"
189                                     },
190                                     {
191                                         xtype: 'DateField',
192                                         xns: Roo.form,
193                                         listeners : {
194                                             render : function (_self)\r
195                                             {\r
196                                                 _this.relDate = _self;\r
197                                                _self.setValue(  new Date() );\r
198                                             },
199                                             select : function (combo, date)
200                                             {
201                                                 _this.grid.footer.onClick('first');
202                                             }
203                                         },
204                                         allowBlank : false,
205                                         format : 'Y-m-d',
206                                         width : 100
207                                     },
208                                     {
209                                         xtype: 'Fill',
210                                         xns: Roo.Toolbar
211                                     },
212                                     {
213                                         xtype: 'Button',
214                                         xns: Roo.Toolbar,
215                                         listeners : {
216                                             click : function ()
217                                             {
218                                             
219                                                  var sel  = _this.invgrid.getSelectionModel().getSelected();
220                                                 if (!sel) {
221                                                     Roo.MessageBox.alert("Error", "Select a invoice");
222                                                     return;
223                                                 }
224                                                 // check current status of shipment..
225                                                 
226                                                 var params =  {
227                                             //        cobmisc_id : sel.data.cobmisc_id,
228                                                     _void : 1
229                                                 };
230                                                 if (sel.data.cobmisc_id * 1) {
231                                                     params.cobmisc_id = sel.data.cobmisc_id * 1 ;
232                                                 }
233                                                 if (sel.data.cobmisc_invchead_id_invchead_id * 1) {    
234                                                     params.invchead_id  =  sel.data.cobmisc_invchead_id_invchead_id * 1;
235                                                 }
236                                                 
237                                                 Roo.MessageBox.confirm("Are you sure", "Are you sure you want to VOID that invoice?",
238                                                     function(r) {
239                                                         if (r != 'yes') {
240                                                             return;
241                                                         }
242                                                         new Pman.Request({
243                                                             mask : 'Sending',
244                                                             url : baseURL + '/Roo/cobmisc',
245                                                             method : 'POST',
246                                                             params :  params,
247                                                             success : function() {
248                                                                 _this.invgrid.ds.load({});
249                                                             }
250                                                         })
251                                                         
252                                                     }
253                                                 );
254                                                         
255                                                         
256                                                
257                                             }
258                                         },
259                                         cls : 'x-btn-text-icon',
260                                         text : "Void / Unpost",
261                                         icon : rootURL + '/Pman/templates/images/trash.gif'
262                                     }
263                                 ]
264                             },
265                             footer : {
266                                 xtype: 'PagingToolbar',
267                                 xns: Roo,
268                                 displayInfo : true,
269                                 displayMsg : "Displaying araging{0} - {1} of {2}",
270                                 emptyMsg : "Nothing found",
271                                 pageSize : 25
272                             },
273                             colModel : [
274                                 {
275                                     xtype: 'ColumnModel',
276                                     xns: Roo.grid,
277                                     dataIndex : 'apaging_docdate',
278                                     header : 'Date',
279                                     width : 100,
280                                     renderer : function(v) { 
281                                         var d = Date.parseDate(v, 'Y-m-d');
282                                     
283                                         return String.format('{0}', d.format('d/M/Y')); 
284                                     }
285                                 },
286                                 {
287                                     xtype: 'ColumnModel',
288                                     xns: Roo.grid,
289                                     dataIndex : 'apaging_vend_name',
290                                     header : 'Vendor',
291                                     width : 200,
292                                     renderer : function(v) { return String.format('{0}', v); }
293                                 },
294                                 {
295                                     xtype: 'ColumnModel',
296                                     xns: Roo.grid,
297                                     dataIndex : 'apaging_doctype',
298                                     header : 'Doc Type',
299                                     width : 120,
300                                     renderer : function(v) {
301                                         switch(v) {
302                                             case 'I':
303                                                 return "Invoice";
304                                             case 'C':
305                                                 return "Credit Memo";        
306                                             case 'D':
307                                                 return "Debit Memo";                    
308                                             case 'R':
309                                                 return "Cash Receipt";        
310                                             case 'V':
311                                                 return "Voucher";        
312                                             default:
313                                                  return String.format('{0}', v); 
314                                          }
315                                      }
316                                 },
317                                 {
318                                     xtype: 'ColumnModel',
319                                     xns: Roo.grid,
320                                     dataIndex : 'apaging_docnumber',
321                                     header : 'Docnumber',
322                                     width : 120,
323                                     renderer : function(v) {
324                                         
325                                                  return String.format('{0}', v); 
326                                          
327                                      }
328                                 },
329                                 {
330                                     xtype: 'ColumnModel',
331                                     xns: Roo.grid,
332                                     dataIndex : 'apaging_curr_symbol',
333                                     header : 'Currency',
334                                     width : 120,
335                                     renderer : function(v) {
336                                         
337                                                  return String.format('{0}', v); 
338                                          
339                                      }
340                                 },
341                                 {
342                                     xtype: 'ColumnModel',
343                                     xns: Roo.grid,
344                                     align : 'right',
345                                     dataIndex : 'apaging_apopen_amount',
346                                     header : 'Value',
347                                     width : 100,
348                                     renderer : function(v) { 
349                                     
350                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
351                                                 Roo.util.Format.usMoney(v)); 
352                                         }
353                                 },
354                                 {
355                                     xtype: 'ColumnModel',
356                                     xns: Roo.grid,
357                                     align : 'right',
358                                     dataIndex : 'apaging_cur_val',
359                                     header : '30 Days',
360                                     width : 100,
361                                     renderer : function(v) { 
362                                     
363                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
364                                                 Roo.util.Format.usMoney(v)); 
365                                         }
366                                 },
367                                 {
368                                     xtype: 'ColumnModel',
369                                     xns: Roo.grid,
370                                     align : 'right',
371                                     dataIndex : 'apaging_sixty_val',
372                                     header : '60 Days',
373                                     width : 100,
374                                     renderer : function(v) { 
375                                     
376                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
377                                                 Roo.util.Format.usMoney(v)); 
378                                         }
379                                 },
380                                 {
381                                     xtype: 'ColumnModel',
382                                     xns: Roo.grid,
383                                     align : 'right',
384                                     dataIndex : 'apaging_ninety_val',
385                                     header : '90 Days',
386                                     width : 100,
387                                     renderer : function(v) { 
388                                     
389                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
390                                                 Roo.util.Format.usMoney(v)); 
391                                         }
392                                 },
393                                 {
394                                     xtype: 'ColumnModel',
395                                     xns: Roo.grid,
396                                     align : 'right',
397                                     dataIndex : 'apaging_plus_val',
398                                     header : 'Over 90 days',
399                                     width : 150,
400                                     renderer : function(v) { 
401                                     
402                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
403                                                 Roo.util.Format.usMoney(v)); 
404                                         }
405                                 },
406                                 {
407                                     xtype: 'ColumnModel',
408                                     xns: Roo.grid,
409                                     align : 'right',
410                                     dataIndex : 'apaging_total_val',
411                                     header : 'Total',
412                                     width : 150,
413                                     renderer : function(v) { 
414                                     
415                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
416                                                 Roo.util.Format.usMoney(v)); 
417                                         }
418                                 },
419                                 {
420                                     xtype: 'ColumnModel',
421                                     xns: Roo.grid,
422                                     align : 'right',
423                                     dataIndex : 'apaging_base_total',
424                                     header : 'Total (BASE)',
425                                     width : 150,
426                                     renderer : function(v) { 
427                                     
428                                             return String.format(v*1 < 0 ? '<span style="color:red">{0}</span>' : '{0}', 
429                                                 Roo.util.Format.usMoney(v)); 
430                                         }
431                                 }
432                             ]
433                         }
434                     }
435                 ],
436                 center : {
437                     xtype: 'LayoutRegion',
438                     xns: Roo
439                 }
440             }
441         };
442     }
443 });