Now not automatically adding dates to registrations. Have button for this.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 22 Nov 2017 17:47:39 +0000 (12:47 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 22 Nov 2017 17:47:39 +0000 (12:47 -0500)
Reworked top of registration dashboard page to get buttons in proper location and to be better responsive.
Removed defaults for reg_hold_minutes, cart_hold_days, and reg_hours_before from dataRegEvent.php
Added default for reg_hours_before to events.php
Added $deleteTimes option to checkEventTimes. Must be set for it to remove times. - dataRegEvent.php
Added dialog box and button to allow user to request any new times in event are added to registrations in eventDashboard.html.
No longer automatically adding times to registrations when adding registrations for an event in event.php.
Added messages to events.php to display when there are not times, when times are added, and when a request to add times or delete registrations for an event fail.
Replaced old "reason" code with "messages" code in eventEditLevels.html and eventEdit.html

classes/data/dataRegEvent.php
models/admin/registrations/events.php
views/admin/registrations/eventDashboard.html
views/admin/registrations/eventEdit.html
views/admin/registrations/eventEditLevels.html

index 458ff47..82d86ac 100644 (file)
@@ -222,7 +222,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'field'     => 'reg_hold_minutes',
                 'type'      => 'integer',
                 'required'  => true,
-                'default'   => 60,
+                // 'default'   => 60, See models/admin/registrations/events.php - Search for "Add event to registrations"
                 'use'       => 'a'
             ),
 
@@ -231,7 +231,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'field'     => 'cart_hold_days',
                 'type'      => 'integer',
                 'required'  => true,
-                'default'   => 10,
+                // 'default'   => 10, See models/admin/registrations/events.php - Search for "Add event to registrations"
                 'use'       => 'a'
             ),
 
@@ -240,7 +240,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'field'     => 'reg_hours_before',
                 'type'      => 'integer',
                 'required'  => true,
-                'default'   => 24,
+                // 'default'   => 24, See models/admin/registrations/events.php - Search for "Add event to registrations"
                 'use'       => 'a'
             ),
 
@@ -249,7 +249,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'field'     => 'registration_account_options',
                 'type'      => 'bitmap',
                 'bitmap'    => $this->config['registration_account_option'],
-                'default'   => 0, // none selected
+                'default'   => 14, // Guest, Saved, Members
                 'use'       => 'a'
             ),
 
@@ -258,7 +258,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'field'     => 'payment_methods',
                 'type'      => 'bitmap',
                 'bitmap'    => $this->config['payment_method'],
-                'default'   => 0, // none selected
+                'default'   => 68, // No Charge
                 'use'       => 'a'
             ),
 
@@ -267,7 +267,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
                 'field'     => 'restricted_payment_methods',
                 'type'      => 'bitmap',
                 'bitmap'    => $this->config['payment_method'],
-                'default'   => 0, // none selected
+                'default'   => 26, // none selected
                 'use'       => 'a'
             ),
 
@@ -967,10 +967,12 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
      * The getEventConfig() method must have been called first or a reg_event ID must be passed so that we have all of the needed event data.
      *
      * @param integer $regEventId Optional ID of a reg event record. If provided, load all registration data using getEventConfig() above
+     *                            This is not required if the event data has already been loaded using getEVentConfig() by the calling code
+     * @param boolean $deleteRemovedTimes Optional flag to ask that times removed from the event are removed from registration
      *
      * @return array updated reg_times data or false if not regEventData has been provided or no recurrence data
      */
-    public function checkEventTimes($regEventId = false)
+    public function checkEventTimes($regEventId = false, $deleteTimes = false)
     {
 
         $needTimesReloaded = false;
@@ -1100,8 +1102,8 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
 
         }
 
-        // If there's anything in the delete list, purge them now and say we need a reload
-        if ($deleteList != '') {
+        // If requested and there's anything in the delete list, purge them now and say we need a reload
+        if ($deleteTimes && $deleteList != '') {
             $this->wpdb->query("
                 DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time
                  WHERE id IN ($deleteList)
index e06301c..16057c5 100644 (file)
@@ -231,6 +231,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
                                     attendee_max_per_reg,
                                     reg_hold_minutes,
                                     cart_hold_days,
+                                    reg_hours_before,
                                     registration_account_options,
                                     payment_methods,
                                     restricted_payment_methods,
@@ -249,6 +250,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
                                     0,
                                     60,
                                     10,
+                                    24,
                                     0,
                                     0,
                                     0,
@@ -337,7 +339,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
                         }
 
                     } else {
-
+                        $messages[] = 'You did not properly confirm your request by entering "DELETE". No dates and times were added.';
                     }
 
                 }
@@ -360,7 +362,26 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
             case 'eventDashboard':
 
                 $regEvent = $this->getEventConfig($regEventID, true, false, true);
-                $regEvent = $this->checkEventTimes();
+
+                // Check if there's a request to add event times from the event
+                if (isset($_REQUEST) && isset($_REQUEST['getTimesFromEvent']) && $_REQUEST['getTimesFromEvent'] == 'yes') {
+
+                    // Check that the user entered the correct confirmation string
+                    if (isset($_REQUEST['addConfirmation']) && $_REQUEST['addConfirmation'] == 'ADD') {
+
+                        // Check for new event times
+                        $regEvent = $this->checkEventTimes();
+
+                        // Get the event data again along with any new times
+                        $regEvent = $this->getEventConfig($regEventID, true, false, true);
+
+                        $messages[] = 'Per your request, any dates and times specified in the event schedules that were not already added here, have now been added.';
+
+                    }else{
+                        $messages[] = 'You did not properly confirm your request by entering "ADD". No dates and times were added.';
+                    }
+
+                }
 
                 if ($regEvent !== false) {
 
@@ -369,12 +390,19 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
                     $regEventLastTime  = $regEvent['lastTime'];
 
                     // if there's a user notice, add it to messages
-                    if ($regEvent['message']) {
+                    if (isset($regEvent['message']) && $regEvent['message']) {
                         $messages[] = $regEvent['message'];
                     }
 
                 }
 
+                // Check if we have any times for this reg_event
+                if (is_array($regEvent['reg_time']) || count($regEVent['reg_time']) > 0) {
+                    $haveRegEventTimes = true;
+                } else {
+                    $messages[] = 'There are no dates for registrations for this event.';
+                }
+
                 $view = 'eventDashboard';
 
                 break;
index 2dc700d..7c2f14f 100644 (file)
@@ -2,25 +2,22 @@
 
 <h1>{$regEvent.event_name}</h1>
 
-    {if $haveMessages}
-        <div class="glm-error" style="font-size: 1rem; line-height: 1rem; margin-top: 1rem;">
-            <i>Please Note:</i>
-            <UL>
-      {foreach $messages as $m}
-                <li>{$m}</li>
-      {/foreach}          
-            </UL>
-        </div>
-    {/if}
-    
-
-<div class="glm-admin-table-inner">
-
-    <div id="glm-admin-member-dashboard glm-admin-table">
-      {if $haveRegEvent}
-
-        <div class="glm-row">
-            <div class="glm-small-12 glm-large-4 glm-columns">
+{if $haveMessages}
+    <div class="glm-error" style="font-size: 1rem; line-height: 1rem; margin-top: 1rem;">
+        <i>Please Note:</i>
+        <UL>
+  {foreach $messages as $m}
+            <li>{$m}</li>
+  {/foreach}          
+        </UL>
+    </div>
+{/if}
+ <div id="glm-admin-member-dashboard" class="glm-admin-table">   
+{if $haveRegEvent}
+    <div class="glm-row">
+        <div class="glm-small-12 glm-medium-4 glm-left">
+            <div class="glm-admin-table">
                 <div class="glm-row">
                     <div class="glm-small-6 glm-column">
                         <h3>Event Code:</h3>
                     </div>
                 </div>
             </div>
-            <div class="glm-small-12 glm-large-4 glm-columns">
-            {if $regEvent.total > 0}
+        </div>
+        <div class="glm-small-12 glm-medium-4 glm-left">
+            <div class="glm-admin-table">
+  {if $haveRegEvent}
                 <div class="glm-row">
                     <div class="glm-small-12 glm-column">
                         <h3>Maximum Attendees:</h3>
@@ -56,7 +55,7 @@
                         {$regEvent.total}
                     </div>
                 </div>
-            {/if}
+  {/if}                    
                 <div class="glm-row">
                     <div class="glm-small-12 glm-column">
                         <h3>Registered:</h3>
@@ -65,7 +64,7 @@
                         {$regEvent.registered}
                     </div>
                 </div>
-            {if $regEvent.total > 0}
+  {if $haveRegEvent}
                 <div class="glm-row">
                     <div class="glm-small-12 glm-column">
                         <h3>Cart Hold:</h3>
                         {$regEvent.totalAvail}
                     </div>
                 </div>
-            {/if}
+  {/if}                    
             </div>
-            
-        {if apply_filters('glm_members_menu_members', true)}
-            <div class="glm-small-12 glm-large-4 glm-columns">
+        </div>
+  {if apply_filters('glm_members_menu_members', true)}
+        
+        <div class="glm-small-12 glm-medium-4 glm-left">
+            <div class="glm-admin-table">
                 <div class="glm-row">
                     <div class="glm-small-12 glm-column">
                         <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-events&option=edit&regEventID={$regEvent.id}" class="button button-secondary glm-button">Edit Registration Event</a>
           {$r_link = apply_filters('glm_members_add_link_to_registrations_event_list_entry', $regEvent.event)}
-          {if is_array($r_link)}
-                        <a class="button button-secondary glm-button" href="{$r_link.url|escape:'string'}">Edit {$r_link.title}</a>
-          {/if}
-                              
+                    </div>
+                </div>
+                <div class="glm-row">
+                    <div class="glm-small-12 glm-column">
+                        <div id="regEventAddTimesButton" class="button button-secondary glm-button">Add Registration Dates/Times from Event</div>                             
+                        <div id="regEventAddTimesDialog" class="glm-dialog-box" title="Add Registration Dates/Times from Event">
+                            <p>
+                                This action looks for dates and time specified for the associated event in the event schedules. If there are any dates and times that are
+                                not already included for registrations, this action will add them using the defaults set for this event. You may set those
+                                defaults by clicking the "Edit Registration Event" button on this page. This action will not modify or remove date and times already
+                                added to registrations for this event.
+                            </p> 
+                            <p>
+                                The primary purpose of this action is to assist with initial setup of registrations for an event when there are a number of 
+                                dates and times specified in the schedules for the event and you wish to make most or all of those dates and times available for registration.
+                            </p>
+                            <p>
+                                <span class="glm-warning">NOTE:</span> If the event covers a large number of dates, this action may add a large number of dates 
+                                and times to registrations for this event. To deactivate or remove those dates you will be required to click on each date/time
+                                and either deactivate it or demove it.
+                            </p>
+                            <form href="{$thisUrl}">
+                                <input type="hidden" name="page" value="glm-members-admin-menu-registrations-events">
+                                <input type="hidden" name="option" value="eventDashboard">
+                                <input type="hidden" name="regEventID" value="{$regEvent.id}">
+                                <input type="hidden" name="getTimesFromEvent" value="yes">
+                                
+                                <center>
+                                    <h3>Event: <span class="glm-warning">{$regEvent.event_name}</span></h3> 
+                                    <p>To add dates and times from the event schedules<br>enter exactly "ADD" in the field below.</p>
+                                    <input type="text" name="addConfirmation" value="" placeholder="Enter 'ADD' here." required>
+                                    <p>Then click this button</p>
+                                    <input type="submit" class="button button-primary glm-button" value="Add Dates and Times to Registrations from the Event">                                
+                                </center>
+                            </form>
+                        </div>
+
+
+
+                    </div>
+                </div>
+                <div class="glm-row">
+                    <div class="glm-small-12 glm-column">
                         <div id="regEventDeleteButton" class="button button-secondary glm-button">Delete Registration Event</div>                             
                         <div id="regEventDeleteDialog" class="glm-dialog-box" title="Delete Registrations for this Event">
                             <center>
                                 </center>
                             </form>
                         </div>
-                        
+
+
+
+                    </div>
+                </div>
+                <div class="glm-row">
+                    <div class="glm-small-12 glm-column">
+          {if is_array($r_link)}
+                        <a class="button button-secondary glm-button" href="{$r_link.url|escape:'string'}">{$r_link.title}</a>
+          {/if}
                     </div>
                 </div>
+                
             </div>
-        {/if}
         </div>
-      {else}
-            <h3>Did not find selected event.</h3>
-      {/if}
+  {/if}
     </div>
+{else}
+    <h3>Did not find selected event.</h3>
+{/if}
 </div>
 
+
 <div class="glm-admin-table-inner glm-admin-table">
   {if $haveRegEvent}
     <p><h3>Dates and Availability</h3></p>
         {if $regEvent}
                         events: [
                             {$sep = ''}
+          {if $haveRegEventTimes}
                {foreach $regEvent.reg_time as $t}
                             {$sep}{
                               {if $t.attendee_max == 0}
                             }
                             {$sep = ','}
             {/foreach}
+          {/if}
                         ],
                         eventMouseover : function(event, jsEvent, view) {
                             $('.fc-event').css( 'cursor', 'pointer' );
 
             }
 
+            // Add registration dates from event dialog box
+            $("#regEventAddTimesDialog").dialog({
+                autoOpen: false,
+                width: 600,
+                resizable: true
+            });
+        
+            // Add registration dates from event button
+            $('#regEventAddTimesButton').on('click', function() {
+                $('#regEventAddTimesDialog').dialog('open');
+            });
+
             // Delete Dialog Box
             $("#regEventDeleteDialog").dialog({
                 autoOpen: false,
index 9c6c62c..1f7cdc2 100644 (file)
 
 <div class="glm-admin-table-inner glm-admin-table">
 
-{if $reason}
-       <p class="glm-error">{$reason}</p>
-{else}
+{if $haveMessages}
+    <div class="glm-error" style="font-size: 1rem; line-height: 1rem; margin-top: 1rem;">
+        <i>Please Note:</i>
+        <UL>
+  {foreach $messages as $m}
+            <li>{$m}</li>
+  {/foreach}          
+        </UL>
+    </div>
+{/if}
 
     <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
         <a onClick="return false;" class="nav-tab nav-tab-active">Edit Registration Settings</a>
     </form>
 </div>
 
-{/if} <!-- no problem reasons -->
-
 <script type="text/javascript">
        jQuery(document).ready(function($) {
        
index a8b5ed2..50628c4 100644 (file)
 
 <div class="glm-admin-table-inner glm-admin-table">
 
-
-{if $reason}
-    <p class="glm-error">{$reason}</p>
-{else}
+{if $haveMessages}
+    <div class="glm-error" style="font-size: 1rem; line-height: 1rem; margin-top: 1rem;">
+        <i>Please Note:</i>
+        <UL>
+  {foreach $messages as $m}
+            <li>{$m}</li>
+  {/foreach}          
+        </UL>
+    </div>
+{/if}
 
     <h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
         <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-events&option=edit&regEventID={$regEventID}" class="nav-tab">Edit Registration Settings</a>
 
         });
     </script>
-
-
-
-
-
-{/if} <!-- no problem reasons -->
-
+    
 </div>
 
 {include file='admin/footer.html'}