Fix issue with adding class and the times without reg_event
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 15 Nov 2017 13:41:47 +0000 (08:41 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 15 Nov 2017 13:41:59 +0000 (08:41 -0500)
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
js/models/front/regEvent.js
js/views/front/regClass.js
models/front/registrations/registration.php

index ce952e8..bd44294 100644 (file)
@@ -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 );
             }
         }
index 20da9da..11e6c3d 100644 (file)
@@ -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);
index 3450a0f..d675a4c 100644 (file)
@@ -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 );
             }
         }
index 97278f2..7d2e1d1 100644 (file)
             $regEvent = $this->getEventForRegistration($eventRegID);
 
             // echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
+            $regEventId = $regEvent['id'];
 
             // Create an $event array with the event data.
             $event = array(
                     // echo '<pre>$rClass[times]: ' . print_r( $rClass['times'], true ) . '</pre>';
                     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'];