From: Laury GvR Date: Thu, 9 Feb 2017 17:15:25 +0000 (-0500) Subject: Adding payment codes settings page. X-Git-Tag: v1.0.0^2~506 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=ffa15c15db0fe2aeea2da3b66bd78fb364851256;p=WP-Plugins%2Fglm-member-db-registrations.git Adding payment codes settings page. Using basic event Amenities template for payment code settings page. Note: the payment_ref_type is not recognised as the page will warn. Also not sure yet what to use instead of 'name'. Data Abstract has a comment of "Name of field" by field 'Amount'? --- diff --git a/classes/data/dataPaymentCode.php b/classes/data/dataPaymentCode.php index 219c2b3..c706aa2 100644 --- a/classes/data/dataPaymentCode.php +++ b/classes/data/dataPaymentCode.php @@ -142,7 +142,7 @@ class GlmDataRegistrationsPaymentCode extends GlmDataAbstract 'use' => 'a' ), - // Field description / explantion + // Field description / explanation 'descr' => array ( 'field' => 'descr', 'type' => 'text', diff --git a/models/admin/settings/registrationsPaymentCode.php b/models/admin/settings/registrationsPaymentCode.php new file mode 100644 index 0000000..c844a37 --- /dev/null +++ b/models/admin/settings/registrationsPaymentCode.php @@ -0,0 +1,197 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Amenities data abstract +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataPaymentCode.php'; + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrationsPaymentCode +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Settings Data + * + * @var $config + * @access public + */ + public $config; + + /* + * Constructor + * + * This contructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + 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 ); + + } + + /* + * Perform Model Action + * + * This method does the work for this model and returns any resulting data + * + * @return array Status and data array + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'menuItemRedirect' + * + * If not false, provides a menu item the controller should + * execute after this one. Normally if this is used, there would also be a + * modelRedirect value supplied as well. + * + * 'modelRedirect' + * + * If not false, provides an action the controller should execute after + * this one. + * + * '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. + * + */ + public function modelAction ( $actionData = false ) + { + $success = true; + $havePaymentCode = false; + $payment_codes = false; + $error = false; + $option2 = ''; + $newPaymentCode = $this->newEntry(); + $enable_members = $this->config['settings']['enable_members']; + + // Check if a category ID is supplied + $id = 0; + if ( isset( $_REQUEST['id'] ) ) { + $id = $_REQUEST['id'] - 0; + } + // If there's an action option + if ( isset( $_REQUEST['option'] ) ) { + switch( $_REQUEST['option'] ) { + case 'addNew': + $return = $this->insertEntry(); + $id = $return['fieldData']['id']; + break; + + case 'update': + if ( $id > 0 ) { + $this->updateEntry( $id ); + } + break; + + case 'delete': + if ( $id > 0 ) { + $this->deleteEntry( $id, true ); + } + break; + + default: + $option2 = false; + break; + + } + } + if ( isset( $_REQUEST['option2'] ) ) { + $option2 = $_REQUEST['option2']; + } + // Get a current list of payment_codes + $payment_codes = $this->getList(); + + if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) { + glmMembersAdmin::addNotice( $payment_codes, 'DataBlock', 'Payment Code Data' ); + } + // If we have list entries - even if it's an empty list + $success = true; + $havePaymentCode = false; + if ( $payment_codes !== false ) { + + $success = true; + + // If we have any entries + if ( count( $payment_codes ) > 0 ) { + $havePaymentCode = true; + } + } + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false, + ); + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice( $payment_codes, 'DataBlock', 'Payment Code Data' ); + } + // Compile template data + $templateData = array( + 'enable_members' => $enable_members, + 'havePaymentCode' => $havePaymentCode, + 'payment_codes' => $payment_codes, + 'groups' => null, + 'option2' => $option2, + 'newPaymentCode' => $newPaymentCode, + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/registrationsPaymentCode.html', + 'data' => $templateData, + ); + + } + + +} diff --git a/setup/adminTabs.php b/setup/adminTabs.php index dd5ba74..cbcaf61 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -29,5 +29,20 @@ if (current_user_can('glm_members_members')) { ); } + + add_filter('glm-member-db-add-tab-for-settings', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Registrations', + 'menu' => 'settings', + 'action' => 'registrationsPaymentCode' + ), + + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } + ); } \ No newline at end of file diff --git a/setup/validActions.php b/setup/validActions.php index 9482fc0..33113c9 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -67,6 +67,9 @@ $glmMembersRegistrationsAddOnValidActions = array( 'registrations' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'regterms' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, ), + 'settings' => array( + 'registrationsPaymentCode' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + ), ), 'frontActions' => array( ) diff --git a/views/admin/management/regpaymentcodes.html b/views/admin/management/regpaymentcodes.html deleted file mode 100644 index 05a5bfe..0000000 --- a/views/admin/management/regpaymentcodes.html +++ /dev/null @@ -1,89 +0,0 @@ - -

Registrations Payment Codes

- -
- - - - - - - - - - - -

Admin Menu and Tab Names

Registration: - - - - - - - - - - - - - - - - - - - - - - -
Code Type: - -
Ref Type: - -
Payment Code: - - {if $paymentCodeSettings.fieldFail.code}

{$paymentCodeSettings.fieldFail.code}

{/if} -
Name of Field / Prompt: - - {if $paymentCodeSettings.fieldFail.amount}

{$paymentCodeSettings.fieldFail.amount}

{/if} -
Field Description / Explanation: - - {if $paymentCodeSettings.fieldFail.descr}

{$paymentCodeSettings.fieldFail.descr}

{/if} -
- - -{include file='admin/footer.html'} diff --git a/views/admin/settings/registrationsPaymentCode.html b/views/admin/settings/registrationsPaymentCode.html new file mode 100644 index 0000000..4edd412 --- /dev/null +++ b/views/admin/settings/registrationsPaymentCode.html @@ -0,0 +1,179 @@ +{include file='admin/settings/header.html'} + + + + + +
+ +
Add Payment Code
+
+
+ + + + + + + + + +
Payment Code Name: + +
+

* Required

+ Cancel + + +
+
+ + +
+
+

Are you sure you want to delete this Payment Code?

+

Yes, delete this Payment Code

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + +
Payment Code Name: + +
+

* Required

+ Cancel + + +
+
+ + +

Registration Payment Codes

+ + + + + + + + + + {if $havePaymentCode} + {assign var="i" value="0"} + {foreach $payment_codes as $p} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + {/foreach} + {else} + + {/if} + +
Payment Code 
+ {$p.name} + +
Delete
+
(no payment codes listed)
+
+ + + +{include file='admin/footer.html'} \ No newline at end of file