Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Invoice\Item;
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Invoice;
|
||||
|
||||
/* 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;
|
||||
@@ -137,7 +137,7 @@ abstract class _Item
|
||||
* @brief Group With Parent
|
||||
*/
|
||||
public $groupWithParent = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -181,7 +181,7 @@ abstract class _Item
|
||||
*/
|
||||
public function taxRate( \IPS\GeoLocation $location = NULL )
|
||||
{
|
||||
return new \IPS\Math\Number( $this->tax ? $this->tax->rate( $location ?: $this->billaddress ) : '0' );
|
||||
return new \IPS\Math\Number( $this->tax ? $this->tax->rate( $location ) : '0' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,7 +338,7 @@ abstract class _Item
|
||||
*/
|
||||
public function requiresBillingAddress()
|
||||
{
|
||||
return in_array( 'other', explode( ',', \IPS\Settings::i()->nexus_require_billing ) );
|
||||
return \in_array( 'other', explode( ',', \IPS\Settings::i()->nexus_require_billing ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,8 +388,8 @@ abstract class _Item
|
||||
* @apiresponse int parentItem If when the item has been purchased it will be a child of another item on the same invoice, the ID number of the item that will be the parent
|
||||
* @apiresponse bool groupWithParent If when the item has been purchased it will have its renewals grouped with its parent
|
||||
* @apiresponse \IPS\nexus\Customer payTo If the payment for this item goes to another user (for example for Downloads files), the user who will receive the payment
|
||||
* @apiresonse float commission If the payment for this item goes to another user (for example for Downloads files), the percentage of the price that will be retained by the site (in addition to fee)
|
||||
* @apiresonse \IPS\nexus\Money fee If the payment for this item goes to another user (for example for Downloads files), the fee that will be deducted by the site (in addition to commission)
|
||||
* @apiresponse float commission If the payment for this item goes to another user (for example for Downloads files), the percentage of the price that will be retained by the site (in addition to fee)
|
||||
* @apiresponse \IPS\nexus\Money fee If the payment for this item goes to another user (for example for Downloads files), the fee that will be deducted by the site (in addition to commission)
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
@@ -413,7 +413,7 @@ abstract class _Item
|
||||
'expireDate' => isset( $this->expireDate ) ? $this->expireDate->rfc3339() : null,
|
||||
'details' => $this->details,
|
||||
'parentPurchase' => ( isset( $this->parent ) and $this->parent instanceof \IPS\nexus\Purchase ) ? $this->parent->apiOutput( $authorizedMember ) : null,
|
||||
'parentItem' => ( isset( $this->parent ) and is_int( $this->parent ) ) ? $this->parent : null,
|
||||
'parentItem' => ( isset( $this->parent ) and \is_int( $this->parent ) ) ? $this->parent : null,
|
||||
'groupWithParent' => isset( $this->groupWithParent ) ? $this->groupWithParent : false,
|
||||
'payTo' => $this->payTo ? $this->payTo->apiOutput( $authorizedMember ) : null,
|
||||
'commission' => $this->commission,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Invoice\Item;
|
||||
|
||||
/* 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;
|
||||
@@ -33,6 +33,11 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
*/
|
||||
public static $requiresAccount = TRUE;
|
||||
|
||||
/**
|
||||
* @brief \DateInterval Length granted by initial purchase before normal renewal term starts (or NULL to match renewal term)
|
||||
*/
|
||||
public $initialInterval;
|
||||
|
||||
/**
|
||||
* @brief \IPS\nexus\Purchase\RenewalTerm Renewal Term
|
||||
*/
|
||||
@@ -100,7 +105,7 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
$where = array( array( 'ps_app=? AND ps_type=? AND ps_member=?', static::$application, static::$type, $customer->member_id ) );
|
||||
if ( $id !== NULL )
|
||||
{
|
||||
if ( is_array( $id ) )
|
||||
if ( \is_array( $id ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'ps_item_id', $id ) );
|
||||
}
|
||||
@@ -186,7 +191,7 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
if ( !$purchase->billing_agreement or $purchase->billing_agreement->canceled )
|
||||
{
|
||||
$form->add( new \IPS\nexus\Form\RenewalTerm( 'ps_renewals', $renewals, FALSE, array( 'lockTerm' => !$purchase->canChangeExpireDate() ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'ps_grace_period', $purchase->grace_period / 86400, FALSE, array( 'max' => \IPS\Settings::i()->cm_invoice_expireafter ?: NULL ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days') ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'ps_grace_period', $purchase->grace_period / 86400, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'max' => \IPS\Settings::i()->cm_invoice_expireafter ?: NULL, 'min' => NULL ), NULL, NULL, NULL ) );
|
||||
}
|
||||
|
||||
if ( !$purchase->grouped_renewals )
|
||||
@@ -205,6 +210,25 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
public static function acpEditSave( \IPS\nexus\Purchase $purchase, array $values )
|
||||
{
|
||||
$purchase->name = $values['ps_name'];
|
||||
|
||||
/* Figure out tax for renewals */
|
||||
$tax = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
if( $purchase->tax )
|
||||
{
|
||||
$tax = \IPS\nexus\Tax::load( $purchase->tax );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
|
||||
if( $tax AND $values['ps_renewals'] )
|
||||
{
|
||||
$values['ps_renewals']->tax = $tax;
|
||||
}
|
||||
|
||||
/* Then save */
|
||||
if ( $purchase->grouped_renewals )
|
||||
{
|
||||
$purchase->ungroupFromParent();
|
||||
@@ -439,7 +463,7 @@ abstract class _Purchase extends \IPS\nexus\Invoice\Item
|
||||
*/
|
||||
public function requiresBillingAddress()
|
||||
{
|
||||
return in_array( 'product', explode( ',', \IPS\Settings::i()->nexus_require_billing ) );
|
||||
return \in_array( 'product', explode( ',', \IPS\Settings::i()->nexus_require_billing ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Invoice\Item;
|
||||
|
||||
/* 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;
|
||||
@@ -178,12 +178,7 @@ class _Renewal extends \IPS\nexus\Invoice\Item
|
||||
$expire->sub( $interval );
|
||||
}
|
||||
$purchase->expire = $expire;
|
||||
|
||||
if ( $status === \IPS\nexus\Invoice::STATUS_PENDING )
|
||||
{
|
||||
$purchase->invoice_pending = $invoice;
|
||||
}
|
||||
|
||||
$purchase->invoice_pending = $invoice;
|
||||
$purchase->save();
|
||||
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $purchase->id, 'name' => $purchase->name, 'invoice_id' => $invoice->id, 'invoice_title' => $invoice->title, 'system' => TRUE ) );
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\Invoice\Item;
|
||||
|
||||
/* 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;
|
||||
|
||||
Reference in new issue
Block a user