Working on getting the data entered into the date fields to stay. feature/saveAddSchedule
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 15 Feb 2018 21:58:33 +0000 (16:58 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 15 Feb 2018 21:58:33 +0000 (16:58 -0500)
When you have a required field not filled out it is loosing the date
data that was entered. I have the time and date now saving. Need to
work on getting the checkboxes and recurring data to save.

classes/data/dataRecurrences.php
models/admin/events/list.php
views/admin/events/editSchedule.html

index 89e20c9..a4694a8 100644 (file)
@@ -159,7 +159,7 @@ class GlmDataEventsRecurrences extends GlmDataAbstract
             'start_time_only' => array (
                 'field' => 'start_time_only',
                 'type' => 'checkbox',
-                'default' => true,
+                'default' => false,
                 'use' => 'a'
             ),
 
index 01f0ae8..4092a10 100644 (file)
@@ -255,23 +255,25 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
             $view = 'edit';
 
+        // echo '<pre>$newRecurrence: ' . print_r( $newRecurrence, true ) . '</pre>';
             break;
 
         case 'insert':
 
             $event = $this->insertEntry();
+            if ($event['status']) {
+                // echo '<pre>$event: ' . print_r( $event, true ) . '</pre>';
 
-            $this->eventID = $event['fieldData']['id'];
+                $this->eventID = $event['fieldData']['id'];
 
-            $this->updateCategories();
-            $categories = $Categories->getListSortedParentChild(false);
+                $this->updateCategories();
+                $categories = $Categories->getListSortedParentChild(false);
 
-            if ( $this->config['settings']['use_event_amenities'] ) {
-                $this->updateAmenities();
-                $amenities = $Amenities->getList(false);
-            }
+                if ( $this->config['settings']['use_event_amenities'] ) {
+                    $this->updateAmenities();
+                    $amenities = $Amenities->getList(false);
+                }
 
-            if ($event['status']) {
                 $haveEvent = true;
                 $eventAdded = true;
 
@@ -369,15 +371,56 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                 glmClearShortcodeCache();
 
             } else {
+                // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+                // echo '<pre>$event: ' . print_r( $event, true ) . '</pre>';
+                // echo '<pre>$newRecurrence: ' . print_r( $newRecurrence, true ) . '</pre>';
                 $option = 'add';
                 $eventAddError = true;
 
                 // Add any recurrence data that may have been submitted
-                //                    if (isset($_REQUEST[''])) {
-                //                          NOT COMPLETED
-                //                    }
+                $newRecurSetup = array(
+                    'name',
+                    'start_time',
+                    'end_time',
+                    'from_date',
+                    'to_date',
+                    'month_of_year',
+                    'week_of_month',
+                    'day_of_week',
+                    'all_day',
+                    'start_time_only',
+                );
+
+                if ( isset( $_REQUEST['recurID'] ) ) {
+                    foreach ( $_REQUEST['recurID'] as $recur ) {
+                        foreach ( $newRecurSetup as $rec ) {
+                            $rec_name = $recur . '_' . $rec;
+                            if ( $_REQUEST[$rec_name] ) {
+                                switch ( $rec ) {
+                                case 'start_time':
+                                case 'end_time':
+                                    $newRecurrence['fieldData'][$rec]['time'] = $_REQUEST[$rec_name];
+                                    break;
+                                case 'from_date':
+                                case 'to_date':
+                                    $newRecurrence['fieldData'][$rec]['date'] = $_REQUEST[$rec_name];
+                                    break;
+                                case 'name':
+                                case 'month_of_year':
+                                case 'week_of_month':
+                                case 'day_of_week':
+                                case 'all_day':
+                                case 'start_time_only':
+                                    $newRecurrence['fieldData'][$rec]['value'] = $_REQUEST[$rec_name];
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                }
 
             }
+            // echo '<pre>$newRecurrence: ' . print_r( $newRecurrence, true ) . '</pre>';
 
             $view = 'edit';
 
index 2bcda6a..5a7a2f5 100644 (file)
                 <tr>
                     <th>All Day Event:</th>
                     <td>
-                        <input id="allDayEvent_{ newRecurID }" data-id="{ newRecurID }" type="checkbox" name="{ newRecurID }_all_day" class="all-day-checkbox">
+                        <input {if $newRecurrence.fieldData.all_day.value}checked{/if} id="allDayEvent_{ newRecurID }" data-id="{ newRecurID }" type="checkbox" name="{ newRecurID }_all_day" class="all-day-checkbox">
                     </td>
                 </tr>
                 <tr class="not-all-day-{ newRecurID }">
                     <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Start Time:</th>
                     <td style="white-space: nowrap;">
                         <input data-id="{ newRecurID }" type="text" name="{ newRecurID }_start_time" value="{$newRecurrence.fieldData.start_time.time}" class="glm-form-text-input-veryshort glm-time-input recurrence-input">
-                        <input data-id="{ newRecurID }" type="checkbox" name="{ newRecurID }_start_time_only" class="start-time-only-checkbox recurrence-input"> Start time only
+                        <input  {if $newRecurrence.fieldData.start_time_only.value}checked{/if} data-id="{ newRecurID }" type="checkbox" name="{ newRecurID }_start_time_only" class="start-time-only-checkbox recurrence-input"> Start time only
                     </td>
                 </tr>
                 <tr id="endTimeRow_{ newRecurID }" class="not-all-day-{ newRecurID }">