From 4e1636325472485c920fc1fd19c94677c15989a2 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 27 Nov 2018 16:37:54 -0500 Subject: [PATCH] New fields for the billing member tab Adding invoice delivery methods. Adding to the import to get these from uptra. Starting work on the bulk invoice create. --- classes/data/dataAccounts.php | 46 ++++- classes/data/dataSettings.php | 14 ++ config/plugin.ini | 1 - index.php | 2 +- models/admin/billing/invoices.php | 6 + models/admin/management/importAccounts.php | 9 +- models/admin/member/billing.php | 1 + ...0.0.27.sql => create_database_V0.0.28.sql} | 9 +- setup/databaseScripts/dbVersions.php | 1 + .../update_database_V0.0.28.sql | 29 +++ views/admin/billing/accounts.html | 10 +- views/admin/billing/bulkAddInvoices.html | 34 ++-- views/admin/billing/editAccount.html | 21 ++ views/admin/settings/billing.html | 183 ++++++++++-------- 14 files changed, 260 insertions(+), 106 deletions(-) rename setup/databaseScripts/{create_database_V0.0.27.sql => create_database_V0.0.28.sql} (96%) create mode 100644 setup/databaseScripts/update_database_V0.0.28.sql diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index 825125a..9603c47 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -106,6 +106,8 @@ class GlmDataAccounts extends GlmDataAbstract } + $billingFieldsRequired = $this->config['settings']['billing_fields_required']; + /* * Table Name */ @@ -150,6 +152,34 @@ class GlmDataAccounts extends GlmDataAbstract 'required' => true, ), + // Account Number + 'account_number' => array( + 'field' => 'account_number', + 'type' => 'text', + 'use' => 'a', + 'required' => false, + ), + + // Invoice Delivery Methods + 'email_invoice' => array( + 'field' => 'email_invoice', + 'type' => 'checkbox', + 'use' => 'a', + ), + 'usmail_invoice' => array( + 'field' => 'usmail_invoice', + 'type' => 'checkbox', + 'use' => 'a', + ), + + 'fax_invoice' => array( + 'field' => 'fax_invoice', + 'type' => 'checkbox', + 'use' => 'a', + ), + + + 'invoice_type' => array( 'field' => 'invoice_type', 'type' => 'integer', @@ -163,7 +193,7 @@ class GlmDataAccounts extends GlmDataAbstract 'type' => 'date', 'use' => 'a', 'default' => '', - 'required' => true, + 'required' => false, ), // Renewal Date @@ -188,7 +218,7 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'email', 'type' => 'text', 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing Company @@ -212,7 +242,7 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'billing_fname', 'type' => 'text', 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing Last Name @@ -220,7 +250,7 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'billing_lname', 'type' => 'text', 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing Address 1 @@ -228,7 +258,7 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'billing_addr1', 'type' => 'text', 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing Address 2 @@ -244,7 +274,7 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'billing_city', 'type' => 'text', 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing State @@ -254,7 +284,7 @@ class GlmDataAccounts extends GlmDataAbstract 'list' => $this->config['states'], 'default' => $this->config['settings']['default_state'], 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing Zip @@ -262,7 +292,7 @@ class GlmDataAccounts extends GlmDataAbstract 'field' => 'billing_zip', 'type' => 'text', 'use' => 'a', - 'required' => true, + 'required' => $billingFieldsRequired, ), // Billing Phone diff --git a/classes/data/dataSettings.php b/classes/data/dataSettings.php index 3e6dd3c..024d052 100644 --- a/classes/data/dataSettings.php +++ b/classes/data/dataSettings.php @@ -258,6 +258,20 @@ class GlmDataBillingSettings extends GlmDataAbstract 'use' => 'a', ), + // Require Billing Fields + 'billing_fields_required' => array( + 'field' => 'billing_fields_required', + 'type' => 'checkbox', + 'use' => 'a', + ), + + // Enable Invoice Methods + 'invoice_methods_enabled' => array( + 'field' => 'invoice_methods_enabled', + 'type' => 'checkbox', + 'use' => 'a', + ), + ); } diff --git a/config/plugin.ini b/config/plugin.ini index 978db5e..ca91c40 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -150,4 +150,3 @@ submission_status_numb['ADMIN_HOLD'] = 70 submission_status_numb['FAILED'] = 80 submission_status_numb['CANCELED'] = 99 -; diff --git a/index.php b/index.php index 7d5a509..cf9bf47 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.16'); -define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.27'); +define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.28'); // 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/billing/invoices.php b/models/admin/billing/invoices.php index 5150865..f78f572 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -154,6 +154,12 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices } $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config ); $paymentTypes = $BillingSupport->getAllInvoiceTypes(); + + // Need to get the accounts + $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); + $accountList = $Accounts->getSimpleAccountList( '', '', true, 'id', 1, 20 ); + $accounts = $accountList['list']; + break; case 'add': diff --git a/models/admin/management/importAccounts.php b/models/admin/management/importAccounts.php index 56673ec..d260f02 100644 --- a/models/admin/management/importAccounts.php +++ b/models/admin/management/importAccounts.php @@ -142,7 +142,8 @@ $importResults .= 'Total Members: ' . $totalMembers . "
"; $sql = " SELECT M.member_id,M.billing_contact,M.account_number, - PT.name as payment_type,M.process_email as email, M.member_name + PT.name as payment_type,M.process_email as email, M.member_name, + MA.email_invoice, MA.usmail_invoice, MA.fax_invoice FROM members.member M LEFT OUTER JOIN members.member_account MA ON ( MA.member_id = M.member_id ) LEFT OUTER JOIN members.payment_types PT ON ( MA.payment_type = PT.id ) @@ -196,6 +197,9 @@ foreach ( $members as $member ) { 'email' => $member['email'], 'account_number' => $member['account_number'], 'renewal_date' => '2018-07-01', + 'email_invoice' => $member['email_invoice'], + 'usmail_invoice' => $member['usmail_invoice'], + 'fax_invoice' => $member['fax_invoice'], ); $accountDataFormat = array( '%d', // ref_dest @@ -204,6 +208,9 @@ foreach ( $members as $member ) { '%s', // email '%s', // account_number '%s', // renewal_date + '%d', // email_invoice + '%d', // usmail_invoice + '%d', // fax_invoice ); $importResults .= '
$accountData: ' . print_r( $accountData, true ) . '
'; diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index c205823..b87e6f7 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -577,6 +577,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $haveAccount = true; } + // echo '
$account: ' . print_r( $account, true ) . '
'; $view = 'editAccount'; break; diff --git a/setup/databaseScripts/create_database_V0.0.27.sql b/setup/databaseScripts/create_database_V0.0.28.sql similarity index 96% rename from setup/databaseScripts/create_database_V0.0.27.sql rename to setup/databaseScripts/create_database_V0.0.28.sql index b1f5522..b46f1af 100644 --- a/setup/databaseScripts/create_database_V0.0.27.sql +++ b/setup/databaseScripts/create_database_V0.0.28.sql @@ -28,7 +28,7 @@ CREATE TABLE {prefix}accounts ( billing_country TINYTEXT NULL, -- Billing Country billing_phone TINYTEXT NULL, -- Billing Phone billing_fax TINYTEXT NULL, -- Billing Fax - anniversary_date DATE NOT NULL, -- anniversary date - used for main invoice generation + anniversary_date DATE NULL, -- anniversary date renewal_date DATE NULL, -- renewal date of account payment_data TEXT NULL, -- stored payment data customer_profile_id TINYTEXT NULL, -- Customer Profile Id (Authorize.net) @@ -37,6 +37,9 @@ CREATE TABLE {prefix}accounts ( email TINYTEXT NULL, -- billing email boss BOOLEAN DEFAULT '0', -- Boss flag account_number TINYTEXT NULL, -- Account Number + email_invoice BOOLEAN DEFAULT '0', -- Invoice by email + usmail_invoice BOOLEAN DEFAULT '0', -- Invoice by US Mail + fax_invoice BOOLEAN DEFAULT '0', -- Invoice by Fax PRIMARY KEY (id), INDEX(ref_dest), INDEX(ref_name(20)), @@ -247,6 +250,8 @@ CREATE TABLE {prefix}settings ( member_types_enabled BOOLEAN DEFAULT '1', -- member types determine invoice types quickbooks_enabled BOOLEAN DEFAULT '0', -- QuickBooks enabled member_billing_enabled BOOLEAN DEFAULT '1', -- Member have access to billing info tab + billing_fields_required BOOLEAN DEFAULT '1', -- Require Billing Fields + invoice_methods_enabled BOOLEAN DEFAULT '1', -- Enable Uptra invoice methods PRIMARY KEY (id) ); @@ -294,7 +299,7 @@ INSERT INTO {prefix}management -- Employees table CREATE TABLE {prefix}employees ( id INT NOT NULL AUTO_INCREMENT, - account INT NOT NULL, -- Account Id + account 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 0ca4626..97ffdf1 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -41,5 +41,6 @@ $glmMembersBillingDbVersions = array( '0.0.25' => array('version' => '0.0.25', 'tables' => 15), '0.0.26' => array('version' => '0.0.26', 'tables' => 15), '0.0.27' => array('version' => '0.0.27', 'tables' => 15, 'date' => '11/19/2018'), + '0.0.28' => array('version' => '0.0.28', 'tables' => 15, 'date' => '11/27/2018'), ); diff --git a/setup/databaseScripts/update_database_V0.0.28.sql b/setup/databaseScripts/update_database_V0.0.28.sql new file mode 100644 index 0000000..8a8575a --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.28.sql @@ -0,0 +1,29 @@ +-- Gaslight Media Billing Database +-- File Created: 11/19/2018 +-- Database Version: 0.0.27 +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Unset not null on anniversary_date field in accounts table +ALTER TABLE {prefix}accounts MODIFY anniversary_date date NULL; + +---- + +ALTER TABLE {prefix}accounts ADD email_invoice BOOLEAN DEFAULT '0'; + +---- + +ALTER TABLE {prefix}accounts ADD usmail_invoice BOOLEAN DEFAULT '0'; + +---- + +ALTER TABLE {prefix}accounts ADD fax_invoice BOOLEAN DEFAULT '0'; + +---- + +ALTER TABLE {prefix}settings ADD billing_fields_required BOOLEAN DEFAULT '1'; + +---- + +ALTER TABLE {prefix}settings ADD invoice_methods_enabled BOOLEAN DEFAULT '1'; diff --git a/views/admin/billing/accounts.html b/views/admin/billing/accounts.html index 13442e3..f6619d3 100644 --- a/views/admin/billing/accounts.html +++ b/views/admin/billing/accounts.html @@ -21,7 +21,9 @@ ID Member Name - Boss/Employees + {if $settings.allow_employees} + Boss/Employees + {/if} Billing Email Anniversary Date Renewal Date @@ -33,13 +35,15 @@ {$t.id} {$t.ref_name} - {if $t.boss.value}Yes{/if} + {if $settings.allow_employees} + {if $t.boss.value}Yes{/if} + {/if} {$t.email} {$t.anniversary_date.date} {$t.renewal_date.date} - + | diff --git a/views/admin/billing/bulkAddInvoices.html b/views/admin/billing/bulkAddInvoices.html index 1e87a59..ba159b4 100644 --- a/views/admin/billing/bulkAddInvoices.html +++ b/views/admin/billing/bulkAddInvoices.html @@ -5,27 +5,37 @@

Bulk Create Invoices

{if $paymentTypes} - - + + + {/if} {if $counties} - + + + - {/if} +
+ + {foreach $accounts as $t} +
{$t.ref_name}
+ {/foreach} + +
+ {include file='admin/footer.html'} diff --git a/views/admin/billing/editAccount.html b/views/admin/billing/editAccount.html index a8a3032..4b106fb 100644 --- a/views/admin/billing/editAccount.html +++ b/views/admin/billing/editAccount.html @@ -41,6 +41,14 @@ +
+
Account Number
+
+ + {if $account.fieldFail.account_number}

{$account.fieldFail.account_number}

{/if}
+
+
+ {if !$lockedToMember} @@ -61,6 +69,19 @@ {/if} + {if !$settings.member_types_enabled} + +
+
Invoice Delivery Methods
+
+ + + +
+
+ + {/if} +
Anniversary Date
diff --git a/views/admin/settings/billing.html b/views/admin/settings/billing.html index d0deba1..f64d0f9 100644 --- a/views/admin/settings/billing.html +++ b/views/admin/settings/billing.html @@ -9,7 +9,7 @@ {if $settingsUpdated}

Settings Updated

{/if} {if $settingsUpdateError}Settings Update Error{/if} -

Billing Invoice Settings

+

Billing Settings

@@ -20,85 +20,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -210,6 +134,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- Allow Membership Choice When renewing - - -
- Allow Employees - - -
- Use member types in Invoice Types - - -
- Enable Quickbooks - - -
- Enable Members billing tab (for members) - - -
- Days Before Renewal Date
- to Allow Membership Renewal
- Must be a number -
- - {if $billingSettings.fieldFail.days_before_renewal}

{$billingSettings.fieldFail.days_before_renewal}

{/if}
-
- Days After Renewal Date
- Membership Expires
- Must be a number -
- - {if $billingSettings.fieldFail.days_after_expired}

{$billingSettings.fieldFail.days_after_expired}

{/if}
-
Invoice Settings
Billing Options
+ Allow Membership Choice When renewing + + +
+ Allow Employees + + +
+ Use member types in Invoice Types + + +
+ Enable Quickbooks + + +
+ Enable Members billing tab (for members) + + +
+ Require Billing Fields + + +
+ Enable Invoice Methods + + +
+ Days Before Renewal Date
+ to Allow Membership Renewal
+ Must be a number +
+ + {if $billingSettings.fieldFail.days_before_renewal}

{$billingSettings.fieldFail.days_before_renewal}

{/if}
+
+ Days After Renewal Date
+ Membership Expires
+ Must be a number +
+ + {if $billingSettings.fieldFail.days_after_expired}

{$billingSettings.fieldFail.days_after_expired}

{/if}
+
-- 2.17.1