Ejemplo n.º 1
0
 /**
  * 
  * @return \Zend\View\Model\ViewModel
  */
 public function editlineitemAction()
 {
     $id = $this->getEvent()->getRouteMatch()->getParam('param1');
     if ($id == null) {
         die("Invalid Banner ID");
     }
     $initialized = $this->initialize();
     if ($initialized !== true) {
         return $initialized;
     }
     $is_preview = $this->getRequest()->getQuery('ispreview');
     // verify
     if ($is_preview == "true") {
         $is_preview = \transformation\TransformPreview::doesPreviewBannerExist($id, $this->auth);
     }
     $banner_preview_id = "";
     if ($is_preview == true) {
         // ACL PREVIEW PERMISSIONS CHECK
         transformation\CheckPermissions::checkEditPermissionInsertionOrderLineItemPreview($id, $this->auth, $this->config_handle);
         $InsertionOrderLineItemVideoRestrictionsPreviewFactory = \_factory\InsertionOrderLineItemVideoRestrictionsPreview::get_instance();
         $params = array();
         $params["InsertionOrderLineItemPreviewID"] = $id;
         $InsertionOrderLineItemVideoRestrictions = $InsertionOrderLineItemVideoRestrictionsPreviewFactory->get_row($params);
         $InsertionOrderLineItemPreviewFactory = \_factory\InsertionOrderLineItemPreview::get_instance();
         $params = array();
         $params["Active"] = 1;
         $params["InsertionOrderLineItemPreviewID"] = $id;
         $banner_preview_id = $id;
         $InsertionOrderLineItem = $InsertionOrderLineItemPreviewFactory->get_row($params);
         $PmpDealPublisherWebsiteToInsertionOrderLineItemPreviewFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderLineItemPreview::get_instance();
         $params = array();
         $params["InsertionOrderLineItemPreviewID"] = $banner_preview_id;
         $PmpDealPublisherWebsiteToInsertionOrderLineItemList = $PmpDealPublisherWebsiteToInsertionOrderLineItemPreviewFactory->get($params);
         $SspRtbChannelToInsertionOrderLineItemPreviewFactory = \_factory\SspRtbChannelToInsertionOrderLineItemPreview::get_instance();
         $params = array();
         $params["InsertionOrderLineItemPreviewID"] = $banner_preview_id;
         $SspRtbChannelToInsertionOrderLineItemList = $SspRtbChannelToInsertionOrderLineItemPreviewFactory->get($params);
     } else {
         // ACL PERMISSIONS CHECK
         transformation\CheckPermissions::checkEditPermissionInsertionOrderLineItem($id, $this->auth, $this->config_handle);
         $InsertionOrderLineItemVideoRestrictionsFactory = \_factory\InsertionOrderLineItemVideoRestrictions::get_instance();
         $params = array();
         $params["InsertionOrderLineItemID"] = $id;
         $InsertionOrderLineItemVideoRestrictions = $InsertionOrderLineItemVideoRestrictionsFactory->get_row($params);
         $InsertionOrderLineItemFactory = \_factory\InsertionOrderLineItem::get_instance();
         $params = array();
         $params["Active"] = 1;
         $params["InsertionOrderLineItemID"] = $id;
         $InsertionOrderLineItem = $InsertionOrderLineItemFactory->get_row($params);
         $PmpDealPublisherWebsiteToInsertionOrderLineItemFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderLineItem::get_instance();
         $params = array();
         $params["InsertionOrderLineItemID"] = $id;
         $PmpDealPublisherWebsiteToInsertionOrderLineItemList = $PmpDealPublisherWebsiteToInsertionOrderLineItemFactory->get($params);
         $SspRtbChannelToInsertionOrderLineItemFactory = \_factory\SspRtbChannelToInsertionOrderLineItem::get_instance();
         $params = array();
         $params["InsertionOrderLineItemID"] = $id;
         $SspRtbChannelToInsertionOrderLineItemList = $SspRtbChannelToInsertionOrderLineItemFactory->get($params);
     }
     if ($InsertionOrderLineItem == null) {
         die("Invalid {$InsertionOrderLineItem} ID");
     }
     $campaignid = isset($InsertionOrderLineItem->InsertionOrderID) ? $InsertionOrderLineItem->InsertionOrderID : "";
     $bannerid = isset($InsertionOrderLineItem->InsertionOrderLineItemID) ? $InsertionOrderLineItem->InsertionOrderLineItemID : "";
     $campaignpreviewid = isset($InsertionOrderLineItem->InsertionOrderPreviewID) ? $InsertionOrderLineItem->InsertionOrderPreviewID : "";
     $bannerpreviewid = isset($InsertionOrderLineItem->InsertionOrderLineItemPreviewID) ? $InsertionOrderLineItem->InsertionOrderLineItemPreviewID : "";
     $bannername = $InsertionOrderLineItem->Name;
     $startdate = date('m/d/Y', strtotime($InsertionOrderLineItem->StartDate));
     $enddate = date('m/d/Y', strtotime($InsertionOrderLineItem->EndDate));
     $current_mobile = $InsertionOrderLineItem->IsMobile;
     if ($InsertionOrderLineItem->IsMobile == 2) {
         $size_list = \util\BannerOptions::$iab_mobile_tablet_banner_options;
     } elseif ($InsertionOrderLineItem->IsMobile > 0) {
         $size_list = \util\BannerOptions::$iab_mobile_phone_banner_options;
     } else {
         $size_list = \util\BannerOptions::$iab_banner_options;
     }
     $height = $InsertionOrderLineItem->Height;
     $width = $InsertionOrderLineItem->Width;
     $weight = $InsertionOrderLineItem->Weight;
     $bidamount = $InsertionOrderLineItem->BidAmount;
     $adtag = $InsertionOrderLineItem->AdTag;
     $landingpagetld = $InsertionOrderLineItem->LandingPageTLD;
     $current_iabsize = $InsertionOrderLineItem->IABSize;
     $ImpressionType = $InsertionOrderLineItem->ImpressionType;
     if ($ImpressionType == 'image') {
         preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $adtag, $matches);
         if (!isset($matches[1])) {
             die("Required Field: <img src= attribute was missing");
         }
         preg_match('/href=[\'"]?([^\\s\\>\'"]*)[\'"\\>]/', $adtag, $matches);
         if (!isset($matches[1])) {
             die("Required Field: <a href= attribute was missing");
         }
     }
     $current_mimes = array();
     $current_apis_supported = array();
     $current_protocols = array();
     $current_delivery_methods = array();
     $current_playback_methods = array();
     $current_start_delay = "";
     $current_linearity = "";
     $impression_type = "banner";
     if ($InsertionOrderLineItemVideoRestrictions != null) {
         $current_mimes_raw = $InsertionOrderLineItemVideoRestrictions->MimesCommaSeparated;
         $current_apis_supported_raw = $InsertionOrderLineItemVideoRestrictions->ApisSupportedCommaSeparated;
         $current_protocols_raw = $InsertionOrderLineItemVideoRestrictions->ProtocolsCommaSeparated;
         $current_delivery_methods_raw = $InsertionOrderLineItemVideoRestrictions->DeliveryCommaSeparated;
         $current_playback_methods_raw = $InsertionOrderLineItemVideoRestrictions->PlaybackCommaSeparated;
         $current_start_delay = $InsertionOrderLineItemVideoRestrictions->StartDelay;
         $current_linearity = $InsertionOrderLineItemVideoRestrictions->Linearity;
         $current_mimes = array();
         if ($current_mimes_raw) {
             $current_mimes = explode(',', $current_mimes_raw);
         }
         $current_apis_supported = array();
         if ($current_apis_supported_raw) {
             $current_apis_supported = explode(',', $current_apis_supported_raw);
         }
         $current_protocols = array();
         if ($current_protocols_raw) {
             $current_protocols = explode(',', $current_protocols_raw);
         }
         $current_delivery_methods = array();
         if ($current_delivery_methods_raw) {
             $current_delivery_methods = explode(',', $current_delivery_methods_raw);
         }
         $current_playback_methods = array();
         if ($current_playback_methods_raw) {
             $current_playback_methods = explode(',', $current_playback_methods_raw);
         }
     }
     $is_vast_url = \util\ParseHelper::isVastURL($adtag);
     $vast_type = $is_vast_url == true ? "url" : "xml";
     $imageurl = "";
     $landingpageurl = "";
     if ($ImpressionType == "image") {
         preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $adtag, $matches);
         if (isset($matches[1])) {
             $imageurl = $matches[1];
         }
         preg_match('/href=[\'"]?([^\\s\\>\'"]*)[\'"\\>]/', $adtag, $matches);
         if (isset($matches[1])) {
             $landingpageurl = $matches[1];
         }
     }
     return new ViewModel(array('imageurl' => $imageurl, 'landingpageurl' => $landingpageurl, 'campaignid' => $campaignid, 'bannerid' => $bannerid, 'pmp_deal_list' => $PmpDealPublisherWebsiteToInsertionOrderLineItemList, 'ssp_channel_list' => $SspRtbChannelToInsertionOrderLineItemList, 'campaignpreviewid' => $campaignpreviewid, 'bannerpreviewid' => $bannerpreviewid, 'ispreview' => $is_preview == true ? '1' : '0', 'bannername' => $bannername, 'startdate' => $startdate, 'enddate' => $enddate, 'current_mobile' => $current_mobile, 'mobile_options' => \util\BannerOptions::$mobile_options, 'size_list' => $size_list, 'height' => $height, 'width' => $width, 'weight' => $weight, 'bidamount' => $bidamount, 'adtag' => $adtag, 'vast_type' => $vast_type, 'landingpagetld' => $landingpagetld, 'current_iabsize' => $current_iabsize, 'bread_crumb_info' => $this->getBreadCrumbInfoFromBanner($bannerid, $bannerpreviewid, $is_preview), 'user_id_list' => $this->user_id_list_demand_customer, 'center_class' => 'centerj', 'user_identity' => $this->identity(), 'true_user_name' => $this->auth->getUserName(), 'header_title' => 'Edit Insertion Order', 'is_super_admin' => $this->is_super_admin, 'effective_id' => $this->auth->getEffectiveIdentityID(), 'impersonate_id' => $this->ImpersonateID, 'ImpressionType' => $ImpressionType, 'linearity' => \util\BannerOptions::$linearity, 'start_delay' => \util\BannerOptions::$start_delay, 'playback_methods' => \util\BannerOptions::$playback_methods, 'delivery_methods' => \util\BannerOptions::$delivery_methods, 'apis_supported' => \util\BannerOptions::$apis_supported, 'protocols' => \util\BannerOptions::$protocols, 'mimes' => \util\BannerOptions::$mimes, 'current_mimes' => $current_mimes, 'current_apis_supported' => $current_apis_supported, 'current_protocols' => $current_protocols, 'current_delivery_methods' => $current_delivery_methods, 'current_playback_methods' => $current_playback_methods, 'current_start_delay' => $current_start_delay, 'current_linearity' => $current_linearity, 'impression_type' => $impression_type));
 }
Ejemplo n.º 2
0
 public function process_business_rules_workflow($logger, $config, $rtb_seat_id, &$no_bid_reason, \model\openrtb\RtbBidRequest &$RtbBidRequest)
 {
     $this->config = $config;
     $this->rtb_seat_id = $rtb_seat_id;
     // $logger = \rtbbuyv22\RtbBuyV22Logger::get_instance();
     $InsertionOrderLineItem_Match_List = array();
     $InsertionOrderFactory = \_factory\InsertionOrder::get_instance();
     $params = array();
     $params["Active"] = 1;
     $InsertionOrderList = $InsertionOrderFactory->get_cached($this->config, $params);
     $this->current_time = time();
     $InsertionOrderLineItemFactory = \_factory\InsertionOrderLineItem::get_instance();
     $InsertionOrderLineItemDomainExclusionFactory = \_factory\InsertionOrderLineItemDomainExclusion::get_instance();
     $InsertionOrderLineItemExclusiveInclusionFactory = \_factory\InsertionOrderLineItemDomainExclusiveInclusion::get_instance();
     $InsertionOrderLineItemRestrictionsFactory = \_factory\InsertionOrderLineItemRestrictions::get_instance();
     $InsertionOrderLineItemVideoRestrictionsFactory = \_factory\InsertionOrderLineItemVideoRestrictions::get_instance();
     // match ip against country code
     \buyrtb\workflows\tasklets\common\insertionorder\GetGeoCodeCountry::execute($logger, $this, $RtbBidRequest);
     foreach ($InsertionOrderList as $InsertionOrder) {
         // Check campaign date
         if (\buyrtb\workflows\tasklets\common\insertionorder\CheckCampaignDate::execute($logger, $this, $RtbBidRequest, $InsertionOrder) === false) {
             continue;
         }
         // Check max spend
         if (\buyrtb\workflows\tasklets\common\insertionorder\CheckMaxSpend::execute($logger, $this, $RtbBidRequest, $InsertionOrder) === false) {
             continue;
         }
         // Check max impressions
         if (\buyrtb\workflows\tasklets\common\insertionorder\CheckMaxImpressions::execute($logger, $this, $RtbBidRequest, $InsertionOrder) === false) {
             continue;
         }
         // get markup rate for ad campaign
         $markup_rate = \util\Markup::getMarkupRate($InsertionOrder, $this->config);
         // iterate the active banners for this ad campaign
         $params = array();
         $params["InsertionOrderID"] = $InsertionOrder->InsertionOrderID;
         $params["Active"] = 1;
         $InsertionOrderLineItemList = $InsertionOrderLineItemFactory->get_cached($this->config, $params);
         foreach ($RtbBidRequest->RtbBidRequestImpList as $RtbBidRequestImp) {
             foreach ($InsertionOrderLineItemList as $InsertionOrderLineItem) {
                 if (empty($RtbBidRequestImp->RtbBidRequestVideo) && $InsertionOrderLineItem->ImpressionType == 'video' || !empty($RtbBidRequestImp->RtbBidRequestVideo) && ($InsertionOrderLineItem->ImpressionType == 'banner' || $InsertionOrderLineItem->ImpressionType == 'image')) {
                     continue;
                 }
                 /*
                  * check the business rules against the banner
                  */
                 // Check PMP
                 if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckPrivateMarketPlace::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem) === false) {
                     continue;
                 }
                 // Check Domain Admin SSP Channel Selections
                 if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckSspChannelSelections::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem) === false) {
                     continue;
                 }
                 // Check banner date
                 if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckBannerDate::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem) === false) {
                     continue;
                 }
                 // Check impression price floor
                 if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckPriceFloor::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $markup_rate) === false) {
                     continue;
                 }
                 // Check banner domain exclusive inclusions
                 if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckExclusiveInclusion::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemExclusiveInclusionFactory) === false) {
                     continue;
                 }
                 // Check banner domain exclusions match
                 if (\buyrtb\workflows\tasklets\common\insertionorderlineitem\CheckDomainExclusion::execute($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemDomainExclusionFactory) === false) {
                     continue;
                 }
                 if (!empty($RtbBidRequestImp->RtbBidRequestVideo)) {
                     // Video Workflow
                     $VideoWorkflow = new \buyrtb\workflows\VideoWorkflow();
                     $passed_child_workflow = $VideoWorkflow->process_business_rules_workflow($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemVideoRestrictionsFactory);
                 } else {
                     // Display Banner Workflow - Default [ banner/ad tag/image creative types ]
                     $DisplayWorkflow = new \buyrtb\workflows\DisplayWorkflow();
                     $passed_child_workflow = $DisplayWorkflow->process_business_rules_workflow($logger, $this, $RtbBidRequest, $RtbBidRequestImp, $InsertionOrderLineItem, $InsertionOrderLineItemRestrictionsFactory);
                 }
                 if ($passed_child_workflow === false) {
                     continue;
                 }
                 /*
                  * PASSED ALL THE BUSINESS RULES, ADD TO THE RESULTS
                  */
                 $InsertionOrderLineItemFactory->incrementInsertionOrderLineItemBidsCounterCached($this->config, $rtb_seat_id, $InsertionOrderLineItem->InsertionOrderLineItemID);
                 /*
                  * Adjust the bid rate according to the markup
                  */
                 $mark_down = floatval($InsertionOrderLineItem->BidAmount) * floatval($markup_rate);
                 $adusted_amount = floatval($InsertionOrderLineItem->BidAmount) - floatval($mark_down);
                 $InsertionOrderLineItem->BidAmount = sprintf("%1.4f", $adusted_amount);
                 // default in config
                 $currency = $this->config['settings']['rtb']['auction_currency'];
                 if (isset($RtbBidRequest->cur[0])) {
                     $currency = $RtbBidRequest->cur[0];
                 }
                 $InsertionOrderLineItem_Match_List[(string) $InsertionOrderLineItem->UserID][] = array("currency" => $currency, "impid" => $RtbBidRequestImp->id, "InsertionOrderLineItem" => $InsertionOrderLineItem);
             }
         }
     }
     if (count($InsertionOrderLineItem_Match_List)) {
         // Check Publisher Score
         if (\buyrtb\workflows\tasklets\common\thirdparty\CheckPublisherScore::execute($logger, $this, $RtbBidRequest) === false) {
             $no_bid_reason = NOBID_BAD_PUBLISHER;
             return array();
         }
         // Check Ad Fraud
         if (\buyrtb\workflows\tasklets\common\thirdparty\CheckAdFraud::execute($logger, $this, $RtbBidRequest) === false) {
             $no_bid_reason = NOBID_AD_FRAUD;
             return array();
         }
         // Check Cookie Match
         if (\buyrtb\workflows\tasklets\common\thirdparty\CheckCookieMatch::execute($logger, $this, $RtbBidRequest) === false) {
             $no_bid_reason = NOBID_UNMATCHED_USER;
             return array();
         }
     }
     return $InsertionOrderLineItem_Match_List;
 }
Ejemplo n.º 3
0
 public static function cloneInsertionOrderIntoInsertionOrderPreview($ad_campaign_id, $auth, $config, $mail_transport, $update_data)
 {
     $return_val = array();
     if ($ad_campaign_id === null) {
         return null;
     }
     $InsertionOrderFactory = \_factory\InsertionOrder::get_instance();
     $params = array();
     $params["InsertionOrderID"] = $ad_campaign_id;
     if (!$auth->isSuperAdmin($config)) {
         $params["UserID"] = $auth->getUserID();
     }
     $params["Active"] = 1;
     $InsertionOrder = $InsertionOrderFactory->get_row($params);
     if ($InsertionOrder == null) {
         //die("Invalid InsertionOrder ID");
         $params["error"] = "Invalid InsertionOrder ID";
         return $params;
     }
     /*
      * Clone InsertionOrder into InsertionOrderPreview
      */
     $InsertionOrderPreviewFactory = \_factory\InsertionOrderPreview::get_instance();
     $InsertionOrderPreview = new \model\InsertionOrderPreview();
     $InsertionOrderPreview->InsertionOrderID = $InsertionOrder->InsertionOrderID;
     $InsertionOrderPreview->UserID = $InsertionOrder->UserID;
     $InsertionOrderPreview->Name = $InsertionOrder->Name;
     $InsertionOrderPreview->StartDate = $InsertionOrder->StartDate;
     $InsertionOrderPreview->EndDate = $InsertionOrder->EndDate;
     $InsertionOrderPreview->Customer = $InsertionOrder->Customer;
     $InsertionOrderPreview->CustomerID = $InsertionOrder->CustomerID;
     $InsertionOrderPreview->ImpressionsCounter = 0;
     $InsertionOrderPreview->MaxImpressions = $InsertionOrder->MaxImpressions;
     $InsertionOrderPreview->CurrentSpend = 0;
     $InsertionOrderPreview->MaxSpend = $InsertionOrder->MaxSpend;
     $InsertionOrderPreview->Active = 1;
     $InsertionOrderPreview->DateCreated = date("Y-m-d H:i:s");
     $InsertionOrderPreview->DateUpdated = date("Y-m-d H:i:s");
     $InsertionOrderPreview->ChangeWentLive = 0;
     $InsertionOrderPreview->WentLiveDate = '0000-00-00 00:00:00';
     $InsertionOrderPreviewID = $InsertionOrderPreviewFactory->saveInsertionOrderPreview($InsertionOrderPreview);
     if ($update_data['type'] == 'InsertionOrderID') {
         $return_val = array('InsertionOrderPreviewID' => $InsertionOrderPreviewID);
     }
     $InsertionOrderLineItemFactory = \_factory\InsertionOrderLineItem::get_instance();
     $params = array();
     $params["InsertionOrderID"] = $InsertionOrder->InsertionOrderID;
     $params["Active"] = 1;
     $InsertionOrderLineItemList = $InsertionOrderLineItemFactory->get($params);
     $InsertionOrderLineItemPreviewFactory = \_factory\InsertionOrderLineItemPreview::get_instance();
     $InsertionOrderLineItemRestrictionsFactory = \_factory\InsertionOrderLineItemRestrictions::get_instance();
     $InsertionOrderLineItemRestrictionsPreviewFactory = \_factory\InsertionOrderLineItemRestrictionsPreview::get_instance();
     $InsertionOrderLineItemVideoRestrictionsFactory = \_factory\InsertionOrderLineItemVideoRestrictions::get_instance();
     $InsertionOrderLineItemVideoRestrictionsPreviewFactory = \_factory\InsertionOrderLineItemVideoRestrictionsPreview::get_instance();
     $InsertionOrderLineItemDomainExclusionFactory = \_factory\InsertionOrderLineItemDomainExclusion::get_instance();
     $InsertionOrderLineItemDomainExclusionPreviewFactory = \_factory\InsertionOrderLineItemDomainExclusionPreview::get_instance();
     $InsertionOrderLineItemDomainExclusiveInclusionFactory = \_factory\InsertionOrderLineItemDomainExclusiveInclusion::get_instance();
     $InsertionOrderLineItemDomainExclusiveInclusionPreviewFactory = \_factory\InsertionOrderLineItemDomainExclusiveInclusionPreview::get_instance();
     $SspRtbChannelToInsertionOrderLineItemPreviewFactory = \_factory\SspRtbChannelToInsertionOrderLineItemPreview::get_instance();
     $SspRtbChannelToInsertionOrderLineItemFactory = \_factory\SspRtbChannelToInsertionOrderLineItem::get_instance();
     $PmpDealPublisherWebsiteToInsertionOrderLineItemFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderLineItem::get_instance();
     $PmpDealPublisherWebsiteToInsertionOrderLineItemPreviewFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderLineItemPreview::get_instance();
     $SspRtbChannelToInsertionOrderPreviewFactory = \_factory\SspRtbChannelToInsertionOrderPreview::get_instance();
     $SspRtbChannelToInsertionOrderFactory = \_factory\SspRtbChannelToInsertionOrder::get_instance();
     $PmpDealPublisherWebsiteToInsertionOrderFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrder::get_instance();
     $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory = \_factory\PmpDealPublisherWebsiteToInsertionOrderPreview::get_instance();
     /*
      * PMP INVENTORY
      */
     $params = array();
     $params["InsertionOrderID"] = $InsertionOrder->InsertionOrderID;
     $PmpDealPublisherWebsiteToInsertionOrder = $PmpDealPublisherWebsiteToInsertionOrderFactory->get_row($params);
     if ($PmpDealPublisherWebsiteToInsertionOrder != null) {
         $PmpDealPublisherWebsiteToInsertionOrderPreview = new \model\PmpDealPublisherWebsiteToInsertionOrderPreview();
         $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteID = $PmpDealPublisherWebsiteToInsertionOrder->PublisherWebsiteID;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteLocal = $PmpDealPublisherWebsiteToInsertionOrder->PublisherWebsiteLocal;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->PublisherWebsiteDescription = $PmpDealPublisherWebsiteToInsertionOrder->PublisherWebsiteDescription;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->InsertionOrderPreviewID = $InsertionOrderPreviewID;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->Enabled = $PmpDealPublisherWebsiteToInsertionOrder->Enabled;
         $PmpDealPublisherWebsiteToInsertionOrderPreview->DateCreated = date("Y-m-d H:i:s");
         $PmpDealPublisherWebsiteToInsertionOrderPreview->DateUpdated = date("Y-m-d H:i:s");
         $PmpDealPublisherWebsiteToInsertionOrderPreviewFactory->savePmpDealPublisherWebsiteToInsertionOrderPreview($PmpDealPublisherWebsiteToInsertionOrderPreview);
     }
     /*
      * SSP INVENTORY
      */
     $params = array();
     $params["InsertionOrderID"] = $InsertionOrder->InsertionOrderID;
     $SspRtbChannelToInsertionOrder = $SspRtbChannelToInsertionOrderFactory->get_row($params);
     if ($SspRtbChannelToInsertionOrder != null) {
         $SspRtbChannelToInsertionOrderPreview = new \model\SspRtbChannelToInsertionOrderPreview();
         $SspRtbChannelToInsertionOrderPreview->SspPublisherChannelID = $SspRtbChannelToInsertionOrder->SspPublisherChannelID;
         $SspRtbChannelToInsertionOrderPreview->SspPublisherChannelDescription = $SspRtbChannelToInsertionOrder->SspPublisherChannelDescription;
         $SspRtbChannelToInsertionOrderPreview->SspExchange = $SspRtbChannelToInsertionOrder->SspExchange;
         $SspRtbChannelToInsertionOrderPreview->InsertionOrderPreviewID = $InsertionOrderPreviewID;
         $SspRtbChannelToInsertionOrderPreview->Enabled = $SspRtbChannelToInsertionOrder->Enabled;
         $SspRtbChannelToInsertionOrderPreview->DateCreated = date("Y-m-d H:i:s");
         $SspRtbChannelToInsertionOrderPreview->DateUpdated = date("Y-m-d H:i:s");
         $SspRtbChannelToInsertionOrderPreviewFactory->saveSspRtbChannelToInsertionOrderPreview($SspRtbChannelToInsertionOrderPreview);
     }
     foreach ($InsertionOrderLineItemList as $InsertionOrderLineItem) {
         $banner_id = $InsertionOrderLineItem->InsertionOrderLineItemID;
         $BannerPreview = new \model\InsertionOrderLineItemPreview();
         $BannerPreview->InsertionOrderPreviewID = $InsertionOrderPreviewID;
         $BannerPreview->InsertionOrderLineItemID = $InsertionOrderLineItem->InsertionOrderLineItemID;
         $BannerPreview->UserID = $InsertionOrderLineItem->UserID;
         $BannerPreview->Name = $InsertionOrderLineItem->Name;
         $BannerPreview->ImpressionType = $InsertionOrderLineItem->ImpressionType;
         $BannerPreview->StartDate = $InsertionOrderLineItem->StartDate;
         $BannerPreview->EndDate = $InsertionOrderLineItem->EndDate;
         $BannerPreview->IsMobile = $InsertionOrderLineItem->IsMobile;
         $BannerPreview->IABSize = $InsertionOrderLineItem->IABSize;
         $BannerPreview->Height = $InsertionOrderLineItem->Height;
         $BannerPreview->Width = $InsertionOrderLineItem->Width;
         $BannerPreview->Weight = $InsertionOrderLineItem->Weight;
         $BannerPreview->BidAmount = $InsertionOrderLineItem->BidAmount;
         $BannerPreview->AdTag = $InsertionOrderLineItem->AdTag;
         $BannerPreview->DeliveryType = $InsertionOrderLineItem->DeliveryType;
         $BannerPreview->LandingPageTLD = $InsertionOrderLineItem->LandingPageTLD;
         $BannerPreview->ImpressionsCounter = $InsertionOrderLineItem->ImpressionsCounter;
         $BannerPreview->BidsCounter = $InsertionOrderLineItem->BidsCounter;
         $BannerPreview->CurrentSpend = $InsertionOrderLineItem->CurrentSpend;
         $BannerPreview->Active = $InsertionOrderLineItem->Active;
         $BannerPreview->DateCreated = date("Y-m-d H:i:s");
         $BannerPreview->DateUpdated = date("Y-m-d H:i:s");
         $BannerPreview->ChangeWentLive = 0;
         $BannerPreview->WentLiveDate = '0000-00-00 00:00:00';
         $InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewFactory->saveInsertionOrderLineItemPreview($BannerPreview);
         if ($update_data['type'] == 'InsertionOrderLineItemID' && $update_data['id'] == $banner_id) {
             $return_val = array('InsertionOrderLineItemPreviewID' => $InsertionOrderLineItemPreviewID, 'InsertionOrderPreviewID' => $InsertionOrderPreviewID);
         }
         if ($BannerPreview->ImpressionType == 'video') {
             /*
              * VIDEO RESTRICTIONS
              */
             $params = array();
             $params["InsertionOrderLineItemID"] = $banner_id;
             $InsertionOrderLineItemVideoRestrictions = $InsertionOrderLineItemVideoRestrictionsFactory->get_row($params);
             if ($InsertionOrderLineItemVideoRestrictions != null) {
                 $VideoRestrictionsPreview = new \model\InsertionOrderLineItemVideoRestrictionsPreview();
                 $VideoRestrictionsPreview->InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewID;
                 $VideoRestrictionsPreview->GeoCountry = $InsertionOrderLineItemVideoRestrictions->GeoCountry;
                 $VideoRestrictionsPreview->GeoState = $InsertionOrderLineItemVideoRestrictions->GeoState;
                 $VideoRestrictionsPreview->GeoCity = $InsertionOrderLineItemVideoRestrictions->GeoCity;
                 $VideoRestrictionsPreview->MimesCommaSeparated = $InsertionOrderLineItemVideoRestrictions->MimesCommaSeparated;
                 $VideoRestrictionsPreview->MinDuration = $InsertionOrderLineItemVideoRestrictions->MinDuration;
                 $VideoRestrictionsPreview->MaxDuration = $InsertionOrderLineItemVideoRestrictions->MaxDuration;
                 $VideoRestrictionsPreview->ApisSupportedCommaSeparated = $InsertionOrderLineItemVideoRestrictions->ApisSupportedCommaSeparated;
                 $VideoRestrictionsPreview->ProtocolsCommaSeparated = $InsertionOrderLineItemVideoRestrictions->ProtocolsCommaSeparated;
                 $VideoRestrictionsPreview->DeliveryCommaSeparated = $InsertionOrderLineItemVideoRestrictions->DeliveryCommaSeparated;
                 $VideoRestrictionsPreview->PlaybackCommaSeparated = $InsertionOrderLineItemVideoRestrictions->PlaybackCommaSeparated;
                 $VideoRestrictionsPreview->StartDelay = $InsertionOrderLineItemVideoRestrictions->StartDelay;
                 $VideoRestrictionsPreview->Linearity = $InsertionOrderLineItemVideoRestrictions->Linearity;
                 $VideoRestrictionsPreview->FoldPos = $InsertionOrderLineItemVideoRestrictions->FoldPos;
                 $VideoRestrictionsPreview->MinHeight = $InsertionOrderLineItemVideoRestrictions->MinHeight;
                 $VideoRestrictionsPreview->MinWidth = $InsertionOrderLineItemVideoRestrictions->MinWidth;
                 $VideoRestrictionsPreview->Secure = $InsertionOrderLineItemVideoRestrictions->Secure;
                 $VideoRestrictionsPreview->Optout = $InsertionOrderLineItemVideoRestrictions->Optout;
                 $VideoRestrictionsPreview->Vertical = $InsertionOrderLineItemVideoRestrictions->Vertical;
                 $VideoRestrictionsPreview->DateCreated = date("Y-m-d H:i:s");
                 $VideoRestrictionsPreview->DateUpdated = date("Y-m-d H:i:s");
                 $InsertionOrderLineItemVideoRestrictionsPreviewID = $InsertionOrderLineItemVideoRestrictionsPreviewFactory->saveInsertionOrderLineItemVideoRestrictionsPreview($VideoRestrictionsPreview);
                 if ($update_data['type'] == 'InsertionOrderLineItemVideoRestrictionsID' && $update_data['id'] == $InsertionOrderLineItemVideoRestrictions->InsertionOrderLineItemVideoRestrictionsID) {
                     $return_val = array('InsertionOrderLineItemVideoRestrictionsPreviewID' => $InsertionOrderLineItemVideoRestrictionsPreviewID, 'InsertionOrderLineItemPreviewID' => $InsertionOrderLineItemPreviewID, 'InsertionOrderPreviewID' => $InsertionOrderPreviewID);
                 }
             }
         } else {
             /*
              * BANNER RESTRICTIONS
              */
             $params = array();
             $params["InsertionOrderLineItemID"] = $banner_id;
             $InsertionOrderLineItemRestrictions = $InsertionOrderLineItemRestrictionsFactory->get_row($params);
             // may not be present
             if ($InsertionOrderLineItemRestrictions != null) {
                 $BannerRestrictionsPreview = new \model\InsertionOrderLineItemRestrictionsPreview();
                 $BannerRestrictionsPreview->InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewID;
                 $BannerRestrictionsPreview->GeoCountry = $InsertionOrderLineItemRestrictions->GeoCountry;
                 $BannerRestrictionsPreview->GeoState = $InsertionOrderLineItemRestrictions->GeoState;
                 $BannerRestrictionsPreview->GeoCity = $InsertionOrderLineItemRestrictions->GeoCity;
                 $BannerRestrictionsPreview->AdTagType = $InsertionOrderLineItemRestrictions->AdTagType;
                 $BannerRestrictionsPreview->AdPositionMinLeft = $InsertionOrderLineItemRestrictions->AdPositionMinLeft;
                 $BannerRestrictionsPreview->AdPositionMaxLeft = $InsertionOrderLineItemRestrictions->AdPositionMaxLeft;
                 $BannerRestrictionsPreview->AdPositionMinTop = $InsertionOrderLineItemRestrictions->AdPositionMinTop;
                 $BannerRestrictionsPreview->AdPositionMaxTop = $InsertionOrderLineItemRestrictions->AdPositionMaxTop;
                 $BannerRestrictionsPreview->FoldPos = $InsertionOrderLineItemRestrictions->FoldPos;
                 $BannerRestrictionsPreview->Freq = $InsertionOrderLineItemRestrictions->Freq;
                 $BannerRestrictionsPreview->Timezone = $InsertionOrderLineItemRestrictions->Timezone;
                 $BannerRestrictionsPreview->InIframe = $InsertionOrderLineItemRestrictions->InIframe;
                 $BannerRestrictionsPreview->MinScreenResolutionWidth = $InsertionOrderLineItemRestrictions->MinScreenResolutionWidth;
                 $BannerRestrictionsPreview->MaxScreenResolutionWidth = $InsertionOrderLineItemRestrictions->MaxScreenResolutionWidth;
                 $BannerRestrictionsPreview->MinScreenResolutionHeight = $InsertionOrderLineItemRestrictions->MinScreenResolutionHeight;
                 $BannerRestrictionsPreview->MaxScreenResolutionHeight = $InsertionOrderLineItemRestrictions->MaxScreenResolutionHeight;
                 $BannerRestrictionsPreview->HttpLanguage = $InsertionOrderLineItemRestrictions->HttpLanguage;
                 $BannerRestrictionsPreview->BrowserUserAgentGrep = $InsertionOrderLineItemRestrictions->BrowserUserAgentGrep;
                 $BannerRestrictionsPreview->Secure = $InsertionOrderLineItemRestrictions->Secure;
                 $BannerRestrictionsPreview->Optout = $InsertionOrderLineItemRestrictions->Optout;
                 $BannerRestrictionsPreview->Vertical = $InsertionOrderLineItemRestrictions->Vertical;
                 $BannerRestrictionsPreview->DateCreated = date("Y-m-d H:i:s");
                 $BannerRestrictionsPreview->DateUpdated = date("Y-m-d H:i:s");
                 $InsertionOrderLineItemRestrictionsPreviewID = $InsertionOrderLineItemRestrictionsPreviewFactory->saveInsertionOrderLineItemRestrictionsPreview($BannerRestrictionsPreview);
                 if ($update_data['type'] == 'InsertionOrderLineItemRestrictionsID' && $update_data['id'] == $InsertionOrderLineItemRestrictions->InsertionOrderLineItemRestrictionsID) {
                     $return_val = array('InsertionOrderLineItemRestrictionsPreviewID' => $InsertionOrderLineItemRestrictionsPreviewID, 'InsertionOrderLineItemPreviewID' => $InsertionOrderLineItemPreviewID, 'InsertionOrderPreviewID' => $InsertionOrderPreviewID);
                 }
             }
         }
         /*
          * PMP INVENTORY
          */
         $params = array();
         $params["InsertionOrderLineItemID"] = $banner_id;
         $PmpDealPublisherWebsiteToInsertionOrderLineItemList = $PmpDealPublisherWebsiteToInsertionOrderLineItemFactory->get($params);
         if ($PmpDealPublisherWebsiteToInsertionOrderLineItemList != null) {
             foreach ($PmpDealPublisherWebsiteToInsertionOrderLineItemList as $PmpDealPublisherWebsiteToInsertionOrderLineItem) {
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview = new \model\PmpDealPublisherWebsiteToInsertionOrderLineItemPreview();
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->PublisherWebsiteID = $PmpDealPublisherWebsiteToInsertionOrderLineItem->PublisherWebsiteID;
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->PublisherWebsiteLocal = $PmpDealPublisherWebsiteToInsertionOrderLineItem->PublisherWebsiteLocal;
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->PublisherWebsiteDescription = $PmpDealPublisherWebsiteToInsertionOrderLineItem->PublisherWebsiteDescription;
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewID;
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->Enabled = $PmpDealPublisherWebsiteToInsertionOrderLineItem->Enabled;
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->DateCreated = date("Y-m-d H:i:s");
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreview->DateUpdated = date("Y-m-d H:i:s");
                 $PmpDealPublisherWebsiteToInsertionOrderLineItemPreviewFactory->savePmpDealPublisherWebsiteToInsertionOrderLineItemPreview($PmpDealPublisherWebsiteToInsertionOrderLineItemPreview);
             }
         }
         /*
          * SSP INVENTORY
          */
         $params = array();
         $params["InsertionOrderLineItemID"] = $banner_id;
         $SspRtbChannelToInsertionOrderLineItemList = $SspRtbChannelToInsertionOrderLineItemFactory->get_row($params);
         if ($SspRtbChannelToInsertionOrderLineItemList != null) {
             foreach ($SspRtbChannelToInsertionOrderLineItemList as $SspRtbChannelToInsertionOrderLineItem) {
                 $SspRtbChannelToInsertionOrderLineItemPreview = new \model\SspRtbChannelToInsertionOrderLineItemPreview();
                 $SspRtbChannelToInsertionOrderLineItemPreview->SspPublisherChannelID = $SspRtbChannelToInsertionOrderLineItem->SspPublisherChannelID;
                 $SspRtbChannelToInsertionOrderLineItemPreview->SspPublisherChannelDescription = $SspRtbChannelToInsertionOrderLineItem->SspPublisherChannelDescription;
                 $SspRtbChannelToInsertionOrderLineItemPreview->SspExchange = $SspRtbChannelToInsertionOrderLineItem->SspExchange;
                 $SspRtbChannelToInsertionOrderLineItemPreview->InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewID;
                 $SspRtbChannelToInsertionOrderLineItemPreview->Enabled = $SspRtbChannelToInsertionOrderLineItem->Enabled;
                 $SspRtbChannelToInsertionOrderLineItemPreview->DateCreated = date("Y-m-d H:i:s");
                 $SspRtbChannelToInsertionOrderLineItemPreview->DateUpdated = date("Y-m-d H:i:s");
                 $SspRtbChannelToInsertionOrderLineItemPreviewFactory->saveSspRtbChannelToInsertionOrderLineItemPreview($SspRtbChannelToInsertionOrderLineItemPreview);
             }
         }
         /*
          * DOMAIN EXCLUSIONS
          */
         $params = array();
         $params["InsertionOrderLineItemID"] = $banner_id;
         $InsertionOrderLineItemDomainExclusionList = $InsertionOrderLineItemDomainExclusionFactory->get($params);
         foreach ($InsertionOrderLineItemDomainExclusionList as $InsertionOrderLineItemDomainExclusion) {
             $BannerDomainExclusionPreview = new \model\InsertionOrderLineItemDomainExclusionPreview();
             $BannerDomainExclusionPreview->InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewID;
             $BannerDomainExclusionPreview->ExclusionType = $InsertionOrderLineItemDomainExclusion->ExclusionType;
             $BannerDomainExclusionPreview->DomainName = $InsertionOrderLineItemDomainExclusion->DomainName;
             $BannerDomainExclusionPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerDomainExclusionPreview->DateUpdated = date("Y-m-d H:i:s");
             $InsertionOrderLineItemDomainExclusionPreviewID = $InsertionOrderLineItemDomainExclusionPreviewFactory->saveInsertionOrderLineItemDomainExclusionPreview($BannerDomainExclusionPreview);
             if ($update_data['type'] == 'InsertionOrderLineItemDomainExclusionID' && $update_data['id'] == $InsertionOrderLineItemDomainExclusion->InsertionOrderLineItemDomainExclusionID) {
                 $return_val = array('InsertionOrderLineItemDomainExclusionPreviewID' => $InsertionOrderLineItemDomainExclusionPreviewID, 'InsertionOrderLineItemPreviewID' => $InsertionOrderLineItemPreviewID, 'InsertionOrderPreviewID' => $InsertionOrderPreviewID);
             }
         }
         /*
          * DOMAIN EXCLUSIVE INCLUSIONS
          */
         $params = array();
         $params["InsertionOrderLineItemID"] = $banner_id;
         $InsertionOrderLineItemDomainExclusiveInclusionList = $InsertionOrderLineItemDomainExclusiveInclusionFactory->get($params);
         foreach ($InsertionOrderLineItemDomainExclusiveInclusionList as $InsertionOrderLineItemDomainExclusiveInclusion) {
             $BannerDomainExclusiveInclusionPreview = new \model\InsertionOrderLineItemDomainExclusiveInclusionPreview();
             $BannerDomainExclusiveInclusionPreview->InsertionOrderLineItemPreviewID = $InsertionOrderLineItemPreviewID;
             $BannerDomainExclusiveInclusionPreview->InclusionType = $InsertionOrderLineItemDomainExclusiveInclusion->InclusionType;
             $BannerDomainExclusiveInclusionPreview->DomainName = $InsertionOrderLineItemDomainExclusiveInclusion->DomainName;
             $BannerDomainExclusiveInclusionPreview->DateCreated = date("Y-m-d H:i:s");
             $BannerDomainExclusiveInclusionPreview->DateUpdated = date("Y-m-d H:i:s");
             $InsertionOrderLineItemDomainExclusiveInclusionPreviewID = $InsertionOrderLineItemDomainExclusiveInclusionPreviewFactory->saveInsertionOrderLineItemDomainExclusiveInclusionPreview($BannerDomainExclusiveInclusionPreview);
             if ($update_data['type'] == 'InsertionOrderLineItemDomainExclusiveInclusionID' && $update_data['id'] == $InsertionOrderLineItemDomainExclusiveInclusion->InsertionOrderLineItemDomainExclusiveInclusionID) {
                 $return_val = array('InsertionOrderLineItemDomainExclusiveInclusionPreviewID' => $InsertionOrderLineItemDomainExclusiveInclusionPreviewID, 'InsertionOrderLineItemPreviewID' => $InsertionOrderLineItemPreviewID, 'InsertionOrderPreviewID' => $InsertionOrderPreviewID);
             }
         }
     }
     if (!$auth->getIsSuperAdmin($config) && $config['mail']['subscribe']['campaigns'] === true) {
         // if this ad campaign was not created/edited by the admin, then send out a notification email
         $message = '<b>NginAd Demand Customer Campaign Edited by ' . $auth->getUserName() . '.</b><br /><br />';
         $message = $message . '<table border="0" width="10%">';
         $message = $message . '<tr><td><b>InsertionOrderID: </b></td><td>' . $InsertionOrder->InsertionOrderID . '</td></tr>';
         $message = $message . '<tr><td><b>UserID: </b></td><td>' . $InsertionOrder->UserID . '</td></tr>';
         $message = $message . '<tr><td><b>Name: </b></td><td>' . $InsertionOrder->Name . '</td></tr>';
         $message = $message . '<tr><td><b>StartDate: </b></td><td>' . $InsertionOrder->StartDate . '</td></tr>';
         $message = $message . '<tr><td><b>EndDate: </b></td><td>' . $InsertionOrder->EndDate . '</td></tr>';
         $message = $message . '<tr><td><b>Customer: </b></td><td>' . $InsertionOrder->Customer . '</td></tr>';
         $message = $message . '<tr><td><b>CustomerID: </b></td><td>' . $InsertionOrder->CustomerID . '</td></tr>';
         $message = $message . '<tr><td><b>MaxImpressions: </b></td><td>' . $InsertionOrder->MaxImpressions . '</td></tr>';
         $message = $message . '<tr><td><b>MaxSpend: </b></td><td>' . $InsertionOrder->MaxSpend . '</td></tr>';
         $message = $message . '</table>';
         $subject = "NginAd Demand Customer Campaign Edited by " . $auth->getUserName();
         $text = new Mime\Part($message);
         $text->type = Mime\Mime::TYPE_HTML;
         $text->charset = 'utf-8';
         $mimeMessage = new Mime\Message();
         $mimeMessage->setParts(array($text));
         $zf_message = new Message();
         $zf_message->addTo($config['mail']['admin-email']['email'], $config['mail']['admin-email']['name'])->addFrom($config['mail']['reply-to']['email'], $config['mail']['reply-to']['name'])->setSubject($subject)->setBody($mimeMessage);
         $mail_transport->send($zf_message);
     }
     return $return_val;
 }