1 package SL::Controller::Helper::ReportGenerator::ControlRow::Base;
 
   5 use parent qw(SL::DB::Object);
 
   7 use Rose::Object::MakeMethods::Generic (
 
   8   scalar => [ qw(params) ],
 
  12 sub validate_params { die 'name needs to be implemented' }
 
  13 sub set_data        { die 'name needs to be implemented' }
 
  25 SL::Controller::Helper::ReportGenerator::ControlRow::Base - a base class
 
  26 for report generator control row classes
 
  30 ControlRow is an interface that allows generic control rows to be added
 
  31 to objects for the C<SL::Controller::Helper::ReportGenerator>. This is a
 
  32 base class from which all control row classes are derived.
 
  36 Adding your own new control row of the type "only_dashes":
 
  38   package SL::Controller::Helper::ReportGenerator::ControlRow::OnlyDashes;
 
  40   use parent qw(SL::Controller::Helper::ReportGenerator::ControlRow::Base);
 
  42   sub validate_params { return; } # no params
 
  45     my ($self, $report) = @_;
 
  47     my %data = map { $_ => {data => '---'} } keys %{ $report->{columns} };
 
  49     $report->add_data(\%data);
 
  52 After that, you have to register your new class in
 
  53 C<SL::Controller::Helper::ReportGenerator::ControlRow::ALL>:
 
  55   use SL::Controller::Helper::ReportGenerator::ControlRow::OnlyDashes;
 
  57   our %type_to_class = (
 
  59     only_dashes => 'SL::Controller::Helper::ReportGenerator::ControlRow::OnlyDashes',
 
  63 =head1 WRITING OWN CONTROL ROW CLASSES
 
  65 You can use C<SL::Controller::Helper::ReportGenerator::ControlRow::Base>
 
  66 as parent of your module. You have to provide two methods:
 
  70 =item C<validate_params>
 
  72 This method is used to validate any params used for your module.
 
  73 You can access the params through the method C<params> which contains all
 
  74 remaining params after the type of the call to make_control_row (see
 
  75 C<SL::Controller::Helper::ReportGenerator::ControlRow>).
 
  77 The method should return an array of error messages if there are any
 
  78 errors. Otherwise it should return C<undef>.
 
  80 =item C<set_data REPORT>
 
  82 This method sould set the data for the report generator, which is handeled
 
  87 =head1 REGISTERING OWN CONTROL ROW CLASSES
 
  89 See C<SL::Controller::Helper::ReportGenerator::ControlRow::ALL>. Here your
 
  90 class should be included with C<use> and entered in the map C<%type_to_class>
 
  91 with an appropiate name for it's type.
 
  96 Bernd Bleßmann E<lt>bernd@kivitendo-premium.deE<gt>