update search form
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 8 Jul 2013 20:05:34 +0000 (20:05 +0000)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 8 Jul 2013 20:05:34 +0000 (20:05 +0000)
Adding amenities to form
add some style for the group of checkboxes

Toolkit/Members/SearchQueryGenerator.php
Toolkit/Members/UserSearchForm.php
Toolkit/Members/templates/userSearchForm.html

index 9d847ef..b0232ff 100644 (file)
@@ -245,6 +245,10 @@ class Toolkit_Members_SearchQueryGenerator
                     'filter' => FILTER_VALIDATE_INT,
                     'flags'  => FILTER_FORCE_ARRAY
                 ),
+                'amenity'        => array(
+                    'filter' => FILTER_VALIDATE_INT,
+                    'flags'  => FILTER_FORCE_ARRAY
+                ),
                 'park'            => array(
                     'filter' => FILTER_VALIDATE_INT,
                     'flags'  => FILTER_FORCE_ARRAY
@@ -252,7 +256,14 @@ class Toolkit_Members_SearchQueryGenerator
             )
         );
         extract($postedArrays);
-
+//        var_dump($postedArrays);exit;
+        if (!empty($amenity) && $amenity[0]) {
+            $params[] = "m.member_id IN (
+                SELECT member_id
+                  FROM member_amenity
+                 WHERE amenity_id IN ("
+                .implode(',', $amenity)."))";
+        }
         if (!empty($activity) && $activity[0]) {
             $params[] = "m.member_id IN (
                 SELECT member_id
index 1f0cb02..9c42e0e 100644 (file)
@@ -380,21 +380,16 @@ class Toolkit_Members_UserSearchForm
              WHERE m.new_member <> CAST(1 AS BOOLEAN)
                AND m.active = CAST(1 AS BOOLEAN)
                AND a.display_form = CAST(1 AS BOOLEAN)
-               AND (mc.category_id = :cid
-                OR mc.category_id in (
-                    SELECT category_id
-                      FROM category
-                     WHERE parent_id      = :cid))
              ORDER BY amenity_name";
 
                        $stmt = $dbh->prepare($sql);
                        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);
+//                if (!$isAccommodationCategory->fetchColumn()) {
+//                    continue;
+//                }
+//                             $stmt->bindParam(':cid', $id, PDO::PARAM_INT);
                                $stmt->execute();
                                while ($row = $stmt->fetch()) {
                                        $amenities[$row['amenity_name']] = $row['amenity_id'];
@@ -578,10 +573,11 @@ class Toolkit_Members_UserSearchForm
         $tpl = new HTML_Template_Flexy($flexyOpts);
         $tpl->compile($this->formTemplate);
 
-        $activity = $this->getActivities();
-        $parks    = $this->getParks();
-        $regions  = $this->memberRegionsAssignedToPage;
-        $counties = $this->getCounties();
+        $activity  = $this->getActivities();
+        $amenities = $this->getMemberAmenities($this->dbh);
+        $parks     = $this->getParks();
+        $regions   = $this->memberRegionsAssignedToPage;
+        $counties  = $this->getCounties();
 
         $page             = new stdClass();
         $page->formURL    = BASE_URL . 'index.php?catid=' . $this->_catid;
@@ -601,6 +597,8 @@ class Toolkit_Members_UserSearchForm
             = (!empty($counties) && count($counties) > 1)
             ? $counties
             : null;
+        $page->amenities = $amenities;
+//        var_dump($page);exit;
 
         return $tpl->bufferedOutputObject($page);
        }
index 3924cf4..e457d6c 100644 (file)
@@ -1,13 +1,14 @@
 <style>
     fieldset #glm-member-search {width:100%;}
     fieldset #glm-member-search label {width:25%;text-align: right;}
-    .fieldcontain {display:block;width:100%;clear:right; margin: 10px 0;}
+    .fieldcontain {display:block;width:100%;clear:right; margin: 10px 0;padding: 5px;}
        .fieldcontain input[type=submit] {
                float: right;
        }
-    .glm-chbx-label {width:250px;text-align: left;float:left;display:inline;}
+    .glm-chbx-label {width:280px;text-align: left;float:left;display:inline;}
     .glm-chbx {width:580px;text-align: left;display:block;clear:right;float:right;}
-    .fieldHdr {width: 120px;float: left;display: block;text-align: right;}
+    .fieldHdr {width: 120px;float: left;display: block;text-align: right;margin:0 15px;font-weight: bold;}
+    .fieldHdr2 {width: 100%;display: block;text-align: left;margin:0 15px;font-weight: bold;}
 </style>
 <div
     id="category-search"
                     placeholder="trail name"
                     value="{_POST[member_name]}">
             </div>
+            <div flexy:if="regions" class="fieldcontain">
+                <label class="fieldHdr">Regions</label>
+                <select name="region">
+                    <option value="">-- Select --</option>
+                    {foreach:regions,id,name}
+                    <?php
+                    echo '<option value="'.$id.'"
+                        '.(($id == $_POST['region'])?'selected':'')
+                        .'>'.$name.'</option>';
+                    ?>
+                    {end:}
+                </select>
+            </div>
+            <div flexy:if="counties" class="fieldcontain">
+                <label class="fieldHdr">Counties</label>
+                <select name="county">
+                    <option value="">-- Select --</option>
+                    {foreach:counties,id,name}
+                    <?php
+                    echo '<option value="'.$id.'"
+                        '.(($id == $_POST['county'])?'selected':'')
+                        .'>'.$name.'</option>';
+                    ?>
+                    {end:}
+                </select>
+            </div>
             <div flexy:if="activities" class="fieldcontain">
-                <label class="fieldHdr">Activities</label>
+                <label class="fieldHdr2">Activities</label>
                 <div class="glm-chbx">
                 {foreach:activities,id,name}
                 <label for="chbx-{id:h}" class="glm-chbx-label">
@@ -49,7 +76,7 @@
                 </div>
             </div>
             <div flexy:if="parks" class="fieldcontain">
-                <label class="fieldHdr">Parks</label>
+                <label class="fieldHdr2">Parks</label>
                 <div class="glm-chbx">
                 {foreach:parks,id,name}
                 <label for="chbx-{id:h}" class="glm-chbx-label">
                 {end:}
                 </div>
             </div>
-            <div flexy:if="regions" class="fieldcontain">
-                <label class="fieldHdr">Regions</label>
-                <select name="region">
-                    <option value="">-- Select --</option>
-                    {foreach:regions,id,name}
-                    <?php
-                    echo '<option value="'.$id.'"
-                        '.(($id == $_POST['region'])?'selected':'')
-                        .'>'.$name.'</option>';
-                    ?>
-                    {end:}
-                </select>
-            </div>
-            <div flexy:if="counties" class="fieldcontain">
-                <label class="fieldHdr">Counties</label>
-                <select name="county">
-                    <option value="">-- Select --</option>
-                    {foreach:counties,id,name}
-                    <?php
-                    echo '<option value="'.$id.'"
-                        '.(($id == $_POST['county'])?'selected':'')
-                        .'>'.$name.'</option>';
-                    ?>
-                    {end:}
-                </select>
+
+            <div flexy:if="parks" class="fieldcontain">
+                <label class="fieldHdr2">Amenities</label>
+                <div class="glm-chbx">
+                {foreach:amenities,name,id}
+                <label for="amchbx-{id:h}" class="glm-chbx-label">
+                  <?php
+                  echo '<input
+                    id="amchbx-'.$id.'"
+                    type="checkbox"
+                    name="amenity[]"
+                    value="'.$id.'"
+                    '.((isset($_POST['amenity'])
+                    && is_array($_POST['amenity'])
+                    && in_array($id, $_POST['amenity']))?'checked':'').'
+                  >';
+                  ?>
+                  {name}
+                </label>
+                {end:}
+                </div>
             </div>
+
             <div class="fieldcontain">
                 <input class="submit" type="submit" value="Search">
             </div>