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


PHP Tinebase_DateTime::isLater方法代码示例

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


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

示例1: _computeRecurMonthlyByMonthDay

 /**
  * computes monthly (bymonthday) recurring events and inserts them into given $_recurSet
  *
  * @param Calendar_Model_Event      $_event
  * @param Calendar_Model_Rrule      $_rrule
  * @param array                     $_exceptionRecurIds
  * @param Tinebase_DateTime                 $_from
  * @param Tinebase_DateTime                 $_until
  * @param Tinebase_Record_RecordSet $_recurSet
  * @return void
  */
 protected static function _computeRecurMonthlyByMonthDay($_event, $_rrule, $_exceptionRecurIds, $_from, $_until, $_recurSet)
 {
     $eventInOrganizerTZ = clone $_event;
     $eventInOrganizerTZ->setTimezone($_event->originator_tz);
     // some clients skip the monthday e.g. for yearly rrules
     if (!$_rrule->bymonthday) {
         $_rrule->bymonthday = $eventInOrganizerTZ->dtstart->format('j');
     }
     // NOTE: non existing dates will be discarded (e.g. 31. Feb.)
     //       for correct computations we deal with virtual dates, represented as arrays
     $computationStartDateArray = self::date2array($eventInOrganizerTZ->dtstart);
     // adopt startdate if rrule monthday != dtstart monthday
     // in this case, the first instance is not the base event!
     if ($_rrule->bymonthday != $computationStartDateArray['day']) {
         $computationStartDateArray['day'] = $_rrule->bymonthday;
         $computationStartDateArray = self::addMonthIgnoringDay($computationStartDateArray, -1 * $_rrule->interval);
     }
     $computationEndDate = $_event->rrule_until instanceof DateTime && $_until->isLater($_event->rrule_until) ? $_event->rrule_until : $_until;
     // if dtstart is before $_from, we compute the offset where to start our calculations
     if ($eventInOrganizerTZ->dtstart->isEarlier($_from)) {
         $computationOffsetMonth = self::getMonthDiff($eventInOrganizerTZ->dtend, $_from);
         // NOTE: $computationOffsetMonth must be multiple of interval!
         $computationOffsetMonth = floor($computationOffsetMonth / $_rrule->interval) * $_rrule->interval;
         $computationStartDateArray = self::addMonthIgnoringDay($computationStartDateArray, $computationOffsetMonth - $_rrule->interval);
     }
     $eventLength = $eventInOrganizerTZ->dtstart->diff($eventInOrganizerTZ->dtend);
     $originatorsOriginalDtstart = clone $eventInOrganizerTZ->dtstart;
     while (true) {
         $computationStartDateArray = self::addMonthIgnoringDay($computationStartDateArray, $_rrule->interval);
         $recurEvent = self::cloneEvent($eventInOrganizerTZ);
         $recurEvent->dtstart = self::array2date($computationStartDateArray, $eventInOrganizerTZ->originator_tz);
         // we calculate dtend from the event length, as events during a dst boundary could get dtend less than dtstart otherwise
         $recurEvent->dtend = clone $recurEvent->dtstart;
         $recurEvent->dtend->add($eventLength);
         $recurEvent->setTimezone('UTC');
         if ($computationEndDate->isEarlier($recurEvent->dtstart)) {
             break;
         }
         // skip non existing dates
         if (!Tinebase_DateTime::isDate(self::array2string($computationStartDateArray))) {
             continue;
         }
         // skip events ending before our period.
         // NOTE: such events could be included, cause our offset only calcs months and not seconds
         if ($_from->compare($recurEvent->dtend) >= 0) {
             continue;
         }
         $recurEvent->setRecurId($_event->getId());
         if (!in_array($recurEvent->recurid, $_exceptionRecurIds)) {
             self::addRecurrence($recurEvent, $_recurSet);
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:64,代码来源:Rrule.php

示例2: _createAutoInvoicesForContract

 /**
  * create auto invoices for one contract
  * 
  * @param Sales_Model_Contract $contract
  * @param Tinebase_DateTime $currentDate
  * @param boolean $merge
  */
 protected function _createAutoInvoicesForContract(Sales_Model_Contract $contract, Tinebase_DateTime $currentDate, $merge = false)
 {
     // set this current billing date (user timezone)
     $this->_currentBillingDate = clone $currentDate;
     $this->_currentBillingDate->setDate($this->_currentBillingDate->format('Y'), $this->_currentBillingDate->format('m'), 1);
     $this->_currentBillingDate->setTime(0, 0, 0);
     // check all prerequisites needed for billing of the contract
     if (!$this->_validateContract($contract)) {
         return false;
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Processing contract "' . $this->_currentBillingContract->number . '"');
     }
     // fire event to allow other applications do some work before billing
     $this->_firePrebillEvent();
     // find product aggregates of the current contract
     $productAggregates = $this->_findProductAggregates();
     // find month that needs to be billed next (note: _currentMonthToBill is the 01-01 00:00:00 of the next month, its the border, like last_autobill)
     $this->_currentMonthToBill = null;
     foreach ($productAggregates as $productAggregate) {
         if (null != $productAggregate->last_autobill) {
             $tmp = clone $productAggregate->last_autobill;
             $tmp->setDate($tmp->format('Y'), $tmp->format('m'), 1);
             $tmp->setTime(0, 0, 0);
             if (null == $this->_currentMonthToBill || $tmp->isLater($this->_currentMonthToBill)) {
                 $this->_currentMonthToBill = $tmp;
             }
         }
     }
     // this contract has no productAggregates, maybe just time accounts? use last invoice to find already billed month
     if (null == $this->_currentMonthToBill) {
         // find newest invoice of contract (probably can be done more efficient!)
         $invoiceRelations = Tinebase_Relations::getInstance()->getRelations('Sales_Model_Contract', 'Sql', $contract->getId(), NULL, array(), TRUE, array('Sales_Model_Invoice'));
         // do not modify $newestInvoiceTime!!!! it does NOT get cloned!
         $newestInvoiceTime = null;
         $newestInvoice = null;
         foreach ($invoiceRelations as $invoiceRelation) {
             $invoiceRelation->related_record->setTimezone(Tinebase_Core::getUserTimezone());
             if (null == $newestInvoiceTime || $invoiceRelation->related_record->creation_time->isLater($newestInvoiceTime)) {
                 $newestInvoiceTime = $invoiceRelation->related_record->creation_time;
                 $newestInvoice = $invoiceRelation->related_record;
             }
         }
         if (null != $newestInvoice) {
             // we can only take the end_date because there are no product aggregates (that have a last_autobill set) in this contract, otherwise it might be one interval ahead!
             $this->_currentMonthToBill = clone $newestInvoice->end_date;
             $this->_currentMonthToBill->addDay(4);
             $this->_currentMonthToBill->subMonth(1);
             //$this->_currentMonthToBill->setTimezone(Tinebase_Core::getUserTimezone());
         }
     }
     $_addMonth = true;
     if (null == $this->_currentMonthToBill) {
         $this->_currentMonthToBill = clone $contract->start_date;
         $_addMonth = false;
     }
     $this->_currentMonthToBill->setTimezone(Tinebase_Core::getUserTimezone());
     $this->_currentMonthToBill->setDate($this->_currentMonthToBill->format('Y'), $this->_currentMonthToBill->format('m'), 1);
     $this->_currentMonthToBill->setTime(0, 0, 0);
     if ($_addMonth) {
         $this->_currentMonthToBill->addMonth(1);
     }
     $doSleep = false;
     if (($merge || $contract->merge_invoices) && $this->_currentMonthToBill->isEarlier($this->_currentBillingDate)) {
         $this->_currentMonthToBill = clone $this->_currentBillingDate;
     }
     while ($this->_currentMonthToBill->isEarlierOrEquals($this->_currentBillingDate)) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' $this->_currentMonthToBill: ' . $this->_currentMonthToBill . ' $this->_currentBillingDate ' . $this->_currentBillingDate);
             foreach ($productAggregates as $productAggregate) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $productAggregate->id . ' ' . $productAggregate->last_autobill . ' ' . $productAggregate->interval);
             }
         }
         //required to have one sec difference in the invoice creation_time, can be optimized to look for milliseconds
         if ($doSleep) {
             sleep(1);
             $doSleep = false;
         }
         // prepare relations and find all billable accountables of the current contract
         list($relations, $billableAccountables) = $this->_prepareInvoiceRelationsAndFindBillableAccountables($productAggregates);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' count $billableAccountables: ' . count($billableAccountables));
             foreach ($billableAccountables as $ba) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' accountable: ' . get_class($ba['ac']) . ' id: ' . $ba['ac']->getId());
             }
         }
         // find invoice positions and the first start date and last end date of all billables
         list($invoicePositions, $earliestStartDate, $latestEndDate) = $this->_findInvoicePositionsAndInvoiceInterval($billableAccountables);
         /**** TODO ****/
         // if there are no positions, no more bills need to be created,
         // but the last_autobill info is set, if the current date is later
         if ($invoicePositions->count() > 0) {
             // prepare invoice
//.........这里部分代码省略.........
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:101,代码来源:Invoice.php


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