From: Steve Sutton Date: Tue, 21 Nov 2017 21:34:55 +0000 (-0500) Subject: Payment Types now added to settings page. X-Git-Tag: v1.0.0^2~224 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=87fca59439ab939d5507fecbf0b5ffcf80badd44;p=WP-Plugins%2Fglm-member-db-billing.git Payment Types now added to settings page. Can now List, Add, Edit, Delete payment types. --- diff --git a/classes/data/dataPaymentTypes.php b/classes/data/dataPaymentTypes.php new file mode 100644 index 0000000..0b7a7d6 --- /dev/null +++ b/classes/data/dataPaymentTypes.php @@ -0,0 +1,192 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.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: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataPaymentTypes 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; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * 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 . 'payment_types'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a', + ), + + // Default Billing Period + 'name' => array( + 'field' => 'name', + 'type' => 'text', + 'use' => 'a', + ), + + // Default Invoice Date + 'qcode' => array( + 'field' => 'qcode', + 'type' => 'text', + 'use' => 'a', + ), + + // Notification From Email + 'category' => array( + 'field' => 'category', + 'type' => 'text', + 'use' => 'a', + ), + + // Notification Message + 'amount' => array( + 'field' => 'amount', + 'type' => 'text', + 'use' => 'a', + ), + + // Logo for Invioce PDF + 'notes' => array( + 'field' => 'notes', + 'type' => 'text', + 'use' => 'a', + ), + + // Name + 'dynamic_amount' => array( + 'field' => 'dynamic_amount', + 'type' => 'text', + 'use' => 'a', + ), + + ); + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } + +} + +?> diff --git a/models/admin/readme.txt b/models/admin/readme.txt deleted file mode 100644 index e9a199d..0000000 --- a/models/admin/readme.txt +++ /dev/null @@ -1,5 +0,0 @@ -The admin controller executes models under this directory. - -Typically you should add a directory here that matches the page where the action should take place. - -Under that directory place the model for the various actions. \ No newline at end of file diff --git a/models/admin/settings/paymentTypes.php b/models/admin/settings/paymentTypes.php new file mode 100644 index 0000000..1eec3ea --- /dev/null +++ b/models/admin/settings/paymentTypes.php @@ -0,0 +1,189 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Member Types data abstract +require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH.'/data/dataPaymentTypes.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_paymentTypes extends GlmDataPaymentTypes +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration 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; + $havePaymentTypes = false; + $paymentTypes = false; + $error = false; + $enable_members = $this->config['settings']['enable_members']; + + // Check for region id + $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': + $this->insertEntry(); + break; + + case 'update': + if ($id > 0) { + $this->updateEntry($id); + } + break; + + case 'delete': + if ($id > 0) { + $this->deleteEntry($id, true); + } + break; + + } + + } + + // Get a current list of members + $paymentTypes = $this->getList('', 'name'); + + // echo '
$paymentTypes: ' . print_r( $paymentTypes, true ) . '
'; + + // If we have list entries - even if it's an empty list + $success = true; + $havePaymentTypes = false; + if ($paymentTypes !== false) { + + $success = true; + + // If we have any entries + if (count($paymentTypes) > 0) { + $havePaymentTypes = 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 + ); + } + + // Compile template data + $templateData = array( + 'enable_members' => $enable_members, + 'havePaymentTypes' => $havePaymentTypes, + 'paymentTypes' => $paymentTypes + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/paymentTypes.html', + 'data' => $templateData + ); + + } + + +} + +?> diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 220d203..9261ce4 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -46,4 +46,17 @@ if ( current_user_can( 'glm_members_members' ) ) { return $addOnTabs; } ); + add_filter( 'glm-member-db-add-tab-for-settings', + function( $addOnTabs ) { + $newTabs = array( + array( + 'text' => 'Payment Types', + 'menu' => 'settings', + 'action' => 'paymentTypes', + ) + ); + $addOnTabs = array_merge( $addOnTabs, $newTabs ); + return $addOnTabs; + } + ); } diff --git a/setup/validActions.php b/setup/validActions.php index a207c60..ada37b9 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -60,7 +60,8 @@ $glmMembersBillingAddOnValidActions = array( 'adminActions' => array( 'settings' => array( - 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + 'paymentTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), ), 'frontActions' => array( diff --git a/views/admin/readme.txt b/views/admin/readme.txt deleted file mode 100644 index 5a9d7ea..0000000 --- a/views/admin/readme.txt +++ /dev/null @@ -1,5 +0,0 @@ -The admin controller uses views (templates) under this directory to generate final output. - -Typically you should add a directory here that matches the page where the view is used. - -Under that directory place the view (template) for the various actions. \ No newline at end of file diff --git a/views/admin/settings/paymentTypes.html b/views/admin/settings/paymentTypes.html new file mode 100644 index 0000000..79c3ec5 --- /dev/null +++ b/views/admin/settings/paymentTypes.html @@ -0,0 +1,223 @@ +{include file='admin/settings/header.html'} + + +
Add a PaymentType
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
PaymentType Name: + +
Code: + +
Category: + +
Amount: + +
Dynamic Amount: + +
Notes: + +
+

* Required

+ Cancel + +
+
+ + +
+
+

Are you sure you want to delete this paymentType?

+

Yes, delete this paymentType

+

Cancel

+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
PaymentType Name: + +
Code: + +
Category: + +
Amount: + +
Dynamic Amount: + +
Notes: + +
+

* Required

+ Cancel + +
+
+ +

PaymentTypes

+ + + + + + + + + + + + {if $havePaymentTypes} + {assign var="i" value="0"} + {foreach $paymentTypes as $t} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + {/foreach} + {else} + + {/if} + +
IDPaymentTypeAmount 
{$t.id} + {$t.name} + + {$t.amount} + +
Delete
+
(no paymentTypes listed)
+ + + +{include file='admin/footer.html'}