Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Comission Rules
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 15 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comission Rules
|
||||
*/
|
||||
class _commissionrules extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\CommissionRule';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'commission_rules_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'commission_rules_blurb', TRUE, TRUE );
|
||||
return parent::manage();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _fields extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* View
|
||||
*
|
||||
@@ -152,9 +157,22 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$groupedChildren[] = $child;
|
||||
$childGroupedRenewals = $child->grouped_renewals;
|
||||
|
||||
/* Figure out tax */
|
||||
$tax = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
$childGroupedRenewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $childGroupedRenewals['price'], $this->purchase->renewals->cost->currency ), new \DateInterval( 'P' . $childGroupedRenewals['term'] . mb_strtoupper( $childGroupedRenewals['unit'] ) ) );
|
||||
if( $this->purchase->tax )
|
||||
{
|
||||
$tax = \IPS\nexus\Tax::load( $this->purchase->tax );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
|
||||
try
|
||||
{
|
||||
$childGroupedRenewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $childGroupedRenewals['price'], $this->purchase->renewals->cost->currency ), new \DateInterval( 'P' . $childGroupedRenewals['term'] . mb_strtoupper( $childGroupedRenewals['unit'] ) ), $tax );
|
||||
$renewals = new \IPS\nexus\Purchase\RenewalTerm( $renewals->subtract( $childGroupedRenewalTerm ), $renewals->interval );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
@@ -278,6 +296,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
$invoice = new \IPS\nexus\Invoice;
|
||||
$invoice->currency = $this->purchase->renewal_currency;
|
||||
$invoice->member = $this->purchase->member;
|
||||
$invoice->billaddress = $this->purchase->member->primaryBillingAddress();
|
||||
$invoice->addItem( \IPS\nexus\Invoice\Item\Renewal::create( $this->purchase, $values['renew_cycles'] ) );
|
||||
$invoice->save();
|
||||
$invoice->sendNotification();
|
||||
@@ -393,6 +412,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
protected function reactivate()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$parent = $this->purchase->parent();
|
||||
|
||||
@@ -486,6 +506,8 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
protected function group()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
if ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/E', 403, '' );
|
||||
@@ -511,6 +533,8 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
protected function ungroup()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
if ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/F', 403, '' );
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief referralbanners
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 18 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* referralbanners
|
||||
*/
|
||||
class _referralbanners extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\ReferralBanner';
|
||||
|
||||
/**
|
||||
* Title can contain HTML?
|
||||
*/
|
||||
public $_titleHtml = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'referralbanners_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'referral_banners_blurb', TRUE, TRUE );
|
||||
return parent::manage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
parent::form();
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('referral_banners');
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Referrals
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 15 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referrals
|
||||
*/
|
||||
class _referrals extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Call
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __call( $method, $args )
|
||||
{
|
||||
$tabs = array();
|
||||
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'referrals_manage' ) )
|
||||
{
|
||||
$tabs['refersettings'] = 'settings';
|
||||
}
|
||||
if( \IPS\Settings::i()->cm_ref_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'referrals_commission_rules' ) )
|
||||
{
|
||||
$tabs['commissionrules'] = 'commission_rules';
|
||||
}
|
||||
if( \IPS\Settings::i()->cm_ref_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'referrals_banners' ) )
|
||||
{
|
||||
$tabs['referralbanners'] = 'referral_banners';
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->tab ) and isset( $tabs[ \IPS\Request::i()->tab ] ) )
|
||||
{
|
||||
$activeTab = \IPS\Request::i()->tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_tabs = array_keys( $tabs ) ;
|
||||
$activeTab = array_shift( $_tabs );
|
||||
}
|
||||
|
||||
$classname = 'IPS\nexus\modules\admin\customers\\' . $activeTab;
|
||||
$class = new $classname;
|
||||
$class->url = \IPS\Http\Url::internal("app=nexus&module=customers&controller=referrals&tab={$activeTab}");
|
||||
$class->execute();
|
||||
|
||||
if ( $method !== 'manage' or \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_customers_referrals');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, \IPS\Output::i()->output, \IPS\Http\Url::internal( "app=nexus&module=customers&controller=referrals" ) );
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Referral Settings
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 15 Aug 2014
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referral Settings
|
||||
*/
|
||||
class _refersettings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$tabsKey = md5( \IPS\Http\Url::internal("app=nexus&module=customers&controller=referrals") );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'cm_ref_on', \IPS\Settings::i()->cm_ref_on, FALSE, array( 'togglesOn' => array( 'nexus_com_rules' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_com_rules', \IPS\Settings::i()->nexus_com_rules, FALSE, array( 'togglesOff' => array( 'nexus_com_rules_alt' ) ), NULL, NULL, NULL, 'nexus_com_rules' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'nexus_com_rules_alt', NULL, FALSE, array( 'app' => 'nexus', 'key' => 'nexus_com_rules_val', 'editor' => array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'nexus_com_rules_alt', 'attachIds' => array( NULL, NULL, 'nexus_com_rules_alt' ) ) ), NULL, NULL, NULL, 'nexus_com_rules_alt' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'nexus', 'nexus_com_rules_val', $values['nexus_com_rules_alt'] );
|
||||
unset( $values['nexus_com_rules_alt'] );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=customers&controller=referrals') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -52,7 +57,7 @@ class _search extends \IPS\Dispatcher\Controller
|
||||
array(
|
||||
'select' => 'address',
|
||||
'from' => 'nexus_customer_addresses',
|
||||
'where' => 'nexus_customer_addresses.member=nexus_customers.member_id AND primary_billing=1'
|
||||
'where' => 'nexus_customer_addresses.`member`=nexus_customers.member_id AND primary_billing=1'
|
||||
)
|
||||
);
|
||||
$table->include = array( 'photo', 'name', 'cm_last_name', 'cm_first_name', 'email', 'address' );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _view extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Member
|
||||
*/
|
||||
@@ -82,12 +87,13 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function addresses()
|
||||
{
|
||||
$addresses = new \IPS\Helpers\Table\Db( 'nexus_customer_addresses', \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'view', 'addresses' ), array( 'member=?', $this->member->member_id ) );
|
||||
$addresses = new \IPS\Helpers\Table\Db( 'nexus_customer_addresses', \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'view', 'addresses' ), array( '`member`=?', $this->member->member_id ) );
|
||||
$addresses->sortBy = 'primary_billing, primary_shipping, added';
|
||||
$addresses->include = array( 'address', 'primary_billing', 'primary_shipping' );
|
||||
$addresses->parsers = array( 'address' => function( $val )
|
||||
{
|
||||
return \IPS\GeoLocation::buildFromJson( $val )->toString( '<br>' );
|
||||
$address = \IPS\GeoLocation::buildFromJson( $val );
|
||||
return $address->toString( '<br>' ) . ( ( isset( $address->business ) and $address->business and isset( $address->vat ) and $address->vat ) ? ( '<br>' . \IPS\Member::loggedIn()->language()->addToStack('cm_checkout_vat_number') . ': ' .\IPS\Theme::i()->getTemplate( 'global', 'nexus' )->vatNumber( $address->vat ) ) : '' );
|
||||
} );
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_edit_details' ) )
|
||||
{
|
||||
@@ -122,23 +128,6 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$addresses->rowsTemplate = array( \IPS\Theme::i()->getTemplate('customers'), 'addressTableRows' );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('customers')->customerPopup( $addresses );
|
||||
}
|
||||
|
||||
/**
|
||||
* View Purchase List
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function purchaseList()
|
||||
{
|
||||
$purchases = \IPS\nexus\Purchase::tree( \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( 'do', 'purchaseList' ), array( array( 'ps_member=?', $this->member->member_id ) ) );
|
||||
$purchases->rootsPerPage = 25;
|
||||
$purchases->getTotalRoots = function()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_parent=0', $this->member->member_id ) )->first();
|
||||
};
|
||||
\IPS\Output::i()->output = $purchases;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'members_purchases', FALSE, array( 'sprintf' => array( $this->member->cm_name ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Customer Fields
|
||||
@@ -157,6 +146,10 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
|
||||
{
|
||||
$column = $field->column;
|
||||
if ( $field->type === 'Editor' )
|
||||
{
|
||||
$field::$editorOptions = array_merge( $field::$editorOptions, array( 'attachIds' => array( $this->member->member_id ) ) );
|
||||
}
|
||||
$form->add( $field->buildHelper( $this->member->$column ) );
|
||||
}
|
||||
|
||||
@@ -249,7 +242,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
if ( \IPS\Request::i()->note_id )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'customer_notes_edit' );
|
||||
$noteId = intval( \IPS\Request::i()->note_id );
|
||||
$noteId = \intval( \IPS\Request::i()->note_id );
|
||||
try
|
||||
{
|
||||
$note = \IPS\Db::i()->select( 'note_text', 'nexus_notes', array( 'note_id=?', \IPS\Request::i()->note_id ) )->first();
|
||||
@@ -363,12 +356,28 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$address = new \IPS\nexus\Customer\Address;
|
||||
$address->member = $this->member;
|
||||
$address->primary_billing = ( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( 'member=? AND primary_billing=1', $this->member->member_id ) )->first() == 0 );
|
||||
$address->primary_shipping = ( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( 'member=? AND primary_shipping=1', $this->member->member_id ) )->first() == 0 );
|
||||
$address->primary_billing = ( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( '`member`=? AND primary_billing=1', $this->member->member_id ) )->first() == 0 );
|
||||
$address->primary_shipping = ( \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_addresses', array( '`member`=? AND primary_shipping=1', $this->member->member_id ) )->first() == 0 );
|
||||
}
|
||||
|
||||
$needTaxStatus = NULL;
|
||||
foreach ( \IPS\nexus\Tax::roots() as $tax )
|
||||
{
|
||||
if ( $tax->type === 'eu' )
|
||||
{
|
||||
$needTaxStatus = 'eu';
|
||||
break;
|
||||
}
|
||||
if ( $tax->type === 'business' )
|
||||
{
|
||||
$needTaxStatus = 'business';
|
||||
}
|
||||
}
|
||||
$addressHelperClass = $needTaxStatus ? 'IPS\nexus\Form\BusinessAddress' : 'IPS\Helpers\Form\Address';
|
||||
$addressHelperOptions = ( $needTaxStatus === 'eu' ) ? array( 'vat' => TRUE ) : array();
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'address', $address->address, TRUE ) );
|
||||
$form->add( new $addressHelperClass( 'address', $address->address, TRUE, $addressHelperOptions ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'primary_billing', $address->primary_billing ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'primary_shipping', $address->primary_shipping ) );
|
||||
if ( $values = $form->values() )
|
||||
@@ -381,12 +390,12 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
if ( $values['primary_billing'] and !$address->primary_billing )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'primary_billing' => 0 ), array( 'member=?', $this->member->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'primary_billing' => 0 ), array( '`member`=?', $this->member->member_id ) );
|
||||
$this->member->log( 'address', array( 'type' => 'primary_billing', 'details' => json_encode( $values['address'] ) ) );
|
||||
}
|
||||
if ( $values['primary_shipping'] and !$address->primary_shipping )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'primary_shipping' => 0 ), array( 'member=?', $this->member->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'primary_shipping' => 0 ), array( '`member`=?', $this->member->member_id ) );
|
||||
$this->member->log( 'address', array( 'type' => 'primary_shipping', 'details' => json_encode( $values['address'] ) ) );
|
||||
}
|
||||
}
|
||||
@@ -430,12 +439,13 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Add Card
|
||||
*
|
||||
* @csrfChecked Uses Form helper in Gateway classes 7 Oct 2019
|
||||
* @return void
|
||||
*/
|
||||
public function addCard()
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_gateways.js', 'nexus', 'global' ) );
|
||||
$form = \IPS\nexus\Customer\CreditCard::create( $this->member );
|
||||
$form = \IPS\nexus\Customer\CreditCard::create( $this->member, TRUE );
|
||||
if ( $form instanceof \IPS\nexus\Customer\CreditCard )
|
||||
{
|
||||
$this->member->log( 'card', array( 'type' => 'add', 'number' => $form->card->lastFour ) );
|
||||
@@ -444,8 +454,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,7 +497,13 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$form = new \IPS\Helpers\Form;
|
||||
if ( !$existing )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'altcontact_member_admin', NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'altcontact_member_admin', NULL, TRUE, array(), function( $val )
|
||||
{
|
||||
if( $this->member->member_id === $val->member_id )
|
||||
{
|
||||
throw new \DomainException('altcontact_member_admin_self');
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'altcontact_purchases_admin', $existing ? iterator_to_array( $existing->purchases ) : NULL, FALSE, array( 'class' => 'IPS\nexus\Purchase', 'forceOwner' => $this->member, 'multiple' => TRUE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'altcontact_support_admin', $existing ? $existing->support : FALSE ) );
|
||||
@@ -548,6 +563,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( isset( \IPS\Request::i()->process ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
$values = array(
|
||||
'void_refund_transactions' => \IPS\Request::i()->trans,
|
||||
'void_cancel_billing_agreements' => \IPS\Request::i()->ba,
|
||||
@@ -617,14 +633,14 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
$member = $this->member;
|
||||
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$this->member->member_id}")->setQueryString( array(
|
||||
'do' => 'void',
|
||||
'do' => 'void',
|
||||
'process' => 1,
|
||||
'trans' => $values['void_refund_transactions'],
|
||||
'ba' => isset( $values['void_cancel_billing_agreements'] ) ? $values['void_cancel_billing_agreements'] : FALSE ,
|
||||
'purch' => $values['void_cancel_purchases'],
|
||||
) ), function( $data ) use ( $member )
|
||||
) )->csrf(), function( $data ) use ( $member )
|
||||
{
|
||||
if ( !is_array( $data ) )
|
||||
if ( !\is_array( $data ) )
|
||||
{
|
||||
$data = array( 'trans' => 0, 'ba' => 0, 'purch' => 0, 'fail' => array() );
|
||||
}
|
||||
@@ -635,16 +651,16 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_transactions', array( 't_member=?', $member->member_id ), 't_id', array( $data['trans'], 10 ) ), 'IPS\nexus\Transaction' ) as $transaction )
|
||||
{
|
||||
if ( in_array( $transaction->status, array( $transaction::STATUS_PENDING, $transaction::STATUS_WAITING, $transaction::STATUS_GATEWAY_PENDING ) ) )
|
||||
if ( \in_array( $transaction->status, array( $transaction::STATUS_PENDING, $transaction::STATUS_WAITING, $transaction::STATUS_GATEWAY_PENDING ) ) )
|
||||
{
|
||||
$transaction->status = $transaction::STATUS_REVIEW;
|
||||
$transaction->save();
|
||||
}
|
||||
elseif ( in_array( $transaction->status, array( $transaction::STATUS_PAID, $transaction::STATUS_HELD, $transaction::STATUS_REVIEW, $transaction::STATUS_PART_REFUNDED ) ) )
|
||||
elseif ( \in_array( $transaction->status, array( $transaction::STATUS_PAID, $transaction::STATUS_HELD, $transaction::STATUS_REVIEW, $transaction::STATUS_PART_REFUNDED ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $this->auth and in_array( $this->status, array( static::STATUS_HELD, static::STATUS_REVIEW ) ) )
|
||||
if ( $this->auth and \in_array( $this->status, array( static::STATUS_HELD, static::STATUS_REVIEW ) ) )
|
||||
{
|
||||
$transaction->void();
|
||||
}
|
||||
@@ -710,7 +726,7 @@ class _view extends \IPS\Dispatcher\Controller
|
||||
return NULL;
|
||||
}, function() use ( $member )
|
||||
{
|
||||
if ( count( $_SESSION['voidAccountFails'] ) )
|
||||
if ( \count( $_SESSION['voidAccountFails'] ) )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $member->acpUrl()->setQueryString( 'do', 'voidFails' ) );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user