From: Chuck Scott Date: Thu, 7 Sep 2017 18:54:48 +0000 (-0400) Subject: More reorganization of registrations admin models and views. X-Git-Tag: v1.0.0^2~424 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=e939cb4d0798afe06ba0d8cea13ab2f6c3637d96;p=WP-Plugins%2Fglm-member-db-registrations.git More reorganization of registrations admin models and views. Removed old view files. Removed saved versions of models. Minor changes to hawe the registrations admin menus show. --- diff --git a/models/admin/registrations/dashboard-SAVE.php b/models/admin/registrations/dashboard-SAVE.php new file mode 100644 index 0000000..88678ed --- /dev/null +++ b/models/admin/registrations/dashboard-SAVE.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'; + $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'; + + 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'; + break; + + case 'dashboard': + + if ($regEventID) { + $regEvent = $this->editEntry($regEventID); + if ($regEvent) { + $haveRegEvent = true; + } + } + + if (!$haveRegEvent) { + $reason = 'Unable to load registration event data.'; + } + + $template = 'eventDashboard'; + break; + + case 'list': + default: + + $regEventList = $this->getList(); + + $template = 'eventList'; + 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.'.html', + 'data' => $templateData + ); + + } + + +} diff --git a/models/admin/registrations/dashboard.php b/models/admin/registrations/dashboard.php deleted file mode 100644 index ec4ce61..0000000 --- a/models/admin/registrations/dashboard.php +++ /dev/null @@ -1,280 +0,0 @@ - - * @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-SAVE.php b/models/admin/registrations/event-SAVE.php new file mode 100644 index 0000000..32fc106 --- /dev/null +++ b/models/admin/registrations/event-SAVE.php @@ -0,0 +1,385 @@ + + * @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'; + $regEvent = false; + $haveEvent = false; + $haveRegEventRecurrences = false; + $haveRegEventTimes = false; + $regEventFirstTime = false; + $regEventLastTime = 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 and make sure it's and integer + if (isset($_REQUEST['regEventID']) && $_REQUEST['regEventID'] != '') { + $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 we're adding a new reg event + 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 we have an event ID + if ($regEventID) { + + // Try to get the event configuration including recurrences and times + $this->postProcAddedEventData = true; + $regEvent = $this->getEventConfig($regEventID, true, true, true); + + // If we have the event data + if ($regEvent) { + + $haveRegEvent = true; + + // If event is time_specific and we have recurrences for the event + if ($regEvent['time_specific']['value'] && is_array($regEvent['recurrences']) && count($regEvent['recurrences']) > 0) { + + $haveRegEventRecurrences = true; + + // For each recurrence + foreach ($regEvent['recurrences'] as $k=>$v) { + + $regEvent['recurrences'][$k]['haveTimes'] = false; + + // If we have times for this recuirrence + if ($v['times'] && count($v['times']) > 0) { + + $regEvent['recurrences'][$k]['haveTimes'] = false; + $haveRegEventTimes = true; + + // Get the first event date/time + $first = current($v['times']); + $last = end($v['times']); + $regEvent['recurrences'][$k]['first_time'] = $first; + $regEvent['recurrences'][$k]['lastTime'] = $last; + + // Set event first and last times + if (!$regEventFirstTime || $regEventFirstTime['timestamp'] < $first ) { + $regEventFirstTime = $first; + } + if (!$regEventLastTime || $regEventLastTime['timestamp'] > $last ) { + $regEventLastTime = $last; + } + + // Check all event times for matching reg event times + foreach ($v['times'] as $tk=>$tv) { + + // If time doesn't exist in reg_times + if (!isset($regEvent['reg_times'][$tk])) { + + $sTime = date('Y-m-d H:i:s',strtotime($tv['start_time']['datetime'])); + $eTime = date('Y-m-d H:i:s',strtotime($tv['end_time']['datetime'])); + + // Add reg event time + $this->wpdb->insert( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time", + array( + 'reg_event' => $regEvent['event'], + 'event_time' => $tk, + 'start_datetime' => $sTime, + 'end_datetime' => $eTime, + 'all_day' => $tv['all_day']['value'], + 'attendees' => $regEvent['attendees']['value'], + 'attendee_max' => $regEvent['attendee_max'], + 'attendee_count' => 0, + 'attendees_pending' => 0, + 'attendees_available' => $regEvent['attendee_max'], + 'total_base_charge' => 0, + 'total_per_attendee' => 0, + 'total_other' => 0, + 'total_taxes' => 0, + 'total_charges' => 0, + 'total_discounts' => 0, + 'total_payments' => 0 + ), + array( + '%d', // reg_event + '%d', // event_time record ID + '%s', // start_datetime + '%s', // end_datetime + '%d', // all_day flag + '%d', // attendees flag + '%d', // attendee_max + '%d', // attendee_count + '%d', // attendees_pending + '%d', // attendees_available + '%f', // total_base__charge + '%f', // total_per_attendee + '%f', // total_other + '%f', // total_taxes + '%f', // total_charges + '%f', // total_discounts + '%f' // total_payments + ) + ); + } + } + } + } + } + } + } + + 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, + 'haveRegEventRecurrences' => $haveRegEventRecurrences, + 'haveRegEventTimes' => $haveRegEventTimes, + 'regEventFirstTime' => $regEventFirstTime, + 'regEventLastTime' => $regEventLastTime, + 'regEventID' => $regEventID, + 'regEvent' => $regEvent, + 'regEventUpdated' => $regEventUpdated, + 'regEventUpdateError' => $regEventUpdateError, + 'regEventAdded' => $regEventAdded , + 'reason' => $reason + ); + + // echo "
".print_r($templateData,1)."
"; + + // 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 deleted file mode 100644 index 8f06f93..0000000 --- a/models/admin/registrations/event.php +++ /dev/null @@ -1,386 +0,0 @@ - - * @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; - $haveRegEventRecurrences = false; - $haveRegEventTimes = false; - $regEventFirstTime = false; - $regEventLastTime = 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 and make sure it's and integer - if (isset($_REQUEST['regEventID']) && $_REQUEST['regEventID'] != '') { - $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 we're adding a new reg event - 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 we have an event ID - if ($regEventID) { - - // Try to get the event configuration including recurrences and times - $this->postProcAddedEventData = true; - $regEvent = $this->getEventConfig($regEventID, true, true, true); - - // If we have the event data - if ($regEvent) { - - $haveRegEvent = true; - - // If event is time_specific and we have recurrences for the event - if ($regEvent['time_specific']['value'] && is_array($regEvent['recurrences']) && count($regEvent['recurrences']) > 0) { - - $haveRegEventRecurrences = true; - - // For each recurrence - foreach ($regEvent['recurrences'] as $k=>$v) { - - $regEvent['recurrences'][$k]['haveTimes'] = false; - - // If we have times for this recuirrence - if ($v['times'] && count($v['times']) > 0) { - - $regEvent['recurrences'][$k]['haveTimes'] = false; - $haveRegEventTimes = true; - - // Get the first event date/time - $first = current($v['times']); - $last = end($v['times']); - $regEvent['recurrences'][$k]['first_time'] = $first; - $regEvent['recurrences'][$k]['lastTime'] = $last; - - // Set event first and last times - if (!$regEventFirstTime || $regEventFirstTime['timestamp'] < $first ) { - $regEventFirstTime = $first; - } - if (!$regEventLastTime || $regEventLastTime['timestamp'] > $last ) { - $regEventLastTime = $last; - } - - // Check all event times for matching reg event times - foreach ($v['times'] as $tk=>$tv) { - - // If time doesn't exist in reg_times - if (!isset($regEvent['reg_times'][$tk])) { - - $sTime = date('Y-m-d H:i:s',strtotime($tv['start_time']['datetime'])); - $eTime = date('Y-m-d H:i:s',strtotime($tv['end_time']['datetime'])); - - // Add reg event time - $this->wpdb->insert( - GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time", - array( - 'reg_event' => $regEvent['event'], - 'event_time' => $tk, - 'start_datetime' => $sTime, - 'end_datetime' => $eTime, - 'all_day' => $tv['all_day']['value'], - 'attendees' => $regEvent['attendees']['value'], - 'attendee_max' => $regEvent['attendee_max'], - 'attendee_count' => 0, - 'attendees_pending' => 0, - 'attendees_available' => $regEvent['attendee_max'], - 'total_base_charge' => 0, - 'total_per_attendee' => 0, - 'total_other' => 0, - 'total_taxes' => 0, - 'total_charges' => 0, - 'total_discounts' => 0, - 'total_payments' => 0 - ), - array( - '%d', // reg_event - '%d', // event_time record ID - '%s', // start_datetime - '%s', // end_datetime - '%d', // all_day flag - '%d', // attendees flag - '%d', // attendee_max - '%d', // attendee_count - '%d', // attendees_pending - '%d', // attendees_available - '%f', // total_base__charge - '%f', // total_per_attendee - '%f', // total_other - '%f', // total_taxes - '%f', // total_charges - '%f', // total_discounts - '%f' // total_payments - ) - ); - } - } - } - } - } - } - } - - 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, - 'haveRegEventRecurrences' => $haveRegEventRecurrences, - 'haveRegEventTimes' => $haveRegEventTimes, - 'regEventFirstTime' => $regEventFirstTime, - 'regEventLastTime' => $regEventLastTime, - 'regEventID' => $regEventID, - 'regEvent' => $regEvent, - 'regEventUpdated' => $regEventUpdated, - 'regEventUpdateError' => $regEventUpdateError, - 'regEventAdded' => $regEventAdded , - 'reason' => $reason - ); - - // echo "
".print_r($templateData,1)."
"; - - // 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-SAVE.php b/models/admin/registrations/events-SAVE.php new file mode 100644 index 0000000..b1bbe7e --- /dev/null +++ b/models/admin/registrations/events-SAVE.php @@ -0,0 +1,264 @@ + + * @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_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; + + default: + + echo "OOOPPPPSSSSS! Should not get here....."; + exit; + + break; + + + } + + echo "---------------------------------------------------"; + // 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/events.php b/models/admin/registrations/events.php index d83561a..589d7a0 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -1,7 +1,7 @@ 0) { - $regEvent = $this->getEntry($regEventID); - if ($regEvent) { - $haveRegEvent = true; - } - } + + } else { + + // Try to get saved + $regEventID = get_option('glmMembersDatabaseRegistrationsRegEventID'); + } - // 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 (!$regEventID || $regEventID <= 0) { + $regEventID = false; } - // 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); + + + switch ($option) { + + case 'configureEvent': - // If there's some type of failure, flag that for the view file - if ($regEvent['status']) { - $regEventUpdated = true; - } else { - $regEventUpdateError = true; - } - - $template = 'eventEdit.html'; + $view = 'eventEditLevels'; break; - case 'add': case 'edit': - + + // If we're adding a new reg event 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." + INSERT INTO ".$this->table." ( event, event_name, @@ -196,7 +204,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 0, 0, '' - ) + ) ;"; $this->wpdb->query($sql); $regEventID = $this->wpdb->insert_id; @@ -204,7 +212,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent if ($regEventID) { $regEventUpdated = true; } - + } } else { @@ -212,7 +220,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent } } - + // If there's no problem yet, try to get the regEvent data for edit if ($reason == '') { if ($regEventID) { @@ -223,38 +231,255 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent } } - $template = 'eventEdit.html'; + $view = 'eventEdit'; + break; - default: + 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'; + + break; + + + case 'eventDashboard': + + // If we have an event ID + if ($regEventID) { + + $regEvent = $this->getEntry($regEventID); + if ($regEvent) { - echo "OOOPPPPSSSSS! Should not get here....."; - exit; + $haveRegEvent = true; + + // Try to get the event configuration including recurrences and times + $this->postProcAddedEventData = true; + $regEvent = $this->getEventConfig($regEventID, true, true, true); + + // If we have the event data + if ($regEvent) { + + $haveRegEvent = true; + + // If event is time_specific and we have recurrences for the event + if ($regEvent['time_specific']['value'] && is_array($regEvent['recurrences']) && count($regEvent['recurrences']) > 0) { + + $haveRegEventRecurrences = true; + + // For each recurrence + foreach ($regEvent['recurrences'] as $k=>$v) { + + $regEvent['recurrences'][$k]['haveTimes'] = false; + + // If we have times for this recurrence + if ($v['times'] && count($v['times']) > 0) { + + $regEvent['recurrences'][$k]['haveTimes'] = false; + $haveRegEventTimes = true; + + // Get the first event date/time + $first = current($v['times']); + $last = end($v['times']); + $regEvent['recurrences'][$k]['first_time'] = $first; + $regEvent['recurrences'][$k]['lastTime'] = $last; + + // Set event first and last times + if (!$regEventFirstTime || $regEventFirstTime['timestamp'] < $first ) { + $regEventFirstTime = $first; + } + if (!$regEventLastTime || $regEventLastTime['timestamp'] > $last ) { + $regEventLastTime = $last; + } + + // Check all event times for matching reg event times + foreach ($v['times'] as $tk=>$tv) { + + // If time doesn't exist in reg_times + if (!isset($regEvent['reg_times'][$tk])) { + + $sTime = date('Y-m-d H:i:s',strtotime($tv['start_time']['datetime'])); + $eTime = date('Y-m-d H:i:s',strtotime($tv['end_time']['datetime'])); + + // Add reg event time + $this->wpdb->insert( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time", + array( + 'reg_event' => $regEvent['event'], + 'event_time' => $tk, + 'start_datetime' => $sTime, + 'end_datetime' => $eTime, + 'all_day' => $tv['all_day']['value'], + 'attendees' => $regEvent['attendees']['value'], + 'attendee_max' => $regEvent['attendee_max'], + 'attendee_count' => 0, + 'attendees_pending' => 0, + 'attendees_available' => $regEvent['attendee_max'], + 'total_base_charge' => 0, + 'total_per_attendee' => 0, + 'total_other' => 0, + 'total_taxes' => 0, + 'total_charges' => 0, + 'total_discounts' => 0, + 'total_payments' => 0 + ), + array( + '%d', // reg_event + '%d', // event_time record ID + '%s', // start_datetime + '%s', // end_datetime + '%d', // all_day flag + '%d', // attendees flag + '%d', // attendee_max + '%d', // attendee_count + '%d', // attendees_pending + '%d', // attendees_available + '%f', // total_base__charge + '%f', // total_per_attendee + '%f', // total_other + '%f', // total_taxes + '%f', // total_charges + '%f', // total_discounts + '%f' // total_payments + ) + ); + + } // If time isn't in reg_times + } // each recurrence times + } // have times for recurrence + } // each recurrence + } // Time specific and have times + } // have event data + } // have reg event ID + + } else { + $reason = 'Unable to load registration event data or registration event not selected.'; + } + + $view = 'eventDashboard'; + + break; + + case 'dashboard': + default: + + // 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.event_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 registration events 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, true); + + // 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 event 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; + } + } + + // Get full list of event names matching the current where clause for text search box + $namesList = $this->getSimpleRegEventsList($where); + + $view = 'eventsDashboard'; break; - } + // If we have a valid account ID, save that for future use + if ($regEventID > 0) { + update_option('glmMembersDatabaseRegistrationsRegEventID', $regEventID); + } // Compile template data $templateData = array( - 'haveEvent' => $haveEvent, - 'eventID' => $eventID, - 'haveRegEvent' => $haveRegEvent, - 'regEventID' => $regEventID, - 'regEvent' => $regEvent, - 'regEventUpdated' => $regEventUpdated, - 'regEventUpdateError' => $regEventUpdateError, - 'regEventAdded' => $regEventAdded , - 'reason' => $reason + 'option' => $option, + 'regEventsCount' => $regEventsCount, + 'haveRegEvents' => $haveRegEvents, + 'regEvents' => $list, + 'alphaList' => $alphaList, + 'alphaSelected' => $alphaSelected, + 'numbDisplayed' => $numbDisplayed, + 'lastDisplayed' => $lastDisplayed, + 'paging' => $paging, + 'prevStart' => $prevStart, + 'nextStart' => $nextStart, + 'start' => $start, + 'limit' => $limit, + 'namesList' => $namesList, + 'textSearch' => $textSearch, + 'regEventID' => $regEventID, + 'regEvent' => $regEvent, + 'haveRegEvent' => $haveRegEvent, + 'haveRegEventRecurrences' => $haveRegEventRecurrences, + 'haveRegEventTimes' => $haveRegEventTimes, + 'regEventFirstTime' => $regEventFirstTime, + 'regEventLastTime' => $regEventLastTime, + '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, + 'view' => 'admin/registrations/'.$view.'.html', 'data' => $templateData ); diff --git a/models/admin/registrations/index.php b/models/admin/registrations/index.php deleted file mode 100644 index 9c43253..0000000 --- a/models/admin/registrations/index.php +++ /dev/null @@ -1,379 +0,0 @@ - - * @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_index 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) - { - - $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; - $namesList = 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.event_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 registration events 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, true); - - // 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 event 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; - } - } - - // Get full list of event names matching the current where clause for text search box - $namesList = $this->getSimpleRegEventsList($where); - - - - $template = 'index.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; - } - - // 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, - 'alphaList' => $alphaList, - 'alphaSelected' => $alphaSelected, - 'numbDisplayed' => $numbDisplayed, - 'lastDisplayed' => $lastDisplayed, - 'paging' => $paging, - 'prevStart' => $prevStart, - 'nextStart' => $nextStart, - 'start' => $start, - 'limit' => $limit, - 'namesList' => $namesList, - 'textSearch' => $textSearch - ); - - // 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 62c2e99..94955d1 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -56,25 +56,15 @@ add_submenu_page( 'Registrations', 'glm_members_members', 'glm-members-admin-menu-registrations-index', - function() {$this->controller('registrations');} + function() {$this->controller('registrations', 'events');} ); -/* -add_submenu_page( - 'glm-members-admin-menu-members', - 'Registration Events Dashboard', - '    Dashboard', - 'glm_members_members', - 'glm-members-admin-menu-registrations-index', - function() {$this->controller('registrations', 'index');} -); -*/ add_submenu_page( 'glm-members-admin-menu-members', 'Selected Event', - '    Selected Event', + '    Events', 'glm_members_members', - 'glm-members-admin-menu-registrations-event', - function() {$this->controller('registrations', 'event');} + 'glm-members-admin-menu-registrations-events', + function() {$this->controller('registrations', 'events');} ); add_submenu_page( diff --git a/setup/validActions.php b/setup/validActions.php index b9d73ff..76b0c10 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -64,7 +64,7 @@ $glmMembersRegistrationsAddOnValidActions = array( ), 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'event' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'events' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'requests' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'accounts' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), diff --git a/views/admin/registrations/accountDashboard.html b/views/admin/registrations/accountDashboard.html index 99303f0..fa8e85b 100644 --- a/views/admin/registrations/accountDashboard.html +++ b/views/admin/registrations/accountDashboard.html @@ -114,7 +114,7 @@ {/if} - + {$reg.event_name} {$reg.event_datetime.datetime} diff --git a/views/admin/registrations/event.html b/views/admin/registrations/event.html deleted file mode 100644 index d653d32..0000000 --- a/views/admin/registrations/event.html +++ /dev/null @@ -1,131 +0,0 @@ -{include file='admin/registrations/header.html'} - -

Selected Event Dashboard

- -
- - {if $reason} -

{$reason}

- {/if} - -

Event

-
-
- -
- {if $haveRegEvent} -

Dates and Availability

- - - - -
-
(calendar loads here)
-
- {else} -

Did not find selected event.

- {/if} - -
- - - - -{include file='admin/footer.html'} - diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html new file mode 100644 index 0000000..b7542b6 --- /dev/null +++ b/views/admin/registrations/eventDashboard.html @@ -0,0 +1,131 @@ +{include file='admin/registrations/eventHeader.html'} + +

Selected Event Dashboard

+ +
+ + {if $reason} +

{$reason}

+ {/if} + +

Event

+
+ {if $haveRegEvent} + +
+
+
+
+
+ {$regEvent.event_name} +
+
+
+
+
+
+

Earliest Event Date:

+
+
+ {$regEventFirstTime.start_time.datetime} +
+
+
+
+
+
+

Latest Event Date:

+
+
+ {$regEventLastTime.start_time.datetime} +
+
+
+
+
+
+
+
+

Event Code:

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

Did not find selected event.

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

Dates and Availability

+ + + + +
+
(calendar loads here)
+
+ {else} +

Did not find selected event.

+ {/if} + +
+ + + + +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/eventEdit.html b/views/admin/registrations/eventEdit.html index 40860fa..a7ae558 100644 --- a/views/admin/registrations/eventEdit.html +++ b/views/admin/registrations/eventEdit.html @@ -1,4 +1,4 @@ -{include file='admin/registrations/header.html'} +{include file='admin/registrations/eventHeader.html'}

Registrations Event Edit @@ -15,8 +15,8 @@ {else}

@@ -32,11 +32,163 @@ NEED TO ADD TESTS FOR CHANGES IN INPUT
- {**** General Settings for Event ****} - {include file='admin/registrations/eventEditSettings.html'} - - {**** Registration Levels and Charges for Event ****} - {include file='admin/registrations/eventEditLevels.html'} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Event Name + + {if $regEvent.fieldFail.event_name}

{$regEvent.fieldFail.event_name}

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

{$regEvent.fieldFail.event_code}

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

{$regEvent.fieldFail.notify_email}

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

{$regEvent.fieldFail.admin_active}

{/if}
+
Date/Time Specific Registrations + + Check this box for events where registrations are for specific dates and times. + {if $regEvent.fieldFail.time_specific}

{$regEvent.fieldFail.time_specific}

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

{$regEvent.fieldFail.active}

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

{$regEvent.fieldFail.attendees}

{/if}
+
Maximum # 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 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 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) + 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 Options + {foreach from=$regEvent.fieldData.registration_account_options.bitmap item=v} + {$v.name}
+ {/foreach} + {if $regEvent.fieldFail.registration_account_options}

{$regEvent.fieldFail.registration_account_options}

{/if}
+
Payment 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}
+ {/foreach} + {if $regEvent.fieldFail.payment_methods}

{$regEvent.fieldFail.payment_methods}

{/if}
+
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.restricted_payment_methods}

{$regEvent.fieldFail.restricted_payment_methods}

{/if}
+
Terms and Conditions for Registration + + {if $regEvent.fieldFail.terms} +

{$regEvent.fieldFail.terms}

+ {/if}
+
File + {if $regEvent.fieldData.reg_file} + Replace this file: + {$regEvent.fieldData.reg_file}    + Delete File
+ {else} + New file: + {/if} +
File Title + + {if $regEvent.fieldFail.reg_file_title}

{$regEvent.fieldFail.reg_file_title}

{/if}
+
Notes + + {if $regEvent.fieldFail.notes} +

{$regEvent.fieldFail.notes}

+ {/if}
+

@@ -47,41 +199,6 @@ NEED TO ADD TESTS FOR CHANGES IN INPUT
- -{/literal} -
- -
-{* Bootstrap the models needed on page load *} -{* Need to have RegEvent model created *} -{* And create the RegClasses collection *} - +{/if} + + + +{include file='admin/footer.html'} diff --git a/views/admin/registrations/eventEditSettings.html b/views/admin/registrations/eventEditSettings.html deleted file mode 100644 index fef7ce4..0000000 --- a/views/admin/registrations/eventEditSettings.html +++ /dev/null @@ -1,160 +0,0 @@ - -{**** General Settings for Event ****} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event Name - - {if $regEvent.fieldFail.event_name}

{$regEvent.fieldFail.event_name}

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

{$regEvent.fieldFail.event_code}

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

{$regEvent.fieldFail.notify_email}

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

{$regEvent.fieldFail.admin_active}

{/if}
-
Date/Time Specific Registrations - - Check this box for events where registrations are for specific dates and times. - {if $regEvent.fieldFail.time_specific}

{$regEvent.fieldFail.time_specific}

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

{$regEvent.fieldFail.active}

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

{$regEvent.fieldFail.attendees}

{/if}
-
Maximum # 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 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 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) - 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 Options - {foreach from=$regEvent.fieldData.registration_account_options.bitmap item=v} - {$v.name}
- {/foreach} - {if $regEvent.fieldFail.registration_account_options}

{$regEvent.fieldFail.registration_account_options}

{/if}
-
Payment 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}
- {/foreach} - {if $regEvent.fieldFail.payment_methods}

{$regEvent.fieldFail.payment_methods}

{/if}
-
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.restricted_payment_methods}

{$regEvent.fieldFail.restricted_payment_methods}

{/if}
-
Terms and Conditions for Registration - - {if $regEvent.fieldFail.terms} -

{$regEvent.fieldFail.terms}

- {/if}
-
File - {if $regEvent.fieldData.reg_file} - Replace this file: - {$regEvent.fieldData.reg_file}    - Delete File
- {else} - New file: - {/if} -
File Title - - {if $regEvent.fieldFail.reg_file_title}

{$regEvent.fieldFail.reg_file_title}

{/if}
-
Notes - - {if $regEvent.fieldFail.notes} -

{$regEvent.fieldFail.notes}

- {/if}
-
diff --git a/views/admin/registrations/eventHeader.html b/views/admin/registrations/eventHeader.html new file mode 100644 index 0000000..064bf70 --- /dev/null +++ b/views/admin/registrations/eventHeader.html @@ -0,0 +1,7 @@ +
+

Event Registrations

+ +
diff --git a/views/admin/registrations/eventsDashboard.html b/views/admin/registrations/eventsDashboard.html new file mode 100644 index 0000000..6832a38 --- /dev/null +++ b/views/admin/registrations/eventsDashboard.html @@ -0,0 +1,148 @@ +{include file='admin/registrations/eventHeader.html'} + +

Registrations Dashboard

+ +
+
+ + + + + + +

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 registration events listed)
+ + {if $paging} + + + {/if} + +
+
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/registrations/header.html b/views/admin/registrations/header.html deleted file mode 100644 index 11f6006..0000000 --- a/views/admin/registrations/header.html +++ /dev/null @@ -1,5 +0,0 @@ -
-

Event Registrations

-
- - diff --git a/views/admin/registrations/index.html b/views/admin/registrations/index.html deleted file mode 100644 index 1b20e26..0000000 --- a/views/admin/registrations/index.html +++ /dev/null @@ -1,148 +0,0 @@ -{include file='admin/registrations/header.html'} - -

Registrations Dashboard

- -
-
- - - - - - -

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 registration events listed)
- - {if $paging} - - - {/if} - -
-
- - - -{include file='admin/footer.html'}