Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+35 -29
View File
@@ -98,22 +98,22 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
$table->parsers = array(
'i_status' => function( $val )
{
return \IPS\Theme::i()->getTemplate('invoices')->status( $val );
return \IPS\Theme::i()->getTemplate( 'invoices', 'nexus' )->status( $val );
},
'i_member' => function ( $val, $row )
{
if ( $val )
{
return \IPS\Theme::i()->getTemplate('global')->userLink( \IPS\Member::load( $val ) );
return \IPS\Theme::i()->getTemplate( 'global', 'nexus' )->userLink( \IPS\Member::load( $val ) );
}
elseif ( $row['i_guest_data'] )
{
$data = json_decode( $row['i_guest_data'], TRUE );
return \IPS\nexus\Customer::constructFromData( $data['member'] )->cm_name;
return htmlspecialchars( \IPS\nexus\Customer::constructFromData( $data['member'] )->cm_name, ENT_DISALLOWED, 'UTF-8', FALSE );
}
else
{
return \IPS\Theme::i()->getTemplate('global')->userLink( \IPS\Member::load( 0 ) );
return \IPS\Theme::i()->getTemplate( 'global', 'nexus' )->userLink( \IPS\Member::load( 0 ) );
}
},
'i_total' => function( $val, $row )
@@ -1408,6 +1408,7 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
/**
* Get output for API
*
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
* @return array
* @apiresponse int id ID number
* @apiresponse string title Title
@@ -1433,14 +1434,14 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
* @apiresponse string viewUrl The URL to where the customer can view this invoice
* @apiresponse string checkoutUrl The URL to where the customer can pay this invoice
*/
public function apiOutput()
public function apiOutput( \IPS\Member $authorizedMember = NULL )
{
$summary = $this->summary();
$tax = array();
foreach ( $summary['tax'] as $classId => $data )
{
$tax[] = ( new \IPS\nexus\Invoice\Item\TaxItem( $classId, $data ) )->apiOutput();
$tax[] = ( new \IPS\nexus\Invoice\Item\TaxItem( $classId, $data ) )->apiOutput( $authorizedMember );
}
return array(
@@ -1449,31 +1450,31 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
'status' => $this->status,
'issueDate' => $this->date->rfc3339(),
'paidDate' => $this->paid ? $this->paid->rfc3339() : null,
'customer' => $this->member->apiOutput(),
'items' => array_map( function( $item ){
return $item->apiOutput();
'customer' => $this->member->apiOutput( $authorizedMember ),
'items' => array_map( function( $item ) use ( $authorizedMember ) {
return $item->apiOutput( $authorizedMember );
}, $summary['items'] ),
'subTotal' => $summary['subtotal']->apiOutput(),
'shippingCharges' => array_map( function( $item ){
return $item->apiOutput();
'subTotal' => $summary['subtotal']->apiOutput( $authorizedMember ),
'shippingCharges' => array_map( function( $item ) use ( $authorizedMember ) {
return $item->apiOutput( $authorizedMember );
}, $summary['shipping'] ),
'shippingTotal' => $summary['shippingTotal']->apiOutput(),
'shippingTotal' => $summary['shippingTotal']->apiOutput( $authorizedMember ),
'tax' => $tax,
'taxTotal' => $summary['taxTotal']->apiOutput(),
'total' => $summary['total']->apiOutput(),
'outstanding' => $this->amountToPay()->apiOutput(),
'billingAddress' => $this->billaddress ? $this->billaddress->apiOutput() : null,
'shippingAddress' => $this->shipaddress ? $this->shipaddress->apiOutput() : null,
'taxTotal' => $summary['taxTotal']->apiOutput( $authorizedMember ),
'total' => $summary['total']->apiOutput( $authorizedMember ),
'outstanding' => $this->amountToPay()->apiOutput( $authorizedMember ),
'billingAddress' => $this->billaddress ? $this->billaddress->apiOutput( $authorizedMember ) : null,
'shippingAddress' => $this->shipaddress ? $this->shipaddress->apiOutput( $authorizedMember ) : null,
'poNumber' => $this->po,
'notes' => $this->notes,
'transactions' => array_map( function( $transaction ){
return $transaction->apiOutput();
'transactions' => array_map( function( $transaction ) use ( $authorizedMember ) {
return $transaction->apiOutput( $authorizedMember );
}, iterator_to_array( $this->transactions() ) ),
'shipments' => array_map( function( $shipment ){
return $shipment->apiOutput();
'shipments' => array_map( function( $shipment ) use ( $authorizedMember ) {
return $shipment->apiOutput( $authorizedMember );
}, iterator_to_array( $this->shipments() ) ),
'purchases' => array_map( function( $purchase ){
return $purchase->apiOutput();
'purchases' => array_map( function( $purchase ) use ( $authorizedMember ) {
return $purchase->apiOutput( $authorizedMember );
}, iterator_to_array( $this->purchasesCreated() ) ),
'viewUrl' => (string) $this->url(),
'checkoutUrl' => (string) $this->checkoutUrl(),
@@ -1539,6 +1540,7 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
{
$profileFields = $this->guest_data['profileFields'];
$securityAnswers = isset( $this->guest_data['securityAnswers'] ) ? $this->guest_data['securityAnswers'] : array();
$spamData = $this->guest_data['spamData'];
/* If the member has already been created (the user made two separate purchases with the same data), use that, otherwise create one */
try
@@ -1554,6 +1556,8 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
$memberToSave->changed[ $k ] = $v;
}
$memberToSave->save();
$memberToSave->logHistory( 'core', 'account', array( 'type' => 'register_checkout', 'spamCode' => $spamData['code'], 'spamAction' => $spamData['action'], 'invoice' => $this->id ), FALSE );
}
$this->member = $memberToSave;
$this->guest_data = NULL;
@@ -1719,12 +1723,14 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
$purchase->app = $item::$application;
$purchase->type = $item::$type;
$purchase->item_id = intval( $item->id );
$purchase->custom_fields = $item->details;
$purchase->custom_fields = $item->purchaseDetails;
$purchase->original_invoice = $this;
$purchase->tax = $item->tax ? $item->tax->id : 0;
if ( $item->payTo )
{
$purchase->pay_to = $item->payTo;
$purchase->commission = $item->commission;
$purchase->fee = $item->fee ?: NULL;
}
if ( $item->parent !== NULL )
{
@@ -2095,7 +2101,7 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
$return['purchases'] = array();
foreach ( $purchases as $purchase )
{
$return['purchases'][] = \IPS\Theme::i()->getTemplate('purchases')->link( $purchase );
$return['purchases'][] = \IPS\Theme::i()->getTemplate( 'purchases', 'nexus' )->link( $purchase );
}
}
@@ -2107,12 +2113,12 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
{
if ( $shipment->status === \IPS\nexus\Shipping\Order::STATUS_SHIPPED )
{
$return['shipments'][] = \IPS\Theme::i()->getTemplate('shiporders')->link( $shipment );
$return['shipments'][] = \IPS\Theme::i()->getTemplate( 'shiporders', 'nexus' )->link( $shipment );
}
else
{
$return['shipments'][] = array(
'message' => \IPS\Theme::i()->getTemplate('shiporders')->link( $shipment ),
'message' => \IPS\Theme::i()->getTemplate( 'shiporders', 'nexus' )->link( $shipment ),
'warning' => \IPS\Member::loggedIn()->language()->addToStack('invoice_unpaid_shipments_shipped'),
);
}
@@ -2184,7 +2190,7 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
$this->save();
}
return \IPS\Http\Url::internal( 'app=nexus&module=checkout&controller=checkout&id=' . $this->id, 'front', 'nexus_checkout', array(), \IPS\Settings::i()->nexus_https );
return \IPS\Http\Url::internal( 'app=nexus&module=checkout&controller=checkout&id=' . $this->id, 'front', 'nexus_checkout' );
}
/**