From 967da99f78c6de64e464f6b8e06a2d545426c96b Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Tue, 30 Jul 2024 10:24:17 +0200 Subject: [PATCH] Fix #1517 Added accounts statistics for the administrator Hopefully also fixed some sorting weirdness when switching through various stats screens. --- RELEASE_NOTES.txt | 4 + lib/OA/Admin/Menu/config.php | 5 +- lib/OA/Admin/Statistics/Common.php | 8 +- .../Statistics/Delivery/CommonEntity.php | 127 +++++++++++++----- .../Delivery/Controller/AgencyDaily.php | 90 +++++++++++++ .../Delivery/Controller/AgencyHistory.php | 92 +++++++++++++ .../Delivery/Controller/GlobalAgency.php | 100 ++++++++++++++ lib/OA/Admin/Statistics/Fields/Delivery.php | 18 ++- .../tests/unit/Factory.admin.test.php | 3 + lib/max/SqlBuilder.php | 12 ++ lib/max/language/en/default.lang.php | 1 + lib/max/other/html.php | 8 +- www/admin/assets/css/icons.css | 21 --- .../images/icon-campaign-openx-add-large.png | Bin 1950 -> 0 bytes .../assets/images/icon-campaign-openx-add.png | Bin 660 -> 0 bytes .../images/icon-campaign-openx-large.png | Bin 1885 -> 0 bytes .../assets/images/icon-campaign-openx.png | Bin 664 -> 0 bytes 17 files changed, 421 insertions(+), 68 deletions(-) create mode 100644 lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php create mode 100644 lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php create mode 100644 lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php delete mode 100644 www/admin/assets/images/icon-campaign-openx-add-large.png delete mode 100644 www/admin/assets/images/icon-campaign-openx-add.png delete mode 100644 www/admin/assets/images/icon-campaign-openx-large.png delete mode 100644 www/admin/assets/images/icon-campaign-openx.png diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 1bf209cf8b..3e49324c9a 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -51,6 +51,10 @@ New Features * Added support for writing to a fail2ban compatible log file on unsuccessful login attempts. + * Replaced advertiser and website statistics with a new account statistics + screen for administrator users. + + Bug Fixes --------- diff --git a/lib/OA/Admin/Menu/config.php b/lib/OA/Admin/Menu/config.php index e17e298c23..fd34610952 100644 --- a/lib/OA/Admin/Menu/config.php +++ b/lib/OA/Admin/Menu/config.php @@ -26,7 +26,10 @@ function _buildNavigation($accountType) } // Note: The stats screens haven't been updated to use the new menuing names... - $oMenu->add(new OA_Admin_Menu_Section("2", 'Stats', "stats.php?entity=global&breakdown=history", false, "statistics")); + $oMenu->add(new OA_Admin_Menu_Section("2", 'Stats', "stats.php?entity=global&breakdown=agency", false, "statistics")); + $oMenu->addTo("2", new OA_Admin_Menu_Section("2.9", 'GlobalAgency', "stats.php?entity=global&breakdown=agency", false, "statistics/agencies")); + $oMenu->addTo("2.9", new OA_Admin_Menu_Section("2.9.1", 'AgencyHistory', "stats.php?entity=agency&breakdown=history&agencyid={agencyid}", false, "statistics/agencyHistory")); + $oMenu->addTo("2.9.1", new OA_Admin_Menu_Section("2.9.1.1", 'DailyStats', "stats.php?entity=agency&breakdown=daily&agencyid={agencyid}&day={day}", false, "statistics/agencyHistory/daily")); $oMenu->addTo("2", new OA_Admin_Menu_Section("2.2", 'GlobalHistory', "stats.php?entity=global&breakdown=history", false, "statistics/global")); $oMenu->addTo("2.2", new OA_Admin_Menu_Section("2.2.1", 'DailyStats', "stats.php?entity=global&breakdown=daily&day={day}", false, "statistics/global/daily")); $oMenu->addTo("2", new OA_Admin_Menu_Section("report-index", 'AdvancedReports', "report-index.php", false, "statistics")); diff --git a/lib/OA/Admin/Statistics/Common.php b/lib/OA/Admin/Statistics/Common.php index f789a9bee1..5698bc2b0e 100644 --- a/lib/OA/Admin/Statistics/Common.php +++ b/lib/OA/Admin/Statistics/Common.php @@ -589,7 +589,7 @@ public function _pluginSort($a, $b) * @access private * @param string $type One of "advertiser", "publisher", "placement", * "ad", "zone". - * @param ingeger $default Optional default value. + * @param integer|null $default Optional default value. * @return integer The appropriate ID field. */ public function _getId($type, $default = null) @@ -628,6 +628,12 @@ public function _getId($type, $default = null) } else { return (int) MAX_getValue('zoneid', $default); } + } elseif ($type == 'agency') { + if (is_null($default)) { + return (int) MAX_getValue('agencyid', ''); + } else { + return (int) MAX_getValue('agencyid', $default); + } } } diff --git a/lib/OA/Admin/Statistics/Delivery/CommonEntity.php b/lib/OA/Admin/Statistics/Delivery/CommonEntity.php index fdd82481d1..3573c38a46 100644 --- a/lib/OA/Admin/Statistics/Delivery/CommonEntity.php +++ b/lib/OA/Admin/Statistics/Delivery/CommonEntity.php @@ -54,6 +54,7 @@ abstract class OA_Admin_Statistics_Delivery_CommonEntity extends OA_Admin_Statis 'b' => 'stats.php?entity=banner&breakdown=history', 'p' => 'stats.php?entity=affiliate&breakdown=history', 'z' => 'stats.php?entity=zone&breakdown=history', + 'g' => 'stats.php?entity=agency&breakdown=history', ]; /** @@ -240,6 +241,7 @@ public function prepareData($aParams) } $this->data = [ + 'agency_id' => [], 'advertiser_id' => [], 'placement_id' => [], 'ad_id' => [], @@ -303,6 +305,9 @@ public function prepareData($aParams) } } } + if (in_array('agency_id', $aggregates)) { + $this->childrendata['agency_id'] = Admin_DA::fromCache('getAgencies', $aParams); + } foreach ($aRows as $row) { foreach ($aggregates as $agg) { @@ -354,59 +359,52 @@ public function mergeData($aParams, $key) } /** - * Get advertiser stats + * Get agency stats * * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ - public function getAdvertisers($aParams, $level, $expand = '') + public function getAgencies($aParams) { - $aParams['include'] = ['advertiser_id', 'placement_id']; - $aParams['exclude'] = ['zone_id']; + $aParams['include'] = ['agency_id']; + $aParams['exclude'] = ['advertiser_id', 'zone_id', 'ad_id', 'placement_id']; $this->prepareData($aParams); $period_preset = MAX_getStoredValue('period_preset', 'today'); - $aAdvertisers = $this->mergeData($aParams, 'advertiser_id'); + $aAgencies = $this->mergeData($aParams, 'agency_id'); MAX_sortArray( - $aAdvertisers, - ($this->listOrderField == 'id' ? 'advertiser_id' : $this->listOrderField), + $aAgencies, + ($this->listOrderField == 'id' ? 'agency_id' : $this->listOrderField), $this->listOrderDirection == 'up', ); $aEntitiesData = []; - foreach ($aAdvertisers as $advertiserId => $advertiser) { - $advertiser['active'] = $this->_hasActiveStats($advertiser); + foreach ($aAgencies as $agencyId => $agency) { + $agency['active'] = $this->_hasActiveStats($agency); - $this->_summarizeStats($advertiser); + $this->_summarizeStats($agency); - if ($this->startLevel > $level || !$this->hideInactive || $advertiser['active']) { - $advertiser['prefix'] = 'a'; - $advertiser['id'] = $advertiserId; - $advertiser['linkparams'] = "clientid={$advertiserId}&"; + if (!$this->hideInactive || $agency['active']) { + $agency['prefix'] = 'g'; + $agency['id'] = $agencyId; + $agency['linkparams'] = "agencyid={$agencyId}&"; if (is_array($aParams) && $aParams !== []) { foreach ($aParams as $key => $value) { if ($key != "include" && $key != "exclude") { - $advertiser['linkparams'] .= $key . "=" . $value . "&"; + $agency['linkparams'] .= $key . "=" . $value . "&"; } } } else { - $advertiser['linkparams'] .= "&"; + $agency['linkparams'] .= "&"; } - $advertiser['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) - . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); - - $advertiser['conversionslink'] = "stats.php?entity=conversions&clientid={$advertiserId}"; - $advertiser['expanded'] = MAX_isExpanded($advertiserId, $expand, $this->aNodes, $advertiser['prefix']); - $advertiser['icon'] = MAX_getEntityIcon('advertiser', $advertiser['active'], $advertiser['type']); + $agency['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) + . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); - if ($advertiser['expanded'] || $this->startLevel > $level) { - $aParams2 = $aParams + ['advertiser_id' => $advertiserId]; - $advertiser['subentities'] = $this->getCampaigns($aParams2, $level + 1, $expand); - } + $agency['icon'] = MAX_getEntityIcon('agency', $agency['active']); - $aEntitiesData[] = $advertiser; - } elseif ($this->startLevel == $level) { + $aEntitiesData[] = $agency; + } else { $this->hiddenEntities++; } } @@ -420,7 +418,7 @@ public function getAdvertisers($aParams, $level, $expand = '') * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getCampaigns($aParams, $level, $expand = '') { @@ -467,7 +465,7 @@ public function getCampaigns($aParams, $level, $expand = '') $campaign['linkparams'] .= "&"; } $campaign['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) - . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); + . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); $campaign['expanded'] = MAX_isExpanded($campaignId, $expand, $this->aNodes, $campaign['prefix']); $campaign['icon'] = MAX_getEntityIcon('placement', $campaign['active'], $campaign['type']); @@ -495,6 +493,67 @@ public function getCampaigns($aParams, $level, $expand = '') return $aEntitiesData; } + /** + * Get advertiser stats + * + * @param array Query parameters + * @param int Tree level + * @param string Expand GET parameter, used only when called from other get methods + * @return array Entities array + */ + public function getAdvertisers($aParams, $level, $expand = '') + { + $aParams['include'] = ['advertiser_id', 'placement_id']; + $aParams['exclude'] = ['zone_id']; + $this->prepareData($aParams); + $period_preset = MAX_getStoredValue('period_preset', 'today'); + $aAdvertisers = $this->mergeData($aParams, 'advertiser_id'); + MAX_sortArray( + $aAdvertisers, + ($this->listOrderField == 'id' ? 'advertiser_id' : $this->listOrderField), + $this->listOrderDirection == 'up', + ); + + $aEntitiesData = []; + foreach ($aAdvertisers as $advertiserId => $advertiser) { + $advertiser['active'] = $this->_hasActiveStats($advertiser); + + $this->_summarizeStats($advertiser); + + if ($this->startLevel > $level || !$this->hideInactive || $advertiser['active']) { + $advertiser['prefix'] = 'a'; + $advertiser['id'] = $advertiserId; + $advertiser['linkparams'] = "clientid={$advertiserId}&"; + if (is_array($aParams) && $aParams !== []) { + foreach ($aParams as $key => $value) { + if ($key != "include" && $key != "exclude") { + $advertiser['linkparams'] .= $key . "=" . $value . "&"; + } + } + } else { + $advertiser['linkparams'] .= "&"; + } + $advertiser['linkparams'] .= "period_preset={$period_preset}&period_start=" . MAX_getStoredValue('period_start', date('Y-m-d')) + . "&period_end=" . MAX_getStoredValue('period_end', date('Y-m-d')); + + $advertiser['conversionslink'] = "stats.php?entity=conversions&clientid={$advertiserId}"; + $advertiser['expanded'] = MAX_isExpanded($advertiserId, $expand, $this->aNodes, $advertiser['prefix']); + $advertiser['icon'] = MAX_getEntityIcon('advertiser', $advertiser['active'], $advertiser['type']); + + if ($advertiser['expanded'] || $this->startLevel > $level) { + $aParams2 = $aParams + ['advertiser_id' => $advertiserId]; + $advertiser['subentities'] = $this->getCampaigns($aParams2, $level + 1, $expand); + } + + $aEntitiesData[] = $advertiser; + } elseif ($this->startLevel == $level) { + $this->hiddenEntities++; + } + } + + return $aEntitiesData; + } + /** * Returns the HTML used to display the help icon triggering the tooltip * @param $id ID of the html div to show on hover @@ -511,7 +570,7 @@ private function getHtmlHelpLink($id) * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getBanners($aParams, $level, $expand = '') { @@ -574,7 +633,7 @@ public function getBanners($aParams, $level, $expand = '') * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getPublishers($aParams, $level, $expand = '') { @@ -634,7 +693,7 @@ public function getPublishers($aParams, $level, $expand = '') * @param array Query parameters * @param int Tree level * @param string Expand GET parameter, used only when called from other get methods - * @return Entities array + * @return array Entities array */ public function getZones($aParams, $level, $expand) { diff --git a/lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php new file mode 100644 index 0000000000..815efa2b72 --- /dev/null +++ b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyDaily.php @@ -0,0 +1,90 @@ + Accounts -> Daily Statistics + * + * @package OpenXAdmin + * @subpackage StatisticsDelivery + */ +class OA_Admin_Statistics_Delivery_Controller_AgencyDaily extends OA_Admin_Statistics_Delivery_CommonCrossHistory +{ + /** + * The final "child" implementation of the PHP5-style constructor. + * + * @param array $aParams An array of parameters. The array should + * be indexed by the name of object variables, + * with the values that those variables should + * be set to. For example, the parameter: + * $aParams = array('foo' => 'bar') + * would result in $this->foo = bar. + */ + public function __construct($aParams) + { + // Set this page's entity/breakdown values + $this->entity = 'agency'; + $this->breakdown = 'daily'; + + // Use the OA_Admin_Statistics_Daily helper class + $this->useDailyClass = true; + + parent::__construct($aParams); + } + + /** + * The final "child" implementation of the parental abstract method. + * + * @see OA_Admin_Statistics_Common::start() + */ + public function start() + { + // Get parameters + $agencyId = $this->_getId('agency'); + + // Security check + OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); + + // Add standard page parameters + $this->aPageParams = ['agencyid' => $agencyId]; + + // Load $_GET parameters + $this->_loadParams(); + + // Load the period preset and stats breakdown parameters + $this->_loadPeriodPresetParam(); + $this->_loadStatsBreakdownParam(); + + // HTML Framework + $this->pageId = '2.9.1.1'; + $this->aPageSections = [$this->pageId]; + + // Add breadcrumbs + $this->_addBreadcrumbs('agency', $agencyId); + + // Add shortcuts + $this->_addShortcut( + $GLOBALS['strAgencyProperties'], + 'agency-edit.php?agencyid=' . $agencyId, + 'iconAgency', + ); + + // Prepare the data for display by output() method + $aParams = [ + 'agency_id' => $agencyId, + ]; + $this->prepare($aParams); + } +} diff --git a/lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php new file mode 100644 index 0000000000..8cba2251f5 --- /dev/null +++ b/lib/OA/Admin/Statistics/Delivery/Controller/AgencyHistory.php @@ -0,0 +1,92 @@ + Accounts + * + * @package OpenXAdmin + * @subpackage StatisticsDelivery + */ +class OA_Admin_Statistics_Delivery_Controller_AgencyHistory extends OA_Admin_Statistics_Delivery_CommonHistory +{ + /** + * The final "child" implementation of the PHP5-style constructor. + * + * @param array $aParams An array of parameters. The array should + * be indexed by the name of object variables, + * with the values that those variables should + * be set to. For example, the parameter: + * $aParams = array('foo' => 'bar') + * would result in $this->foo = bar. + */ + public function __construct($aParams) + { + // Set this page's entity/breakdown values + $this->entity = 'agency'; + $this->breakdown = 'history'; + + // This page uses the day span selector element + $this->showDaySpanSelector = true; + + parent::__construct($aParams); + } + + /** + * The final "child" implementation of the parental abstract method. + * + * @see OA_Admin_Statistics_Common::start() + */ + public function start() + { + // Get parameters + $agencyId = $this->_getId('agency'); + + // Security check + OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); + + // Add standard page parameters + $this->aPageParams = [ + 'agencyid' => $agencyId, + ]; + + // Load the period preset and stats breakdown parameters + $this->_loadPeriodPresetParam(); + $this->_loadStatsBreakdownParam(); + + // Load $_GET parameters + $this->_loadParams(); + + // HTML Framework + $this->pageId = '2.9.1'; + $this->aPageSections = [$this->pageId]; + + // Add breadcrumbs + $this->_addBreadcrumbs('agency', $agencyId); + + // Add shortcuts + $this->_addShortcut( + $GLOBALS['strAgencyProperties'], + 'agency-edit.php?agencyid=' . $agencyId, + 'iconAgency', + ); + + // Prepare the data for display by output() method + $aParams = [ + 'agency_id' => $agencyId, + ]; + $this->prepare($aParams, 'stats.php'); + } +} diff --git a/lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php b/lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php new file mode 100644 index 0000000000..c458c717c2 --- /dev/null +++ b/lib/OA/Admin/Statistics/Delivery/Controller/GlobalAgency.php @@ -0,0 +1,100 @@ + Accounts + * + * @package OpenXAdmin + * @subpackage StatisticsDelivery + */ +class OA_Admin_Statistics_Delivery_Controller_GlobalAgency extends OA_Admin_Statistics_Delivery_CommonEntity +{ + /** + * The final "child" implementation of the PHP5-style constructor. + * + * @param array $aParams An array of parameters. The array should + * be indexed by the name of object variables, + * with the values that those variables should + * be set to. For example, the parameter: + * $aParams = array('foo' => 'bar') + * would result in $this->foo = bar. + */ + public function __construct($aParams) + { + // Set this page's entity/breakdown values + $this->entity = 'global'; + $this->breakdown = 'agency'; + + // This page uses the day span selector element + $this->showDaySpanSelector = true; + + parent::__construct($aParams); + } + + /** + * The final "child" implementation of the parental abstract method. + * + * @see OA_Admin_Statistics_Common::start() + */ + public function start() + { + // Get the preferences + $aPref = $GLOBALS['_MAX']['PREF']; + + // Security check + OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN); + + // HTML Framework + $this->pageId = '2.9'; + $this->aPageSections = ['2.4', '2.9']; + + $this->hideInactive = MAX_getStoredValue('hideinactive', ($aPref['ui_hide_inactive'] == true), null, true); + $this->showHideInactive = true; + + $this->startLevel = MAX_getStoredValue('startlevel', 0, null, true); + + // Init nodes + $this->aNodes = MAX_getStoredArray('nodes', []); + $expand = MAX_getValue('expand', ''); + $collapse = MAX_getValue('collapse'); + + // Adjust which nodes are opened closed... + MAX_adjustNodes($this->aNodes, $expand, $collapse); + + $aParams = $this->coreParams; + + // Load the period preset and stats breakdown parameters + $this->_loadPeriodPresetParam(); + $this->_loadStatsBreakdownParam(); + + $this->_loadParams(); + + $this->aEntitiesData = $this->getAgencies($aParams); + + // Summarise the values into the totals array, & format + $this->_summariseTotalsAndFormat($this->aEntitiesData); + + // Location params + $this->aPageParams['period_preset'] = MAX_getStoredValue('period_preset', 'today'); + $this->aPageParams['statsBreakdown'] = htmlspecialchars(MAX_getStoredValue('statsBreakdown', 'day')); + $this->aPageParams['period_start'] = htmlspecialchars(MAX_getStoredValue('period_start', date('Y-m-d'))); + $this->aPageParams['period_end'] = htmlspecialchars(MAX_getStoredValue('period_end', date('Y-m-d'))); + $this->_loadParams(); + + // Save preferences + $this->aPagePrefs['hideinactive'] = $this->hideInactive; + } +} diff --git a/lib/OA/Admin/Statistics/Fields/Delivery.php b/lib/OA/Admin/Statistics/Fields/Delivery.php index b960820d74..3177a8c563 100644 --- a/lib/OA/Admin/Statistics/Fields/Delivery.php +++ b/lib/OA/Admin/Statistics/Fields/Delivery.php @@ -391,8 +391,8 @@ public function mergeConversions(&$aRows, $method, $aParams, $emptyRow) $aFields[] = "CONCAT(diac.ad_id, '_', diac.zone_id) AS pkey"; } elseif (!isset($aParams['exclude']['ad_id'])) { $aFields[] = "diac.ad_id AS pkey"; - } else { - $aFields[] = "diac.zone_id AS pkey"; + } elseif (!isset($aParams['exclude']['zone_id'])) { + $aFields[] = "(0) AS pkey"; } } else { $aParams['exclude']['ad_id'] = true; @@ -441,14 +441,20 @@ public function mergeConversions(&$aRows, $method, $aParams, $emptyRow) " AND '" . $oEndDate->format('%Y-%m-%d %H:%M:%S') . "'"; } - if (!empty($aParams['agency_id'])) { + if (!empty($aParams['agency_id']) || isset($aParams['include']['agency_id'])) { $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)"; $aFrom['m'] = "JOIN {$conf['table']['prefix']}{$conf['table']['campaigns']} m ON (m.campaignid = b.campaignid)"; $aFrom['c'] = "JOIN {$conf['table']['prefix']}{$conf['table']['clients']} c ON (c.clientid = m.clientid)"; - $aFrom['z'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['zones']} z ON (z.zoneid = diac.zone_id)"; - $aFrom['p'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['affiliates']} p ON (p.affiliateid = z.affiliateid AND p.agencyid = '{$aParams['agency_id']}')"; - $aWhere[] = "c.agencyid = '{$aParams['agency_id']}'"; + if (!empty($aParams['agency_id'])) { + $aFrom['z'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['zones']} z ON (z.zoneid = diac.zone_id)"; + $aFrom['p'] = "LEFT JOIN {$conf['table']['prefix']}{$conf['table']['affiliates']} p ON (p.affiliateid = z.affiliateid AND p.agencyid = '{$aParams['agency_id']}')"; + + $aWhere[] = "c.agencyid = '{$aParams['agency_id']}'"; + } else { + $aFields[] = "c.agencyid AS agency_id"; + $aGroupBy[] = "agency_id"; + } } if (!empty($aParams['advertiser_id']) || isset($aParams['include']['advertiser_id'])) { $aFrom['b'] = "JOIN {$conf['table']['prefix']}{$conf['table']['banners']} b ON (b.bannerid = diac.ad_id)"; diff --git a/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php b/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php index 37fedd134e..c2dfc24e78 100644 --- a/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php +++ b/lib/OA/Admin/Statistics/tests/unit/Factory.admin.test.php @@ -45,6 +45,8 @@ class Test_OA_Admin_Statistics_Factory extends UnitTestCase 'affiliate-history' => 'OA_Admin_Statistics_Delivery_Controller_AffiliateHistory', 'affiliate-zones' => 'OA_Admin_Statistics_Delivery_Controller_AffiliateZones', + 'agency-history' => 'OA_Admin_Statistics_Delivery_Controller_AgencyHistory', + 'banner-affiliates' => 'OA_Admin_Statistics_Delivery_Controller_BannerAffiliates', 'banner-affiliate-history' => 'OA_Admin_Statistics_Delivery_Controller_BannerAffiliateHistory', //'banner-daily' => 'OA_Admin_Statistics_Delivery_Controller_BannerDaily', @@ -60,6 +62,7 @@ class Test_OA_Admin_Statistics_Factory extends UnitTestCase 'global-advertiser' => 'OA_Admin_Statistics_Delivery_Controller_GlobalAdvertiser', 'global-affiliates' => 'OA_Admin_Statistics_Delivery_Controller_GlobalAffiliates', + 'global-agency' => 'OA_Admin_Statistics_Delivery_Controller_GlobalAgency', //'global-daily' => 'OA_Admin_Statistics_Delivery_Controller_GlobalDaily', 'global-history' => 'OA_Admin_Statistics_Delivery_Controller_GlobalHistory', diff --git a/lib/max/SqlBuilder.php b/lib/max/SqlBuilder.php index 82a1a8aa84..e66bcd9a41 100644 --- a/lib/max/SqlBuilder.php +++ b/lib/max/SqlBuilder.php @@ -131,6 +131,9 @@ public static function _getColumns($entity, $aParams, $allFields) case 'stats_by_entity': if (isset($aParams['include']) && is_array($aParams['include'])) { + if (in_array('agency_id', $aParams['include'])) { + $aColumns += ['g.agencyid' => 'agency_id']; + } if (in_array('advertiser_id', $aParams['include'])) { $aColumns += ['m.clientid' => 'advertiser_id']; } @@ -166,6 +169,7 @@ public static function _getColumns($entity, $aParams, $allFields) 'placement_id' => 'd.campaignid', 'advertiser_id' => 'm.clientid', 'publisher_id' => 'z.affiliateid', + 'agency_id' => 'g.agencyid', ]; $aColumns[strtr(self::sqlKeyConcat($aParams['include']), $tr)] = 'pkey'; } else { @@ -593,6 +597,14 @@ public static function _getTables($entity, $aParams, $includeStats = false) $aTables += [$conf['table']['prefix'] . $conf['table']['data_summary_ad_hourly'] => 's']; } + if (in_array('agency_id', $aParams['include'] ?? [])) { + $aTables += [ + $conf['table']['prefix'] . $conf['table']['agency'] => 'g', + $conf['table']['prefix'] . $conf['table']['affiliates'] => 'p', + $conf['table']['prefix'] . $conf['table']['zones'] => 'z', + ]; + } + if (!empty($aParams['agency_id'])) { if (!in_array('ad_id', $aParams['exclude'] ?? [])) { $aTables += [ diff --git a/lib/max/language/en/default.lang.php b/lib/max/language/en/default.lang.php index 4e9a7bcb59..1e22d81777 100644 --- a/lib/max/language/en/default.lang.php +++ b/lib/max/language/en/default.lang.php @@ -991,6 +991,7 @@ // Agency $GLOBALS['strAgencyManagement'] = "Account Management"; +$GLOBALS['strGlobalAgency'] = 'Accounts'; $GLOBALS['strAgency'] = "Account"; $GLOBALS['strAddAgency'] = "Add new account"; $GLOBALS['strAddAgency_Key'] = "Add new account"; diff --git a/lib/max/other/html.php b/lib/max/other/html.php index 018f36de98..12bb31c188 100644 --- a/lib/max/other/html.php +++ b/lib/max/other/html.php @@ -37,12 +37,13 @@ function MAX_buildName($id, $name) return htmlspecialchars($name); } -function MAX_getEntityIcon($entity, $active = true, $type = '', $marketAdvertiserid = '') +function MAX_getEntityIcon($entity, $active = true, $type = '') { include_once MAX_PATH . '/www/admin/lib-zones.inc.php'; $icon = ''; switch ($entity) { + case 'agency': case 'advertiser': $icon = $active ? 'images/icon-advertiser.gif' : 'images/icon-advertiser-d.gif'; break; @@ -67,8 +68,7 @@ function MAX_getEntityIcon($entity, $active = true, $type = '', $marketAdvertise case 'zone': switch ($type) { - case MAX_ZoneMarketMigrated: $icon = 'images/icon-advertiser-openx.png'; - break; + default: case phpAds_ZoneBanner: $icon = 'images/icon-zone.gif'; break; case phpAds_ZoneInterstitial: $icon = 'images/icon-interstitial.gif'; @@ -81,8 +81,6 @@ function MAX_getEntityIcon($entity, $active = true, $type = '', $marketAdvertise break; case MAX_ZoneClick: $icon = 'images/icon-zone-click.gif'; break; - default: $icon = 'images/icon-zone.gif'; - break; } break; } diff --git a/www/admin/assets/css/icons.css b/www/admin/assets/css/icons.css index 15aa087f18..2450ce80d1 100644 --- a/www/admin/assets/css/icons.css +++ b/www/admin/assets/css/icons.css @@ -20,9 +20,6 @@ div.breadcrumb .inlineIcon { .iconAdvertiser { background-image: url("../images/icon-advertiser.png"); } -.iconAdvertiserSystem { - background-image: url("../images/icon-advertiser-openx.png"); -} .iconAdvertiserLarge { background-image: url("../images/icon-advertiser-large.png"); } @@ -41,12 +38,6 @@ div.breadcrumb .inlineIcon { .iconCampaign { background-image: url("../images/icon-campaign.png"); } -.iconCampaignSystem { - background-image: url("../images/icon-campaign-openx.png"); -} -.iconCampaignSystemLarge { - background-image: url("../images/icon-campaign-openx-large.png"); -} .iconCampaignDisabled { background-image: url("../images/icon-campaign-disabled.png"); } @@ -62,12 +53,6 @@ div.breadcrumb .inlineIcon { .iconCampaignAddLarge { background-image: url("../images/icon-campaign-add-large.png"); } -.iconCampaignSystemAdd { - background-image: url("../images/icon-campaign-openx-add.png"); -} -.iconCampaignSystemAddLarge { - background-image: url("../images/icon-campaign-openx-add-large.png"); -} .iconCampaignDuplicate { background-image: url("../images/icon-campaign-duplicate.png"); } @@ -83,12 +68,6 @@ div.breadcrumb .inlineIcon { .iconCampaignsLarge { background-image: url("../images/icon-campaigns-large.png"); } -.iconCampaignsSystem { - background-image: url("../images/icon-campaigns-openx.png"); -} -.iconCampaignsSystemLarge { - background-image: url("../images/icon-campaigns-openx-large.png"); -} .iconTracker { background-image: url("../images/icon-tracker.png"); } diff --git a/www/admin/assets/images/icon-campaign-openx-add-large.png b/www/admin/assets/images/icon-campaign-openx-add-large.png deleted file mode 100644 index 55bf5263918850c625ac20785808d7c5da137d0e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1950 zcmV;P2VwY$P)Da1}GSn0VWQQn@`bZOU0*=}eanz&E`_!a|W8nF`%OOe)7x}?#EQ+Ea6bc>p z`Fu<0u$M$54v`oUHY*QFfngXex~}JEbA0i5Jbgr{nyLXdF~Vx7Nv1{Dm3(d&*<7f- zc#}P8avYHzo-Er-LO76<9mE5al}H0pl;jH!Q2r&QB7z5y2nI8)2Rr+H7&J0$BKzMf zPJ4av)?3+6?QK!2c@W~eFQV- zjKz+R)~38?`Ide3GD8qfR~Bx*IehnJrzo6&<&hN8@jsMrWkh88nmWood+2u*Qk*3d zQwXqHM*DK1p@{c|j6m#qXX=p1l$4Y(<_T2wbH2ry{;=CfRPTmt1PS~t?AUfZ>FSz{ z-@`wK%YsceMyIjsdLJcdI=VdkBGlRZ^(Rd<{J{0|kQEsUbxURH06`@Z%G2n}S&FbS746zhwCgwUyjQ`yZ3j_& z?hs5@0YcRc2-Um=e}56?ebPC4L}I0%w4=yTGPNj$k}8Bs_rg>v#I=ikZFv3SXXuIa zVQZ%!Q^Nm(KO=<$$i28zWPklc=3cXk;WzfMlthGkX9RHUMygcc*sUnqG!vo7IYC00 zU%q0DjZlc#7Kmlf5$ud|A9lVU$n9k;8}4+0lVnv!BJJ$&d3^XuzCY>E8n;ijm-scOHJ{C(8#5Ah;%7X9`m8UpbEj# zI_%!Li)5#G$J%x4@N#{9d??6S#*ZI=eblvhjCp+PIO&uuwaFx-hl7nVCEok#v%( z)IKwHfK(M8gwJ)sas*hMI1C>C1HIuYaTw^jEZ)oJw0Y}R0iMgz!$;z6=5F6tGf&it zNfY^l-%x!cIPr-AL|R+_9@2<ju3o@zPYiwdCRUoXcuI6VRw>8q2N+TI% zX$<;afDh~@>)`123f2^LoQUio!VJUB&CTDIm6Zu~XIo)RjEynEnsblDhzvSC zT~Sf7>iYHT=wxw4`utJngO|%=^zue0UJnM>NHx# kM4Dwz@y7lzl>Y@702JsVW-aqEY5)KL07*qoM6N<$g1kzuj{pDw diff --git a/www/admin/assets/images/icon-campaign-openx-add.png b/www/admin/assets/images/icon-campaign-openx-add.png deleted file mode 100644 index c3bbd0a5f8bafc99cb2ca5a2b7196225bf91f01a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 660 zcmV;F0&D$=P)+90{EvynO{7OCK~lpclmigB0-mh6 zTi`wI2OJXf8ca<*f;RoKEQn|(x75Pxt3u@JmEY_)hS-`Zt4s*1Aoa2vw32`zRs$6q z8SG{j8(3_x6cxR?P;TEz8^rEGI&DA{({N^&F&vz;+1A$7pR+q>iU2=;Q6(v@*1f z()ae8cRzo8;bBzt`h$S$;wl3oJl4M>l1MN`IlOh&qhnVqkk1wrudC&uTi|RJoqJZD zarW7JEG=F@JUNf%qz`qp1y03>!1V`+#WaM%VUz_x>I@svIP1wVU_*%2z8AW#qr2-o zBv}TclR>NIzk6VLE=BaMpJrc&$bYWO9>n0l05vu4Act}^AVhi`CG7lJeC`Qjt^=fN z$cqOsGc#?nb2AKseTLS*U^VRyTZ-LeT7`hMKhAuZd84nr9g-x&2lLgWGP2~Y$zXt;)$kf1yeKoK7Z3i==y35FD~V3gKi z(kc)FHnk0fLfP$hXLfeS|39;{Oov`sXctcM@0^)4v-5rPU(SCnl4+WF7K+M0k|a5= zNsgoBI`5BSI*z96+^Uc=)D8&94pAKSz9!@ZoJdOCQBOGUQ(X_+;Q6}8A&QGkUuwf9 zV35Q}^kf|lGL~AB02!>8BuFyo%$YL_o12?|ip64$W+9<`78Mn(qCY?)kwAY31coQeGCUp+8X6kD7&dI!M!FoewZmj(huw4CQ&CYd zlSycrhIl-VOo(cXfw3?q##UKbIV)-MDRZ|q!YcBSWRnWN2?PRj_`yspilQJIjh@QQ z&3%hbTS+wH5Vwi2S@}r@7>030*Y#i~_b-0GKSG2`s2XAuBdmt%GA(LXg6tQWT*zMn z?nvtHM`TAN%kCotf6to&7!w8cCbT;Sch< zY+tUFiG2UzAe5Fphp97% zV$a9xJG^K4wnOx1h9KNkS-AC1`r#{?qHqG1O_D?BHz?og5s~FSxKs z6auUk&~dQPP&_cZM z5lu6Qh?VjyjmwA`fl$cd6&l3J1L&AziJXfTc?peGttiK2Si)KsymAQH>TM|A+(!=o zX%mTR^e4)L`whK?veQ;b@;wrtAQe|f;J*J&8qN(7_Z0o6p?t7{oy976{zFUTLDTb) zqqOuR5gKg%{DUSOKXmIdWJQKT!%~?BKv0QBiTw+HjT8$Zt9Gx*{@RGlqh=N9J9|uW5#iAp0UWxCDup>wus0?BoLS^+LvC5iDbLHU=TuvH8{Ow zv|_p>{9E?n@Am%2@(`_ z2pU^oPdz$q`gB~qdIjey&SJ}^O+1H%vWXJ~neNQ&v6xobq;Z|J96{LQM;N7O!(w=) z$_E3~*sqi%trMrArmF}Rln8U$x_vv|Td@+=)m1og?0AYucbL>i%{J$3xQUaShYPKA zRkHJMW5$a4X!DdqG3$_p!^EQnHybA6z|nJ>xu~wH;_1Y*JhrlSF!gsZWNw_8c;U zys%Quh%QcbQE6gg`JK%!jh5_er9-5Bax0Y(x>YQ?EJjE zXGb$9i5@I8C7c>jT_ouFc$nDs*%}F3L~q`eOeA?c5Ox^)X}ZEYgT z^y>sQb(E|L!UV#^%hR9ofE149=}tEcR8&-yH#aw*AZKjKfDHppjD<0wn+*dt8Rr%b zzR{DcXW|x)l(V}x)d1}`s>G8IW%{O?hjJ~`K_-y|Y@q#Cr~WD?y4dEFa`tDT{4c-& Xz~=ykZmC4_00000NkvXXu0mjf3i5aL diff --git a/www/admin/assets/images/icon-campaign-openx.png b/www/admin/assets/images/icon-campaign-openx.png deleted file mode 100644 index 15858e2144cd4065a2e6cdee5ae74110c1d3fbd4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 664 zcmV;J0%!e+P)UFJB3~fBDy3&Zi2#6P#ESV@>B;aZ4YAMx?oW3 zPUWFA8EMCn_4S|s?u<(wHt4~d-~2z`@BQAJHv$pie@rxAB5lGdCb@@%LIi@Lzz7aX zRR|wz1#DjC9*hhJ%k5~kNUR=cnhH_WU|(85@BNsS&E+XUO-m;>mG8yOrxARa7_xdM z-+kW!Ljg@o^y9UY=HEEUT$3Ub{d_=_QE8Rw3enskziTO2NCS?g+`_RPD82-^_w(iR z?+TKWleprG!@l!01Ydxa_&Iym%orcc%bp(RiRSbS-AX*7rl&_Jb+3Zb-CIa|xSO9X z{{Ce^)Kajh=Y1_#HHYFCDQt5mnY;`>+Dp(>Rtqd=WjfaS4LENzWAZ0bn|;giRsBZ1 ztN4KEp0AKt6CtdJy|NXT~W%R>}=*BYhHqH zrBW$6P#>n2qs?Uddq}GHRboe(4NiSHyW#HxJe`P5pTW5cU3@DL2;ju2lU#vl41_st zkvp+Gsu&Jk+<j^Iqm#jk>*FA3~uJo(&9O yS1|Zb1cpV8jvJEu`}(