Now have events.php generating JSONs for backbone that do not use associative arrays...
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 14 Sep 2017 20:02:57 +0000 (16:02 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 14 Sep 2017 20:02:57 +0000 (16:02 -0400)
classes/data/dataRegEvent.php
data/event_setup.php
js/models/admin/regClass.js
models/admin/registrations/events.php
views/admin/registrations/eventEdit.html
views/admin/registrations/eventEditLevels.html
views/admin/registrations/eventsDashboard.html

index db6865a..77cf050 100644 (file)
@@ -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;
             }
index 7321015..f291701 100644 (file)
@@ -166,3 +166,266 @@ $regEventSample = array(
 
 //echo "<pre>".print_r($regEventSample,1)."</pre>";
 
+/*  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
+                                )
+
+                        )
+
+                )
+
+        )
+
+)
+
+*/
index 1ba7314..b4685f5 100644 (file)
@@ -6,7 +6,7 @@ app.Models.Admin.RegClass = Backbone.Model.extend({
     // Defaults
     defaults: {
         id: null,
-        parent: 0,
+//        parent: 0,
         reg_event: 0,
         name: '',
         descr: '',
index f128148..b9cd4cf 100644 (file)
@@ -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
index af9f5af..73c6fef 100644 (file)
@@ -35,10 +35,9 @@ NEED TO ADD TESTS FOR CHANGES IN INPUT<br>
         <table id="glm-table-settings" class="glm-registrations-table">
     
             <tr>
-                <th {if $regEvent.fieldRequired.event_name}class="glm-required-nowrap-left-align"{else}class="glm-nowrap-left-align"{/if}>Event Name</th>
-                <td {if $regEvent.fieldFail.event_name}class="glm-form-bad-input" data-tabid="glm-event_name"{/if}>
-                    <input type="text" name="event_name" value="{$regEvent.fieldData.event_name}" class="glm-form-text-input-medium">
-                {if $regEvent.fieldFail.event_name}<p>{$regEvent.fieldFail.event_name}</p>{/if}<br>
+                <th class="glm-nowrap-left-align">Event Name</th>
+                <td>
+                    {$regEvent.fieldData.event_name}
                 </td>
             </tr>
             <tr>
index 2c58c4d..8623861 100644 (file)
         <script type="text/template" id="regEvent-template">
             <div style="margin-bottom: 1em;">
                 <a id="add-reg-level" class="button button-secondary glm-button glm-right">Add a Registration Level</a>
-                <h3>Registration Levels</h3>
-            </div>
-        </script>
-    
-        <script type="text/template" id="account-template">
-            <a class="glm-reg-level-registrant-delete">Delete</a>
-            <label class="registrant-label">
-                <span class="glm-reg-level-registrant-email"><%= email %></span>
-            </label>
-            <div class="registrant-edit">
-                <input type="text" class="editEmail" value="<%- email %>">
-                <input type="submit" class="saveRegistrant" value="Save">
+                <h3>Event: <%= event_name %></h3>
+                <p><%= descr %></p>
             </div>
         </script>
     
                 <input class="class-descr" type="text" name="reg_descr_<% if (id) { %><%- id %><% } else { %> new <% } %>" size="90" value="<% if (descr) { %><%- descr %><% } %>">
             </div>
         </script>
-    
-        <script type="text/template" id="eventReg-account-login">
-            <h4>Login</h4>
-            <a class="glm-reg-account-login" id="loginCancel">Close</a>
-            <input class="login">
-            <input class="password">
-            <input type="submit" class="accountLogin" value="Login">
+
+        <script type="text/template" id="regRate-template">
+            <div>Registration Rate Template</div>
         </script>
-    
+
     {/literal}
-    
+
     <div class="glm-reg-event-list" id="regApp">
     </div>
     
     {* And create the RegClasses collection *}
     <script>
         //var $=jQuery.noConflict();
-        var appLoginUrl = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=login';
         var ajaxUrl = '{$ajaxUrl}?action=glm_members_admin_ajax';
         var app = {
-            Models: { Front: {}, Admin: {} },
-            Collections: { Front: {}, Admin: {} },
-            Views: { Front: {}, Admin: {} },
+            Models: { Admin: {} },
+            Collections: { Admin: {} },
+            Views: { Admin: {} },
         };
         var regEvent = '';
         jQuery(function($){
-            regEvent = new app.Models.Admin.RegEvent;
-            regEvent.set( {$regEventJSON} );
-            regEvent.setClasses( {$regClassJSON} );
+               regEvent = new app.Models.Admin.RegEvent;
+            regEvent.setClasses({$regClassesJSON});
+//            regEvent.setTimes({$regTimesJSON});
+            regEvent.set( {$regEventJSON} );   
             new app.Views.Admin.EventEditLevels();
         });
     </script>
index 3fd9a90..9156b7f 100644 (file)
@@ -53,7 +53,7 @@
             <tr class="alternate">
         {/if}
                 <td style="width: 50px;">
-                    {$r.id}
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-events&option=eventDashboard&regEventID={$r.id}">{$r.id}</a>
                 </td>
                 <td>
                     <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-events&option=eventDashboard&regEventID={$r.id}">{$r.event_name}</a>