Working on cron task and db update
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 25 Apr 2018 19:20:29 +0000 (15:20 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 25 Apr 2018 19:20:29 +0000 (15:20 -0400)
db update for new fields for the notification queue.
The rest is setting up the cron task for generating email notices based
on renewal dates.

15 files changed:
classes/billingSupport.php
classes/notifications.php
index.php
models/admin/ajax/billingFlagExpiredUsers.php [new file with mode: 0644]
models/admin/ajax/billingRunQueue.php [new file with mode: 0644]
models/admin/ajax/billingSetupQueue.php [new file with mode: 0644]
models/admin/ajax/flagExpired.php [deleted file]
models/admin/ajax/runQueue.php [deleted file]
models/admin/ajax/setupQueue.php [deleted file]
setup/adminHooks.php
setup/databaseScripts/create_database_V0.0.23.sql [deleted file]
setup/databaseScripts/create_database_V0.0.24.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.24.sql [new file with mode: 0644]
setup/validActions.php

index f671429..821e46a 100644 (file)
@@ -580,8 +580,9 @@ class GlmBillingSupport
         return $this->wpdb->get_results(
             "SELECT *
                FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
-              WHERE renewal_date + INTERVAL 1 YEAR " . ($before ? '-' : '+' ) . " $days DAY = '$curDate'
-                AND archived <> true"
+              WHERE renewal_date + INTERVAL 1 YEAR " . ($before ? '-' : '+' ) . " INTERVAL $days DAY = '$curDate'
+                AND archived <> true",
+            ARRAY_A
         );
     }
 
index 58fbf62..dcfa912 100644 (file)
@@ -397,6 +397,7 @@ class GlmNotifications
         $query =
         "SELECT *
            FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "notification_queue";
+        //$query = " WHERE processed_time IS NULL";
         if ( $numb = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
             $query .= " LIMIT $limit OFFSET 0";
         }
index e100a30..b5ba692 100644 (file)
--- a/index.php
+++ b/index.php
@@ -38,7 +38,7 @@
  *  version from this plugin.
  */
 define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.23');
+define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.24');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_BILLING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
diff --git a/models/admin/ajax/billingFlagExpiredUsers.php b/models/admin/ajax/billingFlagExpiredUsers.php
new file mode 100644 (file)
index 0000000..d9f79cb
--- /dev/null
@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+/**
+ * Steve Note...
+ *
+ * You can get to this using the following URL.
+ *
+ * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=setupQueue
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+// Load Members data abstract
+// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_billingFlagExpiredUsers
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    public function modelAction( $actionData = false )
+    {
+
+        echo '<pre>$actionData: ' . print_r( $actionData, true ) . '</pre>';
+        return false;
+
+        $days_after_expired = $this->config['settings']['days_after_expired'];
+        $current_date       = date( 'Y-m-d' );
+
+        // Update All expired accounts so they can only be in members only not admin.
+        // Find all member contacts (by ref_dest) with accounts that are expired.
+        // With those set their contact_role to 30 (login only)
+        if ( $days_after_expired = filter_var( $days_after_expired, FILTER_VALIDATE_INT ) ) {
+            $this->wpdb->query(
+                "UPDATE " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX. "contacts
+                    SET contact_role = 30
+                  WHERE ref_dest IN (
+                        SELECT ref_dest
+                          FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+                         WHERE renewal_date + INTERVAL 1 YEAR + INTERVAL $days_after_expired DAY <= '$current_date'
+                        )
+                    AND contact_role <> 30"
+            );
+        }
+
+        wp_die();
+    }
+}
diff --git a/models/admin/ajax/billingRunQueue.php b/models/admin/ajax/billingRunQueue.php
new file mode 100644 (file)
index 0000000..c77a936
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/notifications.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+/**
+ * Steve Note
+ *
+ * You can get to this using the following URL.
+ *
+ *
+ {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=runQueue
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+// Load Members data abstract
+// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_billingRunQueue
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    public function modelAction( $actionData = false ) {
+        $Notifications = new GlmNotifications( $this->wpdb, $this->config );
+        // Get the queue and send notices.
+        $queued = $Notifications->getQueuedNotifications();
+        echo '<pre>$queued: ' . print_r( $queued, true ) . '</pre>';
+        if ( isset( $queued ) && !empty( $queued ) ) {
+            foreach ( $queued as $queue ) {
+                $Notifications->sendEmailNotification( $queue['notification_type'], $queue['account'] );
+                $Notifications->markQueueProcessed( $queue['id'] );
+                // $Notifications->deleteQueue( $queue['id'] );
+            }
+        }
+        wp_die();
+    }
+}
diff --git a/models/admin/ajax/billingSetupQueue.php b/models/admin/ajax/billingSetupQueue.php
new file mode 100644 (file)
index 0000000..13f1dda
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/notifications.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+/**
+ * Steve Note...
+ *
+ * You can get to this using the following URL.
+ *
+ * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=setupQueue
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+// Load Members data abstract
+// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_billingSetupQueue
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+    }
+
+    public function modelAction( $actionData = false ) {
+        // Get all notifications that are done by date.
+        $Notifications = new GlmNotifications( $this->wpdb, $this->config );
+        $notifications = $Notifications->getNotificationsWithSendByDate();
+        // echo '<pre>$notifications: ' . print_r( $notifications, true ) . '</pre>';
+
+        // Get all invoices that are unpaid.
+        $billingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+
+        foreach ( $notifications as $notice ) {
+            echo '<pre>$notice: ' . print_r( $notice, true ) . '</pre>';
+            switch( $notice['send_date_period'] ) {
+            case $this->config['send_date_when_numb']['After']:
+                $before = false;
+                break;
+            case $this->config['send_date_when_numb']['Before']:
+                $before = true;
+                break;
+            }
+            $accounts = $billingSupport->getAccountsRenewing( $notice['send_date_number'], $before );
+            echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
+            if ( isset( $accounts ) && is_array( $accounts ) && !empty( $accounts ) ) {
+                foreach ( $accounts as $account ) {
+                    $Notifications->queueNotice( $notice['id'], $account['id'] );
+                }
+            }
+        }
+
+        wp_die();
+    }
+}
diff --git a/models/admin/ajax/flagExpired.php b/models/admin/ajax/flagExpired.php
deleted file mode 100644 (file)
index 3977775..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * PDF Output by admin-ajax
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @version  0.1
- */
-
-require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
-/**
- * Steve Note...
- *
- * You can get to this using the following URL.
- *
- * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=setupQueue
- *
- * You should be able to do this as POST or GET and should be able to add and read additional parameters.
- * I added a "mystuff" parameter to the URL above and it does output from the code in the
- * modelAction() function below.
- *
- * To add another model under models/admin/ajax all you need to do is create it and add it to the
- * setup/validActions.php file.
- *
- */
-
-// Load Members data abstract
-// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
-
-/**
- * This class performs the work of handling images passed to it via
- * an AJAX call that goes through the WorPress AJAX Handler.
- *
- */
-class GlmMembersAdmin_ajax_flagExpired
-{
-
-    /**
-     * WordPress Database Object
-     *
-     * @var $wpdb
-     * @access public
-     */
-    public $wpdb;
-    /**
-     * Plugin Configuration Data
-     *
-     * @var $config
-     * @access public
-     */
-    public $config;
-
-    public function __construct ($wpdb, $config)
-    {
-
-        // Save WordPress Database object
-        $this->wpdb = $wpdb;
-
-        // Save plugin configuration object
-        $this->config = $config;
-
-    }
-
-    public function modelAction( $actionData = false ) {
-
-        $currentDate = new DateTime();
-        echo '<pre>$currentDate: ' . print_r( $currentDate, true ) . '</pre>';
-
-        // Update All expired accounts so they can only be in members only not admin.
-        // TODO: Find all member contacts (by ref_dest) with accounts that are expired.
-        // With those set their contact_role to 30 (login only)
-
-
-        wp_die();
-    }
-}
diff --git a/models/admin/ajax/runQueue.php b/models/admin/ajax/runQueue.php
deleted file mode 100644 (file)
index 28e674e..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * PDF Output by admin-ajax
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @version  0.1
- */
-
-require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/notifications.php';
-require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
-/**
- * Steve Note
- *
- * You can get to this using the following URL.
- *
- *
- {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=runQueue
- *
- * You should be able to do this as POST or GET and should be able to add and read additional parameters.
- * I added a "mystuff" parameter to the URL above and it does output from the code in the
- * modelAction() function below.
- *
- * To add another model under models/admin/ajax all you need to do is create it and add it to the
- * setup/validActions.php file.
- *
- */
-
-// Load Members data abstract
-// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
-
-/**
- * This class performs the work of handling images passed to it via
- * an AJAX call that goes through the WorPress AJAX Handler.
- *
- */
-class GlmMembersAdmin_ajax_runQueue
-{
-
-    /**
-     * WordPress Database Object
-     *
-     * @var $wpdb
-     * @access public
-     */
-    public $wpdb;
-    /**
-     * Plugin Configuration Data
-     *
-     * @var $config
-     * @access public
-     */
-    public $config;
-
-    public function __construct ($wpdb, $config)
-    {
-
-        // Save WordPress Database object
-        $this->wpdb = $wpdb;
-
-        // Save plugin configuration object
-        $this->config = $config;
-
-    }
-
-    public function modelAction( $actionData = false ) {
-        $Notifications = new GlmNotifications( $this->wpdb, $this->config );
-        // Get the queue and send notices.
-        $queued = $Notifications->getQueuedNotifications();
-        echo '<pre>$queued: ' . print_r( $queued, true ) . '</pre>';
-        if ( isset( $queued ) && !empty( $queued ) ) {
-            foreach ( $queued as $queue ) {
-                $Notifications->sendEmailNotification( $queue['notification_type'], $queue['account'] );
-                $Notifications->markQueueProcessed( $queue['id'] );
-            }
-        }
-        wp_die();
-    }
-}
diff --git a/models/admin/ajax/setupQueue.php b/models/admin/ajax/setupQueue.php
deleted file mode 100644 (file)
index 9c6e0f4..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * PDF Output by admin-ajax
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @version  0.1
- */
-
-require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/notifications.php';
-require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
-/**
- * Steve Note...
- *
- * You can get to this using the following URL.
- *
- * {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=setupQueue
- *
- * You should be able to do this as POST or GET and should be able to add and read additional parameters.
- * I added a "mystuff" parameter to the URL above and it does output from the code in the
- * modelAction() function below.
- *
- * To add another model under models/admin/ajax all you need to do is create it and add it to the
- * setup/validActions.php file.
- *
- */
-
-// Load Members data abstract
-// require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php';
-
-/**
- * This class performs the work of handling images passed to it via
- * an AJAX call that goes through the WorPress AJAX Handler.
- *
- */
-class GlmMembersAdmin_ajax_setupQueue
-{
-
-    /**
-     * WordPress Database Object
-     *
-     * @var $wpdb
-     * @access public
-     */
-    public $wpdb;
-    /**
-     * Plugin Configuration Data
-     *
-     * @var $config
-     * @access public
-     */
-    public $config;
-
-    public function __construct ($wpdb, $config)
-    {
-
-        // Save WordPress Database object
-        $this->wpdb = $wpdb;
-
-        // Save plugin configuration object
-        $this->config = $config;
-
-    }
-
-    public function modelAction( $actionData = false ) {
-        // Get all notifications that are done by date.
-        $Notifications = new GlmNotifications( $this->wpdb, $this->config );
-        $notifications = $Notifications->getNotificationsWithSendByDate();
-        echo '<pre>$notifications: ' . print_r( $notifications, true ) . '</pre>';
-
-        // Get all invoices that are unpaid.
-        $billingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
-        //$unpaid_invoices = $billingSupport->getUnPaidInvoices();
-        //echo '<pre>$unpaid_invoices: ' . print_r( $unpaid_invoices, true ) . '</pre>';
-
-        foreach ( $notifications as $notice ) {
-            echo '<pre>$notice: ' . print_r( $notice, true ) . '</pre>';
-            switch( $notice['send_date_period'] ) {
-            case $this->config['send_date_when_numb']['After']:
-                $before = false;
-                break;
-            case $this->config['send_date_when_numb']['Before']:
-                $before = true;
-                break;
-            }
-            $accounts = $billingSupport->getAccountsRenewing( $notice['send_date_number'], $before );
-            echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
-        }
-
-        // Loop through the invoices and for each one see if any notices are to be sent out.
-        $currentDate = new DateTime();
-        echo '<pre>$currentDate: ' . print_r( $currentDate, true ) . '</pre>';
-        // foreach ( $unpaid_invoices as $invoice ) {
-        //     $due_date = $invoice['due_date'];
-        //
-        //     // Loop through the notifications and see if this unpaid one is due.
-        //     foreach ( $notifications as $notice ) {
-        //         // Need due date set in this loop each time.
-        //         $dueDate = new DateTime( $due_date );
-        //         // Is this before or after
-        //         switch ( $notice['send_date_when'] ) {
-        //         case $this->config['send_date_when_numb']['Before']:
-        //             echo '<p>Before</p>';
-        //             $dueDate->modify(
-        //                 '-' . $notice['send_date_number'] . ' '.
-        //                 $this->config['send_date_period'][$notice['send_date_period']] .
-        //                 (($notice['send_date_number'] > 1) ? 's': '')
-        //             );
-        //             echo '<pre>$dueDate: ' . print_r( $dueDate, true ) . '</pre>';
-        //             $diff = $dueDate->diff( $currentDate );
-        //             // When the diff is 0 days then the notice needs to go out.
-        //
-        //             $days_from = $diff->format( '%a' );
-        //             echo '<pre>$days_from: ' . print_r( $days_from, true ) . '</pre>';
-        //             // Check to see if this date occurs today.
-        //             if ( $days_from === '0' ) {
-        //                 // Add the notice id and account id to the queue
-        //                 $Notifications->queueNotice( $notice['id'], $invoice['account'] );
-        //             }
-        //
-        //             break;
-        //         case $this->config['send_date_when_numb']['After']:
-        //             echo '<p>After</p>';
-        //             $dueDate->modify(
-        //                 '+' . $notice['send_date_number'] . ' '.
-        //                 $this->config['send_date_period'][$notice['send_date_period']] .
-        //                 (($notice['send_date_number'] > 1) ? 's': '')
-        //             );
-        //             echo '<pre>$dueDate: ' . print_r( $dueDate, true ) . '</pre>';
-        //             $diff = $dueDate->diff( $currentDate );
-        //             $days_from = $diff->format( '%a' );
-        //             echo '<pre>$days_from: ' . print_r( $days_from, true ) . '</pre>';
-        //             // Check to see if this date occurs today.
-        //             if ( $days_from === '0' ) {
-        //                 // Create the notice email
-        //                 $Notifications->queueNotice( $notice['id'], $invoice['account'] );
-        //             }
-        //             break;
-        //         default:
-        //             break;
-        //         }
-        //     }
-        // }
-
-        wp_die();
-    }
-}
index cacc7c5..07c3e08 100644 (file)
@@ -33,3 +33,51 @@ add_filter(
     9,
     1
 );
+
+// add_filter(
+//     'glm_associate_cron_request',
+//     function( $cron_task ){
+//         $new_cron = array(
+//             array(
+//                 'menu'       => 'ajax',
+//                 'action'     => 'billingFlagExpiredUsers',
+//                 'daysOfWeek' => range( 1, 7 ),
+//                 'times'      => range( 1, 24 ),
+//                 'params'     => array()
+//             )
+//         );
+//         return array_merge( $cron_task, $new_cron );
+//     }
+// );
+
+// add_filter(
+//     'glm_associate_cron_request',
+//     function( $cron_task ) {
+//         $new_cron = array(
+//             array(
+//                 'menu'       => 'ajax',
+//                 'action'     => 'billingSetupQueue',
+//                 'daysOfWeek' => range( 1, 7 ),
+//                 'times'      => range( 1, 24 ),
+//                 'params'     => array()
+//             )
+//         );
+//         return array_merge( $cron_task, $new_cron );
+//     }
+// );
+
+// add_filter(
+//     'glm_associate_cron_request',
+//     function( $cron_task ) {
+//         $new_cron = array(
+//             array(
+//                 'menu'       => 'ajax',
+//                 'action'     => 'billingRunQueue',
+//                 'daysOfWeek' => range( 1, 7 ),
+//                 'times'      => range( 1, 24 ),
+//                 'params'     => array()
+//             )
+//         );
+//         return array_merge( $cron_task, $new_cron );
+//     }
+// );
diff --git a/setup/databaseScripts/create_database_V0.0.23.sql b/setup/databaseScripts/create_database_V0.0.23.sql
deleted file mode 100644 (file)
index 170c7af..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
--- Gaslight Media Billing Module
--- File Created: 11/08/2017
--- Database Version: 0.0.23
--- Database Creation Script
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
---
--- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
---
-
--- Billing Accounts
-CREATE TABLE {prefix}accounts (
-    id INT NOT NULL AUTO_INCREMENT,
-    archived BOOLEAN DEFAULT '0',                          -- Marks account as archived
-    ref_dest INT NOT NULL,                                 -- reference to member id
-    ref_name TINYTEXT NOT NULL,                            -- Name of reference member
-    invoice_type INT NOT NULL DEFAULT '0',                 -- Ref to Invoice Type id
-    billing_fname TINYTEXT NULL,                           -- Billing First Name
-    billing_lname TINYTEXT NULL,                           -- Billing Last Name
-    billing_addr1 TINYTEXT NULL,                           -- Billing Address 1
-    billing_addr2 TINYTEXT NULL,                           -- Billing Address 2
-    billing_city TINYTEXT NULL,                            -- Billing City
-    billing_state TINYTEXT NULL,                           -- Billing State
-    billing_zip TINYTEXT NULL,                             -- Billing Zip
-    billing_phone TINYTEXT NULL,                           -- Billing Phone
-    anniversary_date DATE NOT NULL,                        -- anniversary date - used for main invoice generation
-    renewal_date DATE NULL,                                -- renewal date of account
-    payment_data TEXT NULL,                                -- stored payment data
-    customer_profile_id TINYTEXT NULL,                     -- Customer Profile Id (Authorize.net)
-    payment_profile_id TINYTEXT NULL,                      -- Payment Profile Id (Authorize.net)
-    payment_profile_card TINYTEXT NULL,                    -- Payment Profile Card (Authorize.net)
-    email TINYTEXT NULL,                                   -- billing email
-    boss BOOLEAN DEFAULT '0',                              -- Boss flag
-    PRIMARY KEY (id),
-    INDEX(ref_dest),
-    INDEX(ref_name(20)),
-    INDEX(email(20)),
-    INDEX(invoice_type),
-    INDEX(renewal_date)
-);
-
-----
-
--- transactions
-CREATE TABLE {prefix}transactions (
-    id INT NOT NULL AUTO_INCREMENT,
-    type INT NOT NULL,                                     -- type of transaction (payment,invoice,etc)
-    type_id INT NOT NULL,                                  -- reference to type id
-    account INT NOT NULL,                                  -- reference to account id
-    transaction_time DATETIME NOT NULL,                    -- datetime for the transaction
-    current_invoice_total DECIMAL(8, 2) NOT NULL,          -- invoice total
-    current_payment_total DECIMAL(8, 2) NOT NULL,          -- payment total
-    PRIMARY KEY (id),
-    INDEX(account),
-    INDEX(type_id),
-    INDEX(transaction_time)
-);
-
-----
-
--- Invoices
-CREATE TABLE {prefix}invoices (
-    id INT NOT NULL AUTO_INCREMENT,
-    transaction_time DATETIME NOT NULL,                    -- datetime for the invoice
-    account INT NOT NULL,                                  -- ref to account id
-    amount_total DECIMAL(8, 2) NOT NULL,                   -- total amount for invoice
-    balance DECIMAL(8, 2) NOT NULL,                        -- balance for this invoice
-    due_date DATE NOT NULL,                                -- Due date for this invoice
-    paid BOOLEAN DEFAULT '0',                              -- true/false if invoice is paid
-    notes TINYTEXT,                                        -- notes for this invoice
-    renewal BOOLEAN DEFAULT '0',                           -- true/false if a renewal
-    recurring BOOLEAN DEFAULT '0',                         -- true/false if recurring
-    recurrence INT NULL DEFAULT 0,                         -- recurrence type
-    PRIMARY KEY (id),
-    INDEX(account),
-    INDEX(transaction_time),
-    INDEX(due_date)
-);
-
-----
-
--- Line Item Types
-CREATE TABLE {prefix}invoice_types (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TINYTEXT NOT NULL,                                -- name
-    parent INT NOT NULL DEFAULT 0,                         -- 0 if top level otherwise ref to another line_item_type as it's parent
-    member_type INT NOT NULL DEFAULT 0,                    -- Member Type assigned Default 0
-    amount DECIMAL(8,2) NOT NULL DEFAULT '0.00',           -- amount
-    recurring BOOLEAN DEFAULT '0',                         -- true/false if recurring
-    recurrence INT NULL DEFAULT 0,                         -- recurrence type
-    PRIMARY KEY (id)
-);
-
-----
-
--- Line Items
-CREATE TABLE {prefix}line_items (
-    id INT NOT NULL AUTO_INCREMENT,
-    invoice INT NOT NULL,                                  -- reference to invoice
-    line_item_type INT NOT NULL,                           -- reference to line item type
-    account INT NULL DEFAULT 0,                            -- ref to account id (renewal or employee)
-    name TEXT NOT NULL,                                    -- line item name
-    amount DECIMAL(8,2) DEFAULT '0.00',                    -- line item amount per item
-    quantity INT DEFAULT 1,                                -- quantity
-    total DECIMAL(8,2) DEFAULT '0.00',                     -- line item total
-    recurring BOOLEAN DEFAULT '0',                         -- true/false if recurring
-    recurrence INT NULL DEFAULT 0,                         -- recurrence type
-    created DATE NULL,                                     -- Date this line item was first created
-    first_due_date DATE NULL,                              -- The first due date for this item
-    next_due_date DATE NULL,                               -- Next Due Date for this item
-    PRIMARY KEY (id),
-    INDEX(account),
-    INDEX(created),
-    INDEX(first_due_date),
-    INDEX(next_due_date)
-);
-
-----
-
--- payments
-CREATE TABLE {prefix}payments (
-    id INT NOT NULL AUTO_INCREMENT,
-    transaction_time DATETIME NOT NULL,                    -- datetime of payment
-    account INT NOT NULL,                                  -- ref to account table
-    amount DECIMAL(8, 2) NOT NULL,                         -- payment amount
-    payment_method TINYTEXT NOT NULL,                      -- payment method
-    payment_data TINYTEXT NULL,                            -- additional payment info
-    PRIMARY KEY (id)
-);
-
-----
-
--- pdfs
-CREATE TABLE {prefix}pdfs (
-    id INT NOT NULL AUTO_INCREMENT,
-    ref_type INT NOT NULL,                                 -- reference type
-    ref_dest INT NOT NULL,                                 -- reference types id
-    pdf MEDIUMTEXT NOT NULL,                               -- saved pdf
-    PRIMARY KEY (id)
-);
-
-----
-
--- Notification Types
-CREATE TABLE {prefix}notification_types (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TINYTEXT NOT NULL,                                -- name
-    from_header TINYTEXT NOT NULL,                         -- from headers
-    replyto TINYTEXT NULL,                                 -- reply-to headers
-    subject TINYTEXT NOT NULL,                             -- Subject
-    message TEXT NOT NULL,                                 -- Message
-    send_by_date BOOLEAN NULL DEFAULT '0',                 -- true/false send by date based on due date
-    send_by_action BOOLEAN NULL DEFAULT '0',               -- send notice based on an action
-    send_action INT NULL DEFAULT 0,                        -- (create invoice or receive payment)
-    send_date_number INT NULL DEFAULT 0,                   -- number to apply to send by date
-    send_date_period INT NULL DEFAULT 0,                   -- (days,weeks,months,years)
-    send_date_when INT NULL DEFAULT 0,                     -- (before or after)
-    PRIMARY KEY (id)
-);
-
-----
-
--- Notifications
-CREATE TABLE {prefix}notifications (
-    id INT NOT NULL AUTO_INCREMENT,
-    notification_type INT NOT NULL,                        -- ref to notification type
-    account INT NOT NULL,                                  -- ref to account
-    from_replyto TINYTEXT NOT NULL,                        -- from reply-to header
-    subject TEXT NOT NULL,                                 -- subject
-    message TEXT NOT NULL,                                 -- message
-    date_sent DATETIME NOT NULL,                           -- Date the notice was sent
-    email_sent TINYTEXT NOT NULL,                          -- email used
-    PRIMARY KEY (id)
-);
-
-----
-
--- Notification Queue
-CREATE TABLE {prefix}notification_queue (
-    id INT NOT NULL AUTO_INCREMENT,
-    notification_type INT NOT NULL,                        -- ref to notification type
-    account INT NOT NULL,                                  -- ref to account
-    PRIMARY KEY (id)
-);
-
-----
-
--- Gateway Settings
-CREATE TABLE {prefix}gateway_settings (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TEXT NOT NULL,
-    login_id TINYTEXT NOT NULL,
-    transaction_key TINYTEXT NOT NULL,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Invoice Payments
-CREATE TABLE {prefix}invoice_payments (
-    id INT NOT NULL AUTO_INCREMENT,
-    invoice INT NOT NULL,                                  -- reference to invoice id
-    payment INT NOT NULL,                                  -- reference to payment id
-    amount DECIMAL(8, 2) NOT NULL,                         -- payment amount
-    PRIMARY KEY (id),
-    INDEX(invoice)
-);
-
-----
-
--- Settings
-CREATE TABLE {prefix}settings (
-    id INT NOT NULL AUTO_INCREMENT,
-    company_logo TINYTEXT NULL,                            -- Image logo
-    company_logo_height INT NULL,                          -- Logo Height (only used if creating pdf)
-    company_name TINYTEXT NULL,                            -- Company Name
-    company_name2 TINYTEXT NULL,                           -- Company Name 2
-    company_addr1 TINYTEXT NULL,                           -- Company Address 1
-    company_addr2 TINYTEXT NULL,                           -- Company Address 2
-    company_city TINYTEXT NULL,                            -- Company City
-    company_state TINYTEXT NULL,                           -- Company State
-    company_zip TINYTEXT NULL,                             -- Company Zip
-    company_phone TINYTEXT NULL,                           -- Company Phone
-    company_email TINYTEXT NULL,                           -- Company Email
-    company_url TINYTEXT NULL,                             -- Company URL
-    payment_terms TEXT NULL,                               -- Payment Terms
-    days_before_renewal INT NULL,                          -- Number of days before renewal date to allow renewals
-    days_after_expired INT NULL,                           -- Number of days after renewal date expired
-    allow_membership_choice BOOLEAN DEFAULT '0',           -- If memberships can choose their membership levels when they renew
-    allow_employees BOOLEAN DEFAULT '0',                   -- If memberships have employees
-    PRIMARY KEY (id)
-);
-
-----
-
--- Set default billing Settings entry
-INSERT INTO {prefix}settings
-    ( id, days_before_renewal ,days_after_expired )
-    VALUES
-    ( 1, 90, 30 );
-
-----
-
--- Management
-CREATE TABLE {prefix}management (
-    id INT NOT NULL AUTO_INCREMENT,
-    payment_methods SMALLINT NULL,                              -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini
-    proc_methods SMALLINT NULL,                                 -- Credit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini
-    cc_accepts SMALLINT NULL,                                   -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini
-    -- Authorize.net Credentials
-    authorize_net_login TINYTEXT NULL,
-    authorize_net_key TINYTEXT NULL,
-    authorize_net_test TINYINT NULL,                            -- Authorize.net test mode - List - see proc_test_mode in plugin.ini
-    authorize_net_conf BOOLEAN NULL,                            -- Flag to send payment confirmation Email from Authorize.net
-    authorize_net_merchant_email TINYTEXT NULL,                 -- E-Mail Authorize.net will send copy of confirmation E-Mail
-    -- Merchant Solutions Credentials
-    merchant_solutions_acctid TINYTEXT NULL,                    -- Merchant Solutions credentials
-    merchant_solutions_merchantpin TINYTEXT NULL,
-    merchant_solutions_test TINYINT NULL,                       -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini
-    merchant_solutions_conf BOOLEAN NULL,                       -- Flag to send payment confirmation Email
-    merchant_solutions_merchant_email TINYTEXT NULL,            -- Merchant Solutions will send copy of confirmation E-Mail
-    PRIMARY KEY (id)
-);
-
-----
-
--- Set default billing Management entry
-INSERT INTO {prefix}management
-    ( id )
-    VALUES
-    ( 1 );
-
-----
-
--- Employees table
-CREATE TABLE {prefix}employees (
-    id INT NOT NULL AUTO_INCREMENT,
-    account INT NOT NULL,                                     -- Account Id
-    employee INT NOT NULL,                                     -- Employee Account Id
-    PRIMARY KEY (id)
-);
diff --git a/setup/databaseScripts/create_database_V0.0.24.sql b/setup/databaseScripts/create_database_V0.0.24.sql
new file mode 100644 (file)
index 0000000..e8fec7f
--- /dev/null
@@ -0,0 +1,288 @@
+-- Gaslight Media Billing Module
+-- File Created: 11/08/2017
+-- Database Version: 0.0.24
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+--
+-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
+--
+
+-- Billing Accounts
+CREATE TABLE {prefix}accounts (
+    id INT NOT NULL AUTO_INCREMENT,
+    archived BOOLEAN DEFAULT '0',                          -- Marks account as archived
+    ref_dest INT NOT NULL,                                 -- reference to member id
+    ref_name TINYTEXT NOT NULL,                            -- Name of reference member
+    invoice_type INT NOT NULL DEFAULT '0',                 -- Ref to Invoice Type id
+    billing_fname TINYTEXT NULL,                           -- Billing First Name
+    billing_lname TINYTEXT NULL,                           -- Billing Last Name
+    billing_addr1 TINYTEXT NULL,                           -- Billing Address 1
+    billing_addr2 TINYTEXT NULL,                           -- Billing Address 2
+    billing_city TINYTEXT NULL,                            -- Billing City
+    billing_state TINYTEXT NULL,                           -- Billing State
+    billing_zip TINYTEXT NULL,                             -- Billing Zip
+    billing_phone TINYTEXT NULL,                           -- Billing Phone
+    anniversary_date DATE NOT NULL,                        -- anniversary date - used for main invoice generation
+    renewal_date DATE NULL,                                -- renewal date of account
+    payment_data TEXT NULL,                                -- stored payment data
+    customer_profile_id TINYTEXT NULL,                     -- Customer Profile Id (Authorize.net)
+    payment_profile_id TINYTEXT NULL,                      -- Payment Profile Id (Authorize.net)
+    payment_profile_card TINYTEXT NULL,                    -- Payment Profile Card (Authorize.net)
+    email TINYTEXT NULL,                                   -- billing email
+    boss BOOLEAN DEFAULT '0',                              -- Boss flag
+    PRIMARY KEY (id),
+    INDEX(ref_dest),
+    INDEX(ref_name(20)),
+    INDEX(email(20)),
+    INDEX(invoice_type),
+    INDEX(renewal_date)
+);
+
+----
+
+-- transactions
+CREATE TABLE {prefix}transactions (
+    id INT NOT NULL AUTO_INCREMENT,
+    type INT NOT NULL,                                     -- type of transaction (payment,invoice,etc)
+    type_id INT NOT NULL,                                  -- reference to type id
+    account INT NOT NULL,                                  -- reference to account id
+    transaction_time DATETIME NOT NULL,                    -- datetime for the transaction
+    current_invoice_total DECIMAL(8, 2) NOT NULL,          -- invoice total
+    current_payment_total DECIMAL(8, 2) NOT NULL,          -- payment total
+    PRIMARY KEY (id),
+    INDEX(account),
+    INDEX(type_id),
+    INDEX(transaction_time)
+);
+
+----
+
+-- Invoices
+CREATE TABLE {prefix}invoices (
+    id INT NOT NULL AUTO_INCREMENT,
+    transaction_time DATETIME NOT NULL,                    -- datetime for the invoice
+    account INT NOT NULL,                                  -- ref to account id
+    amount_total DECIMAL(8, 2) NOT NULL,                   -- total amount for invoice
+    balance DECIMAL(8, 2) NOT NULL,                        -- balance for this invoice
+    due_date DATE NOT NULL,                                -- Due date for this invoice
+    paid BOOLEAN DEFAULT '0',                              -- true/false if invoice is paid
+    notes TINYTEXT,                                        -- notes for this invoice
+    renewal BOOLEAN DEFAULT '0',                           -- true/false if a renewal
+    recurring BOOLEAN DEFAULT '0',                         -- true/false if recurring
+    recurrence INT NULL DEFAULT 0,                         -- recurrence type
+    PRIMARY KEY (id),
+    INDEX(account),
+    INDEX(transaction_time),
+    INDEX(due_date)
+);
+
+----
+
+-- Line Item Types
+CREATE TABLE {prefix}invoice_types (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NOT NULL,                                -- name
+    parent INT NOT NULL DEFAULT 0,                         -- 0 if top level otherwise ref to another line_item_type as it's parent
+    member_type INT NOT NULL DEFAULT 0,                    -- Member Type assigned Default 0
+    amount DECIMAL(8,2) NOT NULL DEFAULT '0.00',           -- amount
+    recurring BOOLEAN DEFAULT '0',                         -- true/false if recurring
+    recurrence INT NULL DEFAULT 0,                         -- recurrence type
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Line Items
+CREATE TABLE {prefix}line_items (
+    id INT NOT NULL AUTO_INCREMENT,
+    invoice INT NOT NULL,                                  -- reference to invoice
+    line_item_type INT NOT NULL,                           -- reference to line item type
+    account INT NULL DEFAULT 0,                            -- ref to account id (renewal or employee)
+    name TEXT NOT NULL,                                    -- line item name
+    amount DECIMAL(8,2) DEFAULT '0.00',                    -- line item amount per item
+    quantity INT DEFAULT 1,                                -- quantity
+    total DECIMAL(8,2) DEFAULT '0.00',                     -- line item total
+    recurring BOOLEAN DEFAULT '0',                         -- true/false if recurring
+    recurrence INT NULL DEFAULT 0,                         -- recurrence type
+    created DATE NULL,                                     -- Date this line item was first created
+    first_due_date DATE NULL,                              -- The first due date for this item
+    next_due_date DATE NULL,                               -- Next Due Date for this item
+    PRIMARY KEY (id),
+    INDEX(account),
+    INDEX(created),
+    INDEX(first_due_date),
+    INDEX(next_due_date)
+);
+
+----
+
+-- payments
+CREATE TABLE {prefix}payments (
+    id INT NOT NULL AUTO_INCREMENT,
+    transaction_time DATETIME NOT NULL,                    -- datetime of payment
+    account INT NOT NULL,                                  -- ref to account table
+    amount DECIMAL(8, 2) NOT NULL,                         -- payment amount
+    payment_method TINYTEXT NOT NULL,                      -- payment method
+    payment_data TINYTEXT NULL,                            -- additional payment info
+    PRIMARY KEY (id)
+);
+
+----
+
+-- pdfs
+CREATE TABLE {prefix}pdfs (
+    id INT NOT NULL AUTO_INCREMENT,
+    ref_type INT NOT NULL,                                 -- reference type
+    ref_dest INT NOT NULL,                                 -- reference types id
+    pdf MEDIUMTEXT NOT NULL,                               -- saved pdf
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Notification Types
+CREATE TABLE {prefix}notification_types (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NOT NULL,                                -- name
+    from_header TINYTEXT NOT NULL,                         -- from headers
+    replyto TINYTEXT NULL,                                 -- reply-to headers
+    subject TINYTEXT NOT NULL,                             -- Subject
+    message TEXT NOT NULL,                                 -- Message
+    send_by_date BOOLEAN NULL DEFAULT '0',                 -- true/false send by date based on due date
+    send_by_action BOOLEAN NULL DEFAULT '0',               -- send notice based on an action
+    send_action INT NULL DEFAULT 0,                        -- (create invoice or receive payment)
+    send_date_number INT NULL DEFAULT 0,                   -- number to apply to send by date
+    send_date_period INT NULL DEFAULT 0,                   -- (days,weeks,months,years)
+    send_date_when INT NULL DEFAULT 0,                     -- (before or after)
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Notifications
+CREATE TABLE {prefix}notifications (
+    id INT NOT NULL AUTO_INCREMENT,
+    notification_type INT NOT NULL,                        -- ref to notification type
+    account INT NOT NULL,                                  -- ref to account
+    from_replyto TINYTEXT NOT NULL,                        -- from reply-to header
+    subject TEXT NOT NULL,                                 -- subject
+    message TEXT NOT NULL,                                 -- message
+    date_sent DATETIME NOT NULL,                           -- Date the notice was sent
+    email_sent TINYTEXT NOT NULL,                          -- email used
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Notification Queue
+CREATE TABLE {prefix}notification_queue (
+    id INT NOT NULL AUTO_INCREMENT,
+    notification_type INT NOT NULL,                        -- ref to notification type
+    account INT NOT NULL,                                  -- ref to account
+    queued_time DATETIME NOT NULL,                         -- Creation time
+    processed_time DATETIME NULL,                          -- The time this queue was processed. (sent out)
+    PRIMARY KEY (id),
+    INDEX (notification_type),
+    INDEX (account),
+    INDEX (queued_time),
+    INDEX (processed_time)
+);
+
+----
+
+-- Gateway Settings
+CREATE TABLE {prefix}gateway_settings (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TEXT NOT NULL,
+    login_id TINYTEXT NOT NULL,
+    transaction_key TINYTEXT NOT NULL,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Invoice Payments
+CREATE TABLE {prefix}invoice_payments (
+    id INT NOT NULL AUTO_INCREMENT,
+    invoice INT NOT NULL,                                  -- reference to invoice id
+    payment INT NOT NULL,                                  -- reference to payment id
+    amount DECIMAL(8, 2) NOT NULL,                         -- payment amount
+    PRIMARY KEY (id),
+    INDEX(invoice)
+);
+
+----
+
+-- Settings
+CREATE TABLE {prefix}settings (
+    id INT NOT NULL AUTO_INCREMENT,
+    company_logo TINYTEXT NULL,                            -- Image logo
+    company_logo_height INT NULL,                          -- Logo Height (only used if creating pdf)
+    company_name TINYTEXT NULL,                            -- Company Name
+    company_name2 TINYTEXT NULL,                           -- Company Name 2
+    company_addr1 TINYTEXT NULL,                           -- Company Address 1
+    company_addr2 TINYTEXT NULL,                           -- Company Address 2
+    company_city TINYTEXT NULL,                            -- Company City
+    company_state TINYTEXT NULL,                           -- Company State
+    company_zip TINYTEXT NULL,                             -- Company Zip
+    company_phone TINYTEXT NULL,                           -- Company Phone
+    company_email TINYTEXT NULL,                           -- Company Email
+    company_url TINYTEXT NULL,                             -- Company URL
+    payment_terms TEXT NULL,                               -- Payment Terms
+    days_before_renewal INT NULL,                          -- Number of days before renewal date to allow renewals
+    days_after_expired INT NULL,                           -- Number of days after renewal date expired
+    allow_membership_choice BOOLEAN DEFAULT '0',           -- If memberships can choose their membership levels when they renew
+    allow_employees BOOLEAN DEFAULT '0',                   -- If memberships have employees
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Set default billing Settings entry
+INSERT INTO {prefix}settings
+    ( id, days_before_renewal ,days_after_expired )
+    VALUES
+    ( 1, 90, 30 );
+
+----
+
+-- Management
+CREATE TABLE {prefix}management (
+    id INT NOT NULL AUTO_INCREMENT,
+    payment_methods SMALLINT NULL,                              -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini
+    proc_methods SMALLINT NULL,                                 -- Credit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini
+    cc_accepts SMALLINT NULL,                                   -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini
+    -- Authorize.net Credentials
+    authorize_net_login TINYTEXT NULL,
+    authorize_net_key TINYTEXT NULL,
+    authorize_net_test TINYINT NULL,                            -- Authorize.net test mode - List - see proc_test_mode in plugin.ini
+    authorize_net_conf BOOLEAN NULL,                            -- Flag to send payment confirmation Email from Authorize.net
+    authorize_net_merchant_email TINYTEXT NULL,                 -- E-Mail Authorize.net will send copy of confirmation E-Mail
+    -- Merchant Solutions Credentials
+    merchant_solutions_acctid TINYTEXT NULL,                    -- Merchant Solutions credentials
+    merchant_solutions_merchantpin TINYTEXT NULL,
+    merchant_solutions_test TINYINT NULL,                       -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini
+    merchant_solutions_conf BOOLEAN NULL,                       -- Flag to send payment confirmation Email
+    merchant_solutions_merchant_email TINYTEXT NULL,            -- Merchant Solutions will send copy of confirmation E-Mail
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Set default billing Management entry
+INSERT INTO {prefix}management
+    ( id )
+    VALUES
+    ( 1 );
+
+----
+
+-- Employees table
+CREATE TABLE {prefix}employees (
+    id INT NOT NULL AUTO_INCREMENT,
+    account INT NOT NULL,                                     -- Account Id
+    employee INT NOT NULL,                                     -- Employee Account Id
+    PRIMARY KEY (id)
+);
index 0975228..964fb44 100644 (file)
@@ -37,5 +37,6 @@ $glmMembersBillingDbVersions = array(
     '0.0.21' => array('version' => '0.0.21', 'tables' => 15),
     '0.0.22' => array('version' => '0.0.22', 'tables' => 15),
     '0.0.23' => array('version' => '0.0.23', 'tables' => 15),
+    '0.0.24' => array('version' => '0.0.24', 'tables' => 15),
 );
 
diff --git a/setup/databaseScripts/update_database_V0.0.24.sql b/setup/databaseScripts/update_database_V0.0.24.sql
new file mode 100644 (file)
index 0000000..c50335f
--- /dev/null
@@ -0,0 +1,34 @@
+-- Gaslight Media Billing Database
+-- File Created: 04/25/2018
+-- Database Version: 0.0.24
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Add queued_time field to notification_queue table
+ALTER TABLE {prefix}notification_queue ADD queued_time DATETIME NOT NULL;        -- Creation time
+
+----
+
+-- Add processed_time field to notification_queue table
+ALTER TABLE {prefix}notification_queue ADD processed_time DATETIME NOT NULL;     -- Processed time
+
+----
+
+-- Add index for notification_type
+CREATE INDEX queue_noticification_type ON {prefix}notification_queue (notification_type);
+
+----
+
+-- Add index for account
+CREATE INDEX queue_account ON {prefix}notification_queue (account);
+
+----
+
+-- Add index for queue time
+CREATE INDEX queue_queued_time ON {prefix}notification_queue (queued_time);
+
+----
+
+-- Add index for processed time
+CREATE INDEX queue_processed_time ON {prefix}notification_queue (processed_time);
index 2419d94..e0b1806 100644 (file)
 $glmMembersBillingAddOnValidActions = array(
     'adminActions' => array(
         'ajax' => array(
-            'setupQueue'         => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'runQueue'           => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'billingAccount'     => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'invoices'           => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'invoiceTypes'       => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'createNewInvoices'  => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'accountsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
-            'paymentsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'billingSetupQueue'       => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'billingRunQueue'         => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'billingAccount'          => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'invoices'                => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'invoiceTypes'            => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'createNewInvoices'       => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'accountsListExport'      => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'paymentsListExport'      => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+            'billingFlagExpiredUsers' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
         ),
         'management' => array(
             'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,