From: Steve Sutton Date: Wed, 23 May 2018 19:40:02 +0000 (-0400) Subject: Updates for referred by and db changes X-Git-Tag: v1.0.0^2~28 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=b555fa3c4151941c561feae9a130d4bf86d68d85;p=WP-Plugins%2Fglm-member-db-travel.git Updates for referred by and db changes new db table for lead to referred by. changes for notes delete add. --- diff --git a/classes/data/dataReferredBy.php b/classes/data/dataReferredBy.php new file mode 100644 index 0000000..ce1d611 --- /dev/null +++ b/classes/data/dataReferredBy.php @@ -0,0 +1,430 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataEvent 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 GlmDataReferredBy extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'referredby'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Name + 'name' => array( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'unique' => true, + 'use' => 'a' + ), + + // Parent - for adding, deleting and editing, has selection tabels + 'parent' => array( + 'field' => 'parent', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'referredby', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, + 'force_list' => true, + 'required' => false, + 'use' => 'a' + ) + + ); + + } + + /** + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + + + /** + * Add a category using supplied parameters + * + * @param string $name Category Name + * @param mixed $parent Existing Parent ID or name of parent to add + * + * @return integer ID of new category or false if failed + * + * @access public + */ + + public function addCategory($name, $parent) { + + $categoryID = false; + $parentID = false; + + // Filter new category name + $name = filter_var($name); + if ($name == false || trim($name) == '') { + return false; + } + + // Determine parent supplied as an ID + + $parentInt = $parent - 0; + if (is_int($parent) && $parentInt > 0) { + + // If it's not positive, then fail + if ($parent <= 0) { + return false; + } + + // Check that parent exists + $sql = " + SELECT COUNT(id) AS count + FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories + WHERE id = $parent + ;"; + $test = $this->wpdb->get_row($sql, ARRAY_A); + + // Should be only one entry if the parent category exists + if ($test['count'] != 1) { + return false; + } + + $parentID = $parent; + + // Else check to see if parent was supplied as a name + } elseif ($parent != '') { + + $parent = filter_var($parent); + + // If the name didn't pass the filer then fail + if ($parent == false) { + return false; + } + + // Check if the name already exists + $sql = " + SELECT id + FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories + WHERE name = '$parent' + ;"; + $parentCategory = $this->wpdb->get_row($sql, ARRAY_A); + + // If we found the parent ID + if ($parentCategory['id']) { + + // Set that as the parent ID for the new category + $parentID = $parentCategory['id']; + + // Otherwise, try to add the parent category + } else { + + // Add the parent as a new category + $sql = " + INSERT INTO ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories + ( name, parent ) + VALUES + ( '".addslashes($parent)."', 0 ) + ;"; + $this->wpdb->query($sql); + $parentID = $this->wpdb->insert_id; + + // Check if it didn't store properly + if (!$parentID) { + return false; + } + + } + + // Otherwise the categroy being added has no parent + } else { + $parentID = 0; + } + + // Check if the new category name/parent already exists + $sql = " + SELECT id + FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories + WHERE name = '$name' + AND parent = $parentID + ;"; + $existing = $this->wpdb->get_row($sql, ARRAY_A); + + if ($existing['id']) { + + $categoryID = $existing['id']; + + } else { + + // Try to add the new category + $sql = " + INSERT INTO ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories + ( name, parent ) + VALUES + ( '".addslashes($name)."', $parentID ) + ;"; + $this->wpdb->query($sql); + $categoryID = $this->wpdb->insert_id; + + } + + return $categoryID; + + } + + /** + * Get categories list sorted by parent/child then alpha + * + * @return array Array of categories + * @param boolean $forEdit If true include list of options for each parent field + * + * @access public + */ + + public function getListSortedParentChild($forEdit = true) { + + $categories = $this->getList(); + $categoriesSorted = $this->sortParentChild($categories); + + if (!$forEdit) { + while (list($k, $v) = each($categoriesSorted)) { + $categoriesSorted[$k]['parent_id'] = $v['parent']['value']; + $categoriesSorted[$k]['parent'] = $v['parent']['name']; + } + } + + return $categoriesSorted; + + } + + /** + * getCategoriesWithCurrentEvents + * + * Returns a list of categories ordered by name that have an event with + * current event times. + * + * @access public + * @return void + */ + public function getCategoriesWithCurrentEvents() + { + $where = " T.id IN ( + SELECT category + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories + WHERE event IN ( + SELECT event + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times + WHERE active + AND start_time >= NOW() + ) + AND event IN ( + SELECT id + FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events + WHERE status = 10 + ) + ) "; + $order = "T.name"; + return $this->getList($where, $order); + } + + /** + * Check other requirements + * + * When deleteing categories, check for references in sub-categories and set them to no parent. + * + */ + function checkOther($r, $a) + { + // Required + parent::checkOther($r, $a); + + // If there's a valid category ID + if (isset($r['id']) && $r['id'] > 0) { + + // Set any parent references with this ID to 0 + $sql = " + UPDATE ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories + SET parent = 0 + WHERE parent = ".$r['id']." + ;"; + $this->wpdb->query($sql); + + } + + return $r; + } + + /** + * Sort a database result array (from DataAbstract.php) by parent, child relationships + * + * @param array $array Array to be sorted + * @param string $name Name of array element that represents the text to sort on + * @param string $parent Name of the array element that represents the parent ID to sort on + * + * @return array Sorted array + */ + public static function sortParentChild($array, $name = 'name', $parent = 'parent') + { + + if (!is_array($array) || count($array) == 0) { + return false; + } + + // Do a sort by custom function with it included in the call + // This lets me directly use $name and $parent in the sort function + uasort($array, function ($a, $b) use ($name, $parent) { + // If there's a parent, append the name of this entry to the parent + // The '~~~' simply keeps appended strings from any chance of a match with something else + if ($a[$parent]['value']) { + $aVal = $a[$parent]['name'].'~~~'.$a['name']; + } else { + // Otheriwse just use the name. + $aVal = $a['name'].'~~~'; + } + + // Same for b value + if ($b[$parent]['value']) { + $bVal = $b[$parent]['name'].'~~~'.$b['name']; + } else { + $bVal = $b['name'].'~~~'; + } + + if ($aVal > $bVal) { + return 1; + } + + if ($aVal < $bVal) { + return -1; + } + + return 0; + + }); + + return $array; + } + +} diff --git a/css/admin.css b/css/admin.css new file mode 100644 index 0000000..e11a094 --- /dev/null +++ b/css/admin.css @@ -0,0 +1,35 @@ +.glm-travel-edit { + max-width: 600px; +} + +.glm-travel-edit .tsLog { + margin: 10px 0; + border-top: 1px dotted #369; + border: 1px solid #eee; + height: 1%; + overflow: hidden; +} +.glm-travel-edit .tsLog h2 { + font-family: Georgia, arial, sans-serif; + font-size: 16px; + padding: 5px 10px; + background: #eee; + font-weight: normal; + margin: 0 0 1em 0 ; +} +.glm-travel-edit .tsLog p { + margin: 0 10px; +} +.glm-travel-edit .tlDelete { + display: block; + float: right; + width: 16px; + height: 16px; + background: url(../assets/cancel.png) no-repeat; + text-indent: -9000px; + margin: 10px; +} + +#addLog textarea { + width: 500px; +} diff --git a/index.php b/index.php index 11455c0..743e580 100644 --- a/index.php +++ b/index.php @@ -44,7 +44,7 @@ if (!defined('ABSPATH')) { * version from this plugin. */ define('GLM_MEMBERS_TRAVEL_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_TRAVEL_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_TRAVEL_PLUGIN_DB_VERSION', '0.0.2'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_TRAVEL_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); diff --git a/models/admin/ajax/travelNotes.php b/models/admin/ajax/travelNotes.php index 693be80..db556ec 100644 --- a/models/admin/ajax/travelNotes.php +++ b/models/admin/ajax/travelNotes.php @@ -85,7 +85,7 @@ class GlmMembersAdmin_ajax_travelNotes extends GlmDataTravelNotes case 'list': default: $lead_id = filter_var( $_REQUEST['lead_id'], FILTER_VALIDATE_INT ); - $notes = $this->getList( "T.lead = $lead_id" ); + $notes = $this->getList( "T.lead = $lead_id", "T.created DESC" ); $view = 'list.html'; break; diff --git a/models/admin/settings/referredBy.php b/models/admin/settings/referredBy.php new file mode 100644 index 0000000..5436dc9 --- /dev/null +++ b/models/admin/settings/referredBy.php @@ -0,0 +1,193 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Event Categories data abstract +require_once GLM_MEMBERS_TRAVEL_PLUGIN_CLASS_PATH.'/data/dataReferredBy.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_settings_referredBy extends GlmDataReferredBy +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + // Run constructor for members data class + parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * 'view' + * + * A suggested view name that the controller should use instead of the + * default view for this model or false to indicate that the default view + * should be used. + * + * 'data' + * + * Data that the model is returning for use in merging with the view to + * produce output. + * + */ + public function modelAction ($actionData = false) + { + + $success = true; + $haveReferredBy = false; + $referredby = false; + $error = false; + + // Check if a category ID is supplied + $id = 0; + if (isset($_REQUEST['id'])) { + $id = $_REQUEST['id']-0; + } + + // If there's an action option + if (isset($_REQUEST['option'])) { + + switch($_REQUEST['option']) { + + case 'addNew': + $this->insertEntry(); + break; + + case 'update': + if ($id > 0) { + $this->updateEntry($id); + } + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + + // Also delete from member info + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'referredby', + array( + 'category' => $id + ) + ); + } + break; + + } + + } + + // Get a current list of referredby + $referredby = $this->getList(); + + // If we have list entries - even if it's an empty list + $success = true; + $haveReferredBy = false; + if ($referredby !== false) { + + $success = true; + + // If we have any entries + if (count($referredby) > 0) { + $haveReferredBy = true; + } + } + + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + // Sort results by hierarchy (Parent/Child and Alpha) + $referredby = $this->sortParentChild($referredby); + + // Compile template data + $templateData = array( + 'haveReferredBy' => $haveReferredBy, + 'referredby' => $referredby + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/referredBy.html', + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php index 819d733..fb3e0b0 100644 --- a/models/admin/travel/index.php +++ b/models/admin/travel/index.php @@ -363,14 +363,12 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads switch ( $option ) { case 'addLog': - echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; - $this->wpdb->insert( GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes', array( 'lead' => $this->entryId, - 'created' => date( 'Y-m-d' ), - 'updated' => date( 'Y-m-d' ), + 'created' => date( 'Y-m-d H:i:s' ), + 'updated' => date( 'Y-m-d H:i:s' ), 'notes' => filter_var( $_REQUEST['new_log'], FILTER_SANITIZE_STRING ) ), array( @@ -381,6 +379,32 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads ) ); + // return array( + // 'status' => true, + // 'modelRedirect' => 'index', + // // 'menuItemRedirect' => 'index', + // 'data' => array( + // 'option' => 'edit', + // 'id' => $this->entryId, + // ) + // ); + + $entry = $this->editEntry( $this->entryId ); + $view = 'edit.html'; + break; + case 'deleteLog': + if ( isset( $_REQUEST['id'] ) + && isset( $_REQUEST['note_id'] ) + && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) + && $note_id = filter_var( $_REQUEST['note_id'], FILTER_VALIDATE_INT ) + ) { + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes', + array( 'lead' => $id, 'id' => $note_id ), + array( '%d', '%d' ) + ); + } + $entry = $this->editEntry( $this->entryId ); $view = 'edit.html'; break; diff --git a/setup/adminTabs.php b/setup/adminTabs.php index f506281..015bc89 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -33,3 +33,21 @@ * */ +if (current_user_can('glm_members_members')) { + + add_filter('glm-member-db-add-tab-for-settings', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Referred By', + 'menu' => 'settings', + 'action' => 'referredBy' + ), + + ); + $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 deleted file mode 100644 index a4cf815..0000000 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ /dev/null @@ -1,84 +0,0 @@ --- Gaslight Media Travel Leads Module --- File Created: 05/18/2018 --- Database Version: 0.0.1 --- Database Creation Script --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes --- --- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** --- - --- Leads -CREATE TABLE {prefix}leads ( - id INT NOT NULL AUTO_INCREMENT, - status INT NOT NULL DEFAULT 0, -- Lead Status (active, inactive) - create_date DATE NOT NULL, -- Date contact was created - updated DATETIME NOT NULL, -- Updated Timestamp - fname TEXT NULL, -- First Name - lname TEXT NULL, -- Last Name - email TINYTEXT NULL, -- Email - company TEXT NULL, -- Company Name - address TEXT NULL, -- Address - address2 TEXT NULL, -- Address 2 - city TEXT NULL, -- City - state TEXT NULL, -- State - zip TEXT NULL, -- ZIP - phone TEXT NULL, -- Phone - fax TEXT NULL, -- Fax - mail_ok BOOLEAN DEFAULT false, -- Mail OK (boolean) - website TEXT NULL, -- Website URL - PRIMARY KEY (id), - INDEX(create_date), - INDEX(email(20)), - INDEX(fname(20)), - INDEX(lname(20)) -); - ----- - --- ReferredBy Groups -CREATE TABLE {prefix}referredby_groups ( - id INT NOT NULL AUTO_INCREMENT, - name TEXT NOT NULL, -- Group Name - PRIMARY KEY (id) -); - ----- - --- ReferredBy -CREATE TABLE {prefix}referredby ( - id INT NOT NULL AUTO_INCREMENT, - groupid INT NOT NULL, -- Group Id - name TINYTEXT NOT NULL, -- Name - pos INT NOT NULL DEFAULT 0, -- Position number - PRIMARY KEY (id), - INDEX(groupid) -); - ----- - --- Lead Notes -CREATE TABLE {prefix}lead_notes ( - id INT NOT NULL AUTO_INCREMENT, - lead INT NOT NULL, -- Reference to lead table - created DATETIME NOT NULL, -- Created Timestamp - updated DATETIME NOT NULL, -- Updated Timestamp - notes TEXT, -- Note Entry - PRIMARY KEY (id), - INDEX(lead) -); - ----- - --- Lead Contacts -CREATE TABLE {prefix}lead_contacts ( - id INT NOT NULL AUTO_INCREMENT, - lead INT NOT NULL, -- Reference to lead table - updated DATETIME NOT NULL, -- Updated Timestamp - name TINYTEXT, -- Name of Contact - email TINYTEXT, -- Email of Contact - phone TINYTEXT, -- Phone of Contact - PRIMARY KEY (id), - INDEX(lead) -); diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql new file mode 100644 index 0000000..01c3e97 --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -0,0 +1,86 @@ +-- Gaslight Media Travel Leads Module +-- File Created: 05/18/2018 +-- Database Version: 0.0.1 +-- Database Creation Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes +-- +-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES **** +-- + +-- Leads +CREATE TABLE {prefix}leads ( + id INT NOT NULL AUTO_INCREMENT, + status INT NOT NULL DEFAULT 0, -- Lead Status (active, inactive) + create_date DATE NOT NULL, -- Date contact was created + updated DATETIME NOT NULL, -- Updated Timestamp + fname TEXT NULL, -- First Name + lname TEXT NULL, -- Last Name + email TINYTEXT NULL, -- Email + company TEXT NULL, -- Company Name + address TEXT NULL, -- Address + address2 TEXT NULL, -- Address 2 + city TEXT NULL, -- City + state TEXT NULL, -- State + zip TEXT NULL, -- ZIP + phone TEXT NULL, -- Phone + fax TEXT NULL, -- Fax + mail_ok BOOLEAN DEFAULT false, -- Mail OK (boolean) + website TEXT NULL, -- Website URL + PRIMARY KEY (id), + INDEX(create_date), + INDEX(email(20)), + INDEX(fname(20)), + INDEX(lname(20)) +); + +---- + +-- ReferredBy +CREATE TABLE {prefix}referredby ( + id INT NOT NULL AUTO_INCREMENT, + parent INT NOT NULL, -- Pointer to the parent referredby id + name TINYTEXT NOT NULL, -- Name + PRIMARY KEY (id), + INDEX(parent) +); + +---- + +-- Referred By to Leads +CREATE TABLE {prefix}leads_referredby ( + id INT NOT NULL AUTO_INCREMENT, + lead INT NOT NULL, -- Reference to lead table + referredby INT NOT NULL, -- Reference to referred by table + PRIMARY KEY (id), + INDEX(lead), + INDEX(referredby) +); + +---- + +-- Lead Notes +CREATE TABLE {prefix}lead_notes ( + id INT NOT NULL AUTO_INCREMENT, + lead INT NOT NULL, -- Reference to lead table + created DATETIME NOT NULL, -- Created Timestamp + updated DATETIME NOT NULL, -- Updated Timestamp + notes TEXT, -- Note Entry + PRIMARY KEY (id), + INDEX(lead) +); + +---- + +-- Lead Contacts +CREATE TABLE {prefix}lead_contacts ( + id INT NOT NULL AUTO_INCREMENT, + lead INT NOT NULL, -- Reference to lead table + updated DATETIME NOT NULL, -- Updated Timestamp + name TINYTEXT, -- Name of Contact + email TINYTEXT, -- Email of Contact + phone TINYTEXT, -- Phone of Contact + PRIMARY KEY (id), + INDEX(lead) +); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 1a972c5..e102a64 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -26,6 +26,7 @@ * exist with that version. */ $glmMembersTravelDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 5, 'date' => '05/18/18'), + '0.0.1' => array('version' => '0.0.1', 'tables' => 4, 'date' => '05/18/18'), + '0.0.2' => array('version' => '0.0.2', 'tables' => 5, 'date' => '05/23/18'), ); diff --git a/setup/databaseScripts/update_database_V0.0.2.sql b/setup/databaseScripts/update_database_V0.0.2.sql new file mode 100644 index 0000000..df8e32d --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.2.sql @@ -0,0 +1,17 @@ +-- Gaslight Media Members Database - Events Add-On +-- File Created: 05/23/2018 +-- Database Version: 0.0.2 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Referred By to Leads +CREATE TABLE {prefix}leads_referredby ( + id INT NOT NULL AUTO_INCREMENT, + lead INT NOT NULL, -- Reference to lead table + referredby INT NOT NULL, -- Reference to referred by table + PRIMARY KEY (id), + INDEX(lead), + INDEX(referredby) +); diff --git a/setup/validActions.php b/setup/validActions.php index 89159c2..744dc39 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -64,6 +64,9 @@ $glmMembersTravelAddOnValidActions = array( 'travelInterest' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, 'travelNotes' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, ), + 'settings' => array( + 'referredBy' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, + ), 'travel' => array( 'index' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, ) diff --git a/views/admin/ajax/notes/list.html b/views/admin/ajax/notes/list.html index f1fb609..210fc8d 100644 --- a/views/admin/ajax/notes/list.html +++ b/views/admin/ajax/notes/list.html @@ -3,13 +3,14 @@ - + {foreach $notes as $n}

{$n.updated.datetime}

- {$n.notes|nl2br} +

{$n.notes|nl2br}

+ Delete
{/foreach} diff --git a/views/admin/settings/referredBy.html b/views/admin/settings/referredBy.html new file mode 100644 index 0000000..89a3fc7 --- /dev/null +++ b/views/admin/settings/referredBy.html @@ -0,0 +1,179 @@ +{include file='admin/settings/header.html'} + + +
Add a Referred By
+
+
+ + + + + + + + + + + + +
Referred By Name: + +
Parent Referred By: + +
+

* Required

+ Cancel + +
+
+ + +
+
+

Are you sure you want to delete this referred by?

+

Yes, delete this referred by

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + + + + + + +
Referred By Name: + +
Parent Referred By: + +
Description: + +
+

* Required

+ Cancel + +
+
+ +

Referred By

+ + + + + + + + + + +{if $haveReferredBy} + {assign var="i" value="0"} + {foreach $referredby as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + {/foreach} +{else} + +{/if} + +
IDReferred By 
{$t.id} + + {$t.name} + + +
Delete
+
(no referred by listed)
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/travel/edit.html b/views/admin/travel/edit.html index d788d19..782369b 100644 --- a/views/admin/travel/edit.html +++ b/views/admin/travel/edit.html @@ -10,13 +10,13 @@ {/if} -
+
diff --git a/views/admin/travel/index.html b/views/admin/travel/index.html index e746ccf..fd3a043 100644 --- a/views/admin/travel/index.html +++ b/views/admin/travel/index.html @@ -6,12 +6,12 @@ - - - - - - + + + + + +
EditCompanyFirst NameLast NameUpdatedStatus Edit Company First Name Last Name Updated Status