From: Steve Sutton Date: Thu, 23 Feb 2017 22:00:46 +0000 (-0500) Subject: Add list/add/edit Account tab in Registrations X-Git-Tag: v1.0.0^2~497 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=ee15ef7ce2500a532e83d20f4fd5e092e4809204;p=WP-Plugins%2Fglm-member-db-registrations.git Add list/add/edit Account tab in Registrations Adding the list page to list out accounts. Working on the edit page to add or edit Accounts. --- diff --git a/models/admin/registrations/accounts.php b/models/admin/registrations/accounts.php new file mode 100644 index 0000000..c294731 --- /dev/null +++ b/models/admin/registrations/accounts.php @@ -0,0 +1,183 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Registrations data abstract + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataAccount.php'; + +class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Registrations Event ID + * + * @var $eventID + * @access public + */ + public $accountID = false; + + /** + * 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 the REgistrations data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ + parent::__construct(false, false, true); + + } + + public function modelAction($actionData = false) + { + $option = 'list'; + $numbAccounts = 0; + $hasAccounts = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $fromDate = false; + $toDate = false; + $filterArchived = false; + $filterPending = false; + $accounts = false; + $view = 'account.html'; + $account = false; + $haveAccount = false; + + // Get any provided option + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + // Get account ID if supplied + if (isset($_REQUEST['account'])) { + + // Make sure it's numeric + $this->accountID = ($_REQUEST['account'] - 0); + + if ($this->accountID <= 0) { + $this->accountID = false; + } + + } + + switch ( $option ) { + case 'add': + $view = 'edit.html'; + $account = $this->newEntry(); + break; + + case 'insert': + break; + + case 'edit': + $view = 'edit.html'; + $account = $this->editEntry( $this->accountID ); + if ( $account['status'] ) { + $haveAccount = true; + } + //echo '
$account: ' . print_r( $account, true ) . '
'; + break; + + case 'update': + break; + + case 'delete': + break; + + default: + $accounts = $this->getList(); + $hasAccounts = ( $accounts !== false && count( $accounts > 0 ) ) ? true: false; + $view = 'account.html'; + break; + } + + // Compile template data + $templateData = array( + 'hasAccounts' => $hasAccounts, + 'numAccounts' => count($accounts), + 'accounts' => $accounts, + 'account' => $account, + 'limit' => $limit, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'paging' => $paging, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + 'filterArchived' => $filterArchived, + 'filterPending' => $filterPending, + 'accountID' => $this->accountID, + 'haveAccount' => $haveAccount, + ); + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/registrations/' . $view, + 'data' => $templateData + ); + + } + + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 7345dc0..e7fd00a 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -67,4 +67,11 @@ add_submenu_page( 'glm-members-admin-menu-registrations-list', function() {$this->controller('registrations', 'list');} ); - +add_submenu_page( + 'glm-members-admin-menu-members', + 'Registration Events', + '    Accounts', + 'glm_members_members', + 'glm-members-admin-menu-registrations-accounts', + function() {$this->controller('registrations', 'accounts');} +); diff --git a/setup/adminTabs.php b/setup/adminTabs.php index cbcaf61..2533501 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -18,8 +18,8 @@ if (current_user_can('glm_members_members')) { function($addOnTabs) { $newTabs = array( array( - 'text' => 'Registrations', - 'menu' => 'management', + 'text' => 'Registrations', + 'menu' => 'management', 'action' => 'registrations' ) ); @@ -27,15 +27,15 @@ if (current_user_can('glm_members_members')) { return $addOnTabs; } ); - + } add_filter('glm-member-db-add-tab-for-settings', function($addOnTabs) { $newTabs = array( array( - 'text' => 'Registrations', - 'menu' => 'settings', + 'text' => 'Registrations', + 'menu' => 'settings', 'action' => 'registrationsPaymentCode' ), @@ -44,5 +44,5 @@ if (current_user_can('glm_members_members')) { return $addOnTabs; } ); - -} \ No newline at end of file + +} diff --git a/setup/validActions.php b/setup/validActions.php index 595b810..5a3eaec 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -60,20 +60,21 @@ $glmMembersRegistrationsAddOnValidActions = array( 'adminActions' => array( 'registrations' => array( - 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'list' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG + 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'list' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'accounts' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, ), 'management' => array( 'registrations' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'regterms' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG + 'regterms' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, ), 'settings' => array( 'registrationsPaymentCode' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'registrationsMisc' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG + 'registrationsMisc' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, ), ), 'frontActions' => array( ) ); -?> \ No newline at end of file +?> diff --git a/views/admin/registrations/account.html b/views/admin/registrations/account.html new file mode 100644 index 0000000..e1d0f51 --- /dev/null +++ b/views/admin/registrations/account.html @@ -0,0 +1,64 @@ +{include file='admin/registrations/header.html'} + +

Account List Page

+ +
+ + + + +
+

+ + Text Search: + + +

+

+ +
+

Total found: {$numAccounts}  

+ + {if $paging} + + + {/if} + +{if $hasAccounts} + {assign var="i" value="0"} + + + + + + + + + + + {foreach $accounts as $account} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + + + {/foreach} +
IDActiveNameCreated
{$account.id}{$account.active.name} + {$account.fname} {$account.lname} + {$account.date_created.timestamp|date_format:"%D"}
+{/if} + + {if $paging} + + + {/if} + +
+ +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/edit.html b/views/admin/registrations/edit.html new file mode 100644 index 0000000..3708596 --- /dev/null +++ b/views/admin/registrations/edit.html @@ -0,0 +1,421 @@ +{include file='admin/registrations/header.html'} + +

Account Edit Page

+ +
+ + {if $haveAccount} {/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/header.html b/views/admin/registrations/header.html index f5dfdbe..1966b1a 100644 --- a/views/admin/registrations/header.html +++ b/views/admin/registrations/header.html @@ -3,7 +3,8 @@
- - \ No newline at end of file + +