Fixed problem with saving Don't show location address flag, adding stuff for ajax...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 24 May 2016 20:15:30 +0000 (16:15 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 24 May 2016 20:16:29 +0000 (16:16 -0400)
classes/data/dataTimes.php
models/admin/ajax/eventsCalMonthAJAX.php [new file with mode: 0644]
models/front/events/list.php
setup/validActions.php
views/admin/events/edit.html
views/admin/events/editAdminContact.html
views/admin/events/editLocation.html
views/admin/events/editStatus.html
views/front/events/agenda.html

index 82c3680..8367a0f 100644 (file)
@@ -232,6 +232,57 @@ class GlmDataEventsTimes extends GlmDataAbstract
         return $r;
     }
 
+    /**
+     * Get event times simplified
+     *
+     * @param integer $categoryID Select by Category (optional)
+     * @param string $startDate Date formatted to be used in MySQL
+     * @param string $endDate Date formatted to be used in MySQL
+     *
+     * @return object Class object
+     */
+    public function getEventTimesSimplified($categoryID = false, $startDate = false, $endDate = false)
+    {
+
+        $savedFields = $this->fields;
+
+        $this->fields = array(
+            'id' => $savedFields['id'],
+            'event' => $savedFields['event'],
+            'event_name' => $savedFields['event_name'],
+            'start_time' => $savedFields['start_time'],
+            'end_time' => $savedFields['end_time'],
+            'all_day' => $savedFields['all_day']
+        );
+
+        // Only display times from start date
+        if (!$startDate) {
+            $startDate = date('Y-m-d H:i:s');
+        }
+        $where = " T.start_time >= '$startDate' ";
+        if ($endDate) {
+            $where .= " AND T.start_time <= '$endDate' ";
+        }
+
+        if ($categoryID) {
+            $where .= "
+                AND
+                T.event IN (
+                    SELECT event
+                      FROM " .GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "event_categories
+                     WHERE category = $categoryID
+                )
+                ";
+        }
+
+        $eventsSimplified = $this->getList($where);
+
+        $this->fields = $savedFields;
+
+        return $eventsSimplified;
+
+    }
+
 }
 
 ?>
diff --git a/models/admin/ajax/eventsCalMonthAJAX.php b/models/admin/ajax/eventsCalMonthAJAX.php
new file mode 100644 (file)
index 0000000..db838be
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Get events for a monty for AJAX call
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Event Times data abstract
+require_once(GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataTimes.php');
+
+/*
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_eventsCalMonthAJAX extends GlmDataEventsTimes
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for members data class
+        parent::__construct(false, false);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This modelAction takes an AJAX image upload and stores the image in the
+     * media/images directory of the plugin.
+     *
+     * This model action does not return, it simply does it's work then calls die();
+     *
+     * @param $actionData
+     *
+     * Echos JSON string as response and does not return
+     */
+    public function modelAction ($actionData = false)
+    {
+
+        $return = array(
+            'status' => false,       // Assume nothing works
+            'events' => false,       // Where our events list will go
+            'message' => ''
+        );
+
+$return['message'] = 'Made it Here!';
+
+        // Return stored image data
+        echo json_encode($return);
+        wp_die();
+    }
+
+
+}
index 9c54133..d80b7f4 100644 (file)
@@ -48,6 +48,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
         $status   = $categoryId = null;
         $action   = '';
         $settings = $events = $event = $categoryEvents = array();
+        $calDates = false;
 
         // If a memberID has been specified, limit to that member
         $memberId = $actionData['request']['member'] - 0;
@@ -445,6 +446,14 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
         default:
             $view = 'agenda.html';
             $events = $this->getModelEventsData($categoryId, null, $memberId);
+
+            /* *** NOT USING AT THIS TIME - Moving to AJAX - REMOVE WHEN DONE
+            // Also get event times for calendar display
+            require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataTimes.php';
+            $Times = new GlmDataEventsTimes($this->wpdb, $this->config);
+            $calDates = $Times->getEventTimesSimplified($categoryID);
+            */
+
             break;
         }
 
@@ -508,7 +517,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
                 $view = 'listForMemberDetail.html';
                 break;
             default:
-                // No changes otherwis
+                // No changes otherwise
                 break;
         }
 
@@ -525,7 +534,8 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
             'fromDate'     => $fromDate,
             'toDate'       => $toDate,
             'eventName'    => $eventNameSearch,
-            'imgUrl'  => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/'
+            'imgUrl'  => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/',
+            'calDates'    => $calDates
         );
 
         error_reporting(E_ALL ^ E_NOTICE);
index bae7db6..6aff891 100644 (file)
@@ -50,6 +50,9 @@ $glmMembersEventsAddOnValidActions = array(
         ),
         'management' => array(
             'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
+        ),
+        'ajax' => array(
+            'eventsCalMonthAJAX' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
         )
     ),
     'frontActions' => array(
index 9c42604..f453774 100644 (file)
@@ -12,7 +12,7 @@
     <a href="{$thisUrl}?page={$thisPage}&glm_action=list" class="button button-secondary glm-button glm-right">Return to Events List</a>
   {/if}
 
-  {if $option == 'edit'}
+  {if $option == 'edit' || $option == 'update'}
     <a id="deleteEventButton" class="button button-secondary glm-button glm-right">Delete this Event</a>
     <h2>Edit Event</h2>
   {else}
                         timeFormat  : 'h:mma',
                         fixedWeekCount : false,
                         eventClick: function(calEvent, jsEvent, view) {
-
-//                            alert('Event: ' + calEvent.title);
                             $("#occurrences").dialog();
                             $(this).css('border-color', 'red');
                         }
 
                     fullCalendarLoaded = true;
                 }
-
+                
             });
 
             /*
                     initLocations();
                 }
             });
-            
+
+            // Set masking for phone number fields - see http://digitalbush.com/projects/masked-input-plugin/
+            $.mask.definitions['e'] = "[A-Za-z0-9: ]";
+            $(".glm-phone-input").mask("999-999-9999? eeeeeeeeeee");
+                            
             // Flash certain elements for a short time after display
             $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
 
index df0f0f7..7b3e873 100644 (file)
@@ -29,7 +29,7 @@
                     <tr>
                         <th {if $event.fieldRequired.admin_phone}class="glm-required"{/if}>Admin Contact Phone:</th>
                         <td {if $event.fieldFail.admin_phone}class="glm-form-bad-input" data-tabid="glm-event-admin"{/if}>
-                            <input type="text" name="admin_phone" value="{$event.fieldData.admin_phone}" class="glm-form-text-input-medium">
+                            <input type="text" name="admin_phone" value="{$event.fieldData.admin_phone}" class="glm-form-text-input-medium glm-phone-input">
                             {if $event.fieldFail.admin_phone}<p>{$event.fieldFail.admin_phone}</p>{/if}<br>
                         </td>
                     </tr>
index dab0722..d3ba261 100644 (file)
     <tr>
         <td>
             <table>
+                <tr>
+                    <th>Hide Location Address:</th>
+                    <td>
+                        <input type="checkbox" name="hide_address" {if $event.fieldData.hide_address.value} checked{/if}>
+                        Don't show location address to site visitors.
+                    </td>
+                </tr>
                 <tr>
                     <th>Use {$terms.term_member_cap} location:</th>
                     <td>
                                     <input id="name_{$loc.id}" type="text" name="Loc{$loc.id}_name" value="{$loc.name}" class="glm-form-text-input-medium">
                                 </td>
                             </tr>
-                            <tr>
-                                <th>Hide Location Address:</th>
-                                <td>
-                                    <input type="checkbox" name="Loc{$loc.id}_hide_address" {if $event.fieldData.hide_address.value} checked{/if}>
-                                    Don't show location address to site visitors.
-                                </td>
-                            </tr>
                             <tr>
                                 <th>Address:</th>
                                 <td>
                             <tr>
                                 <th>Phone:</th>
                                 <td>
-                                    <input type="text" name="Loc{$loc.id}_phone" value="{$loc.phone}" class="glm-form-text-input-medium">
+                                    <input type="text" name="Loc{$loc.id}_phone" value="{$loc.phone}" class="glm-form-text-input-medium glm-phone-input">
                                 </td>
                             </tr>
                             <tr>
index fd2a9d6..92f2e3f 100644 (file)
         <tr>
             <th {if $event.fieldRequired.contact_phone}class="glm-required"{/if}>Event Phone #:</th>
             <td {if $event.fieldFail.contact_phone}class="glm-form-bad-input" data-tabid="glm-event-descr"{/if}>
-                <input type="text" name="phone" value="{$event.fieldData.contact_phone}" class="glm-form-text-input-medium" placeholder="ex: 123-123-1234">
+                <input type="text" name="phone" value="{$event.fieldData.contact_phone}" class="glm-form-text-input-medium glm-phone-input" placeholder="ex: 123-123-1234">
                 {if $event.fieldFail.contact_phone}<p>{$event.fieldFail.contact_phone}</p>{/if}<br>
             </td>
         </tr>
                             <tr>
                                 <th>Contact Phone:</th>
                                 <td>
-                                    <input type="text" name="contact_phone" value="{$event.fieldData.contact_phone}" class="glm-form-text-input-medium">
+                                    <input type="text" name="contact_phone" value="{$event.fieldData.contact_phone}" class="glm-form-text-input-medium glm-phone-input">
                                 </td>
                             </tr>
                             <tr>
index f6dd292..1e4cffe 100644 (file)
                     </div>
                 </div>
             {/foreach}
+            
+            <!-- Calendar -->
+            
+            <div id="eventCalendar"></div>
+            
+            
         </div>
     </div>
 </div>
+
+
+<script type="text/javascript">
+    jQuery(document).ready(function($) {
+
+        var fullCalendarLoaded = false;
+        var recurrencesInited = false;
+        var locationsInited = false;
+
+/* Temporarily dissable calendar display        
+        
+         // Get calendar month via AJAX
+        function eventsCalMonthAJAX(month) {
+            var data = {
+                action: 'glm_members_admin_ajax',
+                glm_action: 'eventsCalMonthAJAX'
+                month: 'Month Stuff'
+            };
+            jQuery.post('{$ajaxUrl}', data, function(response) {
+                alert(response);
+            });
+        }
+// Fire off for testing        
+var x = eventsCalMonthAJAX('123');
+
+
+        if (table == 'glm-table-calendar' && !fullCalendarLoaded) {
+
+            // **** Should probably move all this to a function and check if it's been initialized already
+            $('#eventCalendar').fullCalendar({
+                events: [
+    {$sep = ''}
+    {foreach $calDates as $cDate}
+                    {$sep}{
+                        title : "{$cDate.event_name|unescape:'html'}",
+                        start : '{$cDate.start_time.datetime}',
+                        end   : '{$cDate.end_time.datetime}',
+                        allday : {$cDate.all_day.value}
+                    }
+                    {$sep = ','}
+    {/foreach}
+                ],
+                defaultDate : '{$firstTime.start_time.datetime}',
+                timeFormat  : 'h:mma',
+                fixedWeekCount : false,
+                eventClick: function(calEvent, jsEvent, view) {
+
+                    $("#occurrences").dialog();
+                    $(this).css('border-color', 'red');
+                }
+            });
+
+            fullCalendarLoaded = true;
+//        }
+*/
+
+
+    });
+</script>
\ No newline at end of file