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',
429 params : _this.dateRange()
434 text : "Sales By Customer"
440 click : function (_self, e)
443 url :baseURL + '/Xtuple/Reports/SalesByCountry',
444 params : _this.dateRange()
449 text : "Sales By Country"
455 click : function (_self, e)
458 url :baseURL + '/Xtuple/Reports/SalesByProduct',
459 params : _this.dateRange()
464 text : "Sales By Product"
474 click : function (_self, e)
477 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
478 params : _this.dateRange()
483 text : "Purchases By Vendor"
489 click : function (_self, e)
492 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
493 params : _this.dateRange()
498 text : "Purchases By Product"
508 click : function (_self, e)
511 url :baseURL + '/Xtuple/Reports/StockAtLocation',
512 params : _this.dateRange()
515 Roo.MessageBox.alert("Downloading",
516 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
520 text : "Historical Stock Levels (EO HKFY)"
530 click : function (_self, e)
533 url :baseURL + '/Xtuple/Reports/SGTax',
534 params : _this.dateRange()
537 Roo.MessageBox.alert("Downloading",
538 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
542 text : "SG Tax report"
564 select : function (combo, record, index)
566 Pman.Xtuple.DashboardRender.load();
568 render : function (_self)
570 _this.themeCombo = this;
574 displayField : 'name',
576 hiddenName : 'colortheme',
578 name : 'colorTheme_title',
579 qtip : "Select a Color Theme",
580 selectOnFocus : true,
581 triggerAction : 'all',
583 valueField : 'themeData',
584 value : (function() {
585 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
588 xtype: 'SimpleStore',
591 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
594 fields : ['name','themeData']
601 xtype: 'ContentPanel',
604 render : function (_self)
606 _this.reportpanel = _self;
612 showReport : function(node, isxls) {
614 _this.selectedNode = node;
616 var rc = _this.reportCompany.getValue();
618 flhead_name : _this.selectedNode.attributes.text,
620 period : _this.reportDateFrom.getValue(),
621 interval: _this.reportInterval.getValue(),
622 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
623 singleCountry : rc == 'consolidated' ? 0 : 1
629 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
634 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
637 var el = this.region.el;
645 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
649 Roo.MessageBox.show({
650 title: 'Please wait...',
659 ///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");
661 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
665 callback: function() {
667 Roo.MessageBox.hide();
682 text : "Report Range :"
688 render : function (_self)
690 _this.reportDateFrom = _self;
692 select : function (combo, date)
694 //_this.grid.footer.onClick('first');
700 value : (function() {
701 return Date.parseDate(
702 '' + (new Date()).format('Y-m') + '-01'
709 render : function (_self)
711 _this.reportInterval = _self;
713 select : function (combo, record, index)
715 // Roo.log('select');
716 // _this.grid.footer.onClick('first');
720 displayField : 'fname',
722 fieldLabel : 'Status',
723 hiddenName : 'cm_status',
726 name : 'cm_status_name',
727 triggerAction : 'all',
729 valueField : 'ftype',
732 xtype: 'SimpleStore',
735 [ 'Y', "Since Start of Financial Year"],
736 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
737 [ 'M' , "Single Month"],
738 [ 'MM' , "Single Month with Previous Month"],
739 [ 'MY' , "Single Month with Previous Year"],
740 [ 'MF' , "This Months of Financia Year"],
741 [ 'ML' , "Last 12 Months"]
743 fields : [ 'ftype', 'fname']
750 render : function (_self)
752 _this.reportCompany = _self;
756 displayField : 'fname',
758 fieldLabel : 'Status',
759 hiddenName : 'report_company',
762 name : 'report_company_name',
763 triggerAction : 'all',
765 valueField : 'ftype',
767 hidden : (function() {
769 return baseURL.match(/hk\.php$/) ? false : true;
772 xtype: 'SimpleStore',
775 [ 'hk', "Hong Kong"],
776 [ 'sg' , "Singapore"],
777 [ 'my' , "Malaysia"],
779 [ 'au' , "Australia"],
780 [ 'consolidated' , "Consolidated"]
782 fields : [ 'ftype', 'fname']
789 click : function (_self, e)
791 _this.reportpanel.showReport();
794 text : "Refresh Report"
804 click : function (_self, e)
806 _this.reportpanel.showReport(false,'xls');
809 text : "Download XLS"
816 xtype: 'LayoutRegion',
826 render : function (_self)
842 xtype: 'AsyncTreeNode',
846 xtype: 'DefaultSelectionModel',
849 selectionchange : function (_self, node)
851 var at = node.attributes.id;
853 _this.dashpanel.layout.getRegion('center').showPanel(0);
854 Pman.Xtuple.DashboardRender.load();
858 _this.dashpanel.layout.getRegion('center').showPanel(1);
859 _this.reportpanel.showReport(node);
868 requestMethod : 'GET',
869 baseParams : { _tree : 1, _dragon_only : 1 },
870 dataUrl : baseURL + '/Roo/Flhead'
873 xtype: 'AsyncTreeNode',
880 xtype: 'LayoutRegion',
887 xtype: 'LayoutRegion',