From: Steve Sutton Date: Thu, 3 May 2018 20:49:50 +0000 (-0400) Subject: billing setup queue need to check the period of time. X-Git-Tag: v1.0.0^2~17 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a30beb52e0d834022cd9aff703e1d4a0ee0a4e86;p=WP-Plugins%2Fglm-member-db-billing.git billing setup queue need to check the period of time. Could be month or week. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 5c4c642..ce3e2a0 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -574,13 +574,28 @@ class GlmBillingSupport * @param int $days Days before or after * @param boolean $before Boolean: true -> before, false -> after */ - public function getAccountsRenewing( $days, $before = true ) + public function getAccountsRenewing( $count, $interval, $before = true ) { $curDate = date( 'Y-m-d' ); + switch ( $interval ) { + case '40': + $period = 'YEAR'; + break; + case '30': + $period = 'MONTH'; + break; + case '20': + $period = 'WEEK'; + break; + case '10': + default: + $period = 'DAY'; + break; + } return $this->wpdb->get_results( "SELECT * FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts - WHERE renewal_date + INTERVAL 1 YEAR " . ($before ? '-' : '+' ) . " INTERVAL $days DAY = '$curDate' + WHERE renewal_date + INTERVAL 1 YEAR " . ($before ? '-' : '+' ) . " INTERVAL $count $period = '$curDate' AND archived <> true", ARRAY_A ); diff --git a/models/admin/ajax/billingSetupQueue.php b/models/admin/ajax/billingSetupQueue.php index a4d1374..76738ce 100644 --- a/models/admin/ajax/billingSetupQueue.php +++ b/models/admin/ajax/billingSetupQueue.php @@ -87,7 +87,7 @@ class GlmMembersAdmin_ajax_billingSetupQueue $before = true; break; } - $accounts = $billingSupport->getAccountsRenewing( $notice['send_date_number'], $before ); + $accounts = $billingSupport->getAccountsRenewing( $notice['send_date_number'], $notice['send_date_period'], $before ); echo '
$accounts: ' . print_r( $accounts, true ) . '
'; // return false; if ( isset( $accounts ) && is_array( $accounts ) && !empty( $accounts ) ) {