From f1f5809b81dbd2333d9febd70a739cd8032e339b Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 29 Mar 2018 11:40:28 -0400 Subject: [PATCH] Adding settings for allow_employees and membeship_choice Adding two settings. allow_employees - setup for migcsa allow_membership_choice - on renew form allow member to choice the membership level. --- classes/billingSupport.php | 3 +++ classes/data/dataSettings.php | 14 ++++++++++++++ index.php | 2 +- models/admin/member/billing.php | 4 ++-- ...V0.0.16.sql => create_database_V0.0.17.sql} | 2 ++ setup/databaseScripts/dbVersions.php | 1 + .../update_database_V0.0.17.sql | 14 ++++++++++++++ views/admin/billing/renew.html | 15 ++++++++++++--- views/admin/settings/billing.html | 18 ++++++++++++++++++ views/front/billing/renew.html | 13 ++++++++++--- 10 files changed, 77 insertions(+), 9 deletions(-) rename setup/databaseScripts/{create_database_V0.0.16.sql => create_database_V0.0.17.sql} (98%) create mode 100644 setup/databaseScripts/update_database_V0.0.17.sql diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 62f0005..69d6f8d 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -784,6 +784,9 @@ class GlmBillingSupport public function getListOfAccountEmployees( $member_id ) { $accounts = array(); + if ( !$this->config['settings']['allow_employees'] ) { + return $accounts; + } // This may need to have filters setup in the contact plugin as well. $employees = apply_filters( 'glm_contact_has_employees', '', $member_id ); // echo '
$employees: ' . print_r( $employees, true ) . '
'; diff --git a/classes/data/dataSettings.php b/classes/data/dataSettings.php index 124ab2c..3864417 100644 --- a/classes/data/dataSettings.php +++ b/classes/data/dataSettings.php @@ -223,6 +223,20 @@ class GlmDataBillingSettings extends GlmDataAbstract 'use' => 'a', ), + // Allow membership level choice + 'allow_membership_choice' => array( + 'field' => 'allow_membership_choice', + 'type' => 'checkbox', + 'use' => 'a', + ), + + // Allow Employees + 'allow_employees' => array( + 'field' => 'allow_employees', + 'type' => 'checkbox', + 'use' => 'a', + ), + ); } diff --git a/index.php b/index.php index f831a1f..6b16dd6 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.16'); +define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.17'); // 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/models/admin/member/billing.php b/models/admin/member/billing.php index 20322d1..85c1231 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -209,12 +209,12 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling // echo '
$employees: ' . print_r( $employees, true ) . '
'; // Load DataClass for Management. - require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); $management = $Management->getEntry( 1 ); // Need to see if there's an account for this member. - require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; $account = $Accounts->editEntry( $accountID ); break; diff --git a/setup/databaseScripts/create_database_V0.0.16.sql b/setup/databaseScripts/create_database_V0.0.17.sql similarity index 98% rename from setup/databaseScripts/create_database_V0.0.16.sql rename to setup/databaseScripts/create_database_V0.0.17.sql index 564d691..df04f9d 100644 --- a/setup/databaseScripts/create_database_V0.0.16.sql +++ b/setup/databaseScripts/create_database_V0.0.17.sql @@ -218,6 +218,8 @@ CREATE TABLE {prefix}settings ( payment_terms TEXT NULL, -- Payment Terms days_before_renewal INT NULL, -- Number of days before renewal date to allow renewals days_after_expired INT NULL, -- Number of days after renewal date expired + allow_membership_choice BOOLEAN DEFAULT '0', -- If memberships can choose their membership levels when they renew + allow_employees BOOLEAN DEFAULT '0', -- If memberships have employees PRIMARY KEY (id) ); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index b4dccd3..b9dd82e 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -30,5 +30,6 @@ $glmMembersBillingDbVersions = array( '0.0.14' => array('version' => '0.0.14', 'tables' => 14), '0.0.15' => array('version' => '0.0.15', 'tables' => 14), '0.0.16' => array('version' => '0.0.16', 'tables' => 14), + '0.0.17' => array('version' => '0.0.17', 'tables' => 14), ); diff --git a/setup/databaseScripts/update_database_V0.0.17.sql b/setup/databaseScripts/update_database_V0.0.17.sql new file mode 100644 index 0000000..1c2a7d4 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.17.sql @@ -0,0 +1,14 @@ +-- Gaslight Media Billing Database +-- File Created: 03/28/2018 +-- Database Version: 0.0.15 +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Update the settings +ALTER TABLE {prefix}settings ADD allow_membership_choice BOOLEAN DEFAULT '0'; -- If memberships can choose their membership levels when they renew + +---- + +-- Update the settings +ALTER TABLE {prefix}settings ADD allow_employees BOOLEAN DEFAULT '0'; -- If memberships have employees diff --git a/views/admin/billing/renew.html b/views/admin/billing/renew.html index c9b28c8..7a43577 100644 --- a/views/admin/billing/renew.html +++ b/views/admin/billing/renew.html @@ -28,7 +28,7 @@ Membership Class
-
{/if} @@ -210,7 +213,13 @@ jQuery(document).ready(function($){ // Calculate the total for this page. // Get the member_renewing amount. - var member_renewing_amount = parseFloat( $('input[name=member_renewing]:checked').data('amount') ); + if ( $('input[name=member_renewing]:checked').length ) { + var member_renewing_amount = parseFloat( $('input[name=member_renewing]:checked').data('amount') ); + } else { + var member_renewing_amount = parseFloat( $('input[name=member_renewing]').data('amount') ); + } + console.log( member_renewing_amount ); + // Get each employee and add their amounts. $('input[name^=employees]').each(function(){ diff --git a/views/admin/settings/billing.html b/views/admin/settings/billing.html index f704fd6..636ab88 100644 --- a/views/admin/settings/billing.html +++ b/views/admin/settings/billing.html @@ -20,6 +20,24 @@ + + + + + + + + + +
+ Allow Membership Choice When renewing + + +
+ Allow Employees + + +
diff --git a/views/front/billing/renew.html b/views/front/billing/renew.html index 3d15717..5ba2666 100644 --- a/views/front/billing/renew.html +++ b/views/front/billing/renew.html @@ -24,7 +24,7 @@ Membership Class
-
{/if} @@ -206,7 +209,11 @@ jQuery(document).ready(function($){ // Calculate the total for this page. // Get the member_renewing amount. - var member_renewing_amount = parseFloat( $('input[name=member_renewing]:checked').data('amount') ); + if ( $('input[name=member_renewing]:checked').length ) { + var member_renewing_amount = parseFloat( $('input[name=member_renewing]:checked').data('amount') ); + } else { + var member_renewing_amount = parseFloat( $('input[name=member_renewing]').data('amount') ); + } // Get each employee and add their amounts. $('input[name^=employees]').each(function(){ -- 2.17.1