function onAffCommissionAfterInsert(Am_Event $event) { /* @var $commission AffCommission */ $commission = $event->getCommission(); if ($commission->record_type == AffCommission::VOID) { return; } // void if (empty($commission->invoice_item_id)) { return; } /* @var $invoice_item InvoiceItem */ $invoice_item = $this->getDi()->invoiceItemTable->load($commission->invoice_item_id); $amount = $commission->is_first ? $invoice_item->first_total : $invoice_item->second_total; if ($this->getConfig('mail_sale_admin')) { if ($et = Am_Mail_Template::load('aff.mail_sale_admin')) { $et->setPayment($commission->getPayment())->setInvoice($invoice = $commission->getInvoice())->setAffiliate($commission->getAff())->setUser($invoice->getUser())->setCommission($commission->amount)->setTier($commission->tier + 1)->setProduct($this->getDi()->productTable->load($commission->product_id, false))->setInvoiceItem($invoice_item)->setAmount($amount)->sendAdmin(); } } if ($this->getConfig('mail_sale_user')) { if ($et = Am_Mail_Template::load('aff.mail_sale_user')) { $et->setPayment($commission->getPayment())->setInvoice($invoice = $commission->getInvoice())->setAffiliate($commission->getAff())->setUser($invoice->getUser())->setCommission($commission->amount)->setTier($commission->tier + 1)->setProduct($this->getDi()->productTable->load($commission->product_id, false))->setInvoiceItem($invoice_item)->setAmount($amount)->send($commission->getAff()); } } if ($this->getConfig('notify_payout_empty')) { $aff = $event->getAff(); if (in_array($aff->aff_payout_type, $this->getConfig('payout_methods', array())) || $aff->data()->get('notify_payout_empty_sent')) { return; } $aff->data()->set('notify_payout_empty_sent', 1); $aff->save(); $et = Am_Mail_Template::load('aff.notify_payout_empty', $aff->lang); $et->setAffiliate($aff)->send($aff); } }
function onAffCommissionAfterInsert(Am_Event $event) { /* @var $commission AffCommission */ $commission = $event->getCommission(); if ($commission->record_type == AffCommission::VOID) { return; } // void if ($this->getConfig('mail_sale_admin')) { if ($et = Am_Mail_Template::load('aff.mail_sale_admin')) { $et->setPayment($commission->getPayment())->setInvoice($invoice = $commission->getInvoice())->setAffiliate($commission->getAff())->setUser($invoice->getUser())->setCommission($commission->amount)->setTier($commission->tier + 1)->setProduct($this->getDi()->productTable->load($commission->product_id, false))->sendAdmin(); } } if ($this->getConfig('mail_sale_user')) { if ($et = Am_Mail_Template::load('aff.mail_sale_user')) { $et->setPayment($commission->getPayment())->setInvoice($invoice = $commission->getInvoice())->setAffiliate($commission->getAff())->setUser($invoice->getUser())->setCommission($commission->amount)->setTier($commission->tier + 1)->setProduct($this->getDi()->productTable->load($commission->product_id, false))->send($commission->getAff()); } } }