From fe7f0a2c2592bb7238d8d231f6301b1e60462990 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 8 Jan 2018 16:53:59 -0500 Subject: [PATCH] Started adding new database table and code to support payment codes in the cart data and other things. Updated database with reg_request_pay_code table. Added not_attending flag to reg_request_registrant Started adding code to regCartSupport to add submitted pay codes to the cart and to check them for credits. --- classes/data/dataRegRequestPayCode.php | 146 ++++++++++++++++++ classes/regCartSupport.php | 10 +- index.php | 2 +- ...0.0.20.sql => create_database_V0.0.21.sql} | 14 ++ setup/databaseScripts/dbVersions.php | 3 +- ..._V0.0.20.sql => drop_database_V0.0.21.sql} | 3 +- .../update_database_V0.0.21.sql | 5 +- views/front/registrations/cart.html | 9 ++ 8 files changed, 185 insertions(+), 7 deletions(-) create mode 100644 classes/data/dataRegRequestPayCode.php rename setup/databaseScripts/{create_database_V0.0.20.sql => create_database_V0.0.21.sql} (98%) rename setup/databaseScripts/{drop_database_V0.0.20.sql => drop_database_V0.0.21.sql} (89%) diff --git a/classes/data/dataRegRequestPayCode.php b/classes/data/dataRegRequestPayCode.php new file mode 100644 index 0000000..f7b0201 --- /dev/null +++ b/classes/data/dataRegRequestPayCode.php @@ -0,0 +1,146 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataRegRequestPayCode.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataRegistrationsRequestPayCode class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataRegRequestPayCode.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataRegistrationsRequestPayCode 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_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request_pay_code'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + // ID + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Pointer to payment code + 'payment_code' => array ( + 'field' => 'payment_code', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Pointer to reg_request table entry + 'reg_request' => array ( + 'field' => 'reg_request', + 'type' => 'integer', + 'required' => true, + 'use' => 'a' + ), + + // Total Credit applied to cart using this code + 'credit' => array ( + 'field' => 'credit', + 'type' => 'float', 'required' => false, + 'default' => 0, + 'use' => 'a' + ) + ); + + } + +} diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index edadf15..f490c11 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -210,6 +210,9 @@ class GlmRegCartSupport // Add submitting account if not guest submission (at this point) $this->addAccountToCart($this->cart['request']['account']); + // Add any payment codes + + // Get list of events being requested $this->cart['events'] = $RequestEvent->getList("T.reg_request = $requestId"); @@ -377,7 +380,7 @@ class GlmRegCartSupport $haveEvents = false; // If we have a cart and a good request array - if ($this->cart && is_array($this->cart['request'])) { + if ($this->cart && is_array($this->cart['request'])) {class_name TINYTEXT // If a submission account is specified (otherwise it should be a guest user prior to checkout) if ($this->cart['request']['account'] && !isset($this->cart['accounts'][$this->cart['request']['account']])) { @@ -653,6 +656,8 @@ class GlmRegCartSupport $haveEvents = true; + // Check for event payment code + // Save totals for this event $this->cart['events'][$eventKey]['eventRegistrants'] = $eventRegistrants; $this->cart['events'][$eventKey]['eventCharges'] = $eventCharges; @@ -671,6 +676,9 @@ class GlmRegCartSupport } // Each event + // Check for global payment code + + } // Have events } // have request diff --git a/index.php b/index.php index 063645a..9f7ca72 100644 --- a/index.php +++ b/index.php @@ -44,7 +44,7 @@ if (!defined('ABSPATH')) { * version from this plugin. */ define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '0.0.20'); +define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '0.0.21'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.10.17'); diff --git a/setup/databaseScripts/create_database_V0.0.20.sql b/setup/databaseScripts/create_database_V0.0.21.sql similarity index 98% rename from setup/databaseScripts/create_database_V0.0.20.sql rename to setup/databaseScripts/create_database_V0.0.21.sql index f68af17..02b6cea 100644 --- a/setup/databaseScripts/create_database_V0.0.20.sql +++ b/setup/databaseScripts/create_database_V0.0.21.sql @@ -518,6 +518,7 @@ CREATE TABLE {prefix}reg_request_registrant ( reg_request_event INT NULL, -- Pointer to reg_request_event table entry reg_request_class INT NULL, -- Pointer to reg_request_class table entry reg_request_rate INT NULL, -- Pointer to reg_request_rate table entry + not_attending BOOLEAN DEFAULT false, -- Flag to say if registrant is not attending - set to true when not attending fname TINYTEXT NULL, -- First name of registrant at the time of selection lname TINYTEXT NULL, -- Last name of registrant at the time of selection notes TEXT NULL, -- System operator's notes for this registration request @@ -533,6 +534,19 @@ CREATE TABLE {prefix}reg_request_registrant ( ---- +-- A specific use of a payment code in this request +CREATE TABLE {prefix}reg_request_pay_code ( + id INT NOT NULL AUTO_INCREMENT, + payment_code INT NULL, -- Pointer to payment code + reg_request INT NULL, -- Pointer to the registration request record + credit DOUBLE PRECISION NULL, -- Total credit for this payment code + PRIMARY KEY (id), + INDEX (payment_code), + INDEX (reg_request) +); + +---- + -- Insert into management table INSERT INTO {prefix}management ( diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index dfbbb34..751677a 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -33,7 +33,8 @@ $glmMembersRegistrationsDbVersions = array( '0.0.17' => array('version' => '0.0.17', 'tables' => 15, 'date' => '11/3/2017'), '0.0.18' => array('version' => '0.0.18', 'tables' => 15, 'date' => '11/7/2017'), '0.0.19' => array('version' => '0.0.19', 'tables' => 15, 'date' => '11/22/2017'), - '0.0.20' => array('version' => '0.0.20', 'tables' => 16, 'date' => '01/02/2018') + '0.0.20' => array('version' => '0.0.20', 'tables' => 16, 'date' => '01/02/2018'), + '0.0.21' => array('version' => '0.0.21', 'tables' => 17, 'date' => '01/08/2018') ); diff --git a/setup/databaseScripts/drop_database_V0.0.20.sql b/setup/databaseScripts/drop_database_V0.0.21.sql similarity index 89% rename from setup/databaseScripts/drop_database_V0.0.20.sql rename to setup/databaseScripts/drop_database_V0.0.21.sql index e8754ae..2ac0fe3 100644 --- a/setup/databaseScripts/drop_database_V0.0.20.sql +++ b/setup/databaseScripts/drop_database_V0.0.21.sql @@ -20,6 +20,7 @@ DROP TABLE IF EXISTS {prefix}reg_request_event, {prefix}reg_request_class, {prefix}reg_request_rate, - {prefix}reg_request_registrant + {prefix}reg_request_registrant, + {prefix}reg_request_pay_code ; diff --git a/setup/databaseScripts/update_database_V0.0.21.sql b/setup/databaseScripts/update_database_V0.0.21.sql index 6ad98d8..e4b0aa8 100644 --- a/setup/databaseScripts/update_database_V0.0.21.sql +++ b/setup/databaseScripts/update_database_V0.0.21.sql @@ -10,7 +10,7 @@ CREATE TABLE {prefix}reg_request_pay_code ( id INT NOT NULL AUTO_INCREMENT, payment_code INT NULL, -- Pointer to payment code reg_request INT NULL, -- Pointer to the registration request record - credit DOUBLE PRECISION NULL -- Total credit for this payment code + credit DOUBLE PRECISION NULL, -- Total credit for this payment code PRIMARY KEY (id), INDEX (payment_code), INDEX (reg_request) @@ -18,5 +18,4 @@ CREATE TABLE {prefix}reg_request_pay_code ( ---- - - +ALTER TABLE {prefix}reg_request_registrant ADD COLUMN not_attending BOOLEAN DEFAULT false; diff --git a/views/front/registrations/cart.html b/views/front/registrations/cart.html index 65e1020..d0c6b48 100644 --- a/views/front/registrations/cart.html +++ b/views/front/registrations/cart.html @@ -37,10 +37,19 @@ {/if} +
Request ID: {$cartId}

Selected Registrations

+ +
+
+ If you have a "payment Code", please enter it here: + + +
+
{assign var="summaryType" value="cart"} {include file='front/registrations/cartSummary.html'} -- 2.17.1