Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

User selected parameters on Reports


Go to End


1221 Views

Avatar
TrueThat

Community Member, 1 Post

20 September 2017 at 4:17pm

I'm having difficulty figuring out how to add a date range to my report. Ideally I want the report to show all records in a 24-hour period.

This is what I have so far:

class DailyReport extends SS_Report {

    // the name of the report
    public function title() {
        return 'Auckland List';
    }

    // what we want the report to return
    public function sourceRecords($params = null) {
        return NomineeList::get()->where(array(
            '"Venue"' => 'Auckland'
        ))->sort('Shared');
    }

    function parameterFields() {
        $fields = DateField::create('Created', 'Report Day');
        return $fields;
    }

    // which fields on that object we want to show
    public function columns() {
        $fields = array(
            'RunnersFirstName' => 'First Name',
            'RunnersLastName' => 'Last Name',
            'RunnersEmail' => 'Email',
            'Address' => 'Address',
            'Message' => 'Message',
            'Name' => 'Nominated by',
            'Email' => 'Nominator\'s Email',
            'Shared' => 'Shared'
        );

        return $fields;
    }
}