From: Steve Sutton Date: Tue, 23 Jul 2013 14:33:15 +0000 (+0000) Subject: Updates on the trail search X-Git-Tag: v1.0~71 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a3d2d2e00cd38308d25a47ab2440cf5cf95a29c7;p=web%2FMichiganTrailMaps.git Updates on the trail search The Parks select is now linked to activitities. When you change the activity it will update the parks. The amenities part is passing through the activityId, parkId, regionId, and countyId as hidden fields (for a filter). --- diff --git a/Toolkit/Members/UserSearchForm.php b/Toolkit/Members/UserSearchForm.php index 0af0d37..501b7d6 100644 --- a/Toolkit/Members/UserSearchForm.php +++ b/Toolkit/Members/UserSearchForm.php @@ -386,10 +386,6 @@ class Toolkit_Members_UserSearchForm foreach ($this->memberCatsAssignedToPage as $id) { $isAccommodationCategory->bindParam(':cid', $id, PDO::PARAM_INT); $isAccommodationCategory->execute(); -// if (!$isAccommodationCategory->fetchColumn()) { -// continue; -// } -// $stmt->bindParam(':cid', $id, PDO::PARAM_INT); $stmt->execute(); while ($row = $stmt->fetch()) { $amenities[$row['amenity_name']] = $row['amenity_id']; @@ -571,10 +567,8 @@ class Toolkit_Members_UserSearchForm ) { $GLOBALS['styleSheets'][] = BASE_URL . 'Toolkit/Members/css/member.css'; - $GLOBALS['styleSheets'][] = JQUERY_UI_CDN_CSS; - $GLOBALS['topScripts'][] = JQUERY_UI_CDN_JS; -// $GLOBALS['bottomScripts'][] -// = BASE_URL . 'Toolkit/Members/libjs/userSearchForm.js'; + $GLOBALS['styleSheets'][] = JQUERY_UI_CDN_CSS; + $GLOBALS['topScripts'][] = JQUERY_UI_CDN_JS; $tpl = new HTML_Template_Flexy($flexyOpts); $tpl->compile($this->formTemplate); @@ -582,11 +576,10 @@ class Toolkit_Members_UserSearchForm $amenities = $this->getMemberAmenities($this->dbh); $parks = $this->getParks(); $regions = $this->getAvailableRegions($this->dbh); -// $regions = $this->memberRegionsAssignedToPage; $counties = $this->getCounties(); - $page = new stdClass(); - $page->formURL = BASE_URL . 'index.php?catid=' . $this->_catid; + $page = new stdClass(); + $page->formURL = BASE_URL . 'index.php?catid=' . $this->_catid; $page->activities = (!empty($activity) && count($activity) > 1) ? $activity diff --git a/Toolkit/Members/formAjax.php b/Toolkit/Members/formAjax.php index 12babaa..63fd987 100644 --- a/Toolkit/Members/formAjax.php +++ b/Toolkit/Members/formAjax.php @@ -1,14 +1,55 @@ prepare($sql); + $stmt->bindParam(':category', $activityId, PDO::PARAM_INT); + $stmt->execute(); + echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC)); + } + if (isset($_REQUEST['activityId']) && !$activityId) { + $sql = " + SELECT category_id,name + FROM members.category + WHERE category_id IN ( + SELECT category_id + FROM members.member_category + WHERE member_id IN ( + SELECT member_id + FROM members.member_category + WHERE category_id IN ( + SELECT category_id + FROM members.category + WHERE parent_id = " . PARENT_CATEGORY_ACTIVITIES . "))) + AND parent_id = " . PARENT_CATEGORY_PARKS . " + ORDER BY name"; + $stmt = $dbh->prepare($sql); + $stmt->execute(); + echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC)); + } + if ($regionId) { $sql = " SELECT * FROM members.county @@ -17,11 +58,7 @@ try { SELECT region FROM members.member WHERE active = true - AND member_id IN ( - SELECT member_id - FROM members.member_category - WHERE - ) + AND region = :region ) ORDER BY county_name"; $stmt = $dbh->prepare($sql); @@ -29,24 +66,21 @@ try { $stmt->execute(); echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC)); } - if ($regionId) { + if (isset($_REQUEST['regionId']) && !$regionId) { $sql = " SELECT * FROM members.county - WHERE region_id = :region - AND region_id IN ( + WHERE region_id IN ( SELECT region FROM members.member WHERE active = true - AND region = :region ) ORDER BY county_name"; $stmt = $dbh->prepare($sql); - $stmt->bindParam(':region', $regionId, PDO::PARAM_INT); $stmt->execute(); echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC)); } } catch(PDOException $e) { - + Toolkit_Common::handleError($e); } diff --git a/Toolkit/Members/templates/userSearchForm.html b/Toolkit/Members/templates/userSearchForm.html index 46505fc..15671f4 100644 --- a/Toolkit/Members/templates/userSearchForm.html +++ b/Toolkit/Members/templates/userSearchForm.html @@ -202,6 +202,27 @@ value="Search"> + +
+ + '; + } + if ($park = filter_var($_REQUEST['parkId'], FILTER_VALIDATE_INT)) { + echo ''; + } + if ($region = filter_var($_REQUEST['regionId'], FILTER_VALIDATE_INT)) { + echo ''; + } + if ($county = filter_var($_REQUEST['countyId'], FILTER_VALIDATE_INT)) { + echo ''; + } + ?>
Filter Results:
@@ -239,7 +260,35 @@ if ($("#advSearchRegions").val()) { updateCountySelect(); } + $("#advSearchActivities").change(function(){ + updateParksSelect(); + }); + if ($("#advSearchActivities").val()) { + updateParksSelect(); + } }); + function updateParksSelect() { + $.ajax({ + dataType: 'json', + url: 'ajax/form.json', + data: {'activityId': $("#advSearchActivities").val()}, + success: function(data) { + var currentVal = $("#advSearchParks").val(); + $("#advSearchParks").html(''); + $.each(data, function(index, park) { + //console.log(park); + var sel + = (currentVal == park.category_id) + ? ' selected' + : ''; + $("#advSearchParks").append(''); + //console.log('park: ' + park.name); + }); + } + }); + } function updateCountySelect() { $.ajax({ dataType: 'json',