From ca4725bafce2b42da7993a76ea1b72493e2c8a09 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 28 Oct 2016 10:48:18 -0400 Subject: [PATCH] WIP Event Amenities: Event Amenity setting now using the event management name for amenities (beer types). Event amenities now working on edit event page. Event amenities now working for the setting page. Setting: add edit delete amenities working. Event edit page: adding editing deleting amenities to event working. --- classes/data/dataEvents.php | 12 + models/admin/events/list.php | 18 +- models/admin/management/events.php | 1 + models/admin/settings/eventAmenities.php | 63 ++--- setup/adminTabs.php | 7 +- views/admin/events/edit.html | 152 +++++------ views/admin/events/editStatus.html | 14 +- views/admin/management/events.html | 16 +- views/admin/settings/eventAmenities.html | 328 ++--------------------- 9 files changed, 159 insertions(+), 452 deletions(-) diff --git a/classes/data/dataEvents.php b/classes/data/dataEvents.php index abcdd05..145811b 100644 --- a/classes/data/dataEvents.php +++ b/classes/data/dataEvents.php @@ -91,6 +91,7 @@ class GlmDataEvents extends GlmDataAbstract public $dateRange = "start_time >= now()"; public $postFirstAndLastTimes = false; public $postCategories = true; + public $postAmenities = true; /** * Constructor @@ -492,6 +493,17 @@ class GlmDataEvents extends GlmDataAbstract $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A); } + if ( isset( $this->postAmenities ) && $this->postAmenities ) { + $sql = " + SELECT EC.event AS event_id, C.id, C.name + FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "amenities AS C, + ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "amenity_event AS EC + WHERE C.id = EC.amenity + AND EC.event = ".$r['id']." + ;"; + $r['amenities'] = $this->wpdb->get_results($sql, ARRAY_A); + } + if ($this->postAddTimes) { include_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataTimes.php'; $timeData = new GlmDataEventsTimes( $this->wpdb, $this->config ); diff --git a/models/admin/events/list.php b/models/admin/events/list.php index 48e6a4b..d3099a3 100644 --- a/models/admin/events/list.php +++ b/models/admin/events/list.php @@ -195,7 +195,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents // Get a list of categories $Categories = new GlmDataEventsCategories($this->wpdb, $this->config); $categories = $Categories->getListSortedParentChild(false); - + // Get a list of amenities $Amenities = new GlmDataEventsAmenities($this->wpdb, $this->config); $amenities = $Amenities->getList(false); @@ -247,7 +247,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents $this->updateCategories(); $categories = $Categories->getListSortedParentChild(false); - + $this->updateAmenities(); $amenities = $Amenities->getList(false); @@ -356,6 +356,8 @@ class GlmMembersAdmin_events_list extends GlmDataEvents $event = $this->editEntry($this->eventID); + //echo '
$event: ' . print_r( $event, true ) . '
'; + if ($event['status']) { $haveEvent = true; } @@ -381,7 +383,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents $this->updateCategories(); $categories = $Categories->getListSortedParentChild(false); - + $this->updateAmenities(); $amenities = $Amenities->getList(false); @@ -564,7 +566,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents while (list($k, $v) = each($categories)) { $categories[$k]['selected'] = false; } - + // Check if there is a category filter (multi-select) if (isset($_REQUEST['filterCategories']) && count($_REQUEST['filterCategories']) > 0) { @@ -702,10 +704,10 @@ class GlmMembersAdmin_events_list extends GlmDataEvents // require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEventAmenities.php'; // echo "Test 1"; // $Amenities = new GlmDataEventsAmenities($this->wpdb, $this->config); -// +// // $this->amenities = $Amenities->getList("T.id = ".$this->eventID); // echo "
Test 2:" . print_r($this->amenities, true) . " End Test 2
"; -// +// // // Get list of Amenities selected for this Event // $this->eventAmenities = $Amenities->getAmenityRef($this->eventID); // echo "
Test 3:" . print_r($this->eventAmenities, true) . " End Test 3
"; @@ -795,7 +797,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents 'limit' => $limit, 'namesList' => $namesList, 'eventDefaultState' => $this->config['settings']['event_default_state'], - + ); // Return status, any suggested view, and any data to controller @@ -974,7 +976,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents } } - + /* * Check for new Cities being added * diff --git a/models/admin/management/events.php b/models/admin/management/events.php index d36b85d..ff0149c 100644 --- a/models/admin/management/events.php +++ b/models/admin/management/events.php @@ -361,6 +361,7 @@ class GlmMembersAdmin_management_events extends GlmDataEventsManagement // Try to get the first (should be only) entry for general settings. $event_settings = $this->editEntry(1); + //echo '
$event_settings: ' . print_r( $event_settings, true ) . '
'; if ($event_settings === false) { diff --git a/models/admin/settings/eventAmenities.php b/models/admin/settings/eventAmenities.php index ef5bd96..c987030 100644 --- a/models/admin/settings/eventAmenities.php +++ b/models/admin/settings/eventAmenities.php @@ -14,8 +14,7 @@ */ // Load Amenities data abstract -require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataEventAmenities.php'; -require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataEventGroups.php'; +require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/data/dataAmenities.php'; /* * This class performs the work for the default action of the "Members" menu @@ -99,23 +98,20 @@ class GlmMembersAdmin_settings_eventAmenities extends GlmDataEventsAmenities */ public function modelAction ( $actionData = false ) { - echo "TEST 1"; - $success = true; - $haveAmenities = false; - $haveGroups = false; - $amenities = false; - $error = false; - $option2 = ''; - $newAmenity = $this->newEntry(); + $success = true; + $haveAmenities = false; + $haveGroups = false; + $amenities = false; + $error = false; + $option2 = ''; + $newAmenity = $this->newEntry(); + $enable_members = $this->config['settings']['enable_members']; // Check if a category ID is supplied $id = 0; if ( isset( $_REQUEST['id'] ) ) { $id = $_REQUEST['id'] - 0; } - echo "TEST 1.3"; - $groupData = new GlmDataEventGroups( $this->wpdb, $this->config ); - echo "TEST 1.4"; // If there's an action option if ( isset( $_REQUEST['option'] ) ) { switch( $_REQUEST['option'] ) { @@ -187,7 +183,7 @@ class GlmMembersAdmin_settings_eventAmenities extends GlmDataEventsAmenities case 'updateGroup': if ( $id > 0 ) { $groupData->updateEntry( $id ); - } + } break; case 'deleteGroup': @@ -200,30 +196,24 @@ class GlmMembersAdmin_settings_eventAmenities extends GlmDataEventsAmenities array( 'group_id' => $id ), array( '%d' ) ); - } + } break; default: - echo "TEST 4"; $option2 = false; break; } } - echo "TEST 1.4"; if ( isset( $_REQUEST['option2'] ) ) { $option2 = $_REQUEST['option2']; } - echo "TEST 1.5"; // Get a current list of amenities $amenities = $this->getList(); - echo "TEST 2"; - echo '
$amenities: ' . print_r($amenities, true) . '
'; if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) { glmMembersAdmin::addNotice( $amenities, 'DataBlock', 'Amenities Data' ); } - echo "TEST 3"; // If we have list entries - even if it's an empty list $success = true; $haveAmenities = false; @@ -236,23 +226,6 @@ class GlmMembersAdmin_settings_eventAmenities extends GlmDataEventsAmenities $haveAmenities = true; } } - echo "TEST 4"; - $groups = $groupData->getList(); - echo '
$groups: ' . print_r($groups, true) . '
'; - - if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) { - glmMembersAdmin::addNotice( $groups, 'DataBlock', 'Amenity Groups Data' ); - } - - if ( $groups !== false ) { - $success = true; - - // If we have any entries. - if ( count( $groups ) > 0 ) { - $haveGroups = true; - } - } - // If we had a fatal error, redirect to the error page if ($error) { return array( @@ -267,15 +240,15 @@ class GlmMembersAdmin_settings_eventAmenities extends GlmDataEventsAmenities if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { glmMembersAdmin::addNotice( $amenities, 'DataBlock', 'Amenities Data' ); } - echo "TEST FIN"; // Compile template data $templateData = array( - 'haveAmenities' => $haveAmenities, - 'haveGroups' => $haveGroups, - 'amenities' => $amenities, - 'groups' => $groups, - 'option2' => $option2, - 'newAmenity' => $newAmenity, + 'enable_members' => $enable_members, + 'haveAmenities' => $haveAmenities, + 'haveGroups' => $haveGroups, + 'amenities' => $amenities, + 'groups' => null, + 'option2' => $option2, + 'newAmenity' => $newAmenity, ); // Return status, suggested view, and data to controller diff --git a/setup/adminTabs.php b/setup/adminTabs.php index e6865f5..461e29b 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -66,12 +66,13 @@ if (current_user_can('glm_members_members')) { return $addOnTabs; } ); - + add_filter('glm-member-db-add-tab-for-settings', function($addOnTabs) { + //echo '
$config: ' . print_r( $GLOBALS['config'], true ) . '
'; $newTabs = array( array( - 'text' => 'Event Amenities', + 'text' => 'Event ' . $GLOBALS['config']['settings']['term_event_amenities_plural'], 'menu' => 'settings', 'action' => 'eventAmenities' ), @@ -113,4 +114,4 @@ if (current_user_can('glm_members_members')) { ); } -} \ No newline at end of file +} diff --git a/views/admin/events/edit.html b/views/admin/events/edit.html index 4ded1b6..34184e2 100644 --- a/views/admin/events/edit.html +++ b/views/admin/events/edit.html @@ -11,7 +11,7 @@ {else} Return to Events List {/if} - + {if $option == 'edit' || $option == 'update'} Delete this Event

Edit Event

@@ -29,7 +29,7 @@ {else}
- + {/if} {/if} @@ -78,7 +78,7 @@

NOTE: This calendar does not show changes you have made until you have - clicked on the "Update Event" button to save your changes. + clicked on the "Update Event" button to save your changes. @@ -90,7 +90,7 @@ {include file='admin/events/editAdminContact.html'} - +

@@ -154,42 +154,42 @@ recurrencesInited = true; } - if (table == 'glm-table-location') { - + if (table == 'glm-table-location') { + if (!locationsInited) { - + // Make sure there's at least one location {if !$locations} addNewLocationForm(); {/if} - + initLocations(); initNewCity(); locationsInited = true; - + } // Check Use Member Location checkbox memberID = $('#memberSelect').val(); if (memberID == '') { - - // No member selected - Clear checkbox, Dissable checkbox, Show location + + // No member selected - Clear checkbox, Dissable checkbox, Show location $('#useMemberLocationCheckbox').prop('checked', false); $('#useMemberLocationCheckbox').prop('disabled', true); $('#useMemberMessage').addClass('glm-hidden'); $('#notUseMemberMessage').removeClass('glm-hidden'); $('#locationContainer').removeClass('glm-hidden'); - + } else { - + // Member set - Enable checkbox $('#useMemberLocationCheckbox').prop('disabled', false); $('#useMemberMessage').removeClass('glm-hidden'); $('#notUseMemberMessage').addClass('glm-hidden'); - + } } - + if (table == 'glm-table-calendar' && !fullCalendarLoaded) { // **** Should probably move all this to a function and check if it's been initialized already @@ -237,19 +237,19 @@ } -*/ +*/ {/if} }); fullCalendarLoaded = true; - + } // Count remaining characters in field $('.glm-char-count').keyup( function() { glmCharsRemaining($(this)); }); - + }); /* @@ -334,13 +334,13 @@ // Get lat and lon from the input fields var glmLat = $('#glmLat_' + locID).val(); var glmLng = $('#glmLng_' + locID).val(); - + // If Lat and Lon for this event are currently set to default, then set that location to mapLocationAuto true. mapLocationAuto[locID] = false; if (glmLat == {$settings.maps_default_lat} || glmLng == {$settings.maps_default_lon}) { - mapLocationAuto[locID] = true; + mapLocationAuto[locID] = true; } - + // Delete a location $('.delete-location').on( 'click', function() { locID = $(this).attr('data-id'); @@ -351,7 +351,7 @@ initMap(locID); initNewCity(); - + // Listen for changes in the lat/lon inputs $('.latLonRecenter').on('click', function() { @@ -359,22 +359,22 @@ mapLocationAuto[locID] = false; locID = $(this).attr('data-id'); - + // Get lat and lon from the input fields var glmLat = $('#glmLat_' + locID).val(); var glmLng = $('#glmLng_' + locID).val(); - + location[locID] = new google.maps.LatLng(glmLat, glmLng); - + initMap(locID); - + return false; - + }); } - + /* * This is used to initialize all of the locations when the location tab is first clicked. @@ -561,10 +561,10 @@ $('#' + recurID + '_recurUpdated').val(recurID); glmPageUpdateRequired(); }); - - initDateDelete(); + + initDateDelete(); initCalendars(); - + } // Init Recurrence @@ -573,34 +573,34 @@ $('.recur-spec-date-delete').unbind(); $('.recur-spec-date-delete').on('click', function() { if (confirm("Do you want to delete this date?")) { - $(this).remove(); + $(this).remove(); glmPageUpdateRequired(); } }); } - - // Initialize specific date selection calendards + + // Initialize specific date selection calendards function initCalendars() { - + // Initialize Calendar for date selection var renderedExistingEvents = 0; $('.recur-calendar').on('click', function() { recurID = $(this).attr('data-id'); recurName = $('#recurSchedName_' + recurID).val(); - + if (recurName == undefined || recurName == '') { recurName = '(no schedule name)'; } $('#recurCalendarDialog_' + recurID).attr('title', 'Select Dates for ' + recurName); - + $('#recurCalendarDialog_' + recurID).dialog({ minWidth: 600 }); // Color to change calendar cell to (in rgb so it compares to our test below) var calClickColor = 'rgb(173, 216, 230)'; - var newCalEventID = 0; - + var newCalEventID = 0; + var thisCal = $('#recurCalendar_' + recurID).fullCalendar({ header : { left: 'title', @@ -616,97 +616,97 @@ fixedWeekCount : false, eventAfterAllRender: function(view) { - - // Since this will be called again when we add the events below, + + // Since this will be called again when we add the events below, // we have to detect if it's a second call if (renderedExistingEvents != recurID) { renderedExistingEvents = recurID; - + // Collect specified dates for this recurrence $('.recur-spec-date-' + recurID).each(function() { var date = $(this).val(); var dateID = $(this).attr('data-id'); - + var e = { id: dateID, start: date, title: 'Selected' }; $('#recurCalendar_' + recurID).fullCalendar( 'renderEvent', e, true); - + }); } }, - + // Event handler for when a date is clicked dayClick: function(date, allDay, jsEvent, view) { - + var dateHasEvent = false; - + // Check if there's an event for this date thisCal.fullCalendar('clientEvents', function (event) { if (moment(event.start).isSame(date, 'day')) { - + // Say that we had an event already dateHasEvent = true; - + // Remove the event from the calendar thisCal.fullCalendar( 'removeEvents', event.id); - + // Remove the event from the selected dates list $('#recurSpecDate_' + recurID + '_' + event.id).remove(); - + } }); - + // If there wasn't an event already, add one now if (!dateHasEvent) { - + // Create event for this date var e = { id: ++newCalEventID, start: date, title: 'Selected' }; - - // Add an event to this date + + // Add an event to this date thisCal.fullCalendar( 'renderEvent', e, true); - + // Add this edate to our selected dates list $('#recurSpecDates_' + recurID).append( '' + date.format() + '' ); - + initDateDelete(); - + } - + glmPageUpdateRequired(); $('#' + recurID + '_recurUpdated').val(recurID); }, - + // Event handler for when an event is clicked eventClick: function(calEvent, jsEvent, view) { - + var id = calEvent.id; - + // Remove the event from the calendar thisCal.fullCalendar( 'removeEvents', id); - + // Remove the event from the selected dates list $('#recurSpecDate_' + recurID + '_' + id).remove(); glmPageUpdateRequired(); - - } - + + } + }); // fullCalendar - + }); // Click on "Show Calendar" - } - + } + /* * Category Selection */ @@ -825,7 +825,7 @@ minWidth: 400, dialogClass: "glm-dialog-no-close" }); - + /* * Amenity Selection */ @@ -836,7 +836,6 @@ // Get the ID, name, and parent of the amenity var amenityValue = $('#amenitySelect').val(); var amenityName = $('#amenitySelect').find(':selected').text(); - var amenityParent = $('#amenitySelect').find(':selected').attr('data-parent'); // Check if the amenity has already been added var found = false; @@ -849,9 +848,6 @@ // Check if there's a parent parentName = ''; - if (amenityParent != '') { - parentName = amenityParent + ': '; - } // If not found, Add the amenity if (!found) { @@ -1188,7 +1184,7 @@ /* * Misc support items */ - + // Hide description of cost if Free is checked $('#freeEventCheckbox').on('click', function() { if ($('#freeEventCheckbox')[0].checked) { @@ -1197,7 +1193,7 @@ $('#descriptionOfCostField').removeClass('glm-hidden'); } }); - + // Hide location if use member location checked $('#useMemberLocationCheckbox').on('click', function() { if ($(this)[0].checked) { @@ -1231,12 +1227,12 @@ $('.glm-char-count').keyup( function() { glmCharsRemaining($(this)); }); - + // Set masking for phone number fields - see http://digitalbush.com/projects/masked-input-plugin/ $.mask.definitions['e'] = "[A-Za-z0-9: ]"; $(".glm-phone-input").mask("999-999-9999? eeeeeeeeeee"); - + // Flash certain elements for a short time after display $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500); diff --git a/views/admin/events/editStatus.html b/views/admin/events/editStatus.html index d4a4ec7..26257cb 100644 --- a/views/admin/events/editStatus.html +++ b/views/admin/events/editStatus.html @@ -155,16 +155,16 @@ - Amenities + {$settings.term_event_amenities_plural} -
Add a new Amenity
-
+
Add a new {$settings.term_event_amenities_singular}
+
- +
Amenity Name:{$settings.term_event_amenities_singular} Name:
@@ -186,7 +186,7 @@

* Required

Cancel - +
@@ -200,9 +200,9 @@ {/foreach} {else} - + {/if} -    Select a amenity to add to box below.
+    Select a {$settings.term_event_amenities_singular} to add to box below.
{if isset($event.fieldData.amenities) && $event.fieldData.amenities} diff --git a/views/admin/management/events.html b/views/admin/management/events.html index ec0c46d..3b31944 100644 --- a/views/admin/management/events.html +++ b/views/admin/management/events.html @@ -58,8 +58,8 @@ {foreach from=$eventsSettings.fieldData.event_default_state.list item=v}