Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Extending SideReport - Class not found

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

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

Page: 1
Go to End
Author Topic: 1319 Views
  • IOTI
    Avatar
    Community Member
    189 Posts

    Extending SideReport - Class not found Link to this post

    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?

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: Extending SideReport - Class not found Link to this post

    I think I have it figured out

    Used SS_Report and not getting the error.

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: Extending SideReport - Class not found Link to this post

    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.

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: Extending SideReport - Class not found Link to this post

    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;
    }
       
    }

    ?>

    1319 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.