Fix for setting first date in calendars.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 15 Nov 2017 16:41:30 +0000 (11:41 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 15 Nov 2017 16:41:30 +0000 (11:41 -0500)
I'm adding a field for startingTime in the class so I can set the class
up correctly with the starting time for the event reg page.

js/frontRegApp.js
js/models/front/regClass.js
js/views/front/regClass.js
models/admin/ajax/regFront/registrant.php
models/front/registrations/registration.php
views/front/registrations/registration.html

index bd44294..3e734da 100644 (file)
@@ -102,6 +102,7 @@ app.Models.Front.RegClass = Backbone.Model.extend({
         reg_count: 0,
         loggedIn: false,
         selectedTime: 0,
+        startingTime: '',
     },
 
     initialize: function(){
@@ -520,19 +521,9 @@ app.Views.Front.RegClass = Backbone.View.extend({
         var timeContainer = this.$('.reg-class-times');
         timeContainer.append( view );
 
-        // Need to see if this class has attendees and render them
-        // var view = this.model.registrants.map(function(item){
-        //     return (new app.Views.Front.RegRequestRegistrant({ model: item })).render().el;
-        // });
-        // var accountContainer = this.$('.reg-class-accounts');
-        // accountContainer.append(view);
-
         if ( loginAccount === '' ) {
             this.$('.glm-add-account').hide();
         }
-        // if ( loginAccount != '' && this.model.hasMe() ) {
-        //     this.$('.glm-add-account').hide();
-        // }
         if ( !app.timeSpecific ) {
             console.log('Should be showing the add attendee part now');
             // this.$('.glm-add-new-account').show();
@@ -580,6 +571,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
 
     setCalendar: function(){
         var times = this.model.get( 'times' );
+        var startTime = this.model.get('startingTime');
         $('#eventCalendar-' + this.model.get('id')).fullCalendar({
             events: function(start, end, timezone, callback) {
                 var events = [];
index b0e0bef..b8e0fd8 100644 (file)
@@ -17,6 +17,7 @@ app.Models.Front.RegClass = Backbone.Model.extend({
         reg_count: 0,
         loggedIn: false,
         selectedTime: 0,
+        startingTime: '',
     },
 
     initialize: function(){
index d675a4c..6fdbcb1 100644 (file)
@@ -64,19 +64,9 @@ app.Views.Front.RegClass = Backbone.View.extend({
         var timeContainer = this.$('.reg-class-times');
         timeContainer.append( view );
 
-        // Need to see if this class has attendees and render them
-        // var view = this.model.registrants.map(function(item){
-        //     return (new app.Views.Front.RegRequestRegistrant({ model: item })).render().el;
-        // });
-        // var accountContainer = this.$('.reg-class-accounts');
-        // accountContainer.append(view);
-
         if ( loginAccount === '' ) {
             this.$('.glm-add-account').hide();
         }
-        // if ( loginAccount != '' && this.model.hasMe() ) {
-        //     this.$('.glm-add-account').hide();
-        // }
         if ( !app.timeSpecific ) {
             console.log('Should be showing the add attendee part now');
             // this.$('.glm-add-new-account').show();
@@ -124,6 +114,7 @@ app.Views.Front.RegClass = Backbone.View.extend({
 
     setCalendar: function(){
         var times = this.model.get( 'times' );
+        var startTime = this.model.get('startingTime');
         $('#eventCalendar-' + this.model.get('id')).fullCalendar({
             events: function(start, end, timezone, callback) {
                 var events = [];
index 8e598ff..408b13d 100644 (file)
@@ -97,6 +97,7 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations
 
             // Call to add registrant
             $registrant = $this->addUpdateRegistrantToCart( $modelData, 'add' );
+            $registrant['name'] = $registrant['fname'] . ' ' . $registrant['lname'];
 
             echo json_encode( $registrant, JSON_NUMERIC_CHECK );
             wp_die();
@@ -108,6 +109,7 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations
         case 'update':
 
             $registrant = $this->addUpdateRegistrantToCart( $modelData, 'update' );
+            $registrant['name'] = $registrant['fname'] . ' ' . $registrant['lname'];
 
             echo json_encode( $registrant, JSON_NUMERIC_CHECK );
             wp_die();
index 7d2e1d1..eba74a6 100644 (file)
             // times array. If it doesn't then there's no current registration
             // allowed for that event.
             foreach ( $regEvent['reg_class'] as $key => $rClass ) {
+                $classStartingTime = '';
+                // echo '<pre>$rClass: ' . print_r( $rClass, true ) . '</pre>';
                 // Pull the rate data
                 if ( isset( $rClass['times'] ) && is_array( $rClass['times'] ) && count( $rClass['times'] ) > 0 ) {
                     // echo '<pre>$rClass[times]: ' . print_r( $rClass['times'], true ) . '</pre>';
                     foreach ( $rClass['times'] as &$time ) {
+                        if ( $classStartingTime == '' || $time['start_datetime']['timestamp'] < $classStartingTime['start_datetime']['timestamp'] ) {
+                            $classStartingTime = $time;
+                        }
                         $rClass['loggedIn']            = ( isset($_SESSION['LoginAccount']) ) ? true : false;
                         $rClass['reg_event']           = $regEventId;
                         $rClass['reg_rate_id']         = $time['id'];
                             $regTimes[] = json_encode( $time, JSON_NUMERIC_CHECK );
                         }
                     }
+                    $rClass['startingTime'] = $classStartingTime['start_datetime']['datetime'];
                     $jsonClasses[] = json_encode( $rClass, JSON_NUMERIC_CHECK );
                 } else if ( !isset( $rClass['times'] ) || empty( $rClass['times'] ) ) {
                     unset( $regEvent['reg_class'][$key] );
                                         }
 
                                         // Setup the registrant for this level.
+                                        $registrant['name']        = $accountData['fname'] . ' ' .  $accountData['lname'];
                                         $registrant['class_id']    = $classId;
                                         $registrant['reg_class']   = $classId;
                                         $registrant['email']       = $email;
index dca1bf5..056b2b0 100644 (file)
 {* Template for regClass *}{literal}
 <script type="text/template" id="regClass-template">
     <div class="glm-row">
-        <div class="glm-columns glm-small-12">
+        <div class="glm-columns glm-small-12 glm-large-6">
             <div class="glm-row">
                 <span class="glm-reg-level-title"><%= name %></span>
                 <div class="glm-columns glm-small-12">
                     <%- descr %>
                 </div>
-                <div class="glm-columns glm-small-12 glm-large-12"> <%= reg_rate_name  %> </div>
-                <div class="glm-columns glm-small-12 glm-large-12"> Base Rate: $<%= reg_rate_base_price %> </div>
-                <div class="glm-columns glm-small-12 glm-large-12"> Per Registrant: $<%= reg_rate_per_reg %> </div>
-                <div class="glm-columns glm-small-12 glm-large-12"> Registrant Credits: <%= registrant_credits %> </div>
-                <div class="glm-columns glm-small-12 glm-large-12 glm-hidden">
+                <div class="glm-columns glm-small-12"> <%= reg_rate_name  %> </div>
+                <div class="glm-columns glm-small-12"> Base Rate: $<%= reg_rate_base_price %> </div>
+                <div class="glm-columns glm-small-12"> Per Registrant: $<%= reg_rate_per_reg %> </div>
+                <div class="glm-columns glm-small-12"> Registrant Credits: <%= registrant_credits %> </div>
+                <div class="glm-columns glm-small-12 glm-hidden">
                     <% if ( app.timeSpecific ) { %>
                         <input class="timeSelection" type="hidden" name="timeOption">
                     <% } else { %>
@@ -64,8 +64,6 @@
                     <% } %>
                 </div>
             </div>
-        </div>
-        <div class="glm-columns glm-small-12 glm-large-6">
             <div class="reg-class-detail">
                 &nbsp;
                 <div class="reg-class-times"> </div>
@@ -251,7 +249,6 @@ var app = {
 var regEvent = '';
 var cart = '';
 var loginAccount = '';
-var startTime = '{$regEvent.firstTime.start_time.datetime}';
 jQuery(function($){
     {if $isNewCart}
         location.reload( true );