Example #1
0
 /**
  * Will Show the dashboard index page.
  * (non-PHPdoc)
  * @see \Zend\Mvc\Controller\AbstractActionController::indexAction()
  */
 public function indexAction()
 {
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $user_markup_rate = $this->config_handle['system']['default_demand_markup_rate'];
     $campaign_markup_rate_list = array();
     if ($this->is_super_admin) {
         // admin is logged in as a user, get the markup if any for that user
         if ($this->ImpersonateID != 0 && !empty($this->DemandCustomerInfoID)) {
             $user_markup = \util\Markup::getMarkupForUser($this->auth->getEffectiveIdentityID(), $this->config_handle, false);
             if ($user_markup != null) {
                 $user_markup_rate = $user_markup->MarkupRate;
             }
         }
     }
     $InsertionOrderFactory = \_factory\InsertionOrder::get_instance();
     $params = array();
     $params["Active"] = 1;
     // admin should see campaigns requiring approval and the user they belong to ONLY
     if ($this->is_domain_admin) {
         $params["UserID"] = $this->auth->getUserID();
     } else {
         $params["UserID"] = $this->auth->getEffectiveUserID();
     }
     $_ad_campaign_list = $InsertionOrderFactory->get($params);
     $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance();
     $ad_campaign_list = array();
     // admin should see campaigns requiring approval and the user they belong to ONLY
     foreach ($_ad_campaign_list as $ad_campaign) {
         $is_preview = \transformation\TransformPreview::doesPreviewInsertionOrderExistForInsertionOrder($ad_campaign->InsertionOrderID, $this->auth);
         if ($is_preview != true) {
             $ad_campaign_list[] = $ad_campaign;
             $ad_campaign_markup = \util\Markup::getMarkupForInsertionOrder($ad_campaign->InsertionOrderID, $this->config_handle, false);
             if ($ad_campaign_markup != null) {
                 $campaign_markup_rate_list[$ad_campaign->InsertionOrderID] = $ad_campaign_markup->MarkupRate * 100;
             } else {
                 $campaign_markup_rate_list[$ad_campaign->InsertionOrderID] = $user_markup_rate * 100;
             }
         }
     }
     // get previews
     $params = array();
     $params["Active"] = 1;
     // $params["Deleted"] = 0;
     if ($this->is_super_admin == true && $this->auth->getEffectiveIdentityID() != 0) {
         $params["UserID"] = $this->auth->getEffectiveUserID();
     } elseif ($this->is_super_admin == false) {
         $params["UserID"] = $this->auth->getUserID();
     }
     $_ad_campaign_preview_list = $InsertionOrderPreviewFactory->get($params);
     foreach ($_ad_campaign_preview_list as $ad_campaign_preview) {
         if ($ad_campaign_preview != null) {
             $ad_campaign_list[] = $ad_campaign_preview;
             if ($ad_campaign_preview->InsertionOrderID != null) {
                 $ad_campaign_markup = \util\Markup::getMarkupForInsertionOrder($ad_campaign_preview->InsertionOrderID, $this->config_handle, false);
                 if ($ad_campaign_markup != null) {
                     $campaign_markup_rate_list[$ad_campaign_preview->InsertionOrderID] = $ad_campaign_markup->MarkupRate * 100;
                 } else {
                     $campaign_markup_rate_list[$ad_campaign_preview->InsertionOrderID] = $user_markup_rate * 100;
                 }
             }
         }
     }
     $user_markup_rate *= 100;
     $view = new ViewModel(array('ad_campaigns' => $ad_campaign_list, 'is_super_admin' => $this->auth->isSuperAdmin($this->config_handle), 'is_domain_admin' => $this->auth->isDomainAdmin($this->config_handle), 'user_id_list' => $this->user_id_list_demand_customer, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'campaign_markup_rate_list' => $campaign_markup_rate_list, 'user_markup_rate' => $user_markup_rate, 'dashboard_view' => 'private-exchange', 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'is_super_admin' => $this->is_super_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID));
     if ($this->is_super_admin == false || $this->is_super_admin == true && $this->DemandCustomerInfoID != null && $this->auth->getEffectiveIdentityID() != 0) {
         $view->header_title = '<a href="/private-exchange/createinsertionorder/">Create Insertion Order</a>';
     } else {
         $view->header_title = '&nbsp;';
     }
     return $view;
 }
Example #2
0
 /**
  * Will Show the dashboard index page.
  * (non-PHPdoc)
  * @see \Zend\Mvc\Controller\AbstractActionController::indexAction()
  */
 public function indexAction()
 {
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $user_markup_rate = $this->config_handle['system']['default_demand_markup_rate'];
     $campaign_markup_rate_list = array();
     if (strpos($this->auth->getPrimaryRole(), $this->config_handle['roles']['admin']) !== false) {
         // admin is logged in as a user, get the markup if any for that user
         if ($this->auth->getEffectiveIdentityID() != 0) {
             $user_markup = \util\Markup::getMarkupForUser($this->auth->getEffectiveIdentityID());
             if ($user_markup != null) {
                 $user_markup_rate = $user_markup->MarkupRate;
             }
         }
     }
     if ($this->config_handle['system']['debug']) {
         echo "<br />\n";
         echo "My role in this application is: ";
         var_dump($this->auth->getPrimaryRole());
         echo "<br />\n";
         echo "My UserID in this application is: ";
         var_dump($this->auth->getUserID());
         echo "<br />\n";
     }
     $AdCampaignFactory = \_factory\AdCampaign::get_instance();
     $params = array();
     $params["Active"] = 1;
     // admin should see campaigns requiring approval and the user they belong to ONLY
     $params["UserID"] = $this->auth->getEffectiveUserID();
     $_ad_campaign_list = $AdCampaignFactory->get($params);
     $AdCampaignPreviewFactory = \_factory\AdCampaignPreview::get_instance();
     $ad_campaign_list = array();
     // admin should see campaigns requiring approval and the user they belong to ONLY
     foreach ($_ad_campaign_list as $ad_campaign) {
         $is_preview = \transformation\TransformPreview::doesPreviewAdCampaignExistForAdCampaign($ad_campaign->AdCampaignID, $this->auth);
         if ($is_preview != true) {
             $ad_campaign_list[] = $ad_campaign;
             $ad_campaign_markup = \util\Markup::getMarkupForAdCampaign($ad_campaign->AdCampaignID);
             if ($ad_campaign_markup != null) {
                 $campaign_markup_rate_list[$ad_campaign->AdCampaignID] = $ad_campaign_markup->MarkupRate * 100;
             } else {
                 $campaign_markup_rate_list[$ad_campaign->AdCampaignID] = $user_markup_rate * 100;
             }
         }
     }
     // get previews
     $params = array();
     $params["Active"] = 1;
     // $params["Deleted"] = 0;
     if ($this->is_admin == true && $this->auth->getEffectiveIdentityID() != 0) {
         $params["UserID"] = $this->auth->getEffectiveUserID();
     } elseif ($this->is_admin == false) {
         $params["UserID"] = $this->auth->getUserID();
     }
     $_ad_campaign_preview_list = $AdCampaignPreviewFactory->get($params);
     foreach ($_ad_campaign_preview_list as $ad_campaign_preview) {
         if ($ad_campaign_preview != null) {
             $ad_campaign_list[] = $ad_campaign_preview;
             if ($ad_campaign_preview->AdCampaignID != null) {
                 $ad_campaign_markup = \util\Markup::getMarkupForAdCampaign($ad_campaign_preview->AdCampaignID);
                 if ($ad_campaign_markup != null) {
                     $campaign_markup_rate_list[$ad_campaign_preview->AdCampaignID] = $ad_campaign_markup->MarkupRate * 100;
                 } else {
                     $campaign_markup_rate_list[$ad_campaign_preview->AdCampaignID] = $user_markup_rate * 100;
                 }
             }
         }
     }
     $user_markup_rate *= 100;
     $view = new ViewModel(array('ad_campaigns' => $ad_campaign_list, 'is_admin' => strpos($this->auth->getPrimaryRole(), $this->config_handle['roles']['admin']) !== false, 'user_id_list' => $this->user_id_list_demand_customer, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'campaign_markup_rate_list' => $campaign_markup_rate_list, 'user_markup_rate' => $user_markup_rate, 'dashboard_view' => 'demand', 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'is_admin' => $this->is_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID));
     if ($this->is_admin == false || $this->is_admin == true && $this->DemandCustomerInfoID != null && $this->auth->getEffectiveIdentityID() != 0) {
         $view->header_title = '<a href="/demand/createcampaign/">Create Campaign</a>';
     } else {
         $view->header_title = '&nbsp;';
     }
     return $view;
 }
Example #3
0
 public function privateexchangeAction()
 {
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $PrivateExchangeRtbChannelDailyStatsRollUpPxFilterFactory = \_factory\PrivateExchangeRtbChannelDailyStatsRollUpPxFilter::get_instance();
     $params = array();
     if ($this->auth->isSuperAdmin($this->config_handle)) {
         $params["ParentID"] = $this->auth->getEffectiveIdentityID();
     } else {
         $params["ParentID"] = $this->auth->getUserID();
     }
     $PrivateExchangeRtbChannelDailyStatsRollUpPxFilterList = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilterFactory->get($params);
     $insertion_order_id = $this->getRequest()->getQuery('insertion-order-id');
     if ($insertion_order_id != null) {
         $insertion_order_id = intval($insertion_order_id);
         $markup_rate = \util\Markup::getMarkupRateByInsertionOrderIDAndUserID($insertion_order_id, $this->auth->getEffectiveIdentityID(), $this->config_handle);
     } else {
         $user_markup = \util\Markup::getMarkupForUser($this->auth->getEffectiveIdentityID(), $this->config_handle, false);
         if ($user_markup != null) {
             $markup_rate = $user_markup->MarkupRate;
         } else {
             $markup_rate = $this->config_handle['system']['default_demand_markup_rate'];
         }
     }
     $data = array();
     $PublisherWebsiteFactory = \_factory\PublisherWebsite::get_instance();
     foreach ($PrivateExchangeRtbChannelDailyStatsRollUpPxFilterList as $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter) {
         $site_id = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->PublisherWebsiteID;
         $site_name = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->RtbChannelSiteName;
         if (strlen($site_name) > 20) {
             $site_name = substr($site_name, 0, 20) . '&hellip;';
         }
         $publisher_name = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->PublisherName;
         if (strlen($publisher_name) > 20) {
             $publisher_name = substr($publisher_name, 0, 20) . '&hellip;';
         }
         $label_name = $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->WebDomain . " - " . $site_name . " - " . $publisher_name;
         $adusted_floor_price = "";
         if ($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BidFloor) {
             $floor_price = floatval($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BidFloor);
             $params = array();
             $params["PublisherWebsiteID"] = $site_id;
             $PublisherWebsite = $PublisherWebsiteFactory->get_row_cached($this->config_handle, $params);
             if ($PublisherWebsite == null) {
                 continue;
             }
             // floor should be marked up by the private exchange domain admin rate for this publisher and website
             $px_markup_rate_for_publisher = \util\Markup::getPrivateExchangePublisherMarkupRate($site_id, $PublisherWebsite->DomainOwnerID, $this->config_handle);
             $mark_up = $floor_price * floatval($px_markup_rate_for_publisher);
             $adusted_floor_price = floatval($floor_price) + floatval($mark_up);
             // floor should be marked up by the global exchange rate for this publisher and website
             $exchange_markup_rate_for_publisher = \util\Markup::getPublisherMarkupRate($site_id, $PublisherWebsite->DomainOwnerID, $this->config_handle);
             $mark_up = $adusted_floor_price * floatval($exchange_markup_rate_for_publisher);
             $adusted_floor_price = floatval($adusted_floor_price) + floatval($mark_up);
             // floor should be marked up by the IO markup rate
             // Approximation: actual implementation is mark-down in buyrtb\workflows\OpenRTBWorkflow
             $mark_up = $adusted_floor_price * floatval($markup_rate);
             $adusted_floor_price = floatval($adusted_floor_price) + floatval($mark_up);
             $adusted_floor_price = sprintf("%1.2f", $adusted_floor_price);
         }
         $row = array(" " => '<input type="checkbox" labelname="' . rawurlencode($label_name) . '" class="ckssp" name="ckssp[]" value="' . rawurlencode($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->PublisherWebsiteID . '::' . $label_name) . '" />', "Site ID" => $site_id, "Domain" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->WebDomain, "Name" => $site_name, "IAB Cat" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->IABCategory, "Daily Imps" => number_format($PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->ImpressionsOfferedCounter), "Average CPM" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BidTotalAverage, "Floor" => $adusted_floor_price, "Exchange" => $PrivateExchangeRtbChannelDailyStatsRollUpPxFilter->BuySidePartnerName);
         $data[] = $row;
     }
     $this->setJsonHeader();
     return $this->getResponse()->setContent(json_encode(array("data" => $data)));
 }