Class ReportManager
-
Model
-
AppModel
-
ReportManager
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
string $type The type of report to fetch the name for
Returns
string The name of the report
|
public
array
|
#
getAvailable( )
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)
Returns
array An array representing each report and its name
|
public
string
|
#
getOptions( string $type, array $vars = array() )
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
string $type The type of report to fetch the options for
- $vars
array $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
string $type The type of report to fetch
- $vars
array $vars A list of option values to pass to the report
- $format
string $format The format of the report to generate (optional, default csv)
- $return
string $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
mixed $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
array $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
- $type
string $type The report type
Returns
boolean True if the report type exists, false otherwise
|
public
stdClass
|
#
getReport( integer $id )
Fetch a custom report
Parameters
- $id
integer $id The ID of the custom report
Returns
|
protected
array
|
#
getReportFields( integer $id )
Fetch custom report fields
Fetch custom report fields
Parameters
- $id
integer $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
- $id
integer $id
- $vars
array $vars
Returns
|
protected
|
#
saveReportFields( integer $id, array $report_fields )
Save report fields
Parameters
- $id
integer $id
- $report_fields
array $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
integer $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
string $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
string $type The field type
- $required
string $required Required option
- $regex
string $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
- $type
string $type The field type
Returns
string The default regex to use for that type
|
Methods inherited from AppModel
_()
,
boolToInt()
,
currencyToDecimal()
,
dateToUtc()
,
errors()
,
getPerPage()
,
ifSet()
,
loadCrypto()
,
setDefaultIfEmpty()
,
setPerPage()
,
setRulesIfSet()
,
strToBool()
,
systemDecrypt()
,
systemEncrypt()
,
systemHash()
,
truncateDecimal()
,
validateExists()
,
validateStateCountry()
Methods inherited from Model
affectedRows()
,
begin()
,
commit()
,
getConnection()
,
lastInsertId()
,
makeDSN()
,
prepare()
,
query()
,
rollBack()
,
setAttribute()
,
setFetchMode()
Magic methods summary
Properties summary
Properties inherited from AppModel
$replacement_keys