Interim status of Events add-on
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 8 Mar 2016 16:19:49 +0000 (11:19 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 8 Mar 2016 16:19:49 +0000 (11:19 -0500)
models/admin/events/list.php
views/admin/events/calendar.html [new file with mode: 0644]
views/admin/events/edit.html

index 874cab9..c3d3fd3 100644 (file)
@@ -108,6 +108,8 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
         $eventDeleted = false;
         $eventDeleteError = false;
         $recurrences = false;
+        $times = false;
+        $haveTimes = false;
 
         // Get a list of categories
         $Categories = new GlmDataEventsCategories($this->wpdb, $this->config);
@@ -141,6 +143,36 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
 
 
+        /*
+         * PLACE TEMPORARY TEST DATA FOR CALENDARS HERE
+         */
+        $haveTimes = true;
+        $times = array(
+            /*
+             * Place temp data here. It doesn't matter how you structure it.
+             * We can change the actual parameters in the calendar.html file
+             * later to match the actual data from the database.
+             */
+            '1' => array(
+                'id' => 1,
+                'event' => 1,
+                'custom_event' => false,
+                'recur_id' => 1,
+                'active' => true,
+                'start_time' => array(
+                    'timestamp' => 123123123,
+                    'datetime' => '4/1/2015 17:00'
+                ),
+                'end_time' => array(
+                    'timestamp' => 123123234,
+                    'datetime' => '4/1/2015 122:00'
+                ),
+                'all_day' => false
+            )
+        );
+
+
+
         // Do selected option
         switch ($option) {
 
@@ -270,7 +302,9 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
             'eventDeleted' => $eventDeleted,
             'eventDeleteError' => $eventDeleteError,
             'recurrences' => $recurrences,
-            'newRecurrence' => $newRecurrence
+            'newRecurrence' => $newRecurrence,
+            'times' => $times,
+            'haveTimes' => $haveTimes,
         );
 
         // Return status, any suggested view, and any data to controller
diff --git a/views/admin/events/calendar.html b/views/admin/events/calendar.html
new file mode 100644 (file)
index 0000000..88098d4
--- /dev/null
@@ -0,0 +1,30 @@
+<!-- 
+
+    Calendar view for Edit Event
+    
+    This file is included from inside a table <td> in the views/admin/events/edit.html file.
+     
+-->
+
+Place Calendar View HTML/Scripts here
+
+{if $haveTimes}
+    
+    {foreach $times as $v}
+    
+        Time ID: {$v.id}<br>
+        Event ID: {$v.event}<br>
+        Custom Event Data: {$v.custom_event}<br>
+        Recurrence ID: {$v.recur_id}<br>
+        Active: {$v.active}<br>
+        Start Time - timestamp: {$v.start_time.timestamp}<br>
+        Start Time - date time: {$v.start_time.datetime}<br>
+        End Time - timestamp: {$v.end_time.timestamp}<br>
+        End Time - date time: {$v.end_time.datetime}<br>
+        {$v.all_day}
+    
+    {/foreach}
+    
+{else}
+    <p>(no times listed)</p>
+{/if} 
\ No newline at end of file
index 1765c6d..007d01e 100644 (file)
@@ -67,7 +67,7 @@
                 <th>Status:</th>
                 <td>
                     <select name="status">
-        {foreach from=$event.fieldData.status.list item=v}
+        {foreach $event.fieldData.status.list as $v}
                         <option value="{$v.value}"{if $v.default} selected{/if}>{$v.name}</option>
         {/foreach}
                     </select>
                     <select name="categorySelect" id="categorySelect">
         {if $categories}
                         <option id="categoryNone" value=""></option>
-            {foreach from=$categories item=v}
+            {foreach $categories as $v}
                         <option value="{$v.id}" data-parent="{$v.parent}">
                             {if $v.parent_id}&nbsp;&nbsp;&nbsp;&nbsp;{/if}{$v.name}
                         </option>
                     <div id="activeCategories" class="glm-dynSelect-box">
                     
         {if isset($event.fieldData.categories) && $event.fieldData.categories}
-            {foreach from=$event.fieldData.categories item=c}
+            {foreach $event.fieldData.categories as $c}
                         <div data-id="{$c.id}" class="glm-dynSelect-item glm-events-category">
                             {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} 
                             <span data-id="{$c.id}" class="glm-dynSelect-delete catDelete">X</span>
         
         <table id="glm-table-recurrence" class="glm-admin-table glm-hidden glm-event-table">
             <tr>
-                            <tr>
-                                <th>Schedules</th>
-                                <td>
-                                    <a id="addRecurrenceButton" class="button button-primary glm-button glm-right">Add an Event Schedule</a>
-    
-                                </td>
-                            </tr>
+                <td colspan="2">
+                    <a id="addRecurrence" class="button button-primary glm-button glm-right">Add an Event Schedule</a>
+                </td>
+            </tr>
+            <tr>
+                <td colspan="2">
+                    <table id="recurrenceTable">
+                    
+                    <!-- Recurrence forms go here. New forms are added to the bottom of the list by the scripts at the bottom -->
         {if $recurrences}
-            {foreach from=$recurrences item=v}
+            {foreach $recurrences as $v}
         
             {/foreach}
-        {else}
-                            <tr><td>(no schedule listed)</td></tr>
         {/if}
+            
+                    </table>
+                </td>
             </tr>
         </table>
         
         
         <table id="glm-table-calendar" class="glm-admin-table glm-hidden glm-event-table">
             <tr>
-                <th>A parameter</th>
-                <td>A bunch of calendars for all the dates covered by this event.</td>
+                <td>
+                    {include file='admin/events/calendar.html'}
+                </td>
             </tr>
         </table>
         
         </div>
     </div>
 
-    <!-- Add/Edit Recurrence Dialog Box -->
+    <!-- Add/Edit Recurrence Template -->
     
-    <div id="addRecurrenceDialog" class="glm-dialog-box" title="Add a Schedule">
-        <center>
-        </center>
-        <div class="glm-item-container">
-
-            <table class="glm-admin-table">
-                <tr>
-                    <th>All Day Event:</th>
-                    <td>
-                        <input id="allDayEvent" type="checkbox" name="all_day" {if $event.fieldData.all_day.value} checked{/if}>
-                    </td>
-                </tr>
-                <tr><th></th><th><p>First ocurrance of event</p></th></tr>
-                <tr class="not-all-day">
-                    <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Start Date & Time:</th>
-                    <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
-                        <input type="text" name="start_time" value="{$newRecurrence.fieldData.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
-                        {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
-                    </td>
-                </tr>
-                <tr class="not-all-day">
-                    <th {if $newRecurrence.fieldRequired.end_time}class="glm-required"{/if}>End Date & Time:</th>
-                    <td {if $newRecurrence.fieldFail.end_time}class="glm-form-bad-input"{/if}>
-                        <input type="text" name="end_time" value="{$newRecurrence.fieldData.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
-                        {if $newRecurrence.fieldFail.end_time}<p>{$newRecurrence.fieldFail.end_time}</p>{/if}
-                    </td>
-                </tr>
-
-                <tr class="all-day glm-hidden">
-                    <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Event Date:</th>
-                    <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
-                        <input type="text" name="start_time" value="{$newRecurrence.fieldData.start_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
-                        {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
-                    </td>
-                </tr>
-
-                <tr><th></th><th><p>Date range over which recurring event can take place</p></th></tr>
-                <tr>
-                    <th {if $newRecurrence.fieldRequired.from_date}class="glm-required"{/if}>From Date:</th>
-                    <td {if $newRecurrence.fieldFail.from_date}class="glm-form-bad-input"{/if}>
-                        <input type="text" name="from_date" value="{$newRecurrence.fieldData.from_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
-                        {if $newRecurrence.fieldFail.from_date}<p>{$newRecurrence.fieldFail.from_date}</p>{/if}
-                    </td>
-                </tr>
-                <tr>
-                    <th {if $newRecurrence.fieldRequired.to_date}class="glm-required"{/if}>To Date:</th>
-                    <td {if $newRecurrence.fieldFail.to_date}class="glm-form-bad-input"{/if}>
-                        <input type="text" name="to_date" value="{$newRecurrence.fieldData.to_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
-                        {if $newRecurrence.fieldFail.to_date}<p>{$newRecurrence.fieldFail.to_date}</p>{/if}
-                    </td>
-                </tr>
-                <tr><th></th><th><p>When the event recurrs</p></th></tr>
-                <tr>
-                    <th>Months</th>
-                    <td>
-                        <table width="100%">
-                            <tr>
-                                <td>
-        {foreach from=$newRecurrence.fieldData.month_of_year.bitmap item=v}
-            {if $v.value == 6}  </td><td> {/if}
-                                    <input type="checkbox" name="month_of_year[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name} <br>
-        {/foreach}
-                                </td>
-                            </tr>
-                        </table>
-                    </td>
-                </tr>
-                <tr>
-                    <th>Select specific days of the month:</th>
-                    <td>
-                        <input id="specificDaysOfMonth" type="checkbox" name="by_days_of_month" {if $event.fieldData.all_day.value} checked{/if}>
-                    </td>
-                </tr>
-                <tr class="not-by-day-of-month">
-                    <th>Week of the Month</th>
-                    <td>
-        {foreach from=$newRecurrence.fieldData.week_of_month.bitmap item=v}
-                        <input type="checkbox" name="week_of_month[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name} &nbsp;
-        {/foreach}
-                    </td>
-                </tr>
-                <tr class="not-by-day-of-month">
-                    <th>Day of the Week</th>
-                    <td>
-                        <table width="100%">
-                            <tr>
-                                <td>
-        {foreach from=$newRecurrence.fieldData.day_of_week.bitmap item=v}
-            {if $v.value == 4}  </td><td> {/if}
-                                    <input type="checkbox" name="date_of_week[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name} <br>
-        {/foreach}
-                                </td>
-                            </tr>
-                        </table>
-                    </td>
-                </tr>
-                <tr class="by-day-of-month glm-hidden">
-                    <th>Day of the Month</th>
-                    <td>
-                        <table width="100%" class="glm-calendar">
-                            <tr>
-        {foreach from=$newRecurrence.fieldData.day_of_month.bitmap item=v}
-            {if in_array($v.value, array(7, 14, 21, 28))}
-                            </tr><tr>
-            {/if}
-                                <td>
-                                    <input type="checkbox" name="date_of_week[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}
-                                </td>
-        {/foreach}
-                                <td colspan="4" style="text-align: center;">
-                                    <input type="checkbox" name="last_day_of_month" value="{$v.value}"{if $v.default} checked{/if}> Last day of the month
-                                </td>
-                            </tr>
-                        </table>
-                    </td>
-                </tr>
-            </table>
-            
-        </div>
-        <p>
-            <a id="addRecurrenceCancel" class="button button-primary glm-right">Cancel Adding Schedule</a>
-            <input id="addRecurrenceSubmit" type="submit" value="Add this schedule">
-        </p>
-    </div>
+    <table id="addRecurrenceTemplate" class="glm-hidden">
+        <tr><td colspan="2"><h2>New Event Schedule</h2></td></tr>
+        <tr>
+            <td>
+                <input type="hidden" name="newRecurID" value="{ newRecurID }n">
+                <table width="100%">
+                    <tr><th></th><th><p>First ocurrence of event</p></th></tr>
+                    <tr>
+                        <th>All Day Event:</th>
+                        <td>
+                            <input id="allDayEvent_{ newRecurID }n" type="checkbox" name="all_day[{ newRecurID }n]" {if $event.fieldData.all_day.value} checked{/if}>
+                        </td>
+                    </tr>
+                    <tr class="not-all-day">
+                        <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Start Date & Time:</th>
+                        <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
+                            <input type="text" name="start_time_{ newRecurID }n" value="{$newRecurrence.fieldData.start_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
+                            {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
+                        </td>
+                    </tr>
+                    <tr class="not-all-day">
+                        <th {if $newRecurrence.fieldRequired.end_time}class="glm-required"{/if}>End Date & Time:</th>
+                        <td {if $newRecurrence.fieldFail.end_time}class="glm-form-bad-input"{/if}>
+                            <input type="text" name="end_time_{ newRecurID }n" value="{$newRecurrence.fieldData.end_time.datetime}" class="glm-form-text-input-small glm-datetime-input" placeholder="Click to Select Date/Time">
+                            {if $newRecurrence.fieldFail.end_time}<p>{$newRecurrence.fieldFail.end_time}</p>{/if}
+                        </td>
+                    </tr>
+        
+                    <tr class="all-day glm-hidden">
+                        <th {if $newRecurrence.fieldRequired.start_time}class="glm-required"{/if}>Event Date:</th>
+                        <td {if $newRecurrence.fieldFail.start_time}class="glm-form-bad-input"{/if}>
+                            <input type="text" name="start_time_{ newRecurID }n" value="{$newRecurrence.fieldData.start_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
+                            {if $newRecurrence.fieldFail.start_time}<p>{$newRecurrence.fieldFail.start_time}</p>{/if}
+                        </td>
+                    </tr>
+        
+                    <tr><th></th><th><p>Date range over which recurring event can take place</p></th></tr>
+                    <tr>
+                        <th {if $newRecurrence.fieldRequired.from_date}class="glm-required"{/if}>From Date:</th>
+                        <td {if $newRecurrence.fieldFail.from_date}class="glm-form-bad-input"{/if}>
+                            <input type="text" name="from_date_{ newRecurID }n" value="{$newRecurrence.fieldData.from_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
+                            {if $newRecurrence.fieldFail.from_date}<p>{$newRecurrence.fieldFail.from_date}</p>{/if}
+                        </td>
+                    </tr>
+                    <tr>
+                        <th {if $newRecurrence.fieldRequired.to_date}class="glm-required"{/if}>To Date:</th>
+                        <td {if $newRecurrence.fieldFail.to_date}class="glm-form-bad-input"{/if}>
+                            <input type="text" name="to_date_{ newRecurID }n" value="{$newRecurrence.fieldData.to_date.date}" class="glm-form-text-input-small glm-date-input" placeholder="Click to Select Date/Time">
+                            {if $newRecurrence.fieldFail.to_date}<p>{$newRecurrence.fieldFail.to_date}</p>{/if}
+                        </td>
+                    </tr>
+        
+                </table>
+            </td>
+            <td>
+                <table width="100%">
+        
+                    <tr><th></th><th><p>When the event recurrs</p></th></tr>
+                    <tr>
+                        <th>Months</th>
+                        <td>
+                            <table>
+                                <tr>
+            {foreach $newRecurrence.fieldData.month_of_year.bitmap as $v}
+                {if $v.value==6}
+                                </tr><tr>
+                {/if}
+                                    <td style="white-space: nowrap;"><input type="checkbox" name="month_of_year_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
+            {/foreach}
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+                    <tr>
+                        <th>Select by:</br>Days of month:</th>
+                        <td>
+                            <input id="specificDaysOfMonth" type="checkbox" name="by_days_of_month_{ newRecurID }n" {if $event.fieldData.all_day.value} checked{/if}> Check to select specific days of the month.
+                        </td>
+                    </tr>
+                    <tr class="not-by-day-of-month">
+                        <th>Week of the Month</th>
+                        <td>
+                            <table>
+                                <tr>
+            {foreach $newRecurrence.fieldData.week_of_month.bitmap as $v}
+                                    <td style="white-space: nowrap;"><input type="checkbox" name="week_of_month_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}&nbsp;&nbsp;</td>
+            {/foreach}
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+                    <tr class="not-by-day-of-month">
+                        <th>Day of the Week</th>
+                        <td>
+                            <table>
+                                <tr>
+            {foreach $newRecurrence.fieldData.day_of_week.bitmap as $v}
+                                    <td style="white-space: nowrap;"><input type="checkbox" name="date_of_week_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}</td>
+            {/foreach}
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+                    <tr class="by-day-of-month glm-hidden">
+                        <th>Day of the Month</th>
+                        <td>
+                            <table width="100%" class="glm-calendar">
+                                <tr>
+            {foreach $newRecurrence.fieldData.day_of_month.bitmap as $v}
+                {if in_array($v.value, array(7, 14, 21, 28))}
+                                </tr><tr>
+                {/if}
+                                    <td>
+                                        <input type="checkbox" name="date_of_week_{ newRecurID }n[{$v.value}]" value="{$v.value}"{if $v.default} checked{/if}> {$v.name}
+                                    </td>
+            {/foreach}
+                                    <td colspan="4" style="text-align: center;">
+                                        <input type="checkbox" name="last_day_of_month_{ newRecurID }n" value="{$v.value}"{if $v.default} checked{/if}> Last day of the month
+                                    </td>
+                                </tr>
+                            </table>
+                        </td>
+                    </tr>
+                </table>
+            </td>
+        </tr>
+    </table>
                                 
                                 
 
             /*
              * Recurrences
              */
-             // Add Recurrence dialog
-             $("#addRecurrenceDialog").dialog({
-                 autoOpen: false,
-                 minWidth: 800,
-                 dialogClass: "glm-dialog-no-close"
-             });
-             $('#addRecurrenceButton').click( function() {
-                 $('#addRecurrenceDialog').dialog('open');
-             });
-             $('#addRecurrenceCancel').click( function() {
-                 $("#addRecurrenceDialog").dialog("close");
-             });            
-             $('#addRecurrenceSubmit').click( function() {
-                 // window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=list&option=delete&event={$event.fieldData.id}");
-             });
+             var haveRecurrences = false;
+        {if $recurrences}
+            haveRecurrences = true;
+        {/if}
+
+            /*
+             * Add recurrence using template
+             */
+             
+            // New recurrence ID's start at 0 (have "n" for "new" appended to them in the template)
+            var newRecurID = 0;
+            
+            function addNewRecurrenceForm() {
+                
+                // Tick the new recurrence ID counter and build new HTML from the addRecurrenceTemplate
+                ++newRecurID;
+
+                // If we already have at least one recurrence, we need to add a separator
+                var recurTemp = '';
+                if (haveRecurrences) {
+                    recurTemp = '<tbody><tr><td colspan="2"><hr></td></tr></tbody>';
+
+                // Otherwise, we'll say we now have our first recurrence
+                } else {
+                    haveRecurrences = true;                    
+                }
+
+                recurTemp = recurTemp + $('#addRecurrenceTemplate').html();
+                recurTemp = recurTemp.replace(/{ newRecurID }/g, newRecurID);
+                
+                // Append the new recurrence form to the container
+                $('#recurrenceTable').append(recurTemp);
+                
+            }
+            
+            // When adding a new recurrence is requested
+            $("#addRecurrence").click( function() {
+                addNewRecurrenceForm();
+            });
+            
+            // Also add a new one at the start if none exist
+            if (!haveRecurrences){
+                addNewRecurrenceForm();
+            }
+            
+            $('#addRecurrenceButton').click( function() {
+                $('#addRecurrenceDialog').dialog('open');
+            });
+            $('#addRecurrenceCancel').click( function() {
+                $("#addRecurrenceDialog").dialog("close");
+            });            
+            $('#addRecurrenceSubmit').click( function() {
+                // window.location.replace("{$thisUrl}?page={$thisPage}&glm_action=list&option=delete&event={$event.fieldData.id}");
+            });
     
         
             /*