Example #1
0
    private function assignPayoutVariablesToTemplate(Gpf_Templates_Template $template) {
        $template->assignAttributes($this->user);
        $template->assign('vat_number', $this->vatNumber);
        $template->assign('reg_number', $this->regNumber);
        $template->assign('amount_of_reg_capital', $this->amountOfRegCapital);
        $template->assign('vat_percentage', $this->vatPercentage);
        $template->assign('payoutcurrency', $this->currency->getName());
        $template->assign('affiliate_note', $this->getAffiliateNote());
        $template->assign('payment', $this->getAmount());
        $template->assign('amount', str_replace('.', ',', $this->getAmount()));
        $template->assign('currency', $this->currency->getName());

        if ($this->payoutOption != null) {
            $template->assign('payoutmethod', $this->_localize($this->payoutOption->getName()));
        }
        $template->assign('payment_vat_part', $this->amountVatPart);
        $template->assign('payment_incl_vat', $this->amountWithVat);
        $template->assign('payment_excl_vat', $this->amountWithoutWat);

        $historyItem = $this->getPayoutHistoryItem();
        if ($historyItem === null) {
            
            $template->assign('date', Gpf_Common_DateUtils::getDateInLocaleFormat());
            $template->assign('time', Gpf_Common_DateUtils::getTimeInLocaleFormat());
        } else {
            $time = new Gpf_DateTime($historyItem->getDateInserted());
            $template->assign('date', Gpf_Common_DateUtils::getDateInLocaleFormat($time->toTimestamp()));
            $template->assign('time', Gpf_Common_DateUtils::getTimeInLocaleFormat($time->toTimestamp()));
        }
        $template->assign('invoicenumber',$this->getInvoiceNumber());

        if ($this->payoutOptionFields != null) {
            $userPayoutOptions = Pap_Db_Table_UserPayoutOptions::getInstance()->getValues(
            $this->payoutOption->getFormId(), $this->user->getId());
            foreach ($this->payoutOptionFields as $payoutOptionField) {
                $code = $payoutOptionField->get('code');
                if (array_key_exists($code, $userPayoutOptions)) {
                    $template->assign($code, $userPayoutOptions[$code]->getValue());
                }
            }
        }
    }
    /**
     * @param array $payoutOptionData
     */
    private function processPayoutOption($payoutOptionData, $row) {
        $user = new Pap_Affiliates_User();
        $user->setId($payoutOptionData[Pap_Db_Table_UserPayoutOptions::USERID]);
        try {
            $user->load();

            $payoutOption = new Pap_Db_PayoutOption();
            $payoutOption->setID($user->getPayoutOptionId());
            $payoutOption->load();

            $payoutField = new Gpf_Db_FormField();
            $payoutField->setFormId($payoutOption->getFormId());
            $payoutField->setCode($payoutOptionData[Gpf_Db_Table_FormFields::CODE]);
            $payoutField->loadFromData(array(Gpf_Db_Table_FormFields::FORMID, Gpf_Db_Table_FormFields::CODE));

            $userPayoutOption = new Pap_Db_UserPayoutOption();
            $userPayoutOption->setUserId($payoutOptionData[Pap_Db_Table_UserPayoutOptions::USERID]);
            $userPayoutOption->setFormFieldId($payoutField->getId());
            $userPayoutOption->setValue($payoutOptionData[Pap_Db_Table_UserPayoutOptions::VALUE]);
            $userPayoutOption->save();
            $this->incrementSuccessfulCount();
            $this->logger->debug('Data from line: ' . $this->getFile()->getActualCSVLineNumber() . ' was inserted.');
        } catch (Gpf_Exception $e) {
        	$this->logError('Payout option', $row, $e);
        	$this->appendOutputMessage($this->getSaveErrorMessage($this->getFile()->getActualCSVLineNumber(), $e->getMessage()));
            $this->incrementWrongCount();
        }
    }