本文整理匯總了PHP中Incident_Model::get_total_reports_by_verified方法的典型用法代碼示例。如果您正苦於以下問題:PHP Incident_Model::get_total_reports_by_verified方法的具體用法?PHP Incident_Model::get_total_reports_by_verified怎麽用?PHP Incident_Model::get_total_reports_by_verified使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Incident_Model
的用法示例。
在下文中一共展示了Incident_Model::get_total_reports_by_verified方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
/**
* 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();
}
示例2: index
//.........這裏部分代碼省略.........
foreach ($incident->category AS $category)
{
$ct = (string)$category->category_title;
if( ! isset($localized_categories[$ct]))
{
$translated_title = Category_Lang_Model::category_title($category->id,$l);
$localized_categories[$ct] = $category->category_title;
if($translated_title)
{
$localized_categories[$ct] = $translated_title;
}
}
}
}
$this->template->content->localized_categories = $localized_categories;
$this->template->content->incidents = $incidents;
//Set default as not showing pagination. Will change below if necessary.
$this->template->content->pagination = "";
// Pagination and Total Num of Report Stats
if ($pagination->total_items == 1)
{
$plural = "";
}
else
{
$plural = "s";
}
if ($pagination->total_items > 0)
{
$current_page = ($pagination->sql_offset/ (int) Kohana::config('settings.items_per_page')) + 1;
$total_pages = ceil($pagination->total_items/ (int) Kohana::config('settings.items_per_page'));
if ($total_pages > 1)
{ // If we want to show pagination
$this->template->content->pagination_stats = Kohana::lang('ui_admin.showing_page').' '.$current_page.' '.Kohana::lang('ui_admin.of').' '.$total_pages.' '.Kohana::lang('ui_admin.pages');
$this->template->content->pagination = $pagination;
}
else
{ // If we don't want to show pagination
$this->template->content->pagination_stats = $pagination->total_items.' '.Kohana::lang('ui_admin.reports');
}
}
else
{
$this->template->content->pagination_stats = '('.$pagination->total_items.' report'.$plural.')';
}
// Category Title, if Category ID available
$category_id = ( isset($_GET['c']) AND !empty($_GET['c']) )
? $_GET['c'] : "0";
$category = ORM::factory('category')
->find($category_id);
if($category->loaded)
{
$translated_title = Category_Lang_Model::category_title($category_id,$l);
if($translated_title)
{
$this->template->content->category_title = $translated_title;
}else{
$this->template->content->category_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);
// Average Reports Per Day
$oldest_timestamp = Incident_Model::get_oldest_report_timestamp();
// Round the number of days up to the nearest full day
$days_since = ceil((time() - $oldest_timestamp) / 86400);
if ($days_since < 1) {
$avg_reports_per_day = $total_reports;
}else{
$avg_reports_per_day = 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).'%';
$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->header->header_block = $this->themes->header_block();
}
示例3: index
/**
* 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();
}
示例4: index
/**
* Displays all reports.
*/
public function index($cluster_id = 0)
{
$this->template->header->this_page = 'reports';
$this->template->content = new View('reports');
// Filter By Category
$category_filter = isset($_GET['c']) && !empty($_GET['c']) ? "category_id = " . $_GET['c'] : " 1=1 ";
// Pagination
$pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => ORM::factory('incident')->join('incident_category', 'incident.id', 'incident_category.incident_id')->where('incident_active', '1')->where($category_filter)->count_all()));
$incidents = ORM::factory('incident')->select('DISTINCT incident.*')->join('incident_category', 'incident.id', 'incident_category.incident_id')->where('incident_active', '1')->where($category_filter)->groupby('incident.id')->orderby('incident_date', 'desc')->find_all((int) Kohana::config('settings.items_per_page'), $pagination->sql_offset);
$this->template->content->incidents = $incidents;
//Set default as not showing pagination. Will change below if necessary.
$this->template->content->pagination = '';
// Pagination and Total Num of Report Stats
if ($pagination->total_items == 1) {
$plural = '';
} else {
$plural = 's';
}
if ($pagination->total_items > 0) {
$current_page = $pagination->sql_offset / (int) Kohana::config('settings.items_per_page') + 1;
$total_pages = ceil($pagination->total_items / (int) Kohana::config('settings.items_per_page'));
if ($total_pages > 1) {
// If we want to show pagination
$this->template->content->pagination_stats = Kohana::lang('ui_admin.showing_page') . ' ' . $current_page . ' ' . Kohana::lang('ui_admin.of') . ' ' . $total_pages . ' ' . Kohana::lang('ui_admin.pages');
$this->template->content->pagination = $pagination;
} else {
// If we don't want to show pagination
$this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.reports');
}
} else {
$this->template->content->pagination_stats = '(' . $pagination->total_items . ' report' . $plural . ')';
}
$icon_html = array();
$icon_html[1] = "<img src=\"" . url::base() . "media/img/image.png\">";
//image
$icon_html[2] = "<img src=\"" . url::base() . "media/img/video.png\">";
//video
$icon_html[3] = "";
//audio
$icon_html[4] = "";
//news
$icon_html[5] = "";
//podcast
//Populate media icon array
$this->template->content->media_icons = array();
foreach ($incidents as $incident) {
$incident_id = $incident->id;
if (ORM::factory('media')->where('incident_id', $incident_id)->count_all() > 0) {
$medias = ORM::factory('media')->where('incident_id', $incident_id)->find_all();
//Modifying a tmp var prevents Kohona from throwing an error
$tmp = $this->template->content->media_icons;
$tmp[$incident_id] = '';
foreach ($medias as $media) {
$tmp[$incident_id] .= $icon_html[$media->media_type];
$this->template->content->media_icons = $tmp;
}
}
}
// Category Title, if Category ID available
$category_id = isset($_GET['c']) && !empty($_GET['c']) ? $_GET['c'] : "0";
$category = ORM::factory('category')->find($category_id);
$this->template->content->category_title = $category->loaded ? $category->category_title : "";
// Collect report stats
// Total Reports
$total_reports = Incident_Model::get_total_reports(TRUE);
// Average Reports Per Day
$oldest_timestamp = Incident_Model::get_oldest_report_timestamp();
// Round the number of days up to the nearest full day
$days_since = ceil((time() - $oldest_timestamp) / 86400);
$avg_reports_per_day = round($total_reports / $days_since, 2);
// Percent Verified
$total_verified = Incident_Model::get_total_reports_by_verified(true);
$percent_verified = round($total_verified / $total_reports * 100, 2) . '%';
$this->template->content->total_reports = $total_reports;
$this->template->content->avg_reports_per_day = $avg_reports_per_day;
$this->template->content->percent_verified = $percent_verified;
}
示例5: index
//.........這裏部分代碼省略.........
foreach($query as $row){
$category_master[$row->id]['title'] = $row->category_title;
$category_master[$row->id]['color'] = $row->category_color;
$category_master[$row->id]['category_image_thumb'] = $row->category_image_thumb;
$localized_categories[(string)$row->category_title] = $row->category_title;
$localized_categories[(string)$row->category_title]['title'] = $row->category_title;
$localized_categories[(string)$row->category_title]['color'] = $row->category_title;
}
$this->template->content->category_master = $category_master;
$this->template->content->localized_categories = $localized_categories;
$this->template->content->incidents = $incidents;
//Set default as not showing pagination. Will change below if necessary.
$this->template->content->pagination = "";
// Pagination and Total Num of Report Stats
if ($pagination->total_items == 1)
{
$plural = "";
}
else
{
$plural = "s";
}
if ($pagination->total_items > 0)
{
$current_page = ($pagination->sql_offset/ (int) Kohana::config('settings.items_per_page')) + 1;
$total_pages = ceil($pagination->total_items/ (int) Kohana::config('settings.items_per_page'));
if ($total_pages > 1)
{ // If we want to show pagination
if((isset($_GET["l"]) && ($_GET["l"] === "ja_JP" || $_GET["l"] === "")) OR (!isset($_GET["l"]))){
$this->template->content->pagination_stats = "全".$total_pages."中".$current_page.Kohana::lang('ui_admin.showing_page');
}else{
$this->template->content->pagination_stats = Kohana::lang('ui_admin.showing_page').' '.$current_page.' '.Kohana::lang('ui_admin.of').' '.$total_pages.' '.Kohana::lang('ui_admin.pages');
}
$this->template->content->pagination = $pagination;
}
else
{ // If we don't want to show pagination
$this->template->content->pagination_stats = $pagination->total_items.' '.Kohana::lang('ui_admin.reports');
}
}
else
{
$this->template->content->pagination_stats = '('.$pagination->total_items.' report'.$plural.')';
}
// Category Title, if Category ID available
$category_id = ( isset($_GET['c']) AND !empty($_GET['c']) )
? $_GET['c'] : "0";
$category = ORM::factory('category')
->find($category_id);
if($category->loaded)
{
$translated_title = Category_Lang_Model::category_title($category_id,$l);
if($translated_title)
{
$this->template->content->category_title = $translated_title;
}else{
$this->template->content->category_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);
// Average Reports Per Day
$oldest_timestamp = Incident_Model::get_oldest_report_timestamp();
// Round the number of days up to the nearest full day
$days_since = ceil((time() - $oldest_timestamp) / 86400);
if ($days_since < 1) {
$avg_reports_per_day = $total_reports;
}else{
$avg_reports_per_day = 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).'%';
$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->header->action_name = Kohana::lang('ui_main.reports_title_index');
$this->template->header->header_block = $this->themes->header_block();
}
示例6: index
/**
* Displays all reports.
*/
public function index($cluster_id = 0)
{
$this->template->header->this_page = 'reports';
$this->template->content = new View('reports');
$db = new Database();
$filter = isset($_GET['c']) && !empty($_GET['c']) && $_GET['c'] != 0 ? " AND ( c.id='" . $_GET['c'] . "' OR \n\t\t\t\tc.parent_id='" . $_GET['c'] . "' ) " : " AND 1 = 1";
if (isset($_GET['sw']) && !empty($_GET['sw']) && count($southwest = explode(",", $_GET['sw'])) > 1 && isset($_GET['ne']) && !empty($_GET['ne']) && count($northeast = explode(",", $_GET['ne'])) > 1) {
list($longitude_min, $latitude_min) = $southwest;
list($longitude_max, $latitude_max) = $northeast;
$filter .= " AND l.latitude >=" . $latitude_min . " AND l.latitude <=" . $latitude_max;
$filter .= " AND l.longitude >=" . $longitude_min . " AND l.longitude <=" . $longitude_max;
}
// Pagination
$pagination = new Pagination(array('query_string' => 'page', 'items_per_page' => (int) Kohana::config('settings.items_per_page'), 'total_items' => $db->query("SELECT DISTINCT i.* FROM `" . $this->table_prefix . "incident` AS i JOIN `" . $this->table_prefix . "incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `" . $this->table_prefix . "category` AS c ON (c.`id` = ic.`category_id`) JOIN `" . $this->table_prefix . "location` AS l ON (i.`location_id` = l.`id`) WHERE `incident_active` = '1' {$filter}")->count()));
$incidents = $db->query("SELECT DISTINCT i.*, l.`location_name` FROM `" . $this->table_prefix . "incident` AS i JOIN `" . $this->table_prefix . "incident_category` AS ic ON (i.`id` = ic.`incident_id`) JOIN `" . $this->table_prefix . "category` AS c ON (c.`id` = ic.`category_id`) JOIN `" . $this->table_prefix . "location` AS l ON (i.`location_id` = l.`id`) WHERE `incident_active` = '1' {$filter} ORDER BY incident_date DESC LIMIT " . (int) Kohana::config('settings.items_per_page') . " OFFSET " . $pagination->sql_offset);
$this->template->content->incidents = $incidents;
//Set default as not showing pagination. Will change below if necessary.
$this->template->content->pagination = '';
// Pagination and Total Num of Report Stats
if ($pagination->total_items == 1) {
$plural = '';
} else {
$plural = 's';
}
if ($pagination->total_items > 0) {
$current_page = $pagination->sql_offset / (int) Kohana::config('settings.items_per_page') + 1;
$total_pages = ceil($pagination->total_items / (int) Kohana::config('settings.items_per_page'));
if ($total_pages > 1) {
// If we want to show pagination
$this->template->content->pagination_stats = Kohana::lang('ui_admin.showing_page') . ' ' . $current_page . ' ' . Kohana::lang('ui_admin.of') . ' ' . $total_pages . ' ' . Kohana::lang('ui_admin.pages');
$this->template->content->pagination = $pagination;
} else {
// If we don't want to show pagination
$this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.reports');
}
} else {
$this->template->content->pagination_stats = '(' . $pagination->total_items . ' report' . $plural . ')';
}
$icon_html = array();
$icon_html[1] = "<img src=\"" . url::base() . "media/img/image.png\">";
//image
$icon_html[2] = "<img src=\"" . url::base() . "media/img/video.png\">";
//video
$icon_html[3] = "";
//audio
$icon_html[4] = "";
//news
$icon_html[5] = "";
//podcast
//Populate media icon array
$this->template->content->media_icons = array();
foreach ($incidents as $incident) {
$incident_id = $incident->id;
if (ORM::factory('media')->where('incident_id', $incident_id)->count_all() > 0) {
$medias = ORM::factory('media')->where('incident_id', $incident_id)->find_all();
//Modifying a tmp var prevents Kohona from throwing an error
$tmp = $this->template->content->media_icons;
$tmp[$incident_id] = '';
foreach ($medias as $media) {
$tmp[$incident_id] .= $icon_html[$media->media_type];
$this->template->content->media_icons = $tmp;
}
}
}
// Category Title, if Category ID available
$category_id = isset($_GET['c']) && !empty($_GET['c']) ? $_GET['c'] : "0";
$category = ORM::factory('category')->find($category_id);
$this->template->content->category_title = $category->loaded ? $category->category_title : "";
// Collect report stats
// Total Reports
$total_reports = Incident_Model::get_total_reports(TRUE);
// Average Reports Per Day
$oldest_timestamp = Incident_Model::get_oldest_report_timestamp();
// Round the number of days up to the nearest full day
$days_since = ceil((time() - $oldest_timestamp) / 86400);
$avg_reports_per_day = round($total_reports / $days_since, 2);
// Percent Verified
$total_verified = Incident_Model::get_total_reports_by_verified(true);
$percent_verified = $total_reports == 0 ? 'n/a' : round($total_verified / $total_reports * 100, 2) . '%';
$this->template->content->total_reports = $total_reports;
$this->template->content->avg_reports_per_day = $avg_reports_per_day;
$this->template->content->percent_verified = $percent_verified;
}
示例7: index
//.........這裏部分代碼省略.........
$incidents = ORM::factory("incident")->where("incident_active", 1)->where($location_id_in)->where($incident_id_in)->orderby("incident_dateadd", "desc")->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset);
}
// Swap out category titles with their proper localizations using an array (cleaner way to do this?)
$localized_categories = array();
foreach ($incidents as $incident) {
foreach ($incident->category as $category) {
$ct = (string) $category->category_title;
if (!isset($localized_categories[$ct])) {
$translated_title = Category_Lang_Model::category_title($category->id, $l);
$localized_categories[$ct] = $category->category_title;
if ($translated_title) {
$localized_categories[$ct] = $translated_title;
}
}
}
}
$this->template->content->localized_categories = $localized_categories;
$this->template->content->incidents = $incidents;
// add in person submitted information
$person_submitted_info = array();
foreach ($incidents as $incident) {
$incident_person = ORM::factory('incident_person')->where('incident_id', $incident->id)->find();
if ($incident_person->loaded) {
$person_submitted_info[$incident->id] = array('first_name' => $incident_person->person_first, 'last_name' => $incident_person->person_last);
}
}
$this->template->content->person_submitted_info = $person_submitted_info;
//Set default as not showing pagination. Will change below if necessary.
$this->template->content->pagination = "";
// Pagination and Total Num of Report Stats
if ($pagination->total_items == 1) {
$plural = "";
} else {
$plural = "s";
}
if ($pagination->total_items > 0) {
$current_page = $pagination->sql_offset / (int) Kohana::config('settings.items_per_page') + 1;
$total_pages = ceil($pagination->total_items / (int) Kohana::config('settings.items_per_page'));
if ($total_pages > 1) {
// If we want to show pagination
$this->template->content->pagination_stats = Kohana::lang('ui_admin.showing_page') . ' ' . $current_page . ' ' . Kohana::lang('ui_admin.of') . ' ' . $total_pages . ' ' . Kohana::lang('ui_admin.pages');
$this->template->content->pagination = $pagination;
} else {
// If we don't want to show pagination
$this->template->content->pagination_stats = $pagination->total_items . ' ' . Kohana::lang('ui_admin.reports');
}
} else {
$this->template->content->pagination_stats = '(' . $pagination->total_items . ' report' . $plural . ')';
}
// this is used as text display for search results string
$category_titles = array();
if ($category_ids_in) {
$categories = ORM::factory('category')->where('id ' . $category_ids_in)->find_all();
foreach ($categories as $category) {
$category_titles[] = $category->category_title;
}
}
$this->template->content->category_titles = $category_titles;
$scale_category = ORM::factory('category')->where('category_title', 'Scale')->find();
$context_category = ORM::factory('category')->where('category_title', 'Context')->find();
$visible_categories = ORM::factory('category')->where('parent_id IN (' . implode(",", array($scale_category->id, $context_category->id)) . ')')->find_all();
$scale_categories = array();
$context_categories = array();
foreach ($visible_categories as $visible_category) {
if ($visible_category->parent_id === $scale_category->id) {
$scale_categories[] = $visible_category;
} elseif ($visible_category->parent_id === $context_category->id) {
// design response category should be first in context list
// also assuming that the design response is under the context category
if ($visible_category->id === $design_response_category) {
array_unshift($context_categories, $visible_category);
} else {
array_push($context_categories, $visible_category);
}
}
}
$this->template->content->scale_categories = $scale_categories;
$this->template->content->context_categories = $context_categories;
$this->template->content->selected_categories = $category_ids;
// Collect report stats
$this->template->content->report_stats = new View('reports_stats');
// Total Reports
$total_reports = Incident_Model::get_total_reports(TRUE);
// Average Reports Per Day
$oldest_timestamp = Incident_Model::get_oldest_report_timestamp();
// Round the number of days up to the nearest full day
$days_since = ceil((time() - $oldest_timestamp) / 86400);
if ($days_since < 1) {
$avg_reports_per_day = $total_reports;
} else {
$avg_reports_per_day = 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) . '%';
$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->header->header_block = $this->themes->header_block();
}