Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,43 +12,78 @@
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Invoice\Item\Renewal;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\nexus\Package\CustomField;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\nexus\Purchase\RenewalTerm;
|
||||
use IPS\nexus\Tax;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Theme;
|
||||
use LogicException;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
use const IPS\Helpers\Table\SEARCH_NUMERIC;
|
||||
use const IPS\Helpers\Table\SEARCH_SELECT;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purchases
|
||||
*/
|
||||
class _purchases extends \IPS\Dispatcher\Controller
|
||||
class purchases extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @var Purchase|null
|
||||
*/
|
||||
protected ?Purchase $purchase = null;
|
||||
|
||||
/**
|
||||
* View
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_view' );
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_view' );
|
||||
|
||||
try
|
||||
{
|
||||
$this->purchase = \IPS\nexus\Purchase::load( \IPS\Request::i()->id );
|
||||
$this->purchase = Purchase::load( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X195/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2X195/2', 404, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = $this->purchase->name . " (#{$this->purchase->id})";
|
||||
Output::i()->title = $this->purchase->name . " (#{$this->purchase->id})";
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'purchases.css', 'nexus', 'admin' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'purchases.css', 'nexus', 'admin' ) );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -57,7 +92,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$this->view();
|
||||
}
|
||||
@@ -67,20 +102,20 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function view()
|
||||
protected function view() : void
|
||||
{
|
||||
/* Popup view */
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->hovercard ) )
|
||||
if ( Request::i()->isAjax() and isset( Request::i()->hovercard ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->hovercard( $this->purchase );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'purchases' )->hovercard( $this->purchase );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create children tree */
|
||||
$children = \IPS\nexus\Purchase::tree( $this->purchase->acpUrl(), array(), "p{$this->purchase->id}", $this->purchase, FALSE );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
$children = Purchase::tree( $this->purchase->acpUrl(), array(), "p{$this->purchase->id}", $this->purchase, FALSE );
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $children;
|
||||
Output::i()->output = $children;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,12 +125,12 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $displayValue = trim( \IPS\nexus\Package\CustomField::load( $k )->displayValue( $v, TRUE ) ) )
|
||||
if ( $displayValue = trim( CustomField::load( $k )->displayValue( $v, TRUE ) ) )
|
||||
{
|
||||
$customFields[ $k ] = $displayValue;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
catch ( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* Get customer */
|
||||
@@ -103,15 +138,15 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$customer = $this->purchase->member;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
$customer = NULL;
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->sidebar['actions'] = $this->purchase->buttons();
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $customer, $children, $customFields );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_members.js', 'core' ) );
|
||||
Output::i()->sidebar['actions'] = $this->purchase->buttons();
|
||||
Output::i()->output = Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $customer, $children, $customFields );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_members.js', 'core' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,28 +155,28 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
* @note This is lazy loaded after the purchase page is generated
|
||||
* @return void
|
||||
*/
|
||||
protected function showInvoices()
|
||||
protected function showInvoices() : void
|
||||
{
|
||||
/* Create associated invoices table */
|
||||
try
|
||||
{
|
||||
$originalInvoice = $this->purchase->original_invoice;
|
||||
$invoices = \IPS\nexus\Invoice::table( array( array( 'i_id=? OR ' . \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ), $originalInvoice->id ) ), $this->purchase->acpUrl()->setQueryString( 'do', 'showInvoices' ), "p.{$this->purchase->id}" );
|
||||
$invoices = Invoice::table( array( array( 'i_id=? OR ' . Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ), $originalInvoice->id ) ), $this->purchase->acpUrl()->setQueryString( 'do', 'showInvoices' ), "p.{$this->purchase->id}" );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
$invoices = \IPS\nexus\Invoice::table( array( array( \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ) ) ), $this->purchase->acpUrl()->setQueryString( 'do', 'showInvoices' ), "p.{$this->purchase->id}" );
|
||||
$invoices = Invoice::table( array( array( Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ) ) ), $this->purchase->acpUrl()->setQueryString( 'do', 'showInvoices' ), "p.{$this->purchase->id}" );
|
||||
}
|
||||
$invoices->filters = array(
|
||||
'paid' => array( 'i_status=?', \IPS\nexus\Invoice::STATUS_PAID )
|
||||
'paid' => array( 'i_status=?', Invoice::STATUS_PAID )
|
||||
);
|
||||
$invoices->advancedSearch = array(
|
||||
'i_status' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => \IPS\nexus\Invoice::statuses(), 'multiple' => TRUE ) ),
|
||||
'i_total' => \IPS\Helpers\Table\SEARCH_NUMERIC,
|
||||
'i_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'i_status' => array( SEARCH_SELECT, array( 'options' => Invoice::statuses(), 'multiple' => TRUE ) ),
|
||||
'i_total' => SEARCH_NUMERIC,
|
||||
'i_date' => SEARCH_DATE_RANGE,
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = (string) $invoices;
|
||||
Output::i()->output = (string) $invoices;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,14 +184,14 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function edit()
|
||||
protected function edit() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
|
||||
/* Work stuff out */
|
||||
$renewals = $this->purchase->renewals ?: NULL;
|
||||
$groupedChildren = array();
|
||||
if ( $renewals and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_parent=? AND ps_grouped_renewals<>? AND ps_cancelled=0', $this->purchase->id, '' ) )->first() )
|
||||
if ( $renewals and Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_parent=? AND ps_grouped_renewals<>? AND ps_cancelled=0', $this->purchase->id, '' ) )->first() )
|
||||
{
|
||||
$renewals = $this->purchase->renewals;
|
||||
foreach ( $this->purchase->children() as $child )
|
||||
@@ -173,23 +208,23 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if( $this->purchase->tax )
|
||||
{
|
||||
$tax = \IPS\nexus\Tax::load( $this->purchase->tax );
|
||||
$tax = Tax::load( $this->purchase->tax );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
catch( OutOfRangeException ){}
|
||||
|
||||
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 );
|
||||
$childGroupedRenewalTerm = new RenewalTerm( new Money( $childGroupedRenewals['price'], $this->purchase->renewals->cost->currency ), new DateInterval( 'P' . $childGroupedRenewals['term'] . mb_strtoupper( $childGroupedRenewals['unit'] ) ), $tax );
|
||||
$renewals = new RenewalTerm( $renewals->subtract( $childGroupedRenewalTerm ), $renewals->interval );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
$this->purchase->acpEdit( $form, $renewals );
|
||||
|
||||
/* Handle submissions */
|
||||
@@ -218,7 +253,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,21 +261,21 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function transfer()
|
||||
protected function transfer() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_transfer' );
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_transfer' );
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/6', 403, '' );
|
||||
Output::i()->error( 'not_with_grouped', '2X195/6', 403, '' );
|
||||
}
|
||||
if ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/G', 403, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/G', 403, '' );
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'ps_member', NULL, TRUE ) );
|
||||
$form = new Form;
|
||||
$form->add( new Form\Member( 'ps_member', NULL, TRUE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
@@ -251,9 +286,9 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$this->purchase->transfer( $values['ps_member'] );
|
||||
}
|
||||
catch ( \DomainException $e )
|
||||
catch ( DomainException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), '2X195/8', 403 );
|
||||
Output::i()->error( $e->getMessage(), '2X195/8', 403 );
|
||||
}
|
||||
|
||||
/* Log */
|
||||
@@ -265,7 +300,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,39 +308,39 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function renew()
|
||||
public function renew() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'invoices_add', 'nexus', 'payments' );
|
||||
Dispatcher::i()->checkAcpPermission( 'invoices_add', 'nexus', 'payments' );
|
||||
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/7', 403, '' );
|
||||
Output::i()->error( 'not_with_grouped', '2X195/7', 403, '' );
|
||||
}
|
||||
if ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/D', 403, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/D', 403, '' );
|
||||
}
|
||||
|
||||
/* If this purchase has renewal term, we cannot generate a renewal invoice */
|
||||
if ( !$this->purchase->renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'purchase_no_renew', '2X195/3', 403, '' );
|
||||
Output::i()->error( 'purchase_no_renew', '2X195/3', 403, '' );
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
$cycles = $this->purchase->canRenewUntil( NULL, TRUE, TRUE );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'renew_cycles', 1, TRUE, array( 'min' => 1, 'max' => ( $cycles === TRUE ? NULL : $cycles ) ) ) );
|
||||
$form->add( new Number( 'renew_cycles', 1, TRUE, array( 'min' => 1, 'max' => ( $cycles === TRUE ? NULL : $cycles ) ) ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Generate Invoice */
|
||||
$invoice = new \IPS\nexus\Invoice;
|
||||
$invoice = new 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->addItem( Renewal::create( $this->purchase, $values['renew_cycles'] ) );
|
||||
$invoice->save();
|
||||
$invoice->sendNotification();
|
||||
|
||||
@@ -314,26 +349,26 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
$this->purchase->save();
|
||||
|
||||
/* Take us to that invoice */
|
||||
\IPS\Output::i()->redirect( $invoice->acpUrl() );
|
||||
Output::i()->redirect( $invoice->acpUrl() );
|
||||
}
|
||||
|
||||
/* If this purchase already has an unpaid renewal invoice, display a warning */
|
||||
if ( $this->purchase->invoice_pending )
|
||||
{
|
||||
/* Which will be a proper warning if that invoice is still pending */
|
||||
if ( $this->purchase->invoice_pending->status === \IPS\nexus\Invoice::STATUS_PENDING )
|
||||
if ( $this->purchase->invoice_pending->status === Invoice::STATUS_PENDING )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack('warn_renew_invoice_pending', FALSE, array( 'sprintf' => array( $this->purchase->invoice_pending->acpUrl() ) ) ), 'warning', NULL, FALSE, TRUE );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack('warn_renew_invoice_pending', FALSE, array( 'sprintf' => array( $this->purchase->invoice_pending->acpUrl() ) ) ), 'warning', NULL, FALSE, TRUE );
|
||||
}
|
||||
/* Or just informational if it is canceled or expired */
|
||||
elseif ( $this->purchase->invoice_pending->status !== \IPS\nexus\Invoice::STATUS_PAID )
|
||||
elseif ( $this->purchase->invoice_pending->status !== Invoice::STATUS_PAID )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack('info_renew_invoice_pending', FALSE, array( 'sprintf' => array( $this->purchase->invoice_pending->acpUrl() ) ) ), 'information', NULL, FALSE, TRUE );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack('info_renew_invoice_pending', FALSE, array( 'sprintf' => array( $this->purchase->invoice_pending->acpUrl() ) ) ), 'information', NULL, FALSE, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output .= $form;
|
||||
Output::i()->output .= $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,15 +376,15 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function cancel()
|
||||
protected function cancel() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
|
||||
$parent = $this->purchase->parent();
|
||||
|
||||
if ( ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled ) or ( $this->purchase->grouped_renewals and $parent->billing_agreement and !$parent->billing_agreement->canceled ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/H', 403, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/H', 403, '' );
|
||||
}
|
||||
|
||||
/* What options are available for cancelling? */
|
||||
@@ -361,15 +396,15 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
$options['cancel'] = 'cancel_type_cancel';
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'cancel_type', 'no_renew', FALSE, array(
|
||||
$form = new Form;
|
||||
$form->add( new Radio( 'cancel_type', 'no_renew', FALSE, array(
|
||||
'options' => $options,
|
||||
'toggles' => array( 'cancel' => array( 'form_cancel_type_warning' ) )
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ps_can_reactivate', FALSE ) );
|
||||
$form->add( new YesNo( 'ps_can_reactivate', FALSE ) );
|
||||
if ( $onCancelWarning = $this->purchase->onCancelWarning() )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['cancel_type_warning'] = $onCancelWarning;
|
||||
Member::loggedIn()->language()->words['cancel_type_warning'] = $onCancelWarning;
|
||||
}
|
||||
|
||||
/* Handle submissions */
|
||||
@@ -409,7 +444,7 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Display form */
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,22 +452,22 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reactivate()
|
||||
protected function reactivate() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$error = NULL;
|
||||
if ( !$this->purchase->canAcpReactivate( $error ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $error ?? 'can_not_reactivate', '2X195/K', 403, '' );
|
||||
Output::i()->error( $error ?? 'can_not_reactivate', '2X195/K', 403, '' );
|
||||
}
|
||||
|
||||
$parent = $this->purchase->parent();
|
||||
|
||||
if ( ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled ) or ( $this->purchase->grouped_renewals and $parent->billing_agreement and !$parent->billing_agreement->canceled ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/I', 403, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/I', 403, '' );
|
||||
}
|
||||
|
||||
/* If grouped, ungroup */
|
||||
@@ -464,16 +499,16 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
protected function delete() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_delete' );
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_delete' );
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
$parent = $this->purchase->parent();
|
||||
|
||||
if ( ( $this->purchase->billing_agreement and !$this->purchase->billing_agreement->canceled ) or ( $this->purchase->grouped_renewals and $parent->billing_agreement and !$parent->billing_agreement->canceled ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_billing_agreement', '2X195/J', 403, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/J', 403, '' );
|
||||
}
|
||||
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
@@ -487,11 +522,11 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $parent )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $parent->acpUrl() );
|
||||
Output::i()->redirect( $parent->acpUrl() );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,15 +535,15 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function extra()
|
||||
protected function extra() : void
|
||||
{
|
||||
if ( $output = $this->purchase->acpAction() )
|
||||
{
|
||||
\IPS\Output::i()->output = $output;
|
||||
Output::i()->output = $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,14 +552,14 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function group()
|
||||
protected function group() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
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, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/E', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
@@ -532,9 +567,9 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
$this->purchase->groupWithParent();
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'group', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
catch ( LogicException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'grouperr_' . $e->getMessage(), '1X195/4', 403, '' );
|
||||
Output::i()->error( 'grouperr_' . $e->getMessage(), '1X195/4', 403, '' );
|
||||
}
|
||||
$this->_redirect();
|
||||
}
|
||||
@@ -544,14 +579,14 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function ungroup()
|
||||
protected function ungroup() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
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, '' );
|
||||
Output::i()->error( 'not_with_billing_agreement', '2X195/F', 403, '' );
|
||||
}
|
||||
|
||||
try
|
||||
@@ -559,9 +594,9 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
$this->purchase->ungroupFromParent();
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'ungroup', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
catch ( LogicException )
|
||||
{
|
||||
\IPS\Output::i()->error( '', '1X195/5', 403, '' );
|
||||
Output::i()->error( '', '1X195/5', 403, '' );
|
||||
}
|
||||
$this->_redirect();
|
||||
}
|
||||
@@ -571,37 +606,33 @@ class _purchases extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _redirect()
|
||||
protected function _redirect() : void
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->r ) )
|
||||
if ( isset( Request::i()->r ) )
|
||||
{
|
||||
switch ( mb_substr( \IPS\Request::i()->r, 0, 1 ) )
|
||||
switch ( mb_substr( Request::i()->r, 0, 1 ) )
|
||||
{
|
||||
case 'p':
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\nexus\Purchase::load( $this->purchase->parent )->acpUrl() );
|
||||
Output::i()->redirect( Purchase::load( $this->purchase->parent )->acpUrl() );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
\IPS\Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
break;
|
||||
|
||||
case 's':
|
||||
\IPS\Output::i()->redirect( \IPS\nexus\Support\Request::load( mb_substr( \IPS\Request::i()->r, 2 ) )->acpUrl() );
|
||||
Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user