*/
private $_memberCategories;
+ /**
+ * member counties the banner is assigned to
+ * @var type
+ * @access private
+ */
+ private $_memberCounties;
+
// }}}
// {{{ __construct()
$business = null,
array $toolboxPages = null,
Toolkit_Members_CategoriesIterator $memberCategories = null,
+ array $memberCounties = null,
$description = null,
$id = null,
$embedcode = false
) {
- $this->_image = $image;
- $this->_position = $position;
- $this->_url = $url;
- $this->_active = $active;
- $this->_external = $external;
- $this->_business = $business;
- $this->_campaign = $campaign;
- $this->_campaignId = $campaign->getId();
- $this->_toolboxPages = $toolboxPages;
- $this->_memberCategories = $memberCategories;
- $this->_description = $description;
- $this->_id = $id;
- $this->_embedcode = $embedcode;
- }
+ $this->_image = $image;
+ $this->_position = $position;
+ $this->_url = $url;
+ $this->_active = $active;
+ $this->_external = $external;
+ $this->_business = $business;
+ $this->_campaign = $campaign;
+ $this->_campaignId = $campaign->getId();
+ $this->_toolboxPages = $toolboxPages;
+ $this->_memberCategories = $memberCategories;
+ $this->_memberCounties = $memberCounties;
+ $this->_description = $description;
+ $this->_id = $id;
+ $this->_embedcode = $embedcode;
+ }
// }}}
// {{{ create()
$business = null,
array $toolboxPages = null,
Toolkit_Members_CategoriesIterator $memberCategories = null,
+ array $memberCounties = null,
$description = null,
$id = null,
$embedcode = false
$business,
$toolboxPages,
$memberCategories,
+ $memberCounties,
$description,
$id,
$embedcode
$row['business'],
self::_fetchToolboxPages($dbh, $id),
$memberCategories,
+ self::_fetchMemberCounties($dbh, $id),
$row['description'],
$id,
$row['embedcode']
* @return object Return description (if any) ...
* @access private
*/
- private function _fetchMemberCategories(PDO $dbh, $id)
+ static private function _fetchMemberCategories(PDO $dbh, $id)
{
$memberCategoriesIterator = Toolkit_Members_CategoriesIterator::create();
$sql = "
* @return array toolbox page ids
* @access private
*/
- private function _fetchToolboxPages(PDO $dbh, $id)
+ static private function _fetchToolboxPages(PDO $dbh, $id)
{
$sql = "
- SELECT *
- FROM banners2navpages
- WHERE bid = :bid";
+ SELECT *
+ FROM banners2navpages
+ WHERE bid = :bid";
$stmt = $dbh->prepare($sql);
$stmt->bindParam(':bid', $id, PDO::PARAM_INT);
// }}}
+ static private function _fetchMemberCounties(PDO $dbh, $banner)
+ {
+ $counties = array();
+ try {
+ $sql = "
+ SELECT *
+ FROM members.banners2counties
+ WHERE banner = :banner";
+ $stmt = $dbh->prepare($sql);
+ $stmt->bindParam(':banner', $banner, PDO::PARAM_INT);
+ $stmt->execute();
+ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $counties[] = $row['county'];
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ return $counties;
+ }
+
// {{{ getActive()
}
// }}}
+ public function getMemberCounties()
+ {
+ return $this->_memberCounties;
+ }
// {{{ getPosition()
$this->_id
);
}
+ $this->_removeMemberCounties($dbh, $this->_id);
+ $this->_updateMemberCounties(
+ $dbh, $this->_id, $this->_memberCounties
+ );
return $dbh->commit();
} catch (PDOException $e) {
}
// }}}
+ private function _updateMemberCounties(
+ PDO $dbh,
+ $banner,
+ $counties
+ ) {
+ if (!empty($counties)) {
+ $sql = Toolkit_Common::createSQLInsert(
+ 'banners2counties',
+ array('banner', 'county')
+ );
+ $stmt = $dbh->prepare($sql);
+ $stmt->bindParam(':banner', $banner, PDO::PARAM_INT);
+ foreach ($counties as $i) {
+ // make sure we have an integer
+ if (filter_var($i, FILTER_VALIDATE_INT)) {
+ $stmt->bindParam(':county', $i, PDO::PARAM_INT);
+ $stmt->execute();
+ }
+ }
+ }
+ }
// {{{ _updateBannerCategories()
/**
// }}}
+ private function _removeMemberCounties(PDO $dbh, $banner)
+ {
+ $sql = "
+ DELETE FROM banners2counties
+ WHERE banner = :banner";
+
+ $stmt = $dbh->prepare($sql);
+ $stmt->bindParam(':banner', $banner, PDO::PARAM_INT);
+ $stmt->execute();
+ }
+
// {{{ _removeBannerCategories()
/**
FROM banners2navpages
WHERE catid = :pageCatid";
+ if ($county = filter_var($_REQUEST['countyId'], FILTER_VALIDATE_INT)) {
+ $selectBannersAssignedToCounties = "
+ UNION
+ SELECT banner
+ FROM banners2counties
+ WHERE county = {$county}";
+ } else {
+ $selectBannersAssignedToCounties = '';
+ }
+
$memberCatsOnPage = $this->_getMemberCatsAvailableOnPage(
$pdo,
$categoriesIterator,
INTERSECT
($selectBannersAssignedToPage
UNION
- $selectBannersAssignedToMemberCatsOnPage)
+ $selectBannersAssignedToMemberCatsOnPage
+ $selectBannersAssignedToCounties)
INTERSECT
($bannersWithinRunDate)";
--- /dev/null
+DROP TABLE IF EXISTS members.banners2counties CASCADE;
+
+CREATE TABLE members.banners2counties(
+ banner INTEGER NOT NULL,
+ county INTEGER NOT NULL
+);
+
+GRANT ALL ON members.banners2counties TO nobody;
'contact_email' => $banner->getCampaign()->getContact()->getEmail(),
'report_frequency' => $banner->getCampaign()->getReportFrequency(),
'pages' => $banner->getToolboxPages(),
+ 'member_counties' => $banner->getMemberCounties(),
'sdate' => array(
'm' => $banner->getCampaign()->getSDate()->getMonth(),
'd' => $banner->getCampaign()->getSDate()->getDay(),
)
);
}
+ $e[] = array(
+ 'type' => 'select',
+ 'req' => false,
+ 'name' => 'member_counties',
+ 'display' => 'Member Counties',
+ 'opts' => array(
+ '' => '-- None --'
+ ) + $this->getMemberCounties($dbh),
+ 'att' => array(
+ 'multiple' => 'multiple',
+ 'id' => 'member_counties',
+ 'size' => 10
+ )
+ );
$e[] = array(
'type' => 'date',
'req' => true,
// }}}
+ protected function getMemberCounties(PDO $dbh)
+ {
+ $counties = array();
+ try {
+ $sql = "
+ SELECT county_id,county_name
+ FROM members.county
+ ORDER BY county_name";
+ $stmt = $dbh->query($sql);
+ while ($county = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $counties[$county['county_id']] = $county['county_name'];
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ return $counties;
+ }
+
// {{{ getMemberCategories()
/**
}
$values['pages'] = (array) $values['pages'];
+ $values['member_counties']
+ = (array) $values['member_counties'];
$sdateStr = implode('/', $values['sdate']);
$values['sdate'] = new Date(strtotime($sdateStr));
$values['business'],
$values['pages'],
$memberCategories,
+ $values['member_counties'],
$values['description'],
$_GET['id'],
$values['embedcode']
);
+// echo '<pre>'.print_r($banner, true).'</pre>';
+// exit;
return ctype_digit((string)$_GET['id'])
? $banner->update($dbh, $config)
$posted = filter_var_array(
$_REQUEST,
array(
- 'member_name' => FILTER_SANITIZE_STRING,
- 'activityId' => FILTER_VALIDATE_INT,
- 'parkId' => FILTER_VALIDATE_INT,
- 'regionId' => FILTER_VALIDATE_INT,
- 'countyId' => FILTER_VALIDATE_INT,
- 'amenity' => array(
+ 'member_name' => FILTER_SANITIZE_STRING,
+ 'activityId' => FILTER_VALIDATE_INT,
+ 'destinationId' => FILTER_VALIDATE_INT,
+ 'parkId' => FILTER_VALIDATE_INT,
+ 'regionId' => FILTER_VALIDATE_INT,
+ 'countyId' => FILTER_VALIDATE_INT,
+ 'amenity' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FORCE_ARRAY
)
$parkName = $this->getCategoryName($dbh, $parkId);
$this->_searchTerms->offsetSet('park', $parkName);
}
+ if ($destinationId) {
+ $destinationName = $this->getCategoryName($dbh, $destinationId);
+ $this->_searchTerms->offsetSet('destination', $destinationName);
+ }
if ($regionId) {
$regionName = $this->getRegionName($dbh, $regionId);
$this->_searchTerms->offsetSet('region', $regionName);
$html .= 'Parks ';
}
}
+ if ($this->_searchTerms->offsetExists('destination')) {
+ $dest = $this->_searchTerms->offsetGet('destination');
+ $html .= 'in ' . $dest . ' ';
+ }
if ($this->_searchTerms->offsetExists('region')) {
$html .= 'in ' . $this->_searchTerms->offsetGet('region')
. ' Region ';
'sub_category_id' => FILTER_VALIDATE_INT,
'activityId' => FILTER_VALIDATE_INT,
'parkId' => FILTER_VALIDATE_INT,
+ 'destinationId' => FILTER_VALIDATE_INT,
'regionId' => FILTER_VALIDATE_INT,
'countyId' => FILTER_VALIDATE_INT,
'activity' => array(
FROM member_category
WHERE category_id = {$parkId})";
}
+ if ($destinationId) {
+ $params[] = "m.member_id IN (
+ SELECT member_id
+ FROM member_category
+ WHERE category_id = {$destinationId})";
+ }
// if ($regionId) {
// $params[] = "m.region = {$regionId}";
// }
*/
protected $dbh;
- const PARENT_CATEGORY_ACTIVITIES = 7;
- const PARENT_CATEGORY_PARKS = 8;
+ const PARENT_CATEGORY_ACTIVITIES = 7;
+ const PARENT_CATEGORY_PARKS = 8;
+ const PARENT_CATEGORY_DESTINATIONS = 19;
// }}}
$tpl = new HTML_Template_Flexy($flexyOpts);
$tpl->compile($this->formTemplate);
- $activity = $this->getActivities();
- $amenities = $this->getMemberAmenities($this->dbh);
- $parks = $this->getParks();
- $regions = $this->getAvailableRegions($this->dbh);
- $counties = $this->getCounties();
+ $activity = $this->getActivities();
+ $amenities = $this->getMemberAmenities($this->dbh);
+ $parks = $this->getParks();
+ $destinations = $this->getDestinations();
+ $regions = $this->getAvailableRegions($this->dbh);
+ $counties = $this->getCounties();
- $page = new stdClass();
+ $page = new stdClass();
$page->formURL
= BASE_URL
. 'index.php?_qf__SearchForm=&catid=' . $this->_catid
= (!empty($parks) && count($parks) > 1)
? $parks
: null;
+ $page->destinations
+ = (!empty($destinations) && count($destinations) > 1)
+ ? $destinations
+ : null;
$page->regions
= (!empty($regions) && count($regions) >= 1)
? $regions
return $parks;
}
+ protected function getDestinations()
+ {
+ $destinatons = array();
+ try {
+ $cats
+ = ($this->memberCatsAssignedToPage)
+ ? " AND (category_id IN ("
+ .implode(',', $this->memberCatsAssignedToPage).")
+ OR parent_id IN (".implode(',', $this->memberCatsAssignedToPage)."))"
+ : '';
+ $sql = "
+ SELECT *
+ FROM category
+ WHERE parent_id = "
+ . self::PARENT_CATEGORY_DESTINATIONS
+ . $cats
+ . " AND category_id IN (
+ SELECT category_id
+ FROM member_category)"
+ . " ORDER BY name";
+ $stmt = $this->dbh->query($sql);
+ while ($category = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $destinatons[$category['category_id']] = $category['name'];
+ }
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ return $destinatons;
+ }
+
// {{{ setCatId()
/**
<?php
require_once '../../setup.phtml';
-define('PARENT_CATEGORY_ACTIVITIES', 7);
-define('PARENT_CATEGORY_PARKS', 8);
-$activityId = filter_var($_REQUEST['activityId'], FILTER_VALIDATE_INT);
-$parkId = filter_var($_REQUEST['parkId'], FILTER_VALIDATE_INT);
-$regionId = filter_var($_REQUEST['regionId'], FILTER_VALIDATE_INT);
-$countyId = filter_var($_REQUEST['countyId'], FILTER_VALIDATE_INT);
+$searchBy = filter_var($_REQUEST['search'], FILTER_SANITIZE_STRING);
+$activityId = filter_var($_REQUEST['activityId'], FILTER_VALIDATE_INT);
+$parkId = filter_var($_REQUEST['parkId'], FILTER_VALIDATE_INT);
+$destinationId = filter_var($_REQUEST['destinationId'], FILTER_VALIDATE_INT);
+$regionId = filter_var($_REQUEST['regionId'], FILTER_VALIDATE_INT);
+$countyId = filter_var($_REQUEST['countyId'], FILTER_VALIDATE_INT);
try {
$dbh = Toolkit_Database::getInstance();
-
- if ($activityId) {
+ if ($searchBy == 'counties') {
+ $otherIds
+ = array(
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_ACTIVITIES,
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_PARKS,
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_DESTINATIONS
+ );
+ if ($activityId && $parkId && $destinationId) {
+ $searchIds = array($activityId, $parkId, $destinationId);
+ } else if ($activityId && $parkId) {
+ $searchIds = array($activityId, $parkId);
+ } else if ($activityId) {
+ $searchIds = array($activityId);
+ } else if ($parkId) {
+ $searchIds = array($parkId);
+ } else if ($destinationId) {
+ $searchIds = array($destinationId);
+ }
+ if ($searchIds) {
+ $num = count($searchIds);
+ switch ($num) {
+ case 3:
+ $whereCategory = "WHERE category_id = " . $searchIds[0];
+ $whereCategory .= " AND category_id = " . $searchIds[1];
+ $whereCategory .= " AND category_id = " . $searchIds[2];
+ break;
+ case 2:
+ $whereCategory = "WHERE category_id = " . $searchIds[0];
+ $whereCategory .= " AND category_id = " . $searchIds[1];
+ break;
+ case 1:
+ $whereCategory = "WHERE category_id = " . $searchIds[0];
+ break;
+ }
+ }
+ $sql = "
+ SELECT *
+ FROM members.county
+ WHERE county_id IN (
+ SELECT county
+ FROM members.member
+ WHERE active = '1'
+ AND new_member <> true
+ AND member_id IN (
+ SELECT member_id
+ FROM members.member_category
+ {$whereCategory})
+ )";
+ $stmt = $dbh->prepare($sql);
+ $stmt->execute();
+ echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
+ exit;
+ }
+ switch ($searchBy) {
+ case 'parks':
+ $searchById
+ = "AND parent_id = "
+ . Toolkit_Members_UserSearchForm::PARENT_CATEGORY_PARKS;
+ $otherIds
+ = array(
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_ACTIVITIES,
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_DESTINATIONS
+ );
+ if ($activityId && $destinationId) {
+ $searchIds = array($activityId, $destinationId);
+ } else if ($activityId) {
+ $searchIds = array($activityId);
+ } else if ($destinationId) {
+ $searchIds = array($destinationId);
+ }
+ break;
+ case 'activity':
+ $searchById
+ = "AND parent_id = "
+ . Toolkit_Members_UserSearchForm::PARENT_CATEGORY_ACTIVITIES;
+ $otherIds
+ = array(
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_PARKS,
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_DESTINATIONS
+ );
+ if ($parkId && $destinationId) {
+ $searchIds = array($parkId, $destinationId);
+ } else if ($parkId) {
+ $searchIds = array($parkId);
+ } else if ($destinationId) {
+ $searchIds = array($destinationId);
+ }
+ break;
+ case 'destination':
+ $searchById
+ = "AND parent_id = "
+ . Toolkit_Members_UserSearchForm::PARENT_CATEGORY_DESTINATIONS;
+ $otherIds
+ = array(
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_ACTIVITIES,
+ Toolkit_Members_UserSearchForm::PARENT_CATEGORY_PARKS
+ );
+ if ($activityId && $parkId) {
+ $searchIds = array($activityId, $parkId);
+ } else if ($activityId) {
+ $searchIds = array($activityId);
+ } else if ($parkId) {
+ $searchIds = array($parkId);
+ }
+ break;
+ default:
+ return false;
+ break;
+ }
+ $countySearch
+ = ($countyId)
+ ? "AND county = {$countyId}"
+ : '';
+ if ($searchIds) {
+ if (count($searchIds) > 1) {
+ $whereCategory = "category_id = " . $searchIds[0];
+ $whereCategory .= " AND category_id = " . $searchIds[1];
+ } else {
+ $whereCategory = "category_id = " . $searchIds[0];
+ }
$sql = "
SELECT category_id,name
FROM members.category
WHERE member_id IN (
SELECT member_id
FROM members.member_category
- WHERE category_id = :category))
- AND parent_id = " . PARENT_CATEGORY_PARKS . "
+ WHERE {$whereCategory}
+ )
+ AND member_id IN (
+ SELECT member_id
+ FROM member
+ WHERE active = '1'
+ AND new_member <> true
+ $countySearch
+ )
+ )
+ {$searchById}
ORDER BY name";
- $stmt = $dbh->prepare($sql);
- $stmt->bindParam(':category', $activityId, PDO::PARAM_INT);
+ $stmt = $dbh->query($sql);
$stmt->execute();
echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
- }
- if (isset($_REQUEST['activityId']) && !$activityId) {
+ } else {
$sql = "
SELECT category_id,name
FROM members.category
WHERE category_id IN (
SELECT category_id
FROM members.category
- WHERE parent_id = " . PARENT_CATEGORY_ACTIVITIES . ")))
- AND parent_id = " . PARENT_CATEGORY_PARKS . "
+ WHERE parent_id IN (
+ " . implode(',', $otherIds) . ")
+ )
+ AND member_id IN (
+ SELECT member_id
+ FROM member
+ WHERE active = '1'
+ AND new_member <> true
+ $countySearch
+ )
+ )
+ )
+ {$searchById}
ORDER BY name";
$stmt = $dbh->prepare($sql);
$stmt->execute();
<input type="hidden" name="search" value="1">
<input type="hidden" name="catid" value="<?php echo $_REQUEST['catid'];?>">
<div id="col2">
- <div>Search by Activities & Parks:</div>
- <div flexy:if="counties" class="fieldcontain">
+ <div>Search by:</div>
+ <div flexy:if="activities" class="fieldcontain">
<select name="activityId" id="advSearchActivities">
<option value="">Activities</option>
{foreach:activities,id,name}
{end:}
</select>
</div>
- <div flexy:if="counties" class="fieldcontain">
+ <div flexy:if="parks" class="fieldcontain">
<select name="parkId" id="advSearchParks">
<option value="">Parks</option>
{foreach:parks,id,name}
?>
{end:}
</select>
+ </div>
+ <div flexy:if="destinations" class="fieldcontain">
+ <select name="destinationId" id="advSearchDest">
+ <option value="">Destinations</option>
+ {foreach:destinations,id,name}
+ <?php
+ echo '<option value="'.$id.'"
+ '.(($id == $_REQUEST['destinationId'])?'selected':'')
+ .'>'.$name.'</option>';
+ ?>
+ {end:}
+ </select>
<input
type="submit"
id="trail-search-form-ap"
if ($("#advSearchRegions").val()) {
updateCountySelect();
}
+ // update when activities changes
$("#advSearchActivities").change(function(){
updateParksSelect();
+ updateDestinationSelect();
});
if ($("#advSearchActivities").val()) {
updateParksSelect();
+ updateDestinationSelect();
+ }
+ //update when parks changes
+ $("#advSearchParks").change(function(){
+ updateActivitySelect();
+ updateDestinationSelect();
+ });
+ if ($("#advSearchParks").val()) {
+ updateActivitySelect();
+ updateDestinationSelect();
+ }
+ // update when destination changes
+ $("#advSearchDest").change(function(){
+ updateParksSelect();
+ updateActivitySelect();
+ });
+ if ($("#advSearchDest").val()) {
+ updateParksSelect();
+ updateActivitySelect();
}
});
function updateParksSelect() {
$.ajax({
dataType: 'json',
url: 'ajax/form.json',
- data: {'activityId': $("#advSearchActivities").val()},
+ data: {
+ 'search': 'parks',
+ 'activityId': $("#advSearchActivities").val(),
+ 'destinationId': $("#advSearchDest").val()
+ },
success: function(data) {
var currentVal = $("#advSearchParks").val();
$("#advSearchParks").html('<option value="">Parks</option>');
$.each(data, function(index, park) {
- //console.log(park);
var sel
= (currentVal == park.category_id)
? ' selected'
$("#advSearchParks").append('<option value="' + park.category_id
+ '" '+sel+'>'
+ park.name + '</option>');
- //console.log('park: ' + park.name);
});
}
});
}
+ function updateActivitySelect() {
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'activity',
+ 'parkId': $("#advSearchParks").val(),
+ 'destinationId': $("#advSearchDest").val()
+ },
+ success: function(data) {
+ var currentVal = $("#advSearchActivities").val();
+ $("#advSearchActivities").html('<option value="">Activities</option>');
+ $.each(data, function(index, activity) {
+ var sel
+ = (currentVal == activity.category_id)
+ ? ' selected'
+ : '';
+ $("#advSearchActivities").append('<option value="' + activity.category_id
+ + '" '+sel+'>'
+ + activity.name + '</option>');
+ });
+ }
+ });
+ }
+ function updateDestinationSelect() {
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'destination',
+ 'activityId': $("#advSearchActivities").val(),
+ 'parkId': $("#advSearchParks").val()
+ },
+ success: function(data) {
+ var currentVal = $("#advSearchDest").val();
+ $("#advSearchDest").html('<option value="">Destinations</option>');
+ if (data != null) {
+ $.each(data, function(index, destination) {
+ var sel
+ = (currentVal == destination.category_id)
+ ? ' selected'
+ : '';
+ $("#advSearchDest").append('<option value="' + destination.category_id
+ + '" '+sel+'>'
+ + destination.name + '</option>');
+ });
+ }
+ }
+ });
+ }
function updateCountySelect() {
$.ajax({
dataType: 'json',
url: 'ajax/form.json',
- data: {'regionId': $("#advSearchRegions").val()},
+ data: {'search': 'counties','regionId': $("#advSearchRegions").val()},
success: function(data) {
var currentVal = $("#advSearchCounties").val();
$("#advSearchCounties").html('<option value="">Counties</option>');
$("#advSearchCounties").append('<option value="' + county.county_id
+ '" '+sel+'>'
+ county.county_name + '</option>');
- //console.log(county.county_id);
});
}
});
$GLOBALS['bottomScripts'][] = $this->baseURL . "fancybox/jquery.fancybox.js";
$GLOBALS['bottomScripts'][] = $this->glmAppBaseURL . 'libjs/external.js';
$GLOBALS['bottomScripts'][] = $this->baseURL . "libjs/pagefunctions.js";
+ $GLOBALS['bottomScripts'][] = $this->baseURL . "libjs/findATrail.js";
}
/**
$this->reviewedCount = 0;
try {
$dbh = Toolkit_Database::getInstance();
+
+ // get count for reviewed trails
$sql = "
SELECT count(member_id)
FROM member
WHERE reviewed = true";
$this->reviewedCount = $dbh->query($sql)->fetchColumn();
+
+ // get activitySearch array
$sql = "
SELECT category_id,name
FROM members.category
- WHERE parent_id = 7
+ WHERE parent_id = " . Toolkit_Members_UserSearchForm::PARENT_CATEGORY_ACTIVITIES . "
AND category_id IN (
SELECT category_id
FROM members.member_category
$this->activitySearch[$category['category_id']]
= $category['name'];
}
+
+ // get parkSearch array
$sql = "
SELECT category_id,name
FROM members.category
- WHERE parent_id = 8
+ WHERE parent_id = " . Toolkit_Members_UserSearchForm::PARENT_CATEGORY_PARKS . "
AND category_id IN (
SELECT category_id
FROM members.member_category
$this->parkSearch[$park['category_id']]
= $park['name'];
}
+
+ // get destinationSearch array
+ $sql = "
+ SELECT category_id,name
+ FROM members.category
+ WHERE parent_id = " . Toolkit_Members_UserSearchForm::PARENT_CATEGORY_DESTINATIONS . "
+ AND category_id IN (
+ SELECT category_id
+ FROM members.member_category
+ WHERE member_id IN
+ (SELECT member_id
+ FROM members.member
+ WHERE active = 't'))
+ ORDER BY name";
+ $stmt = $dbh->query($sql);
+ while ($dest = $stmt->fetch(PDO::FETCH_ASSOC)) {
+ $this->destinationSearch[$dest['category_id']]
+ = $dest['name'];
+ }
+
+ // get regionSearch array
$sql = "
SELECT region_id,region_name
FROM members.region
$this->regionSearch[$region['region_id']]
= $region['region_name'];
}
+
+ // get countSearch array
$sql = "
SELECT county_id,county_name
FROM members.county
app.base_url = "http://localhost/app.gaslightmedia.com/"
-database.params.host = "devdb"
+database.params.host = "localhost"
error.reporting[] = E_ALL
error.reporting[] = E_NOTICE
-error.reporting[] = E_STRICT
+;error.reporting[] = E_STRICT
email.owner = "steve+owner@localhost"
email.contact = "steve+contact@localhost"
--- /dev/null
+var findATrailSearch = {
+ activitySelect: $("#activity"),
+ parksSelect: $("#park"),
+ countySelect: $("#county"),
+ destinationSelect: $("#destination"),
+
+ init: function(){
+ // update when activities changes
+ $("#activity").change(function(){
+ findATrailSearch.updateParksSelect();
+ findATrailSearch.updateCountySelect();
+ findATrailSearch.updateDestinationSelect();
+ });
+ if ($("#activity").val()) {
+ findATrailSearch.updateParksSelect();
+ findATrailSearch.updateCountySelect();
+ findATrailSearch.updateDestinationSelect();
+ }
+ //update when parks changes
+ $("#park").change(function(){
+ findATrailSearch.updateActivitySelect();
+
+ findATrailSearch.updateCountySelect();
+ findATrailSearch.updateDestinationSelect();
+ });
+ if ($("#park").val()) {
+ findATrailSearch.updateActivitySelect();
+ findATrailSearch.updateCountySelect();
+ findATrailSearch.updateDestinationSelect();
+ }
+ // update when destination changes
+ $("#destination").change(function(){
+ findATrailSearch.updateActivitySelect();
+ findATrailSearch.updateParksSelect();
+ findATrailSearch.updateCountySelect();
+ });
+ if ($("#destination").val()) {
+ findATrailSearch.updateActivitySelect();
+ findATrailSearch.updateParksSelect();
+ findATrailSearch.updateCountySelect();
+ }
+ // update when destination changes
+ $("#county").change(function(){
+ findATrailSearch.updateActivitySelect();
+ findATrailSearch.updateParksSelect();
+ findATrailSearch.updateDestinationSelect();
+ });
+ if ($("#county").val()) {
+ findATrailSearch.updateActivitySelect();
+ findATrailSearch.updateParksSelect();
+ findATrailSearch.updateDestinationSelect();
+ }
+ },
+ updateParksSelect: function(){
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'parks',
+ 'activityId': $("#activity").val(),
+ 'destinationId': $("#destination").val(),
+ 'countyId': $("#county").val()
+ },
+ success: function(data) {
+ var currentVal = $("#park").val();
+ $("#park").html('<option value="">Parks</option>');
+ if (data != null) {
+ //console.info(data);
+ $.each(data, function(index, park) {
+ var sel
+ = (currentVal == park.category_id)
+ ? ' selected'
+ : '';
+ $("#park").append('<option value="' + park.category_id
+ + '" '+sel+'>'
+ + park.name + '</option>');
+ });
+ }
+ }
+ });
+ },
+ updateActivitySelect: function(){
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'activity',
+ 'parkId': $("#park").val(),
+ 'destinationId': $("#destination").val(),
+ 'countyId': $("#county").val()
+ },
+ success: function(data) {
+ var currentVal = $("#activity").val();
+ $("#activity").html('<option value="">Activities</option>');
+ if (data != null) {
+ //console.info(data);
+ $.each(data, function(index, activity) {
+ var sel
+ = (currentVal == activity.category_id)
+ ? ' selected'
+ : '';
+ $("#activity").append('<option value="' + activity.category_id
+ + '" '+sel+'>'
+ + activity.name + '</option>');
+ });
+ }
+
+ }
+ });
+ },
+ updateDestinationSelect: function(){
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'destination',
+ 'activityId': $("#activity").val(),
+ 'parkId': $("#park").val(),
+ 'countyId': $("#county").val()
+ },
+ success: function(data) {
+ var currentVal = $("#destination").val();
+ $("#destination").html('<option value="">Destinations</option>');
+ if (data != null) {
+ //console.info(data);
+ $.each(data, function(index, destination) {
+ var sel
+ = (currentVal == destination.category_id)
+ ? ' selected'
+ : '';
+ $("#destination").append('<option value="' + destination.category_id
+ + '" '+sel+'>'
+ + destination.name + '</option>');
+ });
+ }
+ }
+ });
+ },
+ updateCountySelect: function(){
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'counties',
+ 'activityId': $("#activity").val(),
+ 'parkId': $("#park").val(),
+ 'destinationId': $("#destination").val()
+ },
+ success: function(data) {
+ var currentVal = $("#county").val();
+ $("#county").html('<option value="">County</option>');
+ if (data != null) {
+ //console.info(data);
+ $.each(data, function(index, county) {
+ var sel
+ = (currentVal == county.county_id)
+ ? ' selected'
+ : '';
+ $("#county").append('<option value="' + county.county_id
+ + '" '+sel+'>'
+ + county.county_name + '</option>');
+ });
+ }
+ }
+ });
+ }
+}
+
+$(function(){
+ findATrailSearch.init();
+});
'.$label.'</option>';
}?>
</select>
+ <select
+ name="destinationId"
+ id="destination"
+ flexy:if="destinationSearch">
+ <option value="">Destinations</option>
+ <?php foreach($t->destinationSearch as $id => $label) {
+ echo '<option
+ value="'.$id.'">
+ '.$label.'</option>';
+ }?>
+ </select>
<input type="submit" name="submit" value="submit">
</form>
</div><!--/#findatrail-->