From 127fc03d44d0c9dad9f323c6db76a3fdcdbbd2cb Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 24 Aug 2016 16:44:45 -0400 Subject: [PATCH] Updated the weekly and monthly date ranges Now I'm getting the correct lead counts for weeks daily and monthly stats. --- models/admin/ajax/statCollector.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/models/admin/ajax/statCollector.php b/models/admin/ajax/statCollector.php index e3a9d19..bf698d4 100644 --- a/models/admin/ajax/statCollector.php +++ b/models/admin/ajax/statCollector.php @@ -147,8 +147,6 @@ class GlmMembersAdmin_ajax_statCollector $stat_date->modify( '+ 1 week' ); $last_stat_date = $stat_date->format( 'Y-m-d' ); } - $current_date = new DateTime(); - $current_date->modify( '+ 1 weeks' ); $results = $this->wpdb->get_results( $this->wpdb->prepare( "SELECT count(id) as leads_count,DATE_FORMAT(date_submitted, '%%Y%%U') as weekly @@ -156,7 +154,7 @@ class GlmMembersAdmin_ajax_statCollector WHERE date_submitted < %s AND date_submitted > %s GROUP BY weekly", - $current_date->format( 'Y-m-d' ), + date( 'Y-m-d', strtotime( 'sunday last week' ) ), $last_stat_date ), ARRAY_A @@ -197,11 +195,6 @@ class GlmMembersAdmin_ajax_statCollector } $current_date = new DateTime(); $current_date->modify( '+ 1 months' ); - $sql = " - SELECT count(id) as leads_count,DATE_FORMAT(date_submitted, '%Y%m') as monthly - FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "lead_entry - GROUP BY monthly"; - //$results = $this->wpdb->get_results( $sql ); $results = $this->wpdb->get_results( $this->wpdb->prepare( "SELECT count(id) as leads_count,DATE_FORMAT(date_submitted, '%%Y%%m') as monthly @@ -209,7 +202,7 @@ class GlmMembersAdmin_ajax_statCollector WHERE date_submitted < %s AND date_submitted > %s GROUP BY monthly", - $current_date->format( 'Y-m-d' ), + date( 'Y-m-d', mktime( 0, 0, 0, date('m'), 1, date('Y') ) ), $last_stat_date ), ARRAY_A -- 2.17.1