Add the venues so they get pulled into the select box for search.
Add venue id for search query.
{
public $wpdb;
public $config;
+ public $memberList = array();
/**
* __construct
$this->config = $config;
parent::__construct(false, false);
+ if ( $this->config['settings']['use_venue_locations'] ) {
+ $this->getMemberList();
+ }
+
+ }
+
+ public function getMemberList()
+ {
+ $this->memberList = apply_filters('member_names_and_ids', '');
}
public function printEvents()
public function getMembers()
{
$members = array();
- $memberData = apply_filters('member_names_and_ids', '');
- if ( isset( $memberData ) && is_array( $memberData) && !empty( $memberData) ) {
- foreach ( $memberData as $member ) {
+
+ if ( isset( $this->memberList ) && is_array( $this->memberList ) && !empty( $this->memberList ) ) {
+ foreach ( $this->memberList as $member ) {
// check to see if this member has an event (current)
$sql = "
SELECT count(id)
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
WHERE ref_dest = %d
+ AND status = 10
AND id IN (
SELECT event
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
}
}
}
+
return $members;
}
+ public function getVenues() {
+ $venues = array();
+
+ if ( isset( $this->memberList ) && is_array( $this->memberList ) && !empty( $this->memberList ) ) {
+ foreach ( $this->memberList as $member ) {
+ // check to see if this member has an event (current)
+ $sql = "
+ SELECT count(id)
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
+ WHERE other_ref_dest = %d
+ AND status = 10
+ AND id IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
+ WHERE active
+ AND start_time >= NOW())";
+ $result = $this->wpdb->get_var( $this->wpdb->prepare( $sql, $member['id'] ) );
+
+ if ( $result > 0 ) {
+ $venues[$member['id']] = array(
+ 'id' => $member['id'],
+ 'name' => $member['name']
+ );
+ }
+ }
+ }
+
+ return $venues;
+ }
+
/**
* getModelEventsData
*
* @param integer $limit Number of events to return (optional)
* @param integer $memberId Member ID if filtering by member
* @param integer $amenityId Amenity id for filter
+ * @param integer $venueId Venue id for filter
*
* @access public
* @return array events
*/
- public function getModelEventsData( $categoryId = null, $limit = null, $memberId = null, $amenityId = null )
+ public function getModelEventsData( $categoryId = null, $limit = null, $memberId = null, $amenityId = null, $venueId = null )
{
$this->postAddTimes = true;
)";
}
+ if ( $venueId = filter_var( $venueId, FILTER_VALIDATE_INT ) ) {
+ $whereParts[] = "
+ T.other_ref_dest = {$venueId}
+ AND T.id IN (
+ SELECT event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
+ WHERE status = " . $this->config['status_numb']['Active'] . "
+ AND " . $this->dateRange . "
+ )
+ ";
+ }
+
// If a category ID is supplied
if ( $catId = filter_var( $categoryId, FILTER_VALIDATE_INT ) ) {
//$events = $this->getEventsByCategory( $catId, $limit );
$amenities = array();
$memberId = null;
$members = array();
+ $venues = array();
+ $venueId = null;
// If a memberID has been specified, limit to that member
if ( isset( $actionData['request']['member'] ) ) {
$search = true;
$action = 'event-list';
}
+ if ( isset( $_REQUEST['venue'] ) && $venueId = filter_var( $_REQUEST['venue'], FILTER_VALIDATE_INT ) ) {
+ $search = true;
+ $action = 'event-list';
+ }
if ( isset( $_REQUEST['member'] ) && $memberId = filter_var( $_REQUEST['member'], FILTER_VALIDATE_INT ) ) {
$search = true;
$action = 'event-list';
}
$categories = $this->getCategories();
- $amenities = $this->getAmenities();
- $members = $this->getMembers();
+ if ( $this->config['settings']['use_event_amenities'] ) {
+ $amenities = $this->getAmenities();
+ }
+ // get venues only if use_venue_locations is turned on
+ if ( $this->config['settings']['use_venue_locations'] ) {
+ $members = $this->getMembers();
+ $venues = $this->getVenues();
+ }
+
+
wp_register_script(
'event-dashboard-js',
GLM_MEMBERS_EVENTS_PLUGIN_BASE_URL . '/js/dashboard.js',
switch ( $action ) {
case 'front-page':
- $events = $this->getModelEventsData( $categoryId, $limit, $memberId, $amenityId );
+ $events = $this->getModelEventsData( $categoryId, $limit, $memberId, $amenityId, $venueId );
break;
case 'event-list-name':
- $events = $this->getModelEventsData( $eventNameSearch, null, $memberId, $amenityId );
+ $events = $this->getModelEventsData( $eventNameSearch, null, $memberId, $amenityId, $venueId );
if ( !$view ) {
$view = 'agenda.html';
}
case 'event-list':
$this->postAddLocations = true;
$this->postAddRecurrences = true;
- $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId );
+ $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId, $venueId );
if ( !$view ) {
$view = 'agenda.html';
}
include_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/SetaPDF/Autoload.php';
$this->postAddLocations = true;
$this->postAddRecurrences = true;
- $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId );
+ $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId, $venueId );
$this->postAddLocations = false;
$this->postAddRecurrences = false;
if ( !$view ) {
$view = 'agenda.html';
}
- $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId );
+ $events = $this->getModelEventsData( $categoryId, null, $memberId, $amenityId, venueId );
$this->postAddRecurrences = false;
break;
}
'amenities' => $amenities,
'memberId' => $memberId,
'members' => $members,
+ 'venues' => $venues,
+ 'venueId' => $venueId,
'events' => $events,
'eventsByDate' => $eventsByDate,
'fromDate' => $fromDate,
{/foreach}
</select>
</div>
- <div class="small-6 medium-3 column">
- <label class="beer-types-label">Beer Types</label>
- <select id="glm-event-beer-type" name="amenity">
- <option value="">-- All Beer Types --</option>
- {foreach $amenities as $amm}
- <option value="{$amm.id}"{if $amenityId == $amm.id} selected{/if}>{$amm.name}</option>
- {/foreach}
- </select>
- </div>
- <div class="small-6 medium-3 column">
- <label class="venues-label">Venues</label>
- <select id="glm-event-venue" name="location">
- <option value="">-- All Venues --</option>
- </select>
- </div>
- <div class="small-6 medium-3 column">
- <label class="brewery-label">Brewery</label>
- <select id="glm-event-member" name="member">
- <option value="">-- All Breweries --</option>
- {foreach $members as $member}
- <option value="{$member.id}"{if $memberId == $member.id} selected{/if}>{$member.name}</option>
- {/foreach}
- </select>
- </div>
+ {if $settings.use_event_amenities}
+ <div class="small-6 medium-3 column">
+ <label class="beer-types-label">Beer Types</label>
+ <select id="glm-event-beer-type" name="amenity">
+ <option value="">-- All Beer Types --</option>
+ {foreach $amenities as $amm}
+ <option value="{$amm.id}"{if $amenityId == $amm.id} selected{/if}>{$amm.name}</option>
+ {/foreach}
+ </select>
+ </div>
+ {/if}
+ {if $settings.use_venue_locations}
+ <div class="small-6 medium-3 column">
+ <label class="venues-label">Venues</label>
+ <select id="glm-event-venue" name="venue">
+ <option value="">-- All Venues --</option>
+ {foreach $venues as $venue}
+ <option value="{$venue.id}"{if $venueId == $venue.id} selected{/if}>{$venue.name}</option>
+ {/foreach}
+ </select>
+ </div>
+ <div class="small-6 medium-3 column">
+ <label class="brewery-label">Brewery</label>
+ <select id="glm-event-member" name="member">
+ <option value="">-- All Breweries --</option>
+ {foreach $members as $member}
+ <option value="{$member.id}"{if $memberId == $member.id} selected{/if}>{$member.name}</option>
+ {/foreach}
+ </select>
+ </div>
+ {/if}
<!-- <input class="glm-search-icon right" type="image" alt="Search" src="{$assetsUrl}search-icon-24x24.png">-->
</div>
<div class="row">
<input id="glm-event-to" name="glm_event_to" value="{$toDate}">
</div>
</div>
-
+
</div>
<div class="small-12 medium-6 column">
-
+
{if !$eventId}
<input class="right" type="image" title="Print PDF" id="glm-event-pdf-submit" src="{$assetsUrl}print-icon-24x24.png">
{else}