Leads Add-On Roughed in, now creates database tables, ready for mode and view code
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 13 Jun 2016 17:48:27 +0000 (13:48 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 13 Jun 2016 17:48:27 +0000 (13:48 -0400)
13 files changed:
classes/data/dataLeads.php
classes/data/dataManagement.php [new file with mode: 0644]
models/admin/leads/index.php
models/admin/management/leads.php [new file with mode: 0644]
setup/adminMenus.php
setup/adminTabs.php
setup/databaseScripts/create_database_V0.0.1.sql
setup/databaseScripts/dbVersions.php
setup/frontHooks.php
setup/validActions.php
views/admin/leads/header.html [new file with mode: 0644]
views/admin/leads/index.html [new file with mode: 0644]
views/admin/management/leads.html [new file with mode: 0644]

index c380550..363537a 100644 (file)
@@ -113,16 +113,10 @@ class GlmDataLeads extends GlmDataAbstract
                 'type' => 'integer',
                 'view_only' => true,
                 'use' => 'a'
-            ),
-
-            // Active flag
-            'active' => array (
-                'field' => 'active',
-                'type' => 'checkbox',
-                'default' => true,
-                'use' => 'a'
             )
 
+/* MORE STUFF GOES HERE */
+
          );
 
     }
diff --git a/classes/data/dataManagement.php b/classes/data/dataManagement.php
new file mode 100644 (file)
index 0000000..831eb5f
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Leads 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 $
+ */
+
+/**
+ * GlmDataLeadsManagement 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 GlmDataLeadsManagement 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_LEADS_PLUGIN_DB_PREFIX . 'management';
+
+        /*
+         * Table Data Fields
+         */
+
+        $this->fields = array (
+
+            'id' => array (
+                'field'     => 'id',
+                'type'      => 'integer',
+                'view_only' => true,
+                'use'       => 'a'
+            )
+
+/* STUFF TO ADD HERE */
+
+         );
+
+    }
+
+    /*
+     * 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 4c2caf7..6a1739a 100644 (file)
@@ -16,7 +16,7 @@
 // Load Leads data abstract
 require_once(GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataLeads.php');
 
-class GlmMembersAdmin_members_leads extends GlmDataLeads
+class GlmMembersAdmin_leads_index extends GlmDataLeads
 {
 
     /**
@@ -84,7 +84,6 @@ class GlmMembersAdmin_members_leads extends GlmDataLeads
 
         // Compile template data
         $templateData = array(
-            'displayData' => $displayData
         );
 
         // Return status, any suggested view, and any data to controller
diff --git a/models/admin/management/leads.php b/models/admin/management/leads.php
new file mode 100644 (file)
index 0000000..123238f
--- /dev/null
@@ -0,0 +1,135 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * GLM Members DB - Leads Add-on - Management Events Tab
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  leadss.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+/**
+ * GlmMembersAdmin_management_leads
+ *
+ * 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_management_leads // extends GlmDataLeadsManagement
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * dbh Postgres database connection
+     *
+     * @var mixed
+     * @access public
+     */
+    public $dbh;
+    /**
+     * settings used for the schema and tablenames
+     *
+     * @var mixed
+     * @access public
+     */
+    public $settings = array();
+    /**
+     * categories
+     *
+     * @var bool
+     * @access public
+     */
+    public $categories = array();
+    public $oldCatMap = array();
+    /**
+     * events
+     *
+     * @var bool
+     * @access public
+     */
+    public $events = array();
+    public $image_owner;
+
+    /**
+     * 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);
+
+    }
+
+    /**
+     * modelAction
+     *
+     * @param bool $actionData
+     * @access public
+     * @return void
+     */
+    public function modelAction($actionData = false)
+    {
+
+
+        // Compile template data
+        $templateData = array(
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status'           => true,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => 'admin/management/leads.html',
+            'data'             => $templateData
+        );
+
+
+    }
+
+}
index 933f81b..61b2c74 100644 (file)
  *
  */
 
+// Add Leads sub-menu for GLM Associate menu
+add_submenu_page(
+    'glm-members-admin-menu-members',
+    'Leads',
+    'Leads',
+    'glm_members_members',
+    'glm-members-admin-menu-leads-index',
+    function() {$this->controller('leads');}
+);
index c937a42..68614b1 100644 (file)
  *
  */
 
+
+// If user can manage all members
+if (current_user_can('glm_members_members')) {
+    if (apply_filters('glm_members_permit_admin_members_leads_tab', true)) {
+        add_filter('glm-member-db-add-tab-for-management',
+            function($addOnTabs) {
+                $newTabs = array(
+                    array(
+                        'text' => 'Leads',
+                        'menu' => 'management',
+                        'action' => 'leads'
+                    )
+                );
+                $addOnTabs = array_merge($addOnTabs, $newTabs);
+                return $addOnTabs;
+            }
+        );
+    }
+}
index 2aca3e1..46856e4 100644 (file)
@@ -20,7 +20,7 @@ CREATE TABLE {prefix}leads (
   member_ok BOOLEAN NULL,                   -- OK to have members contact lead
   created DATETIME NULL,                    -- Timestamp lead was first added
   PRIMARY KEY (id),
-  INDEX (email)
+  INDEX (email(20))
 );
 
 ----
@@ -31,7 +31,7 @@ CREATE TABLE {prefix}sources (
   title TINYTEXT NULL,                      -- Title/Name of source for reference
   code TINYTEXT NULL,                       -- Code supplied by form to indicate source
   PRIMARY KEY (id),
-  INDEX (code)
+  INDEX (code(20))
 );
 
 ----
@@ -60,8 +60,8 @@ CREATE TABLE {prefix}lead_entry (
   PRIMARY KEY (id),
   INDEX (source_id),
   INDEX (lead_id),
-  INDEX (fname),
-  INDEX (lname),
+  INDEX (fname(20)),
+  INDEX (lname(20)),
   INDEX (visit_date),
   INDEX (date_submitted)
 );
@@ -72,9 +72,7 @@ CREATE TABLE {prefix}lead_entry (
 CREATE TABLE {prefix}interest_groups (
   id INT NOT NULL AUTO_INCREMENT,
   title TINYTEXT NULL,                      -- Group name
-  PRIMARY KEY (id),
-  INDEX (interest_id),
-  INDEX (lead_entry_id)
+  PRIMARY KEY (id)
 );
 
 ----
@@ -94,7 +92,7 @@ CREATE TABLE {prefix}interests (
 CREATE TABLE {prefix}lead_interests (
   id INT NOT NULL AUTO_INCREMENT,
   interest_id SMALLINT NULL,                -- Pointer to Interest table
-  lead_entry_id INTERGER NULL,              -- Pointer to lead_entry table
+  lead_entry_id INTEGER NULL,              -- Pointer to lead_entry table
   PRIMARY KEY (id),
   INDEX (interest_id),
   INDEX (lead_entry_id)
@@ -139,9 +137,11 @@ CREATE TABLE {prefix}lead_stats_week (
   stat_week DATE NULL,                      -- First date of week for which these stats are accumulated
   leads_count INTEGER NULL,                 -- Number of leads
   PRIMARY KEY (id),
-  INDEX (state_week)
+  INDEX (stat_week)
 );
 
+----
+
 -- Lead Stats Month Data - Totals of lead stats for 1 month - Preserved indefinately - (generated daily?)
 CREATE TABLE {prefix}lead_stats_month (
   id INT NOT NULL AUTO_INCREMENT,
index 2c174c6..0d26ab7 100644 (file)
@@ -13,7 +13,7 @@
  * @link     http://dev.gaslightmedia.com/
  */
 
-$glmMembersSampleDbVersions = array(
-    '0.0.1' => array('version' => '0.0.1', 'tables' => 1, 'date' => '6/8/2016')
+$glmMembersLeadsDbVersions = array(
+    '0.0.1' => array('version' => '0.0.1', 'tables' => 11, 'date' => '6/8/2016')
 );
 
index 43a536f..00b947a 100644 (file)
  *
  *  *** Also note that parameters will be in the context of the main front controller constructor. ***
  */
+
+// Inject things into gravity forms fields - This intercepts all GravityForms before displaying them
+add_filter( 'gform_pre_render', function($form) {
+
+/*
+
+    // for each field in the form
+    foreach ( $form['fields'] as $k => $v ) {
+
+        // Check for a specific input field - in this case contact interests
+        // This must be the same field name for all forms that need this data
+        if ($v['inputName'] == 'contact_interest_options') {
+
+            // Inject sample options - *** THIS SHOULD BE FROM THE DATABASE TABLE OF LEADS INTERESTS ***
+            $form['fields'][$k]['choices'] = array(
+                0 => array(
+                    'text' => 'Skiing',
+                    'value' => '1',
+                    'isSelected' => false,
+                    'price' => false
+                ),
+                1 => array(
+                    'text' => 'Boating',
+                    'value' => '2',
+                    'isSelected' => false,
+                    'price' => false
+                ),
+                2 => array(
+                    'text' => 'Hiking',
+                    'value' => '3',
+                    'isSelected' => false,
+                    'price' => false
+                )
+            );
+        }
+
+    }
+
+*/
+
+
+    return $form;
+});
+
+// Check all GravityForm submissions to see if they are a form that supplies leads
+add_filter( 'gform_pre_render', function($form) {
+
+    // Check for some key field (perhaps hidden) that indicates that the form contains lead information
+
+    // Collect the leads data and store it using a data class
+
+});
index 34c7810..f262677 100644 (file)
  */
 
 $glmMembersLeadsAddOnValidActions = array(
+    'adminActions' => array(
+        'leads' => array(
+            'index' => GLM_MEMBERS_LEADS_PLUGIN_SLUG
+        ),
+        'management' => array(
+            'leads' => GLM_MEMBERS_LEADS_PLUGIN_SLUG
+        )
+    ),
 );
 
 ?>
\ No newline at end of file
diff --git a/views/admin/leads/header.html b/views/admin/leads/header.html
new file mode 100644 (file)
index 0000000..a70e7ba
--- /dev/null
@@ -0,0 +1,8 @@
+<div class="wrap">
+    <h2>All Leads</h2>
+    <h2 class="nav-tab-wrapper">
+        <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">Dashboard</a>
+    </h2>
+    <div id="glm-admin-content-container">
+    
+    
\ No newline at end of file
diff --git a/views/admin/leads/index.html b/views/admin/leads/index.html
new file mode 100644 (file)
index 0000000..1309ea5
--- /dev/null
@@ -0,0 +1,6 @@
+{include file='admin/leads/header.html'}
+
+<H1>ADMIN LEADS VIEW STUFF GOES HERE</H1>
+
+    
+{include file='admin/footer.html'}
\ No newline at end of file
diff --git a/views/admin/management/leads.html b/views/admin/management/leads.html
new file mode 100644 (file)
index 0000000..ef20a3a
--- /dev/null
@@ -0,0 +1,3 @@
+{include file='admin/management/header.html'}
+
+<H1>ADMIN LEADS MANAGEMENT VIEW STUFF GOES HERE</H1>
\ No newline at end of file