CampaignHelper.class.php
2 months ago
ContactForm7Helper.class.php
2 months ago
TopAffiliatesHelper.class.php
2 months ago
UpdateDB.class.php
2 months ago
TopAffiliatesHelper.class.php
59 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class postaffiliatepro_Util_TopAffiliatesHelper extends postaffiliatepro_Base { |
| 5 | const COL_SALES_COUNT = 'salesCount'; |
| 6 | const COL_COMMISSIONS = 'commissions'; |
| 7 | const COL_RAW_CLICKS = 'clicksRaw'; |
| 8 | |
| 9 | /** |
| 10 | * @var Gpf_Data_RecordSet |
| 11 | */ |
| 12 | private static $affiliateList = null; |
| 13 | |
| 14 | /** |
| 15 | * @return Gpf_Data_RecordSet; |
| 16 | */ |
| 17 | public function getTopAffiliatesList($orderBy, $orderAsc, $limit) { |
| 18 | if (self::$affiliateList !== null) { |
| 19 | return self::$affiliateList; |
| 20 | } |
| 21 | $session = $this->getApiSession(); |
| 22 | if ($session === null || $session === '0') { |
| 23 | return null; |
| 24 | } |
| 25 | $request = new Gpf_Rpc_GridRequest('Pap_Merchants_User_TopAffiliatesGrid', 'getRows', $session); |
| 26 | $request->setLimit(0, $limit); |
| 27 | $columns = array(array('id'), array('userid'), array('firstname'), array('lastname'), array('parentuserid'), array(self::COL_COMMISSIONS), array(self::COL_SALES_COUNT), array(self::COL_RAW_CLICKS)); |
| 28 | for ($i = 1; $i <= 25; $i++) { |
| 29 | $columns[] = array('data' . $i); |
| 30 | } |
| 31 | $request->addParam('columns', new Gpf_Rpc_Array($columns)); |
| 32 | $request->addParam('sort_col', $orderBy); |
| 33 | $request->addParam('sort_asc', 'false'); |
| 34 | |
| 35 | try { |
| 36 | $request->sendNow(); |
| 37 | } catch(Exception $e) { |
| 38 | $this->_log('Can not obtain list of top affiliates:' . $e->getMessage()); |
| 39 | return null; |
| 40 | } |
| 41 | $grid = $request->getGrid(); |
| 42 | self::$affiliateList = $grid->getRecordset(); |
| 43 | return self::$affiliateList; |
| 44 | } |
| 45 | |
| 46 | public function getOrderOptions($orderBy) { |
| 47 | $out = ''; |
| 48 | $select = ($orderBy==='name')?"selected='selected'":""; |
| 49 | $out .= "<option $select value='name'>".__('Name', 'postaffiliatepro').'</option>'; |
| 50 | $select = ($orderBy===self::COL_SALES_COUNT)?"selected='selected'":""; |
| 51 | $out .= "<option $select value='". self::COL_SALES_COUNT."'>".__('Sales count', 'postaffiliatepro').'</option>'; |
| 52 | $select = ($orderBy===self::COL_RAW_CLICKS)?"selected='selected'":""; |
| 53 | $out .= "<option $select value='".self::COL_RAW_CLICKS."'>".__('Clicks list', 'postaffiliatepro').'</option>'; |
| 54 | $select = ($orderBy===self::COL_COMMISSIONS)?"selected='selected'":""; |
| 55 | $out .= "<option $select value='".self::COL_COMMISSIONS."'>".__('Commissions', 'postaffiliatepro').'</option>'; |
| 56 | return $out; |
| 57 | } |
| 58 | } |
| 59 |