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;
177 select : function (combo, record, index)
180 // Pman.Clipping.DashboardRender.load();
182 var ys = n.format('Y' )+ '-05-01';
183 n = Date.parseDate(ys, 'Y-n-d');
185 var ftype = record ? record.data.ftype : this.getValue();
189 //Roo.log(Date.parseDate(ys, 'Y-n-d'));
190 _this.mfrom.setValue(Date.parseDate(ys, 'Y-n-d'));
193 _this.daypick.hide();
195 _this.dateRange = function() {
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')
208 var m = (new Date()).format('n')*1 > 6 ? 6 : 0;
210 Roo.log( n.add(Date.MONTH,m));
211 _this.mfrom.setValue(n.add(Date.MONTH,m));
214 _this.daypick.hide();
215 _this.dateRange = function() {
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')
224 var m = Math.floor(((new Date()).format('n') *1 -1) / 4) * 4;
226 _this.mfrom.setValue(n.add(Date.MONTH, m));
229 _this.daypick.hide();
230 _this.dateRange = function() {
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')
239 var m = (new Date()).format('n') *1 - 1 ;
240 _this.mfrom.setValue(n.add(Date.MONTH, m ));
243 _this.daypick.hide();
244 _this.dateRange = function() {
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')
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 ));
264 _this.daypick.hide();
265 _this.dateRange = function() {
267 date_from : _this.mfrom.getValue(),
268 date_to : _this.mto.getValue()
276 var d = (new Date()).format('w') * -1;
277 _this.daypick.setValue( (new Date()).add(Date.DAY, d ));
280 _this.daypick.show();
285 _this.daypick.setValue(new Date());
288 _this.daypick.show();
292 alerT("oops invalid ftype?");
301 displayField : 'fname',
303 fieldLabel : 'Status',
304 hiddenName : 'cm_status',
307 name : 'cm_status_name',
308 triggerAction : 'all',
310 valueField : 'ftype',
312 dateRange : function() {
314 date_from : _this.mfrom.getValue(),
315 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
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.viewType.dateRange()
435 text : "Sales By Customer"
441 click : function (_self, e)
444 url :baseURL + '/Xtuple/Reports/SalesByCountry',
445 params : _this.viewType.dateRange()
450 text : "Sales By Country"
456 click : function (_self, e)
459 url :baseURL + '/Xtuple/Reports/SalesByProduct',
460 params : _this.viewType.dateRange()
465 text : "Sales By Product"
475 click : function (_self, e)
478 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
479 params : _this.viewType.dateRange()
484 text : "Purchases By Vendor"
490 click : function (_self, e)
493 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
494 params : _this.viewType.dateRange()
499 text : "Purchases By Product"
509 click : function (_self, e)
512 url :baseURL + '/Xtuple/Reports/StockAtLocation',
513 params : _this.viewType.dateRange()
516 Roo.MessageBox.alert("Downloading",
517 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
521 text : "Historical Stock Levels (EO HKFY)"
531 click : function (_self, e)
534 url :baseURL + '/Xtuple/Reports/SGTax',
535 params : _this.dateRange()
538 Roo.MessageBox.alert("Downloading",
539 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
543 text : "SG Tax report"
565 select : function (combo, record, index)
567 Pman.Xtuple.DashboardRender.load();
569 render : function (_self)
571 _this.themeCombo = this;
575 displayField : 'name',
577 hiddenName : 'colortheme',
579 name : 'colorTheme_title',
580 qtip : "Select a Color Theme",
581 selectOnFocus : true,
582 triggerAction : 'all',
584 valueField : 'themeData',
585 value : (function() {
586 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
589 xtype: 'SimpleStore',
592 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
595 fields : ['name','themeData']
602 xtype: 'ContentPanel',
605 render : function (_self)
607 _this.reportpanel = _self;
613 showReport : function(node, isxls) {
615 _this.selectedNode = node;
617 var rc = _this.reportCompany.getValue();
619 flhead_name : _this.selectedNode.attributes.text,
621 period : _this.reportDateFrom.getValue(),
622 interval: _this.reportInterval.getValue(),
623 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
624 singleCountry : rc == 'consolidated' ? 0 : 1
630 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
635 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
638 var el = this.region.el;
646 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
650 Roo.MessageBox.show({
651 title: 'Please wait...',
660 ///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");
662 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
666 callback: function() {
668 Roo.MessageBox.hide();
683 text : "Report Range :"
689 render : function (_self)
691 _this.reportDateFrom = _self;
693 select : function (combo, date)
695 //_this.grid.footer.onClick('first');
701 value : (function() {
702 return Date.parseDate(
703 '' + (new Date()).format('Y-m') + '-01'
710 render : function (_self)
712 _this.reportInterval = _self;
714 select : function (combo, record, index)
716 // Roo.log('select');
717 // _this.grid.footer.onClick('first');
721 displayField : 'fname',
723 fieldLabel : 'Status',
724 hiddenName : 'cm_status',
727 name : 'cm_status_name',
728 triggerAction : 'all',
730 valueField : 'ftype',
733 xtype: 'SimpleStore',
736 [ 'Y', "Since Start of Financial Year"],
737 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
738 [ 'M' , "Single Month"],
739 [ 'MM' , "Single Month with Previous Month"],
740 [ 'MY' , "Single Month with Previous Year"],
741 [ 'MF' , "This Months of Financia Year"],
742 [ 'ML' , "Last 12 Months"]
744 fields : [ 'ftype', 'fname']
751 render : function (_self)
753 _this.reportCompany = _self;
757 displayField : 'fname',
759 fieldLabel : 'Status',
760 hiddenName : 'report_company',
763 name : 'report_company_name',
764 triggerAction : 'all',
766 valueField : 'ftype',
768 hidden : (function() {
770 return baseURL.match(/hk\.php$/) ? false : true;
773 xtype: 'SimpleStore',
776 [ 'hk', "Hong Kong"],
777 [ 'sg' , "Singapore"],
778 [ 'my' , "Malaysia"],
780 [ 'au' , "Australia"],
781 [ 'consolidated' , "Consolidated"]
783 fields : [ 'ftype', 'fname']
790 click : function (_self, e)
792 _this.reportpanel.showReport();
795 text : "Refresh Report"
805 click : function (_self, e)
807 _this.reportpanel.showReport(false,'xls');
810 text : "Download XLS"
817 xtype: 'LayoutRegion',
827 render : function (_self)
843 xtype: 'AsyncTreeNode',
847 xtype: 'DefaultSelectionModel',
850 selectionchange : function (_self, node)
852 var at = node.attributes.id;
854 _this.dashpanel.layout.getRegion('center').showPanel(0);
855 Pman.Xtuple.DashboardRender.load();
859 _this.dashpanel.layout.getRegion('center').showPanel(1);
860 _this.reportpanel.showReport(node);
869 requestMethod : 'GET',
870 baseParams : { _tree : 1, _dragon_only : 1 },
871 dataUrl : baseURL + '/Roo/Flhead'
874 xtype: 'AsyncTreeNode',
881 xtype: 'LayoutRegion',
888 xtype: 'LayoutRegion',