From 3ec7b0a99b3f7a6f04b472bfae517fe64938a8a9 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 14 Sep 2017 16:02:57 -0400 Subject: [PATCH] Now have events.php generating JSONs for backbone that do not use associative arrays for the time, classe, and reg_rate arrays. --- classes/data/dataRegEvent.php | 6 +- data/event_setup.php | 263 ++++++++++++++++++ js/models/admin/regClass.js | 2 +- models/admin/registrations/events.php | 57 ++-- views/admin/registrations/eventEdit.html | 7 +- .../admin/registrations/eventEditLevels.html | 42 +-- .../admin/registrations/eventsDashboard.html | 2 +- 7 files changed, 312 insertions(+), 67 deletions(-) diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index db6865a..77cf050 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -136,8 +136,8 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract 'event_name' => array ( 'field' => 'event_name', 'type' => 'text', - 'required' => true, - 'use' => 'a' + 'required' => false, + 'use' => 'lgned' ), // A short code used to reference this event @@ -465,7 +465,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract // Try to get the base information - and extended data from the Event add-on if requested if ($id > 0) { - $eventData = $this->getEntry($id, 'id', $forEdit); + $eventData = $this->getEntry($id, 'id', ' TRUE ', $forEdit); if (!$eventData) { return false; } diff --git a/data/event_setup.php b/data/event_setup.php index 7321015..f291701 100644 --- a/data/event_setup.php +++ b/data/event_setup.php @@ -166,3 +166,266 @@ $regEventSample = array( //echo "
".print_r($regEventSample,1)."
"; +/* Sample actual data for reference for a complete event (this one doesn't include classes and times yet) + +Array +( + [id] => 61 + [event] => 2 + [event_name] => Active Time + [event_code] => active-time + [notify_email] => cscott@gaslightmedia.com + [admin_active] => Array + ( + [list] => + [value] => 0 + [name] => No + ) + + [active] => Array + ( + [list] => + [value] => 1 + [name] => Yes + ) + + [time_specific] => Array + ( + [list] => + [value] => 0 + [name] => No + ) + + [attendees] => Array + ( + [list] => + [value] => 0 + [name] => No + ) + + [attendee_max] => 0 + [attendee_max_per_reg] => 0 + [reg_hold_minutes] => 60 + [cart_hold_days] => 10 + [registration_account_options] => Array + ( + [bitmap] => Array + ( + [1] => Array + ( + [name] => Guest Registration + [nameEsc] => Guest Registration + [value] => 1 + [default] => 1 + ) + + [2] => Array + ( + [name] => Saved Registration Accounts + [nameEsc] => Saved Registration Accounts + [value] => 2 + [default] => 1 + ) + + [3] => Array + ( + [name] => Member Contact Registrations + [nameEsc] => Member Contact Registrations + [value] => 3 + [default] => 1 + ) + + ) + + [value] => 14 + [names] => Array + ( + [1] => Guest Registration + [2] => Saved Registration Accounts + [3] => Member Contact Registrations + ) + + ) + + [payment_methods] => Array + ( + [bitmap] => Array + ( + [1] => Array + ( + [name] => No Charge + [nameEsc] => No Charge + [value] => 1 + [default] => + ) + + [2] => Array + ( + [name] => Comp Code + [nameEsc] => Comp Code + [value] => 2 + [default] => 1 + ) + + [3] => Array + ( + [name] => Cash + [nameEsc] => Cash + [value] => 3 + [default] => + ) + + [4] => Array + ( + [name] => Check + [nameEsc] => Check + [value] => 4 + [default] => + ) + + [5] => Array + ( + [name] => Credit Card + [nameEsc] => Credit Card + [value] => 5 + [default] => 1 + ) + + [6] => Array + ( + [name] => Call from Merchant + [nameEsc] => Call from Merchant + [value] => 6 + [default] => + ) + + [99] => Array + ( + [name] => Undefined + [nameEsc] => Undefined + [value] => 99 + [default] => + ) + + ) + + [value] => 36 + [names] => Array + ( + [2] => Comp Code + [5] => Credit Card + ) + + ) + + [restricted_payment_methods] => Array + ( + [bitmap] => Array + ( + [1] => Array + ( + [name] => No Charge + [nameEsc] => No Charge + [value] => 1 + [default] => 1 + ) + + [2] => Array + ( + [name] => Comp Code + [nameEsc] => Comp Code + [value] => 2 + [default] => + ) + + [3] => Array + ( + [name] => Cash + [nameEsc] => Cash + [value] => 3 + [default] => 1 + ) + + [4] => Array + ( + [name] => Check + [nameEsc] => Check + [value] => 4 + [default] => 1 + ) + + [5] => Array + ( + [name] => Credit Card + [nameEsc] => Credit Card + [value] => 5 + [default] => + ) + + [6] => Array + ( + [name] => Call from Merchant + [nameEsc] => Call from Merchant + [value] => 6 + [default] => + ) + + [99] => Array + ( + [name] => Undefined + [nameEsc] => Undefined + [value] => 99 + [default] => + ) + + ) + + [value] => 26 + [names] => Array + ( + [1] => No Charge + [3] => Cash + [4] => Check + ) + + ) + + [descr] => This is a description of registrations for this event. This is not the same as the event description that is stored in the Events add-on. This one is specific to registrations for this event. + [terms] => asdasdasdasd + [reg_file] => + [reg_file_title] => asdasdasd + [form_revision] => 0 + [notes] => asdasdaaddadadad + [reg_time] => + [reg_class] => Array + ( + [22] => Array + ( + [id] => 22 + [reg_event] => 61 + [name] => Admiral Class + [descr] => This is our Admiral Class registration level. + [reg_rate] => Array + ( + [17] => Array + ( + [id] => 17 + [reg_event] => 61 + [reg_class] => 22 + [name] => Rate Name + [start_days] => 100 + [end_days] => 50 + [base_rate] => $20.00 + [per_registrant] => $10.00 + [registrant_credits] => 1 + ) + + ) + + ) + + ) + +) + +*/ diff --git a/js/models/admin/regClass.js b/js/models/admin/regClass.js index 1ba7314..b4685f5 100644 --- a/js/models/admin/regClass.js +++ b/js/models/admin/regClass.js @@ -6,7 +6,7 @@ app.Models.Admin.RegClass = Backbone.Model.extend({ // Defaults defaults: { id: null, - parent: 0, +// parent: 0, reg_event: 0, name: '', descr: '', diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index f128148..b9cd4cf 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -111,9 +111,10 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $regEventAdded = false; $reason = false; $regEventSample = false; - $regEventJason = false; - $regClassJSON = false; - + $regEventJSON = false; + $regClassesJSON = false; + $regTimesJSON = false; + // Get any provided option if (isset($_REQUEST['option'])) { $option = $_REQUEST['option']; @@ -136,13 +137,10 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $regEventID = false; } - - switch ($option) { case 'configureEvent': -// This obviously still needs work - not really updated since stolen from front-end code $scripts = array( 'backbone-local' => 'js/lib/backbone.localStorage.min.js', 'regApp' => 'js/adminRegApp.js', @@ -160,26 +158,25 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent wp_enqueue_script( array_keys( $scripts ) ); $regEvent = array(); - // including test data for now - include GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/data/event_setup.php'; - - $regClass = $regEventSample['reg_class']; - - // Find the regClass rate to be used - // There will only be one as this is based on the date. - //$regClassRate + // Get all current registration event data + $regEvent = $this->getEventConfig($regEventID, false, false, true); - $eventData = array(); - - unset($regClass['reg_rate']); - - // Build the Class array of json objects for the classes. - $jsonClasses = array(); - foreach ( $regClass as $rClass ) { - $jsonClasses[] = json_encode( $rClass ); + // Make all arrays of arrays non-associative to make Backbone happy + foreach ($regEvent['reg_class'] as $k=>$v) { + $regEvent['reg_class'][$k]['reg_rate'] = array_values($regEvent['reg_class'][$k]['reg_rate']); } - $regClassJSON = '[' . implode( ',', $jsonClasses ) . ']'; - + $regEvent['reg_class'] = array_values($regEvent['reg_class']); + $regEvent['reg_time'] = array_values($regEvent['reg_time']); + + // Separate Event, Classes, and Times and send those as separate JSONs + $regClassesJSON = json_encode($regEvent['reg_class']); + $regTimesJSON = json_encode($regEvent['reg_time']); + + // Get rid of class and time arrays so we just have the event data + unset($regEvent['reg_class']); + unset($regEvent['reg_time']); + $regEventJSON = json_encode($regEvent); + $view = 'eventEditLevels'; break; @@ -297,7 +294,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent // Try to get the event configuration including recurrences and times $this->postProcAddedEventData = true; - $regEvent = $this->getEventConfig($regEventID, true, true, true); + $regEvent = $this->getEventConfig($regEventID, true, false, true); // If we have the event data if ($regEvent) { @@ -513,11 +510,11 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'regEventAdded' => $regEventAdded, 'reason' => $reason, - 'entry' => $regEventSample, - 'thisJsUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js', - 'regEventJSON' => json_encode( $regEventSample['reg_event'] ), - 'regClassJSON' => $regClassJSON, - + 'entry' => $regEventSample, + 'thisJsUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js', + 'regEventJSON' => $regEventJSON, + 'regClassesJSON' => $regClassesJSON, + 'regTimesJSON' => $regTimesJSON ); // Return status, any suggested view, and any data to controller diff --git a/views/admin/registrations/eventEdit.html b/views/admin/registrations/eventEdit.html index af9f5af..73c6fef 100644 --- a/views/admin/registrations/eventEdit.html +++ b/views/admin/registrations/eventEdit.html @@ -35,10 +35,9 @@ NEED TO ADD TESTS FOR CHANGES IN INPUT
- - + diff --git a/views/admin/registrations/eventEditLevels.html b/views/admin/registrations/eventEditLevels.html index 2c58c4d..8623861 100644 --- a/views/admin/registrations/eventEditLevels.html +++ b/views/admin/registrations/eventEditLevels.html @@ -30,18 +30,8 @@ - - @@ -62,17 +52,13 @@ - - - + {/literal} - +
@@ -81,18 +67,18 @@ {* And create the RegClasses collection *} diff --git a/views/admin/registrations/eventsDashboard.html b/views/admin/registrations/eventsDashboard.html index 3fd9a90..9156b7f 100644 --- a/views/admin/registrations/eventsDashboard.html +++ b/views/admin/registrations/eventsDashboard.html @@ -53,7 +53,7 @@ {/if}
Event Name - - {if $regEvent.fieldFail.event_name}

{$regEvent.fieldFail.event_name}

{/if}
+
Event Name + {$regEvent.fieldData.event_name}
- {$r.id} + {$r.id} {$r.event_name} -- 2.17.1