Permalink
Browse files

Added categories to the view, enabled select box

  • Loading branch information...
1 parent b98d13c commit fb29ff42594a7d73702975761c3315cc6c7ce295 Ivan Jovanovic committed Feb 26, 2011
Showing with 27 additions and 7 deletions.
  1. +3 −2 controllers/mobile/reports.php
  2. +24 −5 views/mobile/reports.php
@@ -155,13 +155,14 @@ public function search($town = false)
$this->template->content->incidents = $incidents;
$this->template->content->category = null;
-
- $this->templat->content->categories = ORM::factory('category')
+ $categories = ORM::factory('category')
->where('category_visible', '1')
->where('parent_id', '0')
->where('category_trusted != 1')
->orderby('category_title', 'ASC')
->find_all();
+
+ $this->template->content->categories = $categories;
}
/**
View
@@ -28,12 +28,31 @@
}
?>
</select>
- <!--<label for="category">Category</label>
+ <label for="category">Category</label>
<select name="category" id="category">
- <option value="0">all</option>
- <option value="la">la</option>
- <option value="li">li</option>
- </select>-->
+ <?php
+ $selected_category = isset($_GET['category']) ? $_GET['category'] : '0';
+
+ echo '<option value="0"';
+ echo 0 == $selected_category ? 'selected' : '';
+ echo '>All categories</option>';
+
+ foreach ($categories as $category) {
+
+ echo '<option value="' . $category->id . '"';
+ echo $category->id == $selected_category ? 'selected' : '';
+ echo '>' . $category->category_title . '</option>';
+
+ if ($category->children->count() > 0) {
+ foreach ($category->children as $child) {
+ echo '<option value="' . $child->id . '"';
+ echo $child->id == $selected_category ? 'selected' : '';
+ echo '>--' . $child->category_title . '</option>';
+ }
+ }
+ }
+ ?>
+ </select>
<label for="order">Order By</label>
<select name="order" id="order">
<?php

0 comments on commit fb29ff4

Please sign in to comment.