public function __construct($groupColumn, $mainTablePreffix, $mainTableColumn = null) { $this->groupColumn = $groupColumn; $this->mainTablePreffix = $mainTablePreffix; $this->mainTableColumn = $mainTableColumn; if (is_null($mainTableColumn)) { $this->mainTableColumn = $groupColumn; } // DB column names $raw = Pap_Db_Table_ClicksImpressions::RAW; $unique = Pap_Db_Table_ClicksImpressions::UNIQUE; $count = 'count'; $commission = Pap_Db_Table_Transactions::COMMISSION; $totalCost = Pap_Db_Table_Transactions::TOTAL_COST; $this->statColumns[self::IMPRESSIONS_RAW] = "IF(im.$raw is NULL, 0, im.$raw)"; $this->statColumns[self::IMPRESSIONS_UNIQUE] = "IF(im.$unique is NULL, 0, im.$unique)"; $this->statColumns[self::CLICKS_RAW] = "IF(cl.$raw is NULL, 0, cl.$raw)"; $this->statColumns[self::CLICKS_UNIQUE] = "IF(cl.$unique is NULL, 0, cl.$unique)"; $this->statColumns[self::CTR_RAW] = "IF(im.$raw>0 AND cl.$raw>0, (cl.$raw/im.$raw)*100, 0)"; $this->statColumns[self::CTR_UNIQUE] = "IF(im.$unique>0 AND cl.$unique>0, (cl.$unique/im.$unique)*100, 0)"; $this->statColumns[self::SALES_COUNT] = "IF(tr.$count is NULL, 0, tr.$count)"; $this->statColumns[self::SALES_TOTAL] = "IF(tr.$totalCost is NULL, 0, tr.$totalCost)"; $this->statColumns[self::COMMISSIONS] = "IF(tr.$commission is NULL, 0, tr.$commission)"; $this->statColumns[self::SCR_RAW] = "IF(cl.$raw>0 AND tr.$count>0, (tr.$count/cl.$raw)*100, 0)"; $this->statColumns[self::SCR_UNIQUE] = "IF(cl.$unique>0 AND tr.$count>0, (tr.$count/cl.$unique)*100, 0)"; $this->statColumns[self::AVG_COMMISSION_PER_CLICK] = "IF(cl.$raw>0 AND tr.$commission>0, tr.$commission/cl.$raw, 0)"; $this->statColumns[self::AVG_COMMISSION_PER_IMP] = "IF(im.$raw>0 AND tr.$commission>0, tr.$commission/im.$raw, 0)"; $this->statColumns[self::AVG_AMOUNT_OF_ORDER] = "IF(tr.$count>0 AND tr.$commission>0, tr.$commission/tr.$count, 0)"; $context = new Pap_Common_StatsColumnsContext($this->statColumns); Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Pap_Common_StatsGrid.initStatsColumns', $context); $this->statColumns = $context->getStatsColumns(); $this->columnsToDatabaseNames[self::SALES_COUNT] = $count; $this->columnsToDatabaseNames[self::SALES_TOTAL] = $totalCost; $this->columnsToDatabaseNames[self::COMMISSIONS] = $commission; parent::__construct(); }
function __construct() { parent::__construct(); $this->userId = Gpf_Session::getAuthUser()->getPapUserId(); }