Fix #7123 - getting abra ready to test
[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                                                           
196                                                                
197                                                                
198                                                                 break;
199                                                             case 'H':        
200                                                             // ?? latest half
201                                                                 var m = (new Date()).format('n')*1  > 6 ? 6 : 0;
202                                                                 Roo.log(m);
203                                                                 Roo.log( n.add(Date.MONTH,m));
204                                                                _this.mfrom.setValue(n.add(Date.MONTH,m));           
205                                                                _this.mfrom.show();
206                                                                _this.mto.hide(); 
207                                                                _this.daypick.hide();
208                                                              
209                                                               break;
210                                                             case 'Q':                
211                                                             
212                                                                 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
213                                                     
214                                                                _this.mfrom.setValue(n.add(Date.MONTH, m));           
215                                                                _this.mfrom.show();
216                                                                _this.mto.hide(); 
217                                                                _this.daypick.hide();
218                                                                   
219                                                                 break;
220                                                     
221                                                             case 'M':        
222                                                                 var m = (new Date()).format('n') *1  - 1 ;
223                                                                _this.mfrom.setValue(n.add(Date.MONTH, m ));
224                                                                _this.mfrom.show();
225                                                                _this.mto.hide(); 
226                                                                _this.daypick.hide();
227                                                                  
228                                                                 break;        
229                                                             
230                                                     
231                                                             
232                                                             case 'R':
233                                                                 // this month..
234                                                                 var m = (new Date()).format('n') * 1;            
235                                                                _this.mfrom.setValue(n.add(Date.MONTH, m-1 )); 
236                                                                _this.mto.setValue(n.add(Date.MONTH,m )); 
237                                                             
238                                                             
239                                                             
240                                                                  _this.mfrom.show();
241                                                                 _this.mto.show(); 
242                                                                 _this.daypick.hide();
243                                                                  
244                                                                 
245                                                                 
246                                                                 break;
247                                                             /*
248                                                              case 'W': // today
249                                                                 var d = (new Date()).format('w') * -1;
250                                                                 _this.daypick.setValue( (new Date()).add(Date.DAY, d )); 
251                                                                  _this.mfrom.hide();
252                                                                 _this.mto.hide(); 
253                                                                 _this.daypick.show();
254                                                                 break;
255                                                             
256                                                             
257                                                             case 'D': // today
258                                                                 _this.daypick.setValue(new Date()); 
259                                                                  _this.mfrom.hide();
260                                                                 _this.mto.hide(); 
261                                                                 _this.daypick.show();
262                                                                 break;
263                                                                 */
264                                                             default:
265                                                                 alerT("oops invalid ftype?");
266                                                                 return;
267                                                         }
268                                                         
269                                                         
270                                                         
271                                                     }
272                                                 },
273                                                 allowBlank : false,
274                                                 displayField : 'fname',
275                                                 editable : false,
276                                                 fieldLabel : 'Status',
277                                                 hiddenName : 'cm_status',
278                                                 listWidth : 200,
279                                                 mode : 'local',
280                                                 name : 'cm_status_name',
281                                                 triggerAction : 'all',
282                                                 value : "R",
283                                                 valueField : 'ftype',
284                                                 width : 150,
285                                                 dateRange : function() {
286                                                 
287                                                   
288                                                     var ftype =  this.getValue();
289                                                     
290                                                     switch(ftype) {
291                                                         case 'Y':
292                                                        
293                                                             
294                                                             return {
295                                                                date_from : _this.mfrom.getValue(),
296                                                                 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
297                                                      
298                                                             };
299                                                        ;
300                                                            
301                                                            
302                                                             break;
303                                                         case 'H':        
304                                                         // 
305                                                                 return {
306                                                                     date_from : _this.mfrom.getValue(),
307                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
308                                                                 };
309                                                             
310                                                           break;
311                                                         case 'Q':                
312                                                         
313                                                             
314                                                  
315                                                                 return {
316                                                                     date_from : _this.mfrom.getValue(),
317                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
318                                                                 };
319                                                            
320                                                             break;
321                                                 
322                                                         case 'M':        
323                                                            
324                                                                 return {
325                                                                     date_from : _this.mfrom.getValue(),
326                                                                     date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
327                                                                 };
328                                                               
329                                                                
330                                                         
331                                                 
332                                                         
333                                                         case 'R':
334                                                            
335                                                                 return {
336                                                                     date_from : _this.mfrom.getValue(),
337                                                                     date_to : _this.mto.getValue()
338                                                                 };
339                                                            
340                                                             
341                                                             break;
342                                                        
343                                                         default:
344                                                             Roo.MessageBox.alert("select range");
345                                                             return;
346                                                     }
347                                                  
348                                                 },
349                                                 store : {
350                                                     xtype: 'SimpleStore',
351                                                     xns: Roo.data,
352                                                     data : [ 
353                                                         [ 'Y', "Show Year From"],
354                                                         [ 'H' , "6 Months From"],
355                                                         [ 'Q', "3 Months From"] ,
356                                                         [ 'M', "Single Month"],
357                                                        // [ 'W', "Single Week Starting"],
358                                                         [ 'R', "Between these Dates"] //,
359                                                       //  [ 'D', "Single Day"]
360                                                         
361                                                     ],
362                                                     fields : [  'ftype', 'fname']
363                                                 }
364                                             },
365                                             {
366                                                 xtype: 'DateField',
367                                                 xns: Roo.form,
368                                                 listeners : {
369                                                     render : function (_self)
370                                                     {
371                                                         _this.mfrom=  _self;
372                                                     }
373                                                 },
374                                                 format : 'd/M/Y',
375                                                 useIso : true,
376                                                 value : (function() {
377                                                     var n = new Date();
378                                                     // previous apr.
379                                                     var y = n.format('Y');
380                                                     if (n.format('m') < 5) { 
381                                                         y--;
382                                                     }
383                                                     
384                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
385                                                 })()
386                                             },
387                                             {
388                                                 xtype: 'DateField',
389                                                 xns: Roo.form,
390                                                 listeners : {
391                                                     render : function (_self)
392                                                     {
393                                                         _this.mto=  _self;
394                                                         //this.hide();
395                                                     }
396                                                 },
397                                                 format : 'd/M/Y',
398                                                 useIso : true,
399                                                 value : (function() {
400                                                     var n = (new Date()).add(Date.YEAR, 1);
401                                                     
402                                                     var n = new Date();
403                                                     // previous apr.
404                                                     var y = n.format('Y');
405                                                     if (n.format('m') >= 5) { 
406                                                         y++;
407                                                     }
408                                                     
409                                                     return Date.parseDate(y  + '-05-01', 'Y-m-d');
410                                                     
411                                                     
412                                                 
413                                                 })()
414                                             },
415                                             {
416                                                 xtype: 'DateField',
417                                                 xns: Roo.form,
418                                                 listeners : {
419                                                     render : function (_self)
420                                                     {
421                                                         _this.daypick = _self;
422                                                         this.hide();
423                                                     }
424                                                 },
425                                                 format : 'd/M/Y',
426                                                 useIso : true,
427                                                 value : (function() {
428                                                 //    var n = new Date();
429                                                     return new Date();
430                                                 })()
431                                             },
432                                             {
433                                                 xtype: 'Button',
434                                                 xns: Roo.Toolbar,
435                                                 listeners : {
436                                                     click : function (_self, e)
437                                                     {
438                                                         Pman.Xtuple.DashboardRender.load();
439                                                     }
440                                                 },
441                                                 text : "Run Report"
442                                             },
443                                             {
444                                                 xtype: 'Button',
445                                                 xns: Roo.Toolbar,
446                                                 text : "Other Reports",
447                                                 menu : {
448                                                     xtype: 'Menu',
449                                                     xns: Roo.menu,
450                                                     items : [
451                                                         {
452                                                             xtype: 'Item',
453                                                             xns: Roo.menu,
454                                                             listeners : {
455                                                                 click : function (_self, e)
456                                                                 {
457                                                                     new Pman.Download({
458                                                                         url :baseURL + '/Xtuple/Reports/SalesByCustomer',
459                                                                         params : _this.viewType.dateRange()
460                                                                          
461                                                                     
462                                                                     });
463                                                                 }
464                                                             },
465                                                             text : "Sales By Customer"
466                                                         },
467                                                         {
468                                                             xtype: 'Item',
469                                                             xns: Roo.menu,
470                                                             listeners : {
471                                                                 click : function (_self, e)
472                                                                 {
473                                                                     new Pman.Download({
474                                                                         url :baseURL + '/Xtuple/Reports/SalesByCountry',
475                                                                         params :  _this.viewType.dateRange()
476                                                                     
477                                                                     });
478                                                                 }
479                                                             },
480                                                             text : "Sales By Country"
481                                                         },
482                                                         {
483                                                             xtype: 'Item',
484                                                             xns: Roo.menu,
485                                                             listeners : {
486                                                                 click : function (_self, e)
487                                                                 {
488                                                                     new Pman.Download({
489                                                                         url :baseURL + '/Xtuple/Reports/SalesByProduct',
490                                                                         params :  _this.viewType.dateRange()
491                                                                     
492                                                                     });
493                                                                 }
494                                                             },
495                                                             text : "Sales By Product"
496                                                         },
497                                                         {
498                                                             xtype: 'Separator',
499                                                             xns: Roo.menu
500                                                         },
501                                                         {
502                                                             xtype: 'Item',
503                                                             xns: Roo.menu,
504                                                             listeners : {
505                                                                 click : function (_self, e)
506                                                                 {
507                                                                     new Pman.Download({
508                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
509                                                                         params :  _this.viewType.dateRange()
510                                                                     
511                                                                     });
512                                                                 }
513                                                             },
514                                                             text : "Purchases By Vendor"
515                                                         },
516                                                         {
517                                                             xtype: 'Item',
518                                                             xns: Roo.menu,
519                                                             listeners : {
520                                                                 click : function (_self, e)
521                                                                 {
522                                                                     new Pman.Download({
523                                                                         url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
524                                                                         params :  _this.viewType.dateRange()
525                                                                     
526                                                                     });
527                                                                 }
528                                                             },
529                                                             text : "Purchases By Product"
530                                                         },
531                                                         {
532                                                             xtype: 'Separator',
533                                                             xns: Roo.menu
534                                                         },
535                                                         {
536                                                             xtype: 'Item',
537                                                             xns: Roo.menu,
538                                                             listeners : {
539                                                                 click : function (_self, e)
540                                                                 {
541                                                                     new Pman.Download({
542                                                                         url :baseURL + '/Xtuple/Reports/StockAtLocation',
543                                                                          params :  _this.viewType.dateRange()
544                                                                     
545                                                                     });
546                                                                     Roo.MessageBox.alert("Downloading", 
547                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
548                                                                     
549                                                                 }
550                                                             },
551                                                             text : "Historical Stock Levels (EO HKFY)"
552                                                         },
553                                                         {
554                                                             xtype: 'Separator',
555                                                             xns: Roo.menu
556                                                         },
557                                                         {
558                                                             xtype: 'Item',
559                                                             xns: Roo.menu,
560                                                             listeners : {
561                                                                 click : function (_self, e)
562                                                                 {
563                                                                     new Pman.Download({
564                                                                         url :baseURL + '/Xtuple/Reports/SGTax',
565                                                                          params :  _this.viewType.dateRange()
566                                                                     
567                                                                     });
568                                                                     Roo.MessageBox.alert("Downloading", 
569                                                                         "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
570                                                                     
571                                                                 }
572                                                             },
573                                                             text : "SG Tax report"
574                                                         }
575                                                     ]
576                                                 }
577                                             },
578                                             {
579                                                 xtype: 'Spacer',
580                                                 xns: Roo.Toolbar
581                                             },
582                                             {
583                                                 xtype: 'Fill',
584                                                 xns: Roo.Toolbar
585                                             },
586                                             {
587                                                 xtype: 'TextItem',
588                                                 xns: Roo.Toolbar,
589                                                 text : "Theme : "
590                                             },
591                                             {
592                                                 xtype: 'ComboBox',
593                                                 xns: Roo.form,
594                                                 listeners : {
595                                                     select : function (combo, record, index)
596                                                     {
597                                                         Pman.Xtuple.DashboardRender.load();
598                                                     },
599                                                     render : function (_self)
600                                                     {
601                                                         _this.themeCombo = this;
602                                                     }
603                                                 },
604                                                 allowBlank : false,
605                                                 displayField : 'name',
606                                                 editable : false,
607                                                 hiddenName : 'colortheme',
608                                                 listWidth : 300,
609                                                 name : 'colorTheme_title',
610                                                 qtip : "Select a Color Theme",
611                                                 selectOnFocus : true,
612                                                 triggerAction : 'all',
613                                                 typeAhead : false,
614                                                 valueField : 'themeData',
615                                                 value : (function() {
616                                                      return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : ''; 
617                                                 })(),
618                                                 store : {
619                                                     xtype: 'SimpleStore',
620                                                     xns: Roo.data,
621                                                     data : (function() {
622                                                         return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
623                                                         
624                                                     })(),
625                                                     fields : ['name','themeData']
626                                                 }
627                                             }
628                                         ]
629                                     }
630                                 },
631                                 {
632                                     xtype: 'ContentPanel',
633                                     xns: Roo,
634                                     listeners : {
635                                         render : function (_self)
636                                         {
637                                             _this.reportpanel = _self;
638                                         }
639                                     },
640                                     autoScroll : true,
641                                     fitToFrame : true,
642                                     region : 'center',
643                                     showReport : function(node, isxls) {
644                                         if (node) {
645                                             _this.selectedNode = node;
646                                         }
647                                         var rc = _this.reportCompany.getValue();
648                                         var params =  {
649                                             flhead_name : _this.selectedNode.attributes.text,
650                                             ts : Math.random(),
651                                             period : _this.reportDateFrom.getValue(),
652                                             interval:   _this.reportInterval.getValue(),
653                                             company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
654                                             singleCountry :  rc == 'consolidated' ? 0 : 1
655                                         };
656                                         
657                                         if (isxls) {
658                                             params._xls = 1;
659                                             new Pman.Download({
660                                                 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
661                                                 method: 'GET',
662                                                 timeout: 120000,
663                                                 params :  params
664                                             });
665                                             Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
666                                             return;
667                                         }
668                                         var el = this.region.el;
669                                     
670                                         var done = false;
671                                         var v= 0;
672                                         var f = function(){
673                                                 if (done) {
674                                                     return;
675                                                 }
676                                                 Roo.MessageBox.updateProgress(v/50, 'Loading..  Around ' + (50-v) + ' seconds to go');
677                                                 v++;
678                                                 f.defer(1000)
679                                            };
680                                          Roo.MessageBox.show({
681                                                title: 'Please wait...',
682                                                msg: 'Loading...',
683                                                width:240,
684                                                progress:true,
685                                                closable:true
686                                            });
687                                         
688                                     
689                                         
690                                         ///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");
691                                         this.load({
692                                             url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
693                                             method: 'GET',
694                                             params :  params,
695                                             timeout: 120,
696                                             callback: function() {
697                                                 done = true;
698                                                 Roo.MessageBox.hide();
699                                             }
700                                             
701                                         });
702                                         
703                                         f();
704                                         
705                                     },
706                                     toolbar : {
707                                         xtype: 'Toolbar',
708                                         xns: Roo,
709                                         items : [
710                                             {
711                                                 xtype: 'TextItem',
712                                                 xns: Roo.Toolbar,
713                                                 text : "Report Range :"
714                                             },
715                                             {
716                                                 xtype: 'DateField',
717                                                 xns: Roo.form,
718                                                 listeners : {
719                                                     render : function (_self)
720                                                     {
721                                                         _this.reportDateFrom = _self;
722                                                     },
723                                                     select : function (combo, date)
724                                                     {
725                                                       //_this.grid.footer.onClick('first');
726                                                     }
727                                                 },
728                                                 format : 'd/M/Y',
729                                                 useIso : 1,
730                                                 width : 120,
731                                                 value : (function() { 
732                                                     return Date.parseDate( 
733                                                         '' + (new Date()).format('Y-m') + '-01'
734                                                         , 'Y-m-d'   ); })()
735                                             },
736                                             {
737                                                 xtype: 'ComboBox',
738                                                 xns: Roo.form,
739                                                 listeners : {
740                                                     render : function (_self)
741                                                     {
742                                                       _this.reportInterval = _self;
743                                                     },
744                                                     select : function (combo, record, index)
745                                                     {
746                                                        // Roo.log('select');
747                                                        // _this.grid.footer.onClick('first');
748                                                     }
749                                                 },
750                                                 allowBlank : false,
751                                                 displayField : 'fname',
752                                                 editable : false,
753                                                 fieldLabel : 'Status',
754                                                 hiddenName : 'cm_status',
755                                                 listWidth : 400,
756                                                 mode : 'local',
757                                                 name : 'cm_status_name',
758                                                 triggerAction : 'all',
759                                                 value : "Y",
760                                                 valueField : 'ftype',
761                                                 width : 200,
762                                                 store : {
763                                                     xtype: 'SimpleStore',
764                                                     xns: Roo.data,
765                                                     data : [ 
766                                                         [ 'Y', "Since Start of Financial Year"],
767                                                         [ 'YY' , "Since Start of Financial Year with same range Previous Year"],            
768                                                         [ 'M' , "Single Month"],
769                                                         [ 'MM' , "Single Month with Previous Month"],    
770                                                         [ 'MY' , "Single Month with Previous Year"],
771                                                         [ 'MF' , "This Months of Financia Year"],
772                                                         [ 'ML' , "Last 12 Months"]
773                                                     ],
774                                                     fields : [  'ftype', 'fname']
775                                                 }
776                                             },
777                                             {
778                                                 xtype: 'ComboBox',
779                                                 xns: Roo.form,
780                                                 listeners : {
781                                                     render : function (_self)
782                                                     {
783                                                       _this.reportCompany = _self;
784                                                     }
785                                                 },
786                                                 allowBlank : false,
787                                                 displayField : 'fname',
788                                                 editable : false,
789                                                 fieldLabel : 'Status',
790                                                 hiddenName : 'report_company',
791                                                 listWidth : 300,
792                                                 mode : 'local',
793                                                 name : 'report_company_name',
794                                                 triggerAction : 'all',
795                                                 value : "hk",
796                                                 valueField : 'ftype',
797                                                 width : 100,
798                                                 hidden : (function() {
799                                                 
800                                                     return baseURL.match(/hk\.php$/) ? false : true;
801                                                 })(),
802                                                 store : {
803                                                     xtype: 'SimpleStore',
804                                                     xns: Roo.data,
805                                                     data : [ 
806                                                         [ 'hk', "Hong Kong"],
807                                                         [ 'sg' , "Singapore"],            
808                                                         [ 'my' , "Malaysia"],
809                                                         [ 'cn' , "China"],    
810                                                         [ 'au' , "Australia"],
811                                                         [ 'consolidated' , "Consolidated"]
812                                                     ],
813                                                     fields : [  'ftype', 'fname']
814                                                 }
815                                             },
816                                             {
817                                                 xtype: 'Button',
818                                                 xns: Roo.Toolbar,
819                                                 listeners : {
820                                                     click : function (_self, e)
821                                                     {
822                                                           _this.reportpanel.showReport(); 
823                                                     }
824                                                 },
825                                                 text : "Refresh Report"
826                                             },
827                                             {
828                                                 xtype: 'Fill',
829                                                 xns: Roo.Toolbar
830                                             },
831                                             {
832                                                 xtype: 'Button',
833                                                 xns: Roo.Toolbar,
834                                                 listeners : {
835                                                     click : function (_self, e)
836                                                     {
837                                                           _this.reportpanel.showReport(false,'xls'); 
838                                                     }
839                                                 },
840                                                 text : "Download XLS"
841                                             }
842                                         ]
843                                     }
844                                 }
845                             ],
846                             center : {
847                                 xtype: 'LayoutRegion',
848                                 xns: Roo,
849                                 hideTabs : true
850                             }
851                         }
852                     },
853                     {
854                         xtype: 'TreePanel',
855                         xns: Roo,
856                         listeners : {
857                             render : function (_self)
858                             {
859                                 _this.tree = _self;
860                             }
861                         },
862                         fitToFrame : true,
863                         region : 'west',
864                         toolbar : {
865                             xtype: 'Toolbar',
866                             xns: Roo
867                         },
868                         tree : {
869                             xtype: 'TreePanel',
870                             xns: Roo.tree,
871                             rootVisible : false,
872                             root : {
873                                 xtype: 'AsyncTreeNode',
874                                 xns: Roo.tree
875                             },
876                             selModel : {
877                                 xtype: 'DefaultSelectionModel',
878                                 xns: Roo.tree,
879                                 listeners : {
880                                     selectionchange : function (_self, node)
881                                     {
882                                         var at = node.attributes.id;
883                                         if (at > 999) {
884                                              _this.dashpanel.layout.getRegion('center').showPanel(0);
885                                               Pman.Xtuple.DashboardRender.load();
886                                               return;
887                                              
888                                         }
889                                         _this.dashpanel.layout.getRegion('center').showPanel(1);
890                                         _this.reportpanel.showReport(node); 
891                                        
892                                         
893                                     }
894                                 }
895                             },
896                             loader : {
897                                 xtype: 'TreeLoader',
898                                 xns: Roo.tree,
899                                 requestMethod : 'GET',
900                                 baseParams : { _tree : 1, _dragon_only : 1 },
901                                 dataUrl : baseURL + '/Roo/Flhead'
902                             },
903                             root : {
904                                 xtype: 'AsyncTreeNode',
905                                 xns: Roo.tree
906                             }
907                         }
908                     }
909                 ],
910                 west : {
911                     xtype: 'LayoutRegion',
912                     xns: Roo,
913                     hidden : false,
914                     split : true,
915                     width : 200
916                 },
917                 center : {
918                     xtype: 'LayoutRegion',
919                     xns: Roo
920                 }
921             }
922         };
923     }
924 });