From: Steve Sutton Date: Thu, 30 Nov 2017 21:40:57 +0000 (-0500) Subject: Update for adding notification types X-Git-Tag: v1.0.0^2~214 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d42aacc1b4e0fb90829e5046a57c31d37ef19e8e;p=WP-Plugins%2Fglm-member-db-billing.git Update for adding notification types Add the setting page for add/edit/delete notification types. --- diff --git a/classes/data/dataInvoiceTypes.php b/classes/data/dataInvoiceTypes.php index 7e3ae96..aaeef24 100644 --- a/classes/data/dataInvoiceTypes.php +++ b/classes/data/dataInvoiceTypes.php @@ -237,5 +237,3 @@ class GlmDataInvoiceTypes extends GlmDataAbstract return $array; } } - -?> diff --git a/classes/data/dataNotificationTypes.php b/classes/data/dataNotificationTypes.php new file mode 100644 index 0000000..42a76bc --- /dev/null +++ b/classes/data/dataNotificationTypes.php @@ -0,0 +1,229 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataBillingManagement class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataNotificationTypes extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * 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 + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // 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; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'notification_types'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a', + ), + + // Notification Type Name + 'name' => array( + 'field' => 'name', + 'type' => 'text', + 'use' => 'a', + ), + + // + 'from_header' => array( + 'field' => 'from_header', + 'type' => 'text', + 'use' => 'a', + ), + + // + 'replyto' => array( + 'field' => 'replyto', + 'type' => 'text', + 'use' => 'a', + ), + + // + 'subject' => array( + 'field' => 'subject', + 'type' => 'text', + 'use' => 'a', + ), + + // + 'message' => array( + 'field' => 'message', + 'type' => 'text', + 'use' => 'a', + ), + + // + 'send_by_date' => array( + 'field' => 'send_by_date', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a', + ), + + // + 'send_by_action' => array( + 'field' => 'send_by_action', + 'type' => 'checkbox', + 'default' => false, + 'use' => 'a', + ), + + // + 'send_action' => array( + 'field' => 'send_action', + 'type' => 'integer', + 'default' => false, + 'use' => 'a', + ), + + // + 'send_date_number' => array( + 'field' => 'send_date_number', + 'type' => 'integer', + 'use' => 'a', + ), + + // + 'send_date_period' => array( + 'field' => 'send_date_period', + 'type' => 'integer', + 'use' => 'a', + ), + + // + 'send_date_when' => array( + 'field' => 'send_date_when', + 'type' => 'integer', + 'use' => 'a', + ), + + ); + + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} diff --git a/models/admin/settings/invoiceTypes.php b/models/admin/settings/invoiceTypes.php index 12049c8..3df8d7a 100644 --- a/models/admin/settings/invoiceTypes.php +++ b/models/admin/settings/invoiceTypes.php @@ -192,5 +192,3 @@ class GlmMembersAdmin_settings_invoiceTypes extends GlmDataInvoiceTypes } - -?> diff --git a/models/admin/settings/notificationTypes.php b/models/admin/settings/notificationTypes.php new file mode 100644 index 0000000..d1a755f --- /dev/null +++ b/models/admin/settings/notificationTypes.php @@ -0,0 +1,211 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Member Types data abstract +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataNotificationTypes.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_settings_notificationTypes extends GlmDataNotificationTypes +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the contoller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction ($actionData = false) + { + + $success = true; + $haveNotificationTypes = false; + $notificationTypes = false; + $error = false; + $enable_members = $this->config['settings']['enable_members']; + + // Check for region id + $id = 0; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']-0; + } + + // need to setup the fields for send_by_(date/action) + if ( isset( $_REQUEST['send_by'] ) ) { + switch ( $_REQUEST['send_by'] ) { + case 'date': + $_REQUEST['send_by_date'] = true; + $_REQUEST['send_by_action'] = false; + break; + case 'action': + $_REQUEST['send_by_action'] = true; + $_REQUEST['send_by_date'] = false; + break; + default: + $_REQUEST['send_by_action'] = false; + $_REQUEST['send_by_date'] = false; + break; + } + } + + // If there's an action option + if (isset($_REQUEST['option'])) { + + switch($_REQUEST['option']) { + + case 'addNew': + + + $this->insertEntry(); + break; + + case 'update': + if ($id > 0) { + $this->updateEntry($id); + } + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + } + break; + + } + + } + + // Get a current list of members + $notificationTypes = $this->getList(); + + // echo '
$notificationTypes: ' . print_r( $notificationTypes, true ) . '
'; + + // If we have list entries - even if it's an empty list + $success = true; + $haveNotificationTypes = false; + if ($notificationTypes !== false) { + + $success = true; + + // If we have any entries + if (count($notificationTypes) > 0) { + $haveNotificationTypes = true; + } + } + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + // Compile template data + $templateData = array( + 'action' => $_REQUEST['glm_action'], + 'enable_members' => $enable_members, + 'haveNotificationTypes' => $haveNotificationTypes, + 'notificationTypes' => $notificationTypes, + 'send_date_period' => $this->config['send_date_period'], + 'send_date_when' => $this->config['send_date_when'], + 'send_action' => $this->config['send_action'], + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/notificationTypes.html', + 'data' => $templateData + ); + + } + + +} diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index a2b3be0..d647608 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -95,7 +95,9 @@ CREATE TABLE {prefix}payments ( -- Notification Types CREATE TABLE {prefix}notification_types ( id INT NOT NULL AUTO_INCREMENT, - from_replyto TINYTEXT NOT NULL, -- from reply-to headers + 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 diff --git a/setup/validActions.php b/setup/validActions.php index d4f1d77..7d6bb65 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -60,9 +60,9 @@ $glmMembersBillingAddOnValidActions = array( 'adminActions' => array( 'settings' => array( - 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'invoiceTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, - 'lineItems' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'invoiceTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'notificationTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), 'billing' => array( 'index' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, diff --git a/views/admin/settings/invoiceTypes.html b/views/admin/settings/invoiceTypes.html index 92334dd..98a2ba5 100644 --- a/views/admin/settings/invoiceTypes.html +++ b/views/admin/settings/invoiceTypes.html @@ -2,24 +2,92 @@ {include file='admin/settings/subHeader.html'} - -
Add a Invoice Type
-
-
- - - - - - - - - - + + + + + + + + + + + + + +
Invoice Type Name: - -
Parent: - + + + + + + + + + + + + + + + + + + + + + + +
Invoice Type Name: + +
Parent: + +
Amount:Numbers only (999.99) + +
Recurring: + + +
Recurrence: + +
+

* Required

+ Cancel + + + + + +
+
+

Are you sure you want to delete this invoice Type?

+

Yes, delete this invoice Type

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + - - - - - - - - - - - - - -
Invoice Type Name: + +
Parent: + -
Amount:Numbers only (999.99) - -
Recurring: - - -
Recurrence: - -
-

* Required

- Cancel - -
-
+ +
Amount:Numbers only (999.99) + +
Recurring: + + +
Recurrence: + +
+

* Required

+ Cancel + + +
- -
-
-

Are you sure you want to delete this invoice Type?

-

Yes, delete this invoice Type

-

Cancel

-
-
+

InvoiceTypes

- -
-
- - - - - - - - - - - - - - - - - - +
Invoice Type Name: - -
Parent: - -
Amount:Numbers only (999.99) - -
Recurring:
+ + + + + + + + + + + + {if $haveInvoiceTypes} + {assign var="i" value="0"} + {foreach $invoiceTypes as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + - - - + + + -
IDInvoiceTypeAmountRecurringRecurrence 
{$t.id} - - + + {$t.name} +
Recurrence:{$t.amount}{if $t.recurring.value}Yes{else}No{/if}{if $t.recurrence}{$recurrenceTypes[$t.recurrence]}{/if} - +
Delete
-

* Required

- Cancel - -
-
- -

InvoiceTypes

+ {/foreach} + {else} + (no Invoice Types listed) + {/if} + + - - - - - - - - - - - - - {if $haveInvoiceTypes} - {assign var="i" value="0"} - {foreach $invoiceTypes as $t} - {if $i++ is odd by 1} - - {else} - - {/if} - - - - - - - - {/foreach} - {else} - - {/if} - -
IDInvoiceTypeAmountRecurringRecurrence 
{$t.id} - - {$t.name} - - {$t.amount}{if $t.recurring.value}Yes{else}No{/if}{if $t.recurrence}{$recurrenceTypes[$t.recurrence]}{/if} -
Delete
-
(no Invoice Types listed)
+ + $('#deleteInvoiceTypeCancel').click( function() { + $("#deleteInvoiceTypeDialog").dialog("close"); + }); + + }); + {include file='admin/footer.html'} diff --git a/views/admin/settings/notificationTypes.html b/views/admin/settings/notificationTypes.html new file mode 100644 index 0000000..bb32d76 --- /dev/null +++ b/views/admin/settings/notificationTypes.html @@ -0,0 +1,317 @@ +{include file='admin/settings/header.html'} + +{include file='admin/settings/subHeader.html'} + + +
Add a Notification Type
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name: + +
Send Notification based on
Due Date
+ + + +
Immediate Action
+ +
Subject + +
From + +
Reply-To + +
+ +
+

* Required

+ Cancel + +
+
+ + +
+
+

Are you sure you want to delete this notification Type?

+

Yes, delete this notification Type

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name: + +
Send Notification based on
Due Date
+ + + +
Immediate Action
+ +
Subject + +
From + +
Reply-To + +
+ +
+

* Required

+ Cancel + +
+
+ +

NotificationTypes

+ + + + + + + + + + + + {if $haveNotificationTypes} + {assign var="i" value="0"} + {foreach $notificationTypes as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + {/foreach} + {else} + + {/if} + +
IDNotificationSubject 
{$t.id} +
+ {$t.name} +
+
{$t.subject} +
Delete
+
(no Notification Types listed)
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/settings/subHeader.html b/views/admin/settings/subHeader.html index ae57844..2269573 100644 --- a/views/admin/settings/subHeader.html +++ b/views/admin/settings/subHeader.html @@ -3,6 +3,6 @@ class="glm-settings-tab nav-tab{if $action == 'billing'} nav-tab-active{/if}">Invoice Settings Invoice Types - Line Items + Notification Types