Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\nexus\extensions\core\MemberACPProfileBlocks;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -20,7 +20,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* @brief ACP Member Profile: Purchases
|
||||
*/
|
||||
class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
class _Purchases extends \IPS\core\MemberACPProfile\TabbedBlock
|
||||
{
|
||||
/**
|
||||
* Purchase tree
|
||||
@@ -28,22 +28,33 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
protected $_purchases = NULL;
|
||||
|
||||
/**
|
||||
* Get purchase table
|
||||
* Get Tab Names
|
||||
*
|
||||
* @return \IPS\Helpers\Tree\Tree
|
||||
* @return string
|
||||
*/
|
||||
protected function purchases()
|
||||
public function tabs()
|
||||
{
|
||||
if ( $this->_purchases === NULL )
|
||||
{
|
||||
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), array( array( 'ps_member=?', $this->member->member_id ) ) );
|
||||
$this->_purchases->rootsPerPage = 15;
|
||||
$this->_purchases->getTotalRoots = function()
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
return $this->_purchases;
|
||||
$tabs = array();
|
||||
|
||||
$activeCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_active=1 AND ps_parent = 0', $this->member->member_id ) )->first();
|
||||
$tabs['active'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $activeCount,
|
||||
);
|
||||
|
||||
$expiredCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_active = 0 AND ps_cancelled = 0 AND ps_parent = 0 AND ps_expire <?', $this->member->member_id, \IPS\DateTime::create()->getTimestamp() ) )->first();
|
||||
$tabs['expired'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $expiredCount,
|
||||
);
|
||||
|
||||
$canceledCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_cancelled=1 AND ps_parent = 0', $this->member->member_id ) )->first();
|
||||
$tabs['canceled'] = array(
|
||||
'icon' => 'credit-card',
|
||||
'count' => $canceledCount,
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,19 +64,48 @@ class _Purchases extends \IPS\core\MemberACPProfile\Block
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
$purchaseCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1', $this->member->member_id ) )->first();
|
||||
$purchaseRootCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_parent=0', $this->member->member_id ) )->first();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $this->purchases(), $purchaseCount, $purchaseRootCount );
|
||||
$tabs = $this->tabs();
|
||||
if ( !\count( $tabs ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
$tabKeys = array_keys( $tabs );
|
||||
$activeTabKey = ( isset( \IPS\Request::i()->block['nexus_Purchase'] ) and array_key_exists( \IPS\Request::i()->block['nexus_Purchases'], $tabs ) ) ? \IPS\Request::i()->block['nexus_Purchases'] : array_shift( $tabKeys );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'customers', 'nexus' )->purchases( $this->member, $tabs, $activeTabKey, $this->tabOutput( $activeTabKey ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tabOutput()
|
||||
public function tabOutput( $activeTabKey )
|
||||
{
|
||||
return (string) $this->purchases();
|
||||
if ( $this->_purchases === NULL )
|
||||
{
|
||||
$where = array();
|
||||
$where[] = array( 'ps_member=?', $this->member->member_id );
|
||||
|
||||
switch ( $activeTabKey )
|
||||
{
|
||||
case 'active':
|
||||
$where[] = array( 'ps_active=1' );
|
||||
break;
|
||||
case 'canceled':
|
||||
$where[] = array( 'ps_cancelled=1' );
|
||||
break;
|
||||
case 'expired':
|
||||
$where[] = array( 'ps_active = 0 and ps_cancelled = 0 and ps_expire <?', \IPS\DateTime::create()->getTimestamp() );
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'blockKey', 'nexus_Purchases' ), $where );
|
||||
$this->_purchases->getTotalRoots = function()
|
||||
{
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
return $this->_purchases;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user