Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -87,7 +87,7 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
|
||||
* @param string $ref Referer
|
||||
* @return \IPS\Helpers\Table\Db
|
||||
*/
|
||||
public static function table( $where = array(), \IPS\Http\Url $url, $ref = 't' )
|
||||
public static function table( ?array $where, \IPS\Http\Url $url, $ref = 't' )
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_invoices', $url, $where );
|
||||
@@ -261,6 +261,11 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
|
||||
*/
|
||||
protected $_itemsIterator;
|
||||
|
||||
/**
|
||||
* @brief Tracked
|
||||
*/
|
||||
protected $_tracked = array();
|
||||
|
||||
/**
|
||||
* Get items
|
||||
*
|
||||
@@ -1380,6 +1385,15 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
|
||||
'target' => '_blank',
|
||||
'link' => $url->setQueryString( 'do', 'printout' ),
|
||||
);
|
||||
|
||||
$trackUrl = $url->setQueryString( array( 'do' => 'track', 'id' => $this->id ) )->csrf();
|
||||
$return['track'] = array(
|
||||
'title' => $this->tracked() ? 'invoice_untrack' : 'invoice_track',
|
||||
'icon' => 'bullhorn',
|
||||
'link' => $this->tracked() ? $trackUrl : $trackUrl->setQueryString( 'track', 1 ),
|
||||
'data' => array( 'confirm' => '' )
|
||||
);
|
||||
|
||||
if ( $this->status !== \IPS\nexus\Invoice::STATUS_CANCELED and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_edit' ) )
|
||||
{
|
||||
$return['unpaid'] = array(
|
||||
@@ -1846,7 +1860,9 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
|
||||
if ( $item->payTo and !$item->payTo->inGroup( explode( ',', \IPS\Settings::i()->nexus_no_commission ) ) )
|
||||
{
|
||||
$recipientAmounts = $item->recipientAmounts();
|
||||
|
||||
|
||||
/* We explicitly re-load $item->payTo in order to ensure the account credit amounts have not changed since the time this invoice request began and now. If an admin began a payout that processed after this page load began, the account credit amount may have been reduced. */
|
||||
$item->payTo = \IPS\nexus\Customer::constructFromData( \IPS\Db::i()->select( '*, core_members.member_id AS _member_id', 'core_members', array( 'core_members.member_id=?', $item->payTo->member_id) )->join( 'nexus_customers', 'nexus_customers.member_id=core_members.member_id' )->first() );
|
||||
$credits = $item->payTo->cm_credits;
|
||||
$credits[ $this->currency ]->amount = $credits[ $this->currency ]->amount->add( $recipientAmounts['recipient_final']->amount );
|
||||
$item->payTo->cm_credits = $credits;
|
||||
@@ -2042,6 +2058,14 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
|
||||
$this->billaddress = $this->member->primaryBillingAddress();
|
||||
}
|
||||
|
||||
/* Send tracked notifications */
|
||||
foreach ( \IPS\Db::i()->select( 'member_id', 'nexus_invoice_tracker', array( 'invoice_id=?', $this->id ) ) as $trackingMember )
|
||||
{
|
||||
$trackingMember = \IPS\Member::load( $trackingMember );
|
||||
\IPS\Email::buildFromTemplate( 'nexus', 'invoiceNotify', array( $this, $this->summary( $trackingMember->language() ) ), \IPS\Email::TYPE_LIST )
|
||||
->send( $trackingMember );
|
||||
}
|
||||
|
||||
/* Log */
|
||||
if ( $member )
|
||||
{
|
||||
@@ -2290,4 +2314,31 @@ class _Invoice extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=payments&controller=invoices&do=view&id={$this->id}", 'admin' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the member tracking this invoice?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for, or NULL for currently logged in member
|
||||
* @return bool
|
||||
*/
|
||||
public function tracked( \IPS\Member $member = NULL )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if( !isset( $this->_tracked[ $member->member_id ] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$tracked = \IPS\Db::i()->select( array( 'invoice_id' ), 'nexus_invoice_tracker', array( 'member_id=? and invoice_id=?', $member->member_id, $this->id ) )->first();
|
||||
|
||||
$this->_tracked[ $member->member_id ] = TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$this->_tracked[ $member->member_id ] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_tracked[ $member->member_id ];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user