From f45c6fccee6cf85425625fa53cdff5d881ecafbc Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 20 Apr 2018 11:49:28 -0400 Subject: [PATCH] Update for the database Add boss to the accounts table. Adding new table for the employees. --- classes/data/dataEmployees.php | 172 ++++++++++++++++++ index.php | 2 +- ...0.0.19.sql => create_database_V0.0.22.sql} | 13 +- setup/databaseScripts/dbVersions.php | 2 + .../update_database_V0.0.20.sql | 2 +- .../update_database_V0.0.21.sql | 14 ++ .../update_database_V0.0.22.sql | 9 + 7 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 classes/data/dataEmployees.php rename setup/databaseScripts/{create_database_V0.0.19.sql => create_database_V0.0.22.sql} (97%) create mode 100644 setup/databaseScripts/update_database_V0.0.21.sql create mode 100644 setup/databaseScripts/update_database_V0.0.22.sql diff --git a/classes/data/dataEmployees.php b/classes/data/dataEmployees.php new file mode 100644 index 0000000..bb3aaac --- /dev/null +++ b/classes/data/dataEmployees.php @@ -0,0 +1,172 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataBillingManagement class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEmployees 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; + + /** + * In the Post Processing get the next_anniversary_date. + */ + public $postNextAnniversaryDate = 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_BILLING_PLUGIN_DB_PREFIX . 'employees'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a', + ), + + // Account ref to accounts table + 'account' => array( + 'field' => 'account', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'accounts', + 'p_field' => 'ref_dest', + 'p_orderby' => 'ref_name', + 'p_blank' => true, + 'required' => true, + 'use' => 'a' + ), + + // Employee ref to accounts table + 'employee' => array( + 'field' => 'employee', + 'type' => 'pointer', + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'accounts', + 'p_field' => 'ref_dest', + 'p_orderby' => 'ref_name', + 'p_blank' => true, + 'required' => true, + '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; + } + + +} diff --git a/index.php b/index.php index 2661175..9dfc503 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.20'); +define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.22'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_BILLING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); diff --git a/setup/databaseScripts/create_database_V0.0.19.sql b/setup/databaseScripts/create_database_V0.0.22.sql similarity index 97% rename from setup/databaseScripts/create_database_V0.0.19.sql rename to setup/databaseScripts/create_database_V0.0.22.sql index 267b92f..af0d452 100644 --- a/setup/databaseScripts/create_database_V0.0.19.sql +++ b/setup/databaseScripts/create_database_V0.0.22.sql @@ -1,6 +1,6 @@ -- Gaslight Media Billing Module -- File Created: 11/08/2017 --- Database Version: 0.0.19 +-- Database Version: 0.0.22 -- Database Creation Script -- -- To permit each query below to be executed separately, @@ -30,6 +30,7 @@ CREATE TABLE {prefix}accounts ( payment_profile_id TINYTEXT NULL, -- Payment Profile Id (Authorize.net) payment_profile_card TINYTEXT NULL, -- Payment Profile Card (Authorize.net) email TINYTEXT NULL, -- billing email + boss BOOLEAN DEFAULT '0', -- Boss flag PRIMARY KEY (id), INDEX(ref_dest), INDEX(ref_name(20)), @@ -266,3 +267,13 @@ INSERT INTO {prefix}management ( id ) VALUES ( 1 ); + +---- + +-- Employees table +CREATE TABLE {prefix}employees ( + id INT NOT NULL AUTO_INCREMENT, + accouunt INT NOT NULL, -- Account Id + employee INT NOT NULL, -- Employee Account Id + PRIMARY KEY (id) +); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 8a31b8d..f7768d2 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -34,5 +34,7 @@ $glmMembersBillingDbVersions = array( '0.0.18' => array('version' => '0.0.18', 'tables' => 14), '0.0.19' => array('version' => '0.0.19', 'tables' => 14), '0.0.20' => array('version' => '0.0.20', 'tables' => 14), + '0.0.21' => array('version' => '0.0.21', 'tables' => 15), + '0.0.22' => array('version' => '0.0.22', 'tables' => 15), ); diff --git a/setup/databaseScripts/update_database_V0.0.20.sql b/setup/databaseScripts/update_database_V0.0.20.sql index e4780ad..6d8594f 100644 --- a/setup/databaseScripts/update_database_V0.0.20.sql +++ b/setup/databaseScripts/update_database_V0.0.20.sql @@ -1,6 +1,6 @@ -- Gaslight Media Billing Database -- File Created: 04/06/2018 --- Database Version: 0.0.19 +-- Database Version: 0.0.20 -- -- To permit each query below to be executed separately, -- all queries must be separated by a line with four dashes diff --git a/setup/databaseScripts/update_database_V0.0.21.sql b/setup/databaseScripts/update_database_V0.0.21.sql new file mode 100644 index 0000000..aff9b3d --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.21.sql @@ -0,0 +1,14 @@ +-- Gaslight Media Billing Database +-- File Created: 04/06/2018 +-- Database Version: 0.0.21 +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Employees table +CREATE TABLE {prefix}employees ( + id INT NOT NULL AUTO_INCREMENT, + accouunt INT NOT NULL, -- Account Id + employee INT NOT NULL, -- Employee Account Id + PRIMARY KEY (id) +); diff --git a/setup/databaseScripts/update_database_V0.0.22.sql b/setup/databaseScripts/update_database_V0.0.22.sql new file mode 100644 index 0000000..b0eadd5 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.22.sql @@ -0,0 +1,9 @@ +-- Gaslight Media Billing Database +-- File Created: 04/06/2018 +-- Database Version: 0.0.22 +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Add boss field to accounts table +UPDATE TABLE {prefix}accounts ADD boss BOOLEAN DEFAULT '0'; -- Boss flag -- 2.17.1