From: Chuck Scott Date: Mon, 13 Jun 2016 17:48:27 +0000 (-0400) Subject: Leads Add-On Roughed in, now creates database tables, ready for mode and view code X-Git-Tag: v1.0.0^2~43 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=d4b70b10ff27f30815b6a29be0d803a8e3f5dbfd;p=WP-Plugins%2Fglm-member-db-leads.git Leads Add-On Roughed in, now creates database tables, ready for mode and view code --- diff --git a/classes/data/dataLeads.php b/classes/data/dataLeads.php index c380550..363537a 100644 --- a/classes/data/dataLeads.php +++ b/classes/data/dataLeads.php @@ -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 index 0000000..831eb5f --- /dev/null +++ b/classes/data/dataManagement.php @@ -0,0 +1,145 @@ + + * @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 + * @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; + } + +} + +?> diff --git a/models/admin/leads/index.php b/models/admin/leads/index.php index 4c2caf7..6a1739a 100644 --- a/models/admin/leads/index.php +++ b/models/admin/leads/index.php @@ -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 index 0000000..123238f --- /dev/null +++ b/models/admin/management/leads.php @@ -0,0 +1,135 @@ + + * @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 + * @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 + ); + + + } + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 933f81b..61b2c74 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -50,3 +50,12 @@ * */ +// 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');} +); diff --git a/setup/adminTabs.php b/setup/adminTabs.php index c937a42..68614b1 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -33,3 +33,22 @@ * */ + +// 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; + } + ); + } +} diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index 2aca3e1..46856e4 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -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, diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 2c174c6..0d26ab7 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -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') ); diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 43a536f..00b947a 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -25,3 +25,55 @@ * * *** 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 + +}); diff --git a/setup/validActions.php b/setup/validActions.php index 34c7810..f262677 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -31,6 +31,14 @@ */ $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 index 0000000..a70e7ba --- /dev/null +++ b/views/admin/leads/header.html @@ -0,0 +1,8 @@ +
+

All Leads

+ +
+ + \ No newline at end of file diff --git a/views/admin/leads/index.html b/views/admin/leads/index.html new file mode 100644 index 0000000..1309ea5 --- /dev/null +++ b/views/admin/leads/index.html @@ -0,0 +1,6 @@ +{include file='admin/leads/header.html'} + +

ADMIN LEADS VIEW STUFF GOES HERE

+ + +{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 index 0000000..ef20a3a --- /dev/null +++ b/views/admin/management/leads.html @@ -0,0 +1,3 @@ +{include file='admin/management/header.html'} + +

ADMIN LEADS MANAGEMENT VIEW STUFF GOES HERE

\ No newline at end of file