/**
     * @service coupon read
     * @param $fields
     * @return Gpf_Rpc_Form
     */
    public function load(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);
        $form->addField(Pap_Db_Table_Coupons::CODE, null);

        $coupon = new Pap_Db_Coupon();
        $coupon->setId($form->getFieldValue(Gpf_View_FormService::ID));
        $coupon->setCode($form->getFieldValue(Gpf_View_FormService::ID));
        $banner = new Pap_Features_Coupon_Coupon();
        $affiliate = new Pap_Affiliates_User();

        try {
            $this->loadCoupon($coupon);
            if (!$coupon->isValid()) {
                return $form;
            }
            $banner->setPrimaryKeyValue($coupon->getBannerID());
            $banner->load();
            $affiliate->setPrimaryKeyValue($coupon->getUserID());
            $affiliate->load();
            $form->addField('couponid', $coupon->getId());
            $form->addField('couponcode', $coupon->getCode());
            $form->addField('name', $banner->getName());
            $form->addField('description', $banner->getData1());
            $this->fillFromUser($form, $affiliate);
            
            Gpf_Plugins_Engine::extensionPoint('PostAffiliate.OfflineSaleForm.load', $form);
            
        } catch (Gpf_Exception $e) {
        }

        return $form;
    }
 private function initAffiliate($affiliateId) {
 	$this->affiliate = new Pap_Affiliates_User();
 	$this->affiliate->setPrimaryKeyValue($affiliateId);
     $this->affiliate->load();
     if ($this->affiliate->getType() != Pap_Application::ROLETYPE_AFFILIATE) {
     	throw new Gpf_Exception($this->_('User is not affiliate'));
     }
 }
Exemple #3
0
 /**
  * @param $userid
  * @return Pap_Affiliates_User
  * @throws Gpf_Exception
  */
 private static function loadFromUserid($userid)
 {
     $user = new Pap_Affiliates_User();
     $user->setPrimaryKeyValue($userid);
     $user->load();
     return $user;
 }