Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -79,6 +79,18 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
$perPage
|
||||
);
|
||||
$pastWithdrawals = new \IPS\Patterns\ActiveRecordIterator( $pastWithdrawalsSelect, 'IPS\nexus\Payout' );
|
||||
|
||||
$activePayouts = [];
|
||||
if( !\IPS\Settings::i()->nexus_payout_unlimited_times )
|
||||
{
|
||||
foreach ( $pastWithdrawals as $payout )
|
||||
{
|
||||
if ( $payout->status == \IPS\nexus\Payout::STATUS_PENDING )
|
||||
{
|
||||
$activePayouts[ $payout->currency ] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Can we withdraw? */
|
||||
$canWithdraw = FALSE;
|
||||
@@ -87,7 +99,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
if ( isset( $balance[ $currency ] ) and $balance[ $currency ]->amount->isGreaterThanZero() )
|
||||
if ( isset( $balance[ $currency ] ) and $balance[ $currency ]->amount->isGreaterThanZero() and !isset( $activePayouts[ $currency ] ) )
|
||||
{
|
||||
$canWithdraw = TRUE;
|
||||
}
|
||||
@@ -130,6 +142,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function withdraw()
|
||||
{
|
||||
$activeWithdrawals = \IPS\Settings::i()->nexus_payout_unlimited_times ? [] : iterator_to_array( \IPS\Db::i()->select( 'po_currency', 'nexus_payouts', array( 'po_status=? AND po_member=?', \IPS\nexus\Payout::STATUS_PENDING, \IPS\nexus\Customer::loggedIn()->member_id ) ) );
|
||||
$withdrawForm = NULL;
|
||||
$withdrawOptions = json_decode( \IPS\Settings::i()->nexus_payout, TRUE );
|
||||
if ( isset( $withdrawOptions['Stripe'] ) )
|
||||
@@ -154,7 +167,7 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
$currencyToggles = array();
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
if ( isset( $balance[ $currency ] ) )
|
||||
if ( isset( $balance[ $currency ] ) AND !\in_array( $currency, $activeWithdrawals ) )
|
||||
{
|
||||
$currencyOptions[ $currency ] = $currency;
|
||||
$currencyToggles[ $currency ] = array( 'withdraw_amount_' . $currency );
|
||||
@@ -163,11 +176,11 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
|
||||
$withdrawForm->add( new \IPS\Helpers\Form\Radio( 'withdraw_currency', NULL, TRUE, array( 'options' => $currencyOptions, 'toggles' => $currencyToggles ) ) );
|
||||
}
|
||||
|
||||
|
||||
$canWithdraw = FALSE;
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
if ( !isset( $balance[ $currency ] ) )
|
||||
if ( !isset( $balance[ $currency ] ) OR ( !\IPS\Settings::i()->nexus_payout_unlimited_times AND \in_array( $currency, $activeWithdrawals ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -177,10 +190,10 @@ class _credit extends \IPS\Dispatcher\Controller
|
||||
/* Default 'max' is our balance */
|
||||
$max = (string) $balance[ $currency ]->amount;
|
||||
|
||||
/* Do we have a maximum withdrawl amount set up? */
|
||||
/* Do we have a maximum withdrawal 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 */
|
||||
/* If our maximum withdrawal amount is less than our balance, then the max we can withdraw is that */
|
||||
$upperLimit = $maximumWithdrawalsAmounts[ $currency ];
|
||||
|
||||
/* Determine our date cutoff */
|
||||
|
||||
Reference in new issue
Block a user