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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Reports in SS3


Go to End


3 Posts   1243 Views

Avatar
lozhowlett

Community Member, 151 Posts

12 June 2014 at 8:33pm

Guys

The documentation is very lacking on reports... I have created a sample report just to test the water, but it doesnt seem to be showing up in the admin system. I have also tried

SS_Report::register("ReportAdmin", "BookingReport_BookingSummary");

but get a error that SS_Report is undefined?

<?php
/** 
 * This report lists all the pages in the CMS
 * of type Page. Sorted by title.
 */
class BookingReport_BookingSummary extends SideReport {
    public function title() {
        // this is the title of the report
        return "Booking Summary Report";
    }
     
    // public function records() {
    //     // the data the report returns all the dataobjects of type Page and sorted by title. See datamodel for more info
    //     return Bookings::get()->sort("Created ASC");
    // }

    function records($params, $sort, $limit){  
        if(isset($params['Colour'])){
            $Bookings = DataObject::get("Bookings", "BookingStatusID = '" . $params['BookingStatusID'] ."'", "Created DESC", Null, $params['ResultsLimit']);         
            return $Bookings;
        }
    }
     
    public function fieldsToShow() {
        // fields you want to display. This will display a list of titles which link to the page in the cms. Handy!
        return array(
            'Name',
            'NumberOfAdultPassengers',
            'NumberOfChildPassengers',
            'NumberOfInfantPassengers',
            "FlightNumber",
            "DepartureAirport",
            "FlightArrivalDate",
            "FlightArrivalHour",
            "FlightArrivalMin",
            "FlightDepartureDate",
            "FlightDepartureHour",
            "FlightDepartureMin",
            "HotelName",
            "HotelAddress",
            "Town",
            "OutboundFlightNumber",
            "InboundFlightNumber",
            "InboundDepartureAirport",
            'Reference',
            "Total",
            "BookingPIN"                

        );
    }  


    function parameterFields() {
        $params = new FieldSet();
        //Colour filter
        $params->push(new DropdownField(
            "BookingStatusID", 
            "Booking Status", 
            array(
                '1' => 'Not Paid',
                '2' => 'Cancelled',
                '3'=> 'Paid',
                'NULL' => 'All'
              )
        ));
 
        //Result Limit
        $ResultLimitOptions = array(
            50 => '50 Bookings',
            100 => '100 Bookings',
            200 => '200 Bookings',
            500 => '500 Bookings',
            Null => 'All Bookings'
        );
         
        $params->push(new DropdownField(
            "ResultsLimit", 
            "Limit results to", 
            $ResultLimitOptions,
            50
        ));
                 
        return $params;
    }   

}
?>

Avatar
Bonner

Community Member, 21 Posts

12 June 2014 at 10:37pm

You don't need to register reports in SS3, they are registered automatically. Comment out the following:

SS_Report::register("ReportAdmin", "BookingReport_BookingSummary");

Avatar
Bonner

Community Member, 21 Posts

12 June 2014 at 10:38pm

Also, you need to do a dev build for it to show.