Pull in time text for selected reg_time on registrant edit.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Oct 2017 20:44:50 +0000 (16:44 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Oct 2017 20:44:50 +0000 (16:44 -0400)
Pull in the time text for the selected reg_time when editing registrant.
Trying to get the calendar also to show the selected time but not
finding a way to do this.

js/frontRegApp.js
js/views/front/regRequestRegistrant.js
models/front/registrations/registration.php
views/front/registrations/registration.html

index 8f1ce1e..2c2a11a 100644 (file)
@@ -978,7 +978,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
     editRegistrant: function(){
         this.$('.reg-edit-form').show();
         if ( app.timeSpecific === true ) {
+            this.$('#reg-select-time').val( this.model.get( 'reg_time' ) );
             app.initFullCalendar();
+            console.log( this.model.get( 'reg_time' ) );
         }
     },
 
index 4276501..b0fa90e 100644 (file)
@@ -48,7 +48,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
     editRegistrant: function(){
         this.$('.reg-edit-form').show();
         if ( app.timeSpecific === true ) {
+            this.$('#reg-select-time').val( this.model.get( 'reg_time' ) );
             app.initFullCalendar();
+            console.log( this.model.get( 'reg_time' ) );
         }
     },
 
index 1d747d2..76e6fe7 100644 (file)
                                                 $registrant['account']
                                             )
                                         );
+                                        $this->wpdb->show_errors();
+                                        if ( $registrant['reg_time'] && filter_var( $registrant['reg_time'], FILTER_VALIDATE_INT ) ) {
+                                            $regTimeText = $this->wpdb->get_var(
+                                                $this->wpdb->prepare(
+                                                    "SELECT DATE_FORMAT( start_datetime, '%%m/%%d/%%Y %%l:%%i %%p' )
+                                                       FROM " .  GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_time
+                                                      WHERE id = %d",
+                                                    $registrant['reg_time']
+                                                )
+                                            );
+                                            var_dump( $regTimeText );
+                                            $registrant['reg_time_text'] = $regTimeText;
+                                        }
+                                        $this->wpdb->print_error();
                                         $registrant['class_id']  = $classId;
                                         $registrant['email']     = $email;
                                         $registrant['validated'] = $accountData['validated'];
                                         $registrant['state']     = $accountData['state'];
                                         $registrant['zip']       = $accountData['zip'];
                                         $registrant['country']   = $accountData['country'];
+                                        echo '<pre>$registrant: ' . print_r( $registrant, true ) . '</pre>';
                                         $registrants[]           = $registrant;
                                     }
                                 }
index 3dfbe00..c007a3c 100644 (file)
             </div>
             {/literal}{if $regEvent.time_specific.value}
                 <div>
-                    Selected Time: <span id="reg-select-time-display"></span>
+                    Selected Time: <span id="reg-select-time-display">{literal}<%= reg_time_text %>{/literal}</span>
                     <input type="hidden" id="reg-select-time">
                 </div>
             {/if}{literal}
@@ -241,7 +241,7 @@ var app = {
     {if $regEvent.time_specific.value}
     initFullCalendar: function(){
         if ({$regEvent.time_specific.value}) {
-            $('#eventCalendar').fullCalendar({
+            app.FullCalendar = $('#eventCalendar').fullCalendar({
                 {if $regEvent}
                     events: [
                         {$sep = ''}
@@ -254,7 +254,7 @@ var app = {
                               {/if}
                                 start : '{$t.start_datetime.datetime}',
                                 end   : '{$t.end_datetime.datetime}',
-                                    allday : {if $t.all_day.value}true{else}false{/if},
+                                allday : {if $t.all_day.value}true{else}false{/if},
                                 reg_time: {$t.id}
                             }
                             {$sep = ','}
@@ -264,8 +264,10 @@ var app = {
                     timeFormat  : 'h:mma',
                     fixedWeekCount : false,
                     eventClick: function(calEvent, jsEvent, view) {
+                        $('.fc-event').css('background-color', '#3a67ad');
                         jQuery('#reg-select-time').val( calEvent.reg_time );
                         jQuery('#reg-select-time-display').html( calEvent.start.format('L LT') );
+                        $(this).css('background-color', 'red');
                     }
                 {/if}
             });