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


PHP Calendar::computeEndDate方法代码示例

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


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

示例1: unset


//.........这里部分代码省略.........
                 unset($this->updates[$key]);
                 unset($this->oldvalues['date']);
             }
             if (($key = array_search('closedate', $this->updates)) !== false) {
                 unset($this->updates[$key]);
                 unset($this->oldvalues['closedate']);
             }
         }
     }
     /*      if (in_array("users_id",$this->updates)) {
              $user = new User;
              $user->getFromDB($this->input["users_id"]);
              if (!empty($user->fields["email"])) {
                 $this->updates[] = "user_email";
                 $this->fields["user_email"] = $user->fields["email"];
              }
           }*/
     if (($key = array_search('status', $this->updates)) !== false && $this->oldvalues['status'] == $this->fields['status']) {
         unset($this->updates[$key]);
         unset($this->oldvalues['status']);
     }
     $sla = new SLA();
     // Set begin waiting date if needed
     if (($key = array_search('status', $this->updates)) !== false && ($this->fields['status'] == 'waiting' || $this->fields['status'] == 'solved')) {
         $this->updates[] = "begin_waiting_date";
         $this->fields["begin_waiting_date"] = $_SESSION["glpi_currenttime"];
         if ($this->fields['slas_id'] > 0) {
             $sla->deleteLevelsToDo($this);
         }
     }
     // Manage come back to waiting state
     if ($key = array_search('status', $this->updates) !== false && ($this->oldvalues['status'] == 'waiting' || $this->oldvalues['status'] == 'solved' && $this->fields['status'] != 'closed')) {
         // Compute ticket waiting time use calendar if exists
         $calendars_id = EntityData::getUsedConfig('calendars_id', $this->fields['entities_id']);
         $calendar = new Calendar();
         $delay_time = 0;
         // Compute ticket waiting time use calendar if exists
         // Using calendar
         if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
             $delay_time = $calendar->getActiveTimeBetween($this->fields['begin_waiting_date'], $_SESSION["glpi_currenttime"]);
         } else {
             // Not calendar defined
             $delay_time = strtotime($_SESSION["glpi_currenttime"]) - strtotime($this->fields['begin_waiting_date']);
         }
         // SLA case : compute sla duration
         if ($this->fields['slas_id'] > 0) {
             if ($sla->getFromDB($this->fields['slas_id'])) {
                 $delay_time_sla = $sla->getActiveTimeBetween($this->fields['begin_waiting_date'], $_SESSION["glpi_currenttime"]);
                 $this->updates[] = "sla_waiting_duration";
                 $this->fields["sla_waiting_duration"] += $delay_time_sla;
             }
             // Compute new due date
             $this->updates[] = "due_date";
             $this->fields['due_date'] = $sla->computeDueDate($this->fields['date'], $this->fields["sla_waiting_duration"]);
             // Add current level to do
             $sla->addLevelToDo($this);
         } else {
             // Using calendar
             if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
                 if ($this->fields['due_date'] > 0) {
                     // compute new due date using calendar
                     $this->updates[] = "due_date";
                     $this->fields['due_date'] = $calendar->computeEndDate($this->fields['due_date'], $delay_time);
                 }
             } else {
                 // Not calendar defined
                 if ($this->fields['due_date'] > 0) {
                     // compute new due date : no calendar so add computed delay_time
                     $this->updates[] = "due_date";
                     $this->fields['due_date'] = date('Y-m-d H:i:s', $delay_time + strtotime($this->fields['due_date']));
                 }
             }
         }
         $this->updates[] = "ticket_waiting_duration";
         $this->fields["ticket_waiting_duration"] += $delay_time;
         // Reset begin_waiting_date
         $this->updates[] = "begin_waiting_date";
         $this->fields["begin_waiting_date"] = 'NULL';
     }
     // solve_delay_stat : use delay between opendate and solvedate
     if (in_array("solvedate", $this->updates)) {
         $this->updates[] = "solve_delay_stat";
         $this->fields['solve_delay_stat'] = $this->computeSolveDelayStat();
     }
     // close_delay_stat : use delay between opendate and closedate
     if (in_array("closedate", $this->updates)) {
         $this->updates[] = "close_delay_stat";
         $this->fields['close_delay_stat'] = $this->computeCloseDelayStat();
     }
     // takeintoaccount :
     //     - update done by someone who have update right / see also updatedatemod used by ticketfollowup updates
     if ($this->canUpdateItem() && $this->fields['takeintoaccount_delay_stat'] == 0) {
         $this->updates[] = "takeintoaccount_delay_stat";
         $this->fields['takeintoaccount_delay_stat'] = $this->computeTakeIntoAccountDelayStat();
     }
     // Do not take into account date_mod if no update is done
     if (count($this->updates) == 1 && ($key = array_search('date_mod', $this->updates)) !== false) {
         unset($this->updates[$key]);
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:ticket.class.php

示例2: unset


//.........这里部分代码省略.........
                 unset($this->updates[$key]);
                 unset($this->oldvalues['closedate']);
             }
         }
     }
     if (($key = array_search('status', $this->updates)) !== false && $this->oldvalues['status'] == $this->fields['status']) {
         unset($this->updates[$key]);
         unset($this->oldvalues['status']);
     }
     // Status solved : check dates
     if (in_array($this->fields["status"], $this->getSolvedStatusArray()) && (in_array("date", $this->updates) || in_array("solvedate", $this->updates))) {
         // Invalid dates : no change
         // solvedate must be > create date
         if ($this->fields["solvedate"] < $this->fields["date"]) {
             Session::addMessageAfterRedirect(__('Invalid dates. Update cancelled.'), false, ERROR);
             if (($key = array_search('date', $this->updates)) !== false) {
                 unset($this->updates[$key]);
                 unset($this->oldvalues['date']);
             }
             if (($key = array_search('solvedate', $this->updates)) !== false) {
                 unset($this->updates[$key]);
                 unset($this->oldvalues['solvedate']);
             }
         }
     }
     // Manage come back to waiting state
     if (!is_null($this->fields['begin_waiting_date']) && ($key = array_search('status', $this->updates)) !== false && ($this->oldvalues['status'] == self::WAITING || in_array($this->oldvalues["status"], $this->getSolvedStatusArray()) && !in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         // Compute ticket waiting time use calendar if exists
         $calendars_id = Entity::getUsedConfig('calendars_id', $this->fields['entities_id']);
         $calendar = new Calendar();
         $delay_time = 0;
         // Compute ticket waiting time use calendar if exists
         // Using calendar
         if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
             $delay_time = $calendar->getActiveTimeBetween($this->fields['begin_waiting_date'], $_SESSION["glpi_currenttime"]);
         } else {
             // Not calendar defined
             $delay_time = strtotime($_SESSION["glpi_currenttime"]) - strtotime($this->fields['begin_waiting_date']);
         }
         // SLA case : compute sla duration
         if (isset($this->fields['slas_id']) && $this->fields['slas_id'] > 0) {
             $sla = new SLA();
             if ($sla->getFromDB($this->fields['slas_id'])) {
                 $sla->setTicketCalendar($calendars_id);
                 $delay_time_sla = $sla->getActiveTimeBetween($this->fields['begin_waiting_date'], $_SESSION["glpi_currenttime"]);
                 $this->updates[] = "sla_waiting_duration";
                 $this->fields["sla_waiting_duration"] += $delay_time_sla;
             }
             // Compute new due date
             $this->updates[] = "due_date";
             $this->fields['due_date'] = $sla->computeDueDate($this->fields['date'], $this->fields["sla_waiting_duration"]);
             // Add current level to do
             $sla->addLevelToDo($this);
         } else {
             // Using calendar
             if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
                 if ($this->fields['due_date'] > 0) {
                     // compute new due date using calendar
                     $this->updates[] = "due_date";
                     $this->fields['due_date'] = $calendar->computeEndDate($this->fields['due_date'], $delay_time);
                 }
             } else {
                 // Not calendar defined
                 if ($this->fields['due_date'] > 0) {
                     // compute new due date : no calendar so add computed delay_time
                     $this->updates[] = "due_date";
                     $this->fields['due_date'] = date('Y-m-d H:i:s', $delay_time + strtotime($this->fields['due_date']));
                 }
             }
         }
         $this->updates[] = "waiting_duration";
         $this->fields["waiting_duration"] += $delay_time;
         // Reset begin_waiting_date
         $this->updates[] = "begin_waiting_date";
         $this->fields["begin_waiting_date"] = 'NULL';
     }
     // Set begin waiting date if needed
     if (($key = array_search('status', $this->updates)) !== false && ($this->fields['status'] == self::WAITING || in_array($this->fields["status"], $this->getSolvedStatusArray()))) {
         $this->updates[] = "begin_waiting_date";
         $this->fields["begin_waiting_date"] = $_SESSION["glpi_currenttime"];
         // Specific for tickets
         if (isset($this->fields['slas_id']) && $this->fields['slas_id'] > 0) {
             SLA::deleteLevelsToDo($this);
         }
     }
     // solve_delay_stat : use delay between opendate and solvedate
     if (in_array("solvedate", $this->updates)) {
         $this->updates[] = "solve_delay_stat";
         $this->fields['solve_delay_stat'] = $this->computeSolveDelayStat();
     }
     // close_delay_stat : use delay between opendate and closedate
     if (in_array("closedate", $this->updates)) {
         $this->updates[] = "close_delay_stat";
         $this->fields['close_delay_stat'] = $this->computeCloseDelayStat();
     }
     // Do not take into account date_mod if no update is done
     if (count($this->updates) == 1 && ($key = array_search('date_mod', $this->updates)) !== false) {
         unset($this->updates[$key]);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:commonitilobject.class.php

示例3: computeExecutionDate

 /**
  * Get execution date of a sla level
  *
  * @param $start_date         datetime    start date
  * @param $slalevels_id       integer     sla level id
  * @param $additional_delay   integer     additional delay to add or substract (for waiting time)
  *                                        (default 0)
  *
  * @return execution date time (NULL if sla not exists)
  **/
 function computeExecutionDate($start_date, $slalevels_id, $additional_delay = 0)
 {
     if (isset($this->fields['id'])) {
         $slalevel = new SlaLevel();
         if ($slalevel->getFromDB($slalevels_id)) {
             // sla level exists
             if ($slalevel->fields['slas_id'] == $this->fields['id']) {
                 // correct sla level
                 $work_in_days = $this->fields['definition_time'] == 'day';
                 $delay = $this->getResolutionTime();
                 // Based on a calendar
                 if ($this->fields['calendars_id'] > 0) {
                     $cal = new Calendar();
                     if ($cal->getFromDB($this->fields['calendars_id'])) {
                         return $cal->computeEndDate($start_date, $delay, $slalevel->fields['execution_time'] + $additional_delay, $work_in_days);
                     }
                 }
                 // No calendar defined or invalid calendar
                 $delay += $additional_delay + $slalevel->fields['execution_time'];
                 $starttime = strtotime($start_date);
                 $endtime = $starttime + $delay;
                 return date('Y-m-d H:i:s', $endtime);
             }
         }
     }
     return NULL;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:37,代码来源:sla.class.php


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