Update for adding notification types
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 30 Nov 2017 21:40:57 +0000 (16:40 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 30 Nov 2017 21:40:57 +0000 (16:40 -0500)
Add the setting page for add/edit/delete notification types.

classes/data/dataInvoiceTypes.php
classes/data/dataNotificationTypes.php [new file with mode: 0644]
models/admin/settings/invoiceTypes.php
models/admin/settings/notificationTypes.php [new file with mode: 0644]
setup/databaseScripts/create_database_V0.0.1.sql
setup/validActions.php
views/admin/settings/invoiceTypes.html
views/admin/settings/notificationTypes.html [new file with mode: 0644]
views/admin/settings/subHeader.html

index 7e3ae96..aaeef24 100644 (file)
@@ -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 (file)
index 0000000..42a76bc
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Management
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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 <cscott@gaslightmedia.com>
+ * @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;
+    }
+
+}
index 12049c8..3df8d7a 100644 (file)
@@ -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 (file)
index 0000000..d1a755f
--- /dev/null
@@ -0,0 +1,211 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin NotificationTypes List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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 '<pre>$notificationTypes: ' . print_r( $notificationTypes, true ) . '</pre>';
+
+        // 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
+        );
+
+    }
+
+
+}
index a2b3be0..d647608 100644 (file)
@@ -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
index d4f1d77..7d6bb65 100644 (file)
@@ -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,
index 92334dd..98a2ba5 100644 (file)
@@ -2,24 +2,92 @@
 
 {include file='admin/settings/subHeader.html'}
 
-    <!-- Add InvoiceTypes Button and Dialog Box -->
-    <div id="newInvoiceTypeButton" class="button button-primary glm-right">Add a Invoice Type</div>
-    <div id="newInvoiceTypeDialog" class="glm-dialog-box" title="Enter a New InvoiceType">
-        <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
-            <input type="hidden" name="glm_action" value="invoiceTypes">
-            <input type="hidden" name="option" value="addNew">
-            <table class="glm-admin-table">
-                <tr>
-                    <th class="glm-required">Invoice Type Name:</th>
-                    <td>
-                        <input type="text" name="name" class="glm-form-text-input" required>
-                    </td>
-                </tr>
-                <tr>
-                    <th class="glm-required">Parent:</th>
-                    <td>
-                        <select name="parent">
-                            <option value="0">(none)</option>
+<!-- Add InvoiceTypes Button and Dialog Box -->
+<div id="newInvoiceTypeButton" class="button button-primary glm-right">Add a Invoice Type</div>
+<div id="newInvoiceTypeDialog" class="glm-dialog-box" title="Enter a New InvoiceType">
+    <form action="{$thisUrl}?page={$thisPage}&glm_action=invoiceTypes" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="invoiceTypes">
+        <input type="hidden" name="option" value="addNew">
+        <table class="glm-admin-table">
+            <tr>
+                <th class="glm-required">Invoice Type Name:</th>
+                <td>
+                    <input type="text" name="name" class="glm-form-text-input" required>
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Parent:</th>
+                <td>
+                    <select name="parent">
+                        <option value="0">(none)</option>
+                        {if $haveInvoiceTypes}
+                            {foreach $invoiceTypes as $t}
+                                {if !$t.parent.value} <!-- don't show child categories -->
+                                    <option value="{$t.id}">{$t.name}</option>
+                                {/if}
+                            {/foreach}
+                        {/if}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Amount:Numbers only (999.99)</th>
+                <td>
+                    <input type="text" name="amount" class="glm-form-text-input" required>
+                </td>
+            </tr>
+            <tr>
+                <th>Recurring:</th>
+                <td>
+                    <input type="hidden" name="recurring" class="glm-form-text-input" value="0">
+                    <input type="checkbox" name="recurring" class="glm-form-text-input" value="1">
+                </td>
+            </tr>
+            <tr>
+                <th>Recurrence:</th>
+                <td>
+                    <select name="recurrence">
+                        <option value="">(none)</option>
+                            {foreach $recurrenceTypes as $typeId => $typeLabel}
+                                <option value="{$typeId}">{$typeLabel}</option>
+                            {/foreach}
+                    </select>
+                </td>
+            </tr>
+        </table>
+        <p><span class="glm-required">*</span> Required</p>
+        <a id="newInvoiceTypeCancel" class="button button-primary glm-right">Cancel</a>
+        <input type="submit" value="Add new Invoice Type" class="button button-primary">
+    </form>
+</div>
+
+<!-- Add InvoiceTypes Button -->
+<div id="deleteInvoiceTypeDialog" class="glm-dialog-box" title="Delete InvoiceType">
+    <center>
+        <p>Are you sure you want to delete this invoice Type?</p>
+        <p><div id="deleteInvoiceTypeConfirm" class="button button-primary">Yes, delete this invoice Type</div></p>
+        <p><div id="deleteInvoiceTypeCancel" class="button button-primary">Cancel</div></p>
+    </center>
+</div>
+
+<!-- Edit InvoiceTypes Dialog Box -->
+<div id="editInvoiceTypeDialog" class="glm-dialog-box" title="Edit this InvoiceType">
+    <form action="{$thisUrl}?page={$thisPage}&glm_action=invoiceTypes" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="invoiceTypes">
+        <input type="hidden" name="option" value="update">
+        <input id="edit-id" type="hidden" name="id" value="">
+        <table class="glm-admin-table">
+            <tr>
+                <th class="glm-required">Invoice Type Name:</th>
+                <td>
+                    <input id="edit-name" type="text" name="name" class="glm-form-text-input" required>
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Parent:</th>
+                <td>
+                    <select id="edit-parent" name="parent">
+                        <option value="0">(none)</option>
                             {if $haveInvoiceTypes}
                                 {foreach $invoiceTypes as $t}
                                     {if !$t.parent.value} <!-- don't show child categories -->
                                     {/if}
                                 {/foreach}
                             {/if}
-                        </select>
-                    </td>
-                </tr>
-                <tr>
-                    <th class="glm-required">Amount:Numbers only (999.99)</th>
-                    <td>
-                        <input type="text" name="amount" class="glm-form-text-input" required>
-                    </td>
-                </tr>
-                <tr>
-                    <th>Recurring:</th>
-                    <td>
-                        <input type="hidden" name="recurring" class="glm-form-text-input" value="0">
-                        <input type="checkbox" name="recurring" class="glm-form-text-input" value="1">
-                    </td>
-                </tr>
-                <tr>
-                    <th>Recurrence:</th>
-                    <td>
-                        <select name="recurrence">
-                            <option value="">(none)</option>
-                                {foreach $recurrenceTypes as $typeId => $typeLabel}
-                                    {if !$t.parent.value} <!-- don't show child categories -->
-                                        <option value="{$typeId}">{$typeLabel}</option>
-                                    {/if}
-                                {/foreach}
-                        </select>
-                    </td>
-                </tr>
-            </table>
-            <p><span class="glm-required">*</span> Required</p>
-            <a id="newInvoiceTypeCancel" class="button button-primary glm-right">Cancel</a>
-            <input type="submit" value="Add new Invoice Type" class="button button-primary">
-        </form>
-    </div>
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Amount:Numbers only (999.99)</th>
+                <td>
+                    <input id="edit-amount" type="text" name="amount" class="glm-form-text-input" required>
+                </td>
+            </tr>
+            <tr>
+                <th>Recurring:</th>
+                <td>
+                    <input type="hidden" name="recurring" class="glm-form-text-input" value="0">
+                    <input id="edit-recurring" type="checkbox" name="recurring" class="glm-form-text-input" value="1">
+                </td>
+            </tr>
+            <tr>
+                <th>Recurrence:</th>
+                <td>
+                    <select id="edit-recurrence" name="recurrence">
+                        <option value="">(none)</option>
+                            {foreach $recurrenceTypes as $typeId => $typeLabel}
+                                <option value="{$typeId}">{$typeLabel}</option>
+                            {/foreach}
+                    </select>
+                </td>
+            </tr>
+        </table>
+        <p><span class="glm-required">*</span> Required</p>
+        <a id="editInvoiceTypeCancel" class="button button-primary glm-right">Cancel</a>
+        <input type="submit" value="Update this Invoice Type" class="button button-primary">
+    </form>
+</div>
 
-    <!-- Add InvoiceTypes Button -->
-    <div id="deleteInvoiceTypeDialog" class="glm-dialog-box" title="Delete InvoiceType">
-        <center>
-            <p>Are you sure you want to delete this invoice Type?</p>
-            <p><div id="deleteInvoiceTypeConfirm" class="button button-primary">Yes, delete this invoice Type</div></p>
-            <p><div id="deleteInvoiceTypeCancel" class="button button-primary">Cancel</div></p>
-        </center>
-    </div>
+<h2>InvoiceTypes</h2>
 
-    <!-- Edit InvoiceTypes Dialog Box -->
-    <div id="editInvoiceTypeDialog" class="glm-dialog-box" title="Edit this InvoiceType">
-        <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
-            <input type="hidden" name="glm_action" value="invoiceTypes">
-            <input type="hidden" name="option" value="update">
-            <input id="edit-id" type="hidden" name="id" value="">
-            <table class="glm-admin-table">
-                <tr>
-                    <th class="glm-required">Invoice Type Name:</th>
-                    <td>
-                        <input id="edit-name" type="text" name="name" class="glm-form-text-input" required>
-                    </td>
-                </tr>
-                <tr>
-                    <th class="glm-required">Parent:</th>
-                    <td>
-                        <select id="edit-parent" name="parent">
-                            <option value="0">(none)</option>
-                                {if $haveInvoiceTypes}
-                                    {foreach $invoiceTypes as $t}
-                                        {if !$t.parent.value} <!-- don't show child categories -->
-                                            <option value="{$t.id}">{$t.name}</option>
-                                        {/if}
-                                    {/foreach}
-                                {/if}
-                        </select>
-                    </td>
-                </tr>
-                <tr>
-                    <th class="glm-required">Amount:Numbers only (999.99)</th>
-                    <td>
-                        <input id="edit-amount" type="text" name="amount" class="glm-form-text-input" required>
-                    </td>
-                </tr>
-                <tr>
-                    <th>Recurring:</th>
+<table class="wp-list-table widefat fixed posts glm-admin-table">
+    <thead>
+        <tr>
+            <th>ID</th>
+            <th>InvoiceType</th>
+            <th>Amount</th>
+            <th>Recurring</th>
+            <th>Recurrence</th>
+            <th>&nbsp;</th>
+        </tr>
+    </thead>
+    <tbody>
+        {if $haveInvoiceTypes}
+            {assign var="i" value="0"}
+            {foreach $invoiceTypes as $t}
+                {if $i++ is odd by 1}
+                    <tr>
+                {else}
+                    <tr class="alternate">
+                {/if}
+                    <td>{$t.id}</td>
                     <td>
-                        <input type="hidden" name="recurring" class="glm-form-text-input" value="0">
-                        <input id="edit-recurring" type="checkbox" name="recurring" class="glm-form-text-input" value="1">
+                        <div{if $t.parent.value} class="glm-indent"{/if}>
+                            <a class="editInvoiceType"
+                                data-invoice-id="{$t.id}"
+                                data-invoice-name="{$t.name}"
+                                data-invoice-parent="{$t.parent.value}"
+                                data-invoice-amount="{$t.amount}"
+                                data-invoice-recurring="{$t.recurring.value}"
+                                data-invoice-recurrence="{$t.recurrence}">{$t.name}</a>
+                        </div>
                     </td>
-                </tr>
-                <tr>
-                    <th>Recurrence:</th>
+                    <td>{$t.amount}</td>
+                    <td>{if $t.recurring.value}Yes{else}No{/if}</td>
+                    <td>{if $t.recurrence}{$recurrenceTypes[$t.recurrence]}{/if}</td>
                     <td>
-                        <select id="edit-recurrence" name="recurrence">
-                            <option value="">(none)</option>
-                                {foreach $recurrenceTypes as $typeId => $typeLabel}
-                                    <option value="{$typeId}">{$typeLabel}</option>
-                                {/foreach}
-                        </select>
+                        <div class="deleteInvoiceTypeButton button button-secondary glm-button-small glm-right"
+                            data-invoiceTypeID="{$t.id}">Delete</div>
                     </td>
                 </tr>
-            </table>
-            <p><span class="glm-required">*</span> Required</p>
-            <a id="editInvoiceTypeCancel" class="button button-primary glm-right">Cancel</a>
-            <input type="submit" value="Update this Invoice Type">
-        </form>
-    </div>
-
-    <h2>InvoiceTypes</h2>
+            {/foreach}
+        {else}
+            <tr class="alternate"><td colspan="2">(no Invoice Types listed)</td></tr>
+        {/if}
+    </tbody>
+</table>
 
-    <table class="wp-list-table widefat fixed posts glm-admin-table">
-        <thead>
-            <tr>
-                <th>ID</th>
-                <th>InvoiceType</th>
-                <th>Amount</th>
-                <th>Recurring</th>
-                <th>Recurrence</th>
-                <th>&nbsp;</th>
-            </tr>
-        </thead>
-        <tbody>
-            {if $haveInvoiceTypes}
-                {assign var="i" value="0"}
-                {foreach $invoiceTypes as $t}
-                    {if $i++ is odd by 1}
-                        <tr>
-                    {else}
-                        <tr class="alternate">
-                    {/if}
-                        <td>{$t.id}</td>
-                        <td>
-                            <div{if $t.parent.value} class="glm-indent"{/if}>
-                                <a class="editInvoiceType"
-                                    data-invoice-id="{$t.id}"
-                                    data-invoice-name="{$t.name}"
-                                    data-invoice-parent="{$t.parent.value}"
-                                    data-invoice-amount="{$t.amount}"
-                                    data-invoice-recurring="{$t.recurring.value}"
-                                    data-invoice-recurrence="{$t.recurrence}">{$t.name}</a>
-                            </div>
-                        </td>
-                        <td>{$t.amount}</td>
-                        <td>{if $t.recurring.value}Yes{else}No{/if}</td>
-                        <td>{if $t.recurrence}{$recurrenceTypes[$t.recurrence]}{/if}</td>
-                        <td>
-                            <div class="deleteInvoiceTypeButton button button-secondary glm-button-small glm-right" data-invoiceTypeID="{$t.id}">Delete</div>
-                        </td>
-                    </tr>
-                {/foreach}
-            {else}
-                <tr class="alternate"><td colspan="2">(no Invoice Types listed)</td></tr>
-            {/if}
-        </tbody>
-    </table>
+<script type="text/javascript">
+    jQuery(document).ready(function($) {
 
-    <script type="text/javascript">
-        jQuery(document).ready(function($) {
-
-            $("#newInvoiceTypeDialog").dialog({
-                autoOpen: false,
-                minWidth: 400,
-                dialogClass: "glm-dialog-no-close"
-            });
-            $("#editInvoiceTypeDialog").dialog({
-                autoOpen: false,
-                minWidth: 400,
-                dialogClass: "glm-dialog-no-close"
-            });
-            $("#deleteInvoiceTypeDialog").dialog({
-                autoOpen: false,
-                minWidth: 400,
-                dialogClass: "glm-dialog-no-close"
-            });
-
-            $('#newInvoiceTypeButton').click( function() {
-                $("#newInvoiceTypeDialog").dialog("open");
-            });
-            $('.editInvoiceType').click( function() {
-                $('#editRecurring').prop( 'checked', false );
+        $("#newInvoiceTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
+        $("#editInvoiceTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
+        $("#deleteInvoiceTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
 
-                var invoiceID         = $(this).data('invoice-id');
-                var invoiceName       = $(this).data('invoice-name');
-                var invoiceParent     = $(this).data('invoice-parent');
-                console.log(invoiceParent);
-                var invoiceAmount     = $(this).data('invoice-amount');
-                var invoiceRecurring  = $(this).data('invoice-recurring');
-                var invoiceRecurrence = $(this).data('invoice-recurrence');
+        $('#newInvoiceTypeButton').click( function() {
+            $("#newInvoiceTypeDialog").dialog("open");
+        });
+        $('.editInvoiceType').click( function() {
+            $('#editRecurring').prop( 'checked', false );
 
-                // Set the values of the edit form for the selected invoiceType
-                $('#edit-id').val( invoiceID );
-                $('#edit-name').val( invoiceName );
-                $('#edit-parent').val( invoiceParent );
-                $('#edit-amount').val( invoiceAmount );
-                if ( invoiceRecurring === 1 ) {
-                    $('#edit-recurring').prop( 'checked', true );
-                }
-                $('#edit-recurrence').val( invoiceRecurrence );
+            var invoiceID         = $(this).data('invoice-id');
+            var invoiceName       = $(this).data('invoice-name');
+            var invoiceParent     = $(this).data('invoice-parent');
+            console.log(invoiceParent);
+            var invoiceAmount     = $(this).data('invoice-amount');
+            var invoiceRecurring  = $(this).data('invoice-recurring');
+            var invoiceRecurrence = $(this).data('invoice-recurrence');
 
-                $("#editInvoiceTypeDialog").dialog("open");
-            });
-            $('#editInvoiceTypeCancel').click( function() {
-                $("#editInvoiceTypeDialog").dialog("close");
-            });
-            $('#newInvoiceTypeCancel').click( function() {
-                $("#newInvoiceTypeDialog").dialog("close");
-            });
+            // Set the values of the edit form for the selected invoiceType
+            $('#edit-id').val( invoiceID );
+            $('#edit-name').val( invoiceName );
+            $('#edit-parent').val( invoiceParent );
+            $('#edit-amount').val( invoiceAmount );
+            if ( invoiceRecurring === 1 ) {
+                $('#edit-recurring').prop( 'checked', true );
+            }
+            $('#edit-recurrence').val( invoiceRecurrence );
 
-            var id = false;
-            $('.deleteInvoiceTypeButton').click( function() {
-                id = $(this).attr('data-invoiceTypeID');
-                $("#deleteInvoiceTypeDialog").dialog("open");
-            });
-            $('#deleteInvoiceTypeConfirm').click( function() {
-                $("#deleteInvoiceTypeDialog").dialog("close");
-                window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=invoiceTypes&option=delete&id=" + id;
-            });
-            $('#deleteInvoiceTypeCancel').click( function() {
-                $("#deleteInvoiceTypeDialog").dialog("close");
-            });
+            $("#editInvoiceTypeDialog").dialog("open");
+        });
+        $('#editInvoiceTypeCancel').click( function() {
+            $("#editInvoiceTypeDialog").dialog("close");
+        });
+        $('#newInvoiceTypeCancel').click( function() {
+            $("#newInvoiceTypeDialog").dialog("close");
+        });
 
+        var id = false;
+        $('.deleteInvoiceTypeButton').click( function() {
+            id = $(this).attr('data-invoiceTypeID');
+            $("#deleteInvoiceTypeDialog").dialog("open");
+        });
+        $('#deleteInvoiceTypeConfirm').click( function() {
+            $("#deleteInvoiceTypeDialog").dialog("close");
+            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=invoiceTypes&option=delete&id=" + id;
         });
-    </script>
+        $('#deleteInvoiceTypeCancel').click( function() {
+            $("#deleteInvoiceTypeDialog").dialog("close");
+        });
+
+    });
+</script>
 
 {include file='admin/footer.html'}
diff --git a/views/admin/settings/notificationTypes.html b/views/admin/settings/notificationTypes.html
new file mode 100644 (file)
index 0000000..bb32d76
--- /dev/null
@@ -0,0 +1,317 @@
+{include file='admin/settings/header.html'}
+
+{include file='admin/settings/subHeader.html'}
+
+<!-- Add NotificationTypes Button and Dialog Box -->
+<div id="newNotificationTypeButton" class="button button-primary glm-right">Add a Notification Type</div>
+<div id="newNotificationTypeDialog" class="glm-dialog-box" title="Enter a New NotificationType">
+    <form action="{$thisUrl}?page={$thisPage}&glm_action=notificationTypes" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="notificationTypes">
+        <input type="hidden" name="option" value="addNew">
+        <table class="glm-admin-table">
+            <tr>
+                <th class="glm-required">Name:</th>
+                <td>
+                    <input type="text" name="name" required />
+                </td>
+            </tr>
+            <tr>
+                <th colspan="2" class="glm-required">Send Notification based on</th>
+            </tr>
+            <tr>
+                <th colspan="2">Due Date</th>
+            </tr>
+            <tr>
+                <th class="glm-required"><input type="radio" name="send_by" value="date" required></th>
+                <td>
+                    <input
+                        type="number"
+                        step="1"
+                        min="0"
+                        max="100"
+                        name="send_date_number"
+                        class="glm-form-text-input-veryshort">
+                    <select name="send_date_period">
+                        {foreach $send_date_period as $id => $val}
+                            <option value="{$id}">{$val}</option>
+                        {/foreach}
+                    </select>
+                    <select name="send_date_when">
+                        {foreach $send_date_when as $id => $val}
+                            <option value="{$id}">{$val}</option>
+                        {/foreach}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th colspan="2">Immediate Action</th>
+            </tr>
+            <tr>
+                <th><input type="radio" name="send_by" value="action" required></th>
+                <td>
+                    <select name="send_action">
+                        {foreach $send_action as $id => $val}
+                            <option value="{$id}">{$val}</option>
+                        {/foreach}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Subject</th>
+                <td class="glm-required">
+                    <input type="text" name="subject" required />
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">From</th>
+                <td class="glm-required">
+                    <input type="text" name="from_header" required />
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Reply-To</th>
+                <td class="glm-required">
+                    <input type="text" name="replyto" required />
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <textarea name="message"></textarea>
+                </td>
+            </tr>
+        </table>
+        <p><span class="glm-required">*</span> Required</p>
+        <a id="newNotificationTypeCancel" class="button button-primary glm-right">Cancel</a>
+        <input type="submit" value="Add new Notification Type" class="button button-primary">
+    </form>
+</div>
+
+<!-- Add NotificationTypes Button -->
+<div id="deleteNotificationTypeDialog" class="glm-dialog-box" title="Delete NotificationType">
+    <center>
+        <p>Are you sure you want to delete this notification Type?</p>
+        <p><div id="deleteNotificationTypeConfirm" class="button button-primary">Yes, delete this notification Type</div></p>
+        <p><div id="deleteNotificationTypeCancel" class="button button-primary">Cancel</div></p>
+    </center>
+</div>
+
+<!-- Edit NotificationTypes Dialog Box -->
+<div id="editNotificationTypeDialog" class="glm-dialog-box" title="Edit this NotificationType">
+    <form action="{$thisUrl}?page={$thisPage}&glm_action=notificationTypes" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="notificationTypes">
+        <input type="hidden" name="option" value="update">
+        <input id="edit-id" type="hidden" name="id" value="">
+        <table class="glm-admin-table">
+            <tr>
+                <th class="glm-required">Name:</th>
+                <td>
+                    <input id="edit-name" type="text" name="name" required />
+                </td>
+            </tr>
+            <tr>
+                <th colspan="2" class="glm-required">Send Notification based on</th>
+            </tr>
+            <tr>
+                <th colspan="2">Due Date</th>
+            </tr>
+            <tr>
+                <th class="glm-required"><input type="radio" id="edit-sendbydate" name="send_by" value="date" required></th>
+                <td>
+                    <input
+                        type="number"
+                        step="1"
+                        min="0"
+                        max="100"
+                        name="send_date_number"
+                        id="edit-senddatenumber"
+                        class="glm-form-text-input-veryshort">
+                    <select id="edit-senddateperiod" name="send_date_period">
+                        {foreach $send_date_period as $id => $val}
+                            <option value="{$id}">{$val}</option>
+                        {/foreach}
+                    </select>
+                    <select id="edit-senddatewhen" name="send_date_when">
+                        {foreach $send_date_when as $id => $val}
+                            <option value="{$id}">{$val}</option>
+                        {/foreach}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th colspan="2">Immediate Action</th>
+            </tr>
+            <tr>
+                <th><input id="edit-sendbyaction" type="radio" name="send_by" value="action" required></th>
+                <td>
+                    <select id="edit-sendaction" name="send_action">
+                        {foreach $send_action as $id => $val}
+                            <option value="{$id}">{$val}</option>
+                        {/foreach}
+                    </select>
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Subject</th>
+                <td class="glm-required">
+                    <input type="text" id="edit-subject" name="subject" required />
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">From</th>
+                <td class="glm-required">
+                    <input type="text" id="edit-fromheader" name="from_header" required />
+                </td>
+            </tr>
+            <tr>
+                <th class="glm-required">Reply-To</th>
+                <td class="glm-required">
+                    <input type="text" id="edit-replyto" name="replyto" required />
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <textarea id="edit-message" name="message"></textarea>
+                </td>
+            </tr>
+        </table>
+        <p><span class="glm-required">*</span> Required</p>
+        <a id="editNotificationTypeCancel" class="button button-primary glm-right">Cancel</a>
+        <input type="submit" value="Update this Notification Type" class="button button-primary">
+    </form>
+</div>
+
+<h2>NotificationTypes</h2>
+
+<table class="wp-list-table widefat fixed posts glm-admin-table">
+    <thead>
+        <tr>
+            <th>ID</th>
+            <th>Notification</th>
+            <th>Subject</th>
+            <th>&nbsp;</th>
+        </tr>
+    </thead>
+    <tbody>
+        {if $haveNotificationTypes}
+            {assign var="i" value="0"}
+            {foreach $notificationTypes as $t}
+                {if $i++ is odd by 1}
+                    <tr>
+                {else}
+                    <tr class="alternate">
+                {/if}
+                    <td>{$t.id}</td>
+                    <td>
+                        <div>
+                            <a class="editNotificationType"
+                                data-notification-id="{$t.id}"
+                                data-notification-name="{$t.name}"
+                                data-notification-sendbydate="{$t.send_by_date.value}"
+                                data-notification-sendbyaction="{$t.send_by_action.value}"
+                                data-notification-sendaction="{$t.send_action}"
+                                data-notification-fromheader="{$t.from_header}"
+                                data-notification-replyto="{$t.replyto}"
+                                data-notification-subject="{$t.subject}"
+                                data-notification-message="{$t.message}"
+                                data-notification-senddatenumber="{$t.send_date_number}"
+                                data-notification-senddateperiod="{$t.send_date_period}"
+                                data-notification-senddatewhen="{$t.send_date_when}"
+                            >{$t.name}</a>
+                        </div>
+                    </td>
+                    <td>{$t.subject}</td>
+                    <td>
+                        <div
+                            class="deleteNotificationTypeButton button button-secondary glm-button-small glm-right"
+                            data-notificationTypeID="{$t.id}">Delete</div>
+                    </td>
+                </tr>
+            {/foreach}
+        {else}
+            <tr class="alternate"><td colspan="2">(no Notification Types listed)</td></tr>
+        {/if}
+    </tbody>
+</table>
+
+<script type="text/javascript">
+    jQuery(document).ready(function($) {
+
+        $("#newNotificationTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
+        $("#editNotificationTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
+        $("#deleteNotificationTypeDialog").dialog({
+            autoOpen: false,
+            minWidth: 400,
+            dialogClass: "glm-dialog-no-close"
+        });
+
+        $('#newNotificationTypeButton').click( function() {
+            $("#newNotificationTypeDialog").dialog("open");
+        });
+        $('.editNotificationType').click( function() {
+            $('#editRecurring').prop( 'checked', false );
+
+            var notificationID             = $(this).data('notification-id');
+            var notificationName           = $(this).data('notification-name');
+            var notificationSendByDate     = $(this).data('notification-sendbydate');
+            var notificationSendByAction   = $(this).data('notification-sendbyaction');
+            var notificationSendAction     = $(this).data('notification-sendaction');
+            var notificationFromHeader     = $(this).data('notification-fromheader');
+            var notificationRepyTo         = $(this).data('notification-replyto');
+            var notificationSubject        = $(this).data('notification-subject');
+            var notificationMessage        = $(this).data('notification-message');
+            var notificationSendDateNumber = $(this).data('notification-senddatenumber');
+            var notificationSendDatePeriod = $(this).data('notification-senddateperiod');
+            var notificationSendDateWhen   = $(this).data('notification-senddatewhen');
+
+            // Set the values of the edit form for the selected notificationType
+            $('#edit-id').val( notificationID );
+            $('#edit-name').val( notificationName );
+            $('#edit-senddatenumber').val( notificationSendDateNumber );
+            $('#edit-senddateperiod').val( notificationSendDatePeriod );
+            $('#edit-senddatewhen').val( notificationSendDateWhen );
+            $('#edit-sendaction').val( notificationSendAction );
+            $('#edit-fromheader').val( notificationFromHeader );
+            $('#edit-replyto').val( notificationRepyTo );
+            $('#edit-subject').val( notificationSubject );
+            $('#edit-message').val( notificationMessage );
+            if ( notificationSendByDate ) {
+                $('#edit-sendbydate').prop('checked', true);
+            }
+            if ( notificationSendByAction ) {
+                $('#edit-sendbyaction').prop('checked', true);
+            }
+
+            $("#editNotificationTypeDialog").dialog("open");
+        });
+        $('#editNotificationTypeCancel').click( function() {
+            $("#editNotificationTypeDialog").dialog("close");
+        });
+        $('#newNotificationTypeCancel').click( function() {
+            $("#newNotificationTypeDialog").dialog("close");
+        });
+
+        var id = false;
+        $('.deleteNotificationTypeButton').click( function() {
+            id = $(this).attr('data-notificationTypeID');
+            $("#deleteNotificationTypeDialog").dialog("open");
+        });
+        $('#deleteNotificationTypeConfirm').click( function() {
+            $("#deleteNotificationTypeDialog").dialog("close");
+            window.location.href = "{$thisUrl}?page={$thisPage}&glm_action=notificationTypes&option=delete&id=" + id;
+        });
+        $('#deleteNotificationTypeCancel').click( function() {
+            $("#deleteNotificationTypeDialog").dialog("close");
+        });
+
+    });
+</script>
+
+{include file='admin/footer.html'}
index ae57844..2269573 100644 (file)
@@ -3,6 +3,6 @@
        class="glm-settings-tab nav-tab{if $action == 'billing'} nav-tab-active{/if}">Invoice Settings</a>
     <a href="{$thisUrl}?page=glm-members-admin-menu-settings&glm_action=invoiceTypes"
        class="glm-settings-tab nav-tab{if $action == 'invoiceTypes'} nav-tab-active{/if}">Invoice Types</a>
-    <a href="{$thisUrl}?page=glm-members-admin-menu-settings&glm_action=lineItems"
-       class="glm-settings-tab nav-tab{if $action == 'lineItems'} nav-tab-active{/if}">Line Items</a>
+    <a href="{$thisUrl}?page=glm-members-admin-menu-settings&glm_action=notificationTypes"
+       class="glm-settings-tab nav-tab{if $action == 'notificationTypes'} nav-tab-active{/if}">Notification Types</a>
 </h2>