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

Extending SideReport - Class not found


Go to End


4 Posts   1875 Views

Avatar
copernican

Community Member, 189 Posts

11 June 2010 at 2:09am

Edited: 11/06/2010 2:10am

Hello

I'm trying to extend SideReport to create a custom report. Here is my code

Also note this is using a clean install of SS 2.4

RentalRequestReport.php located in mysite/code

<?php

/*
* Custom report class for Rental Requests
*/

class RentalRequestReport extends SideReport {
		
		function title() {
			
			return 'Rental Requests';
		}
		
		function records() {
			
			return DataObject::get("BookingFormSubmission", "", "LastName");
		}
		
		function fieldsToShow(){
			
			return array(
				
				'FirstName' => array('NestedTitle', array('2')),
			);
		}
	
}

?>

and in my _config.php file i have

SS_Report::register('SideReport', 'RentalRequestReport');

this is the error I receive when trying to load the SS CMS

Fatal error: Class 'SideReport' not found in *directory* on line 7
*directory was added by me for clients privacy

I was reading in the change log that SideReport was removed "Removed SideReport class, use SSReport as the base-class for them instead"

I tried using SSReport instead but same error.

Am I missing something?

Avatar
copernican

Community Member, 189 Posts

11 June 2010 at 3:36am

I think I have it figured out

Used SS_Report and not getting the error.

Avatar
copernican

Community Member, 189 Posts

11 June 2010 at 4:16am

okay making some progress, but still having problems. Right now I have this

RentalRequestReport.php in mysite/code

<?php

/*
* Custom report class for Rental Requests
*/

class RentalRequestReport extends SS_Report {
		
		function title() {
			
			return 'Rental Requests';
		}
		
		function description() {
			
			return 'All Rental Requests';
		}
		
		function records() {
			
			return DataObject::get('BookingFormSubmission', NULL, 'LastName');
		}
		
		
		
		function fieldsToShow(){
			
			return array(
				
				'FirstName' => array('NestedTitle', array('2')),
			);
		}
	
}

?>

and in my _config.php

SS_Report::register('ReportAdmin', 'RentalRequestReport', 1);

The report shows, but when i click on it it just shows the "error loading page" and won't show anything.

I think i need to do something with columns()? but not sure what to do with it.

Avatar
copernican

Community Member, 189 Posts

11 June 2010 at 5:44am

Success. I have the initial functionality I was looking for. For anybody who is interested...

RentalRequestReport.php in mysite/code

<?php

/**
* An extension to {@link SSReport} that allows a user to view all booking requets
*/


/**
*Gets all Rental Requests
*
*/
class RentalRequestReport extends SS_Report {
		
		function title() {
			
			return 'Rental Requests';
		}
		
		function description() {
			
			return 'All Rental Requests';
		}
		
		function sourceQuery($params){
			
			$sqlQuery = new SQLQuery();
			
			$sqlQuery->from = array('BookingFormSubmission');
			$sqlQuery->orderby = 'LastName';
			
			return $sqlQuery;
			
		}
		
		function columns() {
        $columns['LastName'] = array(
                                        'title' => 'Last name',
                                    );
		
         $columns['FirstName'] = array(
                                        'title' => 'First name',
                                    );
        
		 $columns['Email'] = array(
                                        'title' => 'Email',
                                    );
		 
		 $columns['PhoneNumber'] = array(
                                        'title' => 'Phone number',
                                    );
		 $columns['ArrivalDate'] = array(
                                        'title' => 'Arrival date',
                                    );
		 
		 $columns['DepartureDate'] = array(
                                        'title' => 'Departure date',
                                    );
		 
		 $columns['Guests'] = array(
                                        'title' => 'Guests',
                                    );
		  
		 $columns['AdditionalQuestions'] = array(
                                        'title' => 'Questions',
                                    );
        return $columns;
    }
	
}

?>