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


PHP Tinebase_DateTime::addYear方法代码示例

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


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

示例1: createMissingAccounts

 /**
  * creates missing accounts for all employees having a valid contract
  * if a year is given, missing accounts for this year will be built, otherwise the current and following year will be used
  *
  * @param integer $year
  * @param HumanResources_Model_Employee
  * @param boolean $useBackend Use Backend instead of this Controller (may called by setup also, skips rigts, creating modlog etc.)
  */
 public function createMissingAccounts($year = NULL, $employee = NULL, $useBackend = FALSE)
 {
     // if no year is given, call myself with this year and just go on with the next year
     if (!$year) {
         $date = new Tinebase_DateTime();
         $year = (int) $date->format('Y');
         $this->createMissingAccounts($year, $employee);
         $date->addYear(1);
         $year = (int) $date->format('Y');
     }
     // tine20 should last a hundred years :)
     if ($year < 2006 || $year >= 2106 || !is_int($year)) {
         throw new Tinebase_Exception_Data('The year must be between 2006 and 2106');
     }
     // borders
     $year_starts = new Tinebase_DateTime($year . '-01-01 00:00:00');
     $year_ends = new Tinebase_DateTime($year . '-12-31 23:59:59');
     $validEmployeeIds = array_unique($this->_contractController->getValidContracts($year_starts, $year_ends, $employee)->employee_id);
     $existingFilter = new HumanResources_Model_AccountFilter(array(array('field' => 'year', 'operator' => 'equals', 'value' => $year)));
     $existingFilter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'employee_id', 'operator' => 'in', 'value' => $validEmployeeIds)));
     $result = $this->search($existingFilter)->employee_id;
     $validEmployeeIds = array_diff($validEmployeeIds, $result);
     $createdAccounts = new Tinebase_Record_RecordSet('HumanResources_Model_Account');
     if ($useBackend) {
         $be = new HumanResources_Backend_Account();
         foreach ($validEmployeeIds as $id) {
             $createdAccounts->addRecord($be->create(new HumanResources_Model_Account(array('employee_id' => $id, 'year' => $year))));
         }
     } else {
         foreach ($validEmployeeIds as $id) {
             $createdAccounts->addRecord($this->create(new HumanResources_Model_Account(array('employee_id' => $id, 'year' => $year))));
         }
     }
     return $createdAccounts;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:43,代码来源:Account.php


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