Exemplo n.º 1
0
    /**
     * Processes contact us form and sends email to merchant
     *
     * @service contact_us write
     * @param $fields
     */
    public function save(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $subject = $this->getFieldValue($form, "subject");
        $text = $this->getFieldValue($form, "text");
        Gpf_Session::getAuthUser()->getPapUserId();

        $user = new Pap_Common_User();
        $user->setPrimaryKeyValue(Gpf_Session::getAuthUser()->getPapUserId());
        try {
        	$user->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
        	$form->setErrorMessage($this->_("User cannot be found"));
        	return $form;
        }

        $mailTemplate = new Pap_Mail_MerchantOnContactUs();
        $mailTemplate->setUser($user);
        $mailTemplate->setEmail($subject, $text);
        $mailTemplate->addRecipient(Pap_Common_User::getMerchantEmail());
        $mailTemplate->setFromEmail($user->getEmail());
        $mailTemplate->setFromName($user->getFirstName()." ".$user->getLastName());
        $mailTemplate->send();

        $form->setInfoMessage($this->_("Email was successfully sent to merchant"));
        return $form;
    }
Exemplo n.º 2
0
 /**
  * @return Pap_Common_User or null
  */
 public function getParentUser()
 {
     $parentUserId = $this->getParentUserId();
     if ($parentUserId == '') {
         return null;
     }
     $objUser = new Pap_Common_User();
     $objUser->setPrimaryKeyValue($parentUserId);
     try {
         $objUser->load();
         return $objUser;
     } catch (Gpf_DbEngine_NoRowException $e) {
         return null;
     }
 }
Exemplo n.º 3
0
    private function getCommissionTypeAndValue($campaignId, $userId, $commissionTypeId, $tier = null) {
        if (is_null($tier) || $tier == '') {
            $tier = 1;
        }

        // getting user
        if($userId == '') {
            $this->errorMsg = $this->_("User is not valid!");
            return false;
        }
        $user = new Pap_Common_User();
        $user->setPrimaryKeyValue($userId);
        try {
            $user->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $this->errorMsg = $this->_("User is not valid!");
            return false;
        }

        // getting campaign
        $campaign = new Pap_Common_Campaign();
        $campaign->setId($campaignId);
        try {
            $campaign->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $this->errorMsg = $this->_("Campaign is not valid!");
            return false;
        }
        // getting commission type
        try {
            $commissionType = new Pap_Db_CommissionType();
            $commissionType->setId($commissionTypeId);
            $commissionType->setStatus(Pap_Db_CommissionType::STATUS_ENABLED);
            $commissionType->loadFromData();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $this->errorMsg = $this->_("Transaction type is not valid or doesn't exist in this campaign!");
            return false;
        }
        $fixedcostType = $commissionType->getFixedcostType();
        $fixedcostValue = $commissionType->getFixedcostValue();
        // getting commission group
        $commGroupId = $campaign->getCommissionGroupForUser($userId);
        if($commGroupId == false) {
            $this->errorMsg = $this->_("Cannot recognize commission group for this user in campaign!");
            return false;
        }

        $rsCommissions = $campaign->getCommissionsCollection($commGroupId, $commissionType->getId());
        $commType = null;
        $commValue = null;
        foreach($rsCommissions as $record) {
            if($record->get('tier') == $tier && $record->get('subtype') == 'N') {
                $commType = $record->get('commissiontype');
                $commValue = $record->get('commissionvalue');
                break;
            }
        }

        if($commType == null) {
            $this->errorMsg = $this->_("Error getting commission settings!");
            return false;
        }

        return array('type' => $commType, 'value' => $commValue, 'fixedcostValue' => $fixedcostValue, 'fixedcostType' => $fixedcostType);
    }
Exemplo n.º 4
0
	/**
	 * gets user by user id
	 * @param $userId
	 * @return Pap_Common_User
	 */
	protected function getUserById($context, $id) {
		if($id == '') {
			return null;
		}

		// try to get user by userid
		$user = new Pap_Common_User();
		$user->setPrimaryKeyValue($id);
		try {
			$user->load();
			if($user->getStatus() == Pap_Common_Constants::STATUS_DECLINED) {
				$context->debug("    User with UserId: $id found, but he is declined. We'll not use him.");
				return null;
			}

			$context->debug("    User with UserId: $id found and valid (approved or pending)");
			return $user;
		} catch (Gpf_DbEngine_NoRowException $e) {
			$context->debug("    User with UserId: $id doesn't exist");
			return null;
		}
	}