Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -61,7 +61,12 @@ class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
* @brief Table Column Formatters
|
||||
*/
|
||||
public $tableParsers = array();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Custom form
|
||||
*/
|
||||
public $customFiltersForm = FALSE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -96,7 +101,7 @@ class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
/**
|
||||
* Add Series
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param mixed $name Either a string with the series name or an array [ 'value' => "Series Name", 'key' => "XX" ]. Keys are used to give a country code for GeoCharts.
|
||||
* @param string $type Type of value
|
||||
* @li string
|
||||
* @li number
|
||||
@@ -117,6 +122,7 @@ class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = \is_array( $name ) ? $name['value'] : $name;
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $name );
|
||||
$filterKey = $name;
|
||||
}
|
||||
@@ -125,7 +131,7 @@ class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
{
|
||||
if ( $this->type !== 'PieChart' and $this->type !== 'GeoChart' )
|
||||
{
|
||||
$this->addHeader( $name, $type );
|
||||
$this->addHeader( \is_array( $name ) ? $name['value'] : $name, $type );
|
||||
}
|
||||
|
||||
if( $this->groupBy )
|
||||
@@ -152,17 +158,75 @@ class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init the data array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function initData()
|
||||
{
|
||||
$data = parent::initData();
|
||||
|
||||
if ( $this->customFiltersForm )
|
||||
{
|
||||
if ( $values = $this->getCustomFiltersForm()->values() )
|
||||
{
|
||||
$whereFunction = $this->customFiltersForm['where'];
|
||||
$seriesFunction = $this->customFiltersForm['series'];
|
||||
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
unset( $values[ $k ] );
|
||||
$values[ \mb_substr( $k, \mb_strlen( $this->identifier ) ) ] = $v;
|
||||
}
|
||||
|
||||
$this->groupBy = $this->customFiltersForm['groupBy'];
|
||||
$this->where = array( array( $whereFunction( $values ) ) );
|
||||
|
||||
foreach( $seriesFunction( $values ) as $series )
|
||||
{
|
||||
$this->addSeries( $series[0], $series[1], $series[2], $series[3], $series[4] );
|
||||
}
|
||||
}
|
||||
else if ( $this->savedCustomFilters and \count( $this->savedCustomFilters ) )
|
||||
{
|
||||
$whereFunction = $this->customFiltersForm['where'];
|
||||
$seriesFunction = $this->customFiltersForm['series'];
|
||||
|
||||
$this->groupBy = $this->customFiltersForm['groupBy'];
|
||||
$this->where = array( array( $whereFunction( $this->savedCustomFilters ) ) );
|
||||
|
||||
foreach( $seriesFunction( $this->savedCustomFilters ) as $series )
|
||||
{
|
||||
$this->addSeries( $series[0], $series[1], $series[2], $series[3], $series[4] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$seriesFunction = $this->customFiltersForm['defaultSeries'];
|
||||
|
||||
foreach( $seriesFunction() as $series )
|
||||
{
|
||||
$this->addSeries( $series[0], $series[1], $series[2], $series[3], $series[4] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile Data for Output
|
||||
*
|
||||
* @param array $data The data
|
||||
* @return void
|
||||
*/
|
||||
public function compileForOutput(): void
|
||||
public function compileForOutput()
|
||||
{
|
||||
/* Init data */
|
||||
$data = $this->initData();
|
||||
|
||||
|
||||
/* Work out where clause */
|
||||
$where = $this->where;
|
||||
$where[] = array( "{$this->dateField}>?", 0 );
|
||||
@@ -237,8 +301,9 @@ class _Database extends \IPS\Helpers\Chart\Dynamic
|
||||
{
|
||||
$fromUnixTime = "CONVERT_TZ( {$fromUnixTime}, @@session.time_zone, '" . \IPS\Db::i()->escape_string( \IPS\Member::loggedIn()->timezone ) . "' )";
|
||||
}
|
||||
|
||||
$stmt = \IPS\Db::i()->select(
|
||||
"DATE_FORMAT( {$fromUnixTime}, '{$timescale}' ) AS time_as_alias, " . implode( ', ', array_unique( $this->series ) ) . ( $this->groupBy ? ", " . $this->groupBy : '' ),
|
||||
"SQL_BIG_RESULT DATE_FORMAT( {$fromUnixTime}, '{$timescale}' ) AS time_as_alias, " . implode( ', ', array_unique( $this->series ) ) . ( $this->groupBy ? ", " . $this->groupBy : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
'time_as_alias ASC',
|
||||
|
||||
Reference in new issue
Block a user