From 7a36c694f6d4e104cf93083ebfcef802104b5046 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 15 Nov 2017 11:41:30 -0500 Subject: [PATCH] Fix for setting first date in calendars. 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 | 12 ++---------- js/models/front/regClass.js | 1 + js/views/front/regClass.js | 11 +---------- models/admin/ajax/regFront/registrant.php | 2 ++ models/front/registrations/registration.php | 7 +++++++ views/front/registrations/registration.html | 15 ++++++--------- 6 files changed, 19 insertions(+), 29 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index bd44294..3e734da 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -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 = []; diff --git a/js/models/front/regClass.js b/js/models/front/regClass.js index b0e0bef..b8e0fd8 100644 --- a/js/models/front/regClass.js +++ b/js/models/front/regClass.js @@ -17,6 +17,7 @@ app.Models.Front.RegClass = Backbone.Model.extend({ reg_count: 0, loggedIn: false, selectedTime: 0, + startingTime: '', }, initialize: function(){ diff --git a/js/views/front/regClass.js b/js/views/front/regClass.js index d675a4c..6fdbcb1 100644 --- a/js/views/front/regClass.js +++ b/js/views/front/regClass.js @@ -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 = []; diff --git a/models/admin/ajax/regFront/registrant.php b/models/admin/ajax/regFront/registrant.php index 8e598ff..408b13d 100644 --- a/models/admin/ajax/regFront/registrant.php +++ b/models/admin/ajax/regFront/registrant.php @@ -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(); diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index 7d2e1d1..eba74a6 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -196,10 +196,15 @@ // 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 '
$rClass: ' . print_r( $rClass, true ) . '
'; // Pull the rate data if ( isset( $rClass['times'] ) && is_array( $rClass['times'] ) && count( $rClass['times'] ) > 0 ) { // echo '
$rClass[times]: ' . print_r( $rClass['times'], true ) . '
'; 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']; @@ -214,6 +219,7 @@ $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] ); @@ -308,6 +314,7 @@ } // Setup the registrant for this level. + $registrant['name'] = $accountData['fname'] . ' ' . $accountData['lname']; $registrant['class_id'] = $classId; $registrant['reg_class'] = $classId; $registrant['email'] = $email; diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index dca1bf5..056b2b0 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -44,17 +44,17 @@ {* Template for regClass *}{literal}