/** * @service pay_affiliate read */ public function markTransactionsAsPaymentPending(Gpf_Rpc_Params $params) { $this->clearPaymentPendingMark(); $action = new Gpf_Rpc_Action($params); $userIds = $this->getUserIdsFromFilter($action); $filters = new Gpf_Rpc_FilterCollection($params); $filterIterator = $filters->getIterator(); while($filterIterator->valid()) { $filter = $filterIterator->current(); if(!substr_compare($filter->getCode(), Pap_Merchants_Payout_PayAffiliatesGrid::TANSACTIONS_TABLE_ALIAS.'.data', 0, strlen($filter->getCode())-1)) { $suffix = substr($filter->getCode(), strlen($filter->getCode())-1); $filter->setCode('data'.$suffix); } $filterIterator->next(); } $numRows = $this->updateSelectedRows($filters, $userIds); if ($numRows == 0) { $action->setErrorMessage($this->_('Nobody from selected affiliates have approved commissions. No commissions will be paid.')); $action->addError(); return $action; } $nonZeroUsersCount = $this->getNumberOfNonZeroPaidAffiliates($userIds); if ((count($userIds) - $nonZeroUsersCount) > 0) { $action->setErrorMessage($this->_('%s of selected affiliates have no approved or zero commissions. No commissions will be paid to them.', (count($userIds) - $nonZeroUsersCount))); $action->addError(); return $action; } $action->addOk(); return $action; }