当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::addSeconds方法代码示例

本文整理汇总了PHP中Date::addSeconds方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::addSeconds方法的具体用法?PHP Date::addSeconds怎么用?PHP Date::addSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Date的用法示例。


在下文中一共展示了Date::addSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDeliveryBlocked

 /**
  * A method to test the deliveryBlocked() method.
  */
 function testDeliveryBlocked()
 {
     OA_setTimeZoneUTC();
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '1,5,7,20', 'executionorder' => 1);
     $oLimitationHour = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-07 23:15:45');
     for ($i = 0; $i < 24; $i++) {
         $oDate->addSeconds(SECONDS_PER_HOUR);
         if ($i == 1 || $i == 5 || $i == 7 || $i == 20) {
             $this->assertFalse($oLimitationHour->deliveryBlocked($oDate));
         } else {
             $this->assertTrue($oLimitationHour->deliveryBlocked($oDate));
         }
     }
     // Test timezone
     $aDeliveryLimitation = array('ad_id' => 1, 'logical' => 'and', 'type' => 'deliveryLimitations:Time:Hour', 'comparison' => '=~', 'data' => '1,5,7,20@Europe/Rome', 'executionorder' => 1);
     $oLimitationHour = OA_Maintenance_Priority_DeliveryLimitation_Factory::factory($aDeliveryLimitation);
     $oDate = new Date('2006-02-07 23:15:45');
     for ($i = 0; $i < 24; $i++) {
         $oDate->addSeconds(SECONDS_PER_HOUR);
         if ($i == 0 || $i == 4 || $i == 6 || $i == 19) {
             $this->assertFalse($oLimitationHour->deliveryBlocked($oDate));
         } else {
             $this->assertTrue($oLimitationHour->deliveryBlocked($oDate));
         }
     }
     OA_setTimeZoneLocal();
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:31,代码来源:MpeTimeHour.plg.test.php

示例2: get_init_time

function get_init_time($name) {
  global $log; 
  $date = new Date();  
 
  $log->log("name = $name") ; 
  if ($name == 'end'){ 
     $add_hour = 1;
     $date->addSeconds(3600);  
  } 
   
  if ($date->getMinute() ==0 ) {
    $init_time = $date->getHour() .  ":00";
  } elseif($date->getMinute() <= 15) {
    $init_time = $date->getHour() .  ":00";
  } elseif ($date->getMinute() <= 30) {
    $init_time = $date->getHour() .  ":15";
  } elseif ($date->getMinute() <= 45) {
    $init_time = $date->getHour() .  ":30";
  } else {
    $init_time = $date->getHour() .  ":45";
  }
  $log->log("init_time $init_time mins:" . $date->getMinute()) ; 
  return $init_time ; 

} 
开发者ID:BackupTheBerlios,项目名称:sipums,代码行数:25,代码来源:new_conference.php

示例3: testRun

 /**
  * A method to test the run() method.
  */
 function testRun()
 {
     $oServiceLocator =& OA_ServiceLocator::instance();
     $aConf =& $GLOBALS['_MAX']['CONF'];
     $className = 'OX_Dal_Maintenance_Statistics_' . ucfirst(strtolower($aConf['database']['type']));
     $mockClassName = 'MockOX_Dal_Maintenance_Statistics_' . ucfirst(strtolower($aConf['database']['type']));
     $aConf['maintenance']['operationInterval'] = 60;
     // Test 1: Test with the bucket data not having been migrated,
     //         and ensure that the DAL calls to de-duplicate and
     //         reject conversions are not made
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Mock the MSE DAL used to de-duplicate conversions,
     // and set the expectations of the calls to the DAL
     Mock::generate($className);
     $oDal = new $mockClassName($this);
     $oDal->expectNever('deduplicateConversions');
     $oDal->expectNever('rejectEmptyVarConversions');
     $oDal->OX_Dal_Maintenance_Statistics();
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controlling class' status and test
     $oDeDuplicateConversions = new OX_Maintenance_Statistics_Task_DeDuplicateConversions();
     $oDeDuplicateConversions->oController->updateIntermediate = false;
     $oDeDuplicateConversions->run();
     $oDal->tally();
     // Test 2: Test with the bucket data having been migrated, and
     //         ensure that the DALL calls to de-duplicate and reject
     //         conversions are made correctly
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Mock the MSE DAL used to de-duplicate conversions,
     // and set the expectations of the calls to the DAL
     Mock::generate($className);
     $oDal = new $mockClassName($this);
     $oDate = new Date('2008-09-08 16:59:59');
     $oDate->addSeconds(1);
     $oDal->expectOnce('deduplicateConversions', array($oDate, new Date('2008-09-08 17:59:59')));
     $oDal->expectOnce('rejectEmptyVarConversions', array($oDate, new Date('2008-09-08 17:59:59')));
     $oDal->OX_Dal_Maintenance_Statistics();
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controlling class' status and test
     $oDeDuplicateConversions = new OX_Maintenance_Statistics_Task_DeDuplicateConversions();
     $oDeDuplicateConversions->oController->updateIntermediate = true;
     $oDeDuplicateConversions->oController->oLastDateIntermediate = new Date('2008-09-08 16:59:59');
     $oDeDuplicateConversions->oController->oUpdateIntermediateToDate = new Date('2008-09-08 17:59:59');
     $oDeDuplicateConversions->run();
     $oDal->tally();
     TestEnv::restoreConfig();
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:54,代码来源:DeduplicateConversions.mtsdb.test.php

示例4: run

 /**
  * The implementation of the OA_Task::run() method that performs
  * the required task of managing conversions.
  */
 function run()
 {
     if ($this->oController->updateIntermediate) {
         // Preapre the start date for the management of conversions
         $oStartDate = new Date();
         $oStartDate->copy($this->oController->oLastDateIntermediate);
         $oStartDate->addSeconds(1);
         // Get the MSE DAL to perform the conversion management
         $oServiceLocator =& OA_ServiceLocator::instance();
         $oDal =& $oServiceLocator->get('OX_Dal_Maintenance_Statistics');
         // Manage conversions
         $oDal->manageConversions($oStartDate, $this->oController->oUpdateIntermediateToDate);
     }
 }
开发者ID:hostinger,项目名称:revive-adserver,代码行数:18,代码来源:ManageConversions.php

示例5: run

 /**
  * The implementation of the OA_Task::run() method that performs
  * the required task of migrating data_intermediate_% table data
  * into the data_summary_% tables.
  */
 function run()
 {
     if ($this->oController->updateIntermediate || $this->oController->updateFinal) {
         $message = '- Saving request, impression, click and conversion data into the final tables.';
         $this->oController->report .= $message . "\n";
         OA::debug($message, PEAR_LOG_DEBUG);
     }
     if ($this->oController->updateFinal) {
         // Update the hourly summary table
         $oStartDate = new Date();
         $oStartDate->copy($this->oController->oLastDateFinal);
         $oStartDate->addSeconds(1);
         $this->_saveSummary($oStartDate, $this->oController->oUpdateFinalToDate);
     }
 }
开发者ID:akirsch,项目名称:revive-adserver,代码行数:20,代码来源:SummariseFinal.php

示例6: run

 /**
  * The implementation of the OA_Task::run() method that performs
  * the required task of de-duplicating and rejecting conversions.
  */
 function run()
 {
     if ($this->oController->updateIntermediate) {
         // Preapre the start date for the de-duplication/rejection
         $oStartDate = new Date();
         $oStartDate->copy($this->oController->oLastDateIntermediate);
         $oStartDate->addSeconds(1);
         // Get the MSE DAL to perform the de-duplication
         $oServiceLocator =& OA_ServiceLocator::instance();
         $oDal =& $oServiceLocator->get('OX_Dal_Maintenance_Statistics');
         // De-duplicate conversions
         $oDal->deduplicateConversions($oStartDate, $this->oController->oUpdateIntermediateToDate);
         // Reject empty variable conversions
         $oDal->rejectEmptyVarConversions($oStartDate, $this->oController->oUpdateIntermediateToDate);
     }
 }
开发者ID:akirsch,项目名称:revive-adserver,代码行数:20,代码来源:DeduplicateConversions.php

示例7: prepareWeekBreakdown

 /**
  * A method to modify an array of history data so that it can be displayed in a format
  * compatible with the weekly breakdown template.
  *
  * @param array $aData    A reference to an array of arrays, containing the rows of data.
  * @param object $oCaller The calling object. Expected to have the the class variable
  *                        "statsBreakdown" set.
  */
 function prepareWeekBreakdown(&$aData, $oCaller)
 {
     // Only prepare the weekly breakdown if the statsBreakdown
     // in the caller is set to "week"
     if ($oCaller->statsBreakdown != 'week') {
         return;
     }
     $beginOfWeek = OA_Admin_DaySpan::getBeginOfWeek();
     $aWeekData = array();
     ksort($aData);
     foreach ($aData as $key => $aRowData) {
         // Get the date for this row's data
         $oDate = new Date($key);
         if ($beginOfWeek != 0) {
             // Need to change the date used for the data so
             // that the day appears in the correct week
             $daysToGoback = (int) (SECONDS_PER_DAY * $beginOfWeek);
             $oDate->subtractSeconds($daysToGoback);
         }
         // Get the week this date is in, in YYYY-MM format
         $week = sprintf('%04d-%02d', $oDate->getYear(), $oDate->getWeekOfYear());
         // Prepare the data array for this week, if not set, where
         // the week is in the "week" index, there is a "data" index
         // for all the rows that make up the week, and the array
         // has all the columns of an empty data row
         if (!isset($aWeekData[$week])) {
             $aWeekData[$week] = $oCaller->aEmptyRow;
             $aWeekData[$week]['week'] = $week;
             $aWeekData[$week]['data'] = array();
         }
         // Add the data from the row to the totals of the week
         foreach (array_keys($oCaller->aColumns) as $colKey) {
             $aWeekData[$week][$colKey] += $aRowData[$colKey];
         }
         // Store the row in the week
         $aWeekData[$week]['data'][$key] = $aRowData;
     }
     foreach (array_keys($aWeekData) as $week) {
         // Now that the totals are complete, fill any
         // remaining days in the week with empty data
         $days = count($aWeekData[$week]['data']);
         if ($days < 7) {
             // Locate the first day of the week in the days that make
             // up the week so far
             ksort($aWeekData[$week]['data']);
             $key = key($aWeekData[$week]['data']);
             $oDate = new Date($key);
             $firstDataDayOfWeek = $oDate->getDayOfWeek();
             // Is this after the start of the week?
             if ($firstDataDayOfWeek > $beginOfWeek) {
                 // Change the date to be the first day of this week
                 $daysToGoback = (int) (SECONDS_PER_DAY * ($firstDataDayOfWeek - $beginOfWeek));
                 $oDate->subtractSeconds($daysToGoback);
             }
             // Check each day in the week
             for ($counter = 0; $counter < 7; $counter++) {
                 if (is_null($aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')])) {
                     // Set the day's data to the empty row, plus the "day" heading for the day
                     $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')] = $oCaller->aEmptyRow;
                     $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]['day'] = $oDate->format($GLOBALS['date_format']);
                 } elseif (!is_null($aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]) && !array_key_exists('day', $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')])) {
                     $aWeekData[$week]['data'][$oDate->format('%Y-%m-%d')]['day'] = $oDate->format($GLOBALS['date_format']);
                 }
                 $oDate->addSeconds(SECONDS_PER_DAY);
             }
         }
         // Ensure the day data is sorted correctly
         ksort($aWeekData[$week]['data']);
         // Format all day rows
         foreach (array_keys($aWeekData[$week]['data']) as $key) {
             $oCaller->_formatStatsRowRecursive($aWeekData[$week]['data'][$key]);
         }
         // Calculate CTR and other columns, making sure that the method is available
         if (is_callable(array($oCaller, '_summarizeStats'))) {
             $oCaller->_summarizeStats($aWeekData[$week]);
         }
     }
     // Set the new weekly-formatted data as the new data array to use
     $aData = $aWeekData;
 }
开发者ID:Apeplazas,项目名称:plazadelatecnologia,代码行数:88,代码来源:History.php

示例8: getNextPaymentData

 function getNextPaymentData($mode = '')
 {
     $mode = $mode ? $mode : 'plan';
     $balance = $this->data['balance_kp'] + $this->data['balance_kaf'] + $this->data['balance_kat'];
     $date = new Date($this->data['r_from_date']);
     $data['pmt_date'] = $mode == 'plan' ? $this->data['xp_pmt_date'] : $this->data['cn_date'];
     $n = 0;
     while ($date->format('%Y-%m-%d') != $data['pmt_date']) {
         $date->addSeconds(24 * 60 * 60);
         $n++;
     }
     $data['xp_pmt_date'] = $this->next_payment_date();
     $data['r_from_date'] = $date->format('%Y-%m-%d');
     $data['interest'] = round($balance * (0.01 * $this->data['rates_r'] / $this->data['calendar_type']) * $n, 2);
     $data['fees'] = round($this->data['P_KAT'] * ($this->data['pmt'] - $data['interest']), 2);
     $data['insurances'] = round($this->data['P_KAF'] * ($this->data['pmt'] - $data['interest']), 2);
     $data['principal'] = $this->data['pmt'] - $data['interest'] - $data['fees'] - $data['insurances'];
     $data['balance_kp'] = $this->data['balance_kp'] - $data['principal'];
     $data['balance_kaf'] = $this->data['balance_kaf'] - $data['insurances'];
     $data['balance_kat'] = $this->data['balance_kat'] - $data['fees'];
     $this->load_penalties();
     $data['delay'] = $this->data['delay'];
     $data['penalties'] = $this->data['penalties'];
     $data['pmt'] = $this->data['pmt'] + $this->data['penalties'];
     $data['xp_pmt'] = $this->data['pmt'];
     // <-- esto hay que revisarlo
     if ($data['balance_kp'] < 0 || $data['balance_kaf'] < 0 || $data['balance_kat'] < 0) {
         $data['fees'] = $this->data['balance_kat'];
         $data['insurances'] = $this->data['balance_kaf'];
         $data['principal'] = $this->data['balance_kp'];
         $data['balance_kp'] = 0;
         $data['balance_kaf'] = 0;
         $data['balance_kat'] = 0;
         $data['pmt'] = $data['interest'] + $data['fees'] + $data['insurances'] + $data['principal'] + $data['penalties'];
         $data['xp_pmt'] = 0;
     }
     return $data;
 }
开发者ID:henkmahendra,项目名称:emms-devel,代码行数:38,代码来源:loan.php

示例9: array

$aRunDates = array();
while ($oOIEnd->before($oEndDate) || $oOIEnd->equals($oEndDate)) {
    echo "Adding " . $oOIStart->format('%Y-%m-%d %H:%M:%S') . "' -> '" . $oOIEnd->format('%Y-%m-%d %H:%M:%S') . " to the list of run dates<br />\n";
    // Store the dates
    $oStoreStartDate = new Date();
    $oStoreStartDate->copy($oOIStart);
    $oStoreEndDate = new Date();
    $oStoreEndDate->copy($oOIEnd);
    $aRunDates[] = array('start' => $oStoreStartDate, 'end' => $oStoreEndDate);
    $oOIEnd = OX_OperationInterval::addOperationIntervalTimeSpan($oOIEnd);
    $oOIStart = OX_OperationInterval::addOperationIntervalTimeSpan($oOIStart);
}
// The summariseFinal process requires complete hours (not OI's), so record these too
$oOIStart = new Date(INTERVAL_START);
$oOIEnd = new Date(INTERVAL_START);
$oOIEnd->addSeconds(60 * 60 - 1);
$aRunHours = array();
while ($oOIEnd->before($oEndDate) || $oOIEnd->equals($oEndDate)) {
    echo "Adding " . $oOIStart->format('%Y-%m-%d %H:%M:%S') . "' -> '" . $oOIEnd->format('%Y-%m-%d %H:%M:%S') . " to the list of run dates<br />\n";
    // Store the dates
    $oStoreStartDate = new Date();
    $oStoreStartDate->copy($oOIStart);
    $oStoreEndDate = new Date();
    $oStoreEndDate->copy($oOIEnd);
    $aRunHours[] = array('start' => $oStoreStartDate, 'end' => $oStoreEndDate);
    $oOIEnd->addSeconds(60 * 60);
    $oOIStart->addSeconds(60 * 60);
}
// Create and register an instance of the OA_Dal_Maintenance_Statistics DAL class for the following tasks to use
$oServiceLocator =& OA_ServiceLocator::instance();
if (!$oServiceLocator->get('OX_Dal_Maintenance_Statistics')) {
开发者ID:akirsch,项目名称:revive-adserver,代码行数:31,代码来源:republish.php

示例10: Date

echo $tpl->getHeader($pageHeading);
echo $widgets->addToolTipLayer();
//Settings formular
//help funktions for automatical calculation of pocket money from the finished transactions
$standardStartDate = new Date();
$standardStartDate->subtractSeconds(60 * 60 * 24 * 180);
$calculatePocketMoneyStartDateField = $widgets->addDateField("startDate", $standardStartDate->getFormatted());
$writeCalcuatedPocketMoneyButton = $widgets->createButton("writePocketMoney", getBadgerTranslation2("forecast", "calculatedPocketMoneyButton"), 'calcPocketMoney2();', "Widgets/accept.gif");
$calculatedPocketMoneyLabel = getBadgerTranslation2("forecast", "calculatedPocketMoneyLabel") . ":";
$writeCalculatedToolTip = $widgets->addToolTip(getBadgerTranslation2("forecast", "calculatedPocketMoneyToolTip"));
//field for selecting end date of forecasting
$legendSetting = getBadgerTranslation2("forecast", "legendSetting");
$legendGraphs = getBadgerTranslation2("forecast", "legendGraphs");
$endDateLabel = getBadgerTranslation2("forecast", "endDateField") . ":";
$standardEndDate = new Date();
$standardEndDate->addSeconds(60 * 60 * 24 * 180);
$endDateField = $widgets->addDateField("endDate", $standardEndDate->getFormatted());
$endDateToolTip = $widgets->addToolTip(getBadgerTranslation2("forecast", "endDateToolTip"));
//get accounts from db & field to select the account for forecsatung
$am = new AccountManager($badgerDb);
$account = array();
while ($currentAccount = $am->getNextAccount()) {
    $account[$currentAccount->getId()] = $currentAccount->getTitle();
}
//Drop down to select account
$accountLabel = $widgets->createLabel("selectedAccount", getBadgerTranslation2("forecast", "accountField") . ":", true);
$accountField = $widgets->createSelectField("selectedAccount", $account, $us->getProperty('forecastStandardAccount'), getBadgerTranslation2("forecast", "accountToolTip"), true, 'style="width: 10em;"');
//field to select saving target, default is 0
$savingTargetLabel = $widgets->createLabel("savingTarget", getBadgerTranslation2("forecast", "savingTargetField") . ":", true);
$savingTargetField = $widgets->createField("savingTarget", 5, 0, getBadgerTranslation2("forecast", "savingTargetToolTip"), true, "text", 'style="width: 10em;"');
//field to insert pocketmoney1
开发者ID:BackupTheBerlios,项目名称:badger-svn,代码行数:31,代码来源:forecast.php

示例11: array

 /**
  * A private method to convert the ZIF update type from _getUpdateTypeRequired() into
  * a range of operation intervals where all zones require their ZIF values to be updated.
  *
  * @access private
  * @param mixed $type The update type required. Possible values are the same as
  *                    those returned from the
  *                    {@link OA_Maintenance_Priority_AdServer_Task_ForecastZoneImpressions::getUpdateTypeRequired()}
  *                    method.
  * @return array An array of hashes where keys are operation interval IDs, and
  *               values are PEAR Dates. One element in the array indicates a
  *               contiguous range, two elements indicate a non-contiguous range.
  */
 function _getOperationIntervalRanges($type)
 {
     // Initialise result array
     $aResult = array();
     switch (true) {
         case is_bool($type) && $type === false:
             // Update none, return an empty array
             return $aResult;
         case is_bool($type) && $type === true:
             // Update all - need one week's worth of operation intervals up until the end
             // of the operation interval *after* the one that statistics have been updated
             // to, as we need to predict one interval ahead of now
             $oStatsDates = OX_OperationInterval::convertDateToNextOperationIntervalStartAndEndDates($this->oDateNow);
             $oStartDate = new Date();
             $oStartDate->copy($oStatsDates['start']);
             $oStartDate->subtractSeconds(SECONDS_PER_WEEK);
             $startId = OX_OperationInterval::convertDateToOperationIntervalID($oStartDate);
             $totalIntervals = OX_OperationInterval::operationIntervalsPerWeek();
             break;
         case is_array($type) && $type[0] < $type[1]:
             // A contiguous (ie. inter-week) range, where the first operation interval
             // ID is the lower bound, and the second operation interval ID is the upper
             // The start operation interval ID is the operation interval ID right after
             // the operation interval ID that priority was updated to (ie. $type[0])
             $aDates = OX_OperationInterval::convertDateToNextOperationIntervalStartAndEndDates($this->oPriorityUpdatedToDate);
             $oStartDate = $aDates['start'];
             $startId = OX_OperationInterval::nextOperationIntervalID($type[0], 1);
             $totalIntervals = $type[1] - $type[0];
             break;
         case is_array($type) && $type[0] > $type[1]:
             // A non-contiguous range, so calculate as above, but use the first operation
             // interval ID as the upper bound, and the second operation interval ID as the
             // lower bound in the proceeding week
             // The start operation interval ID is the operation interval ID right after
             // the operation interval ID that priority was updated to (ie. $type[0])
             $aDates = OX_OperationInterval::convertDateToNextOperationIntervalStartAndEndDates($this->oPriorityUpdatedToDate);
             $oStartDate = $aDates['start'];
             $startId = OX_OperationInterval::nextOperationIntervalID($type[0], 1);
             $totalIntervals = OX_OperationInterval::operationIntervalsPerWeek() - $type[0] + $type[1];
             break;
         default:
             OA::debug('OA_Maintenance_Priority_AdServer_Task_ForecastZoneImpressions::getOperationIntRangeByType() called with unexpected type, exiting', PEAR_LOG_CRIT);
             exit;
     }
     // Build the update range array
     $aRange = array();
     $totalIntervalPerWeek = OX_OperationInterval::operationIntervalsPerWeek();
     for ($x = $startId, $y = 0; $y < $totalIntervals; $x++, $y++) {
         if ($x == $totalIntervalPerWeek) {
             $x = 0;
         }
         $aDates = array();
         $aDates['start'] = new Date($oStartDate);
         //->format('%Y-%m-%d %H:%M:%S');
         $oEndDate = new Date();
         $oEndDate->copy($oStartDate);
         $oEndDate->addSeconds(OX_OperationInterval::secondsPerOperationInterval() - 1);
         $aDates['end'] = $oEndDate;
         //->format('%Y-%m-%d %H:%M:%S');
         unset($oEndDate);
         $aRange[$x] = $aDates;
         $oStartDate->addSeconds(OX_OperationInterval::secondsPerOperationInterval());
     }
     // Is the update range array a contiguous (inter-weeek) range?
     if (array_key_exists($totalIntervalPerWeek - 1, $aRange) && array_key_exists(0, $aRange)) {
         // The range contains the first and the last operation interval IDs, is the
         // last date before the first date?
         $oFirstIntervalStartDate = new Date($aRange[0]['start']);
         $oLastIntervalStartDate = new Date($aRange[$totalIntervalPerWeek - 1]['start']);
         if ($oLastIntervalStartDate->before($oFirstIntervalStartDate)) {
             // It's a non-contiguous range, so split into two ranges
             $aRange1 = array();
             $aRange2 = array();
             for ($x = $startId; $x < $totalIntervalPerWeek; $x++) {
                 $aRange1[$x] = $aRange[$x];
             }
             for ($x = 0; $x < $startId; $x++) {
                 if (isset($aRange[$x])) {
                     $aRange2[$x] = $aRange[$x];
                 }
             }
             $aResult[] = $aRange1;
             $aResult[] = $aRange2;
             return $aResult;
         }
     }
     $aResult[] = $aRange;
//.........这里部分代码省略.........
开发者ID:villos,项目名称:tree_admin,代码行数:101,代码来源:ForecastZoneImpressions.php

示例12: sendCampaignImpendingExpiryEmail


//.........这里部分代码省略.........
         $aPrefs['admin'] = $aAdminPrefs;
         // Create a linked user 'special' for the advertiser that will take the admin preferences for advertiser
         $aLinkedUsers['special']['advertiser'] = $doClients->toArray();
         $aLinkedUsers['special']['advertiser']['contact_name'] = $aLinkedUsers['special']['advertiser']['contact'];
         $aLinkedUsers['special']['advertiser']['email_address'] = $aLinkedUsers['special']['advertiser']['email'];
         $aLinkedUsers['special']['advertiser']['language'] = '';
         $aLinkedUsers['special']['advertiser']['user_id'] = 0;
         // Check that every user is not going to receive more than one email if they
         // are linked to more than one account
         $aLinkedUsers = $this->_deleteDuplicatedUser($aLinkedUsers);
         // Create the linked special user preferences from the admin preferences
         // the special user is the client that doesn't have preferences in the database
         $aPrefs['special'] = $aPrefs['admin'];
         $aPrefs['special']['warn_email_special'] = $aPrefs['special']['warn_email_advertiser'];
         $aPrefs['special']['warn_email_special_day_limit'] = $aPrefs['special']['warn_email_advertiser_day_limit'];
         $aPrefs['special']['warn_email_special_impression_limit'] = $aPrefs['special']['warn_email_advertiser_impression_limit'];
         // Store in the client cache
         $this->aClientCache = array($aCampaign['clientid'] => array($aLinkedUsers, $aPrefs, $aAgencyFromDetails));
     } else {
         // Retrieve client cache
         list($aLinkedUsers, $aPrefs, $aAgencyFromDetails) = $this->aClientCache[$aCampaign['clientid']];
     }
     $copiesSent = 0;
     foreach ($aLinkedUsers as $accountType => $aUsers) {
         if ($accountType == 'special' || $accountType == 'advertiser') {
             // Get the agency details and use them for emailing advertisers
             $aFromDetails = $aAgencyFromDetails;
         } else {
             // Use the Admin details
             $aFromDetails = '';
         }
         if ($aPrefs[$accountType]['warn_email_' . $accountType]) {
             // Does the account type want warnings when the impressions are low?
             if ($aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'] > 0 && $aCampaign['views'] > 0) {
                 // Test to see if the placements impressions remaining are less than the limit
                 $dalCampaigns = OA_Dal::factoryDAL('campaigns');
                 $remainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid']);
                 if ($remainingImpressions < $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) {
                     // Yes, the placement will expire soon! But did the placement just reach
                     // the point where it is about to expire, or did it happen a while ago?
                     $previousRemainingImpressions = $dalCampaigns->getAdImpressionsLeft($aCampaign['campaignid'], $aPreviousOIDates['end']);
                     if ($previousRemainingImpressions >= $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit']) {
                         // Yes! This is the operation interval that the boundary
                         // was crossed to the point where it's about to expire,
                         // so send that email, baby!
                         foreach ($aUsers as $aUser) {
                             $aEmail = $this->prepareCampaignImpendingExpiryEmail($aUser, $aCampaign['clientid'], $aCampaign['campaignid'], 'impressions', $aPrefs[$accountType]['warn_email_' . $accountType . '_impression_limit'], $accountType);
                             if ($aEmail !== false) {
                                 if ($this->sendMail($aEmail['subject'], $aEmail['contents'], $aUser['email_address'], $aUser['contact_name'], $aFromDetails)) {
                                     $copiesSent++;
                                     if ($aConf['email']['logOutgoing']) {
                                         phpAds_userlogSetUser(phpAds_userMaintenance);
                                         phpAds_userlogAdd(phpAds_actionWarningMailed, $aPlacement['campaignid'], "{$aEmail['subject']}\n\n\n                                                 {$aUser['contact_name']}({$aUser['email_address']})\n\n\n                                                 {$aEmail['contents']}");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             // Does the account type want warnings when the days are low?
             if ($aPrefs[$accountType]['warn_email_' . $accountType . '_day_limit'] > 0 && !empty($aCampaign['expire_time'])) {
                 // Calculate the date that should be used to see if the warning needs to be sent
                 $warnSeconds = (int) ($aPrefs[$accountType]['warn_email_' . $accountType . '_day_limit'] + 1) * SECONDS_PER_DAY;
                 $oEndDate = new Date($aCampaign['expire_time']);
                 $oEndDate->setTZbyID('UTC');
                 $oTestDate = new Date();
                 $oTestDate->copy($oDate);
                 $oTestDate->addSeconds($warnSeconds);
                 // Test to see if the test date is after the placement's expiration date
                 if ($oTestDate->after($oEndDate)) {
                     // Yes, the placement will expire soon! But did the placement just reach
                     // the point where it is about to expire, or did it happen a while ago?
                     $oiSeconds = (int) $aConf['maintenance']['operationInterval'] * 60;
                     $oTestDate->subtractSeconds($oiSeconds);
                     if (!$oTestDate->after($oEndDate)) {
                         // Yes! This is the operation interval that the boundary
                         // was crossed to the point where it's about to expire,
                         // so send those emails, baby!
                         foreach ($aUsers as $aUser) {
                             $aEmail = $this->prepareCampaignImpendingExpiryEmail($aUser, $aCampaign['clientid'], $aCampaign['campaignid'], 'date', $oEndDate->format($date_format), $accountType);
                             if ($aEmail !== false) {
                                 if ($this->sendMail($aEmail['subject'], $aEmail['contents'], $aUser['email_address'], $aUser['contact_name'], $aFromDetails)) {
                                     $copiesSent++;
                                     if ($aConf['email']['logOutgoing']) {
                                         phpAds_userlogSetUser(phpAds_userMaintenance);
                                         phpAds_userlogAdd(phpAds_actionWarningMailed, $aPlacement['campaignid'], "{$aEmail['subject']}\n\n\n                                                 {$aUser['contact_name']}({$aUser['email_address']})\n\n\n                                                 {$aEmail['contents']}");
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Restore the default language strings
     Language_Loader::load('default');
     return $copiesSent;
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:101,代码来源:Email.php

示例13: testGetPreviousAdDeliveryInfo


//.........这里部分代码省略.........
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 1, 1, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 2, 1, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $bannerId2 = $this->_insertCampaignBanner();
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId2, 0, 3, 2, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId2, 0, 4, 2, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $bannerId3 = $this->_insertCampaignBanner();
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId3, 0, 5, 5, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
     $previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID);
     $previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($previousOperationIntervalID);
     $aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
     $aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($aDates['start']);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 1, 100, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId1, 0, 2, 100, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId2, 0, 3, 200, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId2, 0, 4, 200, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), $bannerId3, 0, 5, 500, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $aDates['start']->format('%Y-%m-%d'), $aDates['start']->format('%H'), 4, 0, 5, 500, $oNow->format('%Y-%m-%d %H:%M:%S'));
     $idDia = $this->_insertDataIntermediateAd($aData);
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
     $previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID);
     $aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
     $oSpecialDate = new Date($aDates['end']);
     $oSpecialDate->addSeconds(1);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId1, 2, 10, 10, 0, 0.5, 0.99, $oNow->format('%Y-%m-%d %H:%M:%S'), 0);
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), 9, 9, 59, 59, 0, 95, 0.995, $oNow->format('%Y-%m-%d %H:%M:%S'), 0);
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId2, 3, 30, 30, 0, 0.4, 0.5, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), 0, $aDates['end']->format('%Y-%m-%d %H:30:00'));
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId2, 3, 30, 30, 0, 0.4, 0.5, $aDates['start']->format('%Y-%m-%d %H:30:00'), 0, $aDates['end']->format('%Y-%m-%d %H:%M:%S'));
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId2, 4, 10, 10, 0, 0.4, 0.5, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), 0, $aDates['end']->format('%Y-%m-%d %H:30:00'));
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId2, 4, 20, 20, 0, 0.8, 0.5, $aDates['start']->format('%Y-%m-%d %H:30:00'), 0, $oSpecialDate->format('%Y-%m-%d %H:%M:%S'));
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oDate);
     $previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($operationIntervalID);
     $previousOperationIntervalID = OX_OperationInterval::previousOperationIntervalID($previousOperationIntervalID);
     $aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($oDate);
     $aDates = OX_OperationInterval::convertDateToPreviousOperationIntervalStartAndEndDates($aDates['start']);
     $oSpecialDate = new Date($aDates['end']);
     $oSpecialDate->addSeconds(1);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId3, 5, 200, 200, 0, 0.2, 0.95, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), 0, $aDates['end']->format('%Y-%m-%d %H:30:00'));
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $aData = array($conf['maintenance']['operationInterval'], $previousOperationIntervalID, $aDates['start']->format('%Y-%m-%d %H:%M:%S'), $aDates['end']->format('%Y-%m-%d %H:%M:%S'), $bannerId3, 5, 100, 100, 0, 0.4, 0.95, $aDates['start']->format('%Y-%m-%d %H:30:00'), 0, $oSpecialDate->format('%Y-%m-%d %H:%M:%S'));
     $this->_insertDataSummaryAdZoneAssoc($aData);
     $result =& $oMaxDalMaintenance->getPreviousAdDeliveryInfo($aEmptyZoneAdArray);
     $this->assertEqual(count($result), 4);
     $this->assertEqual(count($result[1]), 2);
     $this->assertEqual($result[1][1]['ad_id'], $bannerId1);
     $this->assertEqual($result[1][1]['zone_id'], 1);
     $this->assertNull($result[1][1]['required_impressions']);
     $this->assertNull($result[1][1]['requested_impressions']);
     $this->assertNull($result[1][1]['priority_factor']);
     $this->assertNull($result[1][1]['past_zone_traffic_fraction']);
开发者ID:Jaree,项目名称:revive-adserver,代码行数:67,代码来源:Priority_getPreviousAdDeliveryInfo.dal.test.php

示例14: getAdLifetimeZoneImpressionsRemaining

 /**
  * A method to obtain the sum of the zone forecast impression value, for all the zones
  * an advertisement is linked to, cloned out over the advertisement's entire remaining
  * lifetime in the campaign, with any blocked operation intervals removed.
  *
  * Requires that the getActiveAdOperationIntervals() method have previously been
  * called to function correctly.
  *
  * @param PEAR::Date $oNowDate The current date.
  * @param PEAR::Date $oEndDate The end date of the campaign. Note that if the end
  *                             date supplied is not at the end of a day, it will be
  *                             converted to be treated as such.
  * @param array $aCumulativeZoneForecast The cumulative forecast impressions, indexed
  *                                       by operation interval ID, of all the zones the
  *                                       advertisement is linked to.
  *                  array(
  *                      [operation_interval_id] => forecast_impressions,
  *                      [operation_interval_id] => forecast_impressions
  *                                  .
  *                                  .
  *                                  .
  *                  )
  * @return integer The ad's total remaining zone impression forecast for all zone for
  *                 the remaining life of the ad.
  */
 function getAdLifetimeZoneImpressionsRemaining($oNowDate, $oEndDate, $aCumulativeZoneForecast)
 {
     $totalAdLifetimeZoneImpressionsRemaining = 0;
     // Test the parameters, if invalid, return zero
     if (!is_a($oNowDate, 'date') || !is_a($oEndDate, 'date') || !is_array($aCumulativeZoneForecast) || count($aCumulativeZoneForecast) != OX_OperationInterval::operationIntervalsPerWeek()) {
         OA::debug('  - Invalid parameters to getAdLifetimeZoneImpressionsRemaining, returning 0', PEAR_LOG_ERR);
         return $totalAdLifetimeZoneImpressionsRemaining;
     }
     // Ensure that the end of campaign date is at the end of the day
     $oEndDateCopy = new Date($oEndDate);
     $oEndDateCopy->setHour(23);
     $oEndDateCopy->setMinute(59);
     $oEndDateCopy->setSecond(59);
     // Ensure that the $aCumulativeZoneForecast array is sorted by key, so that it can
     // be accessed by array_slice, regardless of the order that the forecast data was added
     // to the array
     ksort($aCumulativeZoneForecast);
     // Step 1: Calculate the sum of the forecast values from "now" until the end of "today"
     $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oNowDate);
     $oEndOfToday = new Date($aDates['start']);
     $oEndOfToday->setTZ($oEndDate->tz);
     $oEndOfToday->setHour(23);
     $oEndOfToday->setMinute(59);
     $oEndOfToday->setSecond(59);
     $oStart = $aDates['start'];
     while ($oStart->before($oEndOfToday)) {
         // Find the Operation Interval ID for this Operation Interval
         $operationIntervalID = OX_OperationInterval::convertDateToOperationIntervalID($oStart);
         // As iteration over every OI is required anyway, test to see if
         // the ad is blocked in this OI; if not, add the forecast values to the
         // running total
         if (empty($this->aBlockedOperationIntervalDates[$oStart->format('%Y-%m-%d %H:%M:%S')])) {
             $totalAdLifetimeZoneImpressionsRemaining += $aCumulativeZoneForecast[$operationIntervalID];
         }
         // Go to the next operation interval in "today"
         $oStart = OX_OperationInterval::addOperationIntervalTimeSpan($oStart);
     }
     // Step 2: Calculate how many times each day of the week occurs between the end of
     //         "today" (i.e. starting "tomorrow morning") and the last day the ad can run
     $aDays = array();
     $oStartOfTomorrow = new Date($oEndOfToday);
     $oStartOfTomorrow->addSeconds(1);
     $oTempDate = new Date();
     $oTempDate->copy($oStartOfTomorrow);
     $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oTempDate);
     while ($aDates['start']->before($oEndDateCopy)) {
         // Increase the count for this day of the week
         $aDays[$aDates['start']->getDayOfWeek()]++;
         // Go to the next day
         $oTempDate->addSeconds(SECONDS_PER_DAY);
         $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oTempDate);
     }
     // Step 3: For every possible day of the week (assuming that day of the week is in the
     //         ad's remaining lifetime), calculate the sum of the forecast values for every
     //         operation interval in that day
     if (!empty($aDays)) {
         $operationIntervalsPerDay = OX_OperationInterval::operationIntervalsPerDay();
         $oTempDate = new Date($oStartOfTomorrow);
         $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oTempDate);
         for ($counter = 0; $counter < 7; $counter++) {
             // Are there any instances of this day in the campaign?
             if ($aDays[$oTempDate->getDayOfWeek()] > 0) {
                 // Calculate the sum of the zone forecasts for this day of week
                 $aDates = OX_OperationInterval::convertDateToOperationIntervalStartAndEndDates($oTempDate);
                 $dayStartOperationIntervalId = OX_OperationInterval::convertDateToOperationIntervalID($aDates['start']);
                 $aDayCumulativeZoneForecast = array_slice($aCumulativeZoneForecast, $dayStartOperationIntervalId, $operationIntervalsPerDay);
                 $forecastSum = array_sum($aDayCumulativeZoneForecast);
                 // Multiply this day's forecast sum value by the number of times this
                 // day of week appears in the remainder of the campaign and add the
                 // value to the running total
                 $totalAdLifetimeZoneImpressionsRemaining += $forecastSum * $aDays[$oTempDate->getDayOfWeek()];
             }
             // Go to the next day
             $oTempDate->addSeconds(SECONDS_PER_DAY);
         }
//.........这里部分代码省略.........
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:101,代码来源:DeliveryLimitation.php

示例15: testRun

 /**
  * A method to test the run() method.
  */
 function testRun()
 {
     $oServiceLocator =& OA_ServiceLocator::instance();
     $aTypes = array('types' => array(0 => 'request', 1 => 'impression', 2 => 'click'), 'connections' => array(1 => MAX_CONNECTION_AD_IMPRESSION, 2 => MAX_CONNECTION_AD_CLICK));
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectNever('saveSummary');
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = false;
     $oSummariseFinal->oController->updateFinal = false;
     $oSummariseFinal->run();
     $oDal->tally();
     // Prepare the dates
     $olastDateIntermediate = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateIntermediate);
     $oStartDate->addSeconds(1);
     $oUpdateIntermediateToDate = new Date('2006-03-09 11:59:59');
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectNever('saveSummary');
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = true;
     $oSummariseFinal->oController->oLastDateIntermediate = $olastDateIntermediate;
     $oSummariseFinal->oController->oUpdateIntermediateToDate = $oUpdateIntermediateToDate;
     $oSummariseFinal->oController->updateFinal = false;
     $oSummariseFinal->run();
     $oDal->tally();
     // Prepare the dates
     $olastDateFinal = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateFinal);
     $oStartDate->addSeconds(1);
     $oUpdateFinalToDate = new Date('2006-03-09 11:59:59');
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectOnce('saveSummary', array($oStartDate, $oUpdateFinalToDate, $aTypes, 'data_intermediate_ad', 'data_summary_ad_hourly'));
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = false;
     $oSummariseFinal->oController->updateFinal = true;
     $oSummariseFinal->oController->oLastDateFinal = $olastDateFinal;
     $oSummariseFinal->oController->oUpdateFinalToDate = $oUpdateFinalToDate;
     $oSummariseFinal->run();
     $oDal->tally();
     // Prepare the dates
     $olastDateIntermediate = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateIntermediate);
     $oStartDate->addSeconds(1);
     $oUpdateIntermediateToDate = new Date('2006-03-09 11:59:59');
     $olastDateFinal = new Date('2006-03-09 10:59:59');
     $oStartDate = new Date();
     $oStartDate->copy($olastDateFinal);
     $oStartDate->addSeconds(1);
     $oUpdateFinalToDate = new Date('2006-03-09 11:59:59');
     // Mock the DAL, and set expectations
     Mock::generate('OX_Dal_Maintenance_Statistics');
     $oDal = new MockOX_Dal_Maintenance_Statistics($this);
     $oDal->expectOnce('saveSummary', array($oStartDate, $oUpdateFinalToDate, $aTypes, 'data_intermediate_ad', 'data_summary_ad_hourly'));
     $oServiceLocator->register('OX_Dal_Maintenance_Statistics', $oDal);
     // Set the controller class
     $oMaintenanceStatistics = new OX_Maintenance_Statistics();
     $oServiceLocator->register('Maintenance_Statistics_Controller', $oMaintenanceStatistics);
     // Test
     $oSummariseFinal = new OX_Maintenance_Statistics_Task_SummariseFinal();
     $oSummariseFinal->oController->updateIntermediate = true;
     $oSummariseFinal->oController->oLastDateIntermediate = $olastDateIntermediate;
     $oSummariseFinal->oController->oUpdateIntermediateToDate = $oUpdateIntermediateToDate;
     $oSummariseFinal->oController->updateFinal = true;
     $oSummariseFinal->oController->oLastDateFinal = $olastDateFinal;
     $oSummariseFinal->oController->oUpdateFinalToDate = $oUpdateFinalToDate;
     $oSummariseFinal->run();
     $oDal->tally();
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:95,代码来源:SummariseFinal.mtsdb.test.php


注:本文中的Date::addSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。