Source of file DataObjectReport.php
Size: 1,659 Bytes - Last Modified: 2021-12-23T10:25:16+00:00
/var/www/docs.ssmods.com/process/src/code/dataobjects/DataObjectReport.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 | <?php /** * An AdvancedReport type that allows a user to select the type they want * to report on. * * @author marcus@silverstripe.com.au * @license BSD License http://silverstripe.org/bsd-license/ */ class DataObjectReport extends AdvancedReport { private static $db = array( 'ReportOn' => 'Varchar(64)', ); public function getReportName() { return "Generic Report"; } protected function getReportableFields() { $fields = array( 'ID' => 'ID', 'Created' => 'Created', 'LastEdited' => 'LastEdited', ); if($this->ReportOn) { $config = Config::inst()->forClass($this->ReportOn); $db = $config->get('db'); $hasOne = $config->get('has_one'); if($db) { $fields = array_merge($fields, $db); } if($hasOne) foreach(array_keys($hasOne) as $name) { $fields[$name . 'ID'] = true; } $fields = array_combine(array_keys($fields), array_keys($fields)); } ksort($fields); return $fields; } public function getSettingsFields() { $fields = parent::getSettingsFields(); $types = ClassInfo::subclassesFor('DataObject'); array_shift($types); ksort($types); $fields->insertAfter( new DropdownField('ReportOn', _t('AdvancedReport.REPORT_ON', 'Report on'), $types), 'Title' ); return $fields; } /** * @return DataList */ public function getDataObjects() { return DataList::create($this->ReportOn) ->filter($this->getFilter()) ->sort($this->getSort()); } /** * Gets the filter we need for the report * * @param $agreementFilter * @return string */ protected function getFilter() { $conditions = $this->getConditions(); return $conditions; } } |