Methods summary
public
|
|
public
array
|
#
getFormats( )
Retrieves a list of report formats
Retrieves a list of report formats
Returns
array A list of report formats and their language
|
public
string
|
#
getName( string $type )
Retrieves the name for the given report type
Retrieves the name for the given report type
Parameters
- $type
- The type of report to fetch the name for
Returns
string The name of the report
|
public
array
|
#
getAvailable( string $format = 'any' )
Retrieves a list of all available reports (those that exist on the file system)
Retrieves a list of all available reports (those that exist on the file system)
Parameters
- $format
- The format the reports must support (optional)
Returns
array An array representing each report and its name
|
public
string
|
#
getOptions( string $type, array $vars = [] )
Retrieves the options for the given report type. Sets Input errors on failure
Retrieves the options for the given report type. Sets Input errors on failure
Parameters
- $type
- The type of report to fetch the options for
- $vars
- A list of option values to pass to the report (optional)
Returns
string The options as a view
|
public
mixed
|
#
fetchAll( string $type, array $vars, string $format = 'csv', string $return = 'download' )
Generates the report type with the given vars. Sets Input errors on failure
Generates the report type with the given vars. Sets Input errors on failure
Parameters
- $type
- The type of report to fetch
- $vars
- A list of option values to pass to the report
- $format
- The format of the report to generate (optional, default csv)
- $return
(optional, default "download") One of the following:
- download To build and send the report to the browser to prompt for download; returns null
- false To build and send the report to the browser to prompt for download; returns null
- object To return a PDOStatement object representing the report data; returns PDOStatement
- true To return a PDOStatement object representing the report data; returns PDOStatement
- file To build the report and store it on the file system; returns the path to the file
Returns
mixed A PDOStatement, string, or void based on the $return parameter
|
protected
mixed
|
#
formatCsv( mixed $field )
Uses Excel-style formatting for CSV fields (individual cells)
Uses Excel-style formatting for CSV fields (individual cells)
Parameters
- $field
- A single string of data representing a cell, or an array of fields representing a row
Returns
mixed An escaped and formatted single cell or array of fields as given
|
protected
string
|
#
buildCsvRow( array $fields )
Builds a CSV row
Parameters
- $fields
- A list of data to place in each cell
Returns
string A CSV row containing the field data
|
public
boolean
|
#
validateType( string $type )
Validates that the given report type exists
Validates that the given report type exists
Parameters
Returns
boolean True if the report type exists, false otherwise
|
public
boolean
|
#
validateFormat( string $format, string $type )
Validates that the given format is valid for the report type given
Validates that the given format is valid for the report type given
Parameters
- $format
- The report format
- $type
- The report type
Returns
boolean True if the format is valid, false otherwise
|
public
stdClass
|
#
getReport( integer $id )
Fetch a custom report
Parameters
- $id
- The ID of the custom report
Returns
|
protected
array
|
#
getReportFields( integer $id )
Fetch custom report fields
Fetch custom report fields
Parameters
- $id
- The ID of the custom report
Returns
array An array of stdClass objects representing custom report fields
|
public
array
|
#
getReports( )
Get all custom reports available
Get all custom reports available
Returns
array An array of stdClass objects each representing a report
|
public
stdClass
|
#
addReport( array $vars )
Add a custom report
Parameters
Returns
|
public
stdClass
|
#
editReport( integer $id, array $vars )
Edit a custom report
Parameters
Returns
|
protected
|
#
saveReportFields( integer $id, array $report_fields )
Save report fields
Parameters
- $id
- The ID of the report whose fields to save
- $report_fields
A numerically indexed array of report fields containing:
- id
- name
- label
- type
- values
- regex
|
public
|
#
deleteReport( integer $id )
Delete a custom report
Parameters
- $id
- The ID of the custom report to delete
|
public
boolean
|
#
validateQuery( string $sql )
Validate that only one query is present, and it is a select query
Validate that only one query is present, and it is a select query
Parameters
- $sql
- The user provided query
Returns
boolean True if the query is valid, false otherwise
|
public
array
|
#
reportFieldTypes( )
Fetch report field types
Returns
array An array of key/value pairs
|
public
array
|
#
reportRequiredType( )
Fetche report field required types
Fetche report field required types
Returns
array An array of key/value pairs
|
protected
string
|
#
requiredToRegex( string $type, string $required, string $regex = null )
Convert the report field type and required status to a regex
Convert the report field type and required status to a regex
Parameters
- $type
- The field type
- $required
- Required option
- $regex
- Defined regex (if any)
Returns
string The regex to use
|
protected
string
|
#
reportDefaultRegex( string $type )
Fetch the default regex for the given report field type
Fetch the default regex for the given report field type
Parameters
Returns
string The default regex to use for that type
|