static function deleteUserTicket(Ticket_User $item) { global $DB; $ticket = new Ticket(); $ptAssignUser = new PluginTimelineticketAssignUser(); $ticket->getFromDB($item->fields['tickets_id']); $calendar = new Calendar(); $calendars_id = Entity::getUsedConfig('calendars_id', $ticket->fields['entities_id']); $query = "SELECT MAX(`date`) AS datedebut, id\n FROM `" . $ptAssignUser->getTable() . "`\n WHERE `tickets_id` = '" . $item->fields['tickets_id'] . "'\n AND `users_id`='" . $item->fields['users_id'] . "'\n AND `delay` IS NULL"; $result = $DB->query($query); $datedebut = ''; $input = array(); if ($result && $DB->numrows($result)) { $datedebut = $DB->result($result, 0, 'datedebut'); $input['id'] = $DB->result($result, 0, 'id'); } else { return; } if (!$datedebut) { $delay = 0; // Utilisation calendrier } else { if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) { $delay = $calendar->getActiveTimeBetween($datedebut, $_SESSION["glpi_currenttime"]); } else { // cas 24/24 - 7/7 $delay = strtotime($_SESSION["glpi_currenttime"]) - strtotime($datedebut); } } $input['delay'] = $delay; $ptAssignUser->update($input); }