Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
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;
@@ -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 ) );
}
/**