Preliminary Packaging Add-On less Front-End and such
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 7 Dec 2015 01:10:01 +0000 (20:10 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 7 Dec 2015 01:10:01 +0000 (20:10 -0500)
15 files changed:
classes/data/dataPackageElements.php [new file with mode: 0644]
classes/data/dataPackages.php [new file with mode: 0644]
defines.php
glm-member-db-packaging.php
models/admin/member/packaging.php [new file with mode: 0644]
models/admin/members/packaging.php [new file with mode: 0644]
models/admin/sample/index.php [deleted file]
setup/adminTabs.php
setup/databaseScripts/create_database_V0.0.2.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php [new file with mode: 0644]
setup/validActions.php
views/admin/member/packaging.html [new file with mode: 0644]
views/admin/members/packaging.html [new file with mode: 0644]
views/admin/sample/header.html [deleted file]
views/admin/sample/index.html [deleted file]

diff --git a/classes/data/dataPackageElements.php b/classes/data/dataPackageElements.php
new file mode 100644 (file)
index 0000000..f5bccbd
--- /dev/null
@@ -0,0 +1,206 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Package Elements data class
+ *
+ * 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: dataPackageElements.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataPackageElements 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 GlmDataPackageElements 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;
+
+    /**
+     * 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_PACKAGES_PLUGIN_DB_PREFIX . 'package_elements';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+
+            'id' => array (
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+
+            // Package Pointer
+            'package' => array (
+                'field' => 'package',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PACKAGES_PLUGIN_DB_PREFIX . 'packages',
+                    'p_field' => 'title',
+                    'p_orderby' => 'title',
+                'required' => true,
+                'use' => 'a'
+            ),
+
+            // Title
+            'title' => array (
+                'field' => 'title',
+                'type' => 'text',
+                'required' => true,
+                'use' => 'a'
+            ),
+
+            // Description
+            'descr' => array (
+                'field' => 'descr',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Short Description
+            'short_descr' => array (
+                'field' => 'short_descr',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Image
+            'image' => array(
+                    'field'    => 'image',
+                    'type'     => 'image',
+                    'use'      => 'a'
+            ),
+
+            // Position
+            'position' => array(
+                    'field' => 'position',
+                    'type' => 'integer',
+                    'use' => 'a'
+            ),
+
+            // Reference Type - Insert new record
+            'ref_type_insert' => array (
+                'field' => 'ref_type',
+                'type' => 'integer',
+                'use' => 'i'
+            ),
+
+            // Reference Type - Output only
+            'ref_type' => array (
+                'field' => 'ref_type',
+                'type' => 'list',
+                    'list' => $this->config['ref_type'],
+                'use' => 'lged'
+            ),
+
+            // Reference Target - Insert new record and for recall
+            'ref_dest' => array (
+                'field' => 'ref_dest',
+                'type' => 'integer',
+                'use' => 'ilged'
+            ),
+
+            // Reference Destination Name
+            'ref_dest_name' => array (
+                'field' => 'ref_dest',
+                'as' => 'ref_dest_name',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                    'p_blank' => true,
+                'use' => 'lged'
+            )
+
+        );
+
+    }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/classes/data/dataPackages.php b/classes/data/dataPackages.php
new file mode 100644 (file)
index 0000000..b57b355
--- /dev/null
@@ -0,0 +1,236 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Packages data class
+ *
+ * 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: dataPackages.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataPackages 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 GlmDataPackages 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;
+
+    /**
+     * 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_PACKAGING_PLUGIN_DB_PREFIX . 'packages';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+
+            'id' => array (
+                'field' => 'id',
+                'type' => 'integer',
+                'view_only' => true,
+                'use' => 'a'
+            ),
+
+            // Active flag
+            'active' => array (
+                'field' => 'active',
+                'type' => 'checkbox',
+                'default' => true,
+                'use' => 'a'
+            ),
+
+            // Title
+            'title' => array (
+                'field' => 'title',
+                'type' => 'text',
+                'required' => true,
+                'use' => 'a'
+            ),
+
+            // Description
+            'descr' => array (
+                'field' => 'descr',
+                'type' => 'text',
+                'required' => true,
+                'use' => 'a'
+            ),
+
+            // Short Description
+            'short_descr' => array (
+                'field' => 'short_descr',
+                'type' => 'text',
+                'use' => 'a'
+            ),
+
+            // Image
+            'image' => array(
+                    'field'    => 'image',
+                    'type'     => 'image',
+                    'use'      => 'a'
+            ),
+
+            // Start Date
+            'start_date' => array (
+                'field' => 'start_date',
+                'type' => 'date',
+                'use' => 'a'
+            ),
+
+            // End Date
+            'end_date' => array (
+                'field' => 'end_date',
+                'type' => 'date',
+                'use' => 'a'
+            ),
+
+            // Expire Date
+            'expire_date' => array (
+                'field' => 'expire_date',
+                'type' => 'date',
+                'use' => 'a'
+            ),
+
+            // Position
+            'position' => array(
+                    'field' => 'position',
+                    'type' => 'integer',
+                    'default' => 0,
+                    'use' => 'a'
+            ),
+
+            // Pricing - Descriptive
+            'pricing' => array (
+                'field' => 'pricing',
+                'type' => 'text',
+                'required' => true,
+                'use' => 'a'
+            ),
+
+            // Reference Type - Insert new record
+            'ref_type_insert' => array (
+                'field' => 'ref_type',
+                'type' => 'integer',
+                'default' => 0,
+                'use' => 'i'
+            ),
+
+            // Reference Type - Output only
+            'ref_type' => array (
+                'field' => 'ref_type',
+                'type' => 'list',
+                    'list' => $this->config['ref_type'],
+                'use' => 'lged'
+            ),
+
+            // Reference Target - Insert new record and for recall
+            'ref_dest' => array (
+                'field' => 'ref_dest',
+                'type' => 'integer',
+                'default' => 0,
+                'use' => 'ilged'
+            ),
+
+            // Reference Destination Name
+            'ref_dest_name' => array (
+                'field' => 'ref_dest',
+                'as' => 'ref_dest_name',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                    'p_blank' => true,
+                'required' => true,
+                'use' => 'lged'
+            )
+
+        );
+
+    }
+
+}
+
+?>
\ No newline at end of file
index f6ee60e..02a2c76 100644 (file)
@@ -11,6 +11,11 @@ define('GLM_MEMBERS_PACKAGING_PLUGIN_NAME', 'Gaslight Media Members Database Pac
 define('GLM_MEMBERS_PACKAGING_PLUGIN_SHORT_NAME', 'Packaging');
 define('GLM_MEMBERS_PACKAGING_PLUGIN_SLUG', 'glm-member-db-packaging');
 
+// Database table prefixes - change if using add-on tables
+global $wpdb;
+define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_membersPackaging_');
+define('GLM_MEMBERS_PACKAGING_PLUGIN_ACTIVE_DB_OPTION', 'glmMembersPackagingDbVersion');
+
 // Determine which system we're running on - If not provided, assume PRODUCTION
 $host = getenv('GLM_HOST_ID');
 if (trim($host) == '') {
@@ -41,15 +46,10 @@ define('GLM_MEMBERS_PACKAGING_PLUGIN_MEDIA_URL', $WPUploadDir['baseurl'].'/'.GLM
 
 // Directories
 define('GLM_MEMBERS_PACKAGING_PLUGIN_PATH', dirname(__FILE__));
-define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS', dirname(__FILE__).'/misc/databaseScripts');
+define('GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/setup');
+define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS', GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH.'/databaseScripts');
 define('GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/classes');
 define('GLM_MEMBERS_PACKAGING_PLUGIN_CONFIG_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/config');
-define('GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH', GLM_MEMBERS_PACKAGING_PLUGIN_PATH.'/setup');
-
-// Database table prefixes
-global $wpdb;
-define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX', $wpdb->prefix.'glm_members_');
-
 
 // Parameters related to the Main GLM Member DB plugin - Depending on what's going on these may already defined by the main plugin
 $pluginsPath = str_replace(GLM_MEMBERS_PACKAGING_PLUGIN_SLUG, '', GLM_MEMBERS_PACKAGING_PLUGIN_PATH);
index 15d695a..fab4f5e 100644 (file)
@@ -34,6 +34,7 @@
  *  version nunmber of that release for the DB version.
  */
 define('GLM_MEMBERS_PACKAGING_PLUGIN_VERSION', '0.0.2');
+define('GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION', '0.0.2');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_PACKAGING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.43');
@@ -124,6 +125,7 @@ if (version_compare($glmMembersDatabasePluginVersion, GLM_MEMBERS_PACKAGING_PLUG
  * Register this add-on with the main GLM Member DB plugin and get information on all add-ons loaded.
  */
 require_once(GLM_MEMBERS_PACKAGING_PLUGIN_SETUP_PATH.'/validActions.php');
+require_once(GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS.'/dbVersions.php');
 function glmMembersRegisterPackaging($addOns) {
 
     // Add this add-on to the add-ons array
@@ -132,7 +134,14 @@ function glmMembersRegisterPackaging($addOns) {
             'name' =>  GLM_MEMBERS_PACKAGING_PLUGIN_NAME,
             'short_name' => GLM_MEMBERS_PACKAGING_PLUGIN_SHORT_NAME,
             'slug' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG,
-            'actions' => $GLOBALS['glmMembersAddOnValidActions']
+            'actions' => $GLOBALS['glmMembersPackagingAddOnValidActions'],
+            'database' => array(
+                'dbPrefix' => GLM_MEMBERS_PACKAGING_PLUGIN_DB_PREFIX,
+                'dbCurrentVersion' => GLM_MEMBERS_PACKAGING_PLUGIN_DB_VERSION,
+                'dbActiveVersionOption' => GLM_MEMBERS_PACKAGING_PLUGIN_ACTIVE_DB_OPTION,
+                'dbScriptPath' => GLM_MEMBERS_PACKAGING_PLUGIN_DB_SCRIPTS,
+                'dbVersions' => $GLOBALS['glmMembersPackagingDbVersions']
+            )
     );
 
     // Return the array with our data added
diff --git a/models/admin/member/packaging.php b/models/admin/member/packaging.php
new file mode 100644 (file)
index 0000000..8c4743a
--- /dev/null
@@ -0,0 +1,280 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members DB - Packaging Add-on - Member package list
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  packaging.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Member Types data abstract
+require_once(GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH.'/data/dataPackages.php');
+
+/**
+ * GlmMembersAdmin_members_packaging Package
+ *
+ * PHP version 5
+ *
+ * @category Model
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmMembersAdmin_member_packaging extends GlmDataPackages
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * '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.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    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);
+
+     }
+
+    public function modelAction($actionData = false)
+    {
+
+        $success = true;
+        $havePackages = false;
+        $packages = false;
+        $havePackage = false;
+        $packageUpdated = false;
+        $packageInfo = false;
+        $packageError = false;
+        $option = false;
+        $error = false;
+
+        // If there's an action option
+        $option = 'list';
+        if (isset($_REQUEST['option'])) {
+            $option = trim($_REQUEST['option']);
+        }
+
+        // Get any package ID
+        $packageID = 0;
+        if (isset($_REQUEST['packageID']) && ($_REQUEST['packageID']-0) > 0) {
+            $packageID = $_REQUEST['packageID'] - 0;
+        }
+
+        // Get the current Member ID
+        $memberID = 0;
+        if (isset($_REQUEST['member']) && ($_REQUEST['member']-0) > 0) {
+            $memberID = $_REQUEST['member'] - 0;
+        }
+
+        if ($memberID == 0) {
+
+            // There should have been a member ID - So failure
+            return array(
+                'status' => false,
+                'menuItemRedirect' => 'error',
+                'modelRedirect' => 'index',
+                'view' => 'admin/error/index.html',
+                'data' => false
+            );
+        }
+
+        switch($option) {
+
+            case 'add':
+
+                // Geenerate new entry
+                $packageInfo = $this->newEntry();
+
+                break;
+
+            case 'insert':
+
+                // Try to insert the new entry
+                $packageInfo = $this->insertEntry();
+
+                // If the package inserted successfully
+                if ($packageInfo && $packageInfo['status']) {
+
+                    // Get the new package ID
+                    $packageID = $packageInfo['fieldData']['id'];
+
+                    // Get the package data again prepared for editing
+                    $packageInfo = $this->editEntry($packageID);
+
+                    // Say what we have
+                    $havePackage = true;
+                    $packageUpdated = true;
+
+                    // Tell the template we're going to be editing.
+                    $option = 'edit';
+
+                // Otherwise, the package didn't successfully submit
+                } else {
+
+                    // Tell the template there were errors and let them try again
+                    $packageError = true;
+
+                }
+                break;
+
+            case 'edit':
+
+                // Get the package prepared for editing
+                $packageInfo = $this->editEntry($packageID);
+
+                // If we have good package data, tell the template
+                if ($packageInfo) {
+                    $havePackage = true;
+                }
+
+                break;
+
+            case 'update':
+
+                // Try to update the package with the submitted data
+                $packageInfo = $this->updateEntry($packageID);
+
+                // If it updated successfully
+                if ($packageInfo && $packageInfo['status']) {
+
+                    // Get the package data again prepared for editing
+                    $packages = $this->editEntry($packageID);
+
+                    // Tell the template the package was updated
+                    $packageUpdated = true;
+
+                // Otherwise it didn't update, tell the template and let them try again
+                } else {
+                    $packageError = true;
+                }
+
+                // Tell the template we have a package and we're editing it
+                $havePackage = true;
+                $option = 'edit';
+
+                break;
+
+            case 'delete':
+                if ($id > 0) {
+                    $this->deleteEntry($id, true);
+                }
+                break;
+
+            case 'list':
+            default:
+
+                // Get the list of packages
+                $packages = $this->getList("T.ref_type = ".$this->config['ref_type_numb']['Member']." AND T.ref_dest = ".$memberID);
+
+                // If we have some, tell the template
+                if ($packages && count($packages) > 0) {
+                    $havePackages = true;
+                }
+
+                // Set the option to list in case we got here by default
+                $option = 'list';
+
+                break;
+        }
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice($packages, 'DataBlock', 'Package Data');
+        }
+
+        // If we have list entries - even if it's an empty list
+        $success = true;
+        $havePackages = false;
+        if ($packages !== false) {
+
+            $success = true;
+
+            // If we have any entries
+            if (count($packages) > 0) {
+                $havePackages = true;
+            }
+        }
+
+        // If we had a fatal error, redirect to the error page
+        if ($error) {
+            return array(
+                    'status' => $success,
+                    'option' => $option,
+                    'menuItemRedirect' => 'error',
+                    'modelRedirect' => 'index',
+                    'view' => 'admin/error/index.html',
+                    'data' => false
+            );
+        }
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data');
+        }
+
+        // Compile template data
+        $templateData = array(
+            'havePackages' => $havePackages,
+            'packages' => $packages,
+            'havePackage' => $havePackage,
+            'packageUpdated' => $packageUpdated,
+            'packageID' => $packageID,
+            'packageInfo' => $packageInfo,
+            'packageError' => $packageError,
+            'memberID' => $memberID,
+            'option' => $option
+        );
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+                'status' => true,
+                'modelRedirect' => false,
+                'view' => 'admin/member/packaging.html',
+                'data' => $templateData
+        );
+
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/models/admin/members/packaging.php b/models/admin/members/packaging.php
new file mode 100644 (file)
index 0000000..4809410
--- /dev/null
@@ -0,0 +1,275 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members DB - Packaging Add-on - Main packages list
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  packaging.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Member Types data abstract
+require_once(GLM_MEMBERS_PACKAGING_PLUGIN_CLASS_PATH.'/data/dataPackages.php');
+
+/**
+ * GlmMembersAdmin_members_packaging Package
+ *
+ * PHP version 5
+ *
+ * @category Model
+ * @package GLM Member DB
+ * @author  Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmMembersAdmin_members_packaging extends GlmDataPackages
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+
+    /*
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * '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.
+     *
+     * @wpdb object WordPress database object
+     *
+     * @return array Array containing status, suggested view, and any data
+     */
+    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);
+
+     }
+
+    public function modelAction($actionData = false)
+    {
+
+        $success = true;
+        $havePackages = false;
+        $packages = false;
+        $havePackage = false;
+        $packageUpdated = false;
+        $packageInfo = false;
+        $packageError = false;
+        $membersList = false;
+        $havePackageMembers = false;
+        $packageMembers = false;
+        $option = false;
+        $error = false;
+
+        // If there's an action option
+        $option = 'list';
+        if (isset($_REQUEST['option'])) {
+            $option = trim($_REQUEST['option']);
+        }
+
+        // Get any package ID
+        $packageID = 0;
+        if (isset($_REQUEST['packageID']) && ($_REQUEST['packageID']-0) > 0) {
+            $packageID = $_REQUEST['packageID'] - 0;
+        }
+
+        if ($option == 'add' || $option == 'edit') {
+            // Get simple member list
+            require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php');
+            $Members = new GlmDataMembers($this->wpdb, $this->config);
+            $membersList = $Members->getSimpleMembersList();
+        }
+
+        switch($option) {
+
+            case 'add':
+
+                // Geenerate new entry
+                $packageInfo = $this->newEntry();
+
+                break;
+
+            case 'insert':
+
+                // Try to insert the new entry
+                $packageInfo = $this->insertEntry();
+
+                // If the package inserted successfully
+                if ($packageInfo && $packageInfo['status']) {
+
+                    // Get the new package ID
+                    $packageID = $packageInfo['fieldData']['id'];
+
+                    // Get the package data again prepared for editing
+                    $packageInfo = $this->editEntry($packageID);
+
+                    // Say what we have
+                    $havePackage = true;
+                    $packageUpdated = true;
+
+                    // Tell the template we're going to be editing.
+                    $option = 'edit';
+
+                // Otherwise, the package didn't successfully submit
+                } else {
+
+                    // Tell the template there were errors and let them try again
+                    $option = 'add';
+                    $packageError = true;
+
+                }
+                break;
+
+            case 'edit':
+
+                // Get the package prepared for editing
+                $packageInfo = $this->editEntry($packageID);
+
+                // If we have good package data, tell the template
+                if ($packageInfo) {
+                    $havePackage = true;
+                }
+
+                break;
+
+            case 'update':
+
+                // Try to update the package with the submitted data
+                $packageInfo = $this->updateEntry($packageID);
+
+                // If it updated successfully
+                if ($packageInfo && $packageInfo['status']) {
+
+                    // Get the package data again prepared for editing
+                    $packages = $this->editEntry($packageID);
+
+                    // Tell the template the package was updated
+                    $packageUpdated = true;
+
+                // Otherwise it didn't update, tell the template and let them try again
+                } else {
+                    $packageError = true;
+                }
+
+                // Tell the template we have a package and we're editing it
+                $havePackage = true;
+                $option = 'edit';
+
+                break;
+
+            case 'delete':
+                if ($id > 0) {
+                    $this->deleteEntry($id, true);
+                }
+                break;
+
+            case 'list':
+            default:
+
+                // Get the list of packages
+                $packages = $this->getList("T.ref_type = 0");
+
+                // If we have some, tell the template
+                if ($packages && count($packages) > 0) {
+                    $havePackages = true;
+                }
+
+                // Set the option to list in case we got here by default
+                $option = 'list';
+
+                break;
+        }
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice($packages, 'DataBlock', 'Package Data');
+        }
+
+        // If we have list entries - even if it's an empty list
+        $success = true;
+        $havePackages = false;
+        if ($packages !== false) {
+
+            $success = true;
+
+            // If we have any entries
+            if (count($packages) > 0) {
+                $havePackages = true;
+            }
+        }
+
+        // If we had a fatal error, redirect to the error page
+        if ($error) {
+            return array(
+                    'status' => $success,
+                    'option' => $option,
+                    'menuItemRedirect' => 'error',
+                    'modelRedirect' => 'index',
+                    'view' => 'admin/error/index.html',
+                    'data' => false
+            );
+        }
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Types Data');
+        }
+
+        // Compile template data
+        $templateData = array(
+            'havePackages' => $havePackages,
+            'packages' => $packages,
+            'havePackage' => $havePackage,
+            'packageUpdated' => $packageUpdated,
+            'packageID' => $packageID,
+            'packageInfo' => $packageInfo,
+            'packageError' => $packageError,
+            'havePackageMembers' => $havePackageMembers,
+            'packageMembers' => $packageMembers,
+            'membersList' => $membersList,
+            'option' => $option
+        );
+
+        // Return status, any suggested view, and any data to controller
+        return array(
+                'status' => true,
+                'modelRedirect' => false,
+                'view' => 'admin/members/packaging.html',
+                'data' => $templateData
+        );
+
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/models/admin/sample/index.php b/models/admin/sample/index.php
deleted file mode 100644 (file)
index 4a64cd6..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * GLM Members DB - Packaging Add-on - Sample Index Model
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @release  admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
- * @link     http://dev.gaslightmedia.com/
- */
-
-/*
- * This model is called when the "Shortcodes" menu is selected
- *
- */
-class GlmMembersAdmin_sample_index
-{
-
-    /**
-     * WordPress Database Object
-     *
-     * @var $wpdb
-     * @access public
-     */
-    public $wpdb;
-
-    /*
-     * Constructor
-     *
-     * This contructor performs the work for this model. This model returns
-     * an array containing the following.
-     *
-     * 'status'
-     *
-     * True if successfull and false if there was a fatal failure.
-     *
-     * '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.
-     *
-     * @wpdb object WordPress database object
-     *
-     * @return array Array containing status, suggested view, and any data
-     */
-    public function __construct ($wpdb, $config)
-    {
-
-        // Save WordPress Database object
-        $this->wpdb = $wpdb;
-
-        // Save plugin configuration object
-        $this->config = $config;
-
-    }
-
-    public function modelAction($actionData = false) {
-
-        // Return status, any suggested view, and any data to controller
-        return array(
-                'status' => true,
-                'modelRedirect' => false,
-                'view' => 'admin/sample/index.html',
-                'data' => false
-        );
-
-    }
-}
-
-?>
\ No newline at end of file
index a420b34..b0f6c3d 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 /*
- * To add a new tab to an existing Member DB page use a blick
+ * To add a new tab to an existing Member DB page use a block
  * like this and replace the {} parameters.
  *
  * add_filter('glm-member-db-add-tab-for-{menu name}',
  *
  */
 
+add_filter('glm-member-db-add-tab-for-members',
+    function($addOnTabs) {
+        $newTabs = array(
+            array(
+                'text' => 'Packaging',
+                'menu' => 'members',
+                'action' => 'packaging'
+            )
+        );
+        $addOnTabs = array_merge($addOnTabs, $newTabs);
+        return $addOnTabs;
+    }
+);
+
+add_filter('glm-member-db-add-tab-for-member',
+    function($addOnTabs) {
+        $newTabs = array(
+            array(
+                'text' => 'Packaging',
+                'menu' => 'member',
+                'action' => 'packaging'
+            )
+        );
+        $addOnTabs = array_merge($addOnTabs, $newTabs);
+        return $addOnTabs;
+    }
+);
+
+
 ?>
\ No newline at end of file
diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql
new file mode 100644 (file)
index 0000000..fa080fb
--- /dev/null
@@ -0,0 +1,51 @@
+-- Gaslight Media Members Database - Packaging 
+-- File Created: 12/02/15 15:27:15
+-- Database Version: 0.0.2
+-- Database Creation Script
+-- 
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Packages 
+CREATE TABLE {prefix}packages (
+  id INT NOT NULL AUTO_INCREMENT,
+  active BOOLEAN NULL,                      -- Package is active
+  title TINYTEXT NULL,                      -- Title of package
+  descr TEXT NULL,                          -- Description of package
+  short_descr TINYTEXT NULL,                -- Short description of package
+  image TINYTEXT NULL,                      -- Package image
+  start_date TIMESTAMP NULL,                -- Date display of this package starts
+  end_date TIMESTAMP NULL,                  -- Date display of this package ends (last date of display)
+  expire_date TIMESTAMP NULL,               -- Date package expires (first date it's expired)
+  position INT NULL,                        -- Display order position
+  pricing TINYTEXT NULL,                    -- Pricing, descriptive
+  ref_type INT NULL,                        -- Type of entity this package is associated with
+  ref_dest INT NULL,                        -- Pointer to the specific entity
+  PRIMARY KEY (id),                         
+  INDEX(ref_type),
+  INDEX(ref_dest),
+  INDEX(start_date),
+  INDEX(end_date),
+  INDEX(expire_date)
+);
+
+----
+
+-- Package Elements - Items in a package
+CREATE TABLE {prefix}package_elements (
+  id INT NOT NULL AUTO_INCREMENT,
+  package INT NULL,                         -- Pointer to the package
+  active BOOLEAN NULL,                      -- Package is active
+  title TINYTEXT NULL,                      -- Title of element
+  descr TEXT NULL,                          -- Description for this entity's participation in the package
+  short_descr TEXT NULL,                    -- Short description for this entity's participation in the package
+  image TINYTEXT NULL,                      -- Element image
+  position INT NULL,                        -- Display order position
+  ref_type INT NULL,                        -- Type of entity this element is association with
+  ref_dest INT NULL,                        -- Pointer to the specific entity
+  PRIMARY KEY (id),
+  INDEX(package),
+  INDEX(ref_type),
+  INDEX(ref_dest)
+);
+
diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php
new file mode 100644 (file)
index 0000000..5451371
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members Packaging DB Versions
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  dbVersions.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+$glmMembersPackagingDbVersions = array(
+            '0.0.2' => array('version' => '0.0.2', 'tables' => 2)
+);
+
index a766289..ba1e4d4 100644 (file)
  * DB plugin when this plugin registers itself.
  */
 
-$glmMembersAddOnValidActions = array(
+$glmMembersPackagingAddOnValidActions = array(
     'adminActions' => array(
-        'sample' => array(
-            'index' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG
+        'members' => array(
+            'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG
+        ),
+        'member' => array(
+            'packaging' => GLM_MEMBERS_PACKAGING_PLUGIN_SLUG
         )
     ),
     'frontActions' => array(
diff --git a/views/admin/member/packaging.html b/views/admin/member/packaging.html
new file mode 100644 (file)
index 0000000..611230d
--- /dev/null
@@ -0,0 +1,184 @@
+{include file='admin/member/header.html'}
+
+    {if $packageUpdated}<h2 class="glm-notice glm-flash-updated">Package Updated</h2>{/if}
+    {if $packageError}<h2 class="glm-error glm-flash-updated">Error submitting package, see below...</h2>{/if}
+    
+{if $option == 'edit' || $option == 'add'}
+    
+  {if $option == 'edit'}
+    <h2>Edit Package</h2>
+  {else}
+    <h2>Add new Package</h2>
+  {/if}
+
+
+    <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="packaging">
+        <input type="hidden" name="member" value="{$memberID}">
+        <input type="hidden" name="ref_type" value="{$ref_type_numb.Member}">
+        <input type="hidden" name="ref_dest" value="{$memberID}">
+      {if $havePackage}
+        <input type="hidden" name="option" value="update">
+        <input type="hidden" name="packageID" value="{$packageID}">
+      {else}
+        <input type="hidden" name="option" value="insert">
+      {/if}
+
+        <table class="glm-admin-table">
+            <tr>
+                <th>Active:</th>
+                <td>
+                    <input type="checkbox" name="active" {if $packageInfo.fieldData.active.value} checked{/if}>
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.title}class="glm-required"{/if}>Title:</th>
+                <td {if $packageInfo.fieldFail.title}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="title" value="{$packageInfo.fieldData.title}" class="glm-form-text-input-short">
+                    {if $packageInfo.fieldFail.title}<p>{$packageInfo.fieldFail.title}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+            <th {if $packageInfo.fieldRequired.descr}class="glm-required"{/if}>Description:</th>
+            <td {if $packageInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
+                {php} 
+                    wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array(
+                        // 'media_buttons' => true,
+                        // 'quicktags' => false,
+                        // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
+                        'textarea_name' => 'descr',
+                        'editor_height' => 200,     // Height in px, overrides editor_rows
+                            // 'textarea_rows' => 8
+                    ));
+                {/php}
+                {if $packageInfo.fieldFail.descr}<p>{$packageInfo.fieldFail.descr}</p>{/if}
+            </td>
+        </tr>
+        <tr>
+            <th {if $packageInfo.fieldRequired.short_descr}class="glm-required"{/if}>Short Description:</th>
+            <td {if $packageInfo.fieldFail.short_descr}class="glm-form-bad-input"{/if}>
+                <input type="text" name="short_descr" value="{$packageInfo.fieldData.short_descr}" class="glm-form-text-input" placeholder="A short, one line, description of the package.">
+                {if $packageInfo.fieldFail.short_descr}<p>{$packageInfo.fieldFail.short_descr}</p>{/if}
+            </td>
+        </tr>
+        <tr>
+            <th {if $packageInfo.fieldRequired.image}class="glm-required"{/if}>Logo:</th>
+            <td {if $packageInfo.fieldFail.image}class="glm-form-bad-input"{/if}>
+                <table class="glm-admin-image-edit-table">
+    {if $packageInfo.fieldData.image}
+                    <tr>
+                        <td>
+                            <div class="glm-galleryImage" data-id="logo">
+                                <img src="{$glmPluginMediaURL}/images/small/{$packageInfo.fieldData.image}">
+                            </div>
+                        </td>
+                        <td>
+                            <input type="checkbox" name="logo_delete"> Delete Image<br>
+                            {$packageInfo.fieldData.image}<br>
+                        </td>
+                    </tr>
+    {/if}
+                    <tr><td colspan="2"><b>New image:</b> <input type="file" name="logo_new"></td></tr>
+                </table>
+                <div id="glm-galleryImageLarger_logo" class="glm-imageDialog"><img src="{$glmPluginMediaURL}/images/large/{$packageInfo.fieldData.image}"></div>
+                {if $packageInfo.fieldFail.image}<p>{$packageInfo.fieldFail.image}</p>{/if}
+            </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.start_date}class="glm-required"{/if}>Start Date:</th>
+                <td {if $packageInfo.fieldFail.start_date}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="start_date" value="{$packageInfo.fieldData.start_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                    {if $packageInfo.fieldFail.start_date}<p>{$packageInfo.fieldFail.start_date}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.end_date}class="glm-required"{/if}>End Date:</th>
+                <td {if $packageInfo.fieldFail.end_date}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="end_date" value="{$packageInfo.fieldData.end_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                    {if $packageInfo.fieldFail.end_date}<p>{$packageInfo.fieldFail.end_date}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.expire_date}class="glm-required"{/if}>Expire Date:</th>
+                <td {if $packageInfo.fieldFail.expire_date}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="expire_date" value="{$packageInfo.fieldData.expire_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                    {if $packageInfo.fieldFail.expire_date}<p>{$packageInfo.fieldFail.expire_date}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.pricing}class="glm-required"{/if}>Pricing Description:</th>
+                <td {if $packageInfo.fieldFail.pricing}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="pricing" value="{$packageInfo.fieldData.pricing}" class="glm-form-text-input" placeholder="Describe package pricing.">
+                    {if $packageInfo.fieldFail.pricing}<p>{$packageInfo.fieldFail.pricing}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.position}class="glm-required"{/if}>Display Order:</th>
+                <td {if $packageInfo.fieldFail.position}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="position" value="{$packageInfo.fieldData.position}" class="glm-form-text-input-short">
+                    {if $packageInfo.fieldFail.position}<p>{$packageInfo.fieldFail.position}</p>{/if}
+                </td>
+            </tr>
+        </table>
+        <input type="submit" value="{if $havePackage}Update Package{else}Add New Package{/if}">
+    </form>
+
+{else} <!-- option is not edit or add -->
+    
+    <div id="addPackageButton" class="button-primary glm-right">Add a Package</div>    
+    <h2>Multi-Member Packages</h2>
+
+    <table class="wp-list-table striped glm-admin-table">
+        <thead>
+            <tr>
+                <th>Package</th>
+                <th>Start</th>
+                <th>End</th>
+                <th>Expire</th>
+            </tr>
+        </thead>
+        <tbody>
+  {if $havePackages}
+    {foreach $packages as $p}
+            <tr>
+                <td>
+                    <a href="{$thisURL}?page={$thisPage}&glm_action=packaging&option=edit&packageID={$p.id}&member={$memberID}">{$p.title}</a>
+                </td>
+                <td>
+                    {$p.start_date.date}
+                </td>
+                <td>
+                    {$p.end_date.date}
+                </td>
+                <td>
+                    {$p.expire_date.date}
+                </td>
+            </tr>
+    {/foreach}
+  {else}
+            <tr class="alternate"><td colspan="5">(no packages listed)</td></tr>
+  {/if}
+        </tbody>
+    </table>
+
+{/if} <!-- end of option test -->
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+    
+            // Add Package Button Action
+            $('#addPackageButton').click( function() {
+                window.location.href = "{$thisURL}?page={$thisPage}&glm_action=packaging&option=add&member={$memberID}";
+            });
+            
+            // Date Input
+            $('.glm-date-input').datepicker();
+//            $( "#glmStartDate" ).datepicker();
+            
+            // Flash certain elements for a short time after display      
+            $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+        });
+    </script>
+            
+{include file='admin/footer.html'}
diff --git a/views/admin/members/packaging.html b/views/admin/members/packaging.html
new file mode 100644 (file)
index 0000000..23d1992
--- /dev/null
@@ -0,0 +1,280 @@
+{include file='admin/members/header.html'}
+
+    {if $packageUpdated}<h2 class="glm-notice glm-flash-updated">Package Updated</h2>{/if}
+    {if $packageError}<h2 class="glm-error glm-flash-updated">Error submitting package, see below...</h2>{/if}
+    
+{if $option == 'edit' || $option == 'add'}
+    
+  {if $option == 'edit'}
+    <h2>Edit Multi-Member Package</h2>
+  {else}
+    <h2>Add new Multi-Member Package</h2>
+  {/if}
+
+
+    <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="glm_action" value="packaging">
+        <input type="hidden" name="ref_type" value="0">
+        <input type="hidden" name="ref_dest" value="0">
+      {if $havePackage}
+        <input type="hidden" name="option" value="update">
+        <input type="hidden" name="packageID" value="{$packageID}">
+      {else}
+        <input type="hidden" name="option" value="insert">
+      {/if}
+
+        <table class="glm-admin-table">
+            <tr>
+                <th>Active:</th>
+                <td>
+                    <input type="checkbox" name="active" {if $packageInfo.fieldData.active.value} checked{/if}>
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.title}class="glm-required"{/if}>Title:</th>
+                <td {if $packageInfo.fieldFail.title}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="title" value="{$packageInfo.fieldData.title}" class="glm-form-text-input-short">
+                    {if $packageInfo.fieldFail.title}<p>{$packageInfo.fieldFail.title}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+            <th {if $packageInfo.fieldRequired.descr}class="glm-required"{/if}>Description:</th>
+            <td {if $packageInfo.fieldFail.descr}class="glm-form-bad-input"{/if}>
+                {php} 
+                    wp_editor('{$packageInfo.fieldData.descr|escape:quotes}', 'glm_descr', array(
+                        // 'media_buttons' => true,
+                        // 'quicktags' => false,
+                        // 'wpautop' => false,  NOTE: Dont's use. Problem when numerous spaces before text.
+                        'textarea_name' => 'descr',
+                        'editor_height' => 200,     // Height in px, overrides editor_rows
+                            // 'textarea_rows' => 8
+                    ));
+                {/php}
+                {if $packageInfo.fieldFail.descr}<p>{$packageInfo.fieldFail.descr}</p>{/if}
+            </td>
+        </tr>
+        <tr>
+            <th {if $packageInfo.fieldRequired.short_descr}class="glm-required"{/if}>Short Description:</th>
+            <td {if $packageInfo.fieldFail.short_descr}class="glm-form-bad-input"{/if}>
+                <input type="text" name="short_descr" value="{$packageInfo.fieldData.short_descr}" class="glm-form-text-input" placeholder="A short, one line, description of the package.">
+                {if $packageInfo.fieldFail.short_descr}<p>{$packageInfo.fieldFail.short_descr}</p>{/if}
+            </td>
+        </tr>
+        <tr>
+            <th {if $packageInfo.fieldRequired.image}class="glm-required"{/if}>Logo:</th>
+            <td {if $packageInfo.fieldFail.image}class="glm-form-bad-input"{/if}>
+                <table class="glm-admin-image-edit-table">
+    {if $packageInfo.fieldData.image}
+                    <tr>
+                        <td>
+                            <div class="glm-galleryImage" data-id="logo">
+                                <img src="{$glmPluginMediaURL}/images/small/{$packageInfo.fieldData.image}">
+                            </div>
+                        </td>
+                        <td>
+                            <input type="checkbox" name="logo_delete"> Delete Image<br>
+                            {$packageInfo.fieldData.image}<br>
+                        </td>
+                    </tr>
+    {/if}
+                    <tr><td colspan="2"><b>New image:</b> <input type="file" name="logo_new"></td></tr>
+                </table>
+                <div id="glm-galleryImageLarger_logo" class="glm-imageDialog"><img src="{$glmPluginMediaURL}/images/large/{$packageInfo.fieldData.image}"></div>
+                {if $packageInfo.fieldFail.image}<p>{$packageInfo.fieldFail.image}</p>{/if}
+            </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.start_date}class="glm-required"{/if}>Start Date:</th>
+                <td {if $packageInfo.fieldFail.start_date}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="start_date" value="{$packageInfo.fieldData.start_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                    {if $packageInfo.fieldFail.start_date}<p>{$packageInfo.fieldFail.start_date}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.end_date}class="glm-required"{/if}>End Date:</th>
+                <td {if $packageInfo.fieldFail.end_date}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="end_date" value="{$packageInfo.fieldData.end_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                    {if $packageInfo.fieldFail.end_date}<p>{$packageInfo.fieldFail.end_date}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.expire_date}class="glm-required"{/if}>Expire Date:</th>
+                <td {if $packageInfo.fieldFail.expire_date}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="expire_date" value="{$packageInfo.fieldData.expire_date.date}" class="glm-form-text-input-short glm-date-input" placeholder="Click for Calendar">
+                    {if $packageInfo.fieldFail.expire_date}<p>{$packageInfo.fieldFail.expire_date}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.pricing}class="glm-required"{/if}>Pricing Description:</th>
+                <td {if $packageInfo.fieldFail.pricing}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="pricing" value="{$packageInfo.fieldData.pricing}" class="glm-form-text-input" placeholder="Describe package pricing.">
+                    {if $packageInfo.fieldFail.pricing}<p>{$packageInfo.fieldFail.pricing}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th {if $packageInfo.fieldRequired.position}class="glm-required"{/if}>Display Order:</th>
+                <td {if $packageInfo.fieldFail.position}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="position" value="{$packageInfo.fieldData.position}" class="glm-form-text-input-short">
+                    {if $packageInfo.fieldFail.position}<p>{$packageInfo.fieldFail.position}</p>{/if}
+                </td>
+            </tr>
+            <tr>
+                <th>Participating Members</th>
+                <td class="glm-imageGalleryContainer">
+
+                    
+                    Search to add a member: <input  id="glmMembersList" type="text" id="autoTest" style="margin-left: 2em;"><br>
+                                        
+                    
+                    <input type="hidden" id="galleryPositionOrder" name="galleryPositionOrder" 
+                        value="{if $havePackageMembers}{foreach $gallery as $i name=ig}{if $i.title}{$i.id}{if not $smarty.foreach.ig.last},{/if}{/if}{/foreach}{/if}" />
+
+                    <!-- The contents of this div are read by imageUpload.js to use as a template for inserting a new image into the gallery area -->
+                    <div id="glmGalleryItmeDataTemplate" class="glm-imageItemHidden">
+                        <li id="packageMember_{ id }" class="glm-galleryContainerFlexible">
+                            <input type="hidden" name="packageMember_{ id }" value="{ id }">
+                            <input type="hidden" name="position_{ id }" value="{ position }">
+                                <table class="glm-statusTable">
+                                    <tr><th>Package Member:</th><td>{ memberName }</td></tr>
+                                    <tr><th>Active:</th><td><input type="checkbox"></td></tr>
+                                    <tr><th>Package Element Title:</th><td><input type="text" value=""></td></tr>
+                                    <tr><th>Description:</th><td><input type="text" value=""></td></tr>
+                                    <tr><th>Short Description:</th><td><input type="text" value=""></td></tr>
+                                    <tr><th>Image:</th><td><input type="file"></td></tr>
+                                </table>
+                        </li>
+                    </div>
+                    <!-- End of template -->
+                    <div class="glm-imageGalleryContainer glm-item-container">
+                        <ul id="glmPackageMembersList" class=".glm-galleryContainer">
+        {if $havePackageMembers}     
+                            <!-- Note that id in li is needed for sorting -->
+            {foreach $packageMembers as $i}
+                            <li id="packageMember_{$i.id}" class="glm-galleryContainerFlexible">
+                                <input type="hidden" name="packageMember_{$i.id}" value="{$i.id}">
+                                <input type="hidden" name="position_{$i.id}" value="{$i.position}">
+                                <div class="glm-galleryImageData">
+                                <table class="glm-galleryContainerContent">
+                                    <tr><th>Package Member:</th><td>{$i.memberName}</td></tr>
+                                    <tr><th>Active:</th><td><input type="checkbox"></td></tr>
+                                    <tr><th>Package Element Title:</th><td><input type="text"></td></tr>
+                                    <tr><th>Description:</th><td><input type="text"></td></tr>
+                                    <tr><th>Short Description:</th><td><input type="text"></td></tr>
+                                    <tr><th>Image:</th><td><input type="file"></td></tr>
+                                    
+                                </table>
+                                </div>
+                            </li>
+            {/foreach}
+        {else}
+                            <li id="glmNoMembersSelected">No members have been added to this package yet.<br>Please select a member above.</li>
+        {/if}
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+        
+            
+            
+            
+            
+        </table>
+        <input type="submit" value="{if $havePackage}Update Package{else}Add New Package{/if}">
+    </form>
+
+{else} <!-- option is not edit or add -->
+    
+    <div id="addPackageButton" class="button-primary glm-right">Add a Package</div>    
+    <h2>Multi-Member Packages</h2>
+
+    <table class="wp-list-table striped glm-admin-table">
+        <thead>
+            <tr>
+                <th>Package</th>
+                <th>Start</th>
+                <th>End</th>
+                <th>Expire</th>
+            </tr>
+        </thead>
+        <tbody>
+  {if $havePackages}
+    {foreach $packages as $p}
+            <tr>
+                <td>
+                    <a href="{$thisURL}?page={$thisPage}&glm_action=packaging&option=edit&packageID={$p.id}">{$p.title}</a>
+                </td>
+                <td>
+                    {$p.start_date.date}
+                </td>
+                <td>
+                    {$p.end_date.date}
+                </td>
+                <td>
+                    {$p.expire_date.date}
+                </td>
+            </tr>
+    {/foreach}
+  {else}
+            <tr class="alternate"><td colspan="5">(no packages listed)</td></tr>
+  {/if}
+        </tbody>
+    </table>
+
+{/if} <!-- end of option test -->
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+    
+            // Add Package Button Action
+            $('#addPackageButton').click( function() {
+                window.location.href = "{$thisURL}?page={$thisPage}&glm_action=packaging&option=add";
+            });
+            
+            // Date Input
+            $('.glm-date-input').datepicker();
+//            $( "#glmStartDate" ).datepicker();
+            
+            // Flash certain elements for a short time after display      
+            $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+            /*
+             * Package Members Processing
+             */
+
+             // Build a list of members for the autocomplete search
+             var availableTags = [
+     {foreach $membersList as $m}
+                 { label: "{$m.name|unescape:'html'}", value: "{$m.name|unescape:'html'}", id: '{$m.id}', name: "{$m.name}" },
+     {/foreach}
+              ];
+
+             $( "#glmMembersList" ).autocomplete({
+                 source: availableTags,
+                 html: true,
+                 select: function( event, ui ) {
+
+                     // get the member ID and Name
+                     var memberID = ui.item.id;
+                     var memberName = ui.item.name
+
+                     // Get a copy of the template 
+                     var memberTemplate = $('#glmGalleryItmeDataTemplate').html();
+                     
+                     // Set the member data into the template copy
+                     memberTemplate = memberTemplate.replace('{ id }', memberID).replace('{ memberName }', memberID);
+                     
+                     // Insert the selected member
+                     $('#glmPackageMembersList').append(memberTemplate);
+
+                     {if !$havePackageMembers}
+                     // Hide the no members selected message
+                     $('#glmNoMembersSelected').hide();                     
+        {/if}        
+
+                 }
+             });
+
+        });
+    </script>
+            
+{include file='admin/footer.html'}
diff --git a/views/admin/sample/header.html b/views/admin/sample/header.html
deleted file mode 100644 (file)
index f9fdb91..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="wrap">
-       
-    <h2>{$glmPluginName}</h2>
-    
-  
\ No newline at end of file
diff --git a/views/admin/sample/index.html b/views/admin/sample/index.html
deleted file mode 100644 (file)
index 6159f5d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-{include file='admin/sample/header.html'}
-
-    <h2>A Sample Add-On Menu</h2>
-
-    This is a test
-
-{include file='admin/footer.html'}