From: Steve Sutton Date: Tue, 12 Dec 2017 21:59:01 +0000 (-0500) Subject: WIP for notifirations X-Git-Tag: v1.0.0^2~195 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=aa48b7bf82d52c078f2e15566cdd04db921c9ff8;p=WP-Plugins%2Fglm-member-db-billing.git WIP for notifirations For sending out emails. --- diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 1848d6e..f78da34 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -6,10 +6,10 @@ * PHP version 5.5 * * @category glmWordPressPlugin - * @package glmMembersDatabase + * @package glmBilling * @author Chuck Scott * @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 index 0000000..09461a6 --- /dev/null +++ b/classes/notifications.php @@ -0,0 +1,108 @@ + + * @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 '
$account: ' . print_r( $account, true ) . '
'; + + // get the Notification type + $notification_type = $this->getNotificationTypeById( $notification_type ); + echo '
$notification_type: ' . print_r( $notification_type, true ) . '
'; + + } + + /** + * 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 + ); + } + +} diff --git a/models/admin/settings/notificationTypes.php b/models/admin/settings/notificationTypes.php index 521ee6f..b38a153 100644 --- a/models/admin/settings/notificationTypes.php +++ b/models/admin/settings/notificationTypes.php @@ -143,6 +143,15 @@ class GlmMembersAdmin_settings_notificationTypes extends GlmDataNotificationType } switch($_REQUEST['option']) { + case 'test': + echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + 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'; diff --git a/views/admin/settings/notificationTypes.html b/views/admin/settings/notificationTypes.html index 38140a6..bf98d1b 100644 --- a/views/admin/settings/notificationTypes.html +++ b/views/admin/settings/notificationTypes.html @@ -186,6 +186,7 @@ ID + Notification Subject Trigger @@ -202,6 +203,9 @@ {/if} {$t.id} + + Test +