Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -74,7 +74,42 @@ class Subscriptions extends OverviewStatisticsAbstract
|
||||
{
|
||||
/* Init Chart */
|
||||
$pieBarData = array();
|
||||
$numbers = $this->getBlockNumbers( $dateRange, $subBlock );
|
||||
foreach ( $numbers as $key => $value )
|
||||
{
|
||||
if ( $key === 'statsreports_current_total' or $key === 'statsreports_previous_total' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$pieBarData[] = [
|
||||
'name' => Member::loggedIn()->language()->addToStack( $key ),
|
||||
'value' => $value,
|
||||
'percentage' => $numbers['statsreports_current_total'] ? round( ( $value / $numbers['statsreports_current_total'] ) * 100, 2 ) : 0
|
||||
];
|
||||
}
|
||||
|
||||
$chart = NULL;
|
||||
if( count( $pieBarData ) )
|
||||
{
|
||||
$chart = Theme::i()->getTemplate( 'global', 'core', 'global' )->applePieChart( $pieBarData );
|
||||
}
|
||||
|
||||
return Theme::i()->getTemplate( 'stats' )->overviewComparisonCount( $numbers['statsreports_current_total'], $numbers['statsreports_previous_total'], $chart );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the numbers to add to the CSV export
|
||||
*
|
||||
* @param array|string|null $dateRange
|
||||
* @param string|null $subBlock
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBlockNumbers( array|string $dateRange=null, string $subBlock=null ) : array
|
||||
{
|
||||
/* Init Chart */
|
||||
$numbers = array();
|
||||
|
||||
/* Add Rows */
|
||||
$where = array( array( 'ps_app=?', 'nexus' ), array( 'ps_type=?', 'subscription' ) );
|
||||
$previousCount = NULL;
|
||||
@@ -90,12 +125,15 @@ class Subscriptions extends OverviewStatisticsAbstract
|
||||
$interval = static::getInterval( $dateRange );
|
||||
$initialTimestamp = $currentDate->sub( $interval )->getTimestamp();
|
||||
$where = array( array( 'ps_start > ?', $initialTimestamp ) );
|
||||
|
||||
$previousCount = Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( array( 'ps_app=?', 'nexus' ), array( 'ps_type=?', 'subscription' ), array( 'ps_start BETWEEN ? AND ?', $currentDate->sub( $interval )->getTimestamp(), $initialTimestamp ) ) )->first();
|
||||
$previousWhere = array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'subscription' ),
|
||||
array( 'ps_start BETWEEN ? AND ?', $currentDate->sub( $interval )->getTimestamp(), $initialTimestamp )
|
||||
);
|
||||
$previousCount = Db::i()->select( 'COUNT(*)', 'nexus_purchases', $previousWhere )->first();
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$chart = NULL;
|
||||
|
||||
foreach( Package::roots() as $package )
|
||||
{
|
||||
@@ -108,24 +146,13 @@ class Subscriptions extends OverviewStatisticsAbstract
|
||||
{
|
||||
$total += $value;
|
||||
|
||||
$pieBarData[] = array(
|
||||
'name' => Member::loggedIn()->language()->addToStack('nexus_subs_' . $package->id ),
|
||||
'value' => $value,
|
||||
'percentage' => 0
|
||||
);
|
||||
$numbers['nexus_subs_' . $package->id] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $pieBarData as &$package )
|
||||
{
|
||||
$package['percentage'] = round( ( $package['value'] / $total ) * 100, 2 );
|
||||
}
|
||||
$numbers['statsreports_current_total'] = $total;
|
||||
$numbers['statsreports_previous_total'] = $previousCount;
|
||||
|
||||
if( count( $pieBarData ) )
|
||||
{
|
||||
$chart = Theme::i()->getTemplate( 'global', 'core', 'global' )->applePieChart( $pieBarData );
|
||||
}
|
||||
|
||||
return Theme::i()->getTemplate( 'stats' )->overviewComparisonCount( $total, $previousCount, $chart );
|
||||
return $numbers;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user