Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -103,10 +103,20 @@ class _purchases extends \IPS\Dispatcher\Controller
}
catch ( \OutOfRangeException $e ) { }
}
/* Get customer */
try
{
$customer = $this->purchase->member;
}
catch ( \OutOfRangeException $e )
{
$customer = NULL;
}
/* Display */
\IPS\Output::i()->sidebar['actions'] = $this->purchase->buttons();
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $children, $invoices, $customFields );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $customer, $children, $invoices, $customFields );
}
/**
@@ -147,7 +147,13 @@ class _view extends \IPS\Dispatcher\Controller
/* Purchases */
$purchaseCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1', $this->member->member_id ) )->first();
$purchaseRootCount = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_member=? AND ps_show=1 AND ps_parent=0', $this->member->member_id ) )->first();
$purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->setQueryString( 'tab', 'purchases' ), array( array( 'ps_member=?', $this->member->member_id ) ) );
$purchases->rootsPerPage = 15;
$purchases->getTotalRoots = function()
{
return NULL;
};
if ( \IPS\Request::i()->isAjax() and \IPS\Request::i()->tab === 'purchases' )
{
\IPS\Output::i()->output = $purchases;
@@ -402,7 +408,14 @@ class _view extends \IPS\Dispatcher\Controller
},
'email' => function( $v, $row )
{
return \IPS\nexus\Customer::load( $row['member_id'] )->email;
try
{
return \IPS\nexus\Customer::load( $row['member_id'] )->email;
}
catch ( \OutOfRangeException $e )
{
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
}
},
'amount' => function( $v ) use ( $member )
{
@@ -472,7 +485,14 @@ class _view extends \IPS\Dispatcher\Controller
/* Average monthly spend */
$sum = "( SUM(t_amount) / ( ( {$time} - core_members.joined ) / 2592000 ) )";
$where = array( array( "( t_status=? OR t_status=? ) AND ({$time} - core_members.joined > 2592000) AND t_currency=?", \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED, $currency ) );
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_transactions', array_merge( $where, array( array( 't_member=?', $this->member->member_id ) ) ) )->join( 'core_members', 'member_id=t_member' )->first();
try
{
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_transactions', array_merge( $where, array( array( 't_member=?', $this->member->member_id ) ) ), 'joined', NULL, 'joined' )->join( 'core_members', 'member_id=t_member' )->first();
}
catch( \UnderflowException $e )
{
$val = 0;
}
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_transactions', array_merge( $where, array( array( 't_member<>0' ) ) ), NULL, NULL, 't_member' ) )->join( 'core_members', 'member_id=t_member' )->first();
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'average_spend_currency', FALSE, array( 'sprintf' => array( $currency ) ) ) ] = array(
'value' => new \IPS\nexus\Money( $val, $currency ),
@@ -492,7 +512,7 @@ class _view extends \IPS\Dispatcher\Controller
$sum = "ROUND( ( AVG( i_paid - i_date ) / 86400 ), 2 )";
$where = array( array( "i_status=? AND i_date>0 AND i_paid>0", \IPS\nexus\Invoice::STATUS_PAID ) );
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_invoices', array_merge( $where, array( array( 'i_member=?', $this->member->member_id ) ) ) )->join( 'core_members', 'member_id=i_member' )->first();
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_invoices', array_merge( $where, array( array( 'i_member<>0' ) ) ), NULL, NULL, 'i_member' ) )->join( 'core_members', 'member_id=i_member' )->first();
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_invoices', array_merge( $where, array( array( 'i_member<>0' ) ) ), NULL, NULL, array( 'i_member', 'joined' ) ) )->join( 'core_members', 'member_id=i_member' )->first();
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'average_time_to_pay' ) ] = array(
'value' => \IPS\Member::loggedIn()->language()->formatNumber( $val, 2 ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack('days'),
'avg' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['avg'], 2 ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack('days'),
@@ -508,8 +528,15 @@ class _view extends \IPS\Dispatcher\Controller
);
$sum = "( COUNT(*) / ( ( {$time} - core_members.joined ) / 2592000 ) )";
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_support_requests', array( 'r_member=?', $this->member->member_id ) )->join( 'core_members', 'member_id=r_member' )->first();
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_support_requests', 'r_member<>0' ) )->join( 'core_members', 'member_id=r_member' )->first();
try
{
$val = \IPS\Db::i()->select( "{$sum} as sum", 'nexus_support_requests', array( 'r_member=?', $this->member->member_id ), 'joined', NULL, 'joined' )->join( 'core_members', 'member_id=r_member' )->first();
}
catch( \UnderflowException $e )
{
$val = 0;
}
$comparisons = \IPS\Db::i()->select( 'AVG(xval) AS avg, MAX(xval) AS max, MIN(xval) AS min', \IPS\Db::i()->select( "{$sum} as xval", 'nexus_support_requests', 'r_member<>0', NULL, NULL, 'joined' ) )->join( 'core_members', 'member_id=r_member' )->first();
$standing[ \IPS\Member::loggedIn()->language()->addToStack( 'average_monthly_support_requests' ) ] = array(
'value' => \IPS\Member::loggedIn()->language()->formatNumber( $val, 2 ),
'avg' => \IPS\Member::loggedIn()->language()->formatNumber( $comparisons['avg'], 2 ),
@@ -603,7 +630,24 @@ class _view extends \IPS\Dispatcher\Controller
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=edit&id=' . $this->member->member_id )
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('customers')->view( $member, (string) $notes, $noteCount, $primaryBillingAddress, (string) $cards, $cardCount, $parents, (string) $alternativeContacts, $altContactCount, $purchases, $purchaseCount, $invoices, $invoiceCount, $history, $referredBy, $referrals, $referCount, $standing, $support, $supportCount, $sparkline );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('customers')->view( $member, (string) $notes, $noteCount, $primaryBillingAddress, (string) $cards, $cardCount, $parents, (string) $alternativeContacts, $altContactCount, $purchases, $purchaseCount, $invoices, $invoiceCount, $history, $referredBy, $referrals, $referCount, $standing, $support, $supportCount, $sparkline, $purchaseRootCount );
}
/**
* View Purchase List
*
* @return void
*/
protected function purchaseList()
{
$purchases = \IPS\nexus\Purchase::tree( $this->member->acpUrl()->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 ) ) );
}
/**
@@ -975,7 +975,7 @@ class _invoices extends \IPS\Dispatcher\Controller
{
$class = $itemTypes[ \IPS\Request::i()->add ];
$formUrl = \IPS\Http\Url::internal('app=nexus&module=payments&controller=invoices&do=generate')->setQueryString( 'add', \IPS\Request::i()->add );
$formUrl = $url->setQueryString( 'add', \IPS\Request::i()->add );
$form = new \IPS\Helpers\Form( 'add', 'invoice_add_item', $formUrl );
if ( method_exists( $class, 'formSecondStep' ) )
{
@@ -308,7 +308,7 @@ class _shipping extends \IPS\Dispatcher\Controller
}, NULL, 'oz', 'easypost_package_weight' ) );
$matrix = NULL;
$fromCountry = \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address )->country;
$fromCountry = \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->easypost_address ?: \IPS\Settings::i()->site_address )->country;
if ( $fromCountry != $shipment->data['address']['country'] )
{
$originCountries = array();
@@ -418,7 +418,7 @@ class _shipping extends \IPS\Dispatcher\Controller
/* Send API call */
$toAddress = $shipment->data['address'];
$fromAddress = \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address );
$fromAddress = \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->easypost_address ?: \IPS\Settings::i()->site_address );
$easyPost = \IPS\Http\Url::external( 'https://api.easypost.com/v2/shipments' )->request()->login( \IPS\Settings::i()->easypost_api_key, '' )->post( array( 'shipment' => array(
'to_address' => array(
'street1' => array_shift( $toAddress['addressLines'] ),
@@ -71,7 +71,7 @@ class _coupons extends \IPS\Node\Controller
$table->parsers = array(
'coupon_customer' => function ( $val )
{
return \IPS\Theme::i()->getTemplate('global')->userLink( \IPS\Member::load( $val ) );
return is_numeric( $val ) ? \IPS\Theme::i()->getTemplate('global')->userLink( \IPS\Member::load( $val ) ) : $val;
}
);
$table->sortBy = 'coupon_uses';
@@ -83,8 +83,18 @@ class _packages extends \IPS\Node\Controller
}
}
}
/* If something has changed, see if anyone has purchased */
$purchases = 0;
if( count( $changes ) )
{
$purchases = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $new->id ) )->first();
}
if ( !empty( $changes ) )
/* Only show this screen if the package has been purchased. Otherwise even just copying a package and saving asks if you want to update
existing purchases unnecessarily */
if ( !empty( $changes ) AND $purchases )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->decision( 'product_change_blurb', array(
'product_change_blurb_existing' => \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=updateExisting&id={$new->_id}" )->setQueryString( 'changes', json_encode( $changes ) ),
@@ -193,14 +203,14 @@ class _packages extends \IPS\Node\Controller
$matrix->rows['x'] = array( 'any_other_amount', '-' );
if ( $values = $matrix->values() )
{
{
$renewOptions = json_decode( $changes['renew_options'], TRUE );
$changes['renew_options'] = array();
foreach ( $renewOptions as $k => $data )
{
$changes['renew_options'][] = array( 'old' => $data, 'new' => $values[ $k ]['now_pay'] );
$changes['renew_options'][ $k ] = array( 'old' => $data, 'new' => $values[ $k ]['now_pay'] );
}
$changes['renew_options'][] = array( 'old' => 'x', 'new' => $values['x']['now_pay'] );
$changes['renew_options']['x'] = array( 'old' => 'x', 'new' => $values['x']['now_pay'] );
}
else
{
@@ -334,7 +344,7 @@ class _packages extends \IPS\Node\Controller
\IPS\Output::i()->error( 'node_error', '2X249/2', 404, '' );
}
$table = new \IPS\Helpers\Table\Db( 'nexus_purchases', \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=view_purchases&id={$package->id}" ), array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $package->id ) );
$table = new \IPS\Helpers\Table\Db( 'nexus_purchases', \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=view_purchases&id={$package->id}" ), array( array( 'ps_app=? AND ps_type=? AND ps_item_id=?', 'nexus', 'package', $package->id ) ) );
$table->include = array( 'ps_id', 'ps_member', 'purchase_status', 'ps_start', 'ps_expire', 'ps_renewals' );
$table->quickSearch = 'ps_id';
$table->advancedSearch = array(
@@ -307,15 +307,16 @@ class _checkout extends \IPS\Dispatcher\Controller
}
$form->add( new \IPS\Helpers\Form\Checkbox( 'reg_admin_mails', $guestData ? $guestData['member']['allow_admin_mails'] : TRUE, FALSE ) );
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] = \IPS\Member::loggedIn()->language()->get( 'reg_agreed_terms', FALSE, array( 'sprintf' => array( \IPS\Http\Url::internal( 'app=core&module=system&controller=terms', 'front', 'terms' ) ) ) );
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] = sprintf( \IPS\Member::loggedIn()->language()->get("reg_agreed_terms"), \IPS\Http\Url::internal( 'app=core&module=system&controller=terms', 'front', 'terms', array(), PROTOCOL_RELATIVE ) );
/* Build the appropriate links for registration terms & privacy policy */
if ( \IPS\Settings::i()->privacy_type == "internal" )
{
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] .= \IPS\Member::loggedIn()->language()->get( 'reg_privacy_link', FALSE, array( 'sprintf' => array( \IPS\Http\Url::internal( 'app=core&module=system&controller=privacy', 'front', 'privacy' ), 'data-ipsDialog data-ipsDialog-size="wide" data-ipsDialog-title="' . \IPS\Member::loggedIn()->language()->get("privacy") . '"' ) ) );
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] .= sprintf( \IPS\Member::loggedIn()->language()->get("reg_privacy_link"), \IPS\Http\Url::internal( 'app=core&module=system&controller=privacy', 'front', 'privacy', array(), PROTOCOL_RELATIVE ), 'data-ipsDialog data-ipsDialog-size="wide" data-ipsDialog-title="' . \IPS\Member::loggedIn()->language()->get("privacy") . '"' );
}
else if ( \IPS\Settings::i()->privacy_type == "external" )
{
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] .= \IPS\Member::loggedIn()->language()->get( 'reg_privacy_link', FALSE, array( 'sprintf' => array( \IPS\Http\Url::external( \IPS\Settings::i()->privacy_link ), 'target="_blank"' ) ) );
\IPS\Member::loggedIn()->language()->words[ "reg_agreed_terms" ] .= sprintf( \IPS\Member::loggedIn()->language()->get("reg_privacy_link"), \IPS\Http\Url::external( \IPS\Settings::i()->privacy_link ), 'target="_blank"' );
}
$form->add( new \IPS\Helpers\Form\Checkbox( 'reg_agreed_terms', (bool) $guestData, TRUE, array(), function( $val )
{
@@ -552,7 +553,7 @@ class _checkout extends \IPS\Dispatcher\Controller
$shipMethods = array();
foreach ( \IPS\nexus\Shipping\FlatRate::roots() as $rate )
{
if ( $rate->isAvailable( $this->invoice->shipaddress ) )
if ( $rate->isAvailable( $this->invoice->shipaddress, iterator_to_array( $this->invoice->items ), $this->invoice->currency, $this->invoice ) )
{
$shipMethods[ $rate->id ] = $rate;
}
@@ -612,14 +613,18 @@ class _checkout extends \IPS\Dispatcher\Controller
foreach ( $data['items'] as $item )
{
$weightInOz += ( $item->weight->float('oz') * $item->quantity );
foreach ( array( 'length', 'width', 'height' ) as $k )
$heightInInches += ( $item->height->float('in') * $item->quantity );
foreach ( array( 'length', 'width' ) as $k )
{
$v = "{$k}InInches";
$$v += ( $item->$k->float('in') * $item->quantity );
if ( $item->$k->float('in') > $$v )
{
$$v = $item->$k->float('in');
}
}
}
try
{
$easyPost = \IPS\nexus\Shipping\EasyPostRate::getRates( $lengthInInches, $widthInInches, $heightInInches, $weightInOz, $this->invoice->member, $this->invoice->shipaddress, $this->invoice->currency );
@@ -846,6 +851,7 @@ class _checkout extends \IPS\Dispatcher\Controller
public function _pay( $data )
{
/* How much are we paying? */
$this->invoice->recalculateTotal();
$amountToPay = $this->invoice->amountToPay();
if ( isset( \IPS\Request::i()->split ) and \IPS\Request::i()->split < $amountToPay->amount )
{
@@ -943,7 +949,12 @@ class _checkout extends \IPS\Dispatcher\Controller
{
$paymentMethodOptions[0] = \IPS\Member::loggedIn()->language()->addToStack( 'account_credit_with_amount', FALSE, array( 'sprintf' => array( \IPS\nexus\Customer::loggedIn()->cm_credits[ $this->invoice->currency ] ) ) );
}
$form = new \IPS\Helpers\Form( 'select_method', 'checkout_pay', $this->invoice->checkoutUrl() );
if ( isset( \IPS\Request::i()->split ) )
{
$form->hiddenValues['split'] = $amountToPay->amount;
}
$form->class = 'ipsForm_vertical';
if ( count( $paymentMethodOptions ) > 1 )
{
@@ -955,7 +966,7 @@ class _checkout extends \IPS\Dispatcher\Controller
}
if ( \IPS\Settings::i()->nexus_tac === 'checkbox' )
{
$form->add( new \IPS\Helpers\Form\Checkbox( 'i_agree_to_tac', FALSE, TRUE, array( 'labelHtmlSprintf' => array( "<a href='" . htmlentities( \IPS\Settings::i()->nexus_tac_link, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . "' target='_blank'>" . \IPS\Member::loggedIn()->language()->addToStack( 'terms_and_conditions' ) . '</a>' ) ), function( $val )
$form->add( new \IPS\Helpers\Form\Checkbox( 'i_agree_to_tac', FALSE, TRUE, array( 'labelHtmlSprintf' => array( "<a href='" . htmlspecialchars( \IPS\Settings::i()->nexus_tac_link, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . "' target='_blank'>" . \IPS\Member::loggedIn()->language()->addToStack( 'terms_and_conditions' ) . '</a>' ) ), function( $val )
{
if ( !$val )
{
@@ -79,7 +79,7 @@ class _addresses extends \IPS\Dispatcher\Controller
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->addresses( $billingAddress, $shippingAddress, $otherAddresses ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->addresses( $billingAddress, $shippingAddress, $otherAddresses );
}
/**
@@ -138,7 +138,7 @@ class _addresses extends \IPS\Dispatcher\Controller
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( $form );
\IPS\Output::i()->output = $form;
}
}
@@ -60,7 +60,7 @@ class _alternatives extends \IPS\Dispatcher\Controller
$contact->alt_id;
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->alternatives() );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->alternatives();
}
/**
@@ -131,7 +131,7 @@ class _alternatives extends \IPS\Dispatcher\Controller
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( $form );
\IPS\Output::i()->output = $form;
}
}
@@ -71,7 +71,7 @@ class _cards extends \IPS\Dispatcher\Controller
catch ( \Exception $e ) { }
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->cards( $cards ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->cards( $cards );
}
/**
@@ -89,7 +89,7 @@ class _cards extends \IPS\Dispatcher\Controller
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( $form );
\IPS\Output::i()->output = $form;
}
}
@@ -120,7 +120,7 @@ class _credit extends \IPS\Dispatcher\Controller
}
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->credit( $balance, $pastWithdrawals, $pastWithdrawalsPagination, $canWithdraw, $canTopup ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->credit( $balance, $pastWithdrawals, $pastWithdrawalsPagination, $canWithdraw, $canTopup );
}
/**
@@ -63,7 +63,7 @@ class _donations extends \IPS\Dispatcher\Controller
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'donations.css' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->donations() );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->donations();
}
/**
@@ -86,6 +86,6 @@ class _info extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https ) );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->info( $form ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->info( $form );
}
}
@@ -92,7 +92,7 @@ class _invoices extends \IPS\Dispatcher\Controller
}
$invoices = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_invoices', $where, 'i_date DESC' ), 'IPS\nexus\Invoice' );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->invoices( $invoices ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->invoices( $invoices );
}
/**
@@ -103,7 +103,7 @@ class _invoices extends \IPS\Dispatcher\Controller
public function view()
{
$shipments = $this->invoice->shipments();
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->invoice( $this->invoice ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->invoice( $this->invoice );
}
/**
@@ -102,7 +102,7 @@ class _purchases extends \IPS\Dispatcher\Controller
{
$purchases[ $purchase->parent ][ $purchase->id ] = $purchase;
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->purchases( $purchases ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->purchases( $purchases );
}
/**
@@ -112,7 +112,7 @@ class _purchases extends \IPS\Dispatcher\Controller
*/
public function view()
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->purchase( $this->purchase ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->purchase( $this->purchase );
}
/**
@@ -130,7 +130,7 @@ class _purchases extends \IPS\Dispatcher\Controller
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( $output );
\IPS\Output::i()->output = $output;
}
}
else
@@ -212,7 +212,7 @@ class _purchases extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( $form );
\IPS\Output::i()->output = $form;
}
/**
@@ -61,6 +61,6 @@ class _referrals extends \IPS\Dispatcher\Controller
$rules = new \IPS\nexus\CommissionRule\Iterator( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_referral_rules' ), 'IPS\nexus\CommissionRule' ), \IPS\Member::loggedIn() );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->template( \IPS\Theme::i()->getTemplate('clients')->referrals( $url, $rules ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->referrals( $url, $rules );
}
}
@@ -68,7 +68,6 @@ class _product extends \IPS\Content\Controller
\IPS\Output::i()->error( 'node_error', '2X240/1', 404, '' );
}
$package = \IPS\nexus\Package::load( $item->id );
$category = \IPS\nexus\Package\Group::load( $item->group );
/* Do we have any in the cart already (this will affect stock level)? */
$inCart = 0;
@@ -89,6 +88,17 @@ class _product extends \IPS\Content\Controller
/* No - show the full page */
else
{
/* We need to create a dummy item so we can work out ship times/prices */
$itemDataForShipping = NULL;
if ( $package->physical )
{
try
{
$itemDataForShipping = $package->createItemForCart( $package->price() );
}
catch ( \OutOfBoundsException $e ) { }
}
/* If physical, get available shipping methods */
$shippingMethods = array();
$locationType = 'none';
@@ -123,7 +133,7 @@ class _product extends \IPS\Content\Controller
}
foreach ( \IPS\nexus\Shipping\FlatRate::roots( NULL, NULL, $where ) as $rate )
{
if ( ( $shipAddress and $rate->isAvailable( $shipAddress ) ) or ( $rate->locations === '*' ) )
if ( ( $shipAddress and $rate->isAvailable( $shipAddress, array( $itemDataForShipping ), $memberCurrency ) ) or ( $rate->locations === '*' ) )
{
$shippingMethods[] = $rate;
}
@@ -134,7 +144,7 @@ class _product extends \IPS\Content\Controller
{
try
{
$fromAddress = \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address );
$fromAddress = \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->easypost_address ?: \IPS\Settings::i()->site_address );
$length = new \IPS\nexus\Shipping\Length( $package->length );
$width = new \IPS\nexus\Shipping\Length( $package->width );
@@ -156,18 +166,7 @@ class _product extends \IPS\Content\Controller
catch ( \IPS\Http\Request\Exception $e ) { }
}
}
/* We need to create a dummy item so we can work out ship times/prices */
$itemDataForShipping = NULL;
if ( count( $shippingMethods ) )
{
try
{
$itemDataForShipping = $package->createItemForCart( $package->price() );
}
catch ( \OutOfBoundsException $e ) { }
}
/* Do we have renewal terms? */
$renewalTerm = NULL;
$renewOptions = $package->renew_options ? json_decode( $package->renew_options, TRUE ) : array();
@@ -58,6 +58,7 @@ class _store extends \IPS\Dispatcher\Controller
{
if ( isset( \IPS\Request::i()->csrfKey ) and \IPS\Request::i()->csrfKey === \IPS\Session\Front::i()->csrfKey )
{
$_SESSION['cart'] = array();
$_SESSION['currency'] = \IPS\Request::i()->currency;
}
$currency = \IPS\Request::i()->currency;
@@ -175,7 +176,11 @@ class _store extends \IPS\Dispatcher\Controller
$where[] = "( p_member_groups='*' OR " . \IPS\Db::i()->findInSet( 'p_member_groups', \IPS\Member::loggedIn()->groups ) . ' )';
$where[] = array( 'p_store=?', 1 );
$popularProducts = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( 'nexus_packages.*', 'nexus_purchases', $where, 'COUNT(*) DESC', $nexus_store_popular[0], 'ps_item_id' )->join( 'nexus_packages', 'ps_item_id=p_id' ), 'IPS\nexus\Package' );
$popularIds = \IPS\Db::i()->select( 'nexus_purchases.ps_item_id', 'nexus_purchases', $where, 'COUNT(ps_item_id) DESC', $nexus_store_popular[0], 'ps_item_id' )->join( 'nexus_packages', 'ps_item_id=p_id' );
if( count( $popularIds ) )
{
$popularProducts = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( 'nexus_packages.*', 'nexus_packages', array( \IPS\Db::i()->in( 'p_id', iterator_to_array( $popularIds ) ) ), 'FIELD(p_id, ' . implode( ',', iterator_to_array($popularIds) ) . ')' ), 'IPS\nexus\Package' );
}
}
/* Display */