Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Addresses
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 06 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -37,14 +37,21 @@ class _addresses extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_addresses') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_addresses');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
|
||||
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Addresses', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=addresses', 'front', 'clientsaddresses', array(), \IPS\Settings::i()->nexus_https ) ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->addresses( NULL, NULL, array() ) . $output;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -149,6 +156,8 @@ class _addresses extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function primary()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$address = \IPS\nexus\Customer\Address::load( \IPS\Request::i()->id );
|
||||
@@ -174,6 +183,11 @@ class _addresses extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$address = \IPS\nexus\Customer\Address::load( \IPS\Request::i()->id );
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Alternative Contacts
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 08 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -38,13 +38,20 @@ class _alternatives extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_alternatives') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_alternatives');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
|
||||
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Alternatives', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=alternatives', 'front', 'clientsalternatives', array(), \IPS\Settings::i()->nexus_https ) ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->alternatives( TRUE ) . $output;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -144,6 +151,9 @@ class _alternatives extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$contact = \IPS\nexus\Customer\AlternativeContact::constructFromData( \IPS\Db::i()->select( '*', 'nexus_alternate_contacts', array( 'main_id=? AND alt_id=?', \IPS\nexus\Customer::loggedIn()->member_id, \IPS\Request::i()->id ) )->first() );
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Billing Agreements
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 17 Dec 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\front\clients;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Billing Agreements
|
||||
*/
|
||||
class _billingagreements extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission_guest', '2X321/1', 403, '' );
|
||||
}
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=billingagreements', 'front', 'clientsbillingagreements', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_billing_agreements');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
|
||||
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingAgreements', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=billingagreements', 'front', 'clientsbillingagreements', array(), \IPS\Settings::i()->nexus_https ) ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->billingAgreements( array() ) . $output;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* View List
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$billingAgreements = array();
|
||||
|
||||
$where = array( 'ba_member=?', \IPS\Member::loggedIn()->member_id );
|
||||
$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts( array( 'billing=1' ) );
|
||||
if ( count( $parentContacts ) )
|
||||
{
|
||||
$or = array();
|
||||
foreach ( array_keys( iterator_to_array( $parentContacts ) ) as $id )
|
||||
{
|
||||
$where[0] .= ' OR ba_member=?';
|
||||
$where[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_billing_agreements', $where ), 'IPS\nexus\Customer\BillingAgreement' ) as $billingAgreement )
|
||||
{
|
||||
try
|
||||
{
|
||||
$status = $billingAgreement->status();
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$status = NULL;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$term = $billingAgreement->term();
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$term = NULL;
|
||||
}
|
||||
|
||||
$billingAgreements[] = array(
|
||||
'status' => $status,
|
||||
'id' => $billingAgreement->gw_id,
|
||||
'term' => $term,
|
||||
'url' => $billingAgreement->url()
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->billingAgreements( $billingAgreements );
|
||||
}
|
||||
|
||||
/**
|
||||
* View
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function view()
|
||||
{
|
||||
/* Load Billing Agreement */
|
||||
try
|
||||
{
|
||||
$billingAgreement = \IPS\nexus\Customer\BillingAgreement::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$billingAgreement->status(); // Just to make the API call so we can catch the error if there is one
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X320/4', 404, '' );
|
||||
}
|
||||
catch ( \IPS\nexus\Gateway\PayPal\Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'billing_agreement_error', '4X321/5', 500, '', array(), $e->getName() );
|
||||
}
|
||||
|
||||
/* Get associated purchases */
|
||||
$purchases = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_billing_agreement=?', $billingAgreement->id ) ), 'IPS\nexus\Purchase' ) as $purchase )
|
||||
{
|
||||
$purchases[0][ $purchase->id ] = $purchase;
|
||||
}
|
||||
|
||||
/* Transactions */
|
||||
$currentPage = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
|
||||
$perPage = 25;
|
||||
$invoices = new \IPS\Patterns\ActiveRecordIterator(
|
||||
\IPS\Db::i()->select(
|
||||
'*',
|
||||
'nexus_invoices',
|
||||
array( 'i_id IN(?)', \IPS\Db::i()->select( 't_invoice', 'nexus_transactions', array( 't_billing_agreement=?', $billingAgreement->id ) ) ),
|
||||
'i_date DESC',
|
||||
array( ( $currentPage - 1 ) * $perPage, $perPage ),
|
||||
NULL,
|
||||
NULL,
|
||||
\IPS\Db::SELECT_SQL_CALC_FOUND_ROWS
|
||||
),
|
||||
'IPS\nexus\Invoice'
|
||||
);
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $billingAgreement->url(), ceil( $invoices->count( TRUE ) / $perPage ), $currentPage, $perPage );
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( $billingAgreement->url(), $billingAgreement->gw_id );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->billingAgreement( $billingAgreement, $purchases, $invoices, $pagination );
|
||||
}
|
||||
|
||||
/**
|
||||
* Act
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function act()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Check act */
|
||||
$act = \IPS\Request::i()->act;
|
||||
if ( !in_array( $act, array( 'suspend', 'reactivate', 'cancel' ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '3X321/3', 403, '' );
|
||||
}
|
||||
|
||||
/* Load Billing Agreement */
|
||||
try
|
||||
{
|
||||
$billingAgreement = \IPS\nexus\Customer\BillingAgreement::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X321/2', 404, '' );
|
||||
}
|
||||
|
||||
/* Perform Action */
|
||||
try
|
||||
{
|
||||
$billingAgreement->$act();
|
||||
|
||||
\IPS\Output::i()->redirect( $billingAgreement->url() );
|
||||
}
|
||||
catch ( \DomainException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'billing_agreement_error_public', '3X321/4', 500, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Cards
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 08 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -38,13 +38,20 @@ class _cards extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_cards') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_cards');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
|
||||
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'Cards', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=cards', 'front', 'clientscards', array(), \IPS\Settings::i()->nexus_https ) ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->cards( array() ) . $output;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -65,7 +72,7 @@ class _cards extends \IPS\Dispatcher\Controller
|
||||
'id' => $card->id,
|
||||
'card_type' => $cardData->type,
|
||||
'card_number' => $cardData->lastFour,
|
||||
'card_expire' => str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear
|
||||
'card_expire' => ( !is_null( $cardData->expMonth ) AND !is_null( $cardData->expYear ) ) ? str_pad( $cardData->expMonth , 2, '0', STR_PAD_LEFT ). '/' . $cardData->expYear : NULL
|
||||
);
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
@@ -101,6 +108,10 @@ class _cards extends \IPS\Dispatcher\Controller
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$card = \IPS\nexus\Customer\CreditCard::load( \IPS\Request::i()->id );
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Account Credit
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 08 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -38,13 +38,20 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_credit') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_credit');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
|
||||
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'AccountCredit', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=credit', 'front', 'clientscredit', array(), \IPS\Settings::i()->nexus_https ) ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->credit( NULL, array(), NULL, FALSE, FALSE ) . $output;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -86,7 +93,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
if ( isset( $balance[ $currency ] ) )
|
||||
if ( isset( $balance[ $currency ] ) and $balance[ $currency ]->amount->isGreaterThanZero() )
|
||||
{
|
||||
$canWithdraw = TRUE;
|
||||
}
|
||||
@@ -110,8 +117,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach ( $account->cm_credits as $value )
|
||||
{
|
||||
$max = $maximumBalanceAmounts ? ( $maximumBalanceAmounts[ $value->currency ]['amount'] - $value->amount ) : NULL;
|
||||
if ( is_null( $max ) or $max > 0 )
|
||||
if ( $maximumBalanceAmounts === NULL or $value->amount->compare( new \IPS\Math\Number( number_format( $maximumBalanceAmounts[ $value->currency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $value->currency ), '.', '' ) ) ) === -1 )
|
||||
{
|
||||
$canTopup = TRUE;
|
||||
}
|
||||
@@ -132,11 +138,16 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$withdrawForm = NULL;
|
||||
$withdrawOptions = json_decode( \IPS\Settings::i()->nexus_payout, TRUE );
|
||||
if ( isset( $withdrawOptions['Stripe'] ) )
|
||||
{
|
||||
unset( $withdrawOptions['Stripe'] );
|
||||
}
|
||||
if ( count( $withdrawOptions ) )
|
||||
{
|
||||
$withdrawForm = new \IPS\Helpers\Form( 'withdraw', 'withdraw_credit' );
|
||||
|
||||
$minimumWithdrawalsAmounts = ( \IPS\Settings::i()->nexus_payout_min and \IPS\Settings::i()->nexus_payout_min !== '*' ) ? json_decode( \IPS\Settings::i()->nexus_payout_min, TRUE ) : NULL;
|
||||
$maximumWithdrawalsAmounts = ( \IPS\Settings::i()->nexus_payout_max and \IPS\Settings::i()->nexus_payout_max !== '*' ) ? json_decode( \IPS\Settings::i()->nexus_payout_max, TRUE ) : NULL;
|
||||
|
||||
$balance = array_filter( \IPS\nexus\Customer::loggedIn()->cm_credits, function( $val )
|
||||
{
|
||||
@@ -167,10 +178,42 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
continue;
|
||||
}
|
||||
|
||||
$min = $minimumWithdrawalsAmounts ? ( $minimumWithdrawalsAmounts[ $currency ]['amount'] ) : NULL;
|
||||
$max = $balance[ $currency ]->amount;
|
||||
|
||||
$field = new \IPS\Helpers\Form\Number( 'withdraw_amount_' . $currency, $max, count( $currencyOptions ) ? NULL : TRUE, array( 'min' => $min, 'max' => $max, 'decimals' => TRUE ), count( $currencyOptions ) ? NULL : function( $val ) use ( $currency )
|
||||
$min = $minimumWithdrawalsAmounts ? ( $minimumWithdrawalsAmounts[ $currency ]['amount'] ) : 0;
|
||||
|
||||
/* Default 'max' is our balance */
|
||||
$max = (string) $balance[ $currency ]->amount;
|
||||
|
||||
/* Do we have a maximum withdrawl amount set up? */
|
||||
if( $maximumWithdrawalsAmounts AND $maximumWithdrawalsAmounts[ $currency ] )
|
||||
{
|
||||
/* If our maximum withdrawl amount is less than our balance, then the max we can withdraw is that */
|
||||
$upperLimit = $maximumWithdrawalsAmounts[ $currency ];
|
||||
|
||||
/* Determine our date cutoff */
|
||||
$periodRestrictions = json_decode( \IPS\Settings::i()->nexus_payout_max_period, TRUE );
|
||||
|
||||
$interval = 'P' . (int) $periodRestrictions[0] . ( mb_strtoupper( mb_substr( $periodRestrictions[1], 0, 1 ) ) );
|
||||
$date = \IPS\DateTime::create()->sub( new \DateInterval( $interval ) )->getTimestamp();
|
||||
|
||||
/* Get our (non-cancelled) payout requests since the date cutoff */
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_payouts', array( 'po_member=? AND po_date>? AND po_status NOT IN(?) AND po_currency=?', \IPS\nexus\Customer::loggedIn()->member_id, $date, 'canc', $currency ) ) as $request )
|
||||
{
|
||||
$upperLimit -= $request['po_amount'];
|
||||
}
|
||||
|
||||
/* Do we need to reset the max? */
|
||||
if( $upperLimit < $max )
|
||||
{
|
||||
$max = $upperLimit;
|
||||
}
|
||||
}
|
||||
|
||||
if( $max <= 0 )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words[ 'withdraw_amount_' . $currency . '_desc' ] = \IPS\Member::loggedIn()->language()->addToStack( 'max_withdrawl_exceeded' );
|
||||
}
|
||||
|
||||
$field = new \IPS\Helpers\Form\Number( 'withdraw_amount_' . $currency, (string) $max, count( $currencyOptions ) ? NULL : TRUE, array( 'min' => $min, 'max' => (string) $max, 'decimals' => \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ), 'disabled' => ( $max <= 0 ) ), count( $currencyOptions ) ? NULL : function( $val ) use ( $currency )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->withdraw_currency === $currency )
|
||||
{
|
||||
@@ -244,7 +287,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
$payout->save();
|
||||
|
||||
$credits = \IPS\nexus\Customer::loggedIn()->cm_credits;
|
||||
$credits[ $currency ]->amount -= $values[ 'withdraw_amount_' . $currency ];
|
||||
$credits[ $currency ]->amount = $credits[ $currency ]->amount->subtract( new \IPS\Math\Number( number_format( $values[ 'withdraw_amount_' . $currency ], \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ), '.', '' ) ) );
|
||||
\IPS\nexus\Customer::loggedIn()->cm_credits = $credits;
|
||||
\IPS\nexus\Customer::loggedIn()->save();
|
||||
|
||||
@@ -300,10 +343,10 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach ( $account->cm_credits as $value )
|
||||
{
|
||||
$max = $maximumBalanceAmounts ? ( $maximumBalanceAmounts[ $value->currency ]['amount'] - $value->amount ) : NULL;
|
||||
if ( is_null( $max ) or $max > 0 )
|
||||
$max = $maximumBalanceAmounts ? ( ( new \IPS\Math\Number( number_format( $maximumBalanceAmounts[ $value->currency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $value->currency ), '.', '' ) ) )->subtract( $value->amount ) ) : NULL;
|
||||
if ( is_null( $max ) or $max->isGreaterThanZero() )
|
||||
{
|
||||
$maximums[ $account->member_id ][ $value->currency ] = $max;
|
||||
$maximums[ $account->member_id ][ $value->currency ] = is_null( $max ) ? NULL : (string) $max;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,7 +389,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$min = $minimumTopupAmounts ? ( $minimumTopupAmounts[ $currency ]['amount'] ) : 0.01;
|
||||
|
||||
$field = new \IPS\Helpers\Form\Number( 'topup_amount_' . $accountId . '_' . $currency, NULL, NULL, array( 'decimals' => TRUE ), function( $val ) use ( $currency, $accountOptions, $accountId, $data, $min, $maximum )
|
||||
$field = new \IPS\Helpers\Form\Number( 'topup_amount_' . $accountId . '_' . $currency, NULL, NULL, array( 'decimals' => \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ) ), function( $val ) use ( $currency, $accountOptions, $accountId, $data, $min, $maximum )
|
||||
{
|
||||
if ( count( $accountOptions ) === 1 or \IPS\Request::i()->topup_account == $accountId )
|
||||
{
|
||||
@@ -375,6 +418,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $topupForm->values() )
|
||||
{
|
||||
|
||||
$account = isset( $values['topup_account'] ) ? \IPS\nexus\Customer::load( $values['topup_account'] ) : \IPS\nexus\Customer::loggedIn();
|
||||
if ( isset( $values[ 'topup_currency_' . $account->member_id ] ) )
|
||||
{
|
||||
@@ -422,7 +466,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
$payout->save();
|
||||
|
||||
$credits = $payout->member->cm_credits;
|
||||
$credits[ $payout->amount->currency ]->amount += $payout->amount->amount;
|
||||
$credits[ $payout->amount->currency ]->amount = $credits[ $payout->amount->currency ]->amount->add( $payout->amount->amount );
|
||||
$payout->member->cm_credits = $credits;
|
||||
$payout->member->save();
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Donations
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 17 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -33,7 +33,7 @@ class _donations extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Custom Fields
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 08 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -38,12 +38,24 @@ class _info extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ), \IPS\Member::loggedIn()->language()->addToStack('client_info') );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_info');
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
|
||||
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingInfo', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ) ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
foreach( $this->_buildInfoForm( TRUE ) AS $formElement )
|
||||
{
|
||||
$form->add( $formElement );
|
||||
}
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->info( $form ) . $output;
|
||||
return;
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -55,21 +67,37 @@ class _info extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
|
||||
foreach( $this->_buildInfoForm() AS $formElement )
|
||||
{
|
||||
$column = $field->column;
|
||||
$form->add( $field->buildHelper( \IPS\nexus\Customer::loggedIn()->$column ) );
|
||||
$form->add( $formElement );
|
||||
}
|
||||
|
||||
if ( $values = $form->values( TRUE ) )
|
||||
{
|
||||
$changes = array();
|
||||
foreach( array( 'cm_first_name', 'cm_last_name' ) AS $nameField )
|
||||
{
|
||||
if ( isset( $values[ $nameField ] ) )
|
||||
{
|
||||
if ( $values[ $nameField ] != \IPS\nexus\Customer::loggedIn()->$nameField )
|
||||
{
|
||||
/* We only need to log this once, so do it if it isn't set */
|
||||
if ( !isset( $changes['name'] ) )
|
||||
{
|
||||
$changes['name'] = \IPS\nexus\Customer::loggedIn()->cm_name;
|
||||
}
|
||||
|
||||
\IPS\nexus\Customer::loggedIn()->$nameField = $values[ $nameField ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
|
||||
{
|
||||
$column = $field->column;
|
||||
if ( \IPS\nexus\Customer::loggedIn()->$column != $values["nexus_ccfield_{$field->id}"] )
|
||||
{
|
||||
$changes[] = array( 'name' => 'nexus_ccfield_' . $field->id, 'value' => $values["nexus_ccfield_{$field->id}"], 'old' => \IPS\nexus\Customer::loggedIn()->$column );
|
||||
$changes['other'][] = array( 'name' => 'nexus_ccfield_' . $field->id, 'value' => $field->displayValue( $values["nexus_ccfield_{$field->id}"] ), 'old' => \IPS\nexus\Customer::loggedIn()->$column );
|
||||
\IPS\nexus\Customer::loggedIn()->$column = $values["nexus_ccfield_{$field->id}"];
|
||||
}
|
||||
|
||||
@@ -80,7 +108,7 @@ class _info extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
if ( !empty( $changes ) )
|
||||
{
|
||||
\IPS\nexus\Customer::loggedIn()->log( 'info', array( 'other' => $changes ) );
|
||||
\IPS\nexus\Customer::loggedIn()->log( 'info', $changes );
|
||||
}
|
||||
\IPS\nexus\Customer::loggedIn()->save();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ) );
|
||||
@@ -88,4 +116,24 @@ class _info extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->info( $form );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build Information Form
|
||||
*
|
||||
* @param bool $protected If TRUE, current values will be blanked out
|
||||
* @return array
|
||||
*/
|
||||
protected function _buildInfoForm( $protected = FALSE )
|
||||
{
|
||||
$formElements = array();
|
||||
$formElements['cm_first_name'] = new \IPS\Helpers\Form\Text( 'cm_first_name', $protected ? NULL : \IPS\nexus\Customer::loggedIn()->cm_first_name, TRUE );
|
||||
$formElements['cm_last_name'] = new \IPS\Helpers\Form\Text( 'cm_last_name', $protected ? NULL : \IPS\nexus\Customer::loggedIn()->cm_last_name, TRUE );
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
|
||||
{
|
||||
$column = $field->column;
|
||||
$formElements[ $column ] = $field->buildHelper( $protected ? NULL : \IPS\nexus\Customer::loggedIn()->$column );
|
||||
}
|
||||
|
||||
return $formElements;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Invoices
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 06 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -38,12 +38,17 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
/* Load Invoice */
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->printout ) )
|
||||
{
|
||||
\IPS\Request::i()->do = 'printout';
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$this->invoice = \IPS\nexus\Invoice::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
@@ -71,6 +76,11 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Invoices Per Page
|
||||
*/
|
||||
protected static $invoicesPerPage = 25;
|
||||
|
||||
/**
|
||||
* View List
|
||||
@@ -90,9 +100,26 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
$where[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_invoices', $where )->first();
|
||||
$page = isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1;
|
||||
|
||||
if ( $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$pages = ( $count > 0 ) ? ceil( $count / static::$invoicesPerPage ) : 1;
|
||||
|
||||
if ( $page > $pages )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=clients&controller=invoices", 'front', 'clients' ) );
|
||||
}
|
||||
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( \IPS\Http\Url::internal( "app=nexus&module=clients&controller=invoices", 'front', 'clients' ), $pages, $page, static::$invoicesPerPage );
|
||||
|
||||
$invoices = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_invoices', $where, 'i_date DESC' ), 'IPS\nexus\Invoice' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->invoices( $invoices );
|
||||
$invoices = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_invoices', $where, 'i_date DESC', array( ( $page - 1 ) * static::$invoicesPerPage, static::$invoicesPerPage ) ), 'IPS\nexus\Invoice' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->invoices( $invoices, $pagination );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +179,21 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function printout()
|
||||
{
|
||||
$output = \IPS\Theme::i()->getTemplate( 'invoices', 'nexus', 'global' )->printInvoice( $this->invoice, $this->invoice->summary() );
|
||||
$address = NULL;
|
||||
if ( $this->invoice->billaddress )
|
||||
{
|
||||
$address = $this->invoice->billaddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$address = \IPS\nexus\Customer\Address::constructFromData( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( "member=? AND primary_billing=?", $this->invoice->member->member_id, 1 ) )->first() )->address;
|
||||
}
|
||||
catch( \UnderflowException $e ) {}
|
||||
}
|
||||
|
||||
$output = \IPS\Theme::i()->getTemplate( 'invoices', 'nexus', 'global' )->printInvoice( $this->invoice, $this->invoice->summary(), $address );
|
||||
\IPS\Output::i()->title = 'I' . $this->invoice->id;
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ) );
|
||||
}
|
||||
@@ -164,16 +205,40 @@ class _invoices extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
/* CSRF check */
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Can only cancel the invoice if it's pending */
|
||||
if ( $this->invoice->status !== \IPS\nexus\Invoice::STATUS_PENDING )
|
||||
{
|
||||
\IPS\Output::i()->error( 'order_already_paid', '2X215/4', 403, '' );
|
||||
}
|
||||
|
||||
/* If they have already made a partial payment, refund it to their account credit */
|
||||
foreach ( $this->invoice->transactions( array( \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED ) ) as $transaction )
|
||||
{
|
||||
try
|
||||
{
|
||||
$transaction->refund( 'credit' );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'order_cancel_error', '4C171/5', 500, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
/* Cancel the invoice */
|
||||
$this->invoice->status = \IPS\nexus\invoice::STATUS_CANCELED;
|
||||
$this->invoice->save();
|
||||
$this->invoice->member->log( 'invoice', array( 'type' => 'status', 'new' => 'canc', 'id' => $this->invoice->id, 'title' => $this->invoice->title ) );
|
||||
|
||||
/* Run any callbacks (for example, coupons get unmarked as being used) */
|
||||
foreach ( $this->invoice->items as $k => $item )
|
||||
{
|
||||
$item->onInvoiceCancel( $this->invoice );
|
||||
}
|
||||
|
||||
$this->invoice->member->log( 'invoice', array( 'type' => 'status', 'new' => 'canc', 'id' => $this->invoice->id, 'title' => $this->invoice->title ) );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( $this->invoice->url() );
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Network Status
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 11 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Purchases
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 06 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -38,7 +38,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
/* Purchases breadcrumb */
|
||||
@@ -182,7 +182,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'renew_for', 1, TRUE, array( 'min' => 1, 'max' => $cycles === TRUE ? NULL : $cycles ), NULL, NULL, $suffix ) );
|
||||
if( $values = $form->values() or $cycles === 1 )
|
||||
{
|
||||
if ( $pendingInvoice = $this->purchase->invoice_pending )
|
||||
if ( $pendingInvoice = $this->purchase->invoice_pending and $pendingInvoice->status === $pendingInvoice::STATUS_PENDING )
|
||||
{
|
||||
if ( count( $pendingInvoice->items ) === 1 )
|
||||
{
|
||||
@@ -231,6 +231,15 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $this->purchase->id, 'name' => $this->purchase->name, 'info' => 'remove_renewals' ) );
|
||||
|
||||
/* If we have a pending renewal invoice, cancel it (as at this point, we need to reactivate instead) */
|
||||
if ( $this->purchase->invoice_pending )
|
||||
{
|
||||
$this->purchase->invoice_pending->status = \IPS\nexus\Invoice::STATUS_CANCELED; # The constant has a typo and it make me sad
|
||||
$this->purchase->invoice_pending->save();
|
||||
|
||||
$this->purchase->invoice_pending = NULL;
|
||||
}
|
||||
|
||||
$this->purchase->renewals = NULL;
|
||||
$this->purchase->can_reactivate = TRUE;
|
||||
$this->purchase->save();
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Referrals
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Nexus
|
||||
* @since 15 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -33,7 +33,7 @@ class _referrals extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( mb_strtolower( $_SERVER['REQUEST_METHOD'] ) == 'get' and \IPS\Settings::i()->nexus_https and \IPS\Request::i()->url()->data['scheme'] !== 'https' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( new \IPS\Http\Url( preg_replace( '/^http:/', 'https:', \IPS\Request::i()->url() ) ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setScheme('https') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'clients.css', 'nexus' ) );
|
||||
|
||||
Reference in new issue
Block a user