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


PHP Tinebase_DateTime::isLaterOrEquals方法代码示例

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


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

示例1: _prepareInvoiceRelationsAndFindBillableAccountables

 /**
  * prepares the relations and finds all billable accountables for the invoice
  * 
  * @param Tinebase_Record_RecordSet $productAggregates
  * @return array
  */
 protected function _prepareInvoiceRelationsAndFindBillableAccountables($productAggregates)
 {
     $modelsToBill = array();
     $billedRelations = array();
     $simpleProductsToBill = array();
     $modelsToSkip = array();
     // this holds all relations for the invoice
     $relations = array();
     $billableAccountables = array();
     // iterate product aggregates to get the billing definition for the models
     foreach ($productAggregates as $productAggregate) {
         // is null, if this is the first time to bill the product aggregate
         $lastBilled = $productAggregate->last_autobill == NULL ? NULL : clone $productAggregate->last_autobill;
         $productEnded = false;
         $endDate = NULL;
         if (NULL != $productAggregate->end_date) {
             $endDate = clone $productAggregate->end_date;
         }
         if ($this->_currentBillingContract->end_date != NULL && (NULL === $endDate || $endDate->isLater($this->_currentBillingContract->end_date))) {
             $endDate = clone $this->_currentBillingContract->end_date;
         }
         // if the product has been billed already, add the interval
         if ($lastBilled) {
             $nextBill = $lastBilled;
             $nextBill->setDate($nextBill->format('Y'), $nextBill->format('m'), 1);
             $nextBill->addMonth($productAggregate->interval);
             if (NULL !== $endDate && $endDate->isEarlier($nextBill)) {
                 if ($productAggregate->billing_point == 'end') {
                     if ($productAggregate->last_autobill->isEarlier($endDate)) {
                         // ok, fix nextBill to be close to endDate
                         $nextBill = $endDate;
                         $nextBill->setDate($nextBill->format('Y'), $nextBill->format('m'), 1);
                         $nextBill->addMonth(1);
                     } else {
                         // not ok, ignore
                         $productEnded = true;
                     }
                 } else {
                     // not ok, ignore
                     $productEnded = true;
                 }
             }
         } else {
             // it hasn't been billed already
             if (NULL != $productAggregate->start_date && $productAggregate->start_date->isLaterOrEquals($this->_currentBillingContract->start_date)) {
                 $nextBill = clone $productAggregate->start_date;
             } else {
                 $nextBill = clone $this->_currentBillingContract->start_date;
             }
             $nextBill->setDate($nextBill->format('Y'), $nextBill->format('m'), 1);
             // add interval, if the billing point is at the end of the interval
             if ($productAggregate->billing_point == 'end') {
                 $nextBill->addMonth($productAggregate->interval);
                 if (NULL !== $endDate && $endDate->isEarlier($nextBill)) {
                     // ok, fix nextBill to be close to endDate
                     $nextBill = $endDate;
                     $nextBill->setDate($nextBill->format('Y'), $nextBill->format('m'), 1);
                     $nextBill->addMonth(1);
                 }
             }
         }
         $nextBill->setTime(0, 0, 0);
         $product = $this->_cachedProducts->getById($productAggregate->product_id);
         if (!$product) {
             $product = Sales_Controller_Product::getInstance()->get($productAggregate->product_id);
             $this->_cachedProducts->addRecord($product);
         }
         // find out if this model has to be billed or skipped
         if (!$productEnded && $this->_currentMonthToBill->isLaterOrEquals($nextBill)) {
             if ($product->accountable == 'Sales_Model_Product' || $product->accountable == '') {
                 $simpleProductsToBill[] = array('pa' => $productAggregate, 'ac' => $productAggregate);
             } else {
                 if ($productAggregate->json_attributes && isset($productAggregate->json_attributes['assignedAccountables']) && is_array($productAggregate->json_attributes['assignedAccountables']) && count($productAggregate->json_attributes['assignedAccountables'])) {
                     foreach ($productAggregate->json_attributes['assignedAccountables'] as $relationId) {
                         $billedRelations[$relationId] = true;
                         $relation = $this->_currentBillingContract->relations->getById($relationId);
                         if (false === $relation || $product->accountable != $relation->related_model) {
                             throw new Tinebase_Exception_UnexpectedValue('couldnt resolved assignedAccountables');
                         }
                         $relations[] = array_merge(array('related_model' => $relation->related_model, 'related_id' => $relation->related_id, 'related_record' => $relation->related_record->toArray()), $this->_getRelationDefaults());
                         $billableAccountables[] = array('ac' => $relation->related_record, 'pa' => $productAggregate);
                     }
                 } else {
                     $modelsToBill[$product->accountable] = $productAggregate;
                 }
             }
         } else {
             $modelsToSkip[] = $product->accountable;
         }
     }
     // iterate relations, look for accountables, prepare relations
     foreach ($this->_currentBillingContract->relations as $relation) {
         if (isset($billedRelations[$relation->id])) {
             continue;
//.........这里部分代码省略.........
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:101,代码来源:Invoice.php

示例2: isBillable

 /**
  * returns true if this record should be billed for the specified date
  * 
  * @param Tinebase_DateTime $date
  * @param Sales_Model_Contract $contract
  * @param Sales_Model_ProductAggregate $productAggregate
  * @return boolean
  */
 public function isBillable(Tinebase_DateTime $date, Sales_Model_Contract $contract = NULL, Sales_Model_ProductAggregate $productAggregate = NULL)
 {
     $this->_referenceContract = $contract;
     if (!$this->last_autobill) {
         if (!$this->start_date) {
             $nextBill = clone $contract->start_date;
         } else {
             $nextBill = clone $this->start_date;
         }
         $nextBill->setDate($nextBill->format('Y'), $nextBill->format('m'), 1);
         if ($this->billing_point == 'end') {
             $nextBill->addMonth($this->interval);
         }
     } else {
         $nextBill = clone $this->last_autobill;
         $nextBill->setDate($nextBill->format('Y'), $nextBill->format('m'), 1);
         $nextBill->addMonth($this->interval);
     }
     // if we are not already in user timezone we are in deep shit, add assertation rather instead or something
     $nextBill->setTimeZone(Tinebase_Core::getUserTimezone());
     $nextBill->setTime(0, 0, 0);
     return $date->isLaterOrEquals($nextBill);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:31,代码来源:ProductAggregate.php


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