public function _new() { // if (!$this->loadData()) // { // $this->dataError(); // sendBack(); // } parent::_new(); // an array of legacy search fields $search_fields = array(); $flash = Flash::Instance(); // get the report model, lets not envoke it again... that's not cool $report = $this->_uses[$this->modeltype]; if (!empty($this->_data['tablename'])) { $report_options[$this->_data['tablename']] = $this->_data['tablename']; } else { $report_options = $report::getTables(); } if (!$report->isLoaded()) { $report->tablename = current($report_options); $this->view->set('update', false); } else { $this->view->set('update', true); } $this->view->set('report_options', $report_options); // get the fields for the tablename and sort them $available_fields = $this->getColumns($report->tablename); ksort($available_fields); // unserialise the options from the db $options = unserialize($report->options); if ($options !== FALSE) { // overlay the defaults so we've got a full set of options $options = $this->expand_options($options, $report->tablename); // sort options by position $options = $this->sort_options($options); // loop through used fields and remove them from the available fields array foreach ($options as $field => $field_options) { // remove the field from the available fields array unset($available_fields[$field]); // we need to check against legacy search options if ($field_options['field_type'] === 'search') { // build an array of broken search options $search_fields[] = $field; // update the legacy options $options[$field] = array_merge($this->default_options, $options[$field]); // ATTN: boolean values didn't work here... but that's what the defaults are set as // set other specific search settings $options[$field]['field_type'] = 'normal'; $options[$field]['normal_enable_search'] = 'true'; $options[$field]['normal_display_field'] = 'false'; // if a default value exists if (isset($options[$field]['default_value'])) { // set it to the new option name $options[$field]['search_default_value'] = $options[$field]['default_value']; // unset the old version unset($options[$field]['default_value']); } } } unset($available_fields['filter']); } else { $options = array(); } if (!empty($search_fields)) { $flash->addError('Legacy search fields found, click save <strong>immediately</strong> to update'); } $description = $report->description; // set smarty vars $this->view->set('description', $description); $this->view->set('available_fields', $available_fields); $this->view->set('selected_tablename', $report->tablename); $this->view->set('options', $options); $this->view->set('report', $report); //Set report defintion list $report_type_id = ReportType::getReportTypeID('Reports'); $definition_list = ReportDefinition::getReportsByType($report_type_id); array_unshift($definition_list, "Default"); $this->view->set('report_definitions', $definition_list); //Set currently selected report definition $selected_def = ReportDefinition::getDefinitionByID($report->report_definition); if ($selected_def->_data['name'] == 'PrintCollection') { $this->view->set('selected_reportdef', 'Default'); } else { $this->view->set('selected_reportdef', $selected_def->_data['name']); } }
public function getReportsByType($_report_type_id = '') { // used by ajax to get the Report Definitions List if (isset($this->_data['ajax']) && empty($_report_type_id)) { $ajax = true; if (!empty($this->_data['report_type_id'])) { $_report_type_id = $this->_data['report_type_id']; } } else { $ajax = false; } $list = ReportDefinition::getReportsByType($_report_type_id); if ($ajax) { $this->view->set('options', $list); $this->setTemplateName('select_options'); } else { return $list; } }