From 88c0037d26cbee67d59e0df40fb51f3ff97907c4 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 17 Aug 2017 10:29:26 -0400 Subject: [PATCH] More backend functionality working now. Have reg_event records being populated and can edit. --- classes/data/dataRegEvent.php | 111 ++++- models/admin/registrations/dashboard.php | 280 +++++++++++++ models/admin/registrations/event.php | 285 +++++++++++++ models/admin/registrations/events.php | 93 +++-- models/admin/registrations/index.php | 1 - models/admin/registrations/list.php | 380 ++++++++++++++++++ setup/adminMenus.php | 17 +- .../create_database_V0.0.8.sql | 7 +- setup/validActions.php | 3 +- views/admin/registrations/event.html | 56 +++ views/admin/registrations/eventDashboard.html | 6 - views/admin/registrations/eventEdit.html | 105 +++-- views/admin/registrations/header.html | 7 +- views/admin/registrations/index.html | 2 + .../{eventList.html => list-save.html} | 2 + views/admin/registrations/list.html | 267 ++++++++++++ views/admin/registrations/text_input.html | 8 - 17 files changed, 1505 insertions(+), 125 deletions(-) create mode 100644 models/admin/registrations/dashboard.php create mode 100644 models/admin/registrations/event.php create mode 100644 models/admin/registrations/list.php create mode 100644 views/admin/registrations/event.html delete mode 100644 views/admin/registrations/eventDashboard.html rename views/admin/registrations/{eventList.html => list-save.html} (84%) create mode 100644 views/admin/registrations/list.html delete mode 100644 views/admin/registrations/text_input.html diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index 03f05b6..255ca1b 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -121,7 +121,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract 'field' => 'event', 'type' => 'integer', 'required' => true, - 'use' => 'lgneud' + 'use' => 'lgned' ), // Event Name @@ -129,7 +129,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract 'field' => 'event_name', 'type' => 'text', 'required' => true, - 'use' => 'lgneud' + 'use' => 'lgned' ), // A short code used to reference this event @@ -208,29 +208,29 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract // Bitmap of how user accounts may be used for this event - See registration_account_option in plugin.ini 'registration_account_options' => array ( - 'field' => 'registration_account_options', - 'type' => 'bitmap', + 'field' => 'registration_account_options', + 'type' => 'bitmap', 'bitmap' => $this->config['registration_account_option'], - 'default' => 0, // none selected - 'use' => 'a' + 'default' => 0, // none selected + 'use' => 'a' ), // Bitmap of payment methods available to users for this event - See payment_method in plugin.ini 'payment_methods' => array ( - 'field' => 'payment_methods', - 'type' => 'bitmap', + 'field' => 'payment_methods', + 'type' => 'bitmap', 'bitmap' => $this->config['payment_method'], - 'default' => 0, // none selected - 'use' => 'a' + 'default' => 0, // none selected + 'use' => 'a' ), // Bitmap of restricted (admin use only) payment methods for this event - see payment_method 'restricted_payment_methods' => array ( - 'field' => 'restricted_payment_methods', - 'type' => 'bitmap', + 'field' => 'restricted_payment_methods', + 'type' => 'bitmap', 'bitmap' => $this->config['payment_method'], - 'default' => 0, // none selected - 'use' => 'a' + 'default' => 0, // none selected + 'use' => 'a' ), // Terms and Conditions for registration @@ -274,9 +274,90 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract ), ); - + } + /* + * Get Alpha list of first characters in event name + * + * @param string $where Where clause + * @param string $selected Optional selected alpha character + * + * @return object Class object + * + */ + public function getAlphaList($where = '', $selected = '') + { + + $sql = " + SELECT DISTINCT LEFT(T.event_name, 1) AS alpha + FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX. "reg_event T + WHERE true + $where + ORDER BY alpha + ;"; + $alphaData = $this->wpdb->get_results($sql, ARRAY_A); + + // Set selected + foreach ($alphaData as $k=>$v) { + $alphaData[$k]['default'] = ($v['alpha'] == $selected); + } + + return $alphaData; + + } + + /* + * Get a simple reg event list - Event Name and ID only + * + * @return array Array of Name and ID for all reg events + * @access public + */ + public function getSimpleRegEventsList($where = '', $order = '', $fieldVals = true, $idField = 'id', $start = false, $limit = false) + { + + // Save the current fields array and make a copy + $fSave = $this->fields; + + // Remove what we don't want from the copy and get the list + $this->fields = array( + 'id' => $fSave['id'], + 'event_name' => $fSave['event_name'] + ); + + $regEventsList = $this->getList($where, $order, $fieldVals, $idField, $start, $limit); + + // Restore the fields list + $this->fields = $fSave; + + return $regEventsList; + } + + /** + * Get ID/Event Name list + * + * @param string $where + * + * @return array ID/Name pairs + */ + public function getIdRegEvent($where = 'true') + { + $savedFields = $this->fields; + + $this->fields = array( + 'id' => $savedFields['id'], + 'event_name' => $savedFields['event_name'] + ); + + $r = $this->getList($where); + + $this->fields = $savedFields; + + return $r; + + } + + } ?> \ No newline at end of file diff --git a/models/admin/registrations/dashboard.php b/models/admin/registrations/dashboard.php new file mode 100644 index 0000000..ec4ce61 --- /dev/null +++ b/models/admin/registrations/dashboard.php @@ -0,0 +1,280 @@ + + * @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/ + */ +echo "NOT UPDATED";exit; +// Load Registrations data abstract +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php'; + +class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent +{ + + /** + * 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 $regEventID = 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'; + $template = 'list.html'; + $haveEvent = false; + $eventID = false; + $haveRegEvent = false; + $regEventID = false; + $regEventUpdated = false; + $regEventUpdateError = false; + $regEventAdded = false; + $reason = false; + + // Get any provided option + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + // Check for a supplied regEvent record ID + if (isset($_REQUEST['regEventID']) && $_REQUEST['regEventID'] != '') { + $regEventID = ($_REQUEST['regEventID'] - 0); + if ($regEventID > 0) { + $regEvent = $this->getEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + } + + // If we don't have a reg event ID, then check for an event ID and make sure it's a positive integer + if (!$haveRegEvent && isset($_REQUEST['event']) && $_REQUEST['event'] != '') { + $eventID = ($_REQUEST['event']-0); + } + + // If we don't have a regEvent or likely event ID, force option to a list + if (!$haveRegEvent && !$eventID) { + $option = 'list'; + } + + switch( $option ) { + + case 'update': + + // Try to update the reg event + $regEvent = $this->updateEntry($regEventID); + + // If there's some type of failure, flag that for the view file + if ($regEvent['status']) { + $regEventUpdated = true; + } else { + $regEventUpdateError = true; + } + + $template = 'eventEdit.html'; + + break; + + + case 'add': + case 'edit': + + if ($option == 'add') { + + // Verify that event is not already listed + $regEvent = $this->getEntry($eventID, 'event'); + if (!$regEvent) { + + // Get data on this event from events add-on + $eventData = apply_filters('glm-member-db-events-get-event', $eventID); + + // Did we get event data? + if ($eventData) { + + // Add event to registrations + $sql = " + INSERT INTO ".$this->table." + ( + event, + event_name, + event_code, + notify_email, + admin_active, + active, + attendees, + attendee_max, + attendee_max_per_reg, + reg_hold_minutes, + cart_hold_days, + registration_account_options, + payment_methods, + restricted_payment_methods, + terms + ) + VALUES + ( + ".$eventData['id'].", + '".$eventData['name']."', + '".$eventData['name_slug']."', + '".$eventData['admin_email']."', + false, + false, + true, + 0, + 0, + 60, + 10, + 0, + 0, + 0, + '' + ) + ;"; + $this->wpdb->query($sql); + $regEventID = $this->wpdb->insert_id; + + if ($regEventID) { + $regEventUpdated = true; + } + + } + + } else { + $reason = "Trying to add an event that is already listed in Registrations."; + } + + } + + // If there's no problem yet, try to get the regEvent data for edit + if ($reason == '') { + if ($regEventID) { + $regEvent = $this->editEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + } + + $template = 'eventEdit.html'; + break; + + case 'dashboard': + + if ($regEventID) { + $regEvent = $this->editEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + + if (!$haveRegEvent) { + $reason = 'Unable to load registration event data.'; + } + + $template = 'eventDashboard.html'; + break; + + case 'list': + default: + + $regEventList = $this->getList(); + + $template = 'eventList.html'; + break; + + } + + + // Compile template data + $templateData = array( + 'haveEvent' => $haveEvent, + 'eventID' => $eventID, + 'haveRegEvent' => $haveRegEvent, + 'regEventID' => $regEventID, + 'regEvent' => $regEvent, + 'regEventUpdated' => $regEventUpdated, + 'regEventUpdateError' => $regEventUpdateError, + 'regEventAdded' => $regEventAdded , + 'reason' => $reason + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/registrations/'.$template, + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/registrations/event.php b/models/admin/registrations/event.php new file mode 100644 index 0000000..a709b63 --- /dev/null +++ b/models/admin/registrations/event.php @@ -0,0 +1,285 @@ + + * @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/dataRegEvent.php'; + +class GlmMembersAdmin_registrations_event extends GlmDataRegistrationsRegEvent +{ + + /** + * 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 $regEventID = 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'; + $template = 'list.html'; + $regEvent = false; + $haveEvent = false; + $eventID = 0; + $haveRegEvent = false; + $regEventID = 0; + $regEventUpdated = false; + $regEventUpdateError = false; + $regEventAdded = false; + $reason = false; + + // Get any provided option + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + + // Check for a supplied regEvent record ID + if (isset($_REQUEST['regEventID']) && $_REQUEST['regEventID'] != '') { + + // Ensure ID is a positive integer + $regEventID = ($_REQUEST['regEventID'] - 0); + + // If no ID was supplied try to get last used reg event ID + if ($regEventID <= 0) { + $regEventID = get_option('glmMembersDatabaseLastUsedRegEventID'); + } + + } + + // If we have a positive Int reg event ID, try to get the reg event data + if ($regEventID > 0) { + $regEvent = $this->getEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + + // If we don't have a reg event ID, then check for an event ID to create new reg event + if (!$haveRegEvent && isset($_REQUEST['event']) && $_REQUEST['event'] != '') { + $eventID = ($_REQUEST['event']-0); + } + + switch( $option ) { + + case 'update': + + // Try to update the reg event + $regEvent = $this->updateEntry($regEventID); + + // If there's some type of failure, flag that for the view file + if ($regEvent['status']) { + $regEventUpdated = true; + } else { + $regEventUpdateError = true; + } + + $template = 'eventEdit.html'; + + break; + + + case 'add': + case 'edit': + + if ($option == 'add') { + + // Verify that event is not already listed + $regEvent = $this->getEntry($eventID, 'event'); + if (!$regEvent) { + + // Get data on this event from events add-on + $eventData = apply_filters('glm-member-db-events-get-event', $eventID); + + // Did we get event data? + if ($eventData) { + + // Add event to registrations + $sql = " + INSERT INTO ".$this->table." + ( + event, + event_name, + event_code, + notify_email, + admin_active, + active, + attendees, + attendee_max, + attendee_max_per_reg, + reg_hold_minutes, + cart_hold_days, + registration_account_options, + payment_methods, + restricted_payment_methods, + terms + ) + VALUES + ( + ".$eventData['id'].", + '".$eventData['name']."', + '".$eventData['name_slug']."', + '".$eventData['admin_email']."', + false, + false, + true, + 0, + 0, + 60, + 10, + 0, + 0, + 0, + '' + ) + ;"; + $this->wpdb->query($sql); + $regEventID = $this->wpdb->insert_id; + + if ($regEventID) { + $regEventUpdated = true; + } + + } + + } else { + $reason = "Trying to add an event that is already listed in Registrations."; + } + + } + + // If there's no problem yet, try to get the regEvent data for edit + if ($reason == '') { + if ($regEventID) { + $regEvent = $this->editEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + } + + $template = 'eventEdit.html'; + break; + + case 'dashboard': + default: + + if ($regEventID) { + $regEvent = $this->editEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + + if (!$haveRegEvent) { + $reason = 'Unable to load registration event data or registration event not selected.'; + } + + $template = 'event.html'; + break; + + } // switch + + // If we have a reg event, then save it as last accessed + if ($haveRegEvent) { + update_option('glmMembersDatabaseLastUsedRegEventID', $regEventID); + } + + // Compile template data + $templateData = array( + 'option' => $option, + 'haveEvent' => $haveEvent, + 'eventID' => $eventID, + 'haveRegEvent' => $haveRegEvent, + 'regEventID' => $regEventID, + 'regEvent' => $regEvent, + 'regEventUpdated' => $regEventUpdated, + 'regEventUpdateError' => $regEventUpdateError, + 'regEventAdded' => $regEventAdded , + 'reason' => $reason + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/registrations/'.$template, + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index cc3da3c..d83561a 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -88,13 +88,16 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent public function modelAction($actionData = false) { - $option = 'list'; - $template = 'list.html'; - $haveEvent = false; - $eventID = false; - $haveRegEvent = false; - $regEventID = false; - $reason = false; + $option = 'list'; + $template = 'list.html'; + $haveEvent = false; + $eventID = false; + $haveRegEvent = false; + $regEventID = false; + $regEventUpdated = false; + $regEventUpdateError = false; + $regEventAdded = false; + $reason = false; // Get any provided option if (isset($_REQUEST['option'])) { @@ -102,8 +105,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent } // Check for a supplied regEvent record ID - if (isset($_REQUEST['regEvent']) && $_REQUEST['regEvent'] != '') { - $regEventID = ($_REQUEST['regEvent'] - 0); + if (isset($_REQUEST['regEventID']) && $_REQUEST['regEventID'] != '') { + $regEventID = ($_REQUEST['regEventID'] - 0); if ($regEventID > 0) { $regEvent = $this->getEntry($regEventID); if ($regEvent) { @@ -112,8 +115,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent } } - // Check for an event ID and make sure it's a positive integer - if (isset($_REQUEST['event']) && $_REQUEST['event'] != '') { + // If we don't have a reg event ID, then check for an event ID and make sure it's a positive integer + if (!$haveRegEvent && isset($_REQUEST['event']) && $_REQUEST['event'] != '') { $eventID = ($_REQUEST['event']-0); } @@ -121,9 +124,26 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent if (!$haveRegEvent && !$eventID) { $option = 'list'; } - + switch( $option ) { + case 'update': + + // Try to update the reg event + $regEvent = $this->updateEntry($regEventID); + + // If there's some type of failure, flag that for the view file + if ($regEvent['status']) { + $regEventUpdated = true; + } else { + $regEventUpdateError = true; + } + + $template = 'eventEdit.html'; + + break; + + case 'add': case 'edit': @@ -165,8 +185,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent '".$eventData['name']."', '".$eventData['name_slug']."', '".$eventData['admin_email']."', - true, - ".($eventData['status']['value'] == 10 ? 'true' : 'false').", + false, + false, true, 0, 0, @@ -180,6 +200,10 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent ;"; $this->wpdb->query($sql); $regEventID = $this->wpdb->insert_id; + + if ($regEventID) { + $regEventUpdated = true; + } } @@ -202,41 +226,28 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $template = 'eventEdit.html'; break; - case 'dashboard': - - if ($regEventID) { - $regEvent = $this->editEntry($regEventID); - if ($regEvent) { - $haveRegEvent = true; - } - } - - if (!$haveRegEvent) { - $reason = 'Unable to load registration event data.'; - } - - $template = 'eventDashboard.html'; - break; - - case 'list': default: + + echo "OOOPPPPSSSSS! Should not get here....."; + exit; - $regEventList = $this->getList(); - - $template = 'eventList.html'; break; - + + } // Compile template data $templateData = array( - 'haveEvent' => $haveEvent, - 'eventID' => $eventID, - 'haveRegEvent' => $haveRegEvent, - 'regEventID' => $regEventID, - 'regEvent' => $regEvent, - 'reason' => $reason + 'haveEvent' => $haveEvent, + 'eventID' => $eventID, + 'haveRegEvent' => $haveRegEvent, + 'regEventID' => $regEventID, + 'regEvent' => $regEvent, + 'regEventUpdated' => $regEventUpdated, + 'regEventUpdateError' => $regEventUpdateError, + 'regEventAdded' => $regEventAdded , + 'reason' => $reason ); // Return status, any suggested view, and any data to controller diff --git a/models/admin/registrations/index.php b/models/admin/registrations/index.php index 658cd58..0e2fa5f 100644 --- a/models/admin/registrations/index.php +++ b/models/admin/registrations/index.php @@ -88,7 +88,6 @@ class GlmMembersAdmin_registrations_index // extends GlmDataRegistrations public function modelAction($actionData = false) { - // Compile template data $templateData = array( ); diff --git a/models/admin/registrations/list.php b/models/admin/registrations/list.php new file mode 100644 index 0000000..1c46b65 --- /dev/null +++ b/models/admin/registrations/list.php @@ -0,0 +1,380 @@ + + * @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/dataRegEvent.php'; + +class GlmMembersAdmin_registrations_list extends GlmDataRegistrationsRegEvent +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /**MEMBER + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Registrations Event ID + * + * @var $eventID + * @access public + */ + public $regEventID = 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) + { + + $where = ' true '; + $alphaWhere = ' true '; + $numbDisplayed = false; + $lastDisplayed = false; + $paging = true; + $prevStart = false; + $nextStart = false; + $start = 1; + $limit = 20; // Set to the number of listings per page + $textSearch = false; + $where = "TRUE"; + $alphaList = false; + $alphaWhere = ''; + $alphaSelected = false; + $haveRegEvents = false; + $regEventsCount = false; + + // If doing alpha list + if (isset($_REQUEST['alpha'])) { + $actionData['request']['alpha'] = $_REQUEST['alpha']; + } + + // If user clicked a page request then we need to check the savedAlpha value + if (isset($_REQUEST['savedAlpha']) && isset($_REQUEST['pageSelect'])) { + $actionData['request']['alpha'] = $_REQUEST['savedAlpha']; + } + + if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { + $alphaSelected = strtoupper($actionData['request']['alpha']); + $alphaWhere .= " AND T.name LIKE '$alphaSelected%'"; + } + + // Get full list for all other filters, but not filtered by alpha (that would be silly) + $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected); + + // Get count of reg event listed + $regEventsCount = $this->getStats($where); + + // Get stats for number of members found matching current selection criteria (includes alpha selection) + $filteredRegEventsFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); + + // Get a current list of reg events + $listResult = $this->getSimpleRegEventsList($where.$alphaWhere, 'event_name', true, 'id', $start, $limit); + + // Get paging results + $numbDisplayed = $listResult['returned']; + $lastDisplayed = $listResult['last']; + if ($start == 1) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ($start < 1) { + $start = 1; + } + } + if ($listResult['returned'] == $limit) { + $nextStart = $start + $limit; + } + + // since we're doing paging, we have to break out just the member data + $list = $listResult['list']; + unset($listResult); + + // If we have list entries - even if it's an empty list + $success = true; + $haveRegEvents = false; + if ($list !== false) { + + $success = true; + + // If we have any entries + if (count($list) > 0) { + $haveRegEvents = true; + } + } + + // Add a url for each reg event + if ( isset( $list) && is_array( $list ) ) { + foreach ($list as $regEvent) { + $list[$regEvent['id']]['reg'] = sanitize_title($member['name']); + } + } + + + + + + + + $template = 'list.html'; + +/* + + // Check for a text search + if (isset($_REQUEST['text_search']) && trim($_REQUEST['text_search']) != '') { + + $textSearch = addslashes(filter_input(INPUT_POST, 'text_search', FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); + $where .= " AND T.id in ( + SELECT DISTINCT(member) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info + WHERE member_name like '%$textSearch%' + )"; + } + + // Check for "Pending Only + if (isset($_REQUEST['filterPending'])) { + + // Refine search only to members with pending Info data + $where .= " AND ( + SELECT COUNT(id) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info I + WHERE I.status = ".$this->config['status_numb']['Pending']." + AND I.member = T.id + )"; + + $filterPending = true; + $haveFilter = true; + } + + // Check for "Featured Only + if (isset($_REQUEST['filterFeatured'])) { + + // Refine search only to members with pending Info data + $where .= " AND ( + SELECT COUNT(id) + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members I + WHERE I.featured = 1 + AND I.id = T.id + + )"; + $filterFeatured = true; + $haveFilter = true; + } + + // If doing alpha list + if (isset($_REQUEST['alpha'])) { + $actionData['request']['alpha'] = $_REQUEST['alpha']; + } + + $alphaList = false; + $alphaWhere = ''; + + $alphaSelected = false; + + // If user clicked a page request then we need to check the savedAlpha value + if (isset($_REQUEST['savedAlpha']) && isset($_REQUEST['pageSelect'])) { + $actionData['request']['alpha'] = $_REQUEST['savedAlpha']; + } + + if ($actionData['request']['alpha'] && strlen($actionData['request']['alpha']) == 1) { + $alphaSelected = strtoupper($actionData['request']['alpha']); + $alphaWhere .= " AND T.name LIKE '$alphaSelected%'"; + } + + // Get full list for all other filters, but not filtered by alpha (that would be silly) + $alphaList = $this->getAlphaList(' AND '.$where, $alphaSelected); + + $whereParts = apply_filters('glm-member-db-admin-search-query', $where); + if ( is_array( $whereParts ) && count( $whereParts ) > 0 ) { + $where .= ' AND '.implode(" AND ", $whereParts); + $whereSep = ' AND '; + } + + // Get count of members listed + $memberCount = $this->getStats($where); + + // If the number of members is less than a page, don't do paging + if ($memberCount <= $limit) { + $paging = false; + } + + // Get full list of names matching this where clause for search box + $namesList = $this->getIdName($where); + + // Check if we're doing paging + if (isset($_REQUEST['pageSelect'])) { + + // If request is for Next + if ($_REQUEST['pageSelect'][0] == 'N') { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } + } + + // Get stats for number of members found matching current selection criteria (includes alpha selection) + $filteredMembersFound = $this->getStats(str_replace('T.', '', $where.$alphaWhere)); + + // Get a current list of members + $listResult = $this->getSimpleMembersList($where.$alphaWhere, 'name', true, 'id', $start, $limit); + + // Get paging results + $numbDisplayed = $listResult['returned']; + $lastDisplayed = $listResult['last']; + if ($start == 1) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ($start < 1) { + $start = 1; + } + } + if ($listResult['returned'] == $limit) { + $nextStart = $start + $limit; + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice($list, 'DataBlock', 'Member Data'); + } + + // since we're doing paging, we have to break out just the member data + $list = $listResult['list']; + unset($listResult); + + // If we have list entries - even if it's an empty list + $success = true; + $haveMembers = false; + if ($list !== false) { + + $success = true; + + // If we have any entries + if (count($list) > 0) { + $haveMembers = true; + } + } + + // Determine if current user can add, edit, delete member data + // $canEdit = current_user_can('glm_members_edit'); + + // Add a url for each member + if ( isset( $list) && is_array( $list ) ) { + foreach ($list as $member) { + $list[$member['id']]['member_slug'] = sanitize_title($member['name']); + } + } + + // Compile template data + $templateData = array( + 'enable_members' => $enable_members, + 'haveMembers' => $haveMembers, + 'members' => $list, + 'memberCount' => $memberCount, + 'categories' => $categories, + 'haveFilter' => $haveFilter, + 'filterArchived' => $filterArchived, + 'filterFeatured' => $filterFeatured, + 'filterPending' => $filterPending, + 'catSelected' => $catSelected, + 'catSearchSelected' => $catSelectedString, + 'alphaList' => $alphaList, + 'alphaSelected' => $alphaSelected, + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'paging' => $paging, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'start' => $start, + 'limit' => $limit, + 'namesList' => $namesList, + 'textSearch' => $textSearch + ); +*/ + + // Compile template data + $templateData = array( + 'regEventsCount' => $regEventsCount, + 'haveRegEvents' => $haveRegEvents, + 'regEvents' => $list, + + ); + + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'admin/registrations/'.$template, + 'data' => $templateData + ); + + } + + +} diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 5145682..b653cff 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -61,13 +61,22 @@ add_submenu_page( add_submenu_page( 'glm-members-admin-menu-members', - 'Registration Events', - '    Events', + 'Registration Events List', + '    List', 'glm_members_members', - 'glm-members-admin-menu-registrations-events', - function() {$this->controller('registrations', 'events');} + 'glm-members-admin-menu-registrations-list', + function() {$this->controller('registrations', 'list');} ); +add_submenu_page( + 'glm-members-admin-menu-members', + 'Selected Event', + '    Selected Event', + 'glm_members_members', + 'glm-members-admin-menu-registrations-event', + function() {$this->controller('registrations', 'event');} + ); + add_submenu_page( 'glm-members-admin-menu-members', 'Registration Requests', diff --git a/setup/databaseScripts/create_database_V0.0.8.sql b/setup/databaseScripts/create_database_V0.0.8.sql index 2cce0b1..04ec95d 100644 --- a/setup/databaseScripts/create_database_V0.0.8.sql +++ b/setup/databaseScripts/create_database_V0.0.8.sql @@ -298,14 +298,14 @@ CREATE TABLE {prefix}payment_code ( -- Registration event specific information -- One record for each event in Events add-on --- Only created when selecting registrations for a particular event in the Events add-on +-- Only created when an event is selected to offer registrations CREATE TABLE {prefix}reg_event ( id INT NOT NULL AUTO_INCREMENT, event INT NULL, -- Pointer to event in Events add-on - False if event record in Events add-on no longer exists event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data event_code TINYTEXT NULL, -- A short code used to reference this event - can be used to directly select an event to register for notify_email TINYTEXT NULL, -- E-Mail addresses to recieve notification of a registration other than org_internal_email in management, comma separated - admin_active BOOLEAN NULL, -- Active flag for admin from Events - If false, then does not show as a link from events to manage event. Still shows in registrations admin + admin_active BOOLEAN NULL, -- Active flag for admin from Events - If logged in Admin user for this event and this is true then admin user may enter registrations even if active is off. active BOOLEAN NULL, -- Active flag to indicate that this event is available for registrations attendees BOOLEAN NULL, -- Registration requires attendees - Otherwise the person submitting the registration is the registrant attendee_max MEDIUMINT NULL, -- Attendee limit - 0 = unlimited @@ -328,12 +328,13 @@ CREATE TABLE {prefix}reg_event ( ---- -- Registration Event Time - Information and summary data for a specific event instance (relates to a perticular time record in events) +-- A pseudo entry is created if registration is not date/time sensitive for this event. The pseudo entry does not point to an event time. -- These are created the first time a person tries to register for an event instance (time) -- One or more for each event CREATE TABLE {prefix}reg_time ( id INT NOT NULL AUTO_INCREMENT, reg_event INT NULL, -- Pointer to reg_event table - event_time INT NULL, -- Pointer to events times table entry - False if event time record in Events add-on no longer exists + event_time INT NULL, -- Pointer to events times table entry - If false, then this is a pseudo entry to use for all registrations (non-date/time specific) start_datetime DATETIME NULL, -- Date and time when event instance starts - Informational - Actual events data is definitive end_datetime DATETIME NULL, -- Date and time when event instance ends - Informational all_day BOOLEAN NULL, -- All Day flag - Informational diff --git a/setup/validActions.php b/setup/validActions.php index 37c0f22..d268ca9 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -61,7 +61,8 @@ $glmMembersRegistrationsAddOnValidActions = array( 'adminActions' => array( 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'events' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'list' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'event' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'requests' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'accounts' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), diff --git a/views/admin/registrations/event.html b/views/admin/registrations/event.html new file mode 100644 index 0000000..ce76d6c --- /dev/null +++ b/views/admin/registrations/event.html @@ -0,0 +1,56 @@ +{include file='admin/registrations/header.html'} + +{if $reason} +

{$reason}

+{/if} + +
+ {if $haveRegEvent} + +
+
+
+
+
+

Event Name:

+
+
+ {$regEvent.fieldData.event_name} +
+
+
+
+
+
+
+
+

Event Code:

+
+
+ {$regEvent.fieldData.event_code} +
+
+
+
+ {if apply_filters('glm_members_menu_members', true)} + + {/if} +
+ {else} +

+ {/if} + +
+ + +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html deleted file mode 100644 index 9a37798..0000000 --- a/views/admin/registrations/eventDashboard.html +++ /dev/null @@ -1,6 +0,0 @@ -{include file='admin/registrations/header.html'} - -

Registrations Event Dashboard

- -{include file='admin/footer.html'} - diff --git a/views/admin/registrations/eventEdit.html b/views/admin/registrations/eventEdit.html index 7bd2b66..c827a6c 100644 --- a/views/admin/registrations/eventEdit.html +++ b/views/admin/registrations/eventEdit.html @@ -1,135 +1,143 @@ {include file='admin/registrations/header.html'} -

Registrations Event Edit

- - -{$x='event_name'} -{$regEvent.fieldData.$x} - - -{include - 'admin/registrations/text_input.html' - fieldName='event_name' - fieldPrompt='Event Name' - fieldValue=$regEvent.fieldData.event_name - fieldFail=$regEvent.fieldFail.event_name -} - +

+ Registrations Event Edit + +     + {if $regEventUpdated}Registration Event Updated{/if} + {if $regEventUpdateError}Registration Event Update Error{/if} + {if $regEventAdded}Registration Event Added{/if} + +

{if $reason}

{$reason}

{else} - Return to Account List + Return to Dashboard + +

(Items in red are required)

- + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - +
Event NameEvent Name {if $regEvent.fieldFail.event_name}

{$regEvent.fieldFail.event_name}

{/if}
Event Registration CodeEvent Registration Code {if $regEvent.fieldFail.event_code}

{$regEvent.fieldFail.event_code}

{/if}
Notify E-Mail AddressNotify E-Mail Address {if $regEvent.fieldFail.notify_email}

{$regEvent.fieldFail.notify_email}

{/if}
Admin ActiveAdmin Active {if $regEvent.fieldFail.admin_active}

{$regEvent.fieldFail.admin_active}

{/if}
Registrations ActiveRegistrations Active {if $regEvent.fieldFail.active}

{$regEvent.fieldFail.active}

{/if}
Multiple Attendees per SubmissionMultiple Attendees per Submission {if $regEvent.fieldFail.attendees}

{$regEvent.fieldFail.attendees}

{/if}
Maximum # of AttendeesMaximum # of Attendees + Set to 0 to permit an unlimited number of attendees for this event.
{if $regEvent.fieldFail.attendee_max}

{$regEvent.fieldFail.attendee_max}

{/if}
Maximum # of Attendees Per SubmissionMaximum # of Attendees Per Submission + Set to 0 for to permit a user to register an unlimited number of attendees for this event at one time.
{if $regEvent.fieldFail.attendee_max_per_reg}

{$regEvent.fieldFail.attendee_max_per_reg}

{/if}
Attendees in Cart Hold TimeAttendees Hold Time (minutes) + When an attendee is added to a registration request, the system will hold that attendee "slot" for this number of minutes + before releasing it for others to register. After the attendee slot is released, the slot will be requested again each + time the selection, cart, or checkout pages are loaded. If there is a slot available at that time, it will again be held + for this amount of time.
{if $regEvent.fieldFail.reg_hold_minutes}

{$regEvent.fieldFail.reg_hold_minutes}

{/if}
Cart Hold Days Without CheckoutCart Hold (days) + If the user has registrations entered but has not yet checked out, their "cart" will be maintained for this number of days. + After that time, the card will be deleted. If a user has established a registrations account (entered registrations or + have been registered before, the user will be able log in and continue with the cart up to this number of days.
{if $regEvent.fieldFail.cart_hold_days}

{$regEvent.fieldFail.cart_hold_days}

{/if}
Account OptionsAccount Options {foreach from=$regEvent.fieldData.registration_account_options.bitmap item=v} - {$v.name}
+ {$v.name}
{/foreach} {if $regEvent.fieldFail.registration_account_options}

{$regEvent.fieldFail.registration_account_options}

{/if}
Payment MethodsPayment Methods + Checking a payment method makes it available for use by regular users at checkout.
{foreach from=$regEvent.fieldData.payment_methods.bitmap item=v} - {$v.name}
+ {$v.name}
{/foreach} {if $regEvent.fieldFail.payment_methods}

{$regEvent.fieldFail.payment_methods}

{/if}
Restricted Payment Methods (Admin use only) - {foreach from=$regEvent.fieldData.resitricted_payment_methods.bitmap item=v} - {$v.name}
+
Restricted Payment Methods + Restricted payment methods are those only available to logged in administrative users. For example, selecting "No Charge" here + will allow administrative users to check out without having to provide any payment information.
+ {foreach from=$regEvent.fieldData.restricted_payment_methods.bitmap item=v} + {$v.name}
{/foreach} - {if $regEvent.fieldFail.resitricted_payment_methods}

{$regEvent.fieldFail.resitricted_payment_methods}

{/if}
+ {if $regEvent.fieldFail.restricted_payment_methods}

{$regEvent.fieldFail.restricted_payment_methods}

{/if}
Terms and Conditions for RegistrationTerms and Conditions for Registration {if $regEvent.fieldFail.terms} @@ -138,7 +146,7 @@
FileFile {if $regEvent.fieldData.reg_file} Replace this file: @@ -150,14 +158,14 @@
File TitleFile Title {if $regEvent.fieldFail.reg_file_title}

{$regEvent.fieldFail.reg_file_title}

{/if}
NotesNotes {if $regEvent.fieldFail.notes} @@ -166,10 +174,21 @@
+ + +
- {/if} + + {include file='admin/footer.html'} diff --git a/views/admin/registrations/header.html b/views/admin/registrations/header.html index ddbd628..3cc1773 100644 --- a/views/admin/registrations/header.html +++ b/views/admin/registrations/header.html @@ -1,9 +1,10 @@

Event Registrations

diff --git a/views/admin/registrations/index.html b/views/admin/registrations/index.html index defc85d..7a33c98 100644 --- a/views/admin/registrations/index.html +++ b/views/admin/registrations/index.html @@ -2,5 +2,7 @@

Registrations Dashboard

+

Not Built Yet

+ {include file='admin/footer.html'} diff --git a/views/admin/registrations/eventList.html b/views/admin/registrations/list-save.html similarity index 84% rename from views/admin/registrations/eventList.html rename to views/admin/registrations/list-save.html index 45c42e7..fbf4367 100644 --- a/views/admin/registrations/eventList.html +++ b/views/admin/registrations/list-save.html @@ -1,6 +1,8 @@ {include file='admin/registrations/header.html'}

Registrations Event List

+ +

Not Built Yet

{include file='admin/footer.html'} diff --git a/views/admin/registrations/list.html b/views/admin/registrations/list.html new file mode 100644 index 0000000..2f8ff80 --- /dev/null +++ b/views/admin/registrations/list.html @@ -0,0 +1,267 @@ +{include file='admin/registrations/header.html'} + +
+
+ + + + + + +

List of Registration Events

+ +
+ Text Search: + +
+ +

Total found: {$regEventsCount}  

+ +
+ + + + {if $paging} + + + {/if} + + + + + + + + + + + + {if $haveRegEvents} + {assign var="i" value="0"} + {foreach $regEvents as $r} + {if $i++ is odd by 1} + + {else} + + {/if} + + + + {/foreach} + {else} + + {/if} + +
IDEvent Name
+ {$r.id} + + {$r.event_name} +
(no {$terms.term_member_plur} listed)
+ + {if $paging} + + + {/if} + +
+ +
+
+ + + + + + + + + + + + + + + + + + + +
Categories: + +
Show Archived:
Featured Only:
Pending Only:
Name Search:
+ Enter any portion of a {$terms.term_member_cap} name and press enter or select any specific {$terms.term_member_cap} found. +
Fields to export + + + + + +
+ {$terms.term_member_cap} ID
+ Old {$terms.term_member_cap} ID
+ {$terms.term_member_cap} Name
+ Profile Reference Name
+ Address Line #1
+ Address Line #2
+ City
+ State
+ ZIP/Postal Code
+ County
+ Region
+
+ Phone #
+ Toll Free
+ Main E-Mail
+ Primary Contact Name
+ Primary Contact E-Mail
+ Web Address (URL)
+ Categories
+ Mailing Address Line #1
+ Mailing Address Line #2
+ Mailing City
+ Mailing State
+ Mailing ZIP/Postal Code
+
+
Export to: + Export for Print
+ Export to Spreadsheet (CSV) +
+ Cancel + +
+
+
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/registrations/text_input.html b/views/admin/registrations/text_input.html deleted file mode 100644 index 814d6fd..0000000 --- a/views/admin/registrations/text_input.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -

title = {$fieldPrompt}

-

name = {$fieldName}

-

value = {$fieldValue}

-

fail = {$fieldFail}

- -- 2.17.1