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() {
315 var ftype = this.getValue();
322 date_from : _this.mfrom.getValue(),
323 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.YEAR, 1).format('Y-m-d')
333 date_from : _this.mfrom.getValue(),
334 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 6).format('Y-m-d')
343 date_from : _this.mfrom.getValue(),
344 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 3).format('Y-m-d')
352 date_from : _this.mfrom.getValue(),
353 date_to :Date.parseDate(_this.mfrom.getValue(), 'Y-n-d').add(Date.MONTH, 1).format('Y-m-d')
363 date_from : _this.mfrom.getValue(),
364 date_to : _this.mto.getValue()
371 Roo.MessageBox.alert("select range");
377 xtype: 'SimpleStore',
380 [ 'Y', "Show Year From"],
381 [ 'H' , "6 Months From"],
382 [ 'Q', "3 Months From"] ,
383 [ 'M', "Single Month"],
384 // [ 'W', "Single Week Starting"],
385 [ 'R', "Between these Dates"] //,
386 // [ 'D', "Single Day"]
389 fields : [ 'ftype', 'fname']
396 render : function (_self)
403 value : (function() {
406 var y = n.format('Y');
407 if (n.format('m') < 5) {
411 return Date.parseDate(y + '-05-01', 'Y-m-d');
418 render : function (_self)
426 value : (function() {
427 var n = (new Date()).add(Date.YEAR, 1);
431 var y = n.format('Y');
432 if (n.format('m') >= 5) {
436 return Date.parseDate(y + '-05-01', 'Y-m-d');
446 render : function (_self)
448 _this.daypick = _self;
454 value : (function() {
455 // var n = new Date();
463 click : function (_self, e)
465 Pman.Xtuple.DashboardRender.load();
473 text : "Other Reports",
482 click : function (_self, e)
485 url :baseURL + '/Xtuple/Reports/SalesByCustomer',
486 params : _this.viewType.dateRange()
492 text : "Sales By Customer"
498 click : function (_self, e)
501 url :baseURL + '/Xtuple/Reports/SalesByCountry',
502 params : _this.viewType.dateRange()
507 text : "Sales By Country"
513 click : function (_self, e)
516 url :baseURL + '/Xtuple/Reports/SalesByProduct',
517 params : _this.viewType.dateRange()
522 text : "Sales By Product"
532 click : function (_self, e)
535 url :baseURL + '/Xtuple/Reports/PurchasesByVendor',
536 params : _this.viewType.dateRange()
541 text : "Purchases By Vendor"
547 click : function (_self, e)
550 url :baseURL + '/Xtuple/Reports/PurchasesByProduct',
551 params : _this.viewType.dateRange()
556 text : "Purchases By Product"
566 click : function (_self, e)
569 url :baseURL + '/Xtuple/Reports/StockAtLocation',
570 params : _this.viewType.dateRange()
573 Roo.MessageBox.alert("Downloading",
574 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
578 text : "Historical Stock Levels (EO HKFY)"
588 click : function (_self, e)
591 url :baseURL + '/Xtuple/Reports/SGTax',
592 params : _this.viewType.dateRange()
595 Roo.MessageBox.alert("Downloading",
596 "The file will start downloading shortly - it may take around 1-2 minutes to calculate");
600 text : "SG Tax report"
622 select : function (combo, record, index)
624 Pman.Xtuple.DashboardRender.load();
626 render : function (_self)
628 _this.themeCombo = this;
632 displayField : 'name',
634 hiddenName : 'colortheme',
636 name : 'colorTheme_title',
637 qtip : "Select a Color Theme",
638 selectOnFocus : true,
639 triggerAction : 'all',
641 valueField : 'themeData',
642 value : (function() {
643 return Pman.Xtuple ? Pman.Xtuple.DashboardRender.colorthemes()[12][1] : '';
646 xtype: 'SimpleStore',
649 return (typeof Pman.Xtuple != 'undefined') ? Pman.Xtuple.DashboardRender.colorthemes() : [];
652 fields : ['name','themeData']
659 xtype: 'ContentPanel',
662 render : function (_self)
664 _this.reportpanel = _self;
670 showReport : function(node, isxls) {
672 _this.selectedNode = node;
674 var rc = _this.reportCompany.getValue();
676 flhead_name : _this.selectedNode.attributes.text,
678 period : _this.reportDateFrom.getValue(),
679 interval: _this.reportInterval.getValue(),
680 company : (_this.reportCompany.hidden) ? '' : rc == 'consolidated' ? '' : rc,
681 singleCountry : rc == 'consolidated' ? 0 : 1
687 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
692 Roo.MessageBox.alert("Notice", "Report is downloading now for the combined report this will take about 50s");
695 var el = this.region.el;
703 Roo.MessageBox.updateProgress(v/50, 'Loading.. Around ' + (50-v) + ' seconds to go');
707 Roo.MessageBox.show({
708 title: 'Please wait...',
717 ///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");
719 url : baseURL + '/Xtuple/Reports/ConsolidatedAccounts',
723 callback: function() {
725 Roo.MessageBox.hide();
740 text : "Report Range :"
746 render : function (_self)
748 _this.reportDateFrom = _self;
750 select : function (combo, date)
752 //_this.grid.footer.onClick('first');
758 value : (function() {
759 return Date.parseDate(
760 '' + (new Date()).format('Y-m') + '-01'
767 render : function (_self)
769 _this.reportInterval = _self;
771 select : function (combo, record, index)
773 // Roo.log('select');
774 // _this.grid.footer.onClick('first');
778 displayField : 'fname',
780 fieldLabel : 'Status',
781 hiddenName : 'cm_status',
784 name : 'cm_status_name',
785 triggerAction : 'all',
787 valueField : 'ftype',
790 xtype: 'SimpleStore',
793 [ 'Y', "Since Start of Financial Year"],
794 [ 'YY' , "Since Start of Financial Year with same range Previous Year"],
795 [ 'M' , "Single Month"],
796 [ 'MM' , "Single Month with Previous Month"],
797 [ 'MY' , "Single Month with Previous Year"],
798 [ 'MF' , "This Months of Financia Year"],
799 [ 'ML' , "Last 12 Months"]
801 fields : [ 'ftype', 'fname']
808 render : function (_self)
810 _this.reportCompany = _self;
814 displayField : 'fname',
816 fieldLabel : 'Status',
817 hiddenName : 'report_company',
820 name : 'report_company_name',
821 triggerAction : 'all',
823 valueField : 'ftype',
825 hidden : (function() {
827 return baseURL.match(/hk\.php$/) ? false : true;
830 xtype: 'SimpleStore',
833 [ 'hk', "Hong Kong"],
834 [ 'sg' , "Singapore"],
835 [ 'my' , "Malaysia"],
837 [ 'au' , "Australia"],
838 [ 'consolidated' , "Consolidated"]
840 fields : [ 'ftype', 'fname']
847 click : function (_self, e)
849 _this.reportpanel.showReport();
852 text : "Refresh Report"
862 click : function (_self, e)
864 _this.reportpanel.showReport(false,'xls');
867 text : "Download XLS"
874 xtype: 'LayoutRegion',
884 render : function (_self)
900 xtype: 'AsyncTreeNode',
904 xtype: 'DefaultSelectionModel',
907 selectionchange : function (_self, node)
909 var at = node.attributes.id;
911 _this.dashpanel.layout.getRegion('center').showPanel(0);
912 Pman.Xtuple.DashboardRender.load();
916 _this.dashpanel.layout.getRegion('center').showPanel(1);
917 _this.reportpanel.showReport(node);
926 requestMethod : 'GET',
927 baseParams : { _tree : 1, _dragon_only : 1 },
928 dataUrl : baseURL + '/Roo/Flhead'
931 xtype: 'AsyncTreeNode',
938 xtype: 'LayoutRegion',
945 xtype: 'LayoutRegion',