function showprofileForm($target, $ID) { global $LANG, $CFG_GLPI; if (!haveRight("profile", "r")) { return false; } $onfocus = ""; if ($ID) { $this->getFromDB($ID); } else { $this->getEmpty(); $onfocus = "onfocus=\"this.value=''\""; } if (empty($this->fields["interface"])) { $this->fields["interface"] = "fusioninventory"; } if (empty($this->fields["name"])) { $this->fields["name"] = $LANG["common"][0]; } echo "<form name='form' method='post' action=\"{$target}\">"; echo "<div align='center'>"; echo "<table class='tab_cadre'><tr>"; echo "<table class='tab_cadre_fixe'>"; echo "<th>" . $LANG["common"][16] . ":</th>"; echo "<th><input type='text' name='name' value=\"" . $this->fields["name"] . "\" {$onfocus}></th>"; echo "<tr><th colspan='2' align='center'><strong>TEST " . $this->fields["name"] . "</strong></th></tr>"; echo "<th>" . $LANG["profiles"][2] . ":</th>"; echo "<th><select name='interface' id='profile_interface'>"; echo "<option value='fusioninventory' " . ($this->fields["interface"] != "fusioninventory" ? "selected" : "") . ">" . $LANG['plugin_fusioninventory']["profile"][1] . "</option>"; echo "</select></th>"; echo "</tr></table>"; echo "</div>"; $params = array('interface' => '__VALUE__', 'ID' => $ID); ajaxUpdateItemOnSelectEvent("profile_interface", "profile_form", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/profiles.php", $params, false); ajaxUpdateItem("profile_form", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/ajax/profiles.php", $params, false, 'profile_interface'); //$prof=new PluginFusioninventoryProfile; // $prof->showfusioninventoryForm($_POST["ID"]); echo "<br>"; echo "<div align='center' id='profile_form'>"; echo "</div>"; echo "</form>"; }
/** * Show generic date search * * @param $element name of the html element * @param $value default value * @param $with_time display with time selection ? * @param $with_future display with future date selection ? * * @return rand value of dropdown **/ function showGenericDateTimeSearch($element, $value = '', $with_time = false, $with_future = false) { global $LANG, $CFG_GLPI; $rand = mt_rand(); // Validate value if ($value != 'NOW' && !preg_match("/\\d{4}-\\d{2}-\\d{2}.*/", $value) && !strstr($value, 'HOUR') && !strstr($value, 'DAY') && !strstr($value, 'WEEK') && !strstr($value, 'MONTH') && !strstr($value, 'YEAR')) { $value = ""; } if (empty($value)) { $value = 'NOW'; } $specific_value = date("Y-m-d H:i:s"); if (preg_match("/\\d{4}-\\d{2}-\\d{2}.*/", $value)) { $specific_value = $value; $value = 0; } echo "<table><tr><td>"; echo "<select id='genericdate{$element}{$rand}' name='_select_{$element}'>"; $val = 'NOW'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">" . $LANG['calendar'][16] . "</option>"; echo "<option value='0' " . ($value === 0 ? 'selected' : '') . ">" . $LANG['calendar'][17] . "</option>"; if ($with_time) { for ($i = 1; $i <= 24; $i++) { $val = '-' . $i . 'HOUR'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "- {$i} " . $LANG['gmt'][1] . "</option>"; } } for ($i = 1; $i <= 7; $i++) { $val = '-' . $i . 'DAY'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "- {$i} " . $LANG['calendar'][12] . "</option>"; } for ($i = 1; $i <= 10; $i++) { $val = '-' . $i . 'WEEK'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "- {$i} " . $LANG['calendar'][13] . "</option>"; } for ($i = 1; $i <= 12; $i++) { $val = '-' . $i . 'MONTH'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "- {$i} " . $LANG['calendar'][14] . "</option>"; } for ($i = 1; $i <= 10; $i++) { $val = '-' . $i . 'YEAR'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "- {$i} " . $LANG['calendar'][15] . "</option>"; } if ($with_future) { if ($with_time) { for ($i = 1; $i <= 24; $i++) { $val = $i . 'HOUR'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "+ {$i} " . $LANG['gmt'][1] . "</option>"; } } for ($i = 1; $i <= 7; $i++) { $val = $i . 'DAY'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "+ {$i} " . $LANG['calendar'][12] . "</option>"; } for ($i = 1; $i <= 10; $i++) { $val = $i . 'WEEK'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "+ {$i} " . $LANG['calendar'][13] . "</option>"; } for ($i = 1; $i <= 12; $i++) { $val = $i . 'MONTH'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "+ {$i} " . $LANG['calendar'][14] . "</option>"; } for ($i = 1; $i <= 10; $i++) { $val = $i . 'YEAR'; echo "<option value='{$val}' " . ($value === $val ? 'selected' : '') . ">"; echo "+ {$i} " . $LANG['calendar'][15] . "</option>"; } } echo "</select>"; echo "</td><td>"; echo "<div id='displaygenericdate{$element}{$rand}'></div>"; $params = array('value' => '__VALUE__', 'name' => $element, 'withtime' => $with_time, 'specificvalue' => $specific_value); ajaxUpdateItemOnSelectEvent("genericdate{$element}{$rand}", "displaygenericdate{$element}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/genericdate.php", $params, false); $params['value'] = $value; ajaxUpdateItem("displaygenericdate{$element}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/genericdate.php", $params); echo "</td></tr></table>"; return $rand; }
} if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } checkLoginUser(); if (isset($_POST["sub_type"])) { $rule = new $_POST["sub_type"](); $criterias = $rule->getCriterias(); if (count($criterias)) { // First include -> first of the predefined array if (!isset($_POST["criteria"])) { $_POST["criteria"] = key($criterias); } $type = ""; if (isset($criterias[$_POST["criteria"]]['type'])) { $type = $criterias[$_POST["criteria"]]['type']; } if (isset($criterias[$_POST["criteria"]]['allow_condition'])) { $allow_condition = $criterias[$_POST["criteria"]]['allow_condition']; } else { $allow_condition = array(); } $randcrit = RuleCriteria::dropdownConditions($_POST["sub_type"], array('criterion' => $_POST["criteria"], 'allow_conditions' => $allow_condition)); echo " "; echo "<span id='condition_span{$randcrit}'>\n"; echo "</span>\n"; $paramscriteria = array('condition' => '__VALUE__', 'criteria' => $_POST["criteria"], 'sub_type' => $_POST["sub_type"]); ajaxUpdateItemOnSelectEvent("dropdown_condition{$randcrit}", "condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria, false); ajaxUpdateItem("condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria, false, "dropdown_condition{$randcrit}"); } }
/** * Make a select box for all items * * @param $myname select name * @param $value_type default value for the device type * @param $value default value * @param $entity_restrict Restrict to a defined entity * @param $types Types used * @param $onlyglobal Restrict to global items * * @return nothing (print out an HTML select box) **/ static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types = '', $onlyglobal = false) { global $LANG, $CFG_GLPI; if (!is_array($types)) { $types = $CFG_GLPI["state_types"]; } $rand = mt_rand(); $options = array(); foreach ($types as $type) { if (class_exists($type)) { $item = new $type(); $options[$type] = $item->getTypeName($type); } } asort($options); if (count($options)) { echo "<select name='itemtype' id='itemtype{$rand}'>"; echo "<option value='0'>" . DROPDOWN_EMPTY_VALUE . "</option>\n"; foreach ($options as $key => $val) { echo "<option value='" . $key . "'>" . $val . "</option>"; } echo "</select>"; $params = array('idtable' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'entity_restrict' => $entity_restrict); if ($onlyglobal) { $params['condition'] = "`is_global` = '1'"; } ajaxUpdateItemOnSelectEvent("itemtype{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownAllItems.php", $params); echo "<br><span id='show_{$myname}{$rand}'> </span>\n"; if ($value > 0) { echo "<script type='text/javascript' >\n"; echo "window.document.getElementById('itemtype{$rand}').value='" . $value_type . "';"; echo "</script>\n"; $params["idtable"] = $value_type; ajaxUpdateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownAllItems.php", $params); } } return $rand; }
/** * Print generic search form * * @param $itemtype type to display the form * @param $params parameters array may include field, contains, sort, is_deleted, link, link2, * contains2, field2, type2 * *@return nothing (displays) **/ static function showGenericSearch($itemtype, $params) { global $LANG, $CFG_GLPI; // Default values of parameters $p['link'] = array(); // $p['field'] = array(); $p['contains'] = array(); $p['searchtype'] = array(); $p['sort'] = ''; $p['is_deleted'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; $p['field2'] = ''; $p['itemtype2'] = ''; $p['searchtype2'] = ''; foreach ($params as $key => $val) { $p[$key] = $val; } $options = self::getCleanedOptions($itemtype); $target = getItemTypeSearchURL($itemtype); // Instanciate an object to access method $item = NULL; if ($itemtype != 'States' && class_exists($itemtype)) { $item = new $itemtype(); } $linked = self::getMetaItemtypeAvailable($itemtype); echo "<form name='searchform{$itemtype}' method='get' action=\"{$target}\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo "<table>"; // Display normal search parameters for ($i = 0; $i < $_SESSION["glpisearchcount"][$itemtype]; $i++) { echo "<tr><td class='left' width='50%'>"; // First line display add / delete images for normal and meta search items if ($i == 0) { echo "<input type='hidden' disabled id='add_search_count' name='add_search_count'\n value='1'>"; echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;\n document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title=\"" . $LANG['search'][17] . "\"></a> "; if ($_SESSION["glpisearchcount"][$itemtype] > 1) { echo "<input type='hidden' disabled id='delete_search_count'\n name='delete_search_count' value='1'>"; echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;\n document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title=\"" . $LANG['search'][18] . "\"></a> "; } if (is_array($linked) && count($linked) > 0) { echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2'\n value='1'>"; echo "<a href='#' onClick=\"document.getElementById('add_search_count2').disabled=false;\n document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title=\"" . $LANG['search'][19] . "\"></a> "; if ($_SESSION["glpisearchcount2"][$itemtype] > 0) { echo "<input type='hidden' disabled id='delete_search_count2'\n name='delete_search_count2' value='1'>"; echo "<a href='#' onClick=\"document.getElementById('delete_search_count2').disabled=false;\n document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title=\"" . $LANG['search'][20] . "\"></a> "; } } $itemtable = getTableForItemType($itemtype); if ($item && $item->maybeDeleted()) { echo "<input type='hidden' id='is_deleted' name='is_deleted' value='" . $p['is_deleted'] . "'>"; echo "<a href='#' onClick = \"toogle('is_deleted','','','');\n document.forms['searchform{$itemtype}'].submit();\">\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/showdeleted" . (!$p['is_deleted'] ? '_no' : '') . ".png\" name='img_deleted' alt=\"" . (!$p['is_deleted'] ? $LANG['common'][3] : $LANG['common'][81]) . "\" title=\"" . (!$p['is_deleted'] ? $LANG['common'][3] : $LANG['common'][81]) . "\" ></a>"; // Dropdown::showYesNo("is_deleted",$p['is_deleted']); echo ' '; } } // Display link item if ($i > 0) { echo "<select name='link[{$i}]'>"; echo "<option value = 'AND' "; if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND") { echo "selected"; } echo ">AND</option>\n"; echo "<option value='OR' "; if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR") { echo "selected"; } echo ">OR</option>\n"; echo "<option value='AND NOT' "; if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "AND NOT") { echo "selected"; } echo ">AND NOT</option>\n"; echo "<option value='OR NOT' "; if (is_array($p["link"]) && isset($p["link"][$i]) && $p["link"][$i] == "OR NOT") { echo "selected"; } echo ">OR NOT</option>"; echo "</select> "; } // display select box to define search item echo "<select id='Search{$itemtype}{$i}' name=\"field[{$i}]\" size='1'>"; echo "<option value='view' "; if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "view") { echo "selected"; } echo ">" . $LANG['search'][11] . "</option>\n"; reset($options); $first_group = true; $selected = 'view'; $str_limit = 28; $nb_in_group = 0; $group = ''; foreach ($options as $key => $val) { // print groups if (!is_array($val)) { if (!$first_group) { $group .= "</optgroup>\n"; } else { $first_group = false; } if ($nb_in_group) { echo $group; } $group = ''; $nb_in_group = 0; $group .= "<optgroup label=\"" . utf8_substr($val, 0, $str_limit) . "\">"; } else { if (!isset($val['nosearch']) || $val['nosearch'] == false) { $nb_in_group++; $group .= "<option title=\"" . cleanInputText($val["name"]) . "\" value='{$key}'"; if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) { $group .= "selected"; $selected = $key; } $group .= ">" . utf8_substr($val["name"], 0, $str_limit) . "</option>\n"; } } } if (!$first_group) { $group .= "</optgroup>\n"; } if ($nb_in_group) { echo $group; } echo "<option value='all' "; if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") { echo "selected"; } echo ">" . $LANG['common'][66] . "</option>"; echo "</select>\n"; echo "</td><td class='left'>"; echo "<div id='SearchSpan{$itemtype}{$i}'>\n"; $_POST['itemtype'] = $itemtype; $_POST['num'] = $i; $_POST['field'] = $selected; $_POST['searchtype'] = is_array($p['searchtype']) && isset($p['searchtype'][$i]) ? $p['searchtype'][$i] : ""; $_POST['value'] = is_array($p['contains']) && isset($p['contains'][$i]) ? stripslashes($p['contains'][$i]) : ""; include GLPI_ROOT . "/ajax/searchoption.php"; echo "</div>\n"; $params = array('field' => '__VALUE__', 'itemtype' => $itemtype, 'num' => $i, 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"]); ajaxUpdateItemOnSelectEvent("Search{$itemtype}{$i}", "SearchSpan{$itemtype}{$i}", $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params, false); echo "</td></tr>\n"; } $metanames = array(); if (is_array($linked) && count($linked) > 0) { for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) { echo "<tr><td class='left' colspan='2'>"; $rand = mt_rand(); echo "<table width='100%'><tr class='left'><td width='35%'>"; // Display link item (not for the first item) echo "<select name='link2[{$i}]'>"; echo "<option value='AND' "; if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND") { echo "selected"; } echo ">AND</option>\n"; echo "<option value='OR' "; if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR") { echo "selected"; } echo ">OR</option>\n"; echo "<option value='AND NOT' "; if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "AND NOT") { echo "selected"; } echo ">AND NOT</option>\n"; echo "<option value='OR NOT' "; if (is_array($p['link2']) && isset($p['link2'][$i]) && $p['link2'][$i] == "OR NOT") { echo "selected"; } echo ">OR NOT</option>\n"; echo "</select> "; // Display select of the linked item type available echo "<select name='itemtype2[{$i}]' id='itemtype2_" . $itemtype . "_" . $i . "_{$rand}'>"; echo "<option value=''>" . DROPDOWN_EMPTY_VALUE . "</option>"; foreach ($linked as $key) { if (!isset($metanames[$key])) { $linkitem = new $key(); $metanames[$key] = $linkitem->getTypeName(); } echo "<option value='{$key}'>" . utf8_substr($metanames[$key], 0, 20) . "</option>\n"; } echo "</select> "; echo "</td><td>"; // Ajax script for display search met& item echo "<span id='show_" . $itemtype . "_" . $i . "_{$rand}'> </span>\n"; $params = array('itemtype' => '__VALUE__', 'num' => $i, 'field' => is_array($p['field2']) && isset($p['field2'][$i]) ? $p['field2'][$i] : "", 'value' => is_array($p['contains2']) && isset($p['contains2'][$i]) ? $p['contains2'][$i] : "", 'searchtype2' => is_array($p['searchtype2']) && isset($p['searchtype2'][$i]) ? $p['searchtype2'][$i] : ""); ajaxUpdateItemOnSelectEvent("itemtype2_" . $itemtype . "_" . $i . "_{$rand}", "show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false); if (is_array($p['itemtype2']) && isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i])) { $params['itemtype'] = $p['itemtype2'][$i]; ajaxUpdateItem("show_" . $itemtype . "_" . $i . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params, false); echo "<script type='text/javascript' >"; echo "window.document.getElementById('itemtype2_" . $itemtype . "_" . $i . "_{$rand}').value='" . $p['itemtype2'][$i] . "';"; echo "</script>\n"; } echo "</td></tr></table>"; echo "</td></tr>\n"; } } echo "</table>\n"; echo "</td>\n"; echo "<td width='150px'>"; echo "<table width='100%'>"; // Display sort selection /* echo "<tr><td colspan='2'>".$LANG['search'][4]; echo " <select name='sort' size='1'>"; reset($options); $first_group=true; foreach ($options as $key => $val) { if (!is_array($val)) { if (!$first_group) { echo "</optgroup>\n"; } else { $first_group=false; } echo "<optgroup label=\"$val\">"; } else { echo "<option value='$key'"; if ($key == $p['sort']) { echo " selected"; } echo ">".utf8_substr($val["name"],0,20)."</option>\n"; } } if (!$first_group) { echo "</optgroup>\n"; } echo "</select> "; echo "</td></tr>\n"; */ // Display deleted selection echo "<tr>"; // Display submit button echo "<td width='80' class='center'>"; echo "<input type='submit' value=\"" . $LANG['buttons'][0] . "\" class='submit' >"; echo "</td><td>"; Bookmark::showSaveButton(BOOKMARK_SEARCH, $itemtype); echo "<a href='{$target}?reset=reset' >"; echo " <img title=\"" . $LANG['buttons'][16] . "\" alt=\"" . $LANG['buttons'][16] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>"; echo "</td></tr></table>\n"; echo "</td></tr>"; echo "</table>\n"; // For dropdown echo "<input type='hidden' name='itemtype' value='{$itemtype}'>"; // Reset to start when submit new search echo "<input type='hidden' name='start' value='0'>"; echo "</form>"; }
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- // Direct access to file if (strpos($_SERVER['PHP_SELF'], "ruleaction.php")) { define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); } if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } checkLoginUser(); // Non define case if (isset($_POST["sub_type"]) && class_exists($_POST["sub_type"])) { if (!isset($_POST["field"])) { $_POST["field"] = key(Rule::getActionsByType($_POST["sub_type"])); } $randaction = RuleAction::dropdownActions($_POST["sub_type"], "action_type", $_POST["field"]); echo " "; echo "<span id='action_type_span{$randaction}'>\n"; echo "</span>\n"; $paramsaction = array('action_type' => '__VALUE__', 'field' => $_POST["field"], 'sub_type' => $_POST["sub_type"]); ajaxUpdateItemOnSelectEvent("dropdown_action_type{$randaction}", "action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction, false); ajaxUpdateItem("action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction, false, "dropdown_action_type{$randaction}"); }
User::dropdown(array('name' => "plan[users_id]", 'value' => $_POST["users_id"], 'right' => "own_ticket", 'entity' => $_POST["entity"])); echo "</td></tr>\n"; } echo "<tr class='tab_bg_2'><td>" . $LANG['state'][0] . " : </td>"; echo "<td class='center'>"; Planning::dropdownState("plan[state]", $state); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . $LANG['search'][8] . " : </td><td>"; $rand_begin = showDateTimeFormItem("plan[begin]", $begin, -1, false, true, '', '', $CFG_GLPI["planning_begin"], $CFG_GLPI["planning_end"]); echo "</td></tr>\n"; echo "<tr class='tab_bg_2'><td>" . $LANG['planning'][3] . " : </td><td>"; $values = array(0 => $LANG['search'][12], 15 * MINUTE_TIMESTAMP => '0' . $LANG['gmt'][2] . '15', 30 * MINUTE_TIMESTAMP => '0' . $LANG['gmt'][2] . '30', 45 * MINUTE_TIMESTAMP => '0' . $LANG['gmt'][2] . '45', 60 * MINUTE_TIMESTAMP => '1' . $LANG['gmt'][2] . '00', 90 * MINUTE_TIMESTAMP => '1' . $LANG['gmt'][2] . '30', 120 * MINUTE_TIMESTAMP => '2' . $LANG['gmt'][2] . '00', 150 * MINUTE_TIMESTAMP => '2' . $LANG['gmt'][2] . '30', 180 * MINUTE_TIMESTAMP => '3' . $LANG['gmt'][2] . '00', 210 * MINUTE_TIMESTAMP => '3' . $LANG['gmt'][2] . '30', 4 * HOUR_TIMESTAMP => '4' . $LANG['gmt'][2] . '00', 5 * HOUR_TIMESTAMP => '5' . $LANG['gmt'][2] . '00', 6 * HOUR_TIMESTAMP => '6' . $LANG['gmt'][2] . '00', 7 * HOUR_TIMESTAMP => '7' . $LANG['gmt'][2] . '00', 8 * HOUR_TIMESTAMP => '8' . $LANG['gmt'][2] . '00'); $default_delay = 0; $begin_timestamp = strtotime($begin); $end_timestamp = strtotime($end); // Floor with MINUTE_TIMESTAMP for rounded purpose $computed_delay = floor(($end_timestamp - $begin_timestamp) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP; if (isset($values[$computed_delay])) { $default_delay = $computed_delay; } $rand = Dropdown::showFromArray("plan[_duration]", $values, array('value' => $default_delay)); echo "<br><div id='date_end{$rand}'></div>"; $params = array('duration' => '__VALUE__', 'end' => $end, 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]); ajaxUpdateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params, false); if ($default_delay == 0) { $params['duration'] = 0; ajaxUpdateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params); } echo "</td></tr>\n"; echo "</table>\n"; ajaxFooter();