From b4b174a799b6ff928dbe6adbb47d7435401d2070 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 12 Dec 2017 15:33:28 -0500 Subject: [PATCH] Save management settings. Payment Gateway settings. Saving the gateway and payment options for billing into the management db table. --- classes/data/dataManagement.php | 227 ++++++++++++++++++ models/admin/management/billing.php | 206 ++++++++++++++++ setup/adminTabs.php | 15 ++ .../create_database_V0.0.3.sql | 26 +- .../update_database_V0.0.3.sql | 26 +- views/admin/management/billing.html | 191 +++++++++++++++ views/admin/management/footer.html | 17 ++ 7 files changed, 682 insertions(+), 26 deletions(-) create mode 100644 classes/data/dataManagement.php create mode 100644 models/admin/management/billing.php create mode 100644 views/admin/management/billing.html create mode 100644 views/admin/management/footer.html diff --git a/classes/data/dataManagement.php b/classes/data/dataManagement.php new file mode 100644 index 0000000..d930f0a --- /dev/null +++ b/classes/data/dataManagement.php @@ -0,0 +1,227 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataManagement.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: dataManagement.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataBillingManagement 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_BILLING_PLUGIN_DB_PREFIX . 'management'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Payment Methods Selected - Bitmap + 'payment_methods' => array ( + 'field' => 'payment_methods', + 'type' => 'bitmap', + 'bitmap' => $this->config['payment_method'], + 'default' => 0, // none selected + 'use' => 'a' + ), + + // Processing Methods Selected - Bitmap + 'proc_methods' => array ( + 'field' => 'proc_methods', + 'type' => 'list', + 'list' => $this->config['proc_method'], + 'default' => $this->config['proc_method_numb']['Merchant'], + 'use' => 'a' + ), + + // Credit Cards Accepted Selected - Bitmap + 'cc_accepts' => array ( + 'field' => 'cc_accepts', + 'type' => 'bitmap', + 'bitmap' => $this->config['credit_card'], + 'default' => 0, // none selected + 'use' => 'a' + ), + + // Authorize.net Login + 'authorize_net_login' => array ( + 'field' => 'authorize_net_login', + 'type' => 'text', + 'use' => 'a' + ), + + // Authorize.net Key + 'authorize_net_key' => array ( + 'field' => 'authorize_net_key', + 'type' => 'text', + 'use' => 'a' + ), + + // Authorize.net Test Mode + 'authorize_net_test' => array ( + 'field' => 'authorize_net_test', + 'type' => 'list', + 'list' => $this->config['proc_test_mode'], + 'default' => $this->config['proc_test_mode_numb']['Local Approval Test'], + 'use' => 'a' + ), + + // Always Use Full Billing Info + 'authorize_net_conf' => array ( + 'field' => 'authorize_net_conf', + 'type' => 'checkbox', + 'use' => 'a', + 'default' => 0, + ), + + // Authorize.net Merchant Email + 'authorize_net_merchant_email' => array ( + 'field' => 'authorize_net_merchant_email', + 'type' => 'text', + 'use' => 'a' + ), + + // Merchant Solutions Account ID + 'merchant_solutions_acctid' => array ( + 'field' => 'merchant_solutions_acctid', + 'type' => 'text', + 'use' => 'a' + ), + + // Merchant Solutions Merchant PIN + 'merchant_solutions_merchantpin' => array ( + 'field' => 'merchant_solutions_merchantpin', + 'type' => 'text', + 'use' => 'a' + ), + + // Merchant Solutions Test Mode + 'merchant_solutions_test' => array ( + 'field' => 'merchant_solutions_test', + 'type' => 'list', + 'list' => $this->config['proc_test_mode'], + 'default' => $this->config['proc_test_mode_numb']['Local Approval Test'], + 'use' => 'a' + ), + + // Always Use Full Billing Info + 'merchant_solutions_conf' => array ( + 'field' => 'merchant_solutions_conf', + 'type' => 'checkbox', + 'use' => 'a', + 'default' => 0, + ), + + // Merchant Email + 'merchant_solutions_merchant_email' => array ( + 'field' => 'merchant_solutions_merchant_email', + 'type' => 'text', + 'use' => 'a' + ), + + ); + + } + +} + +?> diff --git a/models/admin/management/billing.php b/models/admin/management/billing.php new file mode 100644 index 0000000..9456246 --- /dev/null +++ b/models/admin/management/billing.php @@ -0,0 +1,206 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release billing.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Management Billing data abstract +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataManagement.php'; + +/** + * GlmMembersAdmin_management_billing + * + * PHP version 5 + * + * @category Model + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: packaging.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmMembersAdmin_management_billing extends GlmDataBillingManagement +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * dbh Postgres database connection + * + * @var mixed + * @access public + */ + public $config; + /** + * settings used for the schema and tablenames + * + * @var mixed + * @access public + */ +// public $settings = array(); +// /** +// * billing +// * +// * @var bool +// * @access public +// */ +// public $billing = array(); + + /** + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'view' + * + * A suggested view name that the contoller 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. + * + * @wpdb object WordPress database object + * + * @return array Array containing status, suggested view, and any data + */ + 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); + + } + + /** + * modelAction + * + * @param bool $actionData + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + + $option = false; + $settingsUpdated = false; + $settingsUpdateError = false; + $regSettings = false; + + // General settings are always stored in a record with ID=1. + $id = 1; + + // Determine if current user can edit configurations + if (!current_user_can('glm_members_management')) { + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => 'User does not have rights to make configuration changes.' + ) + ); + } + + // Check for submission option + $option = ''; + if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') { + $option = $_REQUEST['option']; + } + + switch( $option ) { + + // Update the settings and redisplay the form + case 'submit': + + // Update the general settings + $regSettings = $this->updateEntry( $id ); + + // Check if we were successful + if ($regSettings['status']) { + + $settingsUpdated = true; + $regSettings = $this->editEntry( $id ); + + } else { + $settingsUpdateError = true; + } + + break; + + // Default is to get the current settings and display the form + default: + + // Try to get the first (should be only) entry for general settings. + $regSettings = $this->editEntry( $id ); + + // Check if we didn't get the settings + if ($regSettings === false) { + + $errorMsg = "Unable to load the Billing management settings"; + + trigger_error($errorMsg, E_USER_NOTICE); + + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => $errorMsg + ) + ); + } + + break; + + } + + // Compile template data + $template_data = array( + 'regSettings' => $regSettings, + 'settingsUpdated' => $settingsUpdated, + 'settingsUpdateError' => $settingsUpdateError + ); + + // echo "
" . print_r($regSettings, true) . "
"; + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/management/billing.html', + 'data' => $template_data + ); + } +} +?> diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 261a5cc..a90ccdb 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -33,6 +33,21 @@ * */ if ( current_user_can( 'glm_members_members' ) ) { + + add_filter('glm-member-db-add-tab-for-management', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Billing', + 'menu' => 'management', + 'action' => 'billing' + ) + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } + ); + add_filter( 'glm-member-db-add-tab-for-settings', function( $addOnTabs ) { $newTabs = array( diff --git a/setup/databaseScripts/create_database_V0.0.3.sql b/setup/databaseScripts/create_database_V0.0.3.sql index 914094e..95dc181 100644 --- a/setup/databaseScripts/create_database_V0.0.3.sql +++ b/setup/databaseScripts/create_database_V0.0.3.sql @@ -181,21 +181,21 @@ INSERT INTO {prefix}settings -- Management CREATE TABLE {prefix}management ( id INT NOT NULL AUTO_INCREMENT, - reg_payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini - reg_proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini - reg_cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini + payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini + proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini + cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini -- Authorize.net Credentials - reg_authorize_net_login TINYTEXT NULL, - reg_authorize_net_key TINYTEXT NULL, - reg_authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini - reg_authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net - reg_authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail + authorize_net_login TINYTEXT NULL, + authorize_net_key TINYTEXT NULL, + authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini + authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net + authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail -- Merchant Solutions Credentials - reg_merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials - reg_merchant_solutions_merchantpin TINYTEXT NULL, - reg_merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini - reg_merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email - reg_merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail + merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials + merchant_solutions_merchantpin TINYTEXT NULL, + merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini + merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email + merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail PRIMARY KEY (id) ); diff --git a/setup/databaseScripts/update_database_V0.0.3.sql b/setup/databaseScripts/update_database_V0.0.3.sql index afc68e9..98f6dc9 100644 --- a/setup/databaseScripts/update_database_V0.0.3.sql +++ b/setup/databaseScripts/update_database_V0.0.3.sql @@ -8,21 +8,21 @@ -- Management CREATE TABLE {prefix}management ( id INT NOT NULL AUTO_INCREMENT, - reg_payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini - reg_proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini - reg_cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini + payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini + proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini + cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini -- Authorize.net Credentials - reg_authorize_net_login TINYTEXT NULL, - reg_authorize_net_key TINYTEXT NULL, - reg_authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini - reg_authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net - reg_authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail + authorize_net_login TINYTEXT NULL, + authorize_net_key TINYTEXT NULL, + authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini + authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net + authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail -- Merchant Solutions Credentials - reg_merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials - reg_merchant_solutions_merchantpin TINYTEXT NULL, - reg_merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini - reg_merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email - reg_merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail + merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials + merchant_solutions_merchantpin TINYTEXT NULL, + merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini + merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email + merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail PRIMARY KEY (id) ); diff --git a/views/admin/management/billing.html b/views/admin/management/billing.html new file mode 100644 index 0000000..aaf240b --- /dev/null +++ b/views/admin/management/billing.html @@ -0,0 +1,191 @@ +{include file='admin/management/header.html'} + + + + + + + + + + +
+ {if $settingsUpdated}

Settings Updated

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

Management Settings

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Payment

Payment Methods: + {foreach from=$regSettings.fieldData.payment_methods.bitmap item=v} + {$v.name}
+ {/foreach} + {if $regSettings.fieldFail.payment_methods}

{$regSettings.fieldFail.payment_methods}

{/if} +
Credit Card Accepted: + {foreach from=$regSettings.fieldData.cc_accepts.bitmap item=v} + {$v.name}
+ {/foreach} + {if $regSettings.fieldFail.cc_accepts}

{$regSettings.fieldFail.cc_accepts}

{/if} +
Credit Card Processor: + +

Authorize.net

Login: + + {if $regSettings.fieldFail.authorize_net_login}

{$regSettings.fieldFail.authorize_net_login}

{/if} +
Key: + + {if $regSettings.fieldFail.authorize_net_key}

{$regSettings.fieldFail.authorize_net_key}

{/if} +
Test Mode: + +
Send Confirmation E-Mail + +
Merchant Email: + + {if $regSettings.fieldFail.authorize_net_merchant_email}

{$regSettings.fieldFail.authorize_net_merchant_email}

{/if} +

Merchant Solutions

Account ID: + + {if $regSettings.fieldFail.merchant_solutions_acctid}

{$regSettings.fieldFail.merchant_solutions_acctid}

{/if} +
Merchant PIN: + + {if $regSettings.fieldFail.merchant_solutions_merchantpin}

{$regSettings.fieldFail.merchant_solutions_merchantpin}

{/if} +
Test Mode: + +
Send Confirmation E-Mail + +
Merchant Email: + + {if $regSettings.fieldFail.merchant_solutions_merchant_email}

{$regSettings.fieldFail.merchant_solutions_merchant_email}

{/if} +
+ + +
+ +
+ + + +{include file='admin/management/footer.html'} diff --git a/views/admin/management/footer.html b/views/admin/management/footer.html new file mode 100644 index 0000000..f491223 --- /dev/null +++ b/views/admin/management/footer.html @@ -0,0 +1,17 @@ + -- 2.17.1