Version 4.1.2
This commit is contained in:
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(
|
||||
|
||||
Reference in new issue
Block a user