<<

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_area_name_sql_snippet

Missing POD for get_area_name_sql_snippet.

get_table_areas

Missing POD for get_table_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

_get_columns($table_name)

    my $columns = _get_columns('items');

Returns an arrayref of hashrefs with the keys name (table.column) and description for every column of the given table. Columns that match a forbidden name (see "check_columns" in Koha::Report) are omitted. Dies if the table name is not a known Koha table.

_get_columns

    my $columns = _get_columns($table_name);

Internal function used by get_columns. Returns an arrayref of hashrefs, one per column of $table_name, with name (as table.column) and description. Columns that reports are not allowed to use, such as passwords, are left out.

Dies if $table_name is not a known database table.

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.

_build_query($tables, $columns, $criteria, $keys, $orderby, $totals, $definition)

    my $sql = _build_query( $tables, $columns, $criteria, $keys, $orderby, $totals, $definition );

Assembles the SQL for a guided report. $tables and $columns are arrayrefs; the first table is the FROM table and each further table is LEFT JOINed using the matching join condition from $keys. $criteria is appended as the WHERE clause, $definition adds dictionary conditions, $totals adds aggregate columns and a GROUP BY, and $orderby is appended as given. Returns the SQL string.

_build_query

    my $sql = _build_query( $tables, $columns, $criteria, $keys, $orderby, $totals, $definition );

Internal function used by build_query. Builds the SQL for a guided report: selects $columns from the first table in $tables, LEFT JOINs the other tables using the join conditions in $keys, then adds $criteria, the saved SQL of any dictionary definitions in $definition, a GROUP BY for $totals and $orderby. Returns the SQL string.

get_criteria($area,$cgi);

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

nb_rows

Missing POD for nb_rows.

select_2_select_count

 returns $sql, $offset, $limit
 $sql returned will be transformed to:
  ~ remove any LIMIT clause
  ~ replace SELECT clause w/ SELECT count(*)

strip_limit This removes the LIMIT from the query so that a custom one can be specified. Usage: ($new_sql, $offset, $limit) = strip_limit($sql);

Where: $sql is the query to modify $new_sql is the resulting query $offset is the offset value, if the LIMIT was the two-argument form (LIMIT offset, count) or used OFFSET (LIMIT count OFFSET offset), 0 if it wasn't otherwise given. $limit is the limit value

Notes: * This makes an effort to not break subqueries that have their own LIMIT specified. It does that by only removing a LIMIT if it comes after a WHERE clause (which isn't perfect, but at least should make more cases work - subqueries with a limit in the WHERE will still break.) * If your query doesn't have a WHERE clause then all LIMITs will be removed. This may break some subqueries, but is hopefully rare enough to not be a big issue.

execute_query

  ($sth, $error) = execute_query({
      sql => $sql,
      offset => $offset,
      limit => $limit
      sql_params => \@sql_params],
      report_id => $report_id
  })

This function returns a DBI statement handler from which the caller can fetch the results of the SQL passed via $sql.

If passed any query other than a SELECT, or if there is a DB error, $errors is returned, and is a hashref 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.

$offset, and $limit are required parameters.

\@sql_params is an optional list of parameter values to paste in. The caller is responsible for making sure that $sql has placeholders and that the number placeholders matches the number of parameters.

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

update_sql

Missing POD for update_sql.

store_results

Missing POD for store_results.

format_results

    my $result = format_results($saved_reports_id);

Returns a hashref with the stored results for the given saved_reports id, along with the name, notes and id of the report they belong to.

Returns undef if there are no stored results with that id, or if the report they belong to has been deleted.

delete_report

Missing POD for delete_report.

get_saved_reports_base_query

Missing POD for get_saved_reports_base_query.

get_saved_reports

Missing POD for get_saved_reports.

_attach_limits

Attached the library or library group limitations to a report for handling in the UI

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 array ref of hashrefs suitable for use as a tmpl_loop with the distinct values of the column

save_dictionary

Missing POD for save_dictionary.

get_from_dictionary

Missing POD for get_from_dictionary.

delete_definition

Missing POD for delete_definition.

get_sql($report_id)

Given a report id, return the SQL statement for that report. Otherwise, it just returns.

get_results

Missing POD for get_results.

GetReservedAuthorisedValues

    my %reserved_authorised_values = GetReservedAuthorisedValues();

Returns a hash containing 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

EmailReport

    my ( $emails, $arrayrefs ) = EmailReport($report_id, $letter_code, $module, $branch, $email)

Take a report and use it to process a Template Toolkit formatted notice Returns arrayrefs containing prepared letters and errors respectively

_get_display_value($original_value, $column)

    my $display = _get_display_value( $value, $column );

Returns the value to display for a criteria option. For the periodicity column the value is looked up in subscription_frequencies and the description is returned. For every other column the original value is returned unchanged.

_get_display_value

    my $display_value = _get_display_value( $original_value, $column );

Internal function used by get_criteria. Returns the value to show for $original_value in the criteria list for $column. For periodicity this is the subscription frequency description; for any other column the original value is returned unchanged.

convert_sql

my $updated_sql = C4::Reports::Guided::convert_sql( $sql );

Convert a sql query using biblioitems.marcxml to use the new biblio_metadata.metadata field instead

AUTHOR

Chris Cormack <crc@liblime.com>

<<