WIP for notifirations
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Dec 2017 21:59:01 +0000 (16:59 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Dec 2017 21:59:01 +0000 (16:59 -0500)
For sending out emails.

classes/billingSupport.php
classes/notifications.php [new file with mode: 0644]
models/admin/settings/notificationTypes.php
views/admin/settings/notificationTypes.html

index 1848d6e..f78da34 100644 (file)
@@ -6,10 +6,10 @@
  * PHP version 5.5
  *
  * @category glmWordPressPlugin
- * @package  glmMembersDatabase
+ * @package  glmBilling
  * @author   Chuck Scott <cscott@gaslightmedia.com>
  * @license  http://www.gaslightmedia.com Gaslightmedia
- * @release  registratiosnSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @release  billingSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
  * @link     http://dev.gaslightmedia.com/
  */
 
@@ -37,20 +37,12 @@ class GlmBillingSupport
      * @access public
      */
     public $config;
-    /**
-     * Billing Request Cart
-     *
-     * $var $cart
-     * @access public
-     */
-    public $cart = false;
 
     /**
      * Constructor
      *
      * @param object $d database connection
      * @param array $config Configuration array
-     * @param bool $limitedEdit Flag to say indicate limited edit requested
      *
      * @return void
      * @access public
@@ -300,6 +292,28 @@ class GlmBillingSupport
         );
     }
 
+    /**
+     * getAccountById
+     *
+     * Grab the account data using the account id.
+     *
+     * @param mixed $account
+     * @access public
+     * @return void
+     */
+    public function getAccountById( $account )
+    {
+        return $this->wpdb->get_row(
+            $this->wpdb->prepare(
+                "SELECT *
+                   FROM "  . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts
+                  WHERE id = %d",
+                $account
+            ),
+            ARRAY_A
+        );
+    }
+
     /**
      * getTransactionsByAccount
      *
diff --git a/classes/notifications.php b/classes/notifications.php
new file mode 100644 (file)
index 0000000..09461a6
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+/**
+ * Gaslight Media Associate
+ * Billings Plugin support class
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmBilling
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  notifications.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+
+class GlmNotifications
+{
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+
+    /**
+     * Constructor
+     *
+     * @param object $d database connection
+     * @param array $config Configuration array
+     *
+     * @return void
+     * @access public
+     */
+    public function __construct($wpdb, $config)
+    {
+
+        // If this class is not being extended along with existing $wpdb and $config
+        if (!$this->wpdb) {
+
+            // Save WordPress Database object
+            $this->wpdb = $wpdb;
+
+            // Save plugin configuration object
+            $this->config = $config;
+
+        }
+
+    }
+
+    /**
+     * sendEmailNotification
+     *
+     * Send out the email notification based on type and the account.
+     *
+     * @param mixed $notification_type Id for notification type.
+     * @param mixed $account           Id for the account.
+     *
+     * @access public
+     * @return void
+     */
+    public function sendEmailNotification( $notification_type, $account )
+    {
+        // Support Class
+        $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+        // get the Account
+        $account = $BillingSupport->getAccountById( $account );
+        echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+
+        // get the Notification type
+        $notification_type = $this->getNotificationTypeById( $notification_type );
+        echo '<pre>$notification_type: ' . print_r( $notification_type, true ) . '</pre>';
+
+    }
+
+    /**
+     * getNotificationTypeById
+     *
+     * Grab the notification type based on the id.
+     *
+     * @param mixed $id Id of the notification_type
+     *
+     * @access public
+     * @return void
+     */
+    public function getNotificationTypeById( $id )
+    {
+        return $this->wpdb->get_row(
+            $this->wpdb->prepare(
+                "SELECT *
+                   FROM "  . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX .  "notification_types
+                  WHERE id = %d",
+                $id
+            ),
+            ARRAY_A
+        );
+    }
+
+}
index 521ee6f..b38a153 100644 (file)
@@ -143,6 +143,15 @@ class GlmMembersAdmin_settings_notificationTypes extends GlmDataNotificationType
         }
 
         switch($_REQUEST['option']) {
+        case 'test':
+            echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+            require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH .  '/notifications.php';
+            $Notifications = new GlmNotifications( $this->wpdb, $this->config );
+            $notification_id = 5;
+            $account = 1;
+            $Notifications->sendEmailNotification( $notification_id, $account );
+            wp_die('Testing here');
+            break;
         case 'add':
             $notification = $this->newEntry();
             $view = 'editNotificationType';
index 38140a6..bf98d1b 100644 (file)
     <thead>
         <tr>
             <th>ID</th>
+            <th> </th>
             <th>Notification</th>
             <th>Subject</th>
             <th>Trigger</th>
                     <tr class="alternate">
                 {/if}
                     <td>{$t.id}</td>
+                    <td>
+                        <a href="{$thisUrl}?page={$thisPage}&glm_action=notificationTypes&option=test&id={$t.id}">Test</a>
+                    </td>
                     <td>
                         <div>
                             <a