<<

NAME

C4::Reports::Guided - Module for generating guided reports

SYNOPSIS

  use C4::Reports::Guided;

DESCRIPTION

METHODS

get_report_areas

This will return a list of all the available report areas

get_report_types

This will return a list of all the available report types

get_report_groups

This will return a list of all the available report areas with groups

get_all_tables

This will return a list of all tables in the database

get_columns($area)

This will return a list of all columns for a report area

build_query($columns,$criteria,$orderby,$area)

This will build the sql needed to return the results asked for, $columns is expected to be of the format tablename.columnname. This is what get_columns returns.

get_criteria($area,$cgi);

Returns an arraref to hashrefs suitable for using in a tmpl_loop. With the criteria and available values.

execute_query

  ($results, $error) = execute_query($sql, $offset, $limit)

When passed $sql, this function returns an array ref containing a result set suitably formatted for display in html or for output as a flat file when passed in $format and $id. It also returns the $total records available for the supplied query. If passed any query other than a SELECT, or if there is a db error, $errors an array ref is returned containing the error after this manner:

$error-{'sqlerr'}> contains the offending SQL keyword. $error-{'queryerr'}> contains the native db engine error returned for the query.

Valid values for $format are 'text,' 'tab,' 'csv,' or 'url. $sql, $type, $offset, and $limit are required parameters. If a valid $format is passed in, $offset and $limit are ignored for obvious reasons. A LIMIT specified by the user in a user-supplied SQL query WILL apply in any case.

save_report($sql,$name,$type,$notes)

Given some sql and a name this will saved it so that it can reused Returns id of the newly created report

create_compound($masterID,$subreportID)

This will take 2 reports and create a compound report using both of them

get_column_type($column)

This takes a column name of the format table.column and will return what type it is (free text, set values, date)

get_distinct_values($column)

Given a column name, return an arrary ref of hashrefs suitable for use as a tmpl_loop with the distinct values of the column

build_authorised_value_list($authorised_value)

Returns an arrayref - hashref pair. The hashref consists of various code => name lists depending on the $authorised_value. The arrayref is the hashref keys, in appropriate order

GetReservedAuthorisedValues

    my %reserved_authorised_values = GetReservedAuthorisedValues();

Returns a hash containig all reserved words

IsAuthorisedValueValid

    my $is_valid_ath_value = IsAuthorisedValueValid($authorised_value)

Returns 1 if $authorised_value is on the reserved authorised values list or in the authorised value categories defined in

GetParametersFromSQL

    my @sql_parameters = GetParametersFromSQL($sql)

Returns an arrayref of hashes containing the keys name and authval

ValidateSQLParameters

    my @problematic_parameters = ValidateSQLParameters($sql)

Returns an arrayref of hashes containing the keys name and authval of those SQL parameters that do not correspond to valid authorised names

AUTHOR

Chris Cormack <crc@liblime.com>

<<