merging events dev branch into revamp branch feature/adminRevamp
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 29 Mar 2019 14:46:39 +0000 (10:46 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 29 Mar 2019 14:46:39 +0000 (10:46 -0400)
16 files changed:
classes/data/dataLocations.php
classes/data/dataManagement.php
index.php
js/dashboard.js
models/admin/events/list.php
models/front/events/frontAdd.php
models/front/events/list.php
readme.txt
setup/databaseScripts/create_database_V0.1.13.sql [deleted file]
setup/databaseScripts/create_database_V0.1.14.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.1.14.sql [new file with mode: 0644]
views/admin/events/editLocation.html
views/admin/management/events.html
views/front/events/frontAdd.html
views/front/events/searchForm.html

index 4f3066e..34908ed 100644 (file)
@@ -174,6 +174,18 @@ class GlmDataEventsLocations extends GlmDataAbstract
                 'use' => 'a'
             ),
 
+            // County - References main plugin county table
+            'county' => array (
+                'field' => 'county',
+                'type' => 'pointer',
+                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'counties',
+                    'p_field' => 'name',
+                    'p_orderby' => 'name',
+                    'p_blank' => false,
+                    'force_list' => true,
+                'use' => 'a'
+            ),
+
             // Country
             'country' => array (
                 'field' => 'country',
index 6fd7e2f..9ea1580 100644 (file)
@@ -297,6 +297,14 @@ class GlmDataEventsManagement extends GlmDataAbstract
                 'use'     => 'a'
             ),
 
+            // Show category in search form
+            'show_search_category' => array(
+                'field'   => 'show_search_category',
+                'type'    => 'checkbox',
+                'default' => false,
+                'use'     => 'a'
+            ),
+
             // Show region in search form
             'show_search_region' => array(
                 'field'   => 'show_search_region',
@@ -305,6 +313,13 @@ class GlmDataEventsManagement extends GlmDataAbstract
                 'use'     => 'a'
             ),
 
+            // Show county in search form
+            'show_search_county' => array(
+                'field'   => 'show_search_county',
+                'type'    => 'checkbox',
+                'default' => false,
+                'use'     => 'a'
+            ),
             // Turn on required fields for Michigan.org
             'michigan_org_requirements' => array(
                 'field'   => 'michigan_org_requirements',
index 5a028cb..723b78d 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
  * Plugin Name: GLM Associate - Events Add-On
  * Plugin URI: http://www.gaslightmedia.com/
  * Description: Gaslight Media Members Database.
- * Version: 1.7.19
+ * Version: 1.7.22
  * Author: Chuck Scott
  * Author URI: http://www.gaslightmedia.com/
  * License: GPL2
@@ -19,7 +19,7 @@
  * @package glmMembersDatabaseEventsAddOn
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.7.19
+ * @version 1.7.22
  */
 
 // Check that we're being called by WordPress.
@@ -43,8 +43,8 @@ if (!defined('ABSPATH')) {
  *  so that we're sure the other add-ons see an up to date
  *  version from this plugin.
  */
-define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.7.19');
-define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.13');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.7.22');
+define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.14');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_EVENTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.9.15');
index d90cb64..4fa5ab4 100644 (file)
@@ -24,12 +24,13 @@ jQuery(document).ready(function ($) {
             GLM_GeoMap.initializeLargeMap();
         });
     }
-    jQuery('#glm-event-pdf-submit').click(function(event){
-        eventForm = $('#glm-member-event-search');
-        // Get the data-cats
-        var categories = $(this).data('cats');
-        eventForm.attr('action', ajaxUrl + '?action=glm_members_admin_ajax&glm_action=pdfOutput&glm-event-pdf=1&categories=' + categories );
-    });
+    // This has been moved into the view file for the event search form
+    // jQuery('#glm-event-pdf-submit').click(function(event){
+    //     eventForm = $('#glm-member-event-search');
+    //     // Get the data-cats
+    //     var categories = $(this).data('cats');
+    //     eventForm.attr('action', ajaxUrl + '?action=glm_members_admin_ajax&glm_action=pdfOutput&glm-event-pdf=1&categories=' + categories );
+    // });
     if (jQuery('#glm-event-name').length > 0) {
         var cache = {};
         jQuery("#glm-event-name").autocomplete({
index ef0682a..d1102f1 100644 (file)
@@ -423,452 +423,453 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
                 $view = 'edit';
                 break;
 
-            case 'update':
-
-                // Get the original Event Status. Before the update.
-                $old_event_status = $this->wpdb->get_var(
-                    $this->wpdb->prepare(
-                        "SELECT status
-                           FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
-                          WHERE id = %d",
-                       $this->eventID
-                    )
-                );
+        case 'update':
+
+            // Get the original Event Status. Before the update.
+            $old_event_status = $this->wpdb->get_var(
+                $this->wpdb->prepare(
+                    "SELECT status
+                       FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+                      WHERE id = %d",
+                   $this->eventID
+                )
+            );
 
-                $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);
+            }
 
-                // Try to update this event
-                $event = $this->updateEntry($this->eventID);
-
-                // Check if that was successful
-                if ($event['status']) {
-                    $eventUpdated = true;
-                    $new_status = $event['fieldData']['status']['value'];
-
-                    // Check if the event is being approved
-                    if ( $event['fieldData']['status']['value'] && $old_event_status ) {
-                        if ( $old_event_status == 20 && $new_status == 10 ) {
-                            // Update approved timestamp.
-                            $this->updateTimestamp('approved', $this->eventID);
-                            if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
-                                $notification->sendMemberNotice( $member_id, $event );
-                            }
-                        } else if ( $isModerated && $old_event_status == 10 && $new_status == 20 ) {
-                            if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
-                                $notification->sendAdminNotice( $member_id, $event );
-                            }
+            // Try to update this event
+            $event = $this->updateEntry($this->eventID);
+
+            // Check if that was successful
+            if ($event['status']) {
+                $eventUpdated = true;
+                $new_status = $event['fieldData']['status']['value'];
+
+                // Check if the event is being approved
+                if ( $event['fieldData']['status']['value'] && $old_event_status ) {
+                    if ( $old_event_status == 20 && $new_status == 10 ) {
+                        // Update approved timestamp.
+                        $this->updateTimestamp('approved', $this->eventID);
+                        if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
+                            $notification->sendMemberNotice( $member_id, $event );
+                        }
+                    } else if ( $isModerated && $old_event_status == 10 && $new_status == 20 ) {
+                        if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
+                            $notification->sendAdminNotice( $member_id, $event );
                         }
                     }
+                }
 
-                    // Update updated timestamp and name slug for URLs
-                    $this->updateTimestamp('updated', $this->eventID);
-                    $this->updateSlug($this->eventID);
-
-                    $event = $this->editEntry($this->eventID);
+                // Update updated timestamp and name slug for URLs
+                $this->updateTimestamp('updated', $this->eventID);
+                $this->updateSlug($this->eventID);
 
-                    // Check for status change for any search engine requests.
-                    $statusActive = $this->config['event_status_numb']['Active'];
-                    $eventSlug = $event['fieldData']['name_slug'];
-                    if ($new_status == $statusActive) {
-                        $indexEvent = true;
-                    } elseif ($old_event_status == $statusActive && $new_status != $statusActive) {
-                        $removeEventIndex = true;
-                    }
+                $event = $this->editEntry($this->eventID);
 
-                } else {
-                    $eventUpdateError = true;
+                // Check for status change for any search engine requests.
+                $statusActive = $this->config['event_status_numb']['Active'];
+                $eventSlug = $event['fieldData']['name_slug'];
+                if ($new_status == $statusActive) {
+                    $indexEvent = true;
+                } elseif ($old_event_status == $statusActive && $new_status != $statusActive) {
+                    $removeEventIndex = true;
                 }
 
-                // Look for location deletes
-                if (isset($_REQUEST['deleteLocation']) && count($_REQUEST['deleteLocation'] > 0)) {
-                    foreach ($_REQUEST['deleteLocation'] as $d) {
+            } else {
+                $eventUpdateError = true;
+            }
 
-                        // If this was not a new entry that was deleted (in which case it was never added)
-                        if ($d[0] != 'n') {
-                            $Locations->deleteEntry($d, true);
-                        }
+            // Look for location deletes
+            if (isset($_REQUEST['deleteLocation']) && count($_REQUEST['deleteLocation'] > 0)) {
+                foreach ($_REQUEST['deleteLocation'] as $d) {
 
+                    // If this was not a new entry that was deleted (in which case it was never added)
+                    if ($d[0] != 'n') {
+                        $Locations->deleteEntry($d, true);
                     }
+
                 }
+            }
 
-                // Look for location data
-                if (isset($_REQUEST['locID'])) {
+            // Look for location data
+            if (isset($_REQUEST['locID'])) {
 
-                    // For each location
-                    foreach ( $_REQUEST['locID'] as $id => $locID ) {
+                // For each location
+                foreach ( $_REQUEST['locID'] as $id => $locID ) {
 
-                        // Check for new cities in this location and if so use the new city real ID
-                        if (isset($_REQUEST[$ocID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
-                            $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']];
-                        }
-
-                        // Check if it's a new Location
-                        if ($locID[0] == 'n') {
+                    // Check for new cities in this location and if so use the new city real ID
+                    if (isset($_REQUEST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') {
+                        $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']];
+                    }
 
-                            // Add the new location
-                            $x = $Locations->insertEntry(true, $locID.'_');
+                    // Check if it's a new Location
+                    if ($locID[0] == 'n') {
 
-                        // Otherwise it's an existing location
-                        } else {
-                           $Locations->updateEntry($id, 'id', true, $locID.'_');
-                        }
+                        // Add the new location
+                        $x = $Locations->insertEntry(true, $locID.'_');
 
+                    // Otherwise it's an existing location
+                    } else {
+                       $Locations->updateEntry($id, 'id', true, $locID.'_');
                     }
 
                 }
 
-                // Look for recurrence deletes
-                if (isset($_REQUEST['deleteRecur']) && count($_REQUEST['deleteRecur'] > 0)) {
-                    foreach ($_REQUEST['deleteRecur'] as $d) {
+            }
 
-                        // If this was not a new entry that was deleted (in which case it was never added)
-                        if ($d[0] != 'n') {
-                            $Recurrences->deleteTimeEntriesForRecurrance($d, true);
-                            $Recurrences->deleteEntry($d, true);
-                        }
+            // Look for recurrence deletes
+            if (isset($_REQUEST['deleteRecur']) && count($_REQUEST['deleteRecur'] > 0)) {
+                foreach ($_REQUEST['deleteRecur'] as $d) {
 
+                    // If this was not a new entry that was deleted (in which case it was never added)
+                    if ($d[0] != 'n') {
+                        $Recurrences->deleteTimeEntriesForRecurrance($d, true);
+                        $Recurrences->deleteEntry($d, true);
                     }
-                }
 
-                // Look for recurrence data
-                if (isset($_REQUEST['recurID'])) {
+                }
+            }
 
-                    // For each recurrence
-                    foreach ($_REQUEST['recurID'] as $recurID) {
+            // Look for recurrence data
+            if (isset($_REQUEST['recurID'])) {
 
-                        // first check if the event is an all-day event
-                        if (isset($_REQUEST[$recurID.'_all_day'])) {
+                // For each recurrence
+                foreach ($_REQUEST['recurID'] as $recurID) {
 
-                            // Then take the start date (date only) and stick it into the start time
-                            $red = explode(' ', $_REQUEST[$recurID.'_start_date']);
-                            $_REQUEST[$recurID.'_start_time'] = $red[0]." 00:00";
-                            $_REQUEST[$recurID.'_end_time'] = $red[0]." 00:00";
+                    // first check if the event is an all-day event
+                    if (isset($_REQUEST[$recurID.'_all_day'])) {
 
-                        }
+                        // Then take the start date (date only) and stick it into the start time
+                        $red = explode(' ', $_REQUEST[$recurID.'_start_date']);
+                        $_REQUEST[$recurID.'_start_time'] = $red[0]." 00:00";
+                        $_REQUEST[$recurID.'_end_time'] = $red[0]." 00:00";
 
-                        // Check if it's a new Recurrence
-                        if ($recurID[0] == 'n') {
+                    }
 
-                            // Add the new recurrence
-                            $r = $Recurrences->insertEntry(true, $recurID.'_');
-                            $thisRecurID = $r['fieldData']['id'];
+                    // Check if it's a new Recurrence
+                    if ($recurID[0] == 'n') {
 
-                            // And create time entries
-                            $Recurrences->createRecurrenceTimesEntries($thisRecurID, true, true);
+                        // Add the new recurrence
+                        $r = $Recurrences->insertEntry(true, $recurID.'_');
+                        $thisRecurID = $r['fieldData']['id'];
 
-                        // Otherwise it's an existing recurrence
-                        } else {
-                           $r = $Recurrences->updateEntry($recurID, 'id', true, 'Recur'.$recurID.'_');
-                           $thisRecurID = $recurID;
-                        }
+                        // And create time entries
+                        $Recurrences->createRecurrenceTimesEntries($thisRecurID, true, true);
 
-                        // Check for any specific dates and if so serialize the array sorted by date
-                        $specDates = serialize(array());
-                        if (isset($_REQUEST['Recur'.$recurID.'_specDate'])) {
-                            asort($_REQUEST['Recur'.$recurID.'_specDate']);
-                            $specDates = serialize($_REQUEST['Recur'.$recurID.'_specDate']);
-                        }
+                    // Otherwise it's an existing recurrence
+                    } else {
+                       $r = $Recurrences->updateEntry($recurID, 'id', true, 'Recur'.$recurID.'_');
+                       $thisRecurID = $recurID;
+                    }
 
-                        // If there's any difference, then update the specific_dates field
-                        if ($specDates != $r['fieldData']['specified_dates_unserialized']) {
-                            $this->wpdb->query("
-                                UPDATE ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "recurrences
-                                   SET specific_dates = '$specDates'
-                                 WHERE id = $thisRecurID;
-                            ");
-                        }
+                    // Check for any specific dates and if so serialize the array sorted by date
+                    $specDates = serialize(array());
+                    if (isset($_REQUEST['Recur'.$recurID.'_specDate'])) {
+                        asort($_REQUEST['Recur'.$recurID.'_specDate']);
+                        $specDates = serialize($_REQUEST['Recur'.$recurID.'_specDate']);
+                    }
 
+                    // If there's any difference, then update the specific_dates field
+                    if ($specDates != $r['fieldData']['specified_dates_unserialized']) {
+                        $this->wpdb->query("
+                            UPDATE ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "recurrences
+                               SET specific_dates = '$specDates'
+                             WHERE id = $thisRecurID;
+                        ");
                     }
 
-                    // Update our recurrences
-                    $recurrences = $Recurrences->getList("T.event = ".$this->eventID);
+                }
 
-                    // Check for any updated recurrences
-                    if (isset($_REQUEST['recurUpdated']) && count($_REQUEST['recurUpdated']) > 0) {
-                        foreach ($_REQUEST['recurUpdated'] as $r) {
+                // Update our recurrences
+                $recurrences = $Recurrences->getList("T.event = ".$this->eventID);
 
-                            // If we have a recurID as a value, then update this recurrence times
-                            if ($r) {
-                                $Recurrences->createRecurrenceTimesEntries($r, true, true);
-                            }
+                // Check for any updated recurrences
+                if (isset($_REQUEST['recurUpdated']) && count($_REQUEST['recurUpdated']) > 0) {
+                    foreach ($_REQUEST['recurUpdated'] as $r) {
+
+                        // If we have a recurID as a value, then update this recurrence times
+                        if ($r) {
+                            $Recurrences->createRecurrenceTimesEntries($r, true, true);
                         }
                     }
-
                 }
 
-                $haveEvent = true;
-                $view = 'edit';
-
-                glmClearShortcodeCache();
+            }
 
-                break;
+            $haveEvent = true;
+            $view = 'edit';
 
-            case 'clone':
-                //echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
-                //exit;
-                // Load Event Clone Class
-                require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/glmEventClone.php';
-                $ClonedEvent = new GlmEventClone( $this->wpdb, $this->config );
+            glmClearShortcodeCache();
 
-                // Clone the current event
-                $this->eventID = $ClonedEvent->cloneEvent( $this->eventID );
+            break;
 
-                // Update the name slug for this event
-                $this->updateSlug( $this->eventID );
+        case 'clone':
+            //echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+            //exit;
+            // Load Event Clone Class
+            require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/glmEventClone.php';
+            $ClonedEvent = new GlmEventClone( $this->wpdb, $this->config );
 
-                // Reset the editEntry for this new event
-                $event = $this->editEntry( $this->eventID );
+            // Clone the current event
+            $this->eventID = $ClonedEvent->cloneEvent( $this->eventID );
 
-                // Set the view file
-                $view = 'edit';
-                $haveEvent = true;
-                break;
+            // Update the name slug for this event
+            $this->updateSlug( $this->eventID );
 
-            case 'delete':
+            // Reset the editEntry for this new event
+            $event = $this->editEntry( $this->eventID );
 
-                $event = $this->deleteEvent($this->eventID);
+            // Set the view file
+            $view = 'edit';
+            $haveEvent = true;
+            break;
 
-                if ($event) {
-                    $eventDeleted = true;
+        case 'delete':
 
-                    // Also ask to have event removed from search engine
-                    $removeEventIndex = true;
-                    $eventSlug = $event['name_slug'];
+            $event = $this->deleteEvent($this->eventID);
 
-                    glmClearShortcodeCache();
-                } else {
-                    $eventDeleteError = true;
-                }
+            if ($event) {
+                $eventDeleted = true;
 
-            case 'list':
-            default:
-                $where = 'true';
+                // Also ask to have event removed from search engine
+                $removeEventIndex = true;
+                $eventSlug = $event['name_slug'];
 
-                // If we have a back request then go through the PHP_SESSION
-                // and extract them into the REQUEST array.
-                if ( isset( $_REQUEST['back'] ) && filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN ) ) {
-                    if ( isset( $_SESSION['search'] ) && is_array( $_SESSION['search'] ) ) {
-                        foreach ( $_SESSION['search'] as $varName => $sessValue ) {
-                            $_REQUEST[$varName] = $sessValue;
-                        }
-                    }
-                }
+                glmClearShortcodeCache();
+            } else {
+                $eventDeleteError = true;
+            }
 
-                // Check for paging
-                if ( isset( $_REQUEST['pageSelect'] ) ) {
-                    $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect'];
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['pageSelect'] ) ) {
-                    unset( $_SESSION['search']['pageSelect'] );
-                }
-                if ( isset( $_REQUEST['nextStart'] ) ) {
-                    $_SESSION['search']['nextStart'] = $_REQUEST['nextStart'];
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['nextStart'] ) ) {
-                    unset( $_SESSION['search']['nextStart'] );
-                }
-                if ( isset( $_REQUEST['prevStart'] ) ) {
-                    $_SESSION['search']['prevStart'] = $_REQUEST['prevStart'];
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) {
-                    unset( $_SESSION['search']['prevStart'] );
-                }
+        case 'list':
+        default:
 
-                // Check for Archived filter
-                if (isset($_REQUEST['filterArchived']) && $_REQUEST['filterArchived'] == 'on') {
-                    $filterArchived = true;
-                    $_SESSION['search']['archived'] = true;
-                    $where .= " AND status = " . $this->config['status_numb']['Archived'];
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterArchived'] ) ) {
-                    unset( $_SESSION['search']['archived'] );
-                }
+            $where = 'true';
 
-                // Check for Pending filter
-                if (isset($_REQUEST['filterPending']) && $_REQUEST['filterPending'] == 'on') {
-                    $filterPending = true;
-                    $_SESSION['search']['pending'] = true;
-                    $where .= " AND status = " . $this->config['status_numb']['Pending'];
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterPending'] ) ) {
-                    unset( $_SESSION['search']['pending'] );
+            // If we have a back request then go through the PHP_SESSION
+            // and extract them into the REQUEST array.
+            if ( isset( $_REQUEST['back'] ) && filter_var( $_REQUEST['back'], FILTER_VALIDATE_BOOLEAN ) ) {
+                if ( isset( $_SESSION['search'] ) && is_array( $_SESSION['search'] ) ) {
+                    foreach ( $_SESSION['search'] as $varName => $sessValue ) {
+                        $_REQUEST[$varName] = $sessValue;
+                    }
                 }
+            }
 
-                // Check for Featured filter
-                if (isset($_REQUEST['filterFeatured']) && $_REQUEST['filterFeatured'] == 'on') {
-                    $filterFeatured = true;
-                    $_SESSION['search']['featured'] = true;
-                    $where .= " AND featured = true";
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterFeatured'] ) ) {
-                    unset( $_SESSION['search']['featured'] );
-                }
+            // Check for paging
+            if ( isset( $_REQUEST['pageSelect'] ) ) {
+                $_SESSION['search']['pageSelect'] = $_REQUEST['pageSelect'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['pageSelect'] ) ) {
+                unset( $_SESSION['search']['pageSelect'] );
+            }
+            if ( isset( $_REQUEST['nextStart'] ) ) {
+                $_SESSION['search']['nextStart'] = $_REQUEST['nextStart'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['nextStart'] ) ) {
+                unset( $_SESSION['search']['nextStart'] );
+            }
+            if ( isset( $_REQUEST['prevStart'] ) ) {
+                $_SESSION['search']['prevStart'] = $_REQUEST['prevStart'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) {
+                unset( $_SESSION['search']['prevStart'] );
+            }
 
-                // Add "selected" element default false;
-                reset($categories);
-                foreach ( $categories as $k => $v ) {
-                    $categories[$k]['selected'] = false;
-                }
+            // Check for Archived filter
+            if (isset($_REQUEST['filterArchived']) && $_REQUEST['filterArchived'] == 'on') {
+                $filterArchived = true;
+                $_SESSION['search']['archived'] = true;
+                $where .= " AND status = " . $this->config['status_numb']['Archived'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterArchived'] ) ) {
+                unset( $_SESSION['search']['archived'] );
+            }
 
-                // Check if there is a category filter (multi-select)
-                if (isset($_REQUEST['filterCategories']) && count($_REQUEST['filterCategories']) > 0) {
+            // Check for Pending filter
+            if (isset($_REQUEST['filterPending']) && $_REQUEST['filterPending'] == 'on') {
+                $filterPending = true;
+                $_SESSION['search']['pending'] = true;
+                $where .= " AND status = " . $this->config['status_numb']['Pending'];
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterPending'] ) ) {
+                unset( $_SESSION['search']['pending'] );
+            }
 
-                    $cats = '';
-                    $catsSep = '';
+            // Check for Featured filter
+            if (isset($_REQUEST['filterFeatured']) && $_REQUEST['filterFeatured'] == 'on') {
+                $filterFeatured = true;
+                $_SESSION['search']['featured'] = true;
+                $where .= " AND featured = true";
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterFeatured'] ) ) {
+                unset( $_SESSION['search']['featured'] );
+            }
 
-                    // For each selected category
-                    foreach($_REQUEST['filterCategories'] as $c) {
-                        $cats .= $catsSep.$c;
-                        $catsSep = ',';
-                        $categories[$c]['selected'] = true;
-                    }
-                    $_SESSION['search']['cats'] = $cats;
-
-                    $where .= " AND id in (
-                            SELECT DISTINCT(EC.event)
-                              FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_categories EC,
-                                   ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories C
-                             WHERE (
-                                   EC.category in ($cats)
-                                   OR (C.parent in ($cats) AND EC.category = C.id)
-                                   )
-                    )";
-                } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterCategories'] ) ) {
-                    unset( $_SESSION['search']['cats'] );
-                }
+            // Add "selected" element default false;
+            reset($categories);
+            foreach ( $categories as $k => $v ) {
+                $categories[$k]['selected'] = false;
+            }
 
-                // Check if we have a Text Search string
-                if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch']) != '') {
-                    $textSearch = trim($_REQUEST['textSearch']);
-                    $where .= " AND name LIKE '%$textSearch%'";
-                    $_SESSION['search']['textSearch'] = $textSearch;
-                } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['textSearch']) == '' ) {
-                    unset( $_SESSION['search']['textSearch'] );
-                }
+            // Check if there is a category filter (multi-select)
+            if (isset($_REQUEST['filterCategories']) && count($_REQUEST['filterCategories']) > 0) {
 
+                $cats = '';
+                $catsSep = '';
 
-                // If we have a From date
-                $dateWhere = '';
-                if (isset($_REQUEST['fromDate']) && trim($_REQUEST['fromDate']) != '') {
-                    $fromDate = date('m/d/Y', strtotime($_REQUEST['fromDate']));
-                    $fromMYSQL = date('Y-m-d', strtotime($fromDate));
-                    $dateWhere = " end_time >= '$fromMYSQL' ";
-                    $_SESSION['search']['fromDate'] = $fromDate;
-                } else if ( !isset( $_REQUEST['searched'] ) ) {
-                    $fromDate = date('m/d/Y');
-                    $fromMYSQL = date('Y-m-d', strtotime($fromDate));
-                    $dateWhere = " end_time >= '$fromMYSQL' ";
-                } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['fromDate']) == '' ) {
-                    unset( $_SESSION['search']['fromDate'] );
+                // For each selected category
+                foreach($_REQUEST['filterCategories'] as $c) {
+                    $cats .= $catsSep.$c;
+                    $catsSep = ',';
+                    $categories[$c]['selected'] = true;
                 }
+                $_SESSION['search']['cats'] = $cats;
+
+                $where .= " AND id in (
+                        SELECT DISTINCT(EC.event)
+                          FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."event_categories EC,
+                               ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."categories C
+                         WHERE (
+                               EC.category in ($cats)
+                               OR (C.parent in ($cats) AND EC.category = C.id)
+                               )
+                )";
+            } else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['filterCategories'] ) ) {
+                unset( $_SESSION['search']['cats'] );
+            }
+
+            // Check if we have a Text Search string
+            if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch']) != '') {
+                $textSearch = trim($_REQUEST['textSearch']);
+                $where .= " AND name LIKE '%$textSearch%'";
+                $_SESSION['search']['textSearch'] = $textSearch;
+            } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['textSearch']) == '' ) {
+                unset( $_SESSION['search']['textSearch'] );
+            }
 
-                // If we have a to Date
-                if (isset($_REQUEST['toDate']) && trim($_REQUEST['toDate']) != '') {
 
-                    $toDate = date('m/d/Y', strtotime($_REQUEST['toDate']));
-                    $toMYSQL = date('Y-m-d', strtotime($toDate." +1 day"));
+            // If we have a From date
+            $dateWhere = '';
+            if (isset($_REQUEST['fromDate']) && trim($_REQUEST['fromDate']) != '') {
+                $fromDate = date('m/d/Y', strtotime($_REQUEST['fromDate']));
+                $fromMYSQL = date('Y-m-d', strtotime($fromDate));
+                $dateWhere = " end_time >= '$fromMYSQL' ";
+                $_SESSION['search']['fromDate'] = $fromDate;
+            } else if ( !isset( $_REQUEST['searched'] ) ) {
+                $fromDate = date('m/d/Y');
+                $fromMYSQL = date('Y-m-d', strtotime($fromDate));
+                $dateWhere = " end_time >= '$fromMYSQL' ";
+            } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['fromDate']) == '' ) {
+                unset( $_SESSION['search']['fromDate'] );
+            }
 
-                    // If we have a from date then we need Parens and AND
-                    if ($dateWhere != '') {
-                        $dateWhere = "( ".$dateWhere." AND start_time <= '$toMYSQL' )";
+            // If we have a to Date
+            if (isset($_REQUEST['toDate']) && trim($_REQUEST['toDate']) != '') {
 
-                    // Otherwise we don't
-                    } else {
-                        $dateWhere = " start_time <= '$toMYSQL' ";
-                    }
-                    $_SESSION['search']['toDate'] = $toDate;
-                } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['toDate']) == '' ) {
-                    unset( $_SESSION['search']['toDate'] );
-                }
+                $toDate = date('m/d/Y', strtotime($_REQUEST['toDate']));
+                $toMYSQL = date('Y-m-d', strtotime($toDate." +1 day"));
 
-                // If we have from and to dates, do search for those inclusive
+                // If we have a from date then we need Parens and AND
                 if ($dateWhere != '') {
-                    $where .= "
-                        AND id in (
-                            SELECT DISTINCT(event)
-                              FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."times
-                             WHERE $dateWhere
-                               AND active
-                        )
-                    ";
-                }
+                    $dateWhere = "( ".$dateWhere." AND start_time <= '$toMYSQL' )";
 
-                // Check if the list is for a specific member
-                if (defined('GLM_EVENTS_MEMBER_MENU') || $memberID) {
-                    $where .= " AND ref_dest = $memberID";
-                    $_SESSION['search']['memberID'] = $memberID;
+                // Otherwise we don't
+                } else {
+                    $dateWhere = " start_time <= '$toMYSQL' ";
                 }
+                $_SESSION['search']['toDate'] = $toDate;
+            } else if ( isset( $_REQUEST['searched'] ) && trim($_REQUEST['toDate']) == '' ) {
+                unset( $_SESSION['search']['toDate'] );
+            }
 
-                // Get the total number of events listed
-                $numbEvents = $this->getStats($where);
+            // If we have from and to dates, do search for those inclusive
+            if ($dateWhere != '') {
+                $where .= "
+                    AND id in (
+                        SELECT DISTINCT(event)
+                          FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."times
+                         WHERE $dateWhere
+                           AND active
+                    )
+                ";
+            }
 
-                // If the number of events is less than a page, don't do paging
-                if ($numbEvents <= $limit) {
-                    $paging = false;
-                }
+            // Check if the list is for a specific member
+            if (defined('GLM_EVENTS_MEMBER_MENU') || $memberID) {
+                $where .= " AND ref_dest = $memberID";
+                $_SESSION['search']['memberID'] = $memberID;
+            }
 
-                // Get full list of names matching this where clause for search box
-                $namesList = $this->getIdName($where);
+            // Get the total number of events listed
+            $numbEvents = $this->getStats($where);
 
-                // Check if we're doing paging
-                if (isset($_REQUEST['pageSelect'])) {
-                    // If request is for Next
-                    if ($_REQUEST['pageSelect'][0] == 'N') {
-                        $newStart = $_REQUEST['nextStart'] - 0;
+            // If the number of events is less than a page, don't do paging
+            if ($numbEvents <= $limit) {
+                $paging = false;
+            }
 
-                    // Otherwise it must be Previous
-                    } else {
-                        $newStart = $_REQUEST['prevStart'] - 0;
-                    }
+            // Get full list of names matching this where clause for search box
+            $namesList = $this->getIdName($where);
 
-                    if ($newStart > 0) {
-                        $start = $newStart;
-                    }
-                }
+            // Check if we're doing paging
+            if (isset($_REQUEST['pageSelect'])) {
+                // If request is for Next
+                if ($_REQUEST['pageSelect'][0] == 'N') {
+                    $newStart = $_REQUEST['nextStart'] - 0;
 
-                if( isset($_SESSION['search']['pageSelect']) ){
-                     // If request is for Next
-                    if ($_SESSION['search']['pageSelect'][0] == 'N') {
-                        $newStart = $_SESSION['search']['nextStart'] - 0;
+                // Otherwise it must be Previous
+                } else {
+                    $newStart = $_REQUEST['prevStart'] - 0;
+                }
 
-                    // Otherwise it must be Previous
-                    } else {
-                        $newStart = $_SESSION['search']['prevStart'] - 0;
-                    }
-                    if ($newStart > 0) {
-                        $start = $newStart;
-                    }
+                if ($newStart > 0) {
+                    $start = $newStart;
                 }
+            }
+
+            if( isset($_SESSION['search']['pageSelect']) ){
+                 // If request is for Next
+                if ($_SESSION['search']['pageSelect'][0] == 'N') {
+                    $newStart = $_SESSION['search']['nextStart'] - 0;
 
-                // Get the list of events and determine number of events in list
-                $saveFLT = $this->postFirstAndLastTimes;
-                $this->postFirstAndLastTimes = true;
-                $orderBy = 'name';
-                $orderBy = "(select min(start_time) FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE T.id = event),name";
-                $eventsResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
-                $this->postFirstAndLastTimes = $saveFLT;
-
-                // Get paging results
-                $numbDisplayed = $eventsResult['returned'];
-                $lastDisplayed = $eventsResult['last'];
-                if ($start == 1) {
-                    $prevStart = false;
+                // Otherwise it must be Previous
                 } else {
-                    $prevStart = $start - $limit;
-                    if ($start < 1) {
-                        $start = 1;
-                    }
+                    $newStart = $_SESSION['search']['prevStart'] - 0;
                 }
-                if ($eventsResult['returned'] == $limit) {
-                    $nextStart = $start + $limit;
+                if ($newStart > 0) {
+                    $start = $newStart;
                 }
+            }
 
-                // since we're doing paging, we have to break out just the events data
-                $events = $eventsResult['list'];
-                if (count($events)>0) {
-                    $haveEvents = true;
+            // Get the list of events and determine number of events in list
+            $saveFLT = $this->postFirstAndLastTimes;
+            $this->postFirstAndLastTimes = true;
+            $orderBy = 'name';
+            $orderBy = "(select min(start_time) FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE T.id = event),name";
+            $eventsResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
+            $this->postFirstAndLastTimes = $saveFLT;
+
+            // Get paging results
+            $numbDisplayed = $eventsResult['returned'];
+            $lastDisplayed = $eventsResult['last'];
+            if ($start == 1) {
+                $prevStart = false;
+            } else {
+                $prevStart = $start - $limit;
+                if ($start < 1) {
+                    $start = 1;
                 }
-                unset($eventsResult);
+            }
+            if ($eventsResult['returned'] == $limit) {
+                $nextStart = $start + $limit;
+            }
+
+            // since we're doing paging, we have to break out just the events data
+            $events = $eventsResult['list'];
+            if ( is_array( $events ) && !empty( $events ) && count($events) > 0 ) {
+                $haveEvents = true;
+            }
+            unset($eventsResult);
 
                 break;
 
@@ -1116,24 +1117,25 @@ class GlmMembersAdmin_events_list extends GlmDataEvents
 
                 }
 
-                // If there's selected categories
-                if (count($selectedCategories) > 0) {
-
-                    // Update the selected categories for this event record, returns new list
-                    $EventCategories->setEventCategories($this->eventID, $selectedCategories);
-
-                }
-
                 // If there's been a new category
                 if ($newCategory) {
 
                     // Get the full category list again
-                    $this->categories = $Categories->getListSortedParentChild();
+                    // $this->categories = $Categories->getListSortedParentChild();
 
                 }
 
             } // For each category being submitted
 
+            // If there's selected categories
+            if (count($selectedCategories) > 0) {
+
+                // Update the selected categories for this event record, returns new list
+                $EventCategories->setEventCategories($this->eventID, $selectedCategories);
+
+            }
+
+
             // Otherwise if this is a submission and there's no categories submitted, so make sure there's none stored
         } elseif ( isset($_REQUEST['option']) && ( $_REQUEST['option'] === 'submit' || $_REQUEST['option'] === 'update' ) ) {
             $EventCategories->clearEventCategories($this->eventID);
index aaae766..4197800 100644 (file)
@@ -13,6 +13,7 @@ require_once GLM_MEMBERS_PLUGIN_PATH.'/models/admin/ajax/imageUpload.php';
 require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataRecurrences.php';
 require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataManagement.php';
 require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCities.php';
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCounties.php';
 
 /**
  * GLmMembersFront_event_fontAdd
@@ -65,19 +66,12 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         foreach ($address as $key => &$part) {
             $part = urlencode($part);
         }
-        $addressString = implode( ',', $address);
-        $url = "//maps.googleapis.com/maps/api/geocode/json?address={$addressString}";
-        $ch = curl_init($url);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        $return = json_decode(curl_exec($ch));
-        curl_close($ch);
-        if (isset($return->results)) {
-            $location = $return->results[0]->geometry->location;
-
-            return array(
-                $location->lat,
-                $location->lng
-            );;
+        $addressString = $address[0] . ',+' . $address[1] . '+' . $address[2];
+
+        $url = "https://nominatim.openstreetmap.org/search/?format=json&addressdetails=1&q={$addressString}&limit=1";
+        $return = json_decode( wp_remote_retrieve_body( wp_remote_get( $url ) ) );
+        if ( $return[0]->lat && $return[0]->lon ) {
+            return array( $return[0]->lat,  $return[0]->lon);
         } else {
             return false;
         }
@@ -212,8 +206,9 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         $eventAmenities  = array();
         $venues          = false;
         $startTimeOnly   = 0;
-        $eventCategories = [];
+        $eventCategories = array();
         $cities          = array();
+        $counties        = array();
 
         if ( isset( $actionData['request']['member_only'] )
             && $memberOnly = filter_var( $actionData['request']['member_only'], FILTER_VALIDATE_BOOLEAN ) ) {
@@ -241,8 +236,18 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         // populate cities dropdown
         $cityData = new GlmDataCities( $this->wpdb, $this->config );
         $cityVals = $cityData->getList( null, 'name' );
-        foreach ( $cityVals as $city ) {
-            $cities[$city['id']] = $city['name'];
+        if ( isset( $cityVals ) && is_array( $cityVals ) && !empty( $cityVals ) ) {
+            foreach ( $cityVals as $city ) {
+                $cities[$city['id']] = $city['name'];
+            }
+        }
+        // populate counties dropdown
+        $countyData = new GlmDataCounties( $this->wpdb, $this->config );
+        $countyVals = $countyData->getList( null, 'name' );
+        if ( isset( $countyVals ) && is_array( $countyVals ) && !empty( $countyVals ) ) {
+            foreach ( $countyVals as $county ) {
+                $counties[$county['id']] = $county['name'];
+            }
         }
         // populate category dropdown
         $categories = new GlmDataEventsCategories( $this->wpdb, $this->config );
@@ -353,6 +358,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
                 $place        = $this->filterInput( $_REQUEST['place'] );
                 $address      = $this->filterInput( $_REQUEST['address'] );
                 $city         = $this->filterInput( $_REQUEST['city'] );
+                $county       = $this->filterInput( $_REQUEST['county'] );
                 $state        = $this->filterInput( $_REQUEST['state'] );
                 $zip          = $this->filterInput( $_REQUEST['zip'] );
                 $contactEmail = $this->filterInput( $_REQUEST['contact_email'] );
@@ -531,29 +537,31 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
                         'name'          => $place,
                         'address'       => $address,
                         'city'          => $city,
+                        'county'        => $county,
                         'state'         => $state,
                         'zip'           => $zip,
                         'phone'         => $contactPhone,
                         'contact_fname' => $contactFirst,
                         'contact_lname' => $contactLast,
-                        'email'         => $contactEmail
+                        'email'         => $contactEmail,
 
                     );
                     $locationDataFormat = array(
-                         '%d',
-                         '%s',
-                         '%s',
-                         '%d',
-                         '%s',
-                         '%s',
-                         '%s',
-                         '%s',
-                         '%s',
-                         '%s'
+                         '%d', // eventID
+                         '%s', // place
+                         '%s', // address
+                         '%d', // city
+                         '%d', // county
+                         '%s', // state
+                         '%s', // zip
+                         '%s', // contactPhone
+                         '%s', // contactFirst
+                         '%s', // contactLast
+                         '%s', // contactEmail
                     );
                     if ( isset( $lat ) && isset( $lon ) && $lat && $lon) {
-                        $locationData['lat'] = $lat;
-                        $locationData['lon'] = $lon;
+                        $locationData['lat']  = $lat;
+                        $locationData['lon']  = $lon;
                         $locationDataFormat[] = '%s';
                         $locationDataFormat[] = '%s';
                     }
@@ -739,6 +747,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
             'confirmation_page' => $redirect_url,
             'mainImgUrl'        => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/',
             'cities'            => $cities,
+            'counties'          => $counties,
         );
 
         //error_reporting(E_ALL ^ E_NOTICE);
index adaa457..f9b2d5e 100644 (file)
@@ -59,6 +59,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
         $eventsByDate    = null;
         $categoryId      = null;
         $categories      = array();
+        $counties        = array();
         $amenityId       = null;
         $amenities       = array();
         $memberId        = null;
@@ -87,12 +88,24 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
                LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations EL ON ( EL.city = C1.id )
                LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E ON ( E.id = EL.event )
          WHERE E.use_member_location <> true
+           AND E.id IN (
+               SELECT event
+                 FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ET
+                WHERE E.status = " . $this->config['status_numb']['Active'] . "
+                  AND " . $this->dateRange . "
+               )
         UNION
         SELECT C2.id,C2.name
           FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities C2
                LEFT OUTER JOIN " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info MI ON ( MI.city = C2.id )
                LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E ON ( E.ref_dest = MI.member )
          WHERE E.use_member_location = true
+           AND E.id IN (
+               SELECT event
+                 FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ET
+                WHERE E.status = " . $this->config['status_numb']['Active'] . "
+                  AND " . $this->dateRange . "
+               )
         ORDER BY name";
         $cityData = $this->wpdb->get_results( $citySql, ARRAY_A );
 
@@ -103,12 +116,24 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
                LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations EL ON ( EL.region = C1.id )
                LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E ON ( E.id = EL.event )
          WHERE E.use_member_location <> true
+           AND E.id IN (
+               SELECT event
+                 FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ET
+                WHERE E.status = " . $this->config['status_numb']['Active'] . "
+                  AND " . $this->dateRange . "
+               )
         UNION
         SELECT C2.id,C2.name
           FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "regions C2
                LEFT OUTER JOIN " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info MI ON ( MI.region = C2.id )
                LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E ON ( E.ref_dest = MI.member )
          WHERE E.use_member_location = true
+           AND E.id IN (
+               SELECT event
+                 FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ET
+                WHERE E.status = " . $this->config['status_numb']['Active'] . "
+                  AND " . $this->dateRange . "
+               )
         ORDER BY name";
         $regionData = $this->wpdb->get_results( $regionSql, ARRAY_A );
 
@@ -401,6 +426,36 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
         } else {
             $eventNameSearch = false;
         }
+        // Setup counties for search
+        if ( $this->config['settings']['enable_counties'] ) {
+            // Get list of counties to search by
+            $countySql = "
+            SELECT C1.id,C1.name
+              FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties C1
+                   LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "locations EL ON ( EL.county = C1.id )
+                   LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E ON ( E.id = EL.event )
+             WHERE E.use_member_location <> true
+               AND E.id IN (
+                   SELECT event
+                     FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ET
+                    WHERE E.status = " . $this->config['status_numb']['Active'] . "
+                      AND " . $this->dateRange . "
+                   )
+            UNION
+            SELECT C2.id,C2.name
+              FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties C2
+                   LEFT OUTER JOIN " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info MI ON ( MI.county = C2.id )
+                   LEFT OUTER JOIN " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E ON ( E.ref_dest = MI.member )
+             WHERE E.use_member_location = true
+               AND E.id IN (
+                   SELECT event
+                     FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times ET
+                    WHERE E.status = " . $this->config['status_numb']['Active'] . "
+                      AND " . $this->dateRange . "
+                   )
+            ORDER BY name";
+            $countyData = $this->wpdb->get_results( $countySql, ARRAY_A );
+        }
 
         $categories = $this->getCategories();
         if ( isset($categories) && is_array($categories)) {
@@ -750,6 +805,7 @@ class GlmMembersFront_events_list extends GlmMembersFront_events_baseAction
             'amenities'    => $amenities,
             'memberId'     => $memberId,
             'cities'       => $cityData,
+            'counties'     => $countyData,
             'regions'      => $regionData,
             'cityId'       => $cityId,
             'regionId'     => $regionId,
index a9e77eb..86945cd 100755 (executable)
@@ -25,6 +25,9 @@ e.g.
 1. Activate the plugin through the 'Plugins' menu in WordPress
 
 == Changelog ==
+= 1.7.20 =
+* Bugfix - Event Category update reworking to avoid duplication of queries.
+
 = 1.7.19 =
 * New option (management) sort_by_featured_in_agenda
 * New option (management) show_search_city
diff --git a/setup/databaseScripts/create_database_V0.1.13.sql b/setup/databaseScripts/create_database_V0.1.13.sql
deleted file mode 100644 (file)
index 46f5e3a..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
--- Gaslight Media Members Database - Events Add-On
--- File Created: 08/18/17
--- Database Version: 0.1.13
--- Database Creation Script
---
--- This file is called to create a new set of tables for this
--- add-on for the most recent database version for this add-on.
---
--- There should only be one such file in this directory
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
-
--- Amenities
-CREATE TABLE {prefix}amenities (
-    id INT NOT NULL AUTO_INCREMENT,
-    active TINYINT(1) NULL,                   -- Amenity is active flag
-    name TINYTEXT NULL,                       -- Name of amenity
-    descr TEXT NULL,                          -- Description of amenity
-    short_descr TINYTEXT NULL,                -- Short description of amenity
-    uses_value BOOLEAN NULL,                  -- Flag indicating whether the amenity requires a quantity number
-    PRIMARY KEY (id),
-    INDEX(name(20))
-);
-
-----
-
--- Amenity Reference - Links a specific amenity to a specific entity of type ref_type
-CREATE TABLE {prefix}amenity_event (
-    id INT NOT NULL AUTO_INCREMENT,
-    amenity INT NULL,
-    event INT NULL,
-    PRIMARY KEY (id),
-    INDEX(event)
-);
-
-----
-
--- groups
-CREATE TABLE {prefix}amenity_groups (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TINYTEXT NULL,                     -- Name of the Group
-    PRIMARY KEY (id),
-    INDEX(name(20))
-);
-
-----
-
--- Amenity Group - Links a specific amenity to groups
-CREATE TABLE {prefix}grouped_amenities (
-    id INT NOT NULL AUTO_INCREMENT,
-    group_id INT,                              -- Pointer to the group
-    amenity_id INT,                            -- Pointer to the Amenity
-    searchable BOOLEAN DEFAULT '0',         -- Flag indicating whether the amenity group will show in the search form
-    PRIMARY KEY (id)
-);
-
-----
-
--- Categories - Categories for events
-CREATE TABLE {prefix}categories (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TINYTEXT NULL,                                   -- Name of event category
-    descr TINYTEXT NULL,                                  -- Description of this category
-    parent INT NULL,                                      -- Parent category, null or 0 if this is a top level category
-    PRIMARY KEY (id),
-    INDEX(parent)
-);
-
-----
-
--- Event-Category - Categories for specific event records
-CREATE TABLE {prefix}event_categories (
-    id INT NOT NULL AUTO_INCREMENT,
-    event INT NULL,                                       -- Pointer to the event
-    category INT NULL,                                    -- Pointer to the category
-    PRIMARY KEY (id),
-    INDEX(event),
-    INDEX(category)
-);
-
-----
-
--- Event Recurrence - Defines how an event recurs
-CREATE TABLE {prefix}recurrences (
-    id INT NOT NULL AUTO_INCREMENT,
-    event INTEGER NULL,                                   -- Pointer to event
-    name TINYTEXT NULL,                                   -- Name of this recurrence schedule - used on admin calendar
-    start_time TIME NULL,                                 -- Start time of day for event
-    start_time_only BOOLEAN NULL,                         -- Use end of first occurrence flag
-    end_time TIME NULL,                                   -- End time of day for event - If less than start time, assume a date boundry
-    all_day BOOLEAN NULL,                                 -- Flag indicating if this is an all-day event (informational only)
-    start_date DATE NULL,                                 -- Starting Date (if all_day is selected) Used instead of start_time
-    from_date DATE NULL,                                  -- From Date for recurrences
-    to_date DATE NULL,                                    -- To Date for recurrences
-    recurring BOOLEAN NULL,                               -- Flag indicating that event recurs on a schedule rather than all dates
-    month_of_year SMALLINT UNSIGNED NULL,                 -- Month of year (bitmap)
-    week_of_month TINYINT UNSIGNED NULL,                  -- Week of the month (bitmap)
-    day_of_week TINYINT UNSIGNED NULL,                    -- Day of the week (bitmap)
-    by_day_of_month BOOLEAN NULL,                         -- Flag indicating if selecting by days of the month
-    day_of_month INTEGER UNSIGNED NULL,                   -- Day of the month (bitmap)
-    last_day_of_month BOOLEAN NULL,                       -- Last day of the month
-    specific_dates TEXT NULL,                             -- Serialized array of specific dates added to the recurrence
-    holiday INT NULL,                                     -- Pointer to holidays list (for future development)
-    holiday_offset TINYINT,                               -- Offset from holiday (from -128 to +127 days)
-    PRIMARY KEY (id),
-    INDEX(event)
-);
-
-----
-
--- Times - List of actual event times for single and recurring events
-CREATE TABLE {prefix}times (
-    id INT NOT NULL AUTO_INCREMENT,
-    event INT NULL,                                       -- Pointer to the primary record for the event
-    custom_event INT NULL,                                -- Pointer to a customized copy of the event record (if set)
-    recur_id INT NULL,                                    -- Pointer to recurrence entry
-    active BOOLEAN NULL,                                  -- Active flag - normally set but used to temporarily disable a specific date
-    start_time DATETIME NULL,                             -- Date and time event starts
-    end_time DATETIME NULL,                               -- Date and time event ends
-    all_day BOOLEAN NULL,                                 -- All Day flag
-    PRIMARY KEY (id),
-    INDEX(event),
-    INDEX(start_time),
-    INDEX(end_time)
-);
-
-----
-
--- Locations - Locations for event - If there's no location pointing to an event try to use the referenced entity in events table
-CREATE TABLE {prefix}locations (
-    id INT NOT NULL AUTO_INCREMENT,
-    event INT NULL,                                       -- Pointer to the primary or custom event record
-    name TINYTEXT NULL,                                   -- Name of location
-    address TINYTEXT NULL,                                -- Street Address
-    city INT NULL,                                        -- Pointer to city - references main plugin city table
-    state TINYTEXT NULL,                                  -- Two character state abbreviation
-    zip TINYTEXT NULL,                                    -- ZIP/Postal code
-    country TINYTEXT NULL,                                -- Country Code
-    lat FLOAT NULL,                                       -- Latitude of location
-    lon FLOAT NULL,                                       -- Longitude of location
-    region INT NULL,                                      -- Pointer to Region - references main plugin region table
-    phone TINYTEXT NULL,                                  -- Location Phone #
-    url TINYTEXT NULL,                                    -- Location URL
-    email TINYTEXT NULL,                                  -- Location E-Mail Address
-    contact_addon_id INT NULL,                            -- ID of Contact from contact add-on (optional and if available)
-    contact_fname TINYTEXT NULL,                          -- Contact first name for this location (optional)
-    contact_lname TINYTEXT NULL,                          -- Contact last name for this location (optional)
-    contact_phone TINYTEXT NULL,                          -- Contact phone for this location (optional)
-    contact_email TINYTEXT NULL,                          -- Contact E-Mail address (optional)
-    PRIMARY KEY (id)
-);
-
-----
-
--- Events - Base event information - May also be entries here referenced by the "times" table for a custom date.
-CREATE TABLE {prefix}events (
-    id INT NOT NULL AUTO_INCREMENT,
-    status INT NULL,                                      -- Status for this event, see config['status']
-    custom_time INT NULL,                                 -- If this is a custom record for a specific instance (date) this points to that times table entry
-    root_event INT NULL,                                  -- Root event pointer if this is a custom record for a specific instance (date) (if custom_time is set)
-    created DATETIME NULL,                                -- Date/Time event was created or date custom event record was created if custom record
-    updated DATETIME NULL,                                -- Date/Time this event record was last updated
-    approved DATETIME NULL,                               -- Date/Ttime this event record was approved
-    ref_type INT NULL,                                    -- Type of entity this event is associated with - See config['ref_type']
-    ref_dest INT NULL,                                    -- Pointer to the specific entity of ref_type this event is associated with
-    hide_address BOOLEAN NULL,                            -- Option to hide address on front-end
-    featured BOOLEAN NULL,                                -- Option to mark as featured event
-    slideshow BOOLEAN NULL,                               -- Option to mark for use in slide show
-    major BOOLEAN NULL,                                   -- Option to mark as a major event
-    name TINYTEXT NULL,                                   -- Name of this event
-    name_slug TINYTEXT NULL,                              -- Slug for this event
-    header TINYTEXT NULL,                                 -- Header text for front-end display - NOT CURRENTLY USED
-    intro TINYTEXT NULL,                                  -- Intro text for front-end display
-    descr TEXT NULL,                                      -- Full description text
-    image TINYTEXT NULL,                                  -- Image file name
-    file1 TINYTEXT NULL,                                  -- File name for a single uploaded file #1
-    file1_descr TINYTEXT NULL,                            -- Description for file uploaded in field "file" #1
-    file2 TINYTEXT NULL,                                  -- File name for a single uploaded file #2
-    file2_descr TINYTEXT NULL,                            -- Description for file uploaded in field "file" #2
-    file3 TINYTEXT NULL,                                  -- File name for a single uploaded file #3
-    file3_descr TINYTEXT NULL,                            -- Description for file uploaded in field "file" #3
-    url TINYTEXT NULL,                                    -- Event URL
-    ticket_url TINYTEXT NULL,                             -- Ticket URL
-    registration_url TINYTEXT NULL,                       -- Registration URL
-    cost TINYTEXT NULL,                                   -- Description of event cost
-    admin_ref_type INT NULL,                              -- Type of admin contact if using a member contact
-    admin_ref_dest INT NULL,                              -- Pointer to admin contact record if using a member contact
-    admin_name TINYTEXT NULL,                             -- Admin Contact Name if not using a member contact
-    admin_org TINYTEXT NULL,                              -- Admin Contact Organization if not using a member contact
-    admin_email TINYTEXT NULL,                            -- Admin Contact E-Mail if not using a member contact
-    admin_phone TINYTEXT NULL,                            -- Admin Contact Phone if not using a member contact
-    free BOOLEAN NULL,                                    -- Event is Free
-    contact_email TINYTEXT NULL,                          -- Contact E-mail address
-    contact_name TINYTEXT NULL,                           -- Contact name
-    contact_phone TINYTEXT NULL,                          -- Event Phone
-    use_member_location BOOLEAN NULL,                     -- Use location of the member (if provided) rather than location table data
-    other_ref_dest INT NULL,                              -- Set location of the event to another member
-    old_event_id INT NULL,                                -- ID of event from old site for reference
-    ical_uid TINYTEXT NULL,                               -- The ical UID for this event.
-    notes TEXT NULL,                                      -- Internal notes for this event
-    PRIMARY KEY (id),
-    INDEX(custom_time),
-    INDEX(root_event),
-    INDEX(ref_type),
-    INDEX(ref_dest),
-    INDEX(featured),
-    INDEX(slideshow),
-    INDEX(major)
-);
-
-----
-
--- Event Management Settings
-CREATE TABLE {prefix}management (
-    id INT NOT NULL AUTO_INCREMENT,
-    canonical_event_page TINYTEXT NULL,                   -- Canonical page slug for event detail
-    pdf_logo TINYTEXT NULL,                               -- Image for the Top of the PDF
-    footer_text TINYTEXT NULL,                            -- Image for the Top of the PDF
-    to_email TINYTEXT NULL,                               -- Email address of the recipient
-    from_email TINYTEXT NULL,                             -- Email address of the sender
-    email_notification TEXT NULL,                         -- Email notification message
-    calendar_view TINYTEXT NULL,                          -- Default calendar view
-    event_default_state TINYTEXT NULL,                    -- Default calendar view
-    term_event_amenities_singular TINYTEXT NULL,          -- Singular term to use for event amenities
-    term_event_amenities_plural TINYTEXT NULL,            -- Plural term to use for event amenities
-    use_event_amenities BOOLEAN NULL,                     -- Whether amenities are used at all for events
-    use_venue_locations BOOLEAN NULL,                     -- To use Other members as the location of event
-    member_events_allowed BOOLEAN NULL,                   -- If members are allowed to add events.
-    member_events_moderated BOOLEAN DEFAULT '0',          -- If member edits are moderated.
-    non_moderated_status_default INTEGER DEFAULT 20,      -- Non Moderated Member Default Event Status
-    ical_feed_image_size TINYTEXT NULL,                   -- Image size to use in iCal Feed
-    event_display_member_message BOOLEAN DEFAULT '0',     -- Boolean to show member message or not
-    event_member_message TEXT NULL,                       -- Member Message
-    event_add_button_color TINYTEXT NULL,                 -- Color of the search button
-    event_add_button_hidden BOOLEAN NULL,                 -- Option to hide the add event button
-    event_back_to_search_color TINYTEXT NULL,             -- Background Color of the search
-    default_agenda_view TINYTEXT NULL,                    -- Default view file for agenda views
-    agenda_date_background_color TINYTEXT NULL,           -- Background Color of the date
-    agenda_date_text_color TINYTEXT NULL,                 -- Text Color of the date
-    agenda_title_color TINYTEXT NULL,                     -- Color of the Event Title
-    agenda_container_background_color TINYTEXT NULL,      -- Event Container Background Color
-    agenda_container_border_color TINYTEXT NULL,          -- Event Container Border Color
-    agenda_view_max_width TINYTEXT NULL,                  -- Max Width of agenda view
-    detail_ext_links_same_window BOOLEAN DEFAULT '0',     -- Turn on to keep from adding target blank to detail page url's
-    michigan_org_requirements BOOLEAN DEFAULT '0',        -- Turn on required fields for Michigan.org
-    sort_by_featured_in_agenda BOOLEAN DEFAULT '0',       -- Sort by the featured events in agenda view
-    show_search_city BOOLEAN DEFAULT '0',                 -- Show city in search form
-    show_search_region BOOLEAN DEFAULT '0',               -- Show region in search form
-    PRIMARY KEY (id)
-);
-
-----
-
--- Set default event management entry
-INSERT INTO {prefix}management
-    ( id, canonical_event_page, term_event_amenities_singular, term_event_amenities_plural, member_events_allowed, ical_feed_image_size, event_display_member_message, event_member_message, default_agenda_view )
-   VALUES
-    ( 1, 'event-detail', 'Amenity', 'Amenities', 1, 'large', 0, '', 'agenda')
-;
-
-----
-
--- Event iCal Feed imports
-CREATE TABLE {prefix}feed_import (
-    id INT NOT NULL AUTO_INCREMENT,
-    feed_url TEXT NOT NULL,            -- The ical feed url to import
-    created DATETIME NULL,             -- The date this feed was created
-    updated DATETIME NULL,             -- Last time this feed was updated
-    duration INT NULL,                 -- The time it took to fetch the feed
-    events INT NULL,                   -- The number of events last fetched
-    PRIMARY KEY (id)
-);
-
-----
-
--- Event Email Notifications
-CREATE TABLE {prefix}email_notifications (
-    id INT NOT NULL AUTO_INCREMENT,
-    declined_message TEXT NULL,    -- Event declined message
-    approved_message TEXT NULL,    -- Event approved message
-    to_email TINYTEXT NULL,        -- To Email Address
-    from_email TINYTEXT NULL,      -- From Email Address
-    email_notification TEXT NULL,  -- Email notification message
-    PRIMARY KEY (id)
-);
-
-----
-
--- Set default event email settings
-INSERT INTO {prefix}email_notifications
-    ( id, declined_message, approved_message )
-   VALUES
-    ( 1, 'The Event parameters do not comply with our event guidelines.', 'Your event has been approved.' )
-;
diff --git a/setup/databaseScripts/create_database_V0.1.14.sql b/setup/databaseScripts/create_database_V0.1.14.sql
new file mode 100644 (file)
index 0000000..c941c61
--- /dev/null
@@ -0,0 +1,303 @@
+-- Gaslight Media Members Database - Events Add-On
+-- File Created: 08/18/17
+-- Database Version: 0.1.13
+-- Database Creation Script
+--
+-- This file is called to create a new set of tables for this
+-- add-on for the most recent database version for this add-on.
+--
+-- There should only be one such file in this directory
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+
+-- Amenities
+CREATE TABLE {prefix}amenities (
+    id INT NOT NULL AUTO_INCREMENT,
+    active TINYINT(1) NULL,                   -- Amenity is active flag
+    name TINYTEXT NULL,                       -- Name of amenity
+    descr TEXT NULL,                          -- Description of amenity
+    short_descr TINYTEXT NULL,                -- Short description of amenity
+    uses_value BOOLEAN NULL,                  -- Flag indicating whether the amenity requires a quantity number
+    PRIMARY KEY (id),
+    INDEX(name(20))
+);
+
+----
+
+-- Amenity Reference - Links a specific amenity to a specific entity of type ref_type
+CREATE TABLE {prefix}amenity_event (
+    id INT NOT NULL AUTO_INCREMENT,
+    amenity INT NULL,
+    event INT NULL,
+    PRIMARY KEY (id),
+    INDEX(event)
+);
+
+----
+
+-- groups
+CREATE TABLE {prefix}amenity_groups (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NULL,                     -- Name of the Group
+    PRIMARY KEY (id),
+    INDEX(name(20))
+);
+
+----
+
+-- Amenity Group - Links a specific amenity to groups
+CREATE TABLE {prefix}grouped_amenities (
+    id INT NOT NULL AUTO_INCREMENT,
+    group_id INT,                              -- Pointer to the group
+    amenity_id INT,                            -- Pointer to the Amenity
+    searchable BOOLEAN DEFAULT '0',         -- Flag indicating whether the amenity group will show in the search form
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Categories - Categories for events
+CREATE TABLE {prefix}categories (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TINYTEXT NULL,                                   -- Name of event category
+    descr TINYTEXT NULL,                                  -- Description of this category
+    parent INT NULL,                                      -- Parent category, null or 0 if this is a top level category
+    PRIMARY KEY (id),
+    INDEX(parent)
+);
+
+----
+
+-- Event-Category - Categories for specific event records
+CREATE TABLE {prefix}event_categories (
+    id INT NOT NULL AUTO_INCREMENT,
+    event INT NULL,                                       -- Pointer to the event
+    category INT NULL,                                    -- Pointer to the category
+    PRIMARY KEY (id),
+    INDEX(event),
+    INDEX(category)
+);
+
+----
+
+-- Event Recurrence - Defines how an event recurs
+CREATE TABLE {prefix}recurrences (
+    id INT NOT NULL AUTO_INCREMENT,
+    event INTEGER NULL,                                   -- Pointer to event
+    name TINYTEXT NULL,                                   -- Name of this recurrence schedule - used on admin calendar
+    start_time TIME NULL,                                 -- Start time of day for event
+    start_time_only BOOLEAN NULL,                         -- Use end of first occurrence flag
+    end_time TIME NULL,                                   -- End time of day for event - If less than start time, assume a date boundry
+    all_day BOOLEAN NULL,                                 -- Flag indicating if this is an all-day event (informational only)
+    start_date DATE NULL,                                 -- Starting Date (if all_day is selected) Used instead of start_time
+    from_date DATE NULL,                                  -- From Date for recurrences
+    to_date DATE NULL,                                    -- To Date for recurrences
+    recurring BOOLEAN NULL,                               -- Flag indicating that event recurs on a schedule rather than all dates
+    month_of_year SMALLINT UNSIGNED NULL,                 -- Month of year (bitmap)
+    week_of_month TINYINT UNSIGNED NULL,                  -- Week of the month (bitmap)
+    day_of_week TINYINT UNSIGNED NULL,                    -- Day of the week (bitmap)
+    by_day_of_month BOOLEAN NULL,                         -- Flag indicating if selecting by days of the month
+    day_of_month INTEGER UNSIGNED NULL,                   -- Day of the month (bitmap)
+    last_day_of_month BOOLEAN NULL,                       -- Last day of the month
+    specific_dates TEXT NULL,                             -- Serialized array of specific dates added to the recurrence
+    holiday INT NULL,                                     -- Pointer to holidays list (for future development)
+    holiday_offset TINYINT,                               -- Offset from holiday (from -128 to +127 days)
+    PRIMARY KEY (id),
+    INDEX(event)
+);
+
+----
+
+-- Times - List of actual event times for single and recurring events
+CREATE TABLE {prefix}times (
+    id INT NOT NULL AUTO_INCREMENT,
+    event INT NULL,                                       -- Pointer to the primary record for the event
+    custom_event INT NULL,                                -- Pointer to a customized copy of the event record (if set)
+    recur_id INT NULL,                                    -- Pointer to recurrence entry
+    active BOOLEAN NULL,                                  -- Active flag - normally set but used to temporarily disable a specific date
+    start_time DATETIME NULL,                             -- Date and time event starts
+    end_time DATETIME NULL,                               -- Date and time event ends
+    all_day BOOLEAN NULL,                                 -- All Day flag
+    PRIMARY KEY (id),
+    INDEX(event),
+    INDEX(start_time),
+    INDEX(end_time)
+);
+
+----
+
+-- Locations - Locations for event - If there's no location pointing to an event try to use the referenced entity in events table
+CREATE TABLE {prefix}locations (
+    id INT NOT NULL AUTO_INCREMENT,
+    event INT NULL,                                       -- Pointer to the primary or custom event record
+    name TINYTEXT NULL,                                   -- Name of location
+    address TINYTEXT NULL,                                -- Street Address
+    city INT NULL,                                        -- Pointer to city - references main plugin city table
+    state TINYTEXT NULL,                                  -- Two character state abbreviation
+    zip TINYTEXT NULL,                                    -- ZIP/Postal code
+    country TINYTEXT NULL,                                -- Country Code
+    county INT NULL,                                      -- Reference to county table
+    lat FLOAT NULL,                                       -- Latitude of location
+    lon FLOAT NULL,                                       -- Longitude of location
+    region INT NULL,                                      -- Pointer to Region - references main plugin region table
+    phone TINYTEXT NULL,                                  -- Location Phone #
+    url TINYTEXT NULL,                                    -- Location URL
+    email TINYTEXT NULL,                                  -- Location E-Mail Address
+    contact_addon_id INT NULL,                            -- ID of Contact from contact add-on (optional and if available)
+    contact_fname TINYTEXT NULL,                          -- Contact first name for this location (optional)
+    contact_lname TINYTEXT NULL,                          -- Contact last name for this location (optional)
+    contact_phone TINYTEXT NULL,                          -- Contact phone for this location (optional)
+    contact_email TINYTEXT NULL,                          -- Contact E-Mail address (optional)
+    PRIMARY KEY (id),
+    INDEX(event),
+    INDEX(city),
+    INDEX(county),
+    INDEX(region)
+);
+
+----
+
+-- Events - Base event information - May also be entries here referenced by the "times" table for a custom date.
+CREATE TABLE {prefix}events (
+    id INT NOT NULL AUTO_INCREMENT,
+    status INT NULL,                                      -- Status for this event, see config['status']
+    custom_time INT NULL,                                 -- If this is a custom record for a specific instance (date) this points to that times table entry
+    root_event INT NULL,                                  -- Root event pointer if this is a custom record for a specific instance (date) (if custom_time is set)
+    created DATETIME NULL,                                -- Date/Time event was created or date custom event record was created if custom record
+    updated DATETIME NULL,                                -- Date/Time this event record was last updated
+    approved DATETIME NULL,                               -- Date/Ttime this event record was approved
+    ref_type INT NULL,                                    -- Type of entity this event is associated with - See config['ref_type']
+    ref_dest INT NULL,                                    -- Pointer to the specific entity of ref_type this event is associated with
+    hide_address BOOLEAN NULL,                            -- Option to hide address on front-end
+    featured BOOLEAN NULL,                                -- Option to mark as featured event
+    slideshow BOOLEAN NULL,                               -- Option to mark for use in slide show
+    major BOOLEAN NULL,                                   -- Option to mark as a major event
+    name TINYTEXT NULL,                                   -- Name of this event
+    name_slug TINYTEXT NULL,                              -- Slug for this event
+    header TINYTEXT NULL,                                 -- Header text for front-end display - NOT CURRENTLY USED
+    intro TINYTEXT NULL,                                  -- Intro text for front-end display
+    descr TEXT NULL,                                      -- Full description text
+    image TINYTEXT NULL,                                  -- Image file name
+    file1 TINYTEXT NULL,                                  -- File name for a single uploaded file #1
+    file1_descr TINYTEXT NULL,                            -- Description for file uploaded in field "file" #1
+    file2 TINYTEXT NULL,                                  -- File name for a single uploaded file #2
+    file2_descr TINYTEXT NULL,                            -- Description for file uploaded in field "file" #2
+    file3 TINYTEXT NULL,                                  -- File name for a single uploaded file #3
+    file3_descr TINYTEXT NULL,                            -- Description for file uploaded in field "file" #3
+    url TINYTEXT NULL,                                    -- Event URL
+    ticket_url TINYTEXT NULL,                             -- Ticket URL
+    registration_url TINYTEXT NULL,                       -- Registration URL
+    cost TINYTEXT NULL,                                   -- Description of event cost
+    admin_ref_type INT NULL,                              -- Type of admin contact if using a member contact
+    admin_ref_dest INT NULL,                              -- Pointer to admin contact record if using a member contact
+    admin_name TINYTEXT NULL,                             -- Admin Contact Name if not using a member contact
+    admin_org TINYTEXT NULL,                              -- Admin Contact Organization if not using a member contact
+    admin_email TINYTEXT NULL,                            -- Admin Contact E-Mail if not using a member contact
+    admin_phone TINYTEXT NULL,                            -- Admin Contact Phone if not using a member contact
+    free BOOLEAN NULL,                                    -- Event is Free
+    contact_email TINYTEXT NULL,                          -- Contact E-mail address
+    contact_name TINYTEXT NULL,                           -- Contact name
+    contact_phone TINYTEXT NULL,                          -- Event Phone
+    use_member_location BOOLEAN NULL,                     -- Use location of the member (if provided) rather than location table data
+    other_ref_dest INT NULL,                              -- Set location of the event to another member
+    old_event_id INT NULL,                                -- ID of event from old site for reference
+    ical_uid TINYTEXT NULL,                               -- The ical UID for this event.
+    notes TEXT NULL,                                      -- Internal notes for this event
+    PRIMARY KEY (id),
+    INDEX(custom_time),
+    INDEX(root_event),
+    INDEX(ref_type),
+    INDEX(ref_dest),
+    INDEX(featured),
+    INDEX(slideshow),
+    INDEX(major)
+);
+
+----
+
+-- Event Management Settings
+CREATE TABLE {prefix}management (
+    id INT NOT NULL AUTO_INCREMENT,
+    canonical_event_page TINYTEXT NULL,                   -- Canonical page slug for event detail
+    pdf_logo TINYTEXT NULL,                               -- Image for the Top of the PDF
+    footer_text TINYTEXT NULL,                            -- Image for the Top of the PDF
+    to_email TINYTEXT NULL,                               -- Email address of the recipient
+    from_email TINYTEXT NULL,                             -- Email address of the sender
+    email_notification TEXT NULL,                         -- Email notification message
+    calendar_view TINYTEXT NULL,                          -- Default calendar view
+    event_default_state TINYTEXT NULL,                    -- Default calendar view
+    term_event_amenities_singular TINYTEXT NULL,          -- Singular term to use for event amenities
+    term_event_amenities_plural TINYTEXT NULL,            -- Plural term to use for event amenities
+    use_event_amenities BOOLEAN NULL,                     -- Whether amenities are used at all for events
+    use_venue_locations BOOLEAN NULL,                     -- To use Other members as the location of event
+    member_events_allowed BOOLEAN NULL,                   -- If members are allowed to add events.
+    member_events_moderated BOOLEAN DEFAULT '0',          -- If member edits are moderated.
+    non_moderated_status_default INTEGER DEFAULT 20,      -- Non Moderated Member Default Event Status
+    ical_feed_image_size TINYTEXT NULL,                   -- Image size to use in iCal Feed
+    event_display_member_message BOOLEAN DEFAULT '0',     -- Boolean to show member message or not
+    event_member_message TEXT NULL,                       -- Member Message
+    event_add_button_color TINYTEXT NULL,                 -- Color of the search button
+    event_add_button_hidden BOOLEAN NULL,                 -- Option to hide the add event button
+    event_back_to_search_color TINYTEXT NULL,             -- Background Color of the search
+    default_agenda_view TINYTEXT NULL,                    -- Default view file for agenda views
+    agenda_date_background_color TINYTEXT NULL,           -- Background Color of the date
+    agenda_date_text_color TINYTEXT NULL,                 -- Text Color of the date
+    agenda_title_color TINYTEXT NULL,                     -- Color of the Event Title
+    agenda_container_background_color TINYTEXT NULL,      -- Event Container Background Color
+    agenda_container_border_color TINYTEXT NULL,          -- Event Container Border Color
+    agenda_view_max_width TINYTEXT NULL,                  -- Max Width of agenda view
+    detail_ext_links_same_window BOOLEAN DEFAULT '0',     -- Turn on to keep from adding target blank to detail page url's
+    michigan_org_requirements BOOLEAN DEFAULT '0',        -- Turn on required fields for Michigan.org
+    sort_by_featured_in_agenda BOOLEAN DEFAULT '0',       -- Sort by the featured events in agenda view
+    show_search_city BOOLEAN DEFAULT '0',                 -- Show city in search form
+    show_search_region BOOLEAN DEFAULT '0',               -- Show region in search form
+    show_search_county BOOLEAN DEFAULT '0',               -- Show county in search form
+    show_search_category BOOLEAN DEFAULT '1',             -- Show category in search form
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Set default event management entry
+INSERT INTO {prefix}management
+    ( id, canonical_event_page, term_event_amenities_singular, term_event_amenities_plural, member_events_allowed, ical_feed_image_size, event_display_member_message, event_member_message, default_agenda_view )
+   VALUES
+    ( 1, 'event-detail', 'Amenity', 'Amenities', 1, 'large', 0, '', 'agenda')
+;
+
+----
+
+-- Event iCal Feed imports
+CREATE TABLE {prefix}feed_import (
+    id INT NOT NULL AUTO_INCREMENT,
+    feed_url TEXT NOT NULL,            -- The ical feed url to import
+    created DATETIME NULL,             -- The date this feed was created
+    updated DATETIME NULL,             -- Last time this feed was updated
+    duration INT NULL,                 -- The time it took to fetch the feed
+    events INT NULL,                   -- The number of events last fetched
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Event Email Notifications
+CREATE TABLE {prefix}email_notifications (
+    id INT NOT NULL AUTO_INCREMENT,
+    declined_message TEXT NULL,    -- Event declined message
+    approved_message TEXT NULL,    -- Event approved message
+    to_email TINYTEXT NULL,        -- To Email Address
+    from_email TINYTEXT NULL,      -- From Email Address
+    email_notification TEXT NULL,  -- Email notification message
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Set default event email settings
+INSERT INTO {prefix}email_notifications
+    ( id, declined_message, approved_message )
+   VALUES
+    ( 1, 'The Event parameters do not comply with our event guidelines.', 'Your event has been approved.' )
+;
index 104236c..430fdd7 100644 (file)
@@ -49,5 +49,6 @@ $glmMembersEventsDbVersions = array(
     '0.1.11' => array('version' => '0.1.11', 'tables' => 13, 'date' => '01/07/2019'),
     '0.1.12' => array('version' => '0.1.12', 'tables' => 13, 'date' => '01/30/2019'),
     '0.1.13' => array('version' => '0.1.13', 'tables' => 13, 'date' => '02/04/2019'),
+    '0.1.14' => array('version' => '0.1.14', 'tables' => 13, 'date' => '02/13/2019'),
 );
 
diff --git a/setup/databaseScripts/update_database_V0.1.14.sql b/setup/databaseScripts/update_database_V0.1.14.sql
new file mode 100644 (file)
index 0000000..0e0554a
--- /dev/null
@@ -0,0 +1,33 @@
+-- Gaslight Media Members Database  - Events Add-On
+-- File Created: 02/13/19
+-- Database Version: 0.1.14
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+ALTER TABLE {prefix}locations ADD COLUMN county INT NULL;                           -- Reference to county table
+
+----
+
+ALTER TABLE {prefix}management ADD COLUMN show_search_county BOOLEAN DEFAULT '0';   -- Show county in search form
+
+----
+
+ALTER TABLE {prefix}management ADD COLUMN show_search_category BOOLEAN DEFAULT '1'; -- Show category in search form
+
+----
+
+CREATE INDEX event ON {prefix}locations (event);
+
+----
+
+CREATE INDEX city ON {prefix}locations (city);
+
+----
+
+CREATE INDEX county ON {prefix}locations (county);
+
+----
+
+CREATE INDEX region ON {prefix}locations (region);
index f1150e4..b23a294 100755 (executable)
@@ -1,5 +1,4 @@
-
-<!-- Location -->
+{* Location *}
 
 {if $settings.selected_map_interface == 1}
     <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.3/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
@@ -10,7 +9,7 @@
     <script type="text/javascript">var enableDraggable = true;</script>
 {/if}
 
-<!-- Add New City Dialog Box -->
+{* Add New City Dialog Box *}
 <div id="newCityDialog" class="glm-dialog-box" title="Enter a New City">
     <table class="glm-admin-table">
         <tr>
@@ -25,7 +24,7 @@
     <a id="newCityCancel" class="button button-primary glm-right">Cancel</a>
     <input class="newCitySubmit" type="submit" value="Add new City">
 </div>
-<!-- New city hidden input fields go here -->
+{* New city hidden input fields go here *}
 <span id="newCityNames"></span>
 
 {if !$settings.use_venue_locations}
@@ -35,9 +34,9 @@
     <tr>
         <td id="placeLocationDeletesHere" colspan="2">
 
-            <!--  Only doing one event at a time  - edit.html has JAVAscript code to create the first and only one
+            {*  Only doing one event at a time  - edit.html has JAVAscript code to create the first and only one
                 <a id="addLocation" class="button button-primary glm-button glm-right">Add a Location</a>
-            -->
+            *}
 
         </td>
     </tr>
     <tr id="locationContainer" {if $event.fieldData.use_member_location.value || $event.fieldData.other_ref_dest.value}class="glm-hidden"{/if}>
         <td>
             <table id="locationTable" width="100%">
-                <!-- Location forms go here. -->
-{if $locations}
-    {foreach $locations as $loc}
-                <tr class="location_{$loc.id}"><td colspan="2"><hr></td></tr>
-                <tr id="location_{$loc.id}" data-id="{$loc.id}" class="location_{$loc.id} location-form">
-                    <td>
-                        <input type="hidden" name="locID[{$loc.id}]" value="Loc{$loc.id}">
-                        <input type="hidden" class="eLocation" data-id="{$loc.id}" name="loc{$loc.id}_id" value="{$loc.id}">
-                        <input type="hidden" name="Loc{$loc.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
-                        <table width="100%">
-                            <tr>
-                                <th>Location Name:</th>
-                                <td>
-                                    <input id="name_{$loc.id}" type="text" name="Loc{$loc.id}_name" value="{$loc.name|escape}" class="glm-form-text-input-medium">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>Address:</th>
-                                <td>
-                                    <input id="address_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>City</th>
-                                <td class="glm-item-container">
-                                    {if !$lockedToMember}
-                                        <!--  Add new city dialog -->
-                                        <div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
+                {* Location forms go here. *}
+                {if $locations}
+                    {foreach $locations as $loc}
+                        <tr class="location_{$loc.id}"><td colspan="2"><hr></td></tr>
+                        <tr id="location_{$loc.id}" data-id="{$loc.id}" class="location_{$loc.id} location-form">
+                            <td>
+                                <input type="hidden" name="locID[{$loc.id}]" value="Loc{$loc.id}">
+                                <input type="hidden" class="eLocation" data-id="{$loc.id}" name="loc{$loc.id}_id" value="{$loc.id}">
+                                <input type="hidden" name="Loc{$loc.id}_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
+                                <table width="100%">
+                                    <tr>
+                                        <th>Location Name:</th>
+                                        <td>
+                                            <input id="name_{$loc.id}" type="text" name="Loc{$loc.id}_name" value="{$loc.name|escape}" class="glm-form-text-input-medium">
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>Address:</th>
+                                        <td>
+                                            <input id="address_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_address" value="{$loc.address}" class="glm-form-text-input-medium">
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>City</th>
+                                        <td class="glm-item-container">
+                                            {if !$lockedToMember}
+                                                {* Add new city dialog *}
+                                                <div data-id="{$loc.id}" class="button button-secondary glm-right new-city-button">Add a new City</div>
+                                            {/if}
+                                            {* City Selection *}
+                                            <select id="city_{$loc.id}" data-id="{$loc.id}" class="city-picklist" name="Loc{$loc.id}_city">
+                                                <option value="0"></option>
+                                                {foreach from=$loc.city.list item=v}
+                                                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                                        {$v.name}
+                                                    </option>
+                                                {/foreach}
+                                            </select>
+                                        </td>
+                                    </tr>
+                                    {if $settings.enable_counties}
+                                        <tr>
+                                            <th>County:</th>
+                                            <td>
+                                                <select id="county_{$loc.id}" data-id="{$loc.id}" name="Loc{$loc.id}_county">
+                                                    <option value="0"></option>
+                                                    {foreach from=$loc.county.list item=v}
+                                                        <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                                            {$v.name}
+                                                        </option>
+                                                    {/foreach}
+                                                </select>
+                                            </td>
+                                        </tr>
+                                    {else}
+                                        <input type="hidden" name="Loc{$loc.id}_county" value="0">
                                     {/if}
-                                    <!-- City Selection -->
-                                    <select id="city_{$loc.id}" data-id="{$loc.id}" class="city-picklist" name="Loc{$loc.id}_city">
-                                        <option value="0"></option>
-                        {foreach from=$loc.city.list item=v}
-                                        <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
-                                            {$v.name}
-                                        </option>
-                        {/foreach}
-                                    </select>
-                                </td>
-                            </tr>
-                            <tr>
-                                <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
-                                <td>
-                                    <select id="state_{$loc.id}" data-id="{$loc.id}" class="" name="Loc{$loc.id}_state">
-                                        <option value=""></option>
-                        {foreach from=$loc.state.list item=v}
-                                        <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
-                                            {$v.name}{if $eventDefaultState == $v.value} (default){/if}
-                                        </option>
-                        {/foreach}
-                                    </select>
-                                </td>
-                            </tr>
-                            <tr>
-                                <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>ZIP / Postal Code:</th>
-                                <td>
-                                    <input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium zipcode-input">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Country:</th>
-                                <td>
-                                    <select id="country_{$loc.id}" data-id="{$loc.id}" name="Loc{$loc.id}_country">
-                        {foreach from=$loc.country.list item=v}
-                                        <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
-                                            {$v.name} {$v.value}
-                                        </option>
-                        {/foreach}
-                                    </select>
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Region:</th>
-                                <td>
-                                    <select name="Loc{$loc.id}_region">
-                                        <option value="0"></option>
-                        {foreach from=$loc.region.list item=v}
-                                        <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
-                        {/foreach}
-                                    </select>
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Phone:</th>
-                                <td>
-                                    <input type="text" name="Loc{$loc.id}_phone" value="{$loc.phone}" class="glm-form-text-input-medium glm-phone-input">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Web Address:</th>
-                                <td>
-                                    <input type="text" name="Loc{$loc.id}_url" value="{$loc.url}" class="glm-form-text-input-medium">
-                                </td>
-                            </tr>
-                            <tr>
-                                <th>Email Address:</th>
-                                <td>
-                                    <input type="text" name="Loc{$loc.id}_email" value="{$loc.email}" class="glm-form-text-input-medium">
-                                </td>
-                            </tr>
+                                    <tr>
+                                        <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
+                                        <td>
+                                            <select id="state_{$loc.id}" data-id="{$loc.id}" class="" name="Loc{$loc.id}_state">
+                                                <option value=""></option>
+                                                {foreach from=$loc.state.list item=v}
+                                                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                                        {$v.name}{if $eventDefaultState == $v.value} (default){/if}
+                                                    </option>
+                                                {/foreach}
+                                            </select>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>ZIP / Postal Code:</th>
+                                        <td>
+                                            <input id="zip_{$loc.id}" data-id="{$loc.id}" type="text" name="Loc{$loc.id}_zip" value="{$loc.zip}" class="glm-form-text-input-medium zipcode-input">
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>Country:</th>
+                                        <td>
+                                            <select id="country_{$loc.id}" data-id="{$loc.id}" name="Loc{$loc.id}_country">
+                                                {foreach from=$loc.country.list item=v}
+                                                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                                        {$v.name} {$v.value}
+                                                    </option>
+                                                {/foreach}
+                                            </select>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>Region:</th>
+                                        <td>
+                                            <select name="Loc{$loc.id}_region">
+                                                <option value="0"></option>
+                                                {foreach from=$loc.region.list item=v}
+                                                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+                                                {/foreach}
+                                            </select>
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>Phone:</th>
+                                        <td>
+                                            <input type="text" name="Loc{$loc.id}_phone" value="{$loc.phone}" class="glm-form-text-input-medium glm-phone-input">
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>Web Address:</th>
+                                        <td>
+                                            <input type="text" name="Loc{$loc.id}_url" value="{$loc.url}" class="glm-form-text-input-medium">
+                                        </td>
+                                    </tr>
+                                    <tr>
+                                        <th>Email Address:</th>
+                                        <td>
+                                            <input type="text" name="Loc{$loc.id}_email" value="{$loc.email}" class="glm-form-text-input-medium">
+                                        </td>
+                                    </tr>
 
-                        </table>
-                    </td>
-                    <td>
-                        <table width="100%">
-                            <tr>
-                                <th>Location:</th>
-                                <td>
-                                        <span class="glm-right">
-                                    <!-- Only doing one location per event right now
-                                            <a id="deleteLocation_{$loc.id}" data-id="{$loc.id}" class="button button-primary glm-button glm-right delete-location">Delete Location222</a>
-                                    -->
-                                        </span>
-                                    <div id="glm-estimate-location_{$loc.id}" class="button button-secondary">Map Location Using Above Address</div>
-                                    <p>
-                                        {if $settings.selected_map_interface == 1}
-                                            <!--  Leaflet Map -->
-                                            <div id="locationMap_{$loc.id}" style="height: 400px; width: 100%;"></div>
-                                        {/if}
-
-                                        {if $settings.selected_map_interface == 2}
-                                            <!-- Google Map -->
-                                            <div id="locationMap_{$loc.id}" class="glm-map-edit-small" style="height: 400; width: 600px;">(map loads here)</div>
-                                        {/if}
-                                        <p>
-                                            <b>Position:</b>
-                                            &nbsp;Lat <input id="glmLat_{$loc.id}" name="Loc{$loc.id}_lat" type="text" value="{$loc.lat}" class="glm-form-text-input-veryshort">
-                                            &nbsp;Lon <input id="glmLng_{$loc.id}" name="Loc{$loc.id}_lon" type="text" value="{$loc.lon}" class="glm-form-text-input-veryshort">
-                                            &nbsp;&nbsp;<span data-id="{$loc.id}" class="button button-secondary latLonRecenter">Update pointer</span><br>
-                                            You may drag the map marker to the exact location desired. Also consider selecting "Satellite" view to better locate the marker.
-                                        </p>
-                                    </p>
-                                </td>
-                            </tr>
-                        </table>
-                    </td>
-                </tr>
+                                </table>
+                            </td>
+                            <td>
+                                <table width="100%">
+                                    <tr>
+                                        <th>Location:</th>
+                                        <td>
+                                            <span class="glm-right">
+                                                {* Only doing one location per event right now
+                                                    <a id="deleteLocation_{$loc.id}" data-id="{$loc.id}" class="button button-primary glm-button glm-right delete-location">Delete Location222</a>
+                                                *}
+                                            </span>
+                                            <div id="glm-estimate-location_{$loc.id}" class="button button-secondary">Map Location Using Above Address</div>
+                                            <p>
+                                                {if $settings.selected_map_interface == 1}
+                                                    <!--  Leaflet Map -->
+                                                    <div id="locationMap_{$loc.id}" style="height: 400px; width: 100%;"></div>
+                                                {/if}
 
-    {/foreach}
-{/if}
+                                                {if $settings.selected_map_interface == 2}
+                                                    <!-- Google Map -->
+                                                    <div id="locationMap_{$loc.id}" class="glm-map-edit-small" style="height: 400; width: 600px;">(map loads here)</div>
+                                                {/if}
+                                                <p>
+                                                    <b>Position:</b>
+                                                    &nbsp;Lat <input id="glmLat_{$loc.id}" name="Loc{$loc.id}_lat" type="text" value="{$loc.lat}" class="glm-form-text-input-veryshort">
+                                                    &nbsp;Lon <input id="glmLng_{$loc.id}" name="Loc{$loc.id}_lon" type="text" value="{$loc.lon}" class="glm-form-text-input-veryshort">
+                                                    &nbsp;&nbsp;<span data-id="{$loc.id}" class="button button-secondary latLonRecenter">Update pointer</span><br>
+                                                    You may drag the map marker to the exact location desired. Also consider selecting "Satellite" view to better locate the marker.
+                                                </p>
+                                            </p>
+                                        </td>
+                                    </tr>
+                                </table>
+                            </td>
+                        </tr>
+                    {/foreach}
+                {/if}
             </table>
         </td>
     </tr>
 </table>
 
-<!-- Add/Edit Location Template -->
+{* Add/Edit Location Template *}
 
 <table id="addLocationTemplate" class="glm-hidden">
     <tr class="location_{ newLocID }">
         <td>
             <input type="hidden" name="locID[{ newLocID }]" value="{ newLocID }">
-    {if $haveEvent}
-            <input type="hidden" name="{ newLocID }_event" value="{$event.fieldData.id}"> <!-- required to have event id with prefix -->
-    {/if}
+            {if $haveEvent}
+                <input type="hidden" name="{ newLocID }_event" value="{$event.fieldData.id}"> {* required to have event id with prefix *}
+            {/if}
             <table width="100%">
                 <tr>
                 <tr>
                     <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>City</th>
                     <td class="glm-item-container">
                         {if !$lockedToMember}
-                            <!--  Add new city dialog -->
+                            {*  Add new city dialog *}
                             <div data-id="{ newLocID }" class="button button-secondary glm-right new-city-button">Add a new City</div>
                         {/if}
-                        <!-- City Selection -->
+                        {* City Selection *}
                         <select id="city_{ newLocID }" data-id="{ newLocID }" class="city-picklist" name="{ newLocID }_city">
                             <option value="0"></option>
-            {foreach from=$newLocation.fieldData.city.list item=v}
-                            <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
-            {/foreach}
+                            {foreach from=$newLocation.fieldData.city.list item=v}
+                                <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+                            {/foreach}
                         </select>
                     </td>
                 </tr>
+                {if $settings.enable_counties}
+                    <tr>
+                        <th>County:</th>
+                        <td>
+                            <select id="county_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_county">
+                                <option value="0"></option>
+                                {foreach from=$newLocation.fieldData.county.list item=v}
+                                    <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+                                {/foreach}
+                            </select>
+                        </td>
+                    </tr>
+                {else}
+                    <input type="hidden" name="{ newLocID }_county" value="0">
+                {/if}
                 <tr>
                     <th{if $settings.michigan_org_requirements && $lockedToMember} class="glm-required"{/if}>State:</th>
                     <td>
                         <select  id="state_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_state">
-            {foreach from=$newLocation.fieldData.state.list item=v}
-                            <option value="{$v.value}"{if $v.value == $eventDefaultState} selected="selected"{/if}>
-                                {$v.name} {if $eventDefaultState == $v.value} (default) {/if}
-                            </option>
-            {/foreach}
+                            {foreach from=$newLocation.fieldData.state.list item=v}
+                                <option value="{$v.value}"{if $v.value == $eventDefaultState} selected="selected"{/if}>
+                                    {$v.name} {if $eventDefaultState == $v.value} (default) {/if}
+                                </option>
+                            {/foreach}
                         </select>
                     </td>
                 </tr>
                     <th>Country:</th>
                     <td>
                         <select id="country_{ newLocID }" data-id="{ newLocID }" name="{ newLocID }_country">
-            {foreach from=$newLocation.fieldData.country.list item=v}
-                            <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
-                                {$v.name} {$v.value}
-                            </option>
-            {/foreach}
+                            {foreach from=$newLocation.fieldData.country.list item=v}
+                                <option value="{$v.value}"{if $v.default} selected="selected"{/if}>
+                                    {$v.name} {$v.value}
+                                </option>
+                            {/foreach}
                         </select>
                     </td>
                 </tr>
                     <td>
                         <select name="{ newLocID }_region">
                             <option value="0"></option>
-            {foreach from=$newLocation.fieldData.region.list item=v}
-                            <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
-            {/foreach}
+                            {foreach from=$newLocation.fieldData.region.list item=v}
+                                <option value="{$v.value}"{if $v.default} selected="selected"{/if}>{$v.name}</option>
+                            {/foreach}
                         </select>
                     </td>
                 </tr>
                 <tr>
                     <th>Location:</th>
                     <td>
-                    <!-- Only doing one event per location now.
+                        {* Only doing one event per location now.
                         <span class="glm-right"><a id="deleteLocation_{ newLocID }" data-id="{ newLocID }" class="button button-primary glm-button glm-right delete-location">Delete Location</a></span>
-                    -->
+                        *}
                         <div id="glm-estimate-location_{ newLocID }" class="button button-secondary">Map Location Using Address</div>
                         <p>
                             {if $settings.selected_map_interface == 1}
-                                <!--  Leaflet Map -->
+                                {*  Leaflet Map *}
                                 <div id="locationMap_{ newLocID }" style="height: 400px; width: 100%;"></div>
                             {/if}
 
                             {if $settings.selected_map_interface == 2}
-                                <!-- Google Map -->
+                                {* Google Map *}
                                 <div id="locationMap_{ newLocID }" class="glm-map-edit-small" style="height: 400; width: 600px;">(map loads here)</div>
                             {/if}
 
index bf8b127..167d16f 100644 (file)
                         <tr>
                             <th>Front-End Event Search Form</th>
                             <td>
+                                <label> <input type="checkbox" name="show_search_category" {if $eventsSettings.fieldData.show_search_category.value}checked{/if}> Show Category Search</label><br><br>
                                 <label> <input type="checkbox" name="show_search_city" {if $eventsSettings.fieldData.show_search_city.value}checked{/if}> Show City Search</label><br><br>
                                 <label> <input type="checkbox" name="show_search_region" {if $eventsSettings.fieldData.show_search_region.value}checked{/if}> Show Region Search</label><br><br>
+                                <label>
+                                    <input type="checkbox" name="show_search_county" {if $eventsSettings.fieldData.show_search_county.value}checked{/if}{if !$settings.enable_counties} disabled{/if}>
+                                    Show County Search
+                                    {if !$settings.enable_counties} <span style="color: red;">(Counties must be enabled in members)</span>{/if}
+                                </label><br><br>
                             </td>
                         </tr>
                         <tr>
index bacd2f3..c9be0eb 100644 (file)
                 <div class="glm-add-event-form-data">
                     <select name="city" class="glm-required" required>
                         <option value="">Choose City</option>
-                    {foreach $cities as $city_id => $city_name}
-                        <option value="{$city_id}">{$city_name}</option>
-                    {/foreach}
+                        {foreach $cities as $city_id => $city_name}
+                            <option value="{$city_id}">{$city_name}</option>
+                        {/foreach}
+                    </select>
+                </div>
+            </div>
+            {if $settings.enable_counties}
+            <div class="glm-add-event-form-item">
+                <div class="glm-add-event-form-label">
+                    <label>County</label>
+                </div>
+                <div class="glm-add-event-form-data">
+                    <select name="county">
+                        <option value="">Choose County</option>
+                        {foreach $counties as $county_id => $county_name}
+                            <option value="{$county_id}">{$county_name}</option>
+                        {/foreach}
                     </select>
                 </div>
             </div>
+            {/if}
             <div class="glm-add-event-form-item">
                 <div style='color:red;' class="glm-add-event-form-label">
                     <label>
                     <select id="state_30" name="state" required>
                         {foreach $states as $stateAbbr => $stateName}
                             <option value="{$stateAbbr}"{if $state_def == $stateAbbr} selected{/if}>
-                        {$stateName}
-                        </option>
+                                {$stateName}
+                            </option>
                         {/foreach}
                     </select>
                 </div>
index 8d46e3a..bd27835 100644 (file)
                         </select>
                     </div>
                 {/if}
-                <div class="glma-small-8 glma-medium-3 glma-column">
-                    <input class="glm-search-icon glma-right" type="image" alt="Search" src="{$assetsUrl}search-icon-24x24.png">
-                    <select id="glm-event-category" name="category" class="glma-select">
-                        <option value="0">-- All Categories --</option>
-                        {foreach $categories as $cat}
-                            <option value="{$cat.id}"{if $cat.default == 1} selected{/if}>{$cat.name}</option>
-                        {/foreach}
-                    </select>
-                </div>
-                {if $settings.show_search_city || $settings.show_search_region}
+                {if $settings.enable_counties && $settings.show_search_county}
+                    <div class="glma-small-8 glma-medium-3 glma-column">
+                        <select id="glm-event-county" name="county" class="glma-select">
+                            <option value="0">-- All Counties --</option>
+                            {foreach $counties as $county}
+                                <option value="{$county.id}"{if $county.default == 1} selected{/if}>{$county.name}</option>
+                            {/foreach}
+                        </select>
+                    </div>
+                {/if}
+                {if $settings.show_search_category}
+                    <div class="glma-small-8 glma-medium-3 glma-column">
+                        <input class="glm-search-icon glma-right" type="image" alt="Search" src="{$assetsUrl}search-icon-24x24.png">
+                        <select id="glm-event-category" name="category" class="glma-select">
+                            <option value="0">-- All Categories --</option>
+                            {foreach $categories as $cat}
+                                <option value="{$cat.id}"{if $cat.default == 1} selected{/if}>{$cat.name}</option>
+                            {/foreach}
+                        </select>
+                    </div>
+                {/if}
+                {if $settings.show_search_city || $settings.show_search_region || $settings.show_search_county}
                     <div class="glma-small-12 glma-medium-9 glma-columns view-select">
                         <select id="glm-event-view-select" class="glma-select">
                             <option id="agenda-view-option" value="agenda"> Agenda View </option>
 {/if}
 <script type="text/javascript">
     jQuery(document).ready(function($){
-        jQuery('#glm-event-pdf-submit').click(function(){
-            jQuery('#glm-member-event-search').attr('method', 'post');
+        jQuery('#glm-event-pdf-submit').click(function(e){
+            e.preventDefault();
+            var eventForm  = $('#glm-member-event-search');
+            var categories = $(this).data('cats');
+            var oldAction  = eventForm.attr('action');
+            var oldMethod  = eventForm.attr('method');
+            eventForm.attr('action', ajaxUrl + '?action=glm_members_admin_ajax&glm_action=pdfOutput&glm-event-pdf=1&categories=' + categories );
+            eventForm.attr('method', 'post');
+            eventForm.attr('target', '_blank');
+            eventForm.submit();
+            eventForm.attr('action', oldAction );
+            eventForm.attr('method', oldMethod );
+            eventForm.attr('target', '');
+
         });
     });
 </script>