private function _search_form() { $search_form = View::factory('admin/reports/search_form'); // Handling location filter $location_filter = isset($_GET['location_filter']); if (!$location_filter) { if (isset($_GET['start_loc'])) { unset($_GET['start_loc']); } if (isset($_GET['alert_radius'])) { unset($_GET['alert_radius']); } } else { $_GET['radius'] = $_GET['alert_radius']; } $search_form->location_filter = $location_filter; $search_form->start_loc = isset($_GET['start_loc']) ? $_GET['start_loc'] : array(0, 0); // Get the date of the oldest report if (!empty($_GET['from'])) { $date_from = strtotime($_GET['from']); } else { $date_from = Incident_Model::get_oldest_report_timestamp(); } // Get the date of the latest report if (!empty($_GET['to'])) { $date_to = strtotime($_GET['to']); } else { $date_to = Incident_Model::get_latest_report_timestamp(); } $search_form->date_from = $date_from; $search_form->date_to = $date_to; // Categories if (!isset($_GET['c']) or !is_array($_GET['c'])) { $_GET['c'] = isset($_GET['c']) ? array($_GET['c']) : array(); } $search_form->categories = $_GET['c']; // Media if (!isset($_GET['m']) or !is_array($_GET['m'])) { $_GET['m'] = isset($_GET['m']) ? array($_GET['m']) : array(); } $search_form->media = $_GET['m']; // Mode if (!isset($_GET['mode']) or !is_array($_GET['mode'])) { $_GET['mode'] = isset($_GET['mode']) ? array($_GET['mode']) : array(); } $search_form->mode = $_GET['mode']; // Approved $search_form->approved = $_GET['a'] = isset($_GET['a']) ? $_GET['a'] : 'all'; if ($_GET['a'] == 'all') { unset($_GET['a']); } // Verified $search_form->verified = $_GET['v'] = isset($_GET['v']) ? $_GET['v'] : 'all'; if ($_GET['v'] == 'all') { unset($_GET['v']); } // Load the alert radius view $alert_radius_view = new View('alerts/radius'); $alert_radius_view->show_usage_info = FALSE; $alert_radius_view->enable_find_location = TRUE; $alert_radius_view->css_class = "map_holder_reports"; $search_form->alert_radius_view = $alert_radius_view; return $search_form; }
/** * Displays all reports. */ public function index() { // Cacheable Controller $this->is_cachable = TRUE; $this->template->header->this_page = 'reports'; $this->template->content = new View('reports'); $this->themes->js = new View('reports_js'); // Store any exisitng URL parameters $this->themes->js->url_params = json_encode($_GET); // Enable the map $this->themes->map_enabled = TRUE; // Set the latitude and longitude $this->themes->js->latitude = Kohana::config('settings.default_lat'); $this->themes->js->longitude = Kohana::config('settings.default_lon'); $this->themes->js->default_map = Kohana::config('settings.default_map'); $this->themes->js->default_zoom = Kohana::config('settings.default_zoom'); // Load the alert radius view $alert_radius_view = new View('alert_radius_view'); $alert_radius_view->show_usage_info = FALSE; $alert_radius_view->enable_find_location = FALSE; $alert_radius_view->css_class = "rb_location-radius"; $this->template->content->alert_radius_view = $alert_radius_view; // Get locale $l = Kohana::config('locale.language.0'); // Get the report listing view $report_listing_view = $this->_get_report_listing_view($l); // Set the view $this->template->content->report_listing_view = $report_listing_view; // Load the category $category_id = (isset($_GET['c']) and intval($_GET['c']) > 0) ? intval($_GET['c']) : 0; $category = ORM::factory('category', $category_id); if ($category->loaded) { $translated_title = Category_Lang_Model::category_title($category_id, $l); // Set the category title $this->template->content->category_title = $translated_title ? $translated_title : $category->category_title; } else { $this->template->content->category_title = ""; } // Collect report stats $this->template->content->report_stats = new View('reports_stats'); // Total Reports $total_reports = Incident_Model::get_total_reports(TRUE); // Get the date of the oldest report $oldest_timestamp = Incident_Model::get_oldest_report_timestamp(); // Get the date of the latest report $latest_timestamp = Incident_Model::get_latest_report_timestamp(); // Round the number of days up to the nearest full day $days_since = ceil((time() - $oldest_timestamp) / 86400); $avg_reports_per_day = $days_since < 1 ? $total_reports : round($total_reports / $days_since, 2); // Percent Verified $total_verified = Incident_Model::get_total_reports_by_verified(TRUE); $percent_verified = $total_reports == 0 ? '-' : round($total_verified / $total_reports * 100, 2) . '%'; // Category tree view $this->template->content->category_tree_view = category::get_category_tree_view(); // Additional view content $this->template->content->oldest_timestamp = $oldest_timestamp; $this->template->content->latest_timestamp = $latest_timestamp; $this->template->content->report_stats->total_reports = $total_reports; $this->template->content->report_stats->avg_reports_per_day = $avg_reports_per_day; $this->template->content->report_stats->percent_verified = $percent_verified; $this->template->content->services = Service_Model::get_array(); $this->template->header->header_block = $this->themes->header_block(); }
/** * Displays all reports. */ public function index() { // Cacheable Controller $this->is_cachable = TRUE; $this->template->header->this_page = 'reports'; $this->template->content = new View('reports/main'); $this->themes->js = new View('reports/reports_js'); $this->template->header->page_title .= Kohana::lang('ui_main.reports') . Kohana::config('settings.title_delimiter'); // Store any exisitng URL parameters $this->themes->js->url_params = json_encode($_GET); // Enable the map $this->themes->map_enabled = TRUE; // Set the latitude and longitude $this->themes->js->latitude = Kohana::config('settings.default_lat'); $this->themes->js->longitude = Kohana::config('settings.default_lon'); $this->themes->js->default_map = Kohana::config('settings.default_map'); $this->themes->js->default_zoom = Kohana::config('settings.default_zoom'); // Get Default Color $this->themes->js->default_map_all = $this->template->content->default_map_all = Kohana::config('settings.default_map_all'); // Get default icon $this->themes->js->default_map_all_icon = $this->template->content->default_map_all_icon = ''; if (Kohana::config('settings.default_map_all_icon_id')) { $icon_object = ORM::factory('media')->find(Kohana::config('settings.default_map_all_icon_id')); $this->themes->js->default_map_all_icon = $this->template->content->default_map_all_icon = Kohana::config('upload.relative_directory') . "/" . $icon_object->media_thumb; } // Load the alert radius view $alert_radius_view = new View('alerts/radius'); $alert_radius_view->show_usage_info = FALSE; $alert_radius_view->enable_find_location = TRUE; $alert_radius_view->css_class = "rb_location-radius"; $this->template->content->alert_radius_view = $alert_radius_view; // Get locale $l = Kohana::config('locale.language.0'); // Get the report listing view $report_listing_view = $this->_get_report_listing_view($l); // Set the view $this->template->content->report_listing_view = $report_listing_view; // Load the category $category_id = (isset($_GET['c']) and intval($_GET['c']) > 0) ? intval($_GET['c']) : 0; $category = ORM::factory('category', $category_id); if ($category->loaded) { // Set the category title $this->template->content->category_title = Category_Lang_Model::category_title($category_id, $l); } else { $this->template->content->category_title = ""; } // Collect report stats $this->template->content->report_stats = new View('reports/stats'); // Total Reports $total_reports = Incident_Model::get_total_reports(TRUE); // Get the date of the oldest report if (isset($_GET['s']) and !empty($_GET['s']) and intval($_GET['s']) > 0) { $oldest_timestamp = intval($_GET['s']); } else { $oldest_timestamp = Incident_Model::get_oldest_report_timestamp(); } // Get the date of the latest report if (isset($_GET['e']) and !empty($_GET['e']) and intval($_GET['e']) > 0) { $latest_timestamp = intval($_GET['e']); } else { $latest_timestamp = Incident_Model::get_latest_report_timestamp(); } // Round the number of days up to the nearest full day $days_since = ceil((time() - $oldest_timestamp) / 86400); $avg_reports_per_day = $days_since < 1 ? $total_reports : round($total_reports / $days_since, 2); // Percent Verified $total_verified = Incident_Model::get_total_reports_by_verified(TRUE); $percent_verified = $total_reports == 0 ? '-' : round($total_verified / $total_reports * 100, 2) . '%'; // Category tree view $this->template->content->category_tree_view = category::get_category_tree_view(); // Additional view content $this->template->content->custom_forms_filter = new View('reports/submit_custom_forms'); $this->template->content->custom_forms_filter->disp_custom_fields = customforms::get_custom_form_fields(); $this->template->content->custom_forms_filter->search_form = TRUE; $this->template->content->oldest_timestamp = $oldest_timestamp; $this->template->content->latest_timestamp = $latest_timestamp; $this->template->content->report_stats->total_reports = $total_reports; $this->template->content->report_stats->avg_reports_per_day = $avg_reports_per_day; $this->template->content->report_stats->percent_verified = $percent_verified; $this->template->content->services = Service_Model::get_array(); }