/**
  * PHP4-style constructor
  *
  * @param array $aFieldSelectionNames A list of the predefined 'friendly' selections.
  * @param string $fieldSelectionDefault The default selection.
  */
 function Admin_UI_OrganisationSelectionField($name = 'OrganisationSelectionField', $defaultAdvertiser = 'all', $defaultPublisher = 'all', $filterBy = FILTER_NONE)
 {
     $this->_name = $name;
     $oScope = new Admin_UI_OrganisationScope();
     $oScope->setAdvertiserId($defaultAdvertiser);
     $oScope->setPublisherId($defaultPublisher);
     $this->_value = $oScope;
     $this->_filter = $filterBy;
 }
Exemple #2
0
 /**
  * A private method to get the required sub-heading parameters for the reports
  * for a given advertiser/publisher limitation scope.
  *
  * @return array An array of parameters that can be used in the
  *               {@link Plugins_Reports::_getReportParametersForDisplay()} method.
  */
 function _getDisplayableParametersFromScope()
 {
     $aParams = array();
     $key = MAX_Plugin_Translation::translate('Advertiser', $this->module);
     $advertiserId = $this->_oScope->getAdvertiserId();
     if (!empty($advertiserId)) {
         // Get the name of the advertiser
         $doClients = OA_Dal::factoryDO('clients');
         $doClients->clientid = $advertiserId;
         $doClients->find();
         if ($doClients->fetch()) {
             $aAdvertiser = $doClients->toArray();
             $aParams[$key] = $aAdvertiser['clientname'];
         }
     } else {
         if ($this->_oScope->getAnonymous()) {
             $aParams[$key] = MAX_Plugin_Translation::translate('Anonymous Advertisers', $this->module);
         } else {
             $aParams[$key] = MAX_Plugin_Translation::translate('All Advertisers', $this->module);
         }
     }
     $key = MAX_Plugin_Translation::translate('Website', $this->module);
     $publisherId = $this->_oScope->getPublisherId();
     if (!empty($publisherId)) {
         $doAffiliates = OA_Dal::factoryDO('affiliates');
         $doAffiliates->affiliateid = $publisherId;
         $doAffiliates->find();
         if ($doAffiliates->fetch()) {
             $aPublisher = $doAffiliates->toArray();
             $aParams[$key] = $aPublisher['name'];
         }
     } else {
         if ($this->_oScope->getAnonymous()) {
             $aParams[$key] = MAX_Plugin_Translation::translate('Anonymous Publishers', $this->module);
         } else {
             $aParams[$key] = MAX_Plugin_Translation::translate('All Websites', $this->module);
         }
     }
     return $aParams;
 }
 /**
  * A private method to obtain the raw delivery performance data for a given date range.
  *
  * @access private
  * @param Admin_UI_OrganisationScope $oScope The Admin_UI_OrganisationScope limitation object for
  *                                           the report.
  * @param OA_Admin_DaySpan $oDaySpan The OA_Admin_DaySpan day range limitation object for the report,
  *                                   or for "yesterday" or "today" as required.
  * @param boolean $spanIsForPlacementDates If true, $oDaySpan is used for the start/end date limitaion
  *                                         of the placements, otherwise it is used to limit the
  *                                         data to delivery that happened in the $oDaySpan range.
  * @return array
  */
 function _getDeliveryPerformanceDataRange($oScope, $oDaySpan, $spanIsForPlacementDates = false, $statsTable = false, $appendSqlWhere = false)
 {
     $aConf = $GLOBALS['_MAX']['CONF'];
     if (empty($appendSqlWhere)) {
         $appendSqlWhere = "AND c.type = " . DataObjects_Campaigns::CAMPAIGN_TYPE_DEFAULT . " ";
     }
     if ($statsTable === false) {
         $statsTable = $aConf['table']['prefix'] . $aConf['table']['data_summary_ad_hourly'];
     }
     $advertiserId = $oScope->getAdvertiserId();
     $publisherId = $oScope->getPublisherId();
     $agencyId = $oScope->getAgencyId();
     $query = "\n            SELECT\n                c.campaignid AS campaign_id,\n                c.campaignname AS campaign_name,\n                c.priority AS campaign_priority,\n                c.status AS campaign_is_active,\n                c.activate_time AS campaign_start,\n                c.expire_time AS campaign_end,\n                c.views AS campaign_booked_impressions,\n                SUM(stats.impressions) AS campaign_impressions,\n                MAX(stats.date_time) AS stats_most_recent_date_time\n            FROM\n                {$aConf['table']['prefix']}{$aConf['table']['campaigns']} AS c,\n                {$aConf['table']['prefix']}{$aConf['table']['banners']} AS b,\n                " . $statsTable . " AS stats";
     if ($publisherId) {
         $query .= ",\n                {$aConf['table']['prefix']}{$aConf['table']['zones']} AS z";
     }
     if ($agencyId) {
         $query .= ",\n                {$aConf['table']['prefix']}{$aConf['table']['clients']} AS a";
     }
     $query .= "\n            WHERE\n                c.campaignid = b.campaignid\n\t\t\t\t" . $appendSqlWhere . "\n\t\t\t\tAND\n                b.bannerid = stats.ad_id";
     if ($spanIsForPlacementDates) {
         $query .= "\n                AND\n                (\n                    c.activate_time <= " . DBC::makeLiteral($oDaySpan->getEndDateStringUTC(), 'string') . "\n                    OR\n                    c.activate_time IS NULL\n                )\n                AND\n                (\n                    c.expire_time >= " . DBC::makeLiteral($oDaySpan->getStartDateStringUTC(), 'string') . "\n                    OR\n                    c.expire_time IS NULL\n                )";
     } else {
         $query .= "\n                AND\n                stats.date_time >= " . DBC::makeLiteral($oDaySpan->getStartDateStringUTC(), 'string') . "\n                AND\n                stats.date_time <= " . DBC::makeLiteral($oDaySpan->getEndDateStringUTC(), 'string') . "\n            ";
     }
     if ($advertiserId) {
         $query .= "\n                AND\n                c.clientid = " . DBC::makeLiteral($advertiserId, 'integer');
     }
     if ($publisherId) {
         $query .= "\n                AND\n                stats.zone_id = z.zoneid\n                AND\n                z.affiliateid = " . DBC::makeLiteral($publisherId, 'integer');
     }
     if ($agencyId) {
         $query .= "\n                AND\n                c.clientid = a.clientid\n                AND\n                a.agencyid = " . DBC::makeLiteral($agencyId, 'integer');
     }
     $query .= "\n            GROUP BY\n                campaign_id,\n                campaign_name,\n                campaign_priority,\n                campaign_is_active,\n                campaign_start,\n                campaign_end,\n                campaign_booked_impressions\n            ORDER BY\n                campaign_impressions";
     $rsDeliveryPerformanceData = DBC::NewRecordSet($query);
     $rsDeliveryPerformanceData->find();
     $aDeliveryPerformanceData = $rsDeliveryPerformanceData->getAll();
     return $aDeliveryPerformanceData;
 }