/** * * @service affiliate_invoice read_own * @param $fields */ public function viewInvoice(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $payoutId = $form->getFieldValue("Id"); $payout = new Pap_Db_Payout(); $payout->setPrimaryKeyValue($payoutId); $payout->setUserId(Gpf_Session::getAuthUser()->getPapUserId()); try { $payout->loadFromData(array(Pap_Db_Table_Payouts::ID, Pap_Db_Table_Payouts::USER_ID)); $this->invoiceHtml = $payout->getInvoice(); return $this; } catch(Gpf_Exception $e) { } throw new Gpf_Exception($this->_('Cannot find invoice')); }
/** * * @service affiliate_invoice read * @param $fields */ public function viewInvoice(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $payoutId = $form->getFieldValue("Id"); $payout = new Pap_Db_Payout(); $payout->setPrimaryKeyValue($payoutId); try { $payout->load(); $this->invoiceHtml = $payout->getInvoice(); return $this; } catch(Gpf_Exception $e) { echo $e->getMessage(); } throw new Gpf_Exception($this->_('Cannot find invoice')); }
/** * This class needs to be initialized by row from select generated by * Pap_Merchants_Payout_PayAffiliatesForm::getAffiliatesToPaySelect(); * * @param $record */ function __construct(Pap_Common_User $user, Gpf_Db_Currency $currency, $amount, $invoiceNumber) { parent::__construct(); $this->user = $user; $this->currency = $currency; $this->setInvoiceNumber($invoiceNumber); $this->setUserId($this->user->getId()); $this->computeAmount($amount); $this->initPayoutOption(); if ($this->payoutOption != null) { $this->initPayoutOptionFields(); } }
private function migratePayouts() { echo " Migrating payous....."; $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('sum(commission)', 'commission'); $selectBuilder->select->add('affiliateid'); $selectBuilder->select->add('accountingid'); $selectBuilder->from->add('wd_pa_transactions'); $selectBuilder->where->add('rstatus', '=', Pap3Compatibility_Migration_Pap3Constants::STATUS_APPROVED); $selectBuilder->where->add('payoutstatus', '=', Pap3Compatibility_Migration_Pap3Constants::STATUS_APPROVED); $selectBuilder->where->add('accountingid', '!=', null); $selectBuilder->groupBy->add('accountingid'); $selectBuilder->groupBy->add('affiliateid'); $count = 0; foreach($selectBuilder->getAllRowsIterator() as $record) { $obj = new Pap_Db_Payout(); $obj->setUserId($record->get('affiliateid')); $obj->set('payouthistoryid', $record->get('accountingid')); $obj->set('amount', $record->get('commission')); $obj->save(); $count++; } echo " ($count) ..... DONE<br/>"; }