/** * [get_group_container description] * * @param [type] $object_type [description] * @param [type] $group_id [description] * @param boolean $time_range [description] * @param boolean $start_date [description] * @param boolean $end_date [description] * @param boolean $time_basis [description] * * @method get_group_container * @return [type] [description] * * @author Ken Auberry <*****@*****.**> */ public function get_group_container($object_type, $group_id, $time_range = FALSE, $start_date = FALSE, $end_date = FALSE, $time_basis = FALSE) { $group_info = $this->gm->get_group_info($group_id); $options_list = $group_info['options_list']; $item_list = $group_info['item_list']; $time_range = !empty($time_range) ? $time_range : $options_list['time_range']; $time_basis = $options_list['time_basis']; if (!empty($start_date) && !empty($end_date) && (strtotime($start_date) && strtotime($end_date))) { $time_range = 'custom'; } $object_type = singular($object_type); $accepted_object_types = array('instrument', 'proposal', 'user'); $valid_date_range = $this->gm->earliest_latest_data_for_list($object_type, $group_info['item_list'], $time_basis); $my_times = $this->summary->fix_time_range($time_range, $start_date, $end_date, $valid_date_range); $latest_available_date = new DateTime($valid_date_range['latest']); $earliest_available_date = new DateTime($valid_date_range['earliest']); $valid_range = array('earliest' => $earliest_available_date->format('Y-m-d H:i:s'), 'latest' => $latest_available_date->format('Y-m-d H:i:s'), 'earliest_available_object' => $earliest_available_date, 'latest_available_object' => $latest_available_date); $my_times = array_merge($my_times, $valid_range); $this->page_data['placeholder_info'][$group_id] = array('group_id' => $group_id, 'object_type' => $object_type, 'options_list' => $options_list, 'group_name' => $group_info['group_name'], 'item_list' => $group_info['item_list'], 'time_basis' => $time_basis, 'time_range' => $time_range, 'times' => $my_times); if (!array_key_exists('my_groups', $this->page_data)) { $this->page_data['my_groups'] = array($group_id => $group_info); } else { $this->page_data['my_groups'][$group_id] = $group_info; } $this->page_data['my_object_type'] = $object_type; if (empty($item_list)) { $this->page_data['examples'] = add_objects_instructions($object_type); } else { $this->page_data['placeholder_info'][$group_id]['times'] = $this->summary->fix_time_range($time_range, $start_date, $end_date); } $this->load->view('object_types/group.html', $this->page_data); }
/** * [view description] * * @param string $object_type [description] * @param integer $group_id [description] * @param string $time_range [description] * @param boolean $start_date [description] * @param boolean $end_date [description] * * @return [type] [description] * * @author Ken Auberry <*****@*****.**> */ public function view($object_type, $group_id, $time_range = '1-month', $start_date = FALSE, $end_date = FALSE) { $object_type = singular($object_type); $accepted_object_types = array('instrument', 'proposal', 'user'); if (!in_array($object_type, $accepted_object_types)) { redirect('reporting/view/instrument/{$time_range}'); } $this->page_data['page_header'] = 'MyEMSL Uploads per ' . ucwords($object_type); $this->page_data['my_object_type'] = $object_type; $this->page_data['css_uris'] = array('/resources/stylesheets/status_style.css', '/resources/scripts/select2/select2.css', '/resources/scripts/bootstrap/css/bootstrap.css', '/resources/scripts/bootstrap-daterangepicker/daterangepicker.css', APPPATH . 'resources/stylesheets/reporting.css'); $this->page_data['script_uris'] = array('/resources/scripts/spinner/spin.min.js', '/resources/scripts/spinner/jquery.spin.js', '/resources/scripts/moment.min.js', '/resources/scripts/bootstrap-daterangepicker/daterangepicker.js', '/resources/scripts/jquery-typewatch/jquery.typewatch.js', '/resources/scripts/highcharts/js/highcharts.js', APPPATH . 'resources/scripts/reporting.js'); $this->page_data['js'] = "var object_type = '{$object_type}'; var time_range = '{$time_range}'"; $time_range = str_replace(array('-', '_', '+'), ' ', $time_range); $my_object_list = $this->rep->get_selected_objects($this->user_id, $object_type, $group_id); if (empty($my_object_list)) { $examples = add_objects_instructions($object_type); $this->page_data['examples'] = $examples; $this->page_data['js'] .= "\n \$(function(){\n \$('#object_search_box').focus();\n });\n "; $this->page_data['content_view'] = 'object_types/select_some_objects_insert.html'; } else { $this->page_data['my_objects'] = ''; $object_list = array_map('strval', array_keys($my_object_list[$object_type])); if (!empty($default_object_id) && in_array($default_object_id, $object_list)) { $object_list = array(strval($default_object_id)); } $object_info = $this->eus->get_object_info($object_list, $object_type); foreach ($object_list as $object_id) { $valid_date_range = $this->rep->earliest_latest_data($object_type, $object_id); $my_times = $this->fix_time_range($time_range, $start_date, $end_date, $valid_date_range); $latest_available_date = new DateTime($valid_date_range['latest']); $earliest_available_date = new DateTime($valid_date_range['earliest']); $valid_range = array('earliest' => $earliest_available_date->format('Y-m-d H:i:s'), 'latest' => $latest_available_date->format('Y-m-d H:i:s'), 'earliest_available_object' => $earliest_available_date, 'latest_available_object' => $latest_available_date); if ($my_times['start_time_object']->getTimestamp() < $valid_range['earliest_available_object']->getTimestamp()) { $my_times['start_time_object'] = clone $valid_range['earliest_available_object']; } if ($my_times['end_time_object']->getTimestamp() > $valid_range['latest_available_object']->getTimestamp()) { $my_times['end_time_object'] = clone $valid_range['latest_available_object']; } $my_times = array_merge($my_times, $valid_range); $this->page_data['placeholder_info'][$object_id] = array('object_type' => $object_type, 'object_id' => $object_id, 'time_range' => $time_range, 'times' => $my_times); } $this->page_data['my_objects'] = $object_info; $this->page_data['content_view'] = 'object_types/object.html'; } $this->load->view('reporting_view.html', $this->page_data); }
/** * Constructs the main report viewing page * * @param string $object_type classification of the object of interest [proposal/instrument/user] * @param string $time_range parsable string to specify how far back to look from the current date [e.g. 3-months, 1-week, custom, etc] * @param string $start_date beginning date for data collection in YYYY-MM-DD format * @param string $end_date end date for data collection in YYYY-MM-DD format * @param string $time_basis classification of date type to use [created/modified/submission] * * @method view * * @author Ken Auberry <*****@*****.**> * * @return none sends output to *reporting_view.html* */ public function view($object_type, $time_range = FALSE, $start_date = FALSE, $end_date = FALSE, $time_basis = FALSE) { $this->benchmark->mark('controller_view_start'); $object_type = singular($object_type); $time_basis = !empty($time_basis) ? $time_basis : 'modification_time'; $accepted_object_types = array('instrument', 'proposal', 'user'); if (!in_array($object_type, $accepted_object_types)) { redirect('group/view/instrument'); } $this->page_data['page_header'] = 'Aggregated MyEMSL Uploads by ' . ucwords($object_type) . ' Grouping'; $this->page_data['my_object_type'] = $object_type; $this->page_data['css_uris'] = array('/resources/stylesheets/status_style.css', '/resources/scripts/select2/select2.css', '/resources/scripts/bootstrap/css/bootstrap.css', '/resources/scripts/bootstrap-daterangepicker/daterangepicker.css', base_url() . 'project_resources/stylesheets/reporting.css'); $this->page_data['script_uris'] = array('/resources/scripts/spinner/spin.min.js', '/resources/scripts/spinner/jquery.spin.js', '/resources/scripts/moment.min.js', '/resources/scripts/select2/select2.min.js', '/resources/scripts/bootstrap-daterangepicker/daterangepicker.js', '/resources/scripts/jquery-typewatch/jquery.typewatch.js', '/resources/scripts/highcharts/js/highcharts.js', base_url() . 'project_resources/scripts/reporting.js'); $my_groups = $this->gm->get_selected_groups($this->user_id, $object_type); if (empty($my_groups)) { $this->page_data['content_view'] = 'object_types/select_some_groups_insert.html'; } else { $this->page_data['my_groups'] = ''; foreach ($my_groups as $group_id => $group_info) { $my_start_date = FALSE; $my_end_date = FALSE; $options_list = $group_info['options_list']; $my_start_date = strtotime($start_date) ? $start_date : $options_list['start_time']; $my_start_date = $my_start_date !== 0 ? $my_start_date : FALSE; $my_end_date = strtotime($end_date) ? $end_date : $options_list['end_time']; $my_end_date = $my_end_date !== 0 ? $my_end_date : FALSE; $time_basis = $options_list['time_basis']; $time_range = $time_range ? $time_range : $options_list['time_range']; if ($time_range && $time_range !== $options_list['time_range'] && $time_range !== 'custom') { $this->gm->change_group_option($group_id, 'time_range', $time_range); } $update_start = !$my_start_date ? TRUE : FALSE; $update_end = !$my_end_date ? TRUE : FALSE; $valid_date_range = $this->gm->earliest_latest_data_for_list($object_type, $group_info['item_list'], $time_basis); $my_times = $this->summary->fix_time_range($time_range, $my_start_date, $my_end_date, $valid_date_range); if ($update_start) { $this->gm->change_group_option($group_id, 'start_time', $my_times['start_time_object']->format('Y-m-d')); } if ($update_end) { $this->gm->change_group_option($group_id, 'end_time', $my_times['end_time_object']->format('Y-m-d')); } $latest_available_date = new DateTime($valid_date_range['latest']); $earliest_available_date = new DateTime($valid_date_range['earliest']); // var_dump($my_times); $valid_range = array('earliest' => $earliest_available_date->format('Y-m-d H:i:s'), 'latest' => $latest_available_date->format('Y-m-d H:i:s'), 'earliest_available_object' => $earliest_available_date, 'latest_available_object' => $latest_available_date); if ($my_times['start_time_object']->getTimestamp() < $valid_range['earliest_available_object']->getTimestamp()) { $my_times['start_time_object'] = clone $valid_range['earliest_available_object']; } if ($my_times['end_time_object']->getTimestamp() > $valid_range['latest_available_object']->getTimestamp()) { $my_times['end_time_object'] = clone $valid_range['latest_available_object']; } $my_times = array_merge($my_times, $valid_range); if (empty($group_info['item_list'])) { $this->page_data['examples'] = add_objects_instructions($object_type); } $this->page_data['placeholder_info'][$group_id] = array('group_id' => $group_id, 'object_type' => $object_type, 'options_list' => $options_list, 'group_name' => $group_info['group_name'], 'item_list' => $group_info['item_list'], 'time_basis' => $time_basis, 'time_range' => $time_range, 'times' => $my_times); } //end foreach $time_range = str_replace(array('-', '_', '+'), ' ', $time_range); $this->page_data['my_groups'] = $my_groups; $this->page_data['content_view'] = 'object_types/group.html'; } //end if $this->page_data['js'] = "var object_type = '{$object_type}'; var time_range = '{$time_range}';"; $this->load->view('reporting_view.html', $this->page_data); $this->benchmark->mark('controller_view_end'); }