),
// Facility Type
- 'facility_type' => array (
- 'field' => 'facility_type',
+ 'ref_type' => array (
+ 'field' => 'ref_type',
'type' => 'list',
- 'list' => $this->config['facility_type'],
+ 'list' => $this->config['ref_type'],
'required' => true,
'use' => 'a'
),
}
}
+
+
+ /*
+ * Get the amenitities for a particular reference and destination
+ *
+ * @param integer $ref Reference Type (i.e. member, member_info, location, ...)
+ * @param integer $dest Destination ID (i.e. ID of member info record)
+ *
+ * @return array Array of amenities
+ */
+ public function getAmenityRef($ref_type = false, $ref_dest = false) {
+
+ // Check input for sanity - Refernce type first
+ if ($ref_type == false || ($ref_type-0) <= 0 || !in_array($ref_type, $this->config['ref_type_numb'])) {
+ return false;
+ }
+
+ // Now check for positive integer for destination (record ID)
+ if ($ref_dest == false || ($ref_dest-0) <= 0) {
+ return false;
+ }
+
+ //
+ $sql = "
+ SELECT A.*
+ FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "amenity_ref AS R,
+ ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "amenities AS A
+ WHERE R.ref_type = $ref_type
+ AND R.ref_dest = $ref_dest
+ AND A.id = R.amenity
+ ORDER BY A.name
+ ;";
+ $amenList = $this->wpdb->get_results($sql, ARRAY_A);
+
+ return $amenList;
+
+ }
+
+ /*
+ * Get the amenitities for a particular reference and destination
+ *
+ * @param integer $ref Reference Type (i.e. member, member_info, location, ...)
+ * @param integer $dest Destination ID (i.e. ID of member info record)
+ *
+ * @return array Array of amenities
+ */
+ public function updateAmenityRef($ref_type = false, $ref_dest = false, $amenities = false) {
+
+ // Check input for sanity - Refernce type first
+ if ($ref_type == false || ($ref_type-0) <= 0 || !in_array($ref_type, $this->config['ref_type_numb'])) {
+ return false;
+ }
+
+ // Now check for positive integer for destination (record ID)
+ if ($ref_dest == false || ($ref_dest-0) <= 0) {
+ return false;
+ }
+
+ // Start by deleting all amenities for this destination
+ $sql = "
+ DELETE FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."amenity_ref
+ WHERE ref_type = $ref_type
+ AND ref_dest = $ref_dest
+ ;";
+ $this->wpdb->query($sql);
+
+ // If no amenities supplied, return now with no list
+ if ($amenities == false) {
+ return false;
+ }
+
+ // Since we seem to have a list, add all of these
+ foreach ($amenities as $a) {
+
+ $sql = "
+ INSERT INTO ".GLM_MEMBERS_PLUGIN_DB_PREFIX."amenity_ref
+ ( amenity, ref_type, ref_dest)
+ VALUES
+ ( $a, $ref_type, $ref_dest )
+ ;";
+
+ $this->wpdb->query($sql);
+
+ }
+
+ return $this->getAmenityRef($ref_type, $ref_dest);
+
+ }
+
}
?>
\ No newline at end of file
* @package GLM Member-DB
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @release SVN: $Id: dataMemberType.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @release SVN: $Id: dataCategoryMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
*/
/**
* @package EventManagement
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ * @release SVN: $Id: dataCategoryMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott
* Exp $
*/
class GlmDataCategoryMemberInfo extends GlmDataAbstract
;";
$r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+ // Get Amenity Data for this entry
+ $sql = "
+ SELECT A.*
+ FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenities AS A,
+ ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenity_ref AS R
+ WHERE R.ref_type = ".$this->config['ref_type_numb']['MemberInfo']."
+ AND R.ref_dest = ".$r['id']."
+ AND A.id = R.amenity
+ ;";
+ $r['amenities'] = $this->wpdb->get_results($sql, ARRAY_A);
+
return $r;
}
front-config['list_show_list'] = true
front-config['list_show_search'] = true
front-config['list_search_text'] = true
-front-config['list_search_category'] = false
-front-config['list_search_amenities'] = false
+front-config['list_search_category'] = true
+front-config['list_search_amenities'] = true
front-config['list_search_alpha'] = true
; Front-end Member Listing Options
front-config['list_show_detaillink'] = true
front-config['list_show_tollfree'] = true
front-config['list_show_url'] = true
front-config['list_show_url_newtarget'] = true
+front-config['list_show_email'] = true
front-config['list_show_categories'] = false
front-config['list_show_creditcards'] = false
front-config['list_show_amenities'] = false
front-config['list_map_show_tollfree'] = true
front-config['list_map_show_url'] = true
front-config['list_map_show_url_newtarget'] = true
+front-config['list_map_show_email'] = true
front-config['list_map_show_categories'] = true
front-config['list_map_show_creditcards'] = true
-front-config['list_map_show_amenities'] = false
+front-config['list_map_show_amenities'] = true
; Front-end Member Detail Options
front-config['detail_show_map'] = true
front-config['detail_show_directions'] = true
front-config['detail_show_tollfree'] = true
front-config['detail_show_url'] = true
front-config['detail_show_url_newtarget'] = true
+front-config['detail_show_email'] = true
front-config['detail_show_categories'] = true
front-config['detail_show_creditcards'] = true
front-config['detail_show_amenities'] = true
;
; Facility Type
;
+facility_type[1] = 'Member'
facility_type[10] = 'Hotel - Motel'
facility_type[20] = 'Bed and Breakfast'
facility_type[30] = 'Restaurant'
facility_type[40] = 'Golf'
+facility_type_numb['Member'] = 1
facility_type_numb['HotelMotel'] = 10
facility_type_numb['BedAndBreakfast'] = 20
facility_type_numb['Restaurant'] = 30
admin_debug = true
admin_debug_verbose = true
front_debug = true
+front_debug_verbose = true
googleMapsApiKey = ''
// Get plugin configuration
$configData = parse_ini_file(GLM_MEMBERS_PLUGIN_PATH.'/config/plugin.ini', true);
$config = $configData['common'];
+
// Override parameters according to GLM_HOST_ID
$hostSection = strtolower(GLM_MEMBER_PLUGIN_HOST).':common';
if (isset($configData[$hostSection])) {
name TINYTEXT NULL,
descr TEXT NULL,
short_descr TINYTEXT NULL,
- facility_type INT NULL,
+ ref_type INT NULL,
uses_value BOOLEAN NULL,
PRIMARY KEY (id),
INDEX(name(20))
* Added table settings_general
* Added table settings_terms
* ALTER TABLE wp_glm_members_images CHANGE pending status tinyint;
+* alter table wp_2_glm_members_amenities change column facility_type ref_type integer;
+
TO-DO
$noActive = false;
$categories = false;
$haveCategories = false;
+ $amenities = false;
+ $haveAmenities = false;
+ $memberAmenities = false;
+ $haveMemberAmenities = false;
$regions = false;
$haveRegions = false;
$error = false;
);
}
-
/*
* Get a sorted list of categories.
* These will be sorted so sub-categories fall under their
$haveCategories = true;
}
+ // Get list of Available Member Amenities
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataAmenities.php');
+ $Amenities = new GlmDataAmenities($this->wpdb, $this->config);
+ $amenities = $Amenities->getList("T.ref_type = ".$this->config['ref_type_numb']['MemberInfo']);
+ if (is_array($amenities) && count($amenities) > 0) {
+ $haveAmenities = true;
+ }
+
+ // Get list of Amenities selected for this Member
+ $memberAmenities = $Amenities->getAmenityRef($this->config['ref_type_numb']['MemberInfo'], $memberID);
+ if (is_array($memberAmenities) && count($memberAmenities) > 0) {
+ $haveMemberAmenities = true;
+ }
+
// Lastly, if we have member info, and if this record is active, we need to check for other active records and other things
$categoryMemberInfo = false;
if ($haveMemberInfo) {
// Now get the (possibly updated) category list for this member info record
$categoryMemberInfo = $CategoryMemberInfo->getListWithParents($memberInfoID);
+
+ /*
+ * Get and store any selected amenities
+ *
+ * Makes an array of amenities IDs then stores that
+ */
+ $selectedAmenities = array();
+ $newAmenity = false;
+ if (isset($_REQUEST['amenity']) && is_array($_REQUEST['amenity']) && count($_REQUEST['amenity']) > 0) {
+
+ // For each selected amenity
+ foreach ($_REQUEST['amenity'] as $key) {
+
+ // Make sure key is an integer
+ $key = intval($key -0);
+
+ // Add to selected amenities list
+ $selectedAmenities[$key] = $key;
+
+ } // For each amityy being submitted
+
+ // Update the selected amenities for this member information record, returns new list
+ $memberAmenities = $Amenities->updateAmenityRef($this->config['ref_type_numb']['MemberInfo'], $memberID, $selectedAmenities);
+
+ // 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') {
+ $memberAmenities = $Amenities->updateAmenityRef($this->config['ref_type_numb']['MemberInfo'], $memberID);
+ }
+
} // Have member info
// If we have a member record
'haveCategories' => $haveCategories,
'categories' => $categories,
'categoryMemberInfo' => $categoryMemberInfo,
+ 'haveAmeenities' => $haveAmenities,
+ 'amenities' => $amenities,
+ 'haveMemberAmenities' => $haveMemberAmenities,
+ 'memberAmenities' => $memberAmenities,
'haveImageGallery' => $haveImageGallery,
'imageGallery' => $imageGallery,
'noActive' => $noActive,
}
+ // Get amenity filter data
+ $amenityData = false;
+ $amenSelected = '';
+ if ($this->config['front-config']['list_search_amenities']) {
+
+ // Get amenity data for search pick list
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataAmenities.php');
+ $Amenities = new GlmDataAmenities($this->wpdb, $this->config);
+ $amenityData = $Amenities->getList('T.ref_type = '.$this->config['ref_type_numb']['MemberInfo']);
+
+ // Add default flag as false to all entries
+ foreach ($amenityData as $k=>$v) {
+ $amenityData[$k]['default'] = false;
+ }
+
+ // Check if an amenity has been submitted
+ if (isset($_REQUEST['amenitySearch'])) {
+ $amenSelected = $_REQUEST['amenitySearch'] - 0;
+
+ // If we have an amenity ID
+ if ($amenSelected > 0) {
+
+ // Build query to get the member ID's that have the selected amenity
+ $where .= $whereSep." T.id in (
+ SELECT DISTINCT(ref_dest)
+ FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."amenity_ref
+ WHERE amenity = $amenSelected
+ AND ref_type = ".$this->config['ref_type_numb']['MemberInfo']."
+ )";
+ $whereSep = ' AND ';
+
+ // Set default to true for the selected category
+ $amenityData[$amenSelected]['default'] = true;
+
+ } // If we have a sane amenity ID
+ } // If an amenity search has been selected
+ } // it doing amenity search
+
// Only look at active member information
$where .= $whereSep." T.status = ".$this->config['status_numb']['Active'];
'textSearch' => $textSearch,
'categories' => $categoryData,
'catSelected' => $catSelected,
+ 'amenities' => $amenityData,
+ 'amenSelected' => $amenSelected,
'alphaList' => $alphaList,
'alphaSelected' => $alphaSelected
);
</td>
</tr>
<tr>
- <th class="glm-required">Facility Type:</th>
+ <th class="glm-required">Used With:</th>
<td>
- <select name="facility_type">
+ <select name="ref_type">
<option value=""></option>
- {foreach from=$newAmenity.fieldData.facility_type.list item=v}
+ {foreach from=$newAmenity.fieldData.ref_type.list item=v}
<option value="{$v.value}">{$v.name}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
- <th class="glm-required">Facility Type:</th>
+ <th class="glm-required">Used With:</th>
<td>
- <select id="editAmenityFacility" name="facility_type">
+ <select id="editAmenityRef" name="ref_type">
<option value=""></option>
- {foreach from=$newAmenity.fieldData.facility_type.list item=v}
+ {foreach from=$newAmenity.fieldData.ref_type.list item=v}
<option value="{$v.value}">{$v.name}</option>
{/foreach}
</select>
<thead>
<tr>
<th>Amenity</th>
- <th>Facility Type</th>
+ <th>Used With</th>
<th>Uses Value</th>
<th>Description</th>
<th>Short Description</th>
<tr class="alternate">
{/if}
<td>
- <a class="editAmenity" data-amenityID="{$t.id}" data-facilityTypeID="{$t.facility_type.value}" data-amenityUsesValue="{$t.uses_value.value}">{$t.name}</a>
+ <a class="editAmenity" data-amenityID="{$t.id}" data-refTypeID="{$t.ref_type.value}" data-amenityUsesValue="{$t.uses_value.value}">{$t.name}</a>
</td>
- <td id="editAmenityFacilityType_{$t.id}">
- {$t.facility_type.name}
+ <td id="editAmenityRefType_{$t.id}">
+ {$t.ref_type.name}
</td>
<td id="editAmenityUsesValue_{$t.id}" >
{$t.uses_value.name}
$('.editAmenity').click( function() {
var amenityID = $(this).attr('data-amenityID');
var amenityName = $(this).text();
- var amenityFacilityTypeID = $(this).attr('data-facilityTypeID');
+ var amenityRefTypeID = $(this).attr('data-refTypeID');
var amenityUsesValue = parseInt($(this).attr('data-amenityUsesValue'));
var amenityDescr = $('#editAmenityDescr_' + amenityID).html();
var amenityShortDescr = $('#editAmenityShortDescr_' + amenityID).html();
$('#editAmenityID').val(amenityID);
$('#editAmenityName').val(amenityName.trim());
- $('#editAmenityFacility').val(amenityFacilityTypeID);
+ $('#editAmenityRef').val(amenityRefTypeID);
$('#editAmenityUsesValue').prop('checked', amenityUsesValue);
$('#editAmenityDescr').val(amenityDescr.trim());
$('#editAmenityShortDescr').val(amenityShortDescr.trim());
<input type="hidden" name="category[{$c.category}]" value="{$c.category}">
</div>
{/foreach}
+ {/if}
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <th>Amenities</th>
+ <td class="glm-item-container">
+ <!-- Amenity Selection -->
+ <select name="amenitySelect" id="amenitySelect">
+ <option id="amenityNone" value=""></option>
+ {foreach from=$amenities item=v}
+ <option value="{$v.id}">
+ {$v.name}
+ </option>
+ {/foreach}
+ </select> Select an amenity to add to box below.<br>
+ <div id="activeAmenities" class="glm-dynSelect-box">
+ {if $haveMemberAmenities}
+ {foreach from=$memberAmenities item=c}
+ <div data-id="{$c.id}" class="glm-dynSelect-item glm-members-amenity">
+ {$c.name}
+ <span data-id="{$c.id}" class="glm-dynSelect-delete amenityDelete">X</span>
+ <input type="hidden" name="amenity[{$c.id}]" value="{$c.id}">
+ </div>
+ {/foreach}
{/if}
</div>
</td>
if (!found) {
$('#activeCategories').append('<div data-id="' + catValue
+ '" class="glm-dynSelect-item glm-members-catgegory">'
- + parentName + catName.trim() + ' <span data-id="' + catValue + '" class="glm-dynSelect-delete catDelete">X</span>'
+ + parentName + catName.trim() + ' <span class="glm-dynSelect-delete catDelete">X</span>'
+ '<input type="hidden" name="category[' + catValue + ']" value="' + catValue + '"></div>');
}
// Action to de-select a category
$('.catDelete').live('click', function() {
- var id = $(this).attr('data-id');
- $(".glm-members-category, [data-id='" + id + "']").remove();
+ $(this).parent().remove();
});
/*
dialogClass: "glm-dialog-no-close"
});
+ /*
+ * Action to select an Amenity
+ */
+ $('#amenitySelect').change( function() {
+
+ // Get the ID, name
+ var amenValue = $('#amenitySelect').val();
+ var amenName = $('#amenitySelect').find(':selected').text();
+
+ if (amenValue == '') {
+ return;
+ }
+
+ // Check if the amenity has already been added
+ var found = false;
+ $(".glm-members-amenity").each( function() {
+ var id = $(this).attr('data-id');
+ if (id == amenValue) {
+ found = true;
+ }
+ });
+
+ // If not found, Add the category
+ if (!found) {
+ $('#activeAmenities').append('<div data-id="' + amenValue
+ + '" class="glm-dynSelect-item glm-members-amenity">' + amenName
+ + ' <span class="glm-dynSelect-delete amenityDelete">X</span>'
+ + '<input type="hidden" name="amenity[' + amenValue + ']" value="' + amenValue + '"></div>');
+ }
+
+ // Reset picklist
+ $('#amenitySelect').val('');
+
+ });
+
+ // Action to de-select an Amenity
+ $('.amenityDelete').live('click', function() {
+ $(this).parent().remove();
+ });
+
/*
* New City Dialog
*/
{if $member.phone && $detail_show_phone}<br><b>Phone:</b> {$member.phone}{/if}
{if $member.toll_free && $detail_show_tollfree}<br><b>Toll Free:</b> {$member.toll_free}{/if}
{if $member.url && $detail_show_url}<br><b>Web site:</b> <a href="{$member.url}"{if $detail_show_url_newtarget} target="_blank"{/if}>{$member.url}</a>{/if}
- {if $member.email}<br><b>E-Mail Address:</b> <a href="mailto:{$m.email}">{$member.email}</a>{/if}
+ {if $member.email && $detail_show_email}<br><b>E-Mail Address:</b> <a href="mailto:{$member.email}">{$member.email}</a>{/if}
{if $member.region.value && $detail_show_region}<br><b>Region:</b> {$member.region.name}{/if}
</div>
<!-- Member Logo - Medium and up-->
</ul>
</p>
{/if}
- {if $detail_show_amenities}
+ {if $member.amenities && $detail_show_amenities}
<p>
- Amenities go here
+ <b>{$term_member_cap} Amenities</b>
+ <ul>
+ {foreach $member.amenities as $a}
+ <li>
+ {$a.name}
+ </li>
+ {/foreach}
+ </ul>
</p>
{/if}
</div>
</div>
{/if}
{if $list_search_amenities}
- <div class="row"><div class="small-12 columns">Amenity search goes here</div></div>
+
+ <div class="row">
+ <div class="small-12 medium-5 columns">
+ {$term_member_cap} Amenity:
+ <select name="amenitySearch" id="amenitySelect">
+ <option value=""></option>
+ {foreach from=$amenities item=v}
+ <option value="{$v.id}" {if $v.default} selected="selected"{/if}>
+ {$v.name}
+ </option>
+ {/foreach}
+ </select>
+ </div>
+ </div>
+
{/if}
<div class="row"><div class="small-12 columns"><input type="submit" value="Search"></div></div>
</div>
{if $m.city.name}{$m.city.name}{if $m.state.name}, {/if}{/if}{if $m.state.name}{$m.state.name}{/if}{if $m.zip} {$m.zip}{/if}
{/if}
{if $m.country.name && $list_show_country}<br>{$m.country.name}{/if}
- {/if} {*list_show_address*}
+ {/if}
{if $m.phone && $list_show_phone}<br><b>Phone:</b> {$m.phone}{/if}
{if $m.toll_free && $list_show_tollfree}<br><b>Toll Free:</b> {$m.toll_free}{/if}
{if $m.url && $list_show_url}<br><b>Web site:</b> <a href="{$m.url}"{if $list_show_url_newtarget} target="_blank"{/if}>{$m.url}</a>{/if}
- {if $m.email}<br><b>E-Mail Address:</b> <a href="mailto:{$m.email}">{$m.email}</a>{/if}
+ {if $m.email && $list_show_email}<br><b>E-Mail Address:</b> <a href="mailto:{$m.email}">{$m.email}</a>{/if}
{if $m.region.value && $list_show_region}<br><p><b>Region:</b> {$m.region.name}{/if}
</div>
<!-- Member Logo - Medium and up-->
</ul>
</p>
{/if}
- {if $list_show_amenities}
+ {if $m.amenities && $list_show_amenities}
<p>
- <p>Amenities go here</p>
+ <b>{$term_member_cap} Amenities</b>
+ <ul>
+ {foreach $m.amenities as $A}
+ <li>
+ {$A.name}
+ </li>
+ {/foreach}
+ </ul>
</p>
{/if}
</div>
{if $m.phone && $list_map_show_phone}<b>Phone:</b> {$m.phone}<br>{/if}
{if $m.toll_free && $list_map_show_tollfree}<b>Toll Free:</b> {$m.toll_free}<br>{/if}
{if $m.url && $list_map_show_url}<b>Web site:</b> <a href="{$m.url}"{if $list_map_show_url_newtarget} target="_blank"{/if}>{$m.url}</a><br>{/if}
- {if $m.email}<b>E-Mail Address:</b> <a href="mailto:{$m.email}">{$m.email}</a><br>{/if}
+ {if $m.email && $list_map_show_email}<b>E-Mail Address:</b> <a href="mailto:{$m.email}">{$m.email}</a><br>{/if}
{if $m.region.value && $list_map_show_region}<p><b>Region:</b> {$m.region.name}</p>{/if}
</p>
{if $m.descr && $list_map_show_description}{$m.descr}<br>{/if}
</div>
{/if}
{if $list_map_show_amenities}
- <div>
- <p>Amenities go here</p>
+ <div class="glm-member-list-items">
+ <b>Amenities:</b>
+ <ul>
+ {foreach $m.amenities as $a}
+ <li>{$a.name}</li>
+ {/foreach}
+ </ul>
</div>
{/if}
</div>