C4::Reports::Guided - Module for generating guided reports
use C4::Reports::Guided;
This will return a list of all the available report areas
This will return a list of all the available report types
This will return a list of all the available report areas with groups
This will return a list of all tables in the database
This will return a list of all columns for a report 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.
Returns an arraref to hashrefs suitable for using in a tmpl_loop. With the criteria and available values.
returns $sql, $offset, $limit $sql returned will be transformed to: ~ remove any LIMIT clause ~ replace SELECT clause w/ SELECT count(*)
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, 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.
($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.
Given some sql and a name this will saved it so that it can reused Returns id of the newly created report
This takes a column name of the format table.column and will return what type it is (free text, set values, date)
Given a column name, return an arrary ref of hashrefs suitable for use as a tmpl_loop with the distinct values of the column
Given a report id, return the SQL statement for that report. Otherwise, it just returns.
my %reserved_authorised_values = GetReservedAuthorisedValues();
Returns a hash containig all reserved words
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
my @sql_parameters = GetParametersFromSQL($sql)
Returns an arrayref of hashes containing the keys name and authval
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
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
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
Chris Cormack <crc@liblime.com>