1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Tab.XtupleDashboard = new Roo.XComponent({
6 part : ["Xtuple","Dashboard"],
7 order : '001-Pman.Tab.XtupleDashboard',
10 name : "Pman.Tab.XtupleDashboard",
18 xtype: 'NestedLayoutPanel',
21 activate : function (_self)
25 // Pman.Xtuple.DashboardRender.load();
33 title : "Management Dashboard",
35 xtype: 'BorderLayout',
39 xtype: 'NestedLayoutPanel',
42 render : function (_self)
44 _this.dashpanel = _self;
48 this.layout.getRegion('center').showPanel(0);
54 xtype: 'BorderLayout',
58 xtype: 'ContentPanel',
61 render : function (_self)
63 _this.viewPanel = _self;
66 //_this.paper = Raphael(_self.el.dom);
74 resize : function (_self, width, height)
78 /* _this.svg.attr("width", width)
79 .attr("height", height);
81 // _this.paper.setSize(width, 400);
83 Pman.Clipping.DashboardRender.resize(width,height);
91 activate : function (_self)
93 if (!_this.loadonce) {
94 _this.loadonce = true;
96 (function () { Pman.Xtuple.DashboardRender.load(); }).defer(1000);
117 render : function (_self)
119 _this.countryCombo= _self;
123 displayField : 'addr_country',
125 emptyText : " Country",
126 forceSelection : true,
128 loadingText : "Searching...",
130 name : 'addr_country',
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',
142 beforeload : function (_self, o){
143 o.params = o.params || {};
145 o.params._distinct = 'addr_country';
146 o.params._columns = 'addr_country';
147 o.params['!addr_country'] = '';
151 sortInfo : { direction : 'ASC', field: 'addr_country' },
156 url : baseURL + '/Roo/addr.php'
163 totalProperty : 'total',
164 fields : [{"name":"id","type":"int"},{"name":"addr_line1","type":"string"}]
172 render : function (_self)
174 _this.viewType = _self;
175 _this.dateRange = function() {
177 date_from : _this.mfrom.getValue(),
178 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
184 select : function (combo, record, index)
187 // Pman.Clipping.DashboardRender.load();
189 var ys = n.format('Y' )+ '-05-01';
190 n = Date.parseDate(ys, 'Y-n-d');
192 var ftype = record ? record.data.ftype : this.getValue();
196 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
197 _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
200 _this.daypick.hide();
202 _this.dateRange = function() {
204 date_from : _this.mfrom.getValue(),
205 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
215 var m = (new Date()).format('n')*1 > 6 ? 6 : 0;
217 Roo.log( n.add(Date.MONTH,m));
218 _this.mfrom.setValue(n.add(Date.MONTH,m));
221 _this.daypick.hide();
222 _this.dateRange = function() {
224 date_from : _this.mfrom.getValue(),
225 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
231 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
233 _this.mfrom.setValue(n.add(Date.MONTH, m));
236 _this.daypick.hide();
237 _this.dateRange = function() {
239 date_from : _this.mfrom.getValue(),
240 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
246 var m = (new Date()).format('n') *1 - 1 ;
247 _this.mfrom.setValue(n.add(Date.MONTH, m ));
250 _this.daypick.hide();
251 _this.dateRange = function() {
253 date_from : _this.mfrom.getValue(),
254 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
263 var m = (new Date()).format('n') * 1;
264 _this.mfrom.setValue(n.add(Date.MONTH, m-1 ));
265 _this.mto.setValue(n.add(Date.MONTH,m ));
271 _this.daypick.hide();
272 _this.dateRange = function() {
274 date_from : _this.mfrom.getValue(),
275 date_to : _this.mto.getValue()
283 var d = (new Date()).format('w') * -1;
284 _this.daypick.setValue( (new Date()).add(Date.DAY, d ));
287 _this.daypick.show();
292 _this.daypick.setValue(new Date());
295 _this.daypick.show();
299 alerT("oops invalid ftype?");
308 displayField : 'fname',
310 fieldLabel : 'Status',
311 hiddenName : 'cm_status',
314 name : 'cm_status_name',
315 triggerAction : 'all',
317 valueField : 'ftype',
320 xtype: 'SimpleStore',
323 [ 'Y', "Show Year From"],
324 [ 'H' , "6 Months From"],
325 [ 'Q', "3 Months From"] ,
326 [ 'M', "Single Month"],
327 // [ 'W', "Single Week Starting"],
328 [ 'R', "Between these Dates"] //,
329 // [ 'D', "Single Day"]
332 fields : [ 'ftype', 'fname']
339 render : function (_self)
346 value : (function() {
349 var y = n.format('Y');
350 if (n.format('m') < 5) {
354 return Date.parseDate(y + '-05-01', 'Y-m-d');
361 render : function (_self)
369 value : (function() {
370 var n = (new Date()).add(Date.YEAR, 1);
374 var y = n.format('Y');
375 if (n.format('m') >= 5) {
379 return Date.parseDate(y + '-05-01', 'Y-m-d');
389 render : function (_self)
391 _this.daypick = _self;
397 value : (function() {
398 // var n = new Date();
406 click : function (_self, e)
408 Pman.Xtuple.DashboardRender.load();
416 text : "Other Reports",
425 click : function (_self, e)
428 url :baseURL + '/Xtuple/Reports/SalesByCustomer',
431 date_from : _this.mfrom.getValue(),
432 date_to :_this.mto.getValue()
439 text : "Sales By Customer"
445 click : function (_self, e)
448 url :baseURL + '/Xtuple/Reports/SalesByCountry',
449 params : _this.dateRange()
454 text : "Sales By Country"
460 click : function (_self, e)
463 url :baseURL + '/Xtuple/Reports/SalesByProduct',
464 params : _this.dateRange()
469 text : "Sales By Product"
479 click : function (_self, e)
482 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
483 params : _this.dateRange()
488 text : "Purchases By Vendor"
494 click : function (_self, e)
497 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
498 params : _this.dateRange()
503 text : "Purchases By Product"
513 click : function (_self, e)
516 url :baseURL + '/Xtuple/Reports/StockAtLocation',
517 params : _this.dateRange()
520 Roo.MessageBox.alert("Downloading",
521 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
525 text : "Historical Stock Levels (EO HKFY)"
535 click : function (_self, e)
538 url :baseURL + '/Xtuple/Reports/SGTax',
539 params : _this.dateRange()
542 Roo.MessageBox.alert("Downloading",
543 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
547 text : "SG Tax report"
569 select : function (combo, record, index)
571 Pman.Xtuple.DashboardRender.load();
573 render : function (_self)
575 _this.themeCombo = this;
579 displayField : 'name',
581 hiddenName : 'colortheme',
583 name : 'colorTheme_title',
584 qtip : "Select a Color Theme",
585 selectOnFocus : true,
586 triggerAction : 'all',
588 valueField : 'themeData',
589 value : (function() {
590 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
593 xtype: 'SimpleStore',
596 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
599 fields : ['name','themeData']
606 xtype: 'ContentPanel',
609 render : function (_self)
611 _this.reportpanel = _self;
617 showReport : function(node, isxls) {
619 _this.selectedNode = node;
621 var rc = _this.reportCompany.getValue();
623 flhead_name : _this.selectedNode.attributes.text,
625 period : _this.reportDateFrom.getValue(),
626 interval: _this.reportInterval.getValue(),
627 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
628 singleCountry : rc == 'consolidated' ? 0 : 1
634 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
639 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
642 var el = this.region.el;
650 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
654 Roo.MessageBox.show({
655 title: 'Please wait...',
664 ///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");
666 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
670 callback: function() {
672 Roo.MessageBox.hide();
687 text : "Report Range :"
693 render : function (_self)
695 _this.reportDateFrom = _self;
697 select : function (combo, date)
699 //_this.grid.footer.onClick('first');
705 value : (function() {
706 return Date.parseDate(
707 '' + (new Date()).format('Y-m') + '-01'
714 render : function (_self)
716 _this.reportInterval = _self;
718 select : function (combo, record, index)
720 // Roo.log('select');
721 // _this.grid.footer.onClick('first');
725 displayField : 'fname',
727 fieldLabel : 'Status',
728 hiddenName : 'cm_status',
731 name : 'cm_status_name',
732 triggerAction : 'all',
734 valueField : 'ftype',
737 xtype: 'SimpleStore',
740 [ 'Y', "Since Start of Financial Year"],
741 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
742 [ 'M' , "Single Month"],
743 [ 'MM' , "Single Month with Previous Month"],
744 [ 'MY' , "Single Month with Previous Year"],
745 [ 'MF' , "This Months of Financia Year"],
746 [ 'ML' , "Last 12 Months"]
748 fields : [ 'ftype', 'fname']
755 render : function (_self)
757 _this.reportCompany = _self;
761 displayField : 'fname',
763 fieldLabel : 'Status',
764 hiddenName : 'report_company',
767 name : 'report_company_name',
768 triggerAction : 'all',
770 valueField : 'ftype',
772 hidden : (function() {
774 return baseURL.match(/hk\.php$/) ? false : true;
777 xtype: 'SimpleStore',
780 [ 'hk', "Hong Kong"],
781 [ 'sg' , "Singapore"],
782 [ 'my' , "Malaysia"],
784 [ 'au' , "Australia"],
785 [ 'consolidated' , "Consolidated"]
787 fields : [ 'ftype', 'fname']
794 click : function (_self, e)
796 _this.reportpanel.showReport();
799 text : "Refresh Report"
809 click : function (_self, e)
811 _this.reportpanel.showReport(false,'xls');
814 text : "Download XLS"
821 xtype: 'LayoutRegion',
831 render : function (_self)
847 xtype: 'AsyncTreeNode',
851 xtype: 'DefaultSelectionModel',
854 selectionchange : function (_self, node)
856 var at = node.attributes.id;
858 _this.dashpanel.layout.getRegion('center').showPanel(0);
859 Pman.Xtuple.DashboardRender.load();
863 _this.dashpanel.layout.getRegion('center').showPanel(1);
864 _this.reportpanel.showReport(node);
873 requestMethod : 'GET',
874 baseParams : { _tree : 1, _dragon_only : 1 },
875 dataUrl : baseURL + '/Roo/Flhead'
878 xtype: 'AsyncTreeNode',
885 xtype: 'LayoutRegion',
892 xtype: 'LayoutRegion',