Jump to content

dashboard sales statistics


keat

Recommended Posts

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

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...