'parkId' => FILTER_VALIDATE_INT,
'regionId' => FILTER_VALIDATE_INT,
'countyId' => FILTER_VALIDATE_INT,
+ 'cityId' => FILTER_VALIDATE_INT,
'amenity' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FORCE_ARRAY
$parkName = $this->getCategoryName($dbh, $parkId);
$this->_searchTerms->offsetSet('park', $parkName);
}
+ if ($cityId) {
+ $cityName = $this->getCityName($dbh, $cityId);
+ $this->_searchTerms->offsetSet('city', $cityName);
+ }
if ($destinationId) {
$destinationName = $this->getCategoryName($dbh, $destinationId);
$this->_searchTerms->offsetSet('destination', $destinationName);
$html .= 'Parks ';
}
}
+
if ($this->_searchTerms->offsetExists('destination')) {
$dest = $this->_searchTerms->offsetGet('destination');
$html .= 'in ' . $dest . ' ';
. ' County ';
}
+ if ($this->_searchTerms->offsetExists('city')) {
+ $city = $this->_searchTerms->offsetGet('city');
+ $html .= 'in ' . $city . ' ';
+ }
+
}
return $html;
}
}
}
+ protected function getCityName(PDO $dbh, $id)
+ {
+ try {
+ $sql = "
+ SELECT city_name
+ FROM members.city
+ WHERE city_id = :id";
+ $stmt = $dbh->prepare($sql);
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+ return $stmt->fetchColumn();
+ } catch (PDOException $e) {
+ Toolkit_Common::handleError($e);
+ }
+ }
+
protected function getAmenityName(PDO $dbh, $id)
{
try {
'destinationId' => FILTER_VALIDATE_INT,
'regionId' => FILTER_VALIDATE_INT,
'countyId' => FILTER_VALIDATE_INT,
+ 'cityId' => FILTER_VALIDATE_INT,
'activity' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FORCE_ARRAY
),
- 'amenity' => array(
+ 'amenity' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FORCE_ARRAY
),
'park' => array(
'filter' => FILTER_VALIDATE_INT,
'flags' => FILTER_FORCE_ARRAY
+ ),
+ 'filterActivity' => array(
+ 'filter' => FILTER_VALIDATE_INT,
+ 'flags' => FILTER_FORCE_ARRAY
+ ),
+ 'filterParks' => array(
+ 'filter' => FILTER_VALIDATE_INT,
+ 'flags' => FILTER_FORCE_ARRAY
)
)
);
extract($postedArrays);
+ // These first three have to be grouped into OR's
if (!empty($amenity) && $amenity[0]) {
- $params[] = "m.member_id IN (
+ $params2[] = "m.member_id IN (
SELECT member_id
FROM member_amenity
WHERE amenity_id IN ("
.implode(',', $amenity)."))";
}
+ if (!empty($filterActivity)) {
+ $params2[] = "m.member_id IN (
+ SELECT member_id
+ FROM member_category
+ WHERE category_id IN ("
+ .implode(',', $filterActivity)."))";
+ }
+ if (!empty($filterParks)) {
+ $params2[] = "m.member_id IN (
+ SELECT member_id
+ FROM member_category
+ WHERE category_id IN ("
+ .implode(',', $filterParks)."))";
+ }
// if (!empty($activity) && $activity[0]) {
// $params[] = "m.member_id IN (
// SELECT member_id
// WHERE category_id IN ("
// .implode(',', $activity)."))";
// }
+ if ($cityId) {
+ $params[] = "m.city_id = $cityId";
+ }
if ($activityId) {
$params[] = "m.member_id IN (
SELECT member_id
if (!empty($params)) {
$sql .= ' WHERE ' . implode(' AND ', $params);
}
+ if (!empty($params2)) {
+ $sql .= ' AND (' . implode(' OR ', $params2) . ')';
+ }
return $sql;
}
$destinations = $this->getDestinations();
$regions = $this->getAvailableRegions($this->dbh);
$counties = $this->getCounties();
+ $cities = $this->getCities();
$page = new stdClass();
$page->formURL
= (!empty($counties) && count($counties) > 1)
? $counties
: null;
+ $page->cities
+ = (!empty($cities) && count($cities) > 1)
+ ? $cities
+ : null;
$page->amenities = $amenities;
return $tpl->bufferedOutputObject($page);
public function getCounties()
{
$counties = array();
- $sql .= "
+ $sql = "
SELECT *
FROM county
WHERE county_id IN (
}
return $counties;
}
+
+ public function getCities()
+ {
+ $cities = array();
+ $sql = "
+ SELECT *
+ FROM city
+ WHERE city_id IN (
+ SELECT DISTINCT city_id
+ FROM member
+ WHERE active
+ AND city_id is not null)
+ ORDER BY city_name";
+ $stmt = $this->dbh->prepare($sql);
+ $stmt->execute();
+ while ($row = $stmt->fetch()) {
+ $cities[$row['city_id']] = $row['city_name'];
+ }
+ return $cities;
+ }
}
break;
}
}
+ $reqionSql
+ = ($regionId)
+ ? "AND region_id = $regionId"
+ : '';
$sql = "
- SELECT *
- FROM members.county
- WHERE county_id IN (
- SELECT county
+ SELECT county_id,county_name
+ 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})
- )";
+ AND member_id IN (SELECT member_id
+ FROM members.member_category
+ {$whereCategory}))
+ {$reqionSql}
+ ORDER BY county_name";
$stmt = $dbh->prepare($sql);
$stmt->execute();
echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
exit;
}
switch ($searchBy) {
+ case 'cities':
+ $countySql
+ = ($countyId)
+ ? "AND county_id = $countyId"
+ : '';
+ $sql = "
+ SELECT city_id,city_name
+ FROM city
+ WHERE city_id IN (SELECT city_id
+ FROM member
+ WHERE active = '1'
+ AND new_member <> true)
+ {$countySql}
+ ORDER BY city_name";
+ $stmt = $dbh->prepare($sql);
+ $stmt->execute();
+ echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
+ exit;
+ break;
case 'parks':
$searchById
= "AND parent_id = "
}
if ($regionId) {
$sql = "
- SELECT *
+ SELECT county_id,county_name
FROM members.county
WHERE region_id = :region
AND region_id IN (
}
if (isset($_REQUEST['regionId']) && !$regionId) {
$sql = "
- SELECT *
+ SELECT county_id,county_name
FROM members.county
WHERE region_id IN (
SELECT region
border-radius: 8px 8px 8px 8px;
box-shadow: 0 0 10px rgba(176, 164, 135, 0.7) inset;
}
+ .filterCol {
+ position: relative;
+ font-family: Arial, Helvetica, sans-serif;
+ float: left;
+ width: 32.33333333%;
+ padding: 10px 1%;
+ /*height: 160px;*/
+ }
+ .filterCol label {
+ width: 100%;
+ display: block;
+ }
#lowerbox {
position: relative;
font-family: Arial, Helvetica, sans-serif;
}
#filter_header {
/*border-bottom: 1px solid #D4D4D4;*/
+ font-family: Arial, Helvetica, sans-serif;
+ background: #B8C728;
+ width: auto;
+ bottom: 10px;
+ right: 2%;
+ height: 29px;
+ cursor: pointer;
+ background: #8A1E03;
+ border: 2px solid #FFF;
+ border-radius: 6px;
+ color: #FFF;
+ font-weight: bold;
+ text-transform: uppercase;
+ padding: 3px 8px;
}
#trail-form-name input[type=search] {
display: block;
<form
flexy:ignore="yes"
action="{formURL:h}"
- id="trail-form-ap"
+ id="trail-form-rc"
method="get">
<input type="hidden" value="" name="_qf__SearchForm">
<input type="hidden" name="search" value="1">
<input type="hidden" name="catid" value="<?php echo $_REQUEST['catid'];?>">
<div id="col2">
- <div>Search by:</div>
- <div flexy:if="activities" class="fieldcontain">
- <select name="activityId" id="advSearchActivities">
- <option value="">Activities</option>
- {foreach:activities,id,name}
+ <div>Search by Regions & Counties:</div>
+ <div flexy:if="regions" class="fieldcontain">
+ <select name="regionId" id="advSearchRegions">
+ <option value="">Regions</option>
+ {foreach:regions,id,name}
<?php
echo '<option value="'.$id.'"
- '.(($id == $_REQUEST['activityId'])?'selected':'')
+ '.(($id == $_REQUEST['regionId'])?'selected':'')
.'>'.$name.'</option>';
?>
{end:}
</select>
</div>
- <div flexy:if="parks" class="fieldcontain">
- <select name="parkId" id="advSearchParks">
- <option value="">Parks</option>
- {foreach:parks,id,name}
+ <div flexy:if="counties" class="fieldcontain">
+ <select name="countyId" id="advSearchCounties">
+ <option value="">Counties</option>
+ {foreach:counties,id,name}
<?php
echo '<option value="'.$id.'"
- '.(($id == $_REQUEST['parkId'])?'selected':'')
+ '.(($id == $_REQUEST['countyId'])?'selected':'')
.'>'.$name.'</option>';
?>
{end:}
</select>
</div>
- <div flexy:if="destinations" class="fieldcontain">
- <select name="destinationId" id="advSearchDest">
- <option value="">Destinations</option>
- {foreach:destinations,id,name}
+ <div flexy:if="cities" class="fieldcontain">
+ <select name="cityId" id="advSearchCities">
+ <option value="">Cities</option>
+ {foreach:cities,id,name}
<?php
echo '<option value="'.$id.'"
- '.(($id == $_REQUEST['destinationId'])?'selected':'')
+ '.(($id == $_REQUEST['cityId'])?'selected':'')
.'>'.$name.'</option>';
?>
{end:}
</select>
<input
type="submit"
- id="trail-search-form-ap"
+ id="trail-search-form-rc"
value="Search">
</div>
</div>
</form>
<form
- flexy:ignore="yes"
- action="{formURL:h}"
- id="trail-form-rc"
- method="get">
+ flexy:ignore="yes"
+ action="{formURL:h}"
+ id="trail-form-ap"
+ method="get">
<input type="hidden" value="" name="_qf__SearchForm">
<input type="hidden" name="search" value="1">
<input type="hidden" name="catid" value="<?php echo $_REQUEST['catid'];?>">
<div id="col3">
- <div>Search by Regions & Counties:</div>
- <div flexy:if="regions" class="fieldcontain">
- <select name="regionId" id="advSearchRegions">
- <option value="">Regions</option>
- {foreach:regions,id,name}
+ <div>Search by:</div>
+ <div flexy:if="destinations" class="fieldcontain">
+ <select name="destinationId" id="advSearchDest">
+ <option value="">Destination</option>
+ {foreach:destinations,id,name}
<?php
echo '<option value="'.$id.'"
- '.(($id == $_REQUEST['regionId'])?'selected':'')
+ '.(($id == $_REQUEST['destinationId'])?'selected':'')
.'>'.$name.'</option>';
?>
{end:}
</select>
</div>
- <div flexy:if="counties" class="fieldcontain">
- <select name="countyId" id="advSearchCounties">
- <option value="">Counties</option>
- {foreach:counties,id,name}
+ <div flexy:if="activities" class="fieldcontain">
+ <select name="activityId" id="advSearchActivities">
+ <option value="">Activities</option>
+ {foreach:activities,id,name}
<?php
echo '<option value="'.$id.'"
- '.(($id == $_REQUEST['countyId'])?'selected':'')
+ '.(($id == $_REQUEST['activityId'])?'selected':'')
+ .'>'.$name.'</option>';
+ ?>
+ {end:}
+ </select>
+ </div>
+ <div flexy:if="parks" class="fieldcontain">
+ <select name="parkId" id="advSearchParks">
+ <option value="">Parks</option>
+ {foreach:parks,id,name}
+ <?php
+ echo '<option value="'.$id.'"
+ '.(($id == $_REQUEST['parkId'])?'selected':'')
.'>'.$name.'</option>';
?>
{end:}
if ($county = filter_var($_REQUEST['countyId'], FILTER_VALIDATE_INT)) {
echo '<input type="hidden" name="countyId" value="'.$county.'">';
}
+ if ($city = filter_var($_REQUEST['cityId'], FILTER_VALIDATE_INT)) {
+ echo '<input type="hidden" name="cityId" value="'.$city.'">';
+ }
?>
<div id="lowerbox">
<div id="filter_header">Filter Results:</div>
- <div flexy:if="parks" class="fieldcontain">
- <div class="glm-chbx">
+ <div class="fieldcontain" id="filterContainer" style="display:none;">
+ <div class="glm-chbx filterCol">
+ <h3>Activities</h3>
+ {foreach:activities,id,name}
+ <label for="acchbx-{id:h}">
+ <?php
+ echo '<input
+ id="acchbx-'.$id.'"
+ type="checkbox"
+ name="filterActivity[]"
+ value="'.$id.'"
+ '.((isset($_REQUEST['filterActivity'])
+ && is_array($_REQUEST['filterActivity'])
+ && in_array($id, $_REQUEST['filterActivity']))?'checked':'').'
+ >';
+ ?>
+ {name}
+ </label>
+ {end:}
+ </div>
+ <div class="glm-chbx filterCol">
+ <h3>Amenities</h3>
{foreach:amenities,name,id}
- <label for="amchbx-{id:h}" class="glm-chbx-label">
+ <label for="amchbx-{id:h}">
<?php
echo '<input
id="amchbx-'.$id.'"
</label>
{end:}
</div>
- </div>
- <input
+ <div class="glm-chbx filterCol">
+ <h3>Parks</h3>
+ {foreach:parks,id,name}
+ <label for="pchbx-{id:h}">
+ <?php
+ echo '<input
+ id="pchbx-'.$id.'"
+ type="checkbox"
+ name="filterParks[]"
+ value="'.$id.'"
+ '.((isset($_REQUEST['filterParks'])
+ && is_array($_REQUEST['filterParks'])
+ && in_array($id, $_REQUEST['filterParks']))?'checked':'').'
+ >';
+ ?>
+ {name}
+ </label>
+ {end:}
+ </div>
+ <input
type="submit"
id="trail-search-form-amenities"
value="Update">
+ </div>
+
</div>
</form>
</div>
<script>
jQuery(document).ready(function() {
+ $("#filter_header").click(function(){
+ $("#filterContainer").slideToggle("slow", function(){
+ console.log('filter toggled');
+ });
+ });
$("#advSearchRegions").change(function(){
updateCountySelect();
});
// update when activities changes
$("#advSearchActivities").change(function(){
updateParksSelect();
- updateDestinationSelect();
+// updateDestinationSelect();
});
if ($("#advSearchActivities").val()) {
updateParksSelect();
- updateDestinationSelect();
+// updateDestinationSelect();
}
//update when parks changes
$("#advSearchParks").change(function(){
updateActivitySelect();
- updateDestinationSelect();
+// updateDestinationSelect();
});
if ($("#advSearchParks").val()) {
updateActivitySelect();
- updateDestinationSelect();
+// updateDestinationSelect();
}
// update when destination changes
$("#advSearchDest").change(function(){
updateParksSelect();
updateActivitySelect();
}
+ // Update city when the county changes
+ $("#advSearchCounties").change(function(){
+ updateCitySelect();
+ });
+ if ($("#advSearchCounties").val()) {
+ updateCitySelect();
+ }
});
function updateParksSelect() {
$.ajax({
success: function(data) {
var currentVal = $("#advSearchCounties").val();
$("#advSearchCounties").html('<option value="">Counties</option>');
+ console.log('clear county select');
$.each(data, function(index, county) {
var sel
= (currentVal == county.county_id)
$("#advSearchCounties").append('<option value="' + county.county_id
+ '" '+sel+'>'
+ county.county_name + '</option>');
+ console.log('add county ' + county.county_name + ' to list');
+ });
+ }
+ });
+ }
+ function updateCitySelect() {
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {'search': 'cities','countyId': $("#advSearchCounties").val()},
+ success: function(data) {
+ var currentVal = $("#advSearchCities").val();
+ $("#advSearchCities").html('<option value="">Cities</option>');
+ console.log('clear city select');
+ $.each(data, function(index, city) {
+ var sel
+ = (currentVal == city.city_id)
+ ? ' selected'
+ : '';
+ $("#advSearchCities").append('<option value="' + city.city_id
+ + '" '+sel+'>'
+ + city.city_name + '</option>');
+ console.log('add city ' + city.city_name + ' to list');
});
}
});
$this->parkSearch = array();
$this->regionSearch = array();
$this->countySearch = array();
+ $this->citySearch = array();
$this->reviewedCount = 0;
try {
$dbh = Toolkit_Database::getInstance();
$this->countySearch[$county['county_id']]
= $county['county_name'];
}
+ $sql = "
+ SELECT *
+ FROM city
+ WHERE city_id IN (
+ SELECT DISTINCT city_id
+ FROM member
+ WHERE active
+ AND city_id is not null)
+ ORDER BY city_name";
+ $stmt = $dbh->query($sql);
+ while ($city = $stmt->fetch()) {
+ $this->citySearch[$city['city_id']]
+ = $city['city_name'];
+ }
} catch (PDOException $e) {
Toolkit_Common::handleError($e);
}
init: function(){
// update when activities changes
$("#activity").change(function(){
- findATrailSearch.updateParksSelect();
+// findATrailSearch.updateParksSelect();
findATrailSearch.updateCountySelect();
- findATrailSearch.updateDestinationSelect();
+// findATrailSearch.updateDestinationSelect();
});
if ($("#activity").val()) {
- findATrailSearch.updateParksSelect();
+// findATrailSearch.updateParksSelect();
findATrailSearch.updateCountySelect();
- findATrailSearch.updateDestinationSelect();
+// findATrailSearch.updateDestinationSelect();
}
//update when parks changes
$("#park").change(function(){
findATrailSearch.updateActivitySelect();
findATrailSearch.updateCountySelect();
- findATrailSearch.updateDestinationSelect();
+// findATrailSearch.updateDestinationSelect();
});
if ($("#park").val()) {
findATrailSearch.updateActivitySelect();
findATrailSearch.updateCountySelect();
- findATrailSearch.updateDestinationSelect();
+// findATrailSearch.updateDestinationSelect();
}
// update when destination changes
- $("#destination").change(function(){
- findATrailSearch.updateActivitySelect();
- findATrailSearch.updateParksSelect();
- findATrailSearch.updateCountySelect();
- });
- if ($("#destination").val()) {
- findATrailSearch.updateActivitySelect();
- findATrailSearch.updateParksSelect();
- findATrailSearch.updateCountySelect();
- }
+// $("#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();
+// findATrailSearch.updateParksSelect();
+ findATrailSearch.updateCitySelect();
+// findATrailSearch.updateDestinationSelect();
});
if ($("#county").val()) {
findATrailSearch.updateActivitySelect();
- findATrailSearch.updateParksSelect();
- findATrailSearch.updateDestinationSelect();
+// findATrailSearch.updateParksSelect();
+ findATrailSearch.updateCitySelect();
+// 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>');
- });
- }
- }
- });
- },
+// 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',
}
}
});
+ },
+ updateCitySelect:function(){
+ $.ajax({
+ dataType: 'json',
+ url: 'ajax/form.json',
+ data: {
+ 'search': 'cities',
+ 'activityId': $("#activity").val(),
+ 'parkId': $("#park").val(),
+ 'countyId': $("#county").val()
+ },
+ success: function(data) {
+ var currentVal = $("#city").val();
+ $("#city").html('<option value="">City</option>');
+ if (data != null) {
+ //console.info(data);
+ $.each(data, function(index, city) {
+ var sel
+ = (currentVal == city.city_id)
+ ? ' selected'
+ : '';
+ $("#city").append('<option value="' + city.city_id
+ + '" '+sel+'>'
+ + city.city_name + '</option>');
+ });
+ }
+ }
+ });
}
}
}?>
</select>
<select
- name="parkId"
- id="park"
- flexy:if="parkSearch">
- <option value="">Parks</option>
- <?php foreach($t->parkSearch as $id => $label) {
- echo '<option
- value="'.$id.'">
- '.$label.'</option>';
- }?>
- </select>
- <select
name="countyId"
id="county"
flexy:if="countySearch">
}?>
</select>
<select
- name="destinationId"
- id="destination"
- flexy:if="destinationSearch">
- <option value="">Destinations</option>
- <?php foreach($t->destinationSearch as $id => $label) {
+ name="cityId"
+ id="city"
+ flexy:if="citySearch">
+ <option value="">City</option>
+ <?php foreach($t->citySearch as $id => $label) {
echo '<option
value="'.$id.'">
'.$label.'</option>';