From c1890dd5e1cede9d92a056890258f4b0223f9eac Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 15 Nov 2017 08:41:47 -0500 Subject: [PATCH] Fix issue with adding class and the times without reg_event Reg_event wasn't being brought back when using the dataAbstract and getting the regEvent. So in js when setting the times to add in registrant I'm resetting the reg_event in the times to be sure it is correct. --- js/frontRegApp.js | 10 +++++----- js/models/front/regEvent.js | 8 ++++---- js/views/front/regClass.js | 2 +- models/front/registrations/registration.php | 2 ++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index ce952e8..bd44294 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -146,12 +146,12 @@ app.Models.Front.RegEvent = Backbone.Model.extend({ // console.log(foundClass); if ( foundClass != undefined ) { // Try looking through the class times - // console.log(foundClass); // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time}); var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time }); - // console.log(foundRegTime); - // return; - // var foundRegTime = _.findWhere(app.Times, { id: registrants[i].reg_time }); + if ( foundRegTime ) { + foundRegTime.reg_event = foundClass.get('reg_event'); + console.log(foundRegTime); + } // Now add the time if needed var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id }); // console.log(hasRegTime); @@ -502,7 +502,7 @@ app.Views.Front.RegClass = Backbone.View.extend({ } if ( targetTime ) { var selectedTime = new app.Models.Front.RegTime( targetTime ); - selectedTime.set({parent: this.model}); + selectedTime.set({reg_event: this.model.get('reg_event'), parent: this.model}); this.model.regTimes.create( selectedTime ); } } diff --git a/js/models/front/regEvent.js b/js/models/front/regEvent.js index 20da9da..11e6c3d 100644 --- a/js/models/front/regEvent.js +++ b/js/models/front/regEvent.js @@ -33,12 +33,12 @@ app.Models.Front.RegEvent = Backbone.Model.extend({ // console.log(foundClass); if ( foundClass != undefined ) { // Try looking through the class times - // console.log(foundClass); // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time}); var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time }); - // console.log(foundRegTime); - // return; - // var foundRegTime = _.findWhere(app.Times, { id: registrants[i].reg_time }); + if ( foundRegTime ) { + foundRegTime.reg_event = foundClass.get('reg_event'); + console.log(foundRegTime); + } // Now add the time if needed var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id }); // console.log(hasRegTime); diff --git a/js/views/front/regClass.js b/js/views/front/regClass.js index 3450a0f..d675a4c 100644 --- a/js/views/front/regClass.js +++ b/js/views/front/regClass.js @@ -46,7 +46,7 @@ app.Views.Front.RegClass = Backbone.View.extend({ } if ( targetTime ) { var selectedTime = new app.Models.Front.RegTime( targetTime ); - selectedTime.set({parent: this.model}); + selectedTime.set({reg_event: this.model.get('reg_event'), parent: this.model}); this.model.regTimes.create( selectedTime ); } } diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index 97278f2..7d2e1d1 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -160,6 +160,7 @@ $regEvent = $this->getEventForRegistration($eventRegID); // echo '
$regEvent: ' . print_r( $regEvent, true ) . '
'; + $regEventId = $regEvent['id']; // Create an $event array with the event data. $event = array( @@ -200,6 +201,7 @@ // echo '
$rClass[times]: ' . print_r( $rClass['times'], true ) . '
'; foreach ( $rClass['times'] as &$time ) { $rClass['loggedIn'] = ( isset($_SESSION['LoginAccount']) ) ? true : false; + $rClass['reg_event'] = $regEventId; $rClass['reg_rate_id'] = $time['id']; $rClass['reg_rate_name'] = $time['name']; $rClass['reg_rate_base_price'] = $time['base_rate']; -- 2.17.1