I'm trying to create a dashboard to tell me how much I've made last year, this year so far, overall in total, month, last month, week, and today.
This is the coding i have so far..I cannt get day to work..it prints nothing, I havent even started on week (that looks scarey to code) as well as last year. So far overall sales, this month, and last month works.
$total_sales = $db->select('SELECT SUM(`prod_total`) as `total_sales` FROM `'.$config['dbprefix'].'CubeCart_order_sum` WHERE `status` > 1 ;');
$quick_stats['total_sales'] = $total_sales[0]['total_sales'];
$ave_order = $db->select('SELECT AVG(`prod_total`) as `ave_order` FROM `'.$config['dbprefix'].'CubeCart_order_sum` WHERE `status` > 1 ;');
$quick_stats['ave_order'] = $ave_order[0]['ave_order'];
$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_month)));
$last_year = ($last_month < $this_month) ? $this_year : ($this_year - 1);
$last_month_start = mktime (0, 0, 0, $last_month, '01', $last_year);
$last_month_sales = $db->select('SELECT SUM(`prod_total`) as `last_month` FROM `'.$config['dbprefix'].'CubeCart_order_sum` WHERE `status` > 1 AND `time` > '.$last_month_start.' AND `time` < '.$this_month_start.';');
$quick_stats['last_month'] = $last_month_sales[0]['last_month'];
$this_month_sales = $db->select('SELECT SUM(`prod_total`) as `this_month` FROM `'.$config['dbprefix'].'CubeCart_order_sum` WHERE `status` > 1 AND `time` > '.$this_month_start.';');
$quick_stats['this_month'] = $this_month_sales[0]['this_month'];
##DAY
$this_day = date('d');
$this_day_start = strtotime ('00:00', $this_day);
$this_day_sales = $db->select('SELECT SUM(`prod_total`) as `this_day` FROM `'.$config['dbprefix'].'CubeCart_order_sum` WHERE `status` > 1 AND `time` > '.$this_day_start.';');
How do I do day and week?