Pman.Tab.XtupleDashboard.bjs
[Pman.Xtuple] / Pman.Tab.XtupleDashboard.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.XtupleDashboard = new Roo.XComponent({
6     part     :  ["Xtuple","Dashboard"],
7     order    : '001-Pman.Tab.XtupleDashboard',
8     region   : 'center',
9     parent   : 'Pman',
10     name     : "Pman.Tab.XtupleDashboard",
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             listeners : {
21                 activate : function (_self)
22                 {
23                     
24                     try {
25                        // Pman.Xtuple.DashboardRender.load();    
26                     } catch (e) {
27                         Roo.log(e);
28                     }
29                     
30                 }
31             },
32             region : 'center',
33             title : "Management Dashboard",
34             layout : {
35                 xtype: 'BorderLayout',
36                 xns: Roo,
37                 items : [
38                     {
39                         xtype: 'NestedLayoutPanel',
40                         xns: Roo,
41                         listeners : {
42                             render : function (_self)
43                             {
44                                 _this.dashpanel = _self;
45                                 
46                                 
47                                 (function() { 
48                                         this.layout.getRegion('center').showPanel(0);
49                                 }).defer(100,this);
50                             }
51                         },
52                         region : 'center',
53                         layout : {
54                             xtype: 'BorderLayout',
55                             xns: Roo,
56                             items : [
57                                 {
58                                     xtype: 'ContentPanel',
59                                     xns: Roo,
60                                     listeners : {
61                                         render : function (_self)
62                                         {
63                                             _this.viewPanel = _self;
64                                             
65                                           
66                                             //_this.paper = Raphael(_self.el.dom);
67                                             
68                                         
69                                          
70                                             
71                                             
72                                             
73                                         },
74                                         resize : function (_self, width, height)
75                                         {
76                                             
77                                            Roo.log("RESIZE");
78                                            /* _this.svg.attr("width", width)
79                                                 .attr("height", height);
80                                                 */
81                                            //      _this.paper.setSize(width, 400);
82                                             try {
83                                         Pman.Clipping.DashboardRender.resize(width,height);
84                                             } catch (e) {
85                                                 Roo.log(e);
86                                             }
87                                         
88                                            
89                                             
90                                         },
91                                         activate : function (_self)
92                                         {
93                                             if (!_this.loadonce) {
94                                                 _this.loadonce = true;
95                                             
96                                                 (function () { Pman.Xtuple.DashboardRender.load(); }).defer(1000); 
97                                             }
98                                         }
99                                     },
100                                     autoScroll : true,
101                                     fitContainer : true,
102                                     fitToFrame : true,
103                                     region : 'center',
104                                     toolbar : {
105                                         xtype: 'Toolbar',
106                                         xns: Roo,
107                                         items : [
108                                             {
109                                                 xtype: 'TextItem',
110                                                 xns: Roo.Toolbar,
111                                                 text : "Show : "
112                                             },
113                                             {
114                                                 xtype: 'ComboBox',
115                                                 xns: Roo.form,
116                                                 listeners : {
117                                                     render : function (_self)
118                                                     {
119                                                         _this.countryCombo= _self;
120                                                     }
121                                                 },
122                                                 allowBlank : true,
123                                                 displayField : 'addr_country',
124                                                 editable : false,
125                                                 emptyText : " Country",
126                                                 forceSelection : true,
127                                                 listWidth : 400,
128                                                 loadingText : "Searching...",
129                                                 minChars : 2,
130                                                 name : 'addr_country',
131                                                 pageSize : 20,
132                                                 qtip : "Select addr",
133                                                 selectOnFocus : true,
134                                                 tpl : '<div class="x-grid-cell-text x-btn button"><b>{addr_country}</b> </div>',
135                                                 triggerAction : 'all',
136                                                 typeAhead : true,
137                                                 width : 100,
138                                                 store : {
139                                                     xtype: 'Store',
140                                                     xns: Roo.data,
141                                                     listeners : {
142                                                         beforeload : function (_self, o){
143                                                             o.params = o.params || {};
144                                                             // set more here
145                                                             o.params._distinct = 'addr_country';
146                                                             o.params._columns = 'addr_country';    
147                                                             o.params['!addr_country'] = '';
148                                                         }
149                                                     },
150                                                     remoteSort : true,
151                                                     sortInfo : { direction : 'ASC', field: 'addr_country' },
152                                                     proxy : {
153                                                         xtype: 'HttpProxy',
154                                                         xns: Roo.data,
155                                                         method : 'GET',
156                                                         url : baseURL + '/Roo/addr.php'
157                                                     },
158                                                     reader : {
159                                                         xtype: 'JsonReader',
160                                                         xns: Roo.data,
161                                                         id : 'id',
162                                                         root : 'data',
163                                                         totalProperty : 'total',
164                                                         fields : [{"name":"id","type":"int"},{"name":"addr_line1","type":"string"}]
165                                                     }
166                                                 }
167                                             },
168                                             {
169                                                 xtype: 'ComboBox',
170                                                 xns: Roo.form,
171                                                 listeners : {
172                                                     render : function (_self)
173                                                     {
174                                                       _this.viewType = _self;
175                                                       
176                                                     },
177                                                     select : function (combo, record, index)
178                                                     {
179                                                         Roo.log('select');
180                                                        // Pman.Clipping.DashboardRender.load();
181                                                         var n = new Date();
182                                                         var ys = n.format('Y' )+ '-05-01';
183                                                         n = Date.parseDate(ys, 'Y-n-d');
184                                                         
185                                                         var ftype = record ? record.data.ftype : this.getValue();
186                                                         
187                                                         switch(ftype) {
188                                                             case 'Y':
189                                                                 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
190                                                                _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
191                                                                _this.mfrom.show();
192                                                                _this.mto.hide(); 
193                                                                _this.daypick.hide();
194                                                                
195                                                                _this.dateRange = function() {
196                                                                     return {
197                                                                        date_from : _this.mfrom.getValue(),
198                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
199                                                              
200                                                                     };
201                                                                
202                                                                };
203                                                                
204                                                                
205                                                                 break;
206                                                             case 'H':        
207                                                             // ?? latest half
208                                                                 var m = (new Date()).format('n')*1  > 6 ? 6 : 0;
209                                                                 Roo.log(m);
210                                                                 Roo.log( n.add(Date.MONTH,m));
211                                                                _this.mfrom.setValue(n.add(Date.MONTH,m));           
212                                                                _this.mfrom.show();
213                                                                _this.mto.hide(); 
214                                                                _this.daypick.hide();
215                                                                _this.dateRange = function() {
216                                                                     return {
217                                                                         date_from : _this.mfrom.getValue(),
218                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
219                                                                     };
220                                                                };
221                                                               break;
222                                                             case 'Q':                
223                                                             
224                                                                 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
225                                                     
226                                                                _this.mfrom.setValue(n.add(Date.MONTH, m));           
227                                                                _this.mfrom.show();
228                                                                _this.mto.hide(); 
229                                                                _this.daypick.hide();
230                                                                _this.dateRange = function() {
231                                                                     return {
232                                                                         date_from : _this.mfrom.getValue(),
233                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
234                                                                     };
235                                                                 };   
236                                                                 break;
237                                                     
238                                                             case 'M':        
239                                                                 var m = (new Date()).format('n') *1  - 1 ;
240                                                                _this.mfrom.setValue(n.add(Date.MONTH, m ));
241                                                                _this.mfrom.show();
242                                                                _this.mto.hide(); 
243                                                                _this.daypick.hide();
244                                                                 _this.dateRange = function() {
245                                                                     return {
246                                                                         date_from : _this.mfrom.getValue(),
247                                                                         date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
248                                                                     };
249                                                                 };   
250                                                                 break;        
251                                                             
252                                                     
253                                                             
254                                                             case 'R':
255                                                                 // this month..
256                                                                 var m = (new Date()).format('n') * 1;            
257                                                                _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); 
258                                                                _this.mto.setValue(n.add(Date.MONTH,m )); 
259                                                             
260                                                             
261                                                             
262                                                                  _this.mfrom.show();
263                                                                 _this.mto.show(); 
264                                                                 _this.daypick.hide();
265                                                                  _this.dateRange = function() {
266                                                                     return {
267                                                                         date_from : _this.mfrom.getValue(),
268                                                                         date_to : _this.mto.getValue()
269                                                                     };
270                                                                 };   
271                                                                 
272                                                                 
273                                                                 break;
274                                                             /*
275                                                              case 'W': // today
276                                                                 var d = (new Date()).format('w') * -1;
277                                                                 _this.daypick.setValue( (new Date()).add(Date.DAY, d )); 
278                                                                  _this.mfrom.hide();
279                                                                 _this.mto.hide(); 
280                                                                 _this.daypick.show();
281                                                                 break;
282                                                             
283                                                             
284                                                             case 'D': // today
285                                                                 _this.daypick.setValue(new Date()); 
286                                                                  _this.mfrom.hide();
287                                                                 _this.mto.hide(); 
288                                                                 _this.daypick.show();
289                                                                 break;
290                                                                 */
291                                                             default:
292                                                                 alerT("oops invalid ftype?");
293                                                                 return;
294                                                         }
295                                                         
296                                                         
297                                                         
298                                                     }
299                                                 },
300                                                 allowBlank : false,
301                                                 displayField : 'fname',
302                                                 editable : false,
303                                                 fieldLabel : 'Status',
304                                                 hiddenName : 'cm_status',
305                                                 listWidth : 200,
306                                                 mode : 'local',
307                                                 name : 'cm_status_name',
308                                                 triggerAction : 'all',
309                                                 value : "R",
310                                                 valueField : 'ftype',
311                                                 width : 150,
312                                                 dateRange : function() {
313                                                 
314                                                   
315                                                     var ftype =  this.getValue();
316                                                     
317                                                     switch(ftype) {
318                                                         case 'Y':
319                                                        
320                                                             
321                                                             return {
322                                                                date_from : _this.mfrom.getValue(),
323                                                                 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
324                                                      
325                                                             };
326                                                        ;
327                                                            
328                                                            
329                                                             break;
330                                                         case 'H':        
331                                                         // 
332                                                                 return {
333                                                                     date_from : _this.mfrom.getValue(),
334                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
335                                                                 };
336                                                             
337                                                           break;
338                                                         case 'Q':                
339                                                         
340                                                             var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
341                                                 
342                                                            _this.mfrom.setValue(n.add(Date.MONTH, m));           
343                                                            _this.mfrom.show();
344                                                            _this.mto.hide(); 
345                                                            _this.daypick.hide();
346                                                            _this.dateRange = function() {
347                                                                 return {
348                                                                     date_from : _this.mfrom.getValue(),
349                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
350                                                                 };
351                                                             };   
352                                                             break;
353                                                 
354                                                         case 'M':        
355                                                             var m = (new Date()).format('n') *1  - 1 ;
356                                                            _this.mfrom.setValue(n.add(Date.MONTH, m ));
357                                                            _this.mfrom.show();
358                                                            _this.mto.hide(); 
359                                                            _this.daypick.hide();
360                                                             _this.dateRange = function() {
361                                                                 return {
362                                                                     date_from : _this.mfrom.getValue(),
363                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
364                                                                 };
365                                                             };   
366                                                             break;        
367                                                         
368                                                 
369                                                         
370                                                         case 'R':
371                                                             // this month..
372                                                             var m = (new Date()).format('n') * 1;            
373                                                            _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); 
374                                                            _this.mto.setValue(n.add(Date.MONTH,m )); 
375                                                         
376                                                         
377                                                         
378                                                              _this.mfrom.show();
379                                                             _this.mto.show(); 
380                                                             _this.daypick.hide();
381                                                              _this.dateRange = function() {
382                                                                 return {
383                                                                     date_from : _this.mfrom.getValue(),
384                                                                     date_to : _this.mto.getValue()
385                                                                 };
386                                                             };   
387                                                             
388                                                             
389                                                             break;
390                                                         /*
391                                                          case 'W': // today
392                                                             var d = (new Date()).format('w') * -1;
393                                                             _this.daypick.setValue( (new Date()).add(Date.DAY, d )); 
394                                                              _this.mfrom.hide();
395                                                             _this.mto.hide(); 
396                                                             _this.daypick.show();
397                                                             break;
398                                                         
399                                                         
400                                                         case 'D': // today
401                                                             _this.daypick.setValue(new Date()); 
402                                                              _this.mfrom.hide();
403                                                             _this.mto.hide(); 
404                                                             _this.daypick.show();
405                                                             break;
406                                                             */
407                                                         default:
408                                                             alerT("oops invalid ftype?");
409                                                             return;
410                                                     }
411                                                 
412                                                     return {
413                                                                    date_from : _this.mfrom.getValue(),
414                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
415                                                          
416                                                                 };
417                                                 },
418                                                 store : {
419                                                     xtype: 'SimpleStore',
420                                                     xns: Roo.data,
421                                                     data : [ 
422                                                         [ 'Y', "Show Year From"],
423                                                         [ 'H' , "6 Months From"],
424                                                         [ 'Q', "3 Months From"] ,
425                                                         [ 'M', "Single Month"],
426                                                        // [ 'W', "Single Week Starting"],
427                                                         [ 'R', "Between these Dates"] //,
428                                                       //  [ 'D', "Single Day"]
429                                                         
430                                                     ],
431                                                     fields : [  'ftype', 'fname']
432                                                 }
433                                             },
434                                             {
435                                                 xtype: 'DateField',
436                                                 xns: Roo.form,
437                                                 listeners : {
438                                                     render : function (_self)
439                                                     {
440                                                         _this.mfrom=  _self;
441                                                     }
442                                                 },
443                                                 format : 'd/M/Y',
444                                                 useIso : true,
445                                                 value : (function() {
446                                                     var n = new Date();
447                                                     // previous apr.
448                                                     var y = n.format('Y');
449                                                     if (n.format('m') < 5) { 
450                                                         y--;
451                                                     }
452                                                     
453                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
454                                                 })()
455                                             },
456                                             {
457                                                 xtype: 'DateField',
458                                                 xns: Roo.form,
459                                                 listeners : {
460                                                     render : function (_self)
461                                                     {
462                                                         _this.mto=  _self;
463                                                         //this.hide();
464                                                     }
465                                                 },
466                                                 format : 'd/M/Y',
467                                                 useIso : true,
468                                                 value : (function() {
469                                                     var n = (new Date()).add(Date.YEAR, 1);
470                                                     
471                                                     var n = new Date();
472                                                     // previous apr.
473                                                     var y = n.format('Y');
474                                                     if (n.format('m') >= 5) { 
475                                                         y++;
476                                                     }
477                                                     
478                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
479                                                     
480                                                     
481                                                 
482                                                 })()
483                                             },
484                                             {
485                                                 xtype: 'DateField',
486                                                 xns: Roo.form,
487                                                 listeners : {
488                                                     render : function (_self)
489                                                     {
490                                                         _this.daypick = _self;
491                                                         this.hide();
492                                                     }
493                                                 },
494                                                 format : 'd/M/Y',
495                                                 useIso : true,
496                                                 value : (function() {
497                                                 //    var n = new Date();
498                                                     return new Date();
499                                                 })()
500                                             },
501                                             {
502                                                 xtype: 'Button',
503                                                 xns: Roo.Toolbar,
504                                                 listeners : {
505                                                     click : function (_self, e)
506                                                     {
507                                                         Pman.Xtuple.DashboardRender.load();
508                                                     }
509                                                 },
510                                                 text : "Run Report"
511                                             },
512                                             {
513                                                 xtype: 'Button',
514                                                 xns: Roo.Toolbar,
515                                                 text : "Other Reports",
516                                                 menu : {
517                                                     xtype: 'Menu',
518                                                     xns: Roo.menu,
519                                                     items : [
520                                                         {
521                                                             xtype: 'Item',
522                                                             xns: Roo.menu,
523                                                             listeners : {
524                                                                 click : function (_self, e)
525                                                                 {
526                                                                     new Pman.Download({
527                                                                         url :baseURL + '/Xtuple/Reports/SalesByCustomer',
528                                                                         params : _this.viewType.dateRange()
529                                                                          
530                                                                     
531                                                                     });
532                                                                 }
533                                                             },
534                                                             text : "Sales By Customer"
535                                                         },
536                                                         {
537                                                             xtype: 'Item',
538                                                             xns: Roo.menu,
539                                                             listeners : {
540                                                                 click : function (_self, e)
541                                                                 {
542                                                                     new Pman.Download({
543                                                                         url :baseURL + '/Xtuple/Reports/SalesByCountry',
544                                                                         params :  _this.viewType.dateRange()
545                                                                     
546                                                                     });
547                                                                 }
548                                                             },
549                                                             text : "Sales By Country"
550                                                         },
551                                                         {
552                                                             xtype: 'Item',
553                                                             xns: Roo.menu,
554                                                             listeners : {
555                                                                 click : function (_self, e)
556                                                                 {
557                                                                     new Pman.Download({
558                                                                         url :baseURL + '/Xtuple/Reports/SalesByProduct',
559                                                                         params :  _this.viewType.dateRange()
560                                                                     
561                                                                     });
562                                                                 }
563                                                             },
564                                                             text : "Sales By Product"
565                                                         },
566                                                         {
567                                                             xtype: 'Separator',
568                                                             xns: Roo.menu
569                                                         },
570                                                         {
571                                                             xtype: 'Item',
572                                                             xns: Roo.menu,
573                                                             listeners : {
574                                                                 click : function (_self, e)
575                                                                 {
576                                                                     new Pman.Download({
577                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
578                                                                         params :  _this.viewType.dateRange()
579                                                                     
580                                                                     });
581                                                                 }
582                                                             },
583                                                             text : "Purchases By Vendor"
584                                                         },
585                                                         {
586                                                             xtype: 'Item',
587                                                             xns: Roo.menu,
588                                                             listeners : {
589                                                                 click : function (_self, e)
590                                                                 {
591                                                                     new Pman.Download({
592                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
593                                                                         params :  _this.viewType.dateRange()
594                                                                     
595                                                                     });
596                                                                 }
597                                                             },
598                                                             text : "Purchases By Product"
599                                                         },
600                                                         {
601                                                             xtype: 'Separator',
602                                                             xns: Roo.menu
603                                                         },
604                                                         {
605                                                             xtype: 'Item',
606                                                             xns: Roo.menu,
607                                                             listeners : {
608                                                                 click : function (_self, e)
609                                                                 {
610                                                                     new Pman.Download({
611                                                                         url :baseURL + '/Xtuple/Reports/StockAtLocation',
612                                                                          params :  _this.viewType.dateRange()
613                                                                     
614                                                                     });
615                                                                     Roo.MessageBox.alert("Downloading", 
616                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
617                                                                     
618                                                                 }
619                                                             },
620                                                             text : "Historical Stock Levels (EO HKFY)"
621                                                         },
622                                                         {
623                                                             xtype: 'Separator',
624                                                             xns: Roo.menu
625                                                         },
626                                                         {
627                                                             xtype: 'Item',
628                                                             xns: Roo.menu,
629                                                             listeners : {
630                                                                 click : function (_self, e)
631                                                                 {
632                                                                     new Pman.Download({
633                                                                         url :baseURL + '/Xtuple/Reports/SGTax',
634                                                                          params :  _this.viewType.dateRange()
635                                                                     
636                                                                     });
637                                                                     Roo.MessageBox.alert("Downloading", 
638                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
639                                                                     
640                                                                 }
641                                                             },
642                                                             text : "SG Tax report"
643                                                         }
644                                                     ]
645                                                 }
646                                             },
647                                             {
648                                                 xtype: 'Spacer',
649                                                 xns: Roo.Toolbar
650                                             },
651                                             {
652                                                 xtype: 'Fill',
653                                                 xns: Roo.Toolbar
654                                             },
655                                             {
656                                                 xtype: 'TextItem',
657                                                 xns: Roo.Toolbar,
658                                                 text : "Theme : "
659                                             },
660                                             {
661                                                 xtype: 'ComboBox',
662                                                 xns: Roo.form,
663                                                 listeners : {
664                                                     select : function (combo, record, index)
665                                                     {
666                                                         Pman.Xtuple.DashboardRender.load();
667                                                     },
668                                                     render : function (_self)
669                                                     {
670                                                         _this.themeCombo = this;
671                                                     }
672                                                 },
673                                                 allowBlank : false,
674                                                 displayField : 'name',
675                                                 editable : false,
676                                                 hiddenName : 'colortheme',
677                                                 listWidth : 300,
678                                                 name : 'colorTheme_title',
679                                                 qtip : "Select a Color Theme",
680                                                 selectOnFocus : true,
681                                                 triggerAction : 'all',
682                                                 typeAhead : false,
683                                                 valueField : 'themeData',
684                                                 value : (function() {
685                                                      return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : ''; 
686                                                 })(),
687                                                 store : {
688                                                     xtype: 'SimpleStore',
689                                                     xns: Roo.data,
690                                                     data : (function() {
691                                                         return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
692                                                         
693                                                     })(),
694                                                     fields : ['name','themeData']
695                                                 }
696                                             }
697                                         ]
698                                     }
699                                 },
700                                 {
701                                     xtype: 'ContentPanel',
702                                     xns: Roo,
703                                     listeners : {
704                                         render : function (_self)
705                                         {
706                                             _this.reportpanel = _self;
707                                         }
708                                     },
709                                     autoScroll : true,
710                                     fitToFrame : true,
711                                     region : 'center',
712                                     showReport : function(node, isxls) {
713                                         if (node) {
714                                             _this.selectedNode = node;
715                                         }
716                                         var rc = _this.reportCompany.getValue();
717                                         var params =  {
718                                             flhead_name : _this.selectedNode.attributes.text,
719                                             ts : Math.random(),
720                                             period : _this.reportDateFrom.getValue(),
721                                             interval:   _this.reportInterval.getValue(),
722                                             company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
723                                             singleCountry :  rc == 'consolidated' ? 0 : 1
724                                         };
725                                         
726                                         if (isxls) {
727                                             params._xls = 1;
728                                             new Pman.Download({
729                                                 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
730                                                 method: 'GET',
731                                                 timeout: 120000,
732                                                 params :  params
733                                             });
734                                             Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
735                                             return;
736                                         }
737                                         var el = this.region.el;
738                                     
739                                         var done = false;
740                                         var v= 0;
741                                         var f = function(){
742                                                 if (done) {
743                                                     return;
744                                                 }
745                                                 Roo.MessageBox.updateProgress(v/50, 'Loading..  Around ' + (50-v) + ' seconds to go');
746                                                 v++;
747                                                 f.defer(1000)
748                                            };
749                                          Roo.MessageBox.show({
750                                                title: 'Please wait...',
751                                                msg: 'Loading...',
752                                                width:240,
753                                                progress:true,
754                                                closable:true
755                                            });
756                                         
757                                     
758                                         
759                                         ///el.mask("Loading - Should take around 45 seconds <br/> if it takes longer than 2 minutes, then something is broken<br/> If nothing displays try doing shift-reload or ctrl-reload");
760                                         this.load({
761                                             url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
762                                             method: 'GET',
763                                             params :  params,
764                                             timeout: 120,
765                                             callback: function() {
766                                                 done = true;
767                                                 Roo.MessageBox.hide();
768                                             }
769                                             
770                                         });
771                                         
772                                         f();
773                                         
774                                     },
775                                     toolbar : {
776                                         xtype: 'Toolbar',
777                                         xns: Roo,
778                                         items : [
779                                             {
780                                                 xtype: 'TextItem',
781                                                 xns: Roo.Toolbar,
782                                                 text : "Report Range :"
783                                             },
784                                             {
785                                                 xtype: 'DateField',
786                                                 xns: Roo.form,
787                                                 listeners : {
788                                                     render : function (_self)
789                                                     {
790                                                         _this.reportDateFrom = _self;
791                                                     },
792                                                     select : function (combo, date)
793                                                     {
794                                                       //_this.grid.footer.onClick('first');
795                                                     }
796                                                 },
797                                                 format : 'd/M/Y',
798                                                 useIso : 1,
799                                                 width : 120,
800                                                 value : (function() { 
801                                                     return Date.parseDate( 
802                                                         '' + (new Date()).format('Y-m') + '-01'
803                                                         , 'Y-m-d'   ); })()
804                                             },
805                                             {
806                                                 xtype: 'ComboBox',
807                                                 xns: Roo.form,
808                                                 listeners : {
809                                                     render : function (_self)
810                                                     {
811                                                       _this.reportInterval = _self;
812                                                     },
813                                                     select : function (combo, record, index)
814                                                     {
815                                                        // Roo.log('select');
816                                                        // _this.grid.footer.onClick('first');
817                                                     }
818                                                 },
819                                                 allowBlank : false,
820                                                 displayField : 'fname',
821                                                 editable : false,
822                                                 fieldLabel : 'Status',
823                                                 hiddenName : 'cm_status',
824                                                 listWidth : 400,
825                                                 mode : 'local',
826                                                 name : 'cm_status_name',
827                                                 triggerAction : 'all',
828                                                 value : "Y",
829                                                 valueField : 'ftype',
830                                                 width : 200,
831                                                 store : {
832                                                     xtype: 'SimpleStore',
833                                                     xns: Roo.data,
834                                                     data : [ 
835                                                         [ 'Y', "Since Start of Financial Year"],
836                                                         [ 'YY' , "Since Start of Financial Year with same range Previous Year"],            
837                                                         [ 'M' , "Single Month"],
838                                                         [ 'MM' , "Single Month with Previous Month"],    
839                                                         [ 'MY' , "Single Month with Previous Year"],
840                                                         [ 'MF' , "This Months of Financia Year"],
841                                                         [ 'ML' , "Last 12 Months"]
842                                                     ],
843                                                     fields : [  'ftype', 'fname']
844                                                 }
845                                             },
846                                             {
847                                                 xtype: 'ComboBox',
848                                                 xns: Roo.form,
849                                                 listeners : {
850                                                     render : function (_self)
851                                                     {
852                                                       _this.reportCompany = _self;
853                                                     }
854                                                 },
855                                                 allowBlank : false,
856                                                 displayField : 'fname',
857                                                 editable : false,
858                                                 fieldLabel : 'Status',
859                                                 hiddenName : 'report_company',
860                                                 listWidth : 300,
861                                                 mode : 'local',
862                                                 name : 'report_company_name',
863                                                 triggerAction : 'all',
864                                                 value : "hk",
865                                                 valueField : 'ftype',
866                                                 width : 100,
867                                                 hidden : (function() {
868                                                 
869                                                     return baseURL.match(/hk\.php$/) ? false : true;
870                                                 })(),
871                                                 store : {
872                                                     xtype: 'SimpleStore',
873                                                     xns: Roo.data,
874                                                     data : [ 
875                                                         [ 'hk', "Hong Kong"],
876                                                         [ 'sg' , "Singapore"],            
877                                                         [ 'my' , "Malaysia"],
878                                                         [ 'cn' , "China"],    
879                                                         [ 'au' , "Australia"],
880                                                         [ 'consolidated' , "Consolidated"]
881                                                     ],
882                                                     fields : [  'ftype', 'fname']
883                                                 }
884                                             },
885                                             {
886                                                 xtype: 'Button',
887                                                 xns: Roo.Toolbar,
888                                                 listeners : {
889                                                     click : function (_self, e)
890                                                     {
891                                                           _this.reportpanel.showReport(); 
892                                                     }
893                                                 },
894                                                 text : "Refresh Report"
895                                             },
896                                             {
897                                                 xtype: 'Fill',
898                                                 xns: Roo.Toolbar
899                                             },
900                                             {
901                                                 xtype: 'Button',
902                                                 xns: Roo.Toolbar,
903                                                 listeners : {
904                                                     click : function (_self, e)
905                                                     {
906                                                           _this.reportpanel.showReport(false,'xls'); 
907                                                     }
908                                                 },
909                                                 text : "Download XLS"
910                                             }
911                                         ]
912                                     }
913                                 }
914                             ],
915                             center : {
916                                 xtype: 'LayoutRegion',
917                                 xns: Roo,
918                                 hideTabs : true
919                             }
920                         }
921                     },
922                     {
923                         xtype: 'TreePanel',
924                         xns: Roo,
925                         listeners : {
926                             render : function (_self)
927                             {
928                                 _this.tree = _self;
929                             }
930                         },
931                         fitToFrame : true,
932                         region : 'west',
933                         toolbar : {
934                             xtype: 'Toolbar',
935                             xns: Roo
936                         },
937                         tree : {
938                             xtype: 'TreePanel',
939                             xns: Roo.tree,
940                             rootVisible : false,
941                             root : {
942                                 xtype: 'AsyncTreeNode',
943                                 xns: Roo.tree
944                             },
945                             selModel : {
946                                 xtype: 'DefaultSelectionModel',
947                                 xns: Roo.tree,
948                                 listeners : {
949                                     selectionchange : function (_self, node)
950                                     {
951                                         var at = node.attributes.id;
952                                         if (at > 999) {
953                                              _this.dashpanel.layout.getRegion('center').showPanel(0);
954                                               Pman.Xtuple.DashboardRender.load();
955                                               return;
956                                              
957                                         }
958                                         _this.dashpanel.layout.getRegion('center').showPanel(1);
959                                         _this.reportpanel.showReport(node); 
960                                        
961                                         
962                                     }
963                                 }
964                             },
965                             loader : {
966                                 xtype: 'TreeLoader',
967                                 xns: Roo.tree,
968                                 requestMethod : 'GET',
969                                 baseParams : { _tree : 1, _dragon_only : 1 },
970                                 dataUrl : baseURL + '/Roo/Flhead'
971                             },
972                             root : {
973                                 xtype: 'AsyncTreeNode',
974                                 xns: Roo.tree
975                             }
976                         }
977                     }
978                 ],
979                 west : {
980                     xtype: 'LayoutRegion',
981                     xns: Roo,
982                     hidden : false,
983                     split : true,
984                     width : 200
985                 },
986                 center : {
987                     xtype: 'LayoutRegion',
988                     xns: Roo
989                 }
990             }
991         };
992     }
993 });