Inheritance: extends Gpf_Object, implements Gpf_Rpc_Serializable
    /**
     * @service link_cloaker read
     * @param $fields
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $data->setValue("urlToProtect", Pap_Affiliates_MainPanelHeader::getAffiliateLink());

        return $data;
    }
    /**
     * @service affiliate_panel_settings read
     * @param $fields
     */
    public function loadTree(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $data->setValue(Pap_Settings::AFFILIATE_MENU, Gpf_Settings::get(Pap_Settings::AFFILIATE_MENU));

        return $data;
    }
	/**
	 * @service trend_stats read
	 * @param $fields
	 */
	public function load(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);
		$this->statParams = $this->createStatParams($data->getFilters());
		$this->setActionAndCommissionId($data->getFilters());
		$this->fillData($data, $params);
		return $data;
	}
 private function checkFilters(Gpf_Rpc_Data $data) {
     $filters = $data->getFilters();
     if ($filters->getSize() == 0 || count($filters->getFilter("datetime")) == 0) {
         throw new Exception($this->_("Filter does not contain date parameters"));
     }
     return $filters;
 }
Example #5
0
	public function getDetails(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);
		foreach ($this->fieldValues as $code => $value) {
			$data->setValue($code, $value);
		}
		return $data;
	}
    /**
     * @service campaign read
     * @return Gpf_Data_RecordSet
     */
    public function getActionTypes(Gpf_Rpc_Params $params) {
        $actionTypesHeader = array(Pap_Db_Table_CommissionTypes::TYPE, Pap_Db_Table_CommissionTypes::NAME, Pap_Db_Table_CommissionTypes::ID, 'campaignName');

        $data = new Gpf_Rpc_Data($params);
        $filters = $data->getFilters();

        $statsParams = new Pap_Stats_Params();
        $statsParams->setCampaignId($filters->getFilterValue('campaignid'));
        $statsParams->setBannerId($filters->getFilterValue('bannerid'));

        $transactionTypeStats = new Pap_Stats_TransactionTypeStats($statsParams);
        $transactionTypes = $transactionTypeStats->getTypes();

        $actionTypesRecordSet = new Gpf_Data_RecordSet();
        $actionTypesRecordSet->setHeader($actionTypesHeader);

        $this->initActionCampaignNames();

        foreach ($transactionTypes as $transactionType) {
            if ($transactionType->getType() != Pap_Common_Constants::TYPE_SALE && $transactionType->getType() !=Pap_Common_Constants::TYPE_ACTION && $transactionType->getType() != Pap_Common_Constants::TYPE_RECURRING) {
                continue;
            }
            $actionTypesRecordSet->add(new Gpf_Data_Record($actionTypesHeader, array($transactionType->getType(), $transactionType->getName(), $transactionType->getCommissionTypeId(), $this->getActionCampaignName($transactionType->getCommissionTypeId()))));
        }
        return $actionTypesRecordSet;
    }
    /**
     * @service sub_aff_stats read
     * @param $fields
     */
    public function load(Gpf_Rpc_Params $rpcParams) {
        $data = new Gpf_Rpc_Data($rpcParams);

        $data->setValue("numberOfSubaffiliates", $this->getNumberOfSubaffiliates());

        return $data;
    }
 public function send()
 {
     $this->addParam('data', $this->data->getParams());
     if (count($this->filters) > 0) {
         $this->addParam("filters", $this->addFiltersParameter());
     }
     parent::send();
 }
 /**
  * @service country read
  * @anonym
  * @return Gpf_Rpc_Data
  */
 public function loadDefaultCountry(Gpf_Rpc_Params $params)
 {
     $data = new Gpf_Rpc_Data($params);
     $context = new Gpf_Plugins_ValueContext(Gpf_Settings::get(Gpf_Settings_Gpf::DEFAULT_COUNTRY));
     Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Countries.getDefaultCountry', $context);
     $data->setValue('default', $context->get());
     return $data;
 }
 /**
  * @param Gpf_Rpc_Params $params
  * @service
  * @anonym
  * @return Gpf_Rpc_Data
  */
 public function check(Gpf_Rpc_Params $params)
 {
     $data = new Gpf_Rpc_Data($params);
     $text = $data->getParam('teststring');
     $dataOut = new Gpf_Rpc_Data();
     $dataOut->setValue('status', 'OK');
     $dataOut->setValue('recieved', $text);
     return $dataOut;
 }
    /**
     * @service quick_stats read
     * @param $fields
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $this->statsParams = $this->getStatsParams();
        $this->statsParams->initFrom($data->getFilters());

        $this->fillData($data, $params);
        return $data;
    }
 /**
  *
  * @service financial_overview read
  * @param $fields
  */
 public function load(Gpf_Rpc_Params $params) {
     $data = new Gpf_Rpc_Data($params);
     
     $transactions = new Pap_Stats_Transactions(new Pap_Stats_Params());
     $data->setValue("approvedCommissions", round($transactions->getCommission()->getApproved(), 2));
     $data->setValue("pendingCommissions", round($transactions->getCommission()->getPending(), 2));
     
     return $data;
 }
Example #13
0
    /**
     * @service banners_categories read
     * @param $fields
     */
    public function loadTree(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $tree = new Pap_Features_BannersCategories_Tree(false);
        $tree->laod();
        $data->setValue(self::BANNERS_CATEGORIES_TREE, $tree->toJSON());
        $data->setValue(self::BANNERS_CATEGORIES_TREE_MAXITEMCODE, $tree->getMaxCode());

        return $data;
    }
    /**
     * @service campaigns_categories read
     * @param $fields
     */
    public function loadTree(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $tree = new Pap_Features_CampaignsCategories_Tree(false, array('Y'));
        $tree->laod();
        $data->setValue(Pap_Features_CampaignsCategories_TreePanel::CAMPAIGNS_CATEGORIES_TREE, $tree->toJSON());
        $data->setValue(Pap_Features_CampaignsCategories_TreePanel::CAMPAIGNS_CATEGORIES_TREE_MAXITEMCODE, '0');

        return $data;
    }
 /**
  *
  * @service
  * @anonym
  * @return Gpf_Rpc_Data
  */
 public function ping(Gpf_Rpc_Params $params)
 {
     $sql = new Gpf_SqlBuilder_SelectBuilder();
     $sql->select->addAll(Gpf_Db_Table_AuthUsers::getInstance());
     $sql->from->add(Gpf_Db_Table_AuthUsers::getName());
     $count = $sql->getAllRows()->getSize();
     if ($count == 0) {
         throw new Gpf_Exception($this->_('Ping failed'));
     }
     $data = new Gpf_Rpc_Data();
     $data->setValue('status', 'OK');
     return $data;
 }
    /**
     * @service pay_affiliate read
     * @param $data
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->add("au.username","userName");
        $select->select->add("au.firstname","firstName");
        $select->select->add("au.lastname","lastname");
        $select->select->add("SUM(t.".Pap_Db_Table_Transactions::COMMISSION.")", "payout");
        $select->select->add("pu.".Pap_Db_Table_Users::MINIMUM_PAYOUT, "minimumPayout");
        $select->select->add("IFNULL(po.".Gpf_Db_Table_FieldGroups::NAME.", 'undefined')", "payoutMethod");
        $select->from->add(Pap_Db_Table_Transactions::getName(), "t");
        $select->from->addInnerJoin(Pap_Db_Table_Users::getName(), "pu", "t.userid = pu.userid");
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), "gu", "pu.accountuserid = gu.accountuserid");
        $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), "au", "gu.authid = au.authid");
        $select->groupBy->add("t.".Pap_Db_Table_Transactions::USER_ID);
        $select->from->addLeftJoin(Gpf_Db_Table_FieldGroups::getName(), "po", "pu.payoutoptionid = po.fieldgroupid");
        $select->where->add("t.".Pap_Db_Table_Transactions::USER_ID, "=", $params->get("id"));
        $row = $select->getOneRow();

        $data->setValue("userName", $row->get("userName"));
        $data->setValue("firstName", $row->get("firstName"));
        $data->setValue("lastname", $row->get("lastname"));
        $data->setValue("payout", $row->get("payout"));
        $data->setValue("minimumPayout", $row->get("minimumPayout"));
        $data->setValue("payoutMethod", $row->get("payoutMethod"));

        return $data;
    }
    /**
     * Load affiliate detail for affiliate manager
     *
     * @service affiliate read
     * @param $fields
     */
    public function affiliateDetails(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);
        $search = $data->getFilters()->getFilter("id");
        if (sizeof($search) == 1) {
            $id = $search[0]->getValue();
        }
        

        $user = new Pap_Affiliates_User();
        $user->setId($id);
        try {
            $user->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
            return $data;
        }
        $data->setValue("id", $user->getId());
        $data->setValue("name", $user->getFirstName()." ".$user->getLastName());
        $data->setValue("username", $user->getUserName());

        $formFields = $this->getUserFormFields();
        foreach($formFields as $record) {
            $code = $record->get('code');
            $data->setValue($code, $user->get($code));
        }

        return $data;
    }
    /**
     *
     * @param $message
     * @param $simulation
     * @return Gpf_Rpc_Form
     */
    private function action(Gpf_Rpc_Params $params, $message = '', $simulation = false) {
        $data = new Gpf_Rpc_Data($params);

        $filters = new Gpf_Rpc_FilterCollection($params);
        if ($filters->getFilterValue('reachedCondition') == Gpf::YES) {
            $data->setValue('message', $message);
            return $data;
        }

        $compressedCommissionProcesor = new Pap_Features_CompressedCommissionPlacementModel_Processor();
        $output = $compressedCommissionProcesor->recalculate($params->get('filters'), $simulation);

        $data->setValue('message', $output);
        return $data;
    }
    /**
     * @anonym
     * @service direct_link read
     */
    public function getAffiliateId(Pap_Contexts_Click $context, Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $context = new Pap_Contexts_Click();
        $context->getRequestObject()->setRequestParameter(
        Pap_Tracking_Request::PARAM_REFERRERURL_NAME,
        $params->get('url'));
        $match = $this->getMatch($context);

        if ($match != null) {
            foreach ($match as $key => $value) {
                $data->setValue($key, $value);
            }
        }
        return $data;
    }
 public function loadNoRpc(Gpf_Rpc_Params $params, $useParent = true) {
     $data = new Gpf_Rpc_Data($params);
     $signupFormPanel = new Pap_Affiliates_Promo_SignupFormPanel();
     $addScript = '';
     if ($useParent) {       
         $parentUserId = '<input type="hidden" name="parentuserid"'  
                         . ' value="' . Gpf_Session::getAuthUser()->getPapUserId() . '" />';
     } else {
         $parentUserId = '<input type="hidden" name="parentuserid" id="parentuserid" value="" />';
         $scriptUrl = Gpf_Paths::getInstance()->getFullScriptsUrl().'salejs.php';
         $addScript = '<script id="pap_x2s6df8d" 
                               src="'.$scriptUrl.'" type="text/javascript">
                       </script>
                       <script type="text/javascript">
                         PostAffTracker.writeAffiliateToCustomField(\'parentuserid\');
                       </script>';
     }
     if ($signupFormPanel->containsId("parentuserid")) {
         $signupFormPanel->add($parentUserId, "parentuserid");
     } else {
         $signupFormPanel->addWidget($parentUserId, "parentuserid");
     }
     $signupFormPanelHtml = '<form action="' . self::getSignupScriptUrl($useParent) . '" method="post">' 
                            . $signupFormPanel->render()
                            . '</form>'
                            . $addScript;
     
     $data->setValue("formSource", $signupFormPanelHtml);
     $data->setValue("formPreview", $signupFormPanelHtml);
     
     return $data;
 }
    /**
     * @param $params
     * @param $row
     * @param $primaryKeyName
     * @param $baseAttributes
     */
    private function getResponse(Gpf_Rpc_Params $params, Gpf_DbEngine_RowBase $row, $primaryKeyName, array $baseAttributes = null) {
    	$this->visitorId = $params->get('visitorId');

        $response = new Gpf_Rpc_Data();
        if ($this->visitorId == '') {
            return $response;
        }
        $this->setAccountId($params->get('accountId'));
        
        $this->processAllVisitorVisits();
        if (($visitorAffiliate = $this->getCurrentVisitorAffiliate()) == null) {
            return $response;
        }  
              
    	if (is_null($baseAttributes)) {
    		$baseAttributes = array($primaryKeyName);
    	}
    	$row->set($primaryKeyName, $visitorAffiliate->get($primaryKeyName));
        try {
            $row->load();
        } catch (Gpf_Exception $e) {
            return $response;
        }
        if (Gpf_Session::getAuthUser()->hasPrivilege('click', 'write')) {
            foreach ($row->getAttributes() as $name => $value) {
                $response->setValue($name, $value);
            }
        } else {
        	foreach ($baseAttributes as $attribute) {
            	$response->setValue($attribute, $row->get($attribute));
        	}
        }
        return $response;
    }
 public function getPayeesDeatilsInfo($payoutId) {
     $this->checkMerchantRole();
     $request = new Gpf_Rpc_DataRequest('Pap_Merchants_Payout_PayoutsHistoryGrid', 'payeesDetails', $this->apiSessionObject);
     $request->addFilter('id', 'E', $payoutId);
     $request->sendNow();
     $results = $request->getData();
     
     $output = array();
     
     for ($i=0; $i<$results->getSize(); $i++) {
         $userinfo = $results->getValue('user' . $i);
         $data = new Gpf_Rpc_Data();
         $data->loadFromObject($userinfo);
         $output[] = $data;
     }
     return $output;
 }
 /**
  *
  * @service
  * @anonym
  * 
  * @param Gpf_Rpc_Params $params
  */
 public function getLatestVersion(Gpf_Rpc_Params $params)
 {
     $data = new Gpf_Rpc_Data($params);
     $request = new Gpf_Rpc_DataRequest('Dp_Version_Info', 'getLatestVersion');
     $request->setUrl(Gpf_Install_LicenseManager::MEMBERS_URL);
     $request->setField('id', $data->getParam('id'));
     try {
         $request->sendNow();
         $versionInfo = $request->getData();
         if (version_compare($versionInfo->getValue('version'), Gpf_Application::getInstance()->getVersion()) < 0) {
             $versionInfo->setValue('version', Gpf_Application::getInstance()->getVersion());
         }
         return $versionInfo;
     } catch (Exception $e) {
     }
     return $data;
 }
Example #24
0
 /**
  * @service affiliate_login_form read
  * @param Gpf_Rpc_Params $params
  * @return Gpf_Rpc_Data
  */
 public function load(Gpf_Rpc_Params $params) {
     $data = new Gpf_Rpc_Data($params);
     
     $loginFormPanel = new Gpf_Ui_TemplatePanel("login_form_downloadable.tpl", "affiliates");    
     $loginFormPanel->add('<input type="text" name="username">', "username");   
     $loginFormPanel->add('<input type="password" name="password">', "password");
     $loginFormPanel->add('<input type="checkBox" name="rememberMe">', "rememberMe");
     $loginFormPanel->add('<input type="submit" value="' . $this->_("Login") . '">', "LoginButton");
     
     $loginFormPanelHtml = '<form action="' . self::getLoginScriptUrl() . '" method="post">' 
                            . $loginFormPanel->render()
                            . '</form>';
     
     $data->setValue("formSource", $loginFormPanelHtml);
     $data->setValue("formPreview", $loginFormPanelHtml);
     
     return $data;
 }
    /**
     * Load category detail for transaction manager
     *
     * @service banners_categories read
     * @param $fields
     */
    public function categoryDetails(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);

        $ids = $data->getFilters()->getFilter("id");
        	
        if (sizeof($ids) == 1) {
            $id = $ids[0]->getValue();
        }

        $category = $this->getCategoryData($id);
        if($category == null) {
            return $data;
        }

        foreach ($category as $name => $value) {
            $data->setValue($name, $this->_localize($value));
        }

        return $data;
    }
	/**
	 * Load transaction detail for transaction manager
	 *
	 * @service transaction_stats read
	 * @param $fields
	 */
	public function transactionDetails(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);

		$ids = $data->getFilters()->getFilter("id");
		 
		if (sizeof($ids) == 1) {
			$id = $ids[0]->getValue();
		}

		$trans = $this->getTransactionData($id);
		if($trans == null) {
			return $data;
		}

		foreach ($trans as $name => $value) {
			$data->setValue($name, $value);
		}

		return $data;
	}
	/**
	 *
	 * @service pay_affiliate_stats read
	 * @param $data
	 */
	public function load(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);
		$statsParams = new Pap_Stats_Params();
		$statsParams->initFrom($data->getFilters());
		$transactions = new Pap_Stats_Transactions($statsParams);

		$data->setValue("paid", $this->getPaidData($data->getFilters()));
		$data->setValue("unpaidApprovedComm", $transactions->getCommission()->getApproved());
		$data->setValue("unpaidPendingComm", $transactions->getCommission()->getPending());
		$data->setValue("unpaidDeclinedComm", $transactions->getCommission()->getDeclined());

		return $data;
	}
	/**
	 *
	 * @service banner_stats read
	 * @param $data
	 */
	public function loadFilteredStatistics(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);
		$statsParams = new Pap_Stats_Params();		
		$statsParams->initFrom($data->getFilters());				
		$impressions = new Pap_Stats_Impressions($statsParams);
		$clicks = new Pap_Stats_Clicks($statsParams);
		$sales = new Pap_Stats_Sales($statsParams);

		$data->setValue("impressions", $impressions->getCount()->getAll());
		$data->setValue("rawClicks", $clicks->getCount()->getRaw());
		$data->setValue("uniqueClicks", $clicks->getCount()->getUnique());
		$data->setValue("sales", $sales->getCount()->getApproved());
		$data->setValue("ctr", 0);
		if ($impressions->getCount()->getAll() !== 0) {
			$data->setValue("ctr", $clicks->getCount()->getAll() / ($impressions->getCount()->getAll() / 100));
		}

		return $data;
	}
	/**
	 *
	 * @service campaign_stats read
	 * @param $data
	 */
	public function load(Gpf_Rpc_Params $params) {
		$data = new Gpf_Rpc_Data($params);
		$statsParams = new Pap_Stats_Params();
		$statsParams->initFrom($data->getFilters());						
		$transactions = new Pap_Stats_Transactions($statsParams);
		
		$data->setValue("totalCommisions", $transactions->getCommission()->getAll());
		$data->setValue("totalSales", $transactions->getTotalCost()->getAll());
		$data->setValue("totalPendingCommisions", $transactions->getCommission()->getPending());
		$data->setValue("totalUnpaidApprovedCommisions", $transactions->getCommission()->getApproved());
		
		return $data;
	}
    /**
     *
     * @service pending_task read
     * @param $fields
     */
    public function load(Gpf_Rpc_Params $params) {
        $data = new Gpf_Rpc_Data($params);
        
        $data->setValue("pendingAffiliates", $this->getPendingAffiliatesCount());
        $data->setValue("pendingDirectLinks", $this->getPendingDirectLinksCount());
        
        $transactionsInfo = $this->getPendingTransactionsInfo();
        
        $data->setValue("pendingCommissions", $transactionsInfo->get("pendingCommissions"));
        $data->setValue("totalCommissions", $transactionsInfo->get("totalCommissions"));
        $data->setValue("unsentEmails", $this->getUnsentEmails());

        return $data;
    }