keat Posted August 2, 2017 Share Posted August 2, 2017 Is it possible to add more years to the dashbourd sales stats, and in defferent colours. Maybe 3 or 4 years instead of last year and current Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 2, 2017 Share Posted August 2, 2017 Absolutely. But I think there are not the hooks to do it, so it would have to be code edits. Quote Link to comment Share on other sites More sharing options...
keat Posted August 2, 2017 Author Share Posted August 2, 2017 maybe something for another day then. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted August 2, 2017 Share Posted August 2, 2017 I think I remember someone has a suggestion on the Feature section to do that. Go see if you can vote for it or make the suggestion yourself? Quote Link to comment Share on other sites More sharing options...
bsmither Posted August 4, 2017 Share Posted August 4, 2017 Try this. In /admin/sources/dashboard.index.inc.php: Lines 212-225: From: $this_year = date('Y'); $last_year = $this_year - 1; $chart_data['data'] = "['Month', '$this_year', '$last_year'],"; for ($month = 1; $month <= 12; $month++) { $m = date("M", mktime(0, 0, 0, $month, 10)); $last_year_month = (isset($data[$last_year][$m]) && $data[$last_year][$m]>0) ? $data[$last_year][$m] : 0; $this_year_month = (isset($data[$this_year][$m]) && $data[$this_year][$m]>0) ? $data[$this_year][$m] : 0; $chart_data['data'] .= "['$m', $this_year_month, $last_year_month],"; } $chart_data['title'] = $lang['dashboard']['title_sales_stats'].': '.$last_year.' - '.$this_year; $GLOBALS['smarty']->assign('CHART', $chart_data); To: // $this_year = date('Y'); // $last_year = $this_year - 1; ksort($data); $chart_data['data'] = "['Month', '"; $chart_data['data'] .= implode("', '", array_keys($data)); $chart_data['data'] .= "'],"; for ($month = 1; $month <= 12; $month++) { $m = date("M", mktime(0, 0, 0, $month, 10)); $chart_data['data'] .= "['$m'"; foreach (array_keys($data) as $year) { $year_month = (isset($data[$year][$m]) && $data[$year][$m]>0) ? $data[$year][$m] : 0; $chart_data['data'] .= ",".$year_month; } $chart_data['data'] .= "],"; } $chart_data['title'] = $lang['dashboard']['title_sales_stats'].': '.array_keys($data)[0].' - '.$this_year; $GLOBALS['smarty']->assign('CHART', $chart_data); Line 197: From: ## Statistics (Google Charts) To: ## Statistics (Google Charts) $years_to_show = 5; $last_year_start = mktime(0, 0, 0, '01', '01', $this_year - $years_to_show); Lines 167-174: From: $this_year = date('Y'); $this_month = date('m'); $this_month_start = mktime(0, 0, 0, $this_month, '01', $this_year); ## Work out prev month looks silly but should stop -1 month on 1st March returning January (28 Days in Feb) $last_month = date('m', strtotime("-1 month", mktime(12, 0, 0, $this_month, 15, $this_year))); $last_year = ($last_month < $this_month) ? $this_year : ($this_year - 1); $last_month_start = mktime(0, 0, 0, $last_month, '01', $last_year); $last_year_start = mktime(0, 0, 0, '01', '01', $this_year - 1); To: /* Not the best place for these. $this_year = date('Y'); $this_month = date('m'); $this_month_start = mktime(0, 0, 0, $this_month, '01', $this_year); ## Work out prev month looks silly but should stop -1 month on 1st March returning January (28 Days in Feb) $last_month = date('m', strtotime("-1 month", mktime(12, 0, 0, $this_month, 15, $this_year))); $last_year = ($last_month < $this_month) ? $this_year : ($this_year - 1); $last_month_start = mktime(0, 0, 0, $last_month, '01', $last_year); $last_year_start = mktime(0, 0, 0, '01', '01', $this_year - 1); */ Lines 158-159: From: $GLOBALS['main']->addTabControl($lang['dashboard']['title_dashboard'], 'dashboard'); ## Quick Stats To: $GLOBALS['main']->addTabControl($lang['dashboard']['title_dashboard'], 'dashboard'); $this_year = date('Y'); $this_month = date('m'); $this_month_start = mktime(0, 0, 0, $this_month, '01', $this_year); ## Work out prev month looks silly but should stop -1 month on 1st March returning January (28 Days in Feb) $last_month = date('m', strtotime("-1 month", mktime(12, 0, 0, $this_month, 15, $this_year))); $last_year = ($last_month < $this_month) ? $this_year : ($this_year - 1); // Not really last year - used to accurately work around the rollover from month 12 to month 1 at the next step $last_month_start = mktime(0, 0, 0, $last_month, '01', $last_year); $last_year_start = mktime(0, 0, 0, '01', '01', $this_year - 1); ## Quick Stats Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.