Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -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' ) );
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Incoming 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,8 +33,8 @@ class _referral extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'referred_by', intval( \IPS\Request::i()->id ), \IPS\DateTime::create()->add( new \DateInterval( 'P1Y' ) ) );
|
||||
|
||||
$target = new \IPS\Http\Url( \IPS\Request::i()->direct ? base64_decode( \IPS\Request::i()->direct ) : \IPS\Settings::i()->base_url );
|
||||
if ( $target->isInternal )
|
||||
$target = \IPS\Request::i()->direct ? \IPS\Http\Url::createFromString( base64_decode( \IPS\Request::i()->direct ) ) : \IPS\Http\Url::baseUrl();
|
||||
if ( $target instanceof \IPS\Http\Url\Internal )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $target );
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief View Cart
|
||||
* @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 29 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -53,7 +53,7 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$_SESSION['cart'] = array();
|
||||
}
|
||||
$currency = isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
$currency = ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
@@ -89,6 +89,7 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$v += $_item->quantity;
|
||||
unset( $_SESSION['cart'][ $_k ] );
|
||||
\IPS\Db::i()->update( 'nexus_cart_uploads', array( 'item_id' => $k ), array( 'session_id=? AND item_id=?', \IPS\Session::i()->id, $_k ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +127,14 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
if ( $_SESSION['cart'][ $k ]->quantity == 0 )
|
||||
{
|
||||
unset( $_SESSION['cart'][ $k ] );
|
||||
|
||||
$ids = array();
|
||||
foreach ( \IPS\Db::i()->select( 'id', 'nexus_cart_uploads', array( 'session_id=? AND item_id=?', \IPS\Session::i()->id, $k ) ) as $id )
|
||||
{
|
||||
\IPS\File::unclaimAttachments( 'nexus_Purchases', $id, NULL, 'cart' );
|
||||
$ids[] = $id;
|
||||
}
|
||||
\IPS\Db::i()->delete( 'nexus_cart_uploads', \IPS\Db::i()->in( 'id', $ids ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +145,7 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
$currency = isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
$currency = ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate('store')->cartContents( ( isset( $_SESSION['location'] ) and $_SESSION['location'] ) ? \IPS\GeoLocation::buildFromJson( $_SESSION['location'] ) : NULL, $currency ), 200, 'text/html' );
|
||||
}
|
||||
else
|
||||
@@ -155,6 +164,13 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$_SESSION['cart'] = array();
|
||||
$ids = array();
|
||||
foreach ( \IPS\Db::i()->select( 'id', 'nexus_cart_uploads', array( 'session_id=?', \IPS\Session::i()->id ) ) as $id )
|
||||
{
|
||||
\IPS\File::unclaimAttachments( 'nexus_Purchases', $id, NULL, 'cart' );
|
||||
$ids[] = $id;
|
||||
}
|
||||
\IPS\Db::i()->delete( 'nexus_cart_uploads', \IPS\Db::i()->in( 'id', $ids ) );
|
||||
|
||||
if ( \IPS\CACHE_PAGE_TIMEOUT and !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
@@ -180,21 +196,31 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$currency = isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
$currency = ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
|
||||
$canRegister = ( !\IPS\Settings::i()->nexus_reg_force or \IPS\Member::loggedIn()->member_id );
|
||||
|
||||
$tempInvoiceKey = md5( uniqid() );
|
||||
|
||||
$invoice = new \IPS\nexus\Invoice;
|
||||
$invoice->member = \IPS\nexus\Customer::loggedIn();
|
||||
$invoice->currency = $currency;
|
||||
foreach ( $_SESSION['cart'] as $item )
|
||||
foreach ( $_SESSION['cart'] as $k => $item )
|
||||
{
|
||||
if ( !$canRegister and \IPS\nexus\Package::load( $item->id )->reg )
|
||||
{
|
||||
$canRegister = TRUE;
|
||||
}
|
||||
|
||||
$invoice->addItem( $item );
|
||||
$itemId = $invoice->addItem( $item );
|
||||
|
||||
$ids = array();
|
||||
foreach ( \IPS\Db::i()->select( 'id', 'nexus_cart_uploads', array( 'session_id=? AND item_id=?', \IPS\Session::i()->id, $k ) ) as $id )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_attachments_map', array( 'id1' => $itemId, 'id3' => "invoice-{$tempInvoiceKey}" ), array( 'location_key=? AND id1=? AND id3=?', 'nexus_Purchases', $id, 'cart' ) );
|
||||
$ids[] = $id;
|
||||
}
|
||||
\IPS\Db::i()->delete( 'nexus_cart_uploads', \IPS\Db::i()->in( 'id', $ids ) );
|
||||
}
|
||||
|
||||
if ( !count( $invoice->items ) )
|
||||
@@ -207,7 +233,7 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=store&controller=store&do=register', 'front', 'store' ) );
|
||||
}
|
||||
|
||||
if ( $minimumOrderAmounts = json_decode( \IPS\Settings::i()->nexus_minimum_order, TRUE ) and $minimumOrderAmounts[ $currency ]['amount'] > $invoice->total->amount )
|
||||
if ( $minimumOrderAmounts = json_decode( \IPS\Settings::i()->nexus_minimum_order, TRUE ) and ( new \IPS\Math\Number( number_format( $minimumOrderAmounts[ $currency ]['amount'], 2, '.', '' ) ) )->compare( $invoice->total->amount ) === 1 )
|
||||
{
|
||||
\IPS\Output::i()->error( \IPS\Member::loggedIn()->language()->addToStack( 'err_minimum_order', FALSE, array( 'sprintf' => array( new \IPS\nexus\Money( $minimumOrderAmounts[ $currency ]['amount'], $currency ) ) ) ), '1X214/1', 403, '' );
|
||||
}
|
||||
@@ -217,6 +243,10 @@ class _cart extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'noCache', 0, \IPS\DateTime::ts( time() - 86400 ) );
|
||||
}
|
||||
|
||||
$invoice->save();
|
||||
\IPS\Db::i()->update( 'core_attachments_map', array( 'id3' => "invoice-{$invoice->id}" ), array( 'location_key=? AND id3=?', 'nexus_Purchases', "invoice-{$tempInvoiceKey}" ) );
|
||||
|
||||
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Gift Vouchers
|
||||
* @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 5 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -51,7 +51,7 @@ class _gifts extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* Work out what our options are */
|
||||
$memberCurrency = ( isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() );
|
||||
$memberCurrency = ( ( ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() );
|
||||
$options = array();
|
||||
foreach ( json_decode( \IPS\Settings::i()->nexus_gift_vouchers, TRUE ) as $voucher )
|
||||
{
|
||||
@@ -84,32 +84,41 @@ class _gifts extends \IPS\Dispatcher\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'gift_voucher_recipient' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'gift_voucher_sender', \IPS\Member::loggedIn()->name ) );
|
||||
$form->add( new \IPS\Helpers\Form\TextArea( 'gift_voucher_message' ) );
|
||||
$formTemplate = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'store', 'nexus' ) ), 'giftCardForm' ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$item = new \IPS\nexus\extensions\nexus\Item\GiftVoucher( \IPS\Member::loggedIn()->language()->get('gift_voucher'), new \IPS\nexus\Money( $values['gift_voucher_amount'], $memberCurrency ) );
|
||||
$item->paymentMethodIds = array_keys( \IPS\nexus\Gateway::roots( NULL, NULL, array( 'm_active=1 AND m_gateway<>?', 'TwoCheckout' ) ) ); // It is against 2CO terms to use them for buying gift vouchers
|
||||
$item->extra['method'] = $values['gift_voucher_method'];
|
||||
$item->extra['recipient_email'] = $values['gift_voucher_email'];
|
||||
$item->extra['recipient_name'] = $values['gift_voucher_recipient'];
|
||||
$item->extra['sender'] = $values['gift_voucher_sender'];
|
||||
$item->extra['message'] = $values['gift_voucher_message'];
|
||||
$item->extra['amount'] = $values['gift_voucher_amount'];
|
||||
$item->extra['color'] = $values['gift_voucher_color'];
|
||||
$item->extra['currency'] = $memberCurrency;
|
||||
if( ! abs( $values['gift_voucher_amount'] ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'gift_voucher_invalid_amount' );
|
||||
}
|
||||
|
||||
$invoice = new \IPS\nexus\Invoice;
|
||||
$invoice->currency = $memberCurrency;
|
||||
$invoice->member = \IPS\Member::loggedIn();
|
||||
$invoice->addItem( $item );
|
||||
$invoice->save();
|
||||
|
||||
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
|
||||
if( !$form->error )
|
||||
{
|
||||
$item = new \IPS\nexus\extensions\nexus\Item\GiftVoucher( \IPS\Member::loggedIn()->language()->get( 'gift_voucher' ), new \IPS\nexus\Money( abs( $values[ 'gift_voucher_amount' ] ), $memberCurrency ) );
|
||||
$item->paymentMethodIds = array_keys( \IPS\nexus\Gateway::roots( NULL, NULL, array( 'm_active=1 AND m_gateway<>?', 'TwoCheckout' ) ) ); // It is against 2CO terms to use them for buying gift vouchers
|
||||
$item->extra[ 'method' ] = $values[ 'gift_voucher_method' ];
|
||||
$item->extra[ 'recipient_email' ] = $values[ 'gift_voucher_email' ];
|
||||
$item->extra[ 'recipient_name' ] = $values[ 'gift_voucher_recipient' ];
|
||||
$item->extra[ 'sender' ] = $values[ 'gift_voucher_sender' ];
|
||||
$item->extra[ 'message' ] = $values[ 'gift_voucher_message' ];
|
||||
$item->extra[ 'amount' ] = abs( $values[ 'gift_voucher_amount' ] );
|
||||
$item->extra[ 'color' ] = $values[ 'gift_voucher_color' ];
|
||||
$item->extra[ 'currency' ] = $memberCurrency;
|
||||
|
||||
$invoice = new \IPS\nexus\Invoice;
|
||||
$invoice->currency = $memberCurrency;
|
||||
$invoice->member = \IPS\Member::loggedIn();
|
||||
$invoice->addItem( $item );
|
||||
$invoice->save();
|
||||
|
||||
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$formTemplate = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'store', 'nexus' ) ), 'giftCardForm' ) );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->giftCard( $formTemplate );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('buy_gift_voucher');
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('buy_gift_voucher') );
|
||||
@@ -122,7 +131,7 @@ class _gifts extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function formatCurrency()
|
||||
{
|
||||
\IPS\Output::i()->json( (string) new \IPS\nexus\Money( \IPS\Request::i()->amount, ( isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() ) ) );
|
||||
\IPS\Output::i()->json( (string) new \IPS\nexus\Money( \IPS\Request::i()->amount, ( ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +165,7 @@ class _gifts extends \IPS\Dispatcher\Controller
|
||||
$currency = isset( $extra['currency'] ) ? $extra['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
|
||||
|
||||
$credits = \IPS\nexus\Customer::loggedIn()->cm_credits;
|
||||
$credits[ $currency ]->amount += $extra['amount'];
|
||||
$credits[ $currency ]->amount = $credits[ $currency ]->amount->add( new \IPS\Math\Number( number_format( $extra['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $currency ), '.', '' ) ) );
|
||||
\IPS\nexus\Customer::loggedIn()->cm_credits = $credits;
|
||||
\IPS\nexus\Customer::loggedIn()->save();
|
||||
|
||||
@@ -175,6 +184,7 @@ class _gifts extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'redemption_code' );
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief View product
|
||||
* @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 29 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -59,7 +59,7 @@ class _product extends \IPS\Content\Controller
|
||||
{
|
||||
$_SESSION['cart'] = array();
|
||||
}
|
||||
$memberCurrency = ( isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() );
|
||||
$memberCurrency = ( ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() );
|
||||
|
||||
/* Load Package */
|
||||
$item = parent::manage();
|
||||
@@ -68,21 +68,31 @@ class _product extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2X240/1', 404, '' );
|
||||
}
|
||||
$package = \IPS\nexus\Package::load( $item->id );
|
||||
|
||||
|
||||
/* Do we have any in the cart already (this will affect stock level)? */
|
||||
$inCart = 0;
|
||||
$inCart = array();
|
||||
foreach ( $_SESSION['cart'] as $itemInCart )
|
||||
{
|
||||
if ( $itemInCart->id === $package->id )
|
||||
{
|
||||
$inCart += $itemInCart->quantity;
|
||||
$optionValues = array();
|
||||
foreach( $package->optionIdKeys() as $id )
|
||||
{
|
||||
$optionValues[ $id ] = $itemInCart->details[$id];
|
||||
}
|
||||
$optionValues = json_encode( $optionValues );
|
||||
if ( !isset( $inCart[ $optionValues ] ) )
|
||||
{
|
||||
$inCart[ $optionValues ] = 0;
|
||||
}
|
||||
$inCart[ $optionValues ] += $itemInCart->quantity;
|
||||
}
|
||||
}
|
||||
|
||||
/* Showing just the form to purchase, or full product page? */
|
||||
if ( \IPS\Request::i()->purchase )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->purchaseForm( $package, $item, $this->_getForm( $package, $inCart, TRUE ), $inCart );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->purchaseForm( $package, $item, $this->_getForm( $package, $inCart, TRUE ) );
|
||||
}
|
||||
|
||||
/* No - show the full page */
|
||||
@@ -140,7 +150,7 @@ class _product extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
/* Easypost */
|
||||
if ( \IPS\Settings::i()->easypost_api_key and \IPS\Settings::i()->easypost_show_rates and ( $package->shipping == '*' or in_array( 'easypost', explode( ',', $package->shipping ) ) ) )
|
||||
if ( $shipAddress and \IPS\Settings::i()->easypost_api_key and \IPS\Settings::i()->easypost_show_rates and ( $package->shipping == '*' or in_array( 'easypost', explode( ',', $package->shipping ) ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -176,12 +186,20 @@ class _product extends \IPS\Content\Controller
|
||||
if ( count( $renewOptions ) === 1 )
|
||||
{
|
||||
$renewalTerm = array_pop( $renewOptions );
|
||||
$renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $renewalTerm['cost'][ $memberCurrency ]['amount'], $memberCurrency ), new \DateInterval( 'P' . $renewalTerm['term'] . mb_strtoupper( $renewalTerm['unit'] ) ), isset( $this->tax ) ? \IPS\nexus\Tax::load( $this->tax ) : NULL, $renewalTerm['add'] );
|
||||
$renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $renewalTerm['cost'][ $memberCurrency ]['amount'], $memberCurrency ), new \DateInterval( 'P' . $renewalTerm['term'] . mb_strtoupper( $renewalTerm['unit'] ) ), $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL, $renewalTerm['add'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->package( $package, $item, $this->_getForm( $package, $inCart, TRUE ), $inCart, $shippingMethods, $itemDataForShipping, $locationType, $renewalTerm );
|
||||
$formKey = "package_{$package->id}_submitted";
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->$formKey ) )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $this->_getForm( $package, $inCart, TRUE ), 500 );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->package( $package, $item, $this->_getForm( $package, $inCart, TRUE ), array_sum( $inCart ), $shippingMethods, $itemDataForShipping, $locationType, $renewalTerm );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,13 +207,13 @@ class _product extends \IPS\Content\Controller
|
||||
* Get form
|
||||
*
|
||||
* @param \IPS\nexus\Package $package The package
|
||||
* @param int $inCart The number in the cart already
|
||||
* @param array $inCart The number in the cart already for each of the field combinations
|
||||
* @return string
|
||||
*/
|
||||
protected function _getForm( \IPS\nexus\Package $package, $inCart, $verticalForm = FALSE )
|
||||
{
|
||||
/* Get member's currency */
|
||||
$memberCurrency = ( isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() );
|
||||
$memberCurrency = ( ( isset( $_SESSION['currency'] ) and in_array( $_SESSION['currency'], \IPS\nexus\Money::currencies() ) ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency() );
|
||||
|
||||
/* Init form */
|
||||
$form = new \IPS\Helpers\Form( "package_{$package->id}", 'add_to_cart' );
|
||||
@@ -209,7 +227,7 @@ class _product extends \IPS\Content\Controller
|
||||
$package->storeForm( $form, $memberCurrency );
|
||||
|
||||
/* Are we in stock? */
|
||||
if ( $package->stock != -1 and $package->stock != -2 and ( $package->stock - $inCart ) <= 0 )
|
||||
if ( $package->stock != -1 and $package->stock != -2 and ( $package->stock - array_sum( $inCart ) ) <= 0 )
|
||||
{
|
||||
$form->actionButtons = array();
|
||||
$form->addButton( 'out_of_stock', 'submit', NULL, 'ipsButton ipsButton_primary', array( 'disabled' => 'disabled' ) );
|
||||
@@ -245,9 +263,9 @@ class _product extends \IPS\Content\Controller
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots();
|
||||
$stickyFields = array();
|
||||
foreach ( $item->details as $k => $v )
|
||||
foreach ( $item->details as $j => $v )
|
||||
{
|
||||
if ( $v and isset( $customFields[ $k ] ) and $customFields[ $k ]->sticky )
|
||||
if ( $v and isset( $customFields[ $j ] ) and $customFields[ $j ]->sticky )
|
||||
{
|
||||
$stickyFields[] = $v;
|
||||
}
|
||||
@@ -317,24 +335,50 @@ class _product extends \IPS\Content\Controller
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( array( 'cf_purchase=1' ), array( \IPS\Db::i()->findInSet( 'cf_packages', array( $package->id ) ) ) ) );
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if( \IPS\Request::i()->isAjax() && isset( \IPS\Request::i()->stockCheck ) )
|
||||
{
|
||||
$field->required = FALSE; // Otherwise a required text field (for example) can block the price changing when a different radio (for example) value is selected
|
||||
}
|
||||
|
||||
$form->add( $field->buildHelper() );
|
||||
}
|
||||
|
||||
|
||||
/* Is this the validation for the additional page? */
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->additionalPageCheck ) )
|
||||
{
|
||||
if ( $additionalPage = $package->storeAdditionalPage( $_POST ) )
|
||||
{
|
||||
\IPS\Output::i()->httpHeaders['X-IPS-FormNoSubmit'] = "true";
|
||||
\IPS\Output::i()->json( $additionalPage );
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Custom fields */
|
||||
$details = array();
|
||||
foreach ( $values as $k => $v )
|
||||
$editorUploadIds = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( mb_substr( $k, 0, 13 ) == 'nexus_pfield_' )
|
||||
if ( isset( $values[ 'nexus_pfield_' . $field->id ] ) )
|
||||
{
|
||||
$class = \IPS\nexus\Package\CustomField::load( mb_substr( $k, 13 ) )->buildHelper();
|
||||
$details[ mb_substr( $k, 13 ) ] = $class::stringValue( $v );
|
||||
$class = $field->buildHelper();
|
||||
$details[ $field->id ] = $class::stringValue( $values[ 'nexus_pfield_' . $field->id ] );
|
||||
|
||||
if ( !isset( \IPS\Request::i()->stockCheck ) and $field->type === 'Editor' )
|
||||
{
|
||||
$uploadId = \IPS\Db::i()->insert( 'nexus_cart_uploads', array(
|
||||
'session_id' => \IPS\Session::i()->id,
|
||||
'time' => time()
|
||||
) );
|
||||
$field->claimAttachments( $uploadId, 'cart' );
|
||||
$editorUploadIds[] = $uploadId;
|
||||
}
|
||||
}
|
||||
}
|
||||
$optionValues = $package->optionValues( $details );
|
||||
|
||||
|
||||
/* Stock check */
|
||||
$quantity = isset( $values['quantity'] ) ? $values['quantity'] : 1;
|
||||
try
|
||||
@@ -345,7 +389,8 @@ class _product extends \IPS\Content\Controller
|
||||
{
|
||||
\IPS\Output::i()->error( 'product_options_price_error', '3X240/2', 500, 'product_options_price_error_admin' );
|
||||
}
|
||||
|
||||
$inCartForThisFieldCombination = isset( $inCart[ json_encode( $optionValues ) ] ) ? $inCart[ json_encode( $optionValues ) ] : 0;
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() && isset( \IPS\Request::i()->stockCheck ) )
|
||||
{
|
||||
/* Stock */
|
||||
@@ -357,10 +402,10 @@ class _product extends \IPS\Content\Controller
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
$return = array(
|
||||
'stock' => \IPS\Member::loggedIn()->language()->addToStack( 'x_in_stock', FALSE, array( 'pluralize' => array( $data['stock'] - $inCart ) ) ),
|
||||
'okay' => true
|
||||
'stock' => \IPS\Member::loggedIn()->language()->addToStack( 'x_in_stock', FALSE, array( 'pluralize' => array( $data['stock'] - $inCartForThisFieldCombination ) ) ),
|
||||
'okay' => ( $data['stock'] - $inCartForThisFieldCombination > 0 ) ? true : false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -376,11 +421,11 @@ class _product extends \IPS\Content\Controller
|
||||
|
||||
if ( $term['add'] )
|
||||
{
|
||||
$data['price']->amount += $term['cost'][ $memberCurrency ]['amount'];
|
||||
$normalPrice->amount += $term['cost'][ $memberCurrency ]['amount'];
|
||||
$data['price']->amount = $data['price']->amount->add( new \IPS\Math\Number( number_format( $term['cost'][ $memberCurrency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $memberCurrency ), '.', '' ) ) );
|
||||
$normalPrice->amount = $normalPrice->amount->add( new \IPS\Math\Number( number_format( $term['cost'][ $memberCurrency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $memberCurrency ), '.', '' ) ) );
|
||||
}
|
||||
|
||||
$return['renewal'] = \IPS\Member::loggedIn()->language()->addToStack( 'and_renewal', FALSE, array( 'sprintf' => array( new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $term['cost'][ $memberCurrency ]['amount'] + $_data['renewalAdjustment'], $memberCurrency ), new \DateInterval( 'P' . $term['term'] . mb_strtoupper( $term['unit'] ) ), isset( $this->tax ) ? \IPS\nexus\Tax::load( $this->tax ) : NULL, $term['add'] ) ) ) );
|
||||
$return['renewal'] = \IPS\Member::loggedIn()->language()->addToStack( 'and_renewal', FALSE, array( 'sprintf' => array( new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( ( new \IPS\Math\Number( number_format( $term['cost'][ $memberCurrency ]['amount'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $memberCurrency ), '.', '' ) ) )->add( ( new \IPS\Math\Number( number_format( $_data['renewalAdjustment'], \IPS\nexus\Money::numberOfDecimalsForCurrency( $memberCurrency ), '.', '' ) ) ) ), $memberCurrency ), new \DateInterval( 'P' . $term['term'] . mb_strtoupper( $term['unit'] ) ), $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL, $term['add'] ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -392,16 +437,16 @@ class _product extends \IPS\Content\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$taxRate = \IPS\nexus\Tax::load( $package->tax )->rate( \IPS\nexus\Customer::loggedIn()->estimatedLocation() );
|
||||
$taxRate = new \IPS\Math\Number( \IPS\nexus\Tax::load( $package->tax )->rate( \IPS\nexus\Customer::loggedIn()->estimatedLocation() ) );
|
||||
|
||||
$data['price']->amount += ( $data['price']->amount * $taxRate );
|
||||
$normalPrice->amount += ( $normalPrice->amount * $taxRate );
|
||||
$data['price']->amount = $data['price']->amount->add( $data['price']->amount->multiply( $taxRate ) );
|
||||
$normalPrice->amount = $normalPrice->amount->add( $normalPrice->amount->multiply( $taxRate ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Format and return */
|
||||
if ( $data['price']->amount != $normalPrice->amount )
|
||||
if ( $data['price']->amount->compare( $normalPrice->amount ) !== 0 )
|
||||
{
|
||||
$return['price'] = \IPS\Theme::i()->getTemplate( 'store', 'nexus' )->priceDiscounted( $normalPrice, $data['price'], FALSE );
|
||||
}
|
||||
@@ -411,11 +456,23 @@ class _product extends \IPS\Content\Controller
|
||||
}
|
||||
\IPS\Output::i()->json( $return );
|
||||
}
|
||||
elseif ( $data['stock'] != -1 and ( $data['stock'] - $inCart ) < $quantity )
|
||||
elseif ( $data['stock'] != -1 and ( $data['stock'] - $inCartForThisFieldCombination ) < $quantity )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'not_enough_in_stock', FALSE, array( 'sprintf' => array( $data['stock'] - $inCart ) ) );
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'not_enough_in_stock', FALSE, array( 'sprintf' => array( $data['stock'] - $inCartForThisFieldCombination ) ) );
|
||||
return (string) $form;
|
||||
}
|
||||
|
||||
if ( ( !isset( \IPS\Request::i()->additionalPageCheck ) or !\IPS\Request::i()->isAjax() ) and $additionalPage = $package->storeAdditionalPage( $_POST ) )
|
||||
{
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( $additionalPage );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $additionalPage;
|
||||
}
|
||||
}
|
||||
|
||||
/* Work out renewal term */
|
||||
$renewalTerm = NULL;
|
||||
@@ -430,7 +487,7 @@ class _product extends \IPS\Content\Controller
|
||||
$chosenRenewOption = $renewOptions[ $values['renewal_term'] ];
|
||||
}
|
||||
|
||||
$renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $chosenRenewOption['cost'][ $memberCurrency ]['amount'] + $data['renewalAdjustment'], $memberCurrency ), new \DateInterval( 'P' . $chosenRenewOption['term'] . mb_strtoupper( $chosenRenewOption['unit'] ) ), isset( $this->tax ) ? \IPS\nexus\Tax::load( $this->tax ) : NULL, $chosenRenewOption['add'], $package->grace_period ? new \DateInterval( 'P' . $package->grace_period . 'D' ) : NULL );
|
||||
$renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( ( new \IPS\Math\Number( number_format( $chosenRenewOption['cost'][ $memberCurrency ]['amount'], 2, '.', '' ) ) )->add( new \IPS\Math\Number( number_format( $data['renewalAdjustment'], 2, '.', '' ) ) ), $memberCurrency ), new \DateInterval( 'P' . $chosenRenewOption['term'] . mb_strtoupper( $chosenRenewOption['unit'] ) ), $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL, $chosenRenewOption['add'], $package->grace_period ? new \DateInterval( 'P' . $package->grace_period . 'D' ) : NULL );
|
||||
}
|
||||
|
||||
/* Associations */
|
||||
@@ -448,8 +505,9 @@ class _product extends \IPS\Content\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Blah */
|
||||
$package->addItemsToCartData( $details, $quantity, $renewalTerm, $parent, $values );
|
||||
/* Actually add to cart */
|
||||
$cartId = $package->addItemsToCartData( $details, $quantity, $renewalTerm, $parent, $values );
|
||||
\IPS\Db::i()->update( 'nexus_cart_uploads', array( 'item_id' => $cartId ), \IPS\Db::i()->in( 'id', $editorUploadIds ) );
|
||||
|
||||
/* Redirect or AJAX */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
@@ -458,7 +516,7 @@ class _product extends \IPS\Content\Controller
|
||||
$upsell = \IPS\nexus\Package\Item::getItemsWithPermission( array( array( 'p_upsell=1' ), array( \IPS\Db::i()->findInSet( 'p_associable', array( $package->id ) ) ) ), 'p_position' );
|
||||
|
||||
/* Send */
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate('store')->cartReview( $package, $quantity, $upsell ), 200, 'text/html' );
|
||||
\IPS\Output::i()->json( array( 'dialog' => \IPS\Theme::i()->getTemplate('store')->cartReview( $package, $quantity, $upsell ), 'cart' => \IPS\Theme::i()->getTemplate('store')->cartHeader() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Browse Store
|
||||
* @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 29 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -53,7 +53,7 @@ class _store extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Work out currenty */
|
||||
/* Work out currency */
|
||||
if ( isset( \IPS\Request::i()->currency ) and in_array( \IPS\Request::i()->currency, \IPS\nexus\Money::currencies() ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->csrfKey ) and \IPS\Request::i()->csrfKey === \IPS\Session\Front::i()->csrfKey )
|
||||
@@ -81,7 +81,7 @@ class _store extends \IPS\Dispatcher\Controller
|
||||
\IPS\Request::i()->cookie['storeView'] = ( \IPS\Request::i()->view == 'list' ) ? 'list' : 'grid';
|
||||
}
|
||||
|
||||
$subcategories = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_parent=?', $category->id ) ), 'IPS\nexus\Package\Group' );
|
||||
$subcategories = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_parent=?', $category->id ), 'pg_position ASC' ), 'IPS\nexus\Package\Group' );
|
||||
|
||||
$joins = array();
|
||||
switch ( \IPS\Request::i()->sortby )
|
||||
@@ -124,6 +124,11 @@ class _store extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$packages = new \IPS\Patterns\ActiveRecordIterator( $select, 'IPS\nexus\Package' );
|
||||
$totalCount = \IPS\Db::i()->select( 'count(*)', 'nexus_packages', array(
|
||||
array( 'p_group=?', $category->id ),
|
||||
array( 'p_store=1' ),
|
||||
array( "( p_member_groups='*' OR " . \IPS\Db::i()->findInSet( 'p_member_groups', \IPS\Member::loggedIn()->groups ) . ' )' )
|
||||
) )->first();
|
||||
|
||||
$totalPages = ceil( $packages->count( TRUE ) / static::$productsPerPage );
|
||||
if ( $totalPages and $currentPage > $totalPages )
|
||||
@@ -139,7 +144,7 @@ class _store extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate('store')->categorySidebar( $category, $subcategories );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->category( $category, $subcategories, $packages, $pagination, $packagesWithCustomFields );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->category( $category, $subcategories, $packages, $pagination, $packagesWithCustomFields, $totalCount );
|
||||
|
||||
foreach ( $category->parents() as $parent )
|
||||
{
|
||||
@@ -199,7 +204,7 @@ class _store extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->bodyClasses[] = 'ipsLayout_minimal';
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->register( \IPS\nexus\Package\Item::getItemsWithPermission( array( array( 'p_reg=1' ) ), 'p_date_added DESC' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('store')->register( \IPS\nexus\Package\Item::getItemsWithPermission( array( array( 'p_reg=1' ) ), 'pg_position, p_position', 10, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('sign_up');
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Support Index
|
||||
* @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 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -46,7 +46,7 @@ class _home extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$table = new \IPS\Helpers\Table\Content( 'IPS\nexus\Support\Request', \IPS\Http\Url::internal( 'app=nexus&module=support&controller=home', 'support' ) );
|
||||
$table = new \IPS\Helpers\Table\Content( 'IPS\nexus\Support\Request', \IPS\Http\Url::internal( 'app=nexus&module=support&controller=home', 'front', 'support' ) );
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'support' ), 'tableRows' );
|
||||
$table->classes[] = 'ipsDataList_large';
|
||||
$table->showFilters = FALSE;
|
||||
@@ -68,15 +68,15 @@ class _home extends \IPS\Dispatcher\Controller
|
||||
if ( count( $accounts ) and !isset( \IPS\Request::i()->account ) )
|
||||
{
|
||||
$options = array();
|
||||
$options[ \IPS\nexus\Customer::loggedIn()->member_id ] = \IPS\nexus\Customer::loggedIn()->language()->addToStack( 'my_account', FALSE, array( 'sprintf' => array( \IPS\nexus\Customer::loggedIn()->cm_name ) ) );
|
||||
foreach ( $accounts as $contact )
|
||||
{
|
||||
$options[ $contact->main_id->member_id ] = $contact->main_id->cm_name;
|
||||
}
|
||||
$options[ \IPS\nexus\Customer::loggedIn()->member_id ] = \IPS\nexus\Customer::loggedIn()->language()->addToStack( 'my_account', FALSE, array( 'sprintf' => array( \IPS\nexus\Customer::loggedIn()->cm_name ) ) );
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'account', 'continue' );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'support_account', NULL, TRUE, array( 'options' => $options, 'parse' => 'none' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'support_account', \IPS\nexus\Customer::loggedIn()->member_id, TRUE, array( 'options' => $options, 'parse' => 'none' ) ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=support&controller=home&do=create&account={$values['support_account']}", 'front', 'support_create' ) );
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Legacy Redirector
|
||||
* @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 Commerce
|
||||
* @since 07 Sep 2016
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\front\support;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy Redirector
|
||||
*/
|
||||
class _redirect extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Redirect
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "app=core&module=system&controller=redirect" )->setQueryString( array(
|
||||
'url' => \IPS\Request::i()->url,
|
||||
'resource' => ( \IPS\Request::i()->resource ) ? 1 : NULL,
|
||||
'key' => hash_hmac( "sha256", \IPS\Request::i()->url, \IPS\Settings::i()->site_secret_key ),
|
||||
) );
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Support Request View
|
||||
* @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 09 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -45,6 +45,11 @@ class _view extends \IPS\Content\Controller
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The current support request (instance of \IPS\nexus\Support\Request)
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* View Item
|
||||
*
|
||||
@@ -62,7 +67,9 @@ class _view extends \IPS\Content\Controller
|
||||
if ( isset( \IPS\Request::i()->setStatus ) and !empty( $allowedStatuses ) and in_array( \IPS\Request::i()->setStatus, array_keys( $allowedStatuses ) ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
$this->request->status = \IPS\nexus\Support\Status::load( \IPS\Request::i()->setStatus );
|
||||
$newStatus = \IPS\nexus\Support\Status::load( \IPS\Request::i()->setStatus );
|
||||
$this->request->log( 'status', $this->request->status, $newStatus );
|
||||
$this->request->status = $newStatus;
|
||||
$this->request->save();
|
||||
\IPS\Output::i()->redirect( $this->request->url() );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user