Example #1
0
    protected function fillDataToTemplate(Gpf_Templates_Template $tmpl, Gpf_Rpc_Params $params) {
        $todayParams = $this->getStatsParams('T');
        $thisMonthParams = $this->getStatsParams('TM');
        
        $tmpl->assign('todayClicks', new Pap_Stats_Clicks($todayParams));
        $tmpl->assign('todayImpressions', new Pap_Stats_Impressions($todayParams));
        $tmpl->assign('todaySales', new Pap_Stats_Sales($todayParams));
        $tmpl->assign('todayCommissions', new Pap_Stats_Transactions($todayParams));
        $tmpl->assign('todayRefunds', new Pap_Stats_Refunds($todayParams));
        $tmpl->assign('todayChargebacks', new Pap_Stats_Chargebacks($todayParams));
        $tmpl->assign('todayTransactionTypes', new Pap_Stats_TransactionTypeStats($todayParams));
        
        $signupBonus = new Pap_Stats_Transactions($todayParams);
        $signupBonus->setTransactionType(Pap_Db_Transaction::TYPE_SIGNUP_BONUS);
        $tmpl->assign('todaySignupBonus', $signupBonus);
        
        $tmpl->assign('thisMonthClicks', new Pap_Stats_Clicks($thisMonthParams));
        $tmpl->assign('thisMonthImpressions', new Pap_Stats_Impressions($thisMonthParams));
        $tmpl->assign('thisMonthSales', $s = new Pap_Stats_Sales($thisMonthParams));
        $tmpl->assign('thisMonthCommissions', new Pap_Stats_Transactions($thisMonthParams));
        $tmpl->assign('thisMonthRefunds', new Pap_Stats_Refunds($thisMonthParams));
        $tmpl->assign('thisMonthChargebacks', new Pap_Stats_Chargebacks($thisMonthParams));
        $tmpl->assign('thisMonthTransactionTypes', new Pap_Stats_TransactionTypeStats($thisMonthParams));
        
        $signupBonusMonth = new Pap_Stats_Transactions($thisMonthParams);
        $signupBonusMonth->setTransactionType(Pap_Db_Transaction::TYPE_SIGNUP_BONUS);
        $tmpl->assign('thisMonthSignupBonus', $signupBonusMonth);

        $actionCommissionsEnabled = Gpf::NO;
        $types = new Pap_Stats_TransactionTypeStatsFirstTier($thisMonthParams);
        foreach ($types->getTypes() as $transactionType) {
            if($transactionType->getType() == Pap_Common_Constants::TYPE_ACTION) {
                $actionCommissionsEnabled = Gpf::YES;
                $tmpl->assign('todayActionCommissions', new Pap_Stats_Actions($todayParams));
                $tmpl->assign('thisMonthActionCommissions', new Pap_Stats_Actions($thisMonthParams));
                break;
            }
        }
        $tmpl->assign('actionCommissionsEnabled', $actionCommissionsEnabled);

        if (Gpf_Session::getAuthUser()->hasPrivilege(Pap_Privileges::PENDING_TASK, Pap_Privileges::P_READ)) {
            $pendingTasksGadget = new Pap_Merchants_ApplicationGadgets_PendingTasksGadgets();
            $pendingTasksData = $pendingTasksGadget->load($params);
            $tmpl->assign('pendingTasks', array('affiliates' => $pendingTasksData->getValue('pendingAffiliates'),'links'=>$pendingTasksData->getValue('pendingDirectLinks'),'emails'=>$pendingTasksData->getValue('unsentEmails'),'commissions'=>$pendingTasksData->getValue('pendingCommissions'),'totalcosts'=>$pendingTasksData->getValue('totalCommissions')));
        } else {
            $tmpl->assign('pendingTasks', false);
        }
        
        return $tmpl;
    }
	public function waitingTasks($session){
		$this->loginFromSession($session);
		$pendingTasksGadget = new Pap_Merchants_ApplicationGadgets_PendingTasksGadgets();
		$response = new Pap_Mobile_Response(true);
		$response->pending_affiliates = (int)$pendingTasksGadget->getPendingAffiliatesCount();
		$response->pending_commisions = (int)$pendingTasksGadget->getPendingTransactionsInfo()->get("pendingCommissions");
		$response->pending_links = (int)$pendingTasksGadget->getPendingDirectLinksCount();
		return $response;
	}