function prepareInputForUpdate($input)
{
Toolbox::manageBeginAndEndPlanDates($input['plan']);
if (isset($input['_planningrecall'])) {
PlanningRecall::manageDatas($input['_planningrecall']);
}
// $input["actiontime"] = $input["hour"]*HOUR_TIMESTAMP+$input["minute"]*MINUTE_TIMESTAMP;
if (isset($input['update']) && ($uid = Session::getLoginUserID())) {
// Change from task form
$input["users_id"] = $uid;
}
$itemtype = $this->getItilObjectItemType();
$input["_job"] = new $itemtype();
if (!$input["_job"]->getFromDB($input[$input["_job"]->getForeignKeyField()])) {
return false;
}
if (isset($input["plan"])) {
$input["begin"] = $input['plan']["begin"];
$input["end"] = $input['plan']["end"];
$timestart = strtotime($input["begin"]);
$timeend = strtotime($input["end"]);
$input["actiontime"] = $timeend - $timestart;
unset($input["plan"]);
if (!$this->test_valid_date($input)) {
Session::addMessageAfterRedirect(__('Error in entering dates. The starting date is later than the ending date'), false, ERROR);
return false;
}
Planning::checkAlreadyPlanned($input["users_id_tech"], $input["begin"], $input["end"], array($this->getType() => array($input["id"])));
$calendars_id = Entity::getUsedConfig('calendars_id', $input["_job"]->fields['entities_id']);
$calendar = new Calendar();
// Using calendar
if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
if (!$calendar->isAWorkingHour(strtotime($input["begin"]))) {
Session::addMessageAfterRedirect(__('Start of the selected timeframe is not a working hour.'), false, ERROR);
}
if (!$calendar->isAWorkingHour(strtotime($input["end"]))) {
Session::addMessageAfterRedirect(__('End of the selected timeframe is not a working hour.'), false, ERROR);
}
}
}
return $input;
}