/**
     * @service pay_affiliate read
     */
    public function exportMassPayFile(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $payoutOption = new Pap_Db_PayoutOption();
        $payoutOption->setID($form->getFieldValue('payoutOptionId'));
        $payoutOption->load();
        
        $this->generateExportFile($payoutOption);
        
        $download = new Gpf_File_Download_String($payoutOption->getExportFileName(),
                                                 $this->generateExportFile($payoutOption, $form->getFieldValue('affiliateNote')));
        $download->setAttachment(true);
        return $download;
    }
Ejemplo n.º 2
0
 private function initPayoutOption() {
     if (!array_key_exists($this->user->getPayoutOptionId(), self::$cachedPayoutOptions)) {
         $payoutOption = new Pap_Db_PayoutOption();
         $payoutOption->setID($this->user->getPayoutOptionId());
         try {
             $payoutOption->load();
         } catch (Gpf_Exception $e) {
             $payoutOption = null;
         }
         self::$cachedPayoutOptions[$this->user->getPayoutOptionId()] = $payoutOption;
     }
     $this->payoutOption = self::$cachedPayoutOptions[$this->user->getPayoutOptionId()];
 }
    /**
     * @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();
        }
    }