Version 4.3.6
This commit is contained in:
1 parent
fe1acf984a
commit
1a0c7fd3c2
609 files changed
+14707
-5726
No files matched your search
@@ -69,75 +69,80 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
protected function _overview()
|
||||
{
|
||||
/* Sparkline */
|
||||
$rows = array();
|
||||
$oneYearAgo = \IPS\DateTime::create()->sub( new \DateInterval('P1Y') );
|
||||
$date = clone $oneYearAgo;
|
||||
$endOfLastMonth = mktime( 23, 59, 59, date('n') - 1, date('t'), date('Y') );
|
||||
while ( $date->getTimestamp() < $endOfLastMonth )
|
||||
$sparkline = NULL;
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customer', 'customers_view_statistics' ) )
|
||||
{
|
||||
$rows = array();
|
||||
$oneYearAgo = \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) );
|
||||
$date = clone $oneYearAgo;
|
||||
$endOfLastMonth = mktime( 23, 59, 59, date( 'n' ) - 1, date( 't' ), date( 'Y' ) );
|
||||
while ( $date->getTimestamp() < $endOfLastMonth )
|
||||
{
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
$rows[$date->format( 'n Y' )][$currency] = 0;
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1M' ) );
|
||||
}
|
||||
$sparkline = new \IPS\Helpers\Chart;
|
||||
foreach ( \IPS\Db::i()->select( 'DATE_FORMAT( FROM_UNIXTIME(t_date), \'%c %Y\' ) AS time, SUM(t_amount)-SUM(t_partial_refund) AS amount, t_currency', 'nexus_transactions', array(array("t_member=? AND ( t_status=? OR t_status=? ) AND t_method>0 AND t_date>? AND t_date<?", $this->member->member_id, \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $oneYearAgo->getTimestamp(), time())), NULL, NULL, array('time', 't_currency') ) as $row )
|
||||
{
|
||||
if ( isset( $rows[$row['time']][$row['t_currency']] ) ) // Currency may no longer exist
|
||||
{
|
||||
$rows[$row['time']][$row['t_currency']] += $row['amount'];
|
||||
}
|
||||
}
|
||||
$sparkline->addHeader( \IPS\Member::loggedIn()->language()->addToStack( 'date' ), 'date' );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
$rows[ $date->format( 'n Y' ) ][ $currency ] = 0;
|
||||
$sparkline->addHeader( $currency, 'number' );
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1M' ) );
|
||||
}
|
||||
$sparkline = new \IPS\Helpers\Chart;
|
||||
foreach( \IPS\Db::i()->select( 'DATE_FORMAT( FROM_UNIXTIME(t_date), \'%c %Y\' ) AS time, SUM(t_amount)-SUM(t_partial_refund) AS amount, t_currency', 'nexus_transactions', array( array( "t_member=? AND ( t_status=? OR t_status=? ) AND t_date>? AND t_date<?", $this->member->member_id, \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $oneYearAgo->getTimestamp(), time() ) ), NULL, NULL, array( 'time', 't_currency' ) ) as $row )
|
||||
{
|
||||
if ( isset( $rows[ $row['time'] ][ $row['t_currency'] ] ) ) // Currency may no longer exist
|
||||
foreach ( $rows as $time => $row )
|
||||
{
|
||||
$rows[ $row['time'] ][ $row['t_currency'] ] += $row['amount'];
|
||||
}
|
||||
}
|
||||
$sparkline->addHeader( \IPS\Member::loggedIn()->language()->addToStack('date'), 'date' );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
$sparkline->addHeader( $currency, 'number' );
|
||||
}
|
||||
foreach ( $rows as $time => $row )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$exploded = explode( ' ', $time );
|
||||
$datetime->setDate( $exploded[1], $exploded[0], 1 );
|
||||
$datetime = new \IPS\DateTime;
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$exploded = explode( ' ', $time );
|
||||
$datetime->setDate( $exploded[1], $exploded[0], 1 );
|
||||
|
||||
foreach( $row as $currency => $value )
|
||||
{
|
||||
$row[ $currency ] = number_format( $value, 2, '.', '' );
|
||||
foreach ( $row as $currency => $value )
|
||||
{
|
||||
$row[$currency] = number_format( $value, 2, '.', '' );
|
||||
}
|
||||
|
||||
$sparkline->addRow( array_merge( array($datetime), $row ) );
|
||||
}
|
||||
|
||||
$sparkline->addRow( array_merge( array( $datetime ), $row ) );
|
||||
|
||||
$sparkline = $sparkline->render( 'AreaChart', array(
|
||||
'areaOpacity' => 0.4,
|
||||
'backgroundColor' => '#fff',
|
||||
'colors' => array('#10967e'),
|
||||
'chartArea' => array(
|
||||
'left' => 0,
|
||||
'top' => 0,
|
||||
'width' => '100%',
|
||||
'height' => '100%',
|
||||
),
|
||||
'hAxis' => array(
|
||||
'baselineColor' => '#F3F3F3',
|
||||
'gridlines' => array(
|
||||
'count' => 0,
|
||||
)
|
||||
),
|
||||
'height' => 60,
|
||||
'legend' => array(
|
||||
'position' => 'none',
|
||||
),
|
||||
'lineWidth' => 1,
|
||||
'vAxis' => array(
|
||||
'baselineColor' => '#F3F3F3',
|
||||
'gridlines' => array(
|
||||
'count' => 0,
|
||||
)
|
||||
),
|
||||
) );
|
||||
}
|
||||
|
||||
$sparkline = $sparkline->render( 'AreaChart', array(
|
||||
'areaOpacity' => 0.4,
|
||||
'backgroundColor' => '#fff',
|
||||
'colors' => array( '#10967e' ),
|
||||
'chartArea' => array(
|
||||
'left' => 0,
|
||||
'top' => 0,
|
||||
'width' => '100%',
|
||||
'height' => '100%',
|
||||
),
|
||||
'hAxis' => array(
|
||||
'baselineColor' => '#F3F3F3',
|
||||
'gridlines' => array(
|
||||
'count' => 0,
|
||||
)
|
||||
),
|
||||
'height' => 60,
|
||||
'legend' => array(
|
||||
'position' => 'none',
|
||||
),
|
||||
'lineWidth' => 1,
|
||||
'vAxis' => array(
|
||||
'baselineColor' => '#F3F3F3',
|
||||
'gridlines' => array(
|
||||
'count' => 0,
|
||||
)
|
||||
),
|
||||
) );
|
||||
|
||||
|
||||
/* Referrals */
|
||||
try
|
||||
{
|
||||
@@ -170,7 +175,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
protected function _cards( $edit = FALSE )
|
||||
{
|
||||
$cards = array();
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ), NULL, \IPS\Request::i()->view === 'cards' ? NULL : 2 ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customer_cards', array( 'card_member=?', $this->member->member_id ), NULL, $edit ? NULL : 10 ), 'IPS\nexus\Customer\CreditCard' ) as $card )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -233,7 +238,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
{
|
||||
$billingAgreementCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_billing_agreements', array( 'ba_member=? AND ba_canceled=0', $this->member->member_id ) )->first();
|
||||
$billingAgreements = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_billing_agreements', array( 'ba_member=? AND ba_canceled=0', $this->member->member_id ), NULL, \IPS\Request::i()->view === 'billingagreements' ? NULL : 2 ) as $billingAgreement )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_billing_agreements', array( 'ba_member=? AND ba_canceled=0', $this->member->member_id ), NULL, $edit ? NULL : 10 ) as $billingAgreement )
|
||||
{
|
||||
$billingAgreements[ $billingAgreement['ba_id'] ] = array(
|
||||
'id' => $billingAgreement['ba_id'],
|
||||
@@ -412,7 +417,7 @@ class _AccountInformation extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[] = new \IPS\nexus\Money( 0, $this->member->defaultCurrency() );
|
||||
$return[] = new \IPS\nexus\Money( 0, \IPS\nexus\Customer::load( $this->member )->defaultCurrency() );
|
||||
}
|
||||
return implode( '<br>', $return );
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class _Notes extends \IPS\core\MemberACPProfile\Block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function edit()
|
||||
public function lazyOutput()
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->customerPopup( $this->notes );
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
/**
|
||||
* Get purchase table
|
||||
*
|
||||
* @return \IPS\IPS\Helpers\Tree
|
||||
* @return \IPS\Helpers\Tree\Tree
|
||||
*/
|
||||
protected function purchases()
|
||||
{
|
||||
|
||||
@@ -34,8 +34,8 @@ class _Statistics extends \IPS\core\MemberACPProfile\LazyLoadingBlock
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
/* Total spent */
|
||||
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "(SUM(t_amount)-SUM(t_partial_refund)) as xval", 'nexus_transactions', array( '( t_status=? OR t_status=? ) AND t_currency=? AND t_member<>0', \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ), NULL, NULL, 't_member' ), 'xval>0' )->first();
|
||||
$val = \IPS\Db::i()->select( 'SUM(t_amount)-SUM(t_partial_refund)', 'nexus_transactions', array( 't_member=? AND ( t_status=? OR t_status=? ) AND t_currency=?', $this->member->member_id, \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ) )->first();
|
||||
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "(SUM(t_amount)-SUM(t_partial_refund)) as xval", 'nexus_transactions', array( '( t_status=? OR t_status=? ) AND t_method>0 AND t_currency=? AND t_member<>0', \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ), NULL, NULL, 't_member' ), 'xval>0' )->first();
|
||||
$val = \IPS\Db::i()->select( 'SUM(t_amount)-SUM(t_partial_refund)', 'nexus_transactions', array( 't_member=? AND ( t_status=? OR t_status=? ) AND t_method>0 AND t_currency=?', $this->member->member_id, \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ) )->first();
|
||||
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'total_spent_currency', FALSE, array( 'sprintf' => array( $currency ) ) ) ] = array(
|
||||
'value' => new \IPS\nexus\Money( $val ?: '0', $currency ),
|
||||
'avg' => new \IPS\nexus\Money( $comparisons['avg'], $currency ),
|
||||
|
||||
Reference in new issue
Block a user