static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1, $action = 'showItem') { global $DB, $CFG_GLPI; $rand = mt_rand(); $plugin = new Plugin(); echo "<table border='0'><tr><td>\n"; if ($myname == 'type') { $newtypes = array_flip($types); unset($newtypes['Location']); unset($newtypes['Netpoint']); if ($plugin->isActivated("resources")) { unset($newtypes['PluginResourcesResource']); } $types = array_flip($newtypes); } $rand = Dropdown::showItemTypes($myname, $types, array('emptylabel' => Dropdown::EMPTY_VALUE, 'width' => 150)); $params = array('type' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'action' => $action, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id); Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params); echo "</td><td>\n"; echo "<span id='show_{$myname}{$rand}'> </span>\n"; echo "</td></tr></table>\n"; if ($value > 0) { echo "<script type='text/javascript' >\n"; echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';"; echo "</script>\n"; $params["typetable"] = $value_type; Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params); } return $rand; }
public function itemtypeDropdown() { global $CFG_GLPI; $itemtypes = self::getTypes(); echo "<select name='itemtype' id='tabsitemtype'>"; echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n"; foreach ($itemtypes as $key => $value) { if ($this->fields['id'] > 0 && $this->fields['itemtype'] == $key) { echo "<option value='{$key}' selected='selected'>{$value}</option>"; } else { echo "<option value='{$key}'>{$value}</option>"; } } echo "</select>"; $params = array('itemtype' => '__VALUE__', 'myname' => 'tabstab', 'value' => $this->fields['tab'], 'id' => $this->fields['id']); Ajax::updateItemOnSelectEvent('tabsitemtype', 'tabstab', $CFG_GLPI["root_doc"] . "/plugins/custom/ajax/dropdowntab.php", $params); }
static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1) { global $DB, $CFG_GLPI; $rand = mt_rand(); $plugin = new Plugin(); echo "<table border='0'><tr><td>\n"; echo "<select name='type' id='item_type{$rand}'>\n"; echo "<option value='0;0'>" . Dropdown::EMPTY_VALUE . "</option>\n"; if ($myname == 'type') { $newtypes = array_flip($types); unset($newtypes['Location']); unset($newtypes['Netpoint']); if ($plugin->isActivated("resources")) { unset($newtypes['PluginResourcesResource']); } $types = array_flip($newtypes); } foreach ($types as $type => $label) { $item = new $label(); if ($myname == 'type') { $table = getTableForItemType($label . "Type"); } else { $table = getTableForItemType($label); } echo "<option value='" . $label . ";" . $table . "'>" . $item->getTypeName() . "</option>\n"; } echo "</select>"; $params = array('typetable' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id); Ajax::updateItemOnSelectEvent("item_type{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params); echo "</td><td>\n"; echo "<span id='show_{$myname}{$rand}'> </span>\n"; echo "</td></tr></table>\n"; if ($value > 0) { echo "<script type='text/javascript' >\n"; echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';"; echo "</script>\n"; $params["typetable"] = $value_type; Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params); } return $rand; }
along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); // Make a select box if (isset($_POST["itemtype"]) && CommonITILObject::isPossibleToAssignType($_POST["itemtype"])) { $table = getTableForItemType($_POST["itemtype"]); $rand = mt_rand(); // Message for post-only if (!isset($_POST["admin"]) || $_POST["admin"] == 0) { echo "<br>" . __('Enter the first letters (user, item name, serial or asset number)'); } echo "<br>"; $field_id = Html::cleanId("dropdown_" . $_POST['myname'] . $rand); $p = array('itemtype' => $_POST["itemtype"], 'entity_restrict' => $_POST['entity_restrict'], 'table' => $table, 'myname' => $_POST["myname"]); if (isset($_POST["used"]) && !empty($_POST["used"])) { if (isset($_POST["used"][$_POST["itemtype"]])) { $p["used"] = $_POST["used"][$_POST["itemtype"]]; } } echo Html::jsAjaxDropdown($_POST['myname'], $field_id, $CFG_GLPI['root_doc'] . "/ajax/getDropdownFindNum.php", $p); // Auto update summary of active or just solved tickets $params = array('items_id' => '__VALUE__', 'itemtype' => $_POST['itemtype']); Ajax::updateItemOnSelectEvent($field_id, "item_ticket_selection_information", $CFG_GLPI["root_doc"] . "/ajax/ticketiteminformation.php", $params); }
/** * @see CommonDBTM::showSpecificMassiveActionsParameters() **/ function showSpecificMassiveActionsParameters($input = array()) { global $CFG_GLPI; switch ($input['action']) { case "change_authtype": $rand = Auth::dropdown(array('name' => 'authtype')); $paramsmassaction = array('authtype' => '__VALUE__'); Ajax::updateItemOnSelectEvent("dropdown_authtype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAuthMethods.php", $paramsmassaction); echo "<span id='show_massiveaction_field'><br><br>"; echo "<input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>"; echo "</span>\n"; return true; case "add_user_group": $gu = new Group_User(); return $gu->showSpecificMassiveActionsParameters($input); case "add_userprofile": Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities'])); echo ". " . _n('Profile', 'Profiles', 1) . " "; Profile::dropdownUnder(); echo ". " . __('Recursive') . " "; Dropdown::showYesNo("is_recursive", 0); echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Add') . "'>"; return true; default: return parent::showSpecificMassiveActionsParameters($input); } return false; }
exit; } if (!isset($_POST[$item->getRuleIdField()])) { exit; } // Existing action if ($_POST['ruleactions_id'] > 0) { $already_used = false; } else { // New action $ra = getItemForItemtype($item->getRuleActionClass()); $used = $ra->getAlreadyUsedForRuleID($_POST[$item->getRuleIdField()], $item->getType()); $already_used = in_array($_POST["field"], $used); } echo "<table width='100%'><tr><td width='30%'>"; $action_type = ''; if (isset($_POST["action_type"])) { $action_type = $_POST["action_type"]; } $randaction = RuleAction::dropdownActions(array('subtype' => $_POST["sub_type"], 'name' => "action_type", 'field' => $_POST["field"], 'value' => $action_type, 'alreadyused' => $already_used)); echo "</td><td>"; echo "<span id='action_type_span{$randaction}'>\n"; echo "</span>\n"; $paramsaction = array('action_type' => '__VALUE__', 'field' => $_POST["field"], 'sub_type' => $_POST["sub_type"], $item->getForeignKeyField() => $_POST[$item->getForeignKeyField()]); Ajax::updateItemOnSelectEvent("dropdown_action_type{$randaction}", "action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction); if (isset($_POST['value'])) { $paramsaction['value'] = stripslashes($_POST['value']); } Ajax::updateItem("action_type_span{$randaction}", $CFG_GLPI["root_doc"] . "/ajax/ruleactionvalue.php", $paramsaction, "dropdown_action_type{$randaction}"); echo "</td></tr></table>"; }
Session::checkLoginUser(); if (isset($_POST["sub_type"]) && ($rule = getItemForItemtype($_POST["sub_type"]))) { $criterias = $rule->getAllCriteria(); if (count($criterias)) { // First include -> first of the predefined array if (!isset($_POST["criteria"])) { $_POST["criteria"] = key($criterias); } if (isset($criterias[$_POST["criteria"]]['allow_condition'])) { $allow_condition = $criterias[$_POST["criteria"]]['allow_condition']; } else { $allow_condition = array(); } $condparam = array('criterion' => $_POST["criteria"], 'allow_conditions' => $allow_condition); if (isset($_POST['condition'])) { $condparam['value'] = $_POST['condition']; } echo "<table width='100%'><tr><td width='30%'>"; $randcrit = RuleCriteria::dropdownConditions($_POST["sub_type"], $condparam); echo "</td><td>"; echo "<span id='condition_span{$randcrit}'>\n"; echo "</span>\n"; $paramscriteria = array('condition' => '__VALUE__', 'criteria' => $_POST["criteria"], 'sub_type' => $_POST["sub_type"]); Ajax::updateItemOnSelectEvent("dropdown_condition{$randcrit}", "condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria); if (isset($_POST['pattern'])) { $paramscriteria['value'] = stripslashes($_POST['pattern']); } Ajax::updateItem("condition_span{$randcrit}", $CFG_GLPI["root_doc"] . "/ajax/rulecriteriavalue.php", $paramscriteria, "dropdown_condition{$randcrit}"); echo "</td></tr></table>"; } }
/** * show actor add div * * @param $type string actor type * @param $rand_type integer rand value of div to use * @param $entities_id integer entity ID * @param $is_hidden array of hidden fields (if empty consider as not hidden) * @param $withgroup boolean allow adding a group (true by default) * @param $withsupplier boolean allow adding a supplier (only one possible in ASSIGN case) * (false by default) * @param $inobject boolean display in ITIL object ? (true by default) * * @return nothing display **/ function showActorAddForm($type, $rand_type, $entities_id, $is_hidden = array(), $withgroup = true, $withsupplier = false, $inobject = true) { global $CFG_GLPI; $types = array('' => Dropdown::EMPTY_VALUE, 'user' => __('User')); if ($withgroup) { $types['group'] = __('Group'); } if ($withsupplier && $type == CommonITILActor::ASSIGN) { $types['supplier'] = __('Supplier'); } $typename = self::getActorFieldNameType($type); switch ($type) { case CommonITILActor::REQUESTER: if (isset($is_hidden['_users_id_requester']) && $is_hidden['_users_id_requester']) { unset($types['user']); } if (isset($is_hidden['_groups_id_requester']) && $is_hidden['_groups_id_requester']) { unset($types['group']); } break; case CommonITILActor::OBSERVER: if (isset($is_hidden['_users_id_observer']) && $is_hidden['_users_id_observer']) { unset($types['user']); } if (isset($is_hidden['_groups_id_observer']) && $is_hidden['_groups_id_observer']) { unset($types['group']); } break; case CommonITILActor::ASSIGN: if (isset($is_hidden['_users_id_assign']) && $is_hidden['_users_id_assign']) { unset($types['user']); } if (isset($is_hidden['_groups_id_assign']) && $is_hidden['_groups_id_assign']) { unset($types['group']); } if (isset($types['supplier']) && isset($is_hidden['_suppliers_id_assign']) && $is_hidden['_suppliers_id_assign']) { unset($types['supplier']); } break; default: return false; } echo "<div " . ($inobject ? "style='display:none'" : '') . " id='itilactor{$rand_type}'>"; $rand = Dropdown::showFromArray("_itil_" . $typename . "[_type]", $types); $params = array('type' => '__VALUE__', 'actortype' => $typename, 'itemtype' => $this->getType(), 'allow_email' => $type == CommonITILActor::OBSERVER || $type == CommonITILActor::REQUESTER, 'entity_restrict' => $entities_id, 'use_notif' => Entity::getUsedConfig('is_notif_enable_default', $entities_id, '', 1)); Ajax::updateItemOnSelectEvent("dropdown__itil_" . $typename . "[_type]{$rand}", "showitilactor" . $typename . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownItilActors.php", $params); echo "<span id='showitilactor" . $typename . "_{$rand}'> </span>"; if ($inobject) { echo "<hr>"; } echo "</div>"; }
} else { $end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP); } echo "<table class='tab_cadre'>"; echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>"; $rand_begin = Html::showDateTimeField("plan[begin]", array('value' => $begin, 'timestep' => -1, 'maybeempty' => false, 'canedit' => true, 'mindate' => '', 'maxdate' => '', 'mintime' => $CFG_GLPI["planning_begin"], 'maxtime' => $CFG_GLPI["planning_end"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_2'><td>" . __('Period') . " "; if (isset($_POST["rand_user"])) { echo "<span id='user_available" . $_POST["rand_user"] . "'>"; include_once GLPI_ROOT . '/ajax/planningcheck.php'; echo "</span>"; } echo "</td><td>"; $default_delay = floor((strtotime($end) - strtotime($begin)) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP; $rand = Dropdown::showTimeStamp("plan[_duration]", array('min' => 0, 'max' => 50 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date'))); echo "<br><div id='date_end{$rand}'></div>"; $params = array('duration' => '__VALUE__', 'end' => $end, 'name' => "plan[end]", 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]); Ajax::updateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params); if ($default_delay == 0) { $params['duration'] = 0; Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params); } echo "</td></tr>\n"; if ((!isset($_POST["id"]) || $_POST["id"] == 0) && isset($_POST['itemtype']) && PlanningRecall::isAvailable()) { echo "<tr class='tab_bg_2'><td>" . _x('Planning', 'Reminder') . "</td><td>"; PlanningRecall::dropdown(array('itemtype' => $_POST['itemtype'], 'items_id' => $_POST['items_id'])); echo "</td></tr>"; } echo "</table>\n"; Html::ajaxFooter();
/** * @since version 0.84 (before in entitydata.class) * * @param $entity Entity object **/ static function showHelpdeskOptions(Entity $entity) { global $CFG_GLPI; $ID = $entity->getField('id'); if (!$entity->can($ID, READ) || !Session::haveRightsOr(self::$rightname, array(self::READHELPDESK, self::UPDATEHELPDESK))) { return false; } $canedit = Session::haveRight(self::$rightname, self::UPDATEHELPDESK) && Session::haveAccessToEntity($ID); echo "<div class='spaced'>"; if ($canedit) { echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td colspan='2'>" . _n('Ticket template', 'Ticket templates', 1) . "</td>"; echo "<td colspan='2'>"; $toadd = array(); if ($ID != 0) { $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity')); } $options = array('value' => $entity->fields["tickettemplates_id"], 'entity' => $ID, 'toadd' => $toadd); TicketTemplate::dropdown($options); if ($entity->fields["tickettemplates_id"] == self::CONFIG_PARENT && $ID != 0) { echo "<font class='green'> "; $tt = new TicketTemplate(); $tid = self::getUsedConfig('tickettemplates_id', $ID, '', 0); if (!$tid) { echo Dropdown::EMPTY_VALUE; } else { if ($tt->getFromDB($tid)) { echo $tt->getLink(); } } echo "</font>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Calendar') . "</td>"; echo "<td colspan='2'>"; $options = array('value' => $entity->fields["calendars_id"], 'emptylabel' => __('24/7')); if ($ID != 0) { $options['toadd'] = array(self::CONFIG_PARENT => __('Inheritance of the parent entity')); } Calendar::dropdown($options); if ($entity->fields["calendars_id"] == self::CONFIG_PARENT && $ID != 0) { echo "<font class='green'> "; $calendar = new Calendar(); $cid = self::getUsedConfig('calendars_id', $ID, '', 0); if (!$cid) { _e('24/7'); } else { if ($calendar->getFromDB($cid)) { echo $calendar->getLink(); } } echo "</font>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Tickets default type') . "</td>"; echo "<td colspan='2'>"; $toadd = array(); if ($ID != 0) { $toadd = array(self::CONFIG_PARENT => __('Inheritance of the parent entity')); } Ticket::dropdownType('tickettype', array('value' => $entity->fields["tickettype"], 'toadd' => $toadd)); if ($entity->fields['tickettype'] == self::CONFIG_PARENT && $ID != 0) { echo "<font class='green'> "; echo Ticket::getTicketTypeName(self::getUsedConfig('tickettype', $ID, '', Ticket::INCIDENT_TYPE)); echo "</font>"; } echo "</td></tr>"; echo "<tr class='tab_bg_1'><td colspan='2'>" . __('Automatic assignment of tickets') . "</td>"; echo "<td colspan='2'>"; $autoassign = self::getAutoAssignMode(); if ($ID == 0) { unset($autoassign[self::CONFIG_PARENT]); } Dropdown::showFromArray('auto_assign_mode', $autoassign, array('value' => $entity->fields["auto_assign_mode"])); if ($entity->fields['auto_assign_mode'] == self::CONFIG_PARENT && $ID != 0) { $auto_assign_mode = self::getUsedConfig('auto_assign_mode', $entity->fields['entities_id']); echo "<font class='green'> "; echo $autoassign[$auto_assign_mode]; echo "</font>"; } echo "</td></tr>"; echo "<tr><th colspan='4'>" . __('Automatic closing configuration') . "</th></tr>"; echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Automatic closing of solved tickets after') . "</td>"; echo "<td colspan='2'>"; $autoclose = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), self::CONFIG_NEVER => __('Never'), 0 => __('Immediatly')); if ($ID == 0) { unset($autoclose[self::CONFIG_PARENT]); } Dropdown::showNumber('autoclose_delay', array('value' => $entity->fields['autoclose_delay'], 'min' => 1, 'max' => 99, 'step' => 1, 'toadd' => $autoclose, 'unit' => 'day')); if ($entity->fields['autoclose_delay'] == self::CONFIG_PARENT && $ID != 0) { $autoclose_mode = self::getUsedConfig('autoclose_delay', $entity->fields['entities_id'], '', self::CONFIG_NEVER); echo "<br><font class='green'> "; if ($autoclose_mode >= 0) { printf(_n('%d day', '%d days', $autoclose_mode), $autoclose_mode); } else { echo $autoclose[$autoclose_mode]; } echo "</font>"; } echo "</td></tr>"; echo "<tr><th colspan='4'>" . __('Configuring the satisfaction survey') . "</th></tr>"; echo "<tr class='tab_bg_1'>" . "<td colspan='2'>" . __('Configuring the satisfaction survey') . "</td>"; echo "<td colspan='2'>"; /// no inquest case = rate 0 $typeinquest = array(self::CONFIG_PARENT => __('Inheritance of the parent entity'), 1 => __('Internal survey'), 2 => __('External survey')); // No inherit from parent for root entity if ($ID == 0) { unset($typeinquest[self::CONFIG_PARENT]); if ($entity->fields['inquest_config'] == self::CONFIG_PARENT) { $entity->fields['inquest_config'] = 1; } } $rand = Dropdown::showFromArray('inquest_config', $typeinquest, $options = array('value' => $entity->fields['inquest_config'])); echo "</td></tr>\n"; // Do not display for root entity in inherit case if ($entity->fields['inquest_config'] == self::CONFIG_PARENT && $ID != 0) { $inquestconfig = self::getUsedConfig('inquest_config', $entity->fields['entities_id']); $inquestrate = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_rate'); echo "<tr class='tab_bg_1'><td colspan='4' class='green center'>"; if ($inquestrate == 0) { _e('Disabled'); } else { echo $typeinquest[$inquestconfig] . '<br>'; $inqconf = self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_delay'); printf(_n('%d day', '%d days', $inqconf), $inqconf); echo "<br>"; //TRANS: %d is the percentage. %% to display % printf(__('%d%%'), $inquestrate); if ($inquestconfig == 2) { echo "<br>"; echo self::getUsedConfig('inquest_config', $entity->fields['entities_id'], 'inquest_URL'); } } echo "</td></tr>\n"; } echo "<tr class='tab_bg_1'><td colspan='4'>"; $_POST = array('inquest_config' => $entity->fields['inquest_config'], 'entities_id' => $ID); $params = array('inquest_config' => '__VALUE__', 'entities_id' => $ID); echo "<div id='inquestconfig'>"; include GLPI_ROOT . '/ajax/ticketsatisfaction.php'; echo "</div>\n"; echo "</td></tr>"; if ($canedit) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='4'>"; echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>"; echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); } else { echo "</table>"; } echo "</div>"; Ajax::updateItemOnSelectEvent("dropdown_inquest_config{$rand}", "inquestconfig", $CFG_GLPI["root_doc"] . "/ajax/ticketsatisfaction.php", $params); }
/** * Print out an HTML "<select>" for a dropdown with preselected value * * @param $myname the name of the HTML select * @param $value the preselected value we want (default 0) * @param $locations_id default location ID for search (default -1) * @param $display_comment display the comment near the dropdown (default 1) * @param $entity_restrict Restrict to a defined entity(default -1) * @param $devtype (default '') * * @return nothing (display the select box) **/ static function dropdownNetpoint($myname, $value = 0, $locations_id = -1, $display_comment = 1, $entity_restrict = -1, $devtype = '') { global $CFG_GLPI; $rand = mt_rand(); $name = Dropdown::EMPTY_VALUE; $comment = ""; if (empty($value)) { $value = 0; } if ($value > 0) { $tmpname = Dropdown::getDropdownName("glpi_netpoints", $value, 1); if ($tmpname["name"] != " ") { $name = $tmpname["name"]; $comment = $tmpname["comment"]; } } $field_id = Html::cleanId("dropdown_" . $myname . $rand); $param = array('value' => $value, 'valuename' => $name, 'entity_restrict' => $entity_restrict, 'devtype' => $devtype, 'locations_id' => $locations_id); echo Html::jsAjaxDropdown($myname, $field_id, $CFG_GLPI['root_doc'] . "/ajax/getDropdownNetpoint.php", $param); // Display comment if ($display_comment) { $comment_id = Html::cleanId("comment_" . $myname . $rand); Html::showToolTip($comment, array('contentid' => $comment_id)); $item = new self(); if ($item->canCreate()) { echo "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;' " . "onClick=\"" . Html::jsGetElementbyID('netpoint' . $rand) . ".dialog('open');\">"; Ajax::createIframeModalWindow('netpoint' . $rand, $item->getFormURL()); } $paramscomment = array('value' => '__VALUE__', 'table' => "glpi_netpoints"); echo Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false); } return $rand; }
* @brief */ if (strpos($_SERVER['PHP_SELF'], "dropdownSelectSoftware.php")) { $AJAX_INCLUDE = 1; include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } Session::checkRight("software", "w"); // Make a select box $rand = mt_rand(); $where = ""; if (strlen($_POST['searchText']) > 0 && $_POST['searchText'] != $CFG_GLPI["ajax_wildcard"]) { $where .= " AND `name` " . Search::makeTextSearch($_POST['searchText']) . " "; } $where .= getEntitiesRestrictRequest(' AND', 'glpi_softwares', 'entities_id', $_POST["entity_restrict"], true); $query = "SELECT DISTINCT `glpi_softwares`.`id`,\n `glpi_softwares`.`name`\n FROM `glpi_softwares`\n WHERE `glpi_softwares`.`is_deleted` = '0'\n AND `glpi_softwares`.`is_template` = '0'\n {$where}\n ORDER BY `glpi_softwares`.`name`"; $result = $DB->query($query); echo "<select name='softwares_id' id='item_type{$rand}'>\n"; echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n"; if ($DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $softwares_id = $data["id"]; $output = $data["name"]; echo "<option value='{$softwares_id}' title=\"" . Html::cleanInputText($output) . "\">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>"; } } echo "</select>\n"; $paramsselsoft = array('softwares_id' => '__VALUE__', 'myname' => $_POST["myname"]); Ajax::updateItemOnSelectEvent("item_type{$rand}", "show_" . $_POST["myname"] . $rand, $CFG_GLPI["root_doc"] . "/ajax/dropdownInstallVersion.php", $paramsselsoft); echo "<span id='show_" . $_POST["myname"] . "{$rand}'> </span>\n";
/** * Diplay a dropdown to select an Appliance * * Parameters which could be used in options array : * - name : string / name of the select (default is plugin_appliances_appliances_id) * - entity : integer or array / restrict to a defined entity or array of entities * (default '' : current entity) * - used : array / Already used items ID: not to display in dropdown (default empty) * * @param $options possible options * * @return nothing (HTML display) **/ static function dropdown($options = array()) { global $DB, $CFG_GLPI; // Defautl values $p['name'] = 'plugin_appliances_appliances_id'; $p['entity'] = ''; $p['used'] = array(); if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } $rand = mt_rand(); $where = " WHERE `glpi_plugin_appliances_appliances`.`is_deleted` = '0' " . getEntitiesRestrictRequest("AND", "glpi_plugin_appliances_appliances", '', $p['entity'], true); if (count($p['used'])) { $where .= " AND `id` NOT IN ('" . implode("','", $p['used']) . "')"; } $query = "SELECT *\n FROM `glpi_plugin_appliances_appliancetypes`\n WHERE `id` IN (SELECT DISTINCT `plugin_appliances_appliancetypes_id`\n FROM `glpi_plugin_appliances_appliances` " . $where . ")\n GROUP BY `name`"; $result = $DB->query($query); echo "<select name='_type' id='type_appliances'>\n"; echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n"; while ($data = $DB->fetch_assoc($result)) { echo "<option value='" . $data['id'] . "'>" . $data['name'] . "</option>\n"; } echo "</select>\n"; $params = array('type_appliances' => '__VALUE__', 'entity_restrict' => $p['entity'], 'rand' => $rand, 'myname' => $p['name'], 'used' => $p['used']); Ajax::updateItemOnSelectEvent("type_appliances", "show_" . $p['name'] . $rand, $CFG_GLPI["root_doc"] . "/plugins/appliances/ajax/dropdownTypeAppliances.php", $params); echo "<span id='show_" . $p['name'] . "{$rand}'>"; $_POST["entity_restrict"] = $p['entity']; $_POST["type_appliances"] = 0; $_POST["myname"] = $p['name']; $_POST["rand"] = $rand; $_POST["used"] = $p['used']; include GLPI_ROOT . "/plugins/appliances/ajax/dropdownTypeAppliances.php"; echo "</span>\n"; 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) * **/ function showGenericSearch($params) { global $CFG_GLPI; $itemtype = "PluginResourcesDirectory"; $itemtable = $this->table; // 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 = Search::getCleanedOptions("PluginResourcesDirectory"); $target = $CFG_GLPI["root_doc"] . "/plugins/resources/front/directory.php"; // Instanciate an object to access method $item = NULL; if (class_exists($itemtype)) { $item = new $itemtype(); } $linked = Search::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' value='1'>"; echo "<a href='#' onClick = \"document.getElementById('add_search_count').disabled=false;document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/plus.png\" alt='+' title='" . __s('Add a search criterion') . "'></a> "; if ($_SESSION["glpisearchcount"][$itemtype] > 1) { echo "<input type='hidden' disabled id='delete_search_count' name='delete_search_count' value='1'>"; echo "<a href='#' onClick = \"document.getElementById('delete_search_count').disabled=false;document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/moins.png\" alt='-' title='" . __s('Delete a search criterion') . "'></a> "; } if (is_array($linked) && count($linked) > 0) { echo "<input type='hidden' disabled id='add_search_count2' name='add_search_count2' value='1'>"; echo "<a href='#' onClick = \"document.getElementById('add_search_count2').disabled=false;document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_plus.png\" alt='+' title='" . __s('Add a global search criterion') . "'></a> "; if ($_SESSION["glpisearchcount2"][$itemtype] > 0) { echo "<input type='hidden' disabled id='delete_search_count2' name='delete_search_count2' value='1'>"; echo "<a href='#' onClick = \"document.getElementById('delete_search_count2').disabled=false;document.forms['searchform{$itemtype}'].submit();\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/meta_moins.png\" alt='-' title='" . __s('Delete a global search criterion') . "'></a> "; } } $itemtable = getTableForItemType($itemtype); } // 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 serach 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 ">" . __('Items seen') . "</option>\n"; reset($options); $first_group = true; $selected = 'view'; foreach ($options as $key => $val) { // print groups if (!is_array($val)) { if (!$first_group) { echo "</optgroup>\n"; } else { $first_group = false; } echo "<optgroup label='{$val}'>"; } else { if (!isset($val['nosearch']) || $val['nosearch'] == false) { echo "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'"; if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) { echo "selected"; $selected = $key; } echo ">" . Toolbox::substr($val["name"], 0, 28) . "</option>\n"; } } } if (!$first_group) { echo "</optgroup>\n"; } echo "<option value='all' "; if (is_array($p['field']) && isset($p['field'][$i]) && $p['field'][$i] == "all") { echo "selected"; } echo ">" . __('All') . "</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"]); Ajax::updateItemOnSelectEvent("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'>"; $rand = mt_rand(); // 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}'>" . Toolbox::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] : ""); Ajax::updateItemOnSelectEvent("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]; Ajax::updateItem("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 deleted selection echo "<tr>"; // Display submit button echo "<td width='80' class='center'>"; echo "<input type='submit' value=\"" . _sx('button', 'Search') . "\" class='submit' >"; echo "</td><td>"; Bookmark::showSaveButton(Bookmark::SEARCH, $itemtype); echo "<a href='{$target}?reset=reset' >"; echo " <img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/templates/infotel/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'>"; Html::closeForm(); }
Html::header_nocache(); if (!($item = getItemForItemtype($_POST['itemtype']))) { exit; } $item->checkGlobal(READ); $group = ""; $values = array(); $searchopt = Search::getCleanedOptions($_POST["itemtype"], READ, false); echo "<table width='100%'><tr><td width='40%'>"; foreach ($searchopt as $key => $val) { // print groups $str_limit = 28; if (!is_array($val)) { $group = $val; } else { // No search on plugins if (!isPluginItemType($key) && !isset($val["nometa"])) { $values[$group][$key] = $val["name"]; } } } $rand = Dropdown::showFromArray("metacriteria[" . $_POST["num"] . "][field]", $values, array('value' => $_POST["field"])); $field_id = Html::cleanId("dropdown_metacriteria[" . $_POST["num"] . "][field]" . $rand); echo "</td><td class='left'>"; echo "<span id='Search2Span" . $_POST["itemtype"] . $_POST["num"] . "'>\n"; $_POST['meta'] = 1; include GLPI_ROOT . "/ajax/searchoption.php"; echo "</span>\n"; $params = array('field' => '__VALUE__', 'itemtype' => $_POST["itemtype"], 'num' => $_POST["num"], 'value' => $_POST["value"], 'searchtype' => $_POST["searchtype"], 'meta' => 1); Ajax::updateItemOnSelectEvent($field_id, "Search2Span" . $_POST["itemtype"] . $_POST["num"], $CFG_GLPI["root_doc"] . "/ajax/searchoption.php", $params); echo '</td></tr></table>';
function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; $default_values = self::getDefaultValues(); // Get default values from posted values on reload form // On get because of tabs // we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST) if (!isset($options['template_preview'])) { if (isset($_REQUEST)) { $values = Html::cleanPostForTextArea($_REQUEST); } } // Restore saved value or override with page parameter $saved = $this->restoreInput(); foreach ($default_values as $name => $value) { if (!isset($values[$name])) { if (isset($saved[$name])) { $values[$name] = $saved[$name]; } else { $values[$name] = $value; } } } if (isset($values['content'])) { // Clean new lines to be fix encoding $order = array('\\r', '\\n', "\\"); $replace = array("", "", ""); $values['content'] = str_replace($order, $replace, $values['content']); } if (isset($values['name'])) { $values['name'] = str_replace("\\", "", $values['name']); } if (!$ID) { // Override defaut values from projecttask if needed if (isset($options['_projecttasks_id'])) { $pt = new ProjectTask(); if ($pt->getFromDB($options['_projecttasks_id'])) { $values['name'] = $pt->getField('name'); $values['content'] = $pt->getField('name'); } } } // Check category / type validity if ($values['itilcategories_id']) { $cat = new ITILCategory(); if ($cat->getFromDB($values['itilcategories_id'])) { switch ($values['type']) { case self::INCIDENT_TYPE: if (!$cat->getField('is_incident')) { $values['itilcategories_id'] = 0; } break; case self::DEMAND_TYPE: if (!$cat->getField('is_request')) { $values['itilcategories_id'] = 0; } break; default: break; } } } // Default check if ($ID > 0) { $this->check($ID, READ); } else { // Create item $this->check(-1, CREATE, $values); } if (!$ID) { $this->userentities = array(); if ($values["_users_id_requester"]) { //Get all the user's entities $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true); //For each user's entity, check if the technician which creates the ticket have access to it foreach ($all_entities as $tmp => $ID_entity) { if (Session::haveAccessToEntity($ID_entity)) { $this->userentities[] = $ID_entity; } } } $this->countentitiesforuser = count($this->userentities); if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) { // If entity is not in the list of user's entities, // then use as default value the first value of the user's entites list $this->fields["entities_id"] = $this->userentities[0]; // Pass to values $values['entities_id'] = $this->userentities[0]; } } if ($values['type'] <= 0) { $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE); } if (!isset($options['template_preview'])) { $options['template_preview'] = 0; } // Load ticket template if available : if ($ID) { $tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']); } else { $tt = $this->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']); } // Predefined fields from template : reset them if (isset($values['_predefined_fields'])) { $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']); } else { $values['_predefined_fields'] = array(); } // Store predefined fields to be able not to take into account on change template // Only manage predefined values on ticket creation $predefined_fields = array(); if (!$ID) { if (isset($tt->predefined) && count($tt->predefined)) { foreach ($tt->predefined as $predeffield => $predefvalue) { if (isset($default_values[$predeffield])) { // Is always default value : not set // Set if already predefined field // Set if ticket template change if (count($values['_predefined_fields']) == 0 && $values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID() || $predeffield == 'requesttypes_id' && empty($saved)) { // Load template data $values[$predeffield] = $predefvalue; $this->fields[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } } // All predefined override : add option to say predifined exists if (count($predefined_fields) == 0) { $predefined_fields['_all_predefined_override'] = 1; } } else { // No template load : reset predefined values if (count($values['_predefined_fields'])) { foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) { if ($values[$predeffield] == $predefvalue) { $values[$predeffield] = $default_values[$predeffield]; } } } } } // Put ticket template on $values for actors $values['_tickettemplate'] = $tt; $canupdate = Session::haveRight(self::$rightname, UPDATE); $canpriority = Session::haveRight(self::$rightname, self::CHANGEPRIORITY); $canstatus = $canupdate; if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) { $canupdate = false; // No update for actors $values['_noupdate'] = true; } $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } if ($options['template_preview']) { // Add all values to fields of tickets for template preview foreach ($values as $key => $val) { if (!isset($this->fields[$key])) { $this->fields[$key] = $val; } } } // In percent $colsize1 = '13'; $colsize2 = '29'; $colsize3 = '13'; $colsize4 = '45'; $canupdate_descr = $canupdate || $this->fields['status'] == self::INCOMING && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0; if (!$options['template_preview']) { echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>"; if (isset($options['_projecttasks_id'])) { echo "<input type='hidden' name='_projecttasks_id' value='" . $options['_projecttasks_id'] . "'>"; } } echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe' id='mainformtable'>"; // Optional line $ismultientities = Session::isMultiEntitiesMode(); echo "<tr class='headerRow responsive_hidden'>"; echo "<th colspan='4'>"; if ($ID) { $text = sprintf(__('%1$s - %2$s'), $this->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID)); if ($ismultientities) { $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id'])); } echo $text; } else { if ($ismultientities) { printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id'])); } else { _e('New ticket'); } } echo "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('date'); if (!$ID) { printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date')); } else { _e('Opening date'); } echo $tt->getEndHiddenFieldText('date'); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('date'); $date = $this->fields["date"]; if ($canupdate) { Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false)); } else { echo Html::convDateTime($date); } echo $tt->getEndHiddenFieldValue('date', $this); echo "</td><td colspan='2'></td></tr>"; // SLTs echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('time_to_own'); if (!$ID) { printf(__('%1$s%2$s'), __('Time to own'), $tt->getMandatoryMark('time_to_own')); } else { _e('Time to own'); } echo $tt->getEndHiddenFieldText('time_to_own'); echo "</th>"; echo "<td width='{$colsize2}%' class='nopadding'>"; $slt = new SLT(); $slt->showSltForTicket($this, SLT::TTO, $tt, $canupdate); echo "</td>"; echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date'); if (!$ID) { printf(__('%1$s%2$s'), __('Time to resolve'), $tt->getMandatoryMark('due_date')); } else { _e('Time to resolve'); } echo $tt->getEndHiddenFieldText('due_date'); echo "</th>"; echo "<td width='{$colsize4}%' class='nopadding'>"; $slt->showSltForTicket($this, SLT::TTR, $tt, $canupdate); echo "</td>"; echo "</tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('By') . "</th>"; echo "<td width='{$colsize2}%'>"; if ($canupdate) { User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); } else { echo getUserName($this->fields["users_id_recipient"], $showuserlink); } echo "</td>"; echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>"; echo "<td width='{$colsize4}%'>"; if ($this->fields['users_id_lastupdater'] > 0) { //TRANS: %1$s is the update date, %2$s is the last updater name printf(__('%1$s by %2$s'), Html::convDateTime($this->fields["date_mod"]), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td>"; echo "</tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>"; echo "<td width='{$colsize2}%'>"; Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>"; echo "<td width='{$colsize4}%'>"; Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate)); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } if ($ID) { echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>"; echo "<td width='{$colsize2}%'>"; // Permit to set type when creating ticket without update right if ($canupdate || !$ID) { $opt = array('value' => $this->fields["type"]); /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'this.form.submit()'; } $rand = self::dropdownType('type', $opt); if ($ID) { $params = array('type' => '__VALUE__', 'entity_restrict' => $this->fields['entities_id'], 'value' => $this->fields['itilcategories_id'], 'currenttype' => $this->fields['type']); Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params); } } else { echo self::getTicketTypeName($this->fields["type"]); } echo "</td>"; echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>"; echo "<td width='{$colsize4}%'>"; // Permit to set category when creating ticket without update right if ($canupdate || !$ID || $canupdate_descr) { $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"]); if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { $opt['condition'] = "`is_helpdeskvisible`='1' AND "; } else { $opt['condition'] = ''; } /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'this.form.submit()'; } /// if category mandatory, no empty choice /// no empty choice is default value set on ticket creation, else yes if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $this->fields["itilcategories_id"] > 0) { $opt['display_emptychoice'] = false; } switch ($this->fields["type"]) { case self::INCIDENT_TYPE: $opt['condition'] .= "`is_incident`='1'"; break; case self::DEMAND_TYPE: $opt['condition'] .= "`is_request`='1'"; break; default: break; } echo "<span id='show_category_by_type'>"; ITILCategory::dropdown($opt); echo "</span>"; } else { echo Dropdown::getDropdownName("glpi_itilcategories", $this->fields["itilcategories_id"]); } echo "</td>"; echo "</tr>"; if (!$ID) { echo "</table>"; $this->showActorsPartForm($ID, $values); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status'); printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status')); echo $tt->getEndHiddenFieldText('status') . "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('status'); if ($canstatus) { self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); TicketValidation::alertValidation($this, 'status'); } else { echo self::getStatus($this->fields["status"]); if (in_array($this->fields["status"], $this->getClosedStatusArray()) && $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) { echo " <a class='vsubmit' href='" . $this->getLinkURL() . "&forcetab=TicketFollowup\$1&_openfollowup=1'>" . __('Reopen') . "</a>"; } } echo $tt->getEndHiddenFieldValue('status', $this); echo "</td>"; echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id'); printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id')); echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>"; echo "<td width='{$colsize4}%'>"; echo $tt->getBeginHiddenFieldValue('requesttypes_id'); if ($canupdate) { RequestType::dropdown(array('value' => $this->fields["requesttypes_id"], 'condition' => 'is_active = 1 AND is_ticketheader = 1')); } else { echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]); echo Html::hidden('requesttypes_id', array('value' => $this->fields["requesttypes_id"])); } echo $tt->getEndHiddenFieldValue('requesttypes_id', $this); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('urgency'); printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')); echo $tt->getEndHiddenFieldText('urgency') . "</th>"; echo "<td>"; if ($canupdate && $canpriority || !$ID || $canupdate_descr) { // Only change during creation OR when allowed to change priority OR when user is the creator echo $tt->getBeginHiddenFieldValue('urgency'); $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo $tt->getEndHiddenFieldValue('urgency', $this); } else { $idurgency = "value_urgency" . mt_rand(); echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>"; echo $tt->getBeginHiddenFieldValue('urgency'); echo parent::getUrgencyName($this->fields["urgency"]); echo $tt->getEndHiddenFieldValue('urgency', $this); } echo "</td>"; // Display validation state echo "<th>"; if (!$ID) { echo $tt->getBeginHiddenFieldText('_add_validation'); printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation')); echo $tt->getEndHiddenFieldText('_add_validation'); } else { echo $tt->getBeginHiddenFieldText('global_validation'); _e('Approval'); echo $tt->getEndHiddenFieldText('global_validation'); } echo "</th>"; echo "<td>"; if (!$ID) { echo $tt->getBeginHiddenFieldValue('_add_validation'); $validation_right = ''; if ($values['type'] == self::INCIDENT_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) { $validation_right = 'validate_incident'; } if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) { $validation_right = 'validate_request'; } if (!empty($validation_right)) { echo "<input type='hidden' name='_add_validation' value='" . $values['_add_validation'] . "'>"; $params = array('name' => "users_id_validate", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'users_id_validate' => $values['users_id_validate']); TicketValidation::dropdownValidator($params); } echo $tt->getEndHiddenFieldValue('_add_validation', $this); if ($tt->isPredefinedField('global_validation')) { echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>"; } } else { echo $tt->getBeginHiddenFieldValue('global_validation'); if (Session::haveRightsOr('ticketvalidation', TicketValidation::getCreateRights()) && $canupdate) { TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $this->fields['global_validation'])); } else { echo TicketValidation::getStatus($this->fields['global_validation']); } echo $tt->getEndHiddenFieldValue('global_validation', $this); } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('impact'); printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact')); echo $tt->getEndHiddenFieldText('impact') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('impact'); if ($canupdate) { $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); } else { $idimpact = "value_impact" . mt_rand(); echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $this->fields["impact"] . "'>"; echo parent::getImpactName($this->fields["impact"]); } echo $tt->getEndHiddenFieldValue('impact', $this); echo "</td>"; echo "<th>" . $tt->getBeginHiddenFieldText('locations_id'); printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id')); echo $tt->getEndHiddenFieldText('locations_id') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('locations_id'); if ($canupdate || !$ID) { Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $this->fields['entities_id'])); } else { echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]); } echo $tt->getEndHiddenFieldValue('locations_id', $this); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('priority'); printf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')); echo $tt->getEndHiddenFieldText('priority') . "</th>"; echo "<td>"; $idajax = 'change_priority_' . mt_rand(); if ($canpriority && !$tt->isHiddenField('priority')) { $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idpriority = 'dropdown_priority' . $idpriority; echo " <span id='{$idajax}' style='display:none'></span>"; } else { $idpriority = 0; echo $tt->getBeginHiddenFieldValue('priority'); echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>"; echo $tt->getEndHiddenFieldValue('priority', $this); } if ($canupdate || $canupdate_descr) { $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); } echo "</td>"; echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('items_id'); printf(__('%1$s%2$s'), _n('Associated element', 'Associated elements', Session::getPluralNumber()), $tt->getMandatoryMark('items_id')); if ($ID && $canupdate) { echo " <a href='" . $this->getFormURL() . "?id=" . $ID . "&forcetab=Item_Ticket\$1'><img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'></a>"; } echo $tt->getEndHiddenFieldText('items_id'); echo "</th>"; if (!$ID) { echo "<td rowspan='2'>"; echo $tt->getBeginHiddenFieldValue('items_id'); $values['_canupdate'] = Session::haveRight('ticket', CREATE); if ($values['_canupdate']) { Item_Ticket::itemAddForm($this, $values); } echo $tt->getEndHiddenFieldValue('items_id', $this); echo "</td>"; } else { echo "<td>"; echo $tt->getBeginHiddenFieldValue('items_id'); $values['_canupdate'] = $canupdate || $canupdate_descr; Item_Ticket::itemAddForm($this, $values); echo $tt->getEndHiddenFieldValue('items_id', $this); echo "</td>"; } echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Need comment right to add a followup with the actiontime if (!$ID && Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) { echo "<th>" . $tt->getBeginHiddenFieldText('actiontime'); printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime')); echo $tt->getEndHiddenFieldText('actiontime') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('actiontime'); Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true)); echo $tt->getEndHiddenFieldValue('actiontime', $this); echo "</td>"; } echo "</tr>"; echo "</table>"; if ($ID) { $this->showActorsPartForm($ID, $values); } $view_linked_tickets = $ID || $canupdate; echo "<table class='tab_cadre_fixe' id='mainformtable4'>"; echo "<tr class='tab_bg_1'>"; echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name'); printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')); echo $tt->getEndHiddenFieldText('name') . "</th>"; echo "<td colspan='3'>"; if (!$ID || $canupdate_descr) { echo $tt->getBeginHiddenFieldValue('name'); echo "<input type='text' style='width:98%' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">"; echo $tt->getEndHiddenFieldValue('name', $this); } else { if (empty($this->fields["name"])) { _e('Without title'); } else { echo $this->fields["name"]; } } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content'); printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')); if (!$ID || $canupdate_descr) { $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); Html::showTooltip(nl2br(Html::Clean($content))); } echo $tt->getEndHiddenFieldText('content') . "</th>"; echo "<td colspan='3'>"; if (!$ID || $canupdate_descr) { // Admin =oui on autorise la modification de la description echo $tt->getBeginHiddenFieldValue('content'); $rand = mt_rand(); $rand_text = mt_rand(); $rows = 6; $content_id = "content{$rand}"; if ($CFG_GLPI["use_rich_text"]) { $this->fields["content"] = $this->setRichTextContent($content_id, $this->fields["content"], $rand); $rows = 10; } else { $this->fields["content"] = $this->setSimpleTextContent($this->fields["content"]); } echo "<div id='content{$rand_text}'>"; echo "<textarea id='{$content_id}' name='content' style='width:100%' rows='{$rows}'>" . $this->fields["content"] . "</textarea></div>"; echo Html::scriptBlock("\$(document).ready(function() { \$('#{$content_id}').autogrow(); });"); echo $tt->getEndHiddenFieldValue('content', $this); } else { $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content'])); echo nl2br(Html::Clean($content)); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; if ($view_linked_tickets) { echo "<th style='width:{$colsize1}%'>" . _n('Linked ticket', 'Linked tickets', Session::getPluralNumber()); $rand_linked_ticket = mt_rand(); if ($canupdate) { echo " "; echo "<img onClick=\"" . Html::jsShow("linkedticket{$rand_linked_ticket}") . "\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } echo '</th>'; echo "<td colspan='3'>"; if ($canupdate) { echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>"; echo "<table class='tab_format' width='100%'><tr><td width='30%'>"; Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : ''); echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n"; echo "</td><td width='70%'>"; $linkparam = array('name' => '_link[tickets_id_2]', 'displaywith' => array('id')); if (isset($values["_link"])) { $linkparam['value'] = $values["_link"]['tickets_id_2']; } Ticket::dropdown($linkparam); echo "</td></tr></table>"; echo "</div>"; if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) { echo "<script language='javascript'>"; echo Html::jsShow("linkedticket{$rand_linked_ticket}"); echo "</script>"; } } Ticket_Ticket::displayLinkedTicketsTo($ID); echo "</td>"; } echo "</tr>"; // View files added echo "<tr class='tab_bg_1'>"; // Permit to add doc when creating a ticket echo "<th style='width:{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('_documents_id'); $doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize()); printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id')); // Do not show if hidden. if (!$tt->isHiddenField('_documents_id')) { DocumentType::showAvailableTypesLink(); } echo $tt->getEndHiddenFieldText('_documents_id'); echo "</th>"; echo "<td colspan='3'>"; // Do not set values echo $tt->getEndHiddenFieldValue('_documents_id'); if ($tt->isPredefinedField('_documents_id')) { if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) { echo "<span class='b'>" . __('Default documents:') . '</span>'; echo "<br>"; $doc = new Document(); foreach ($values['_documents_id'] as $key => $val) { if ($doc->getFromDB($val)) { echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>"; echo "- " . $doc->getNameID() . "<br>"; } } } } echo "<div id='fileupload_info'></div>"; echo "</td>"; echo "</tr>"; if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) { echo "<tr class='tab_bg_1'>"; if ($ID) { if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) { echo "<td class='tab_bg_2 center' colspan='4'>"; if ($this->fields["is_deleted"] == 1) { if (self::canPurge()) { echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'> "; } } else { if (self::canUpdate()) { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'> "; } } if ($this->fields["is_deleted"] == 1) { if (self::canPurge()) { echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">"; } } else { if ($this->canDeleteItem()) { echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>"; } } echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>"; echo "</td>"; } } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; if ($tt->isField('id') && $tt->fields['id'] > 0) { echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>"; echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">"; } } } // File upload system $colspan = 3; if (!$CFG_GLPI['use_rich_text']) { $colspan = 4; } echo "<tr class='tab_bg_1'>"; echo "<td colspan='{$colspan}'>"; echo $tt->getBeginHiddenFieldValue('_documents_id'); echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename']))); echo "</td>"; if ($CFG_GLPI['use_rich_text']) { echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='{$colspan}'>"; if (!isset($rand)) { $rand = mt_rand(); } if ($canupdate_descr) { echo Html::initImagePasteSystem($content_id, $rand); } echo "</td>"; } echo "</tr>"; echo "</table>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</div>"; if (!$options['template_preview']) { Html::closeForm(); } return true; }
/** * Make a select box for link tasklists * * Parameters which could be used in options array : * - name : string / name of the select (default is documents_id) * - entity : integer or array / restrict to a defined entity or array of entities * (default -1 : no restriction) * - used : array / Already used items ID: not to display in dropdown (default empty) * * @param $options array of possible options * * @return nothing (print out an HTML select box) * */ static function dropdownTasklists($options = array()) { global $DB, $CFG_GLPI; $p['name'] = 'plugin_tasklists_tasklists_id'; $p['entity'] = ''; $p['used'] = array(); $p['display'] = true; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } $rand = mt_rand(); $where = " WHERE `glpi_plugin_tasklists_tasklists`.`is_deleted` = '0' "; $where .= getEntitiesRestrictRequest("AND", 'glpi_plugin_tasklists_tasklists', '', $p['entity'], true); if (count($p['used'])) { $where .= " AND `id` NOT IN (0, " . implode(",", $p['used']) . ")"; } $query = "SELECT *\n FROM `glpi_plugin_tasklists_tasktypes`\n WHERE `id` IN (SELECT DISTINCT `plugin_tasklists_tasktypes_id`\n FROM `glpi_plugin_tasklists_tasks`\n {$where})\n ORDER BY `name`"; $result = $DB->query($query); $values = array(0 => Dropdown::EMPTY_VALUE); while ($data = $DB->fetch_assoc($result)) { $values[$data['id']] = $data['name']; } $out = Dropdown::showFromArray('_tasktype', $values, array('width' => '30%', 'rand' => $rand, 'display' => false)); $field_id = Html::cleanId("dropdown__tasktype{$rand}"); $params = array('tasktypes' => '__VALUE__', 'entity' => $p['entity'], 'rand' => $rand, 'myname' => $p['name'], 'used' => $p['used']); $out .= Ajax::updateItemOnSelectEvent($field_id, "show_" . $p['name'] . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/ajax/dropdownTypeTasks.php", $params, false); $out .= "<span id='show_" . $p['name'] . "{$rand}'>"; $out .= "</span>\n"; $params['tasktype'] = 0; $out .= Ajax::updateItem("show_" . $p['name'] . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/ajax/dropdownTypeTasks.php", $params, false); if ($p['display']) { echo $out; return $rand; } return $out; }
/** * @param $name * @param $entity (default 0) * @param $entity_sons array * @param $value (default -1) */ static function dropdownFieldAction($name, $entity = 0, $entity_sons = array(), $value = -1) { global $CFG_GLPI; if ($value == -1) { $action = 'old'; } else { $action = 'set'; } $tabactions = array('old' => __('Keep in the current group', 'uninstall'), 'set' => __('Affect to a new group', 'uninstall')); // Affect a new value preg_match('/(.*)_id/', $name, $results); $ajax_page = $results[1]; $rand = Dropdown::showFromArray("_" . $name . "_action", $tabactions, array('value' => $action)); $params = array('id' => '__VALUE__', $name => $value, 'entities_id' => $entity, 'entity_sons' => $entity_sons); Ajax::updateItemOnSelectEvent("dropdown__" . $name . "_action" . $rand, "show_" . $ajax_page, $CFG_GLPI["root_doc"] . "/plugins/uninstall/ajax/{$ajax_page}.php", $params); return $action; }
@license GPLv2+ http://www.gnu.org/licenses/gpl.txt @link https://forge.indepnet.net/projects/order @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ include_once "../../../inc/includes.php"; Session::checkCentralAccess(); // Make a select box for references if (isset($_POST["itemtype"])) { $entity_restrict = getEntitiesRestrictRequest("AND", 'r', '', $_POST['entities_id'], 1); $query = "SELECT s.`plugin_order_references_id` as id, s.`price_taxfree`, s.`reference_code`, r.`name`\n FROM `glpi_plugin_order_references_suppliers` s\n LEFT JOIN `glpi_plugin_order_references` r\n ON (s.`plugin_order_references_id` = r.`id`\n AND r.`is_active` = 1\n AND r.`is_deleted` = 0)\n WHERE s.`suppliers_id` = '{$_POST['suppliers_id']}'\n AND r.`itemtype` = '{$_POST['itemtype']}'\n {$entity_restrict}\n ORDER BY s.`reference_code`"; $result = $DB->query($query); $number = $DB->numrows($result); $values = array(0 => Dropdown::EMPTY_VALUE); if ($number) { while ($data = $DB->fetch_assoc($result)) { $values[$data['id']] = $data['name'] . " - " . $data['reference_code']; } } Dropdown::showFromArray($_POST['fieldname'], $values, array('rand' => $_POST['rand'])); $params = array('reference_id' => '__VALUE__'); Ajax::updateItemOnSelectEvent('dropdown_plugin_order_references_id' . $_POST['rand'], 'show_priceht', '../ajax/dropdownReference.php', $params); // Get price } elseif (isset($_POST['reference_id'])) { $query = "SELECT `price_taxfree`\n FROM `glpi_plugin_order_references_suppliers`\n WHERE `plugin_order_references_id` = '{$_POST['reference_id']}'"; $result = $DB->query($query); $price = $DB->result($result, 0, 'price_taxfree'); $price = Html::formatNumber($price, true); echo "<input value='{$price}' type='number' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='price' />"; }
public function dropdownSuppliers($myname, $value = 0, $entity_restrict = '') { global $DB, $CFG_GLPI; $rand = mt_rand(); $entities = getEntitiesRestrictRequest("AND", "glpi_suppliers", '', $entity_restrict, true); $query = "SELECT `glpi_suppliers`.*\n FROM `glpi_suppliers`\n LEFT JOIN `glpi_contacts_suppliers`\n ON (`glpi_contacts_suppliers`.`suppliers_id` = `glpi_suppliers`.`id`)\n WHERE `glpi_suppliers`.`is_deleted` = '0'\n {$entities}\n GROUP BY `glpi_suppliers`.`id`\n ORDER BY `entities_id`, `name`"; $result = $DB->query($query); echo "<select name='suppliers_id' id='suppliers_id'>\n"; echo "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option>\n"; $prev = -1; while ($data = $DB->fetch_array($result)) { if ($data["entities_id"] != $prev) { if ($prev >= 0) { echo "</optgroup>"; } $prev = $data["entities_id"]; echo "<optgroup label=\"" . Dropdown::getDropdownName("glpi_entities", $prev) . "\">"; } $output = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($output)) { $output .= " (" . $data["id"] . ")"; } echo "<option value='" . $data["id"] . "' " . ($value == $data["id"] ? " selected " : "") . " title=\"" . Html::cleanInputText($output) . "\">" . substr($output, 0, $CFG_GLPI["dropdown_chars_limit"]) . "</option>"; } if ($prev >= 0) { echo "</optgroup>"; } echo "</select>\n"; $params = array('suppliers_id' => '__VALUE__', 'entity_restrict' => $entity_restrict, 'rand' => $rand, 'myname' => $myname); Ajax::updateItemOnSelectEvent("suppliers_id", "show_contacts_id", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/dropdownSupplier.php", $params); return $rand; }
/** * Show generic date search * * @param $element name of the html element * @param $value default value (default '') * @param $options array of possible options: * - with_time display with time selection ? (default false) * - with_future display with future date selection ? (default false) * - with_days display specific days selection TODAY, BEGINMONTH, LASTMONDAY... ? (default true) * * @return rand value of dropdown **/ static function showGenericDateTimeSearch($element, $value = '', $options = array()) { global $CFG_GLPI; $p['with_time'] = false; $p['with_future'] = false; $p['with_days'] = true; $p['with_specific_date'] = true; $p['display'] = true; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } $rand = mt_rand(); $output = ''; // Validate value if ($value != 'NOW' && $value != 'TODAY' && !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; } $output .= "<table width='100%'><tr><td width='50%'>"; $dates = Html::getGenericDateTimeSearchItems($p); $output .= Dropdown::showFromArray("_select_{$element}", $dates, array('value' => $value, 'display' => false, 'rand' => $rand)); $field_id = Html::cleanId("dropdown__select_{$element}{$rand}"); $output .= "</td><td width='50%'>"; $contentid = Html::cleanId("displaygenericdate{$element}{$rand}"); $output .= "<span id='{$contentid}'></span>"; $params = array('value' => '__VALUE__', 'name' => $element, 'withtime' => $p['with_time'], 'specificvalue' => $specific_value); $output .= Ajax::updateItemOnSelectEvent($field_id, $contentid, $CFG_GLPI["root_doc"] . "/ajax/genericdate.php", $params, false); $params['value'] = $value; $output .= Ajax::updateItem($contentid, $CFG_GLPI["root_doc"] . "/ajax/genericdate.php", $params, '', false); $output .= "</td></tr></table>"; if ($p['display']) { echo $output; return $rand; } return $output; }
function selectCriterias() { global $CFG_GLPI; echo "<span id='span_fields' name='span_fields'>"; if (!isset($this->fields['itemtype']) || !$this->fields['itemtype']) { echo "</span>"; return; } if (!isset($this->fields['entities_id'])) { $this->fields['entities_id'] = $_SESSION['glpiactive_entity']; } if ($rand = self::dropdownField($this->fields['itemtype'], array('value' => $this->fields['field']))) { $params = array('itemtype' => $this->fields['itemtype'], 'id_field' => '__VALUE__', 'id' => $this->fields['id']); Ajax::updateItemOnSelectEvent("dropdown_field{$rand}", "span_values", $CFG_GLPI["root_doc"] . "/ajax/dropdownValuesBlacklist.php", $params); } echo "</span>"; }
function showForm($ID, $options = array()) { global $CFG_GLPI, $DB; if (!static::canView()) { return false; } // In percent $colsize1 = '13'; $colsize2 = '37'; $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1); // Set default options if (!$ID) { $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0); foreach ($values as $key => $val) { if (!isset($options[$key])) { $options[$key] = $val; } } if (isset($options['tickets_id'])) { $ticket = new Ticket(); if ($ticket->getFromDB($options['tickets_id'])) { $options['content'] = $ticket->getField('content'); $options['name'] = $ticket->getField('name'); $options['impact'] = $ticket->getField('impact'); $options['urgency'] = $ticket->getField('urgency'); $options['priority'] = $ticket->getField('priority'); $options['itilcategories_id'] = $ticket->getField('itilcategories_id'); $options['due_date'] = $ticket->getField('due_date'); } } if (isset($options['problems_id'])) { $problem = new Problem(); if ($problem->getFromDB($options['problems_id'])) { $options['content'] = $problem->getField('content'); $options['name'] = $problem->getField('name'); $options['impact'] = $problem->getField('impact'); $options['urgency'] = $problem->getField('urgency'); $options['priority'] = $problem->getField('priority'); $options['itilcategories_id'] = $problem->getField('itilcategories_id'); $options['due_date'] = $problem->getField('due_date'); } } } if ($ID > 0) { $this->check($ID, READ); } else { // Create item $this->check(-1, CREATE, $options); } $showuserlink = 0; if (User::canView()) { $showuserlink = 1; } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>"; echo "<td class='left' width='{$colsize2}%'>"; if (isset($options['tickets_id'])) { echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>"; } if (isset($options['problems_id'])) { echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>"; } $date = $this->fields["date"]; if (!$ID) { $date = date("Y-m-d H:i:s"); } Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false)); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>"; echo "<td width='{$colsize2}%' class='left'>"; if ($this->fields["due_date"] == 'NULL') { $this->fields["due_date"] = ''; } Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1)); echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>"; User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all')); echo "</td>"; echo "<th>" . __('Last update') . "</th>"; echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n"; if ($this->fields['users_id_lastupdater'] > 0) { printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink)); } echo "</td></tr>"; } if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Date of solving') . "</th>"; echo "<td>"; Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false)); echo "</td>"; if (in_array($this->fields["status"], $this->getClosedStatusArray())) { echo "<th>" . __('Closing date') . "</th>"; echo "<td>"; Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false)); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Status') . "</th>"; echo "<td width='{$colsize2}%'>"; self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed')); ChangeValidation::alertValidation($this, 'status'); echo "</td>"; echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>"; echo "<td width='{$colsize2}%'>"; // Only change during creation OR when allowed to change priority OR when user is the creator $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Category') . "</th>"; echo "<td >"; $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_change`='1'"); ITILCategory::dropdown($opt); echo "</td>"; echo "<th>" . __('Impact') . "</th>"; echo "<td>"; $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Total duration') . "</th>"; echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>"; echo "<th class='left'>" . __('Priority') . "</th>"; echo "<td>"; $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true)); $idajax = 'change_priority_' . mt_rand(); echo " <span id='{$idajax}' style='display:none'></span>"; $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => 'dropdown_priority' . $idpriority); Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); echo "</td>"; echo "</tr>"; echo "</table>"; $this->showActorsPartForm($ID, $options); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Title') . "</th>"; echo "<td colspan='3'>"; echo "<input type='text' size='90' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . __('Description') . "</th>"; echo "<td colspan='3'>"; $rand = mt_rand(); echo "<textarea id='content{$rand}' name='content' cols='90' rows='6'>" . Html::clean(Html::entity_decode_deep($this->fields["content"])) . "</textarea>"; echo "</td>"; echo "</tr>"; $options['colspan'] = 3; $this->showFormButtons($options); return true; }
/** * Make a select box with all glpi users where select key = name * * @param $options array of possible options: * - name : string / name of the select (default is users_id) * - value * - right : string / limit user who have specific right : * id -> only current user (default case); * interface -> central ; * all -> all users ; * specific right like Ticket::READALL, CREATE.... (is array passed one of all passed right is needed) * - comments : boolean / is the comments displayed near the dropdown (default true) * - entity : integer or array / restrict to a defined entity or array of entities * (default -1 : no restriction) * - entity_sons : boolean / if entity restrict specified auto select its sons * only available if entity is a single value not an array(default false) * - all : Nobody or All display for none selected * all=0 (default) -> Nobody * all=1 -> All * all=-1-> nothing * - rand : integer / already computed rand value * - toupdate : array / Update a specific item on select change on dropdown * (need value_fieldname, to_update, url * (see Ajax::updateItemOnSelectEvent for information) * and may have moreparams) * - used : array / Already used items ID: not to display in dropdown (default empty) * - ldap_import * - on_change : string / value to transmit to "onChange" * - display : boolean / display or get string (default true) * - width : specific width needed (default 80%) * - specific_tags : array of HTML5 tags to add the the field * - url : url of the ajax php code which should return the json data to show in * the dropdown (default /ajax/getDropdownUsers.php) * * @return rand value if displayed / string if not **/ static function dropdown($options = array()) { global $DB, $CFG_GLPI; // Default values $p['name'] = 'users_id'; $p['value'] = ''; $p['right'] = 'id'; $p['all'] = 0; $p['on_change'] = ''; $p['comments'] = 1; $p['width'] = '80%'; $p['entity'] = -1; $p['entity_sons'] = false; $p['used'] = array(); $p['ldap_import'] = false; $p['toupdate'] = ''; $p['rand'] = mt_rand(); $p['display'] = true; $p['_user_index'] = 0; $p['specific_tags'] = array(); $p['url'] = $CFG_GLPI['root_doc'] . "/ajax/getDropdownUsers.php"; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } // check default value (in case of multiple observers) if (is_array($p['value'])) { $p['value'] = $p['value'][$p['_user_index']]; } // Check default value for dropdown : need to be a numeric if (strlen($p['value']) == 0 || !is_numeric($p['value'])) { $p['value'] = 0; } $output = ''; if (!($p['entity'] < 0) && $p['entity_sons']) { if (is_array($p['entity'])) { $output .= "entity_sons options is not available with array of entity"; } else { $p['entity'] = getSonsOf('glpi_entities', $p['entity']); } } // Make a select box with all glpi users $user = getUserName($p['value'], 2); $view_users = self::canView(); if (!empty($p['value']) && $p['value'] > 0) { $default = $user["name"]; } else { if ($p['all']) { $default = __('All'); } else { $default = Dropdown::EMPTY_VALUE; } } $field_id = Html::cleanId("dropdown_" . $p['name'] . $p['rand']); $param = array('value' => $p['value'], 'valuename' => $default, 'width' => $p['width'], 'all' => $p['all'], 'right' => $p['right'], 'on_change' => $p['on_change'], 'used' => $p['used'], 'entity_restrict' => $p['entity'], 'specific_tags' => $p['specific_tags']); $output = Html::jsAjaxDropdown($p['name'], $field_id, $p['url'], $param); // Display comment if ($p['comments']) { $comment_id = Html::cleanId("comment_" . $p['name'] . $p['rand']); $link_id = Html::cleanId("comment_link_" . $p["name"] . $p['rand']); if (!$view_users) { $user["link"] = ''; } else { if (empty($user["link"])) { $user["link"] = $CFG_GLPI['root_doc'] . "/front/user.php"; } } $output .= " " . Html::showToolTip($user["comment"], array('contentid' => $comment_id, 'display' => false, 'link' => $user["link"], 'linkid' => $link_id)); $paramscomment = array('value' => '__VALUE__', 'table' => "glpi_users"); if ($view_users) { $paramscomment['withlink'] = $link_id; } $output .= Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false); } $output .= Ajax::commonDropdownUpdateItem($p, false); if (Session::haveRight('user', self::IMPORTEXTAUTHUSERS) && $p['ldap_import'] && Entity::isEntityDirectoryConfigured($_SESSION['glpiactive_entity'])) { $output .= "<img alt='' title=\"" . __s('Import a user') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('userimport' . $p['rand']) . ".dialog('open');\">"; $output .= Ajax::createIframeModalWindow('userimport' . $p['rand'], $CFG_GLPI["root_doc"] . "/front/ldap.import.php?entity=" . $_SESSION['glpiactive_entity'], array('title' => __('Import a user'), 'display' => false)); } if ($p['display']) { echo $output; return $p['rand']; } return $output; }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI; along with Order. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- @package order @author the order plugin team @copyright Copyright (c) 2010-2011 Order plugin team @license GPLv2+ http://www.gnu.org/licenses/gpl.txt @link https://forge.indepnet.net/projects/order @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); if (!defined('GLPI_ROOT')) { die("Can not acces directly to this file"); } Session::checkCentralAccess(); $rand = $_POST["rand"]; $paramsaction = array('plugin_order_references_id' => '__VALUE__', 'entity_restrict' => $_POST["entity_restrict"], 'suppliers_id' => $_POST["suppliers_id"], 'itemtype' => $_POST['itemtype']); $fields = array("quantity", "priceht", "pricediscounted", "taxe", "validate"); foreach ($fields as $field) { $paramsaction['update'] = $field; Ajax::updateItem("show_{$field}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/referencedetail.php", $paramsaction, "dropdown_reference{$rand}"); Ajax::updateItemOnSelectEvent("dropdown_reference{$rand}", "show_{$field}", $CFG_GLPI["root_doc"] . "/plugins/order/ajax/referencedetail.php", $paramsaction); }
/** * Clone of Ticket::showForm() * Change '$this' by '$ticket', 'self' by 'Ticket' and 'parent' by 'Ticket' */ static function getCentral($ID = 0, $options = array()) { global $CFG_GLPI; // * Added by plugin survey ticket $ticket = new Ticket(); // * End of adding $default_values = Ticket::getDefaultValues(); // Get default values from posted values on reload form if (!isset($options['template_preview'])) { if (isset($_POST)) { $values = $_POST; } } // Restore saved value or override with page parameter $saved = $ticket->restoreInput(); foreach ($default_values as $name => $value) { if (!isset($values[$name])) { if (isset($saved[$name])) { $values[$name] = $saved[$name]; } else { $values[$name] = $value; } } } // Default check if ($ID > 0) { $ticket->check($ID, 'r'); } else { // Create item $ticket->check(-1, 'w', $values); } if (!$ID) { $ticket->userentities = array(); if ($values["_users_id_requester"]) { //Get all the user's entities $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true); //For each user's entity, check if the technician which creates the ticket have access to it foreach ($all_entities as $tmp => $ID_entity) { if (Session::haveAccessToEntity($ID_entity)) { $ticket->userentities[] = $ID_entity; } } } $ticket->countentitiesforuser = count($ticket->userentities); if ($ticket->countentitiesforuser > 0 && !in_array($ticket->fields["entities_id"], $ticket->userentities)) { // If entity is not in the list of user's entities, // then use as default value the first value of the user's entites list $ticket->fields["entities_id"] = $ticket->userentities[0]; // Pass to values $values['entities_id'] = $ticket->userentities[0]; } } if ($values['type'] <= 0) { $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE); } if (!isset($options['template_preview'])) { $options['template_preview'] = 0; } // Load ticket template if available : $tt = $ticket->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']); // Predefined fields from template : reset them if (isset($values['_predefined_fields'])) { $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']); } else { $values['_predefined_fields'] = array(); } // Store predefined fields to be able not to take into account on change template // Only manage predefined values on ticket creation $predefined_fields = array(); if (!$ID) { if (isset($tt->predefined) && count($tt->predefined)) { foreach ($tt->predefined as $predeffield => $predefvalue) { if (isset($default_values[$predeffield])) { // Is always default value : not set // Set if already predefined field // Set if ticket template change if ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) { // Load template data $values[$predeffield] = $predefvalue; $ticket->fields[$predeffield] = $predefvalue; $predefined_fields[$predeffield] = $predefvalue; } } } } else { // No template load : reset predefined values if (count($values['_predefined_fields'])) { foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) { if ($values[$predeffield] == $predefvalue) { $values[$predeffield] = $default_values[$predeffield]; } } } } } // Put ticket template on $values for actors $values['_tickettemplate'] = $tt; $canupdate = Session::haveRight('update_ticket', '1'); $canpriority = Session::haveRight('update_priority', '1'); $canstatus = $canupdate; if (in_array($ticket->fields['status'], $ticket->getClosedStatusArray())) { $canupdate = false; } $showuserlink = 0; if (Session::haveRight('user', 'r')) { $showuserlink = 1; } if (!$options['template_preview']) { $ticket->showTabs($options); } else { // Add all values to fields of tickets for template preview foreach ($values as $key => $val) { if (!isset($ticket->fields[$key])) { $ticket->fields[$key] = $val; } } } // In percent $colsize1 = '13'; $colsize2 = '29'; $colsize3 = '13'; $colsize4 = '45'; $canupdate_descr = $canupdate || $ticket->fields['status'] == Ticket::INCOMING && $ticket->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $ticket->numberOfFollowups() == 0 && $ticket->numberOfTasks() == 0; if (!$options['template_preview']) { echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>"; } echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe' id='mainformtable'>"; // Optional line $ismultientities = Session::isMultiEntitiesMode(); echo "<tr class='headerRow'>"; echo "<th colspan='4'>"; if ($ID) { $text = sprintf(__('%1$s - %2$s'), $ticket->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID)); if ($ismultientities) { $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $ticket->fields['entities_id'])); } echo $text; } else { if ($ismultientities) { printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $ticket->fields['entities_id'])); } else { _e('New ticket'); } } echo "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>"; echo $tt->getBeginHiddenFieldText('date'); if (!$ID) { printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date')); } else { _e('Opening date'); } echo $tt->getEndHiddenFieldText('date'); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('date'); $date = $ticket->fields["date"]; if ($canupdate) { Html::showDateTimeFormItem("date", $date, 1, false); } else { echo Html::convDateTime($date); } echo $tt->getEndHiddenFieldValue('date', $ticket); echo "</td>"; // SLA echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date'); if (!$ID) { printf(__('%1$s%2$s'), __('Due date'), $tt->getMandatoryMark('due_date')); } else { _e('Due date'); } echo $tt->getEndHiddenFieldText('due_date'); echo "</th>"; echo "<td width='{$colsize4}%' class='nopadding'>"; if ($ID) { if ($ticket->fields["slas_id"] > 0) { echo "<table width='100%'><tr><td class='nopadding'>"; echo Html::convDateTime($ticket->fields["due_date"]); echo "</td><td class='b'>" . __('SLA') . "</td>"; echo "<td class='nopadding'>"; echo Dropdown::getDropdownName("glpi_slas", $ticket->fields["slas_id"]); $commentsla = ""; $slalevel = new SlaLevel(); if ($slalevel->getFromDB($ticket->fields['slalevels_id'])) { $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span><br>'; } $nextaction = new SlaLevel_Ticket(); if ($nextaction->getFromDBForTicket($ticket->fields["id"])) { $commentsla .= '<span class="b spaced">' . sprintf(__('Next escalation: %s'), Html::convDateTime($nextaction->fields['date'])) . '</span>'; if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) { $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span>'; } } $slaoptions = array(); if (Session::haveRight('config', 'r')) { $slaoptions['link'] = Toolbox::getItemTypeFormURL('SLA') . "?id=" . $ticket->fields["slas_id"]; } Html::showToolTip($commentsla, $slaoptions); if ($canupdate) { echo " <input type='submit' class='submit' name='sla_delete' value='" . _sx('button', 'Delete permanently') . "'>"; } echo "</td>"; echo "</tr></table>"; } else { echo "<table><tr><td class='nopadding'>"; echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeFormItem("due_date", $ticket->fields["due_date"], 1, true, $canupdate); echo $tt->getEndHiddenFieldValue('due_date', $ticket); echo "</td>"; if ($canupdate) { echo "<td>"; echo $tt->getBeginHiddenFieldText('slas_id'); echo "<span id='sla_action'>"; echo "<a class='vsubmit' " . Html::addConfirmationOnAction(array(__('The assignment of a SLA to a ticket causes the recalculation of the due date.'), __("Escalations defined in the SLA will be triggered under this new date.")), "cleanhide('sla_action');cleandisplay('sla_choice');") . ">" . __('Assign a SLA') . '</a>'; echo "</span>"; echo "<span id='sla_choice' style='display:none'>"; echo "<span class='b'>" . __('SLA') . "</span> "; Sla::dropdown(array('entity' => $ticket->fields["entities_id"], 'value' => $ticket->fields["slas_id"])); echo "</span>"; echo $tt->getEndHiddenFieldText('slas_id'); echo "</td>"; } echo "</tr></table>"; } } else { // New Ticket echo "<table><tr><td class='nopadding'>"; if ($ticket->fields["due_date"] == 'NULL') { $ticket->fields["due_date"] = ''; } echo $tt->getBeginHiddenFieldValue('due_date'); Html::showDateTimeFormItem("due_date", $ticket->fields["due_date"], 1, false, $canupdate); echo $tt->getEndHiddenFieldValue('due_date', $ticket); echo "</td>"; if ($canupdate) { echo "<td class='nopadding b'>" . $tt->getBeginHiddenFieldText('slas_id'); printf(__('%1$s%2$s'), __('SLA'), $tt->getMandatoryMark('slas_id')); echo $tt->getEndHiddenFieldText('slas_id') . "</td>"; echo "<td class='nopadding'>" . $tt->getBeginHiddenFieldValue('slas_id'); Sla::dropdown(array('entity' => $ticket->fields["entities_id"], 'value' => $ticket->fields["slas_id"])); echo $tt->getEndHiddenFieldValue('slas_id', $ticket); echo "</td>"; } echo "</tr></table>"; } echo "</td></tr>"; if ($ID) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('By') . "</th>"; echo "<td width='{$colsize2}%'>"; if ($canupdate) { User::dropdown(array('name' => 'users_id_recipient', 'value' => $ticket->fields["users_id_recipient"], 'entity' => $ticket->fields["entities_id"], 'right' => 'all')); } else { echo getUserName($ticket->fields["users_id_recipient"], $showuserlink); } echo "</td>"; echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>"; echo "<td width='{$colsize4}%'>"; if ($ticket->fields['users_id_lastupdater'] > 0) { //TRANS: %1$s is the update date, %2$s is the last updater name printf(__('%1$s by %2$s'), Html::convDateTime($ticket->fields["date_mod"]), getUserName($ticket->fields["users_id_lastupdater"], $showuserlink)); } echo "</td>"; echo "</tr>"; } if ($ID && (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) || in_array($ticket->fields["status"], $ticket->getClosedStatusArray()))) { echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>"; echo "<td width='{$colsize2}%'>"; Html::showDateTimeFormItem("solvedate", $ticket->fields["solvedate"], 1, false, $canupdate); echo "</td>"; if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) { echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>"; echo "<td width='{$colsize4}%'>"; Html::showDateTimeFormItem("closedate", $ticket->fields["closedate"], 1, false, $canupdate); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "</tr>"; } if ($ID) { echo "</table>"; echo "<table class='tab_cadre_fixe' id='mainformtable2'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>"; echo "<td width='{$colsize2}%'>"; // Permit to set type when creating ticket without update right if ($canupdate || !$ID) { $opt = array('value' => $ticket->fields["type"]); /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'submit()'; } $rand = Ticket::dropdownType('type', $opt); if ($ID) { $params = array('type' => '__VALUE__', 'entity_restrict' => $ticket->fields['entities_id'], 'value' => $ticket->fields['itilcategories_id'], 'currenttype' => $ticket->fields['type']); Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params); } } else { echo Ticket::getTicketTypeName($ticket->fields["type"]); } echo "</td>"; echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>"; echo "<td width='{$colsize4}%'>"; // Permit to set category when creating ticket without update right if ($canupdate || !$ID || $canupdate_descr) { $opt = array('value' => $ticket->fields["itilcategories_id"], 'entity' => $ticket->fields["entities_id"]); if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { $opt['condition'] = "`is_helpdeskvisible`='1' AND "; } else { $opt['condition'] = ''; } /// Auto submit to load template if (!$ID) { $opt['on_change'] = 'submit()'; } /// if category mandatory, no empty choice /// no empty choice is default value set on ticket creation, else yes if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $ticket->fields["itilcategories_id"] > 0) { $opt['display_emptychoice'] = false; } switch ($ticket->fields["type"]) { case Ticket::INCIDENT_TYPE: $opt['condition'] .= "`is_incident`='1'"; break; case Ticket::DEMAND_TYPE: $opt['condition'] .= "`is_request`='1'"; break; default: break; } echo "<span id='show_category_by_type'>"; ITILCategory::dropdown($opt); echo "</span>"; } else { echo Dropdown::getDropdownName("glpi_itilcategories", $ticket->fields["itilcategories_id"]); } echo "</td>"; echo "</tr>"; if (!$ID) { echo "</table>"; $ticket->showActorsPartForm($ID, $values); echo "<table class='tab_cadre_fixe' id='mainformtable3'>"; } echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status'); printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status')); echo $tt->getEndHiddenFieldText('status') . "</th>"; echo "<td width='{$colsize2}%'>"; echo $tt->getBeginHiddenFieldValue('status'); if ($canstatus) { Ticket::dropdownStatus(array('value' => $ticket->fields["status"], 'showtype' => 'allowed')); } else { echo Ticket::getStatus($ticket->fields["status"]); } echo $tt->getEndHiddenFieldValue('status', $ticket); echo "</td>"; echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id'); printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id')); echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>"; echo "<td width='{$colsize4}%'>"; echo $tt->getBeginHiddenFieldValue('requesttypes_id'); if ($canupdate) { RequestType::dropdown(array('value' => $ticket->fields["requesttypes_id"])); } else { echo Dropdown::getDropdownName('glpi_requesttypes', $ticket->fields["requesttypes_id"]); } echo $tt->getEndHiddenFieldValue('requesttypes_id', $ticket); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('urgency'); printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')); echo $tt->getEndHiddenFieldText('urgency') . "</th>"; echo "<td>"; if ($canupdate && $canpriority || !$ID || $canupdate_descr) { // Only change during creation OR when allowed to change priority OR when user is the creator echo $tt->getBeginHiddenFieldValue('urgency'); $idurgency = Ticket::dropdownUrgency(array('value' => $ticket->fields["urgency"])); echo $tt->getEndHiddenFieldValue('urgency', $ticket); } else { $idurgency = "value_urgency" . mt_rand(); echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $ticket->fields["urgency"] . "'>"; echo Ticket::getUrgencyName($ticket->fields["urgency"]); } echo "</td>"; // Display validation state echo "<th>"; if (!$ID) { echo $tt->getBeginHiddenFieldText('_add_validation'); printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation')); echo $tt->getEndHiddenFieldText('_add_validation'); } else { echo $tt->getBeginHiddenFieldText('global_validation'); _e('Approval'); echo $tt->getEndHiddenFieldText('global_validation'); } echo "</th>"; echo "<td>"; if (!$ID) { echo $tt->getBeginHiddenFieldValue('_add_validation'); $validation_right = ''; if ($values['type'] == Ticket::INCIDENT_TYPE && Session::haveRight('create_incident_validation', 1)) { $validation_right = 'validate_incident'; } if ($values['type'] == Ticket::DEMAND_TYPE && Session::haveRight('create_request_validation', 1)) { $validation_right = 'validate_request'; } if (!empty($validation_right)) { User::dropdown(array('name' => "_add_validation", 'entity' => $ticket->fields['entities_id'], 'right' => $validation_right, 'value' => $values['_add_validation'])); } echo $tt->getEndHiddenFieldValue('_add_validation', $ticket); if ($tt->isPredefinedField('global_validation')) { echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>"; } } else { echo $tt->getBeginHiddenFieldValue('global_validation'); if ($canupdate) { TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $ticket->fields['global_validation'])); } else { echo TicketValidation::getStatus($ticket->fields['global_validation']); } echo $tt->getEndHiddenFieldValue('global_validation', $ticket); } echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . $tt->getBeginHiddenFieldText('impact'); printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact')); echo $tt->getEndHiddenFieldText('impact') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('impact'); if ($canupdate) { $idimpact = Ticket::dropdownImpact(array('value' => $ticket->fields["impact"])); } else { $idimpact = "value_impact" . mt_rand(); echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $ticket->fields["impact"] . "'>"; echo Ticket::getImpactName($ticket->fields["impact"]); } echo $tt->getEndHiddenFieldValue('impact', $ticket); echo "</td>"; echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('itemtype'); printf(__('%1$s%2$s'), __('Associated element'), $tt->getMandatoryMark('itemtype')); if ($ID && $canupdate) { echo " <img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n onClick=\"Ext.get('tickethardwareselection{$ID}').setDisplayed('block')\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'>"; } echo $tt->getEndHiddenFieldText('itemtype'); echo "</th>"; echo "<td rowspan='2'>"; echo $tt->getBeginHiddenFieldValue('itemtype'); // Select hardware on creation or if have update right if ($canupdate || !$ID || $canupdate_descr) { if ($ID) { if ($ticket->fields['itemtype'] && ($item = getItemForItemtype($ticket->fields['itemtype'])) && $ticket->fields["items_id"]) { if ($item->can($ticket->fields["items_id"], 'r')) { printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getLink(array('comments' => true))); } else { printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID()); } } } $dev_user_id = 0; $dev_itemtype = $ticket->fields["itemtype"]; $dev_items_id = $ticket->fields["items_id"]; if (!$ID) { $dev_user_id = $values['_users_id_requester']; $dev_itemtype = $values["itemtype"]; $dev_items_id = $values["items_id"]; } else { if (isset($ticket->users[CommonITILActor::REQUESTER]) && count($ticket->users[CommonITILActor::REQUESTER]) == 1) { foreach ($ticket->users[CommonITILActor::REQUESTER] as $user_id_single) { $dev_user_id = $user_id_single['users_id']; } } } if ($ID) { echo "<div id='tickethardwareselection{$ID}' style='display:none'>"; } if ($dev_user_id > 0) { Ticket::dropdownMyDevices($dev_user_id, $ticket->fields["entities_id"], $dev_itemtype, $dev_items_id); } Ticket::dropdownAllDevices("itemtype", $dev_itemtype, $dev_items_id, 1, $dev_user_id, $ticket->fields["entities_id"]); if ($ID) { echo "</div>"; } echo "<span id='item_ticket_selection_information'></span>"; } else { if ($ID && $ticket->fields['itemtype'] && ($item = getItemForItemtype($ticket->fields['itemtype']))) { $item->getFromDB($ticket->fields['items_id']); printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID()); } else { _e('General'); } } echo $tt->getEndHiddenFieldValue('itemtype', $ticket); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . sprintf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')) . "</th>"; echo "<td>"; $idajax = 'change_priority_' . mt_rand(); if ($canupdate && $canpriority && !$tt->isHiddenField('priority')) { $idpriority = Ticket::dropdownPriority(array('value' => $ticket->fields["priority"], 'withmajor' => true)); echo " <span id='{$idajax}' style='display:none'></span>"; } else { $idpriority = 0; echo "<span id='{$idajax}'>" . Ticket::getPriorityName($ticket->fields["priority"]) . "</span>"; } if ($canupdate || $canupdate_descr) { $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority); Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params); } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Need comment right to add a followup with the actiontime if (!$ID && Session::haveRight("global_add_followups", "1")) { echo "<th>" . $tt->getBeginHiddenFieldText('actiontime'); printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime')); echo $tt->getEndHiddenFieldText('actiontime') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('actiontime'); Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true)); echo $tt->getEndHiddenFieldValue('actiontime', $ticket); echo "</td>"; } else { echo "<th></th><td></td>"; } echo "<th>" . $tt->getBeginHiddenFieldText('locations_id'); printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id')); echo $tt->getEndHiddenFieldText('locations_id') . "</th>"; echo "<td>"; echo $tt->getBeginHiddenFieldValue('locations_id'); if ($canupdate) { Location::dropdown(array('value' => $ticket->fields['locations_id'], 'entity' => $ticket->fields['entities_id'])); } else { echo Dropdown::getDropdownName('glpi_locations', $ticket->fields["locations_id"]); } echo $tt->getEndHiddenFieldValue('locations_id', $ticket); echo "</td></tr>"; echo "</table>"; if ($ID) { $values['canupdate'] = $canupdate; $ticket->showActorsPartForm($ID, $values); } $view_linked_tickets = $ID || $canupdate; echo "<table class='tab_cadre_fixe' id='mainformtable4'>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name'); printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')); echo $tt->getEndHiddenFieldText('name') . "</th>"; echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>"; if (!$ID || $canupdate_descr) { echo $tt->getBeginHiddenFieldValue('name'); $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showName{$rand}() {\n"; echo "Ext.get('name{$rand}').setDisplayed('none');"; $params = array('maxlength' => 250, 'size' => 90, 'name' => 'name', 'data' => rawurlencode($ticket->fields["name"])); Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params); echo "}"; echo "</script>\n"; echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n"; if (empty($ticket->fields["name"])) { _e('Without title'); } else { echo $ticket->fields["name"]; } echo "</div>\n"; echo "<div id='viewname{$rand}'>\n"; echo "</div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showName{$rand}();\n </script>"; } echo $tt->getEndHiddenFieldValue('name', $ticket); } else { if (empty($ticket->fields["name"])) { _e('Without title'); } else { echo $ticket->fields["name"]; } } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content'); printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')); echo $tt->getEndHiddenFieldText('content') . "</th>"; echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>"; // * Added by plugin surveyticket $psTicketTemplate = new PluginSurveyticketTicketTemplate(); $psSurvey = new PluginSurveyticketSurvey(); $plugin_surveyticket_surveys_id = 0; $a_tickettemplates = current($psTicketTemplate->find("`tickettemplates_id`='" . $tt->fields['id'] . "'\n AND `type`='" . $values['type'] . "'\n AND `is_central`='1'")); if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) { $psSurvey = new PluginSurveyticketSurvey(); $psSurvey->getFromDB($a_tickettemplates['plugin_surveyticket_surveys_id']); if ($psSurvey->fields['is_active'] == 1) { $plugin_surveyticket_surveys_id = $a_tickettemplates['plugin_surveyticket_surveys_id']; $psSurvey = new PluginSurveyticketSurvey(); $psSurvey->startSurvey($plugin_surveyticket_surveys_id); } } else { // End of adding by plugin if (!$ID || $canupdate_descr) { // Admin =oui on autorise la modification de la description echo $tt->getBeginHiddenFieldValue('content'); $rand = mt_rand(); echo "<script type='text/javascript' >\n"; echo "function showDesc{$rand}() {\n"; echo "Ext.get('desc{$rand}').setDisplayed('none');"; $params = array('rows' => 6, 'cols' => 90, 'name' => 'content', 'data' => rawurlencode($ticket->fields["content"])); Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params); echo "}"; echo "</script>\n"; echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n"; if (!empty($ticket->fields["content"])) { echo nl2br($ticket->fields["content"]); } else { _e('Empty description'); } echo "</div>\n"; echo "<div id='viewdesc{$rand}'></div>\n"; if (!$ID) { echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>"; } echo $tt->getEndHiddenFieldValue('content', $ticket); } else { echo nl2br($ticket->fields["content"]); } // * Added by plugin surveyticket } // End of adding by plugin echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; // Permit to add doc when creating a ticket if (!$ID) { echo "<th width='{$colsize1}%'>" . sprintf(__('File (%s)'), Document::getMaxUploadSize()); echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt=\"" . __s('Help') . "\" onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000," . "height=800')\">"; echo " "; Ticket::showDocumentAddButton(); echo "</th>"; echo "<td width='{$colsize2}%'>"; echo "<div id='uploadfiles'><input type='file' name='filename[]' size='20'></div></td>"; } else { echo "<th colspan='2'>"; $docnb = Document_Item::countForItem($ticket); echo "<a href=\"" . $ticket->getLinkURL() . "&forcetab=Document_Item\$1\">"; //TRANS: %d is the document number echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb); echo "</a></th>"; } if ($view_linked_tickets) { echo "<th width='{$colsize3}%'>" . _n('Linked ticket', 'Linked tickets', 2); $rand_linked_ticket = mt_rand(); if ($canupdate) { echo " "; echo "<img onClick=\"Ext.get('linkedticket{$rand_linked_ticket}').setDisplayed('block')\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>"; } echo '</th>'; echo "<td width='{$colsize4}%'>"; if ($canupdate) { echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>"; Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : ''); printf(__('%1$s: %2$s'), __('Ticket'), __('ID')); echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n"; echo "<input type='text' name='_link[tickets_id_2]'\n value='" . (isset($values["_link"]) ? $values["_link"]['tickets_id_2'] : '') . "'\n size='10'>\n"; echo " "; echo "</div>"; if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) { echo "<script language='javascript'>Ext.get('linkedticket{$rand_linked_ticket}').\n setDisplayed('block');</script>"; } } Ticket_Ticket::displayLinkedTicketsTo($ID); echo "</td>"; } else { echo "<td></td>"; } echo "</tr>"; if ((!$ID || $canupdate || $canupdate_descr || Session::haveRight("assign_ticket", "1") || Session::haveRight("steal_ticket", "1")) && !$options['template_preview']) { echo "<tr class='tab_bg_1'>"; if ($ID) { if (Session::haveRight('delete_ticket', 1)) { echo "<td class='tab_bg_2 center' colspan='2'>"; if ($ticket->fields["is_deleted"] == 1) { echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'></td>"; } else { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'></td>"; } echo "<td class='tab_bg_2 center' colspan='2'>"; if ($ticket->fields["is_deleted"] == 1) { echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">"; } else { echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'></td>"; } } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>"; } echo "<input type='hidden' name='_read_date_mod' value='" . $ticket->getField('date_mod') . "'>"; } else { echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; if ($tt->isField('id') && $tt->fields['id'] > 0) { echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>"; echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">"; } } } echo "</table>"; echo "<input type='hidden' name='id' value='{$ID}'>"; echo "</div>"; if (!$options['template_preview']) { Html::closeForm(); $ticket->addDivForTabs(); } return true; }
function showGenericSearch($itemtype, $params) { global $CFG_GLPI; // Default values of parameters $p = array(); $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 = Search::getCleanedOptions($itemtype); // $target = Toolbox::getItemTypeSearchURL($itemtype); // Instanciate an object to access method $item = NULL; if ($itemtype != 'States' && class_exists($itemtype)) { $item = new $itemtype(); } $linked = Search::getMetaItemtypeAvailable($itemtype); if (!isset($_GET['id']) || strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) { $item->getEmpty(); } else { $item->getFromDB($_GET['id']); } if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) { echo "<form name='searchform{$itemtype}' method='get' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayview_rule.form.php\">"; } else { echo "<form name='searchform{$itemtype}' method='get' action=\"" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/componentscatalog_rule.form.php\">"; } $item->showFormHeader(); // echo "<form name='searchform$itemtype' method='get' action=\"". // $CFG_GLPI['root_doc']."/plugins/monitoring/front/componentscatalog_rule.form.php\">"; // echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Name') . " :"; echo "</td>"; echo "<td>"; echo "<input type='text' name='name' value='" . $_GET['name'] . "'/>"; echo "</td>"; echo "<td>"; echo __('Status') . " :"; echo "</td>"; echo "<td>"; echo $_GET['itemtype']; echo "</td>"; echo "</tr>"; if (isset($_GET['itemtype'])) { echo "<tr class='tab_bg_1'>"; echo "<td colspan='3'>"; 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=\"" . __s('Add a search criterion') . "\"></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=\"" . __s('Delete a search criterion') . "\"></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=\"" . __s('Add a global search criterion') . "\"></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=\"" . __s('Delete a global search criterion') . "\"></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','','',''); // document.forms['searchform$itemtype'].submit();\"> // <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 ">" . __('Items seen') . "</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=\"" . Toolbox::substr($val, 0, $str_limit) . "\">"; } else { if (!isset($val['nosearch']) || $val['nosearch'] == false) { $nb_in_group++; $group .= "<option title=\"" . Html::cleanInputText($val["name"]) . "\" value='{$key}'"; if (is_array($p['field']) && isset($p['field'][$i]) && $key == $p['field'][$i]) { $group .= "selected"; $selected = $key; } $group .= ">" . Toolbox::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 ">" . __('All') . "</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"]); Ajax::updateItemOnSelectEvent("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}'>" . Toolbox::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] : ""); Ajax::updateItemOnSelectEvent("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]; Ajax::updateItem("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 ">".Toolbox::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=\"" . _sx('button', 'Search') . "\" class='submit' >"; echo "</td><td>"; // Bookmark::showSaveButton(Bookmark::SEARCH,$itemtype); if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/displayview_rule.form.php?" . "reset=reset" . "&name=" . $_GET['name'] . "&plugin_monitoring_displayviews_id=" . $_GET['plugin_monitoring_displayviews_id'] . "&itemtype=" . $_GET['itemtype'] . "' >"; } else { echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/componentscatalog_rule.form.php?" . "reset=reset" . "&name=" . $_GET['name'] . "&plugin_monitoring_componentscalalog_id=" . $_GET['plugin_monitoring_componentscalalog_id'] . "&itemtype=" . $_GET['itemtype'] . "' >"; } echo " <img title=\"" . __s('Blank') . "\" alt=\"" . __s('Blank') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>"; echo "</td></tr>"; echo "</table>\n"; echo "</td></tr>"; echo "<tr>"; } if (isset($_GET['id'])) { echo "<td colspan='2' class='center'>"; if (strstr($_SERVER['REQUEST_URI'], 'displayview_rule.form.php')) { echo "<input type='hidden' name='plugin_monitoring_displayviews_id' value='" . $_GET['plugin_monitoring_displayviews_id'] . "' >"; } else { echo "<input type='hidden' name='plugin_monitoring_componentscalalog_id' value='" . $_GET['plugin_monitoring_componentscalalog_id'] . "' >"; } echo "<input type='hidden' name='id' value='" . $_GET['id'] . "' >"; echo "<input type='submit' name='updaterule' value=\"Update this rule\" class='submit' >"; echo "</td>"; echo "<td colspan='2' class='center'>"; echo "<input type='submit' name='deleterule' value=\"Delete this rule\" class='submit' >"; } else { echo "<td colspan='4' class='center'>"; echo "<input type='hidden' name='plugin_monitoring_componentscalalog_id' value='" . $_GET['plugin_monitoring_componentscalalog_id'] . "' >"; echo "<input type='submit' name='addrule' value=\"Add this rule\" class='submit' >"; } echo "</td>"; echo "</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'>"; Html::closeForm(); }
/** Display refresh button in the user page * * @param $user User object * * @return nothing **/ static function showSynchronizationForm(User $user) { global $DB, $CFG_GLPI; if (Session::haveRight("user", User::UPDATEAUTHENT)) { echo "<form method='post' action='" . Toolbox::getItemTypeFormURL('User') . "'>"; echo "<div class='firstbloc'>"; switch ($user->getField('authtype')) { case self::CAS: case self::EXTERNAL: case self::X509: case self::LDAP: //Look it the auth server still exists ! // <- Bad idea : id not exists unable to change anything $sql = "SELECT `name`\n FROM `glpi_authldaps`\n WHERE `id` = '" . $user->getField('auths_id') . "'\n AND `is_active` = 1"; $result = $DB->query($sql); if ($DB->numrows($result) > 0) { echo "<table class='tab_cadre'><tr class='tab_bg_2'><td>"; echo "<input type='hidden' name='id' value='" . $user->getID() . "'>"; echo "<input class=submit type='submit' name='force_ldap_resynch' value='" . __s('Force synchronization') . "'>"; echo "</td></tr></table>"; } break; case self::DB_GLPI: case self::MAIL: break; } echo "</div>"; echo "<div class='spaced'>"; echo "<table class='tab_cadre'>"; echo "<tr><th>" . __('Change of the authentication method') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='center'>"; $rand = self::dropdown(array('name' => 'authtype')); $paramsmassaction = array('authtype' => '__VALUE__', 'name' => 'change_auth_method'); Ajax::updateItemOnSelectEvent("dropdown_authtype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAuthMethods.php", $paramsmassaction); echo "<input type='hidden' name='id' value='" . $user->getID() . "'>"; echo "<span id='show_massiveaction_field'></span>"; echo "</td></tr></table>"; echo "</div>"; Html::closeForm(); } }
static function showListSimple() { global $DB, $CFG_GLPI; if (!Session::haveRight(self::$rightname, self::RESERVEANITEM)) { return false; } $ri = new self(); $ok = false; $showentity = Session::isMultiEntitiesMode(); $values = array(); if (isset($_SESSION['glpi_saved']['ReservationItem'])) { $_POST = $_SESSION['glpi_saved']['ReservationItem']; } if (isset($_POST['reserve'])) { echo "<div id='viewresasearch' class='center'>"; Toolbox::manageBeginAndEndPlanDates($_POST['reserve']); echo "<div id='nosearch' class='center firstbloc'>" . "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/reservationitem.php\">"; echo __('See all reservable items') . "</a></div>\n"; } else { echo "<div id='makesearch' class='center firstbloc'>" . "<a class='pointer' onClick=\"javascript:showHideDiv('viewresasearch','','','');" . "showHideDiv('makesearch','','','')\">"; echo __('Find a free item in a specific period') . "</a></div>\n"; echo "<div id='viewresasearch' style=\"display:none;\" class='center'>"; $begin_time = time(); $begin_time -= $begin_time % HOUR_TIMESTAMP; $_POST['reserve']["begin"] = date("Y-m-d H:i:s", $begin_time); $_POST['reserve']["end"] = date("Y-m-d H:i:s", $begin_time + HOUR_TIMESTAMP); $_POST['reservation_types'] = ''; } echo "<form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>"; echo "<th colspan='3'>" . __('Find a free item in a specific period') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>"; Html::showDateTimeField("reserve[begin]", array('value' => $_POST['reserve']["begin"], 'maybeempty' => false)); echo "</td><td rowspan='3'>"; echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Search') . "\">"; echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>"; $default_delay = floor((strtotime($_POST['reserve']["end"]) - strtotime($_POST['reserve']["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP; $rand = Dropdown::showTimeStamp("reserve[_duration]", array('min' => 0, 'max' => 48 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date'))); echo "<br><div id='date_end{$rand}'></div>"; $params = array('duration' => '__VALUE__', 'end' => $_POST['reserve']["end"], 'name' => "reserve[end]"); Ajax::updateItemOnSelectEvent("dropdown_reserve[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params); echo "</td></tr>"; echo "<tr class='tab_bg_2'><td>" . __('Item type') . "</td><td>"; $sql = "SELECT DISTINCT(`itemtype`)\n FROM `glpi_reservationitems`\n WHERE `is_active` = 1" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']); $result = $DB->query($sql); while ($data = $DB->fetch_assoc($result)) { $values[$data['itemtype']] = $data['itemtype']::getTypeName(); } $query = "SELECT `glpi_peripheraltypes`.`name`, `glpi_peripheraltypes`.`id`\n FROM `glpi_peripheraltypes`\n LEFT JOIN `glpi_peripherals`\n ON `glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`\n LEFT JOIN `glpi_reservationitems`\n ON `glpi_reservationitems`.`items_id` = `glpi_peripherals`.`id`\n WHERE `itemtype` = 'Peripheral'\n AND `is_active` = 1\n AND `peripheraltypes_id`" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']) . "\n ORDER BY `glpi_peripheraltypes`.`name`"; foreach ($DB->request($query) as $ptype) { $id = $ptype['id']; $values["Peripheral#{$id}"] = $ptype['name']; } Dropdown::showFromArray("reservation_types", $values, array('value' => $_POST['reservation_types'], 'display_emptychoice' => true)); echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; // GET method passed to form creation echo "<div id='nosearch' class='center'>"; echo "<form name='form' method='GET' action='reservation.form.php'>"; echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n"; foreach ($CFG_GLPI["reservation_types"] as $itemtype) { if (!($item = getItemForItemtype($itemtype))) { continue; } $itemtable = getTableForItemType($itemtype); $otherserial = "'' AS otherserial"; if ($item->isField('otherserial')) { $otherserial = "`{$itemtable}`.`otherserial`"; } $begin = $_POST['reserve']["begin"]; $end = $_POST['reserve']["end"]; $left = ""; $where = ""; if (isset($_POST['submit']) && isset($begin) && isset($end)) { $left = "LEFT JOIN `glpi_reservations`\n ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n AND '" . $begin . "' < `glpi_reservations`.`end`\n AND '" . $end . "' > `glpi_reservations`.`begin`)"; $where = " AND `glpi_reservations`.`id` IS NULL "; } if (isset($_POST["reservation_types"]) && !empty($_POST["reservation_types"])) { $tmp = explode('#', $_POST["reservation_types"]); $where .= " AND `glpi_reservationitems`.`itemtype` = '" . $tmp[0] . "'"; if (isset($tmp[1]) && $tmp[0] == 'Peripheral' && $itemtype == 'Peripheral') { $left .= " LEFT JOIN `glpi_peripheraltypes`\n ON (`glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`)"; $where .= " AND `{$itemtable}`.`peripheraltypes_id` = '" . $tmp[1] . "'"; } } $query = "SELECT `glpi_reservationitems`.`id`,\n `glpi_reservationitems`.`comment`,\n `{$itemtable}`.`name` AS name,\n `{$itemtable}`.`entities_id` AS entities_id,\n {$otherserial},\n `glpi_locations`.`id` AS location,\n `glpi_reservationitems`.`items_id` AS items_id\n FROM `glpi_reservationitems`\n INNER JOIN `{$itemtable}`\n ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n {$left}\n LEFT JOIN `glpi_locations`\n ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n WHERE `glpi_reservationitems`.`is_active` = '1'\n AND `glpi_reservationitems`.`is_deleted` = '0'\n AND `{$itemtable}`.`is_deleted` = '0'\n {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n ORDER BY `{$itemtable}`.`entities_id`,\n `{$itemtable}`.`name`"; if ($result = $DB->query($query)) { while ($row = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2'><td>"; echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>"; $typename = $item->getTypeName(); if ($itemtype == 'Peripheral') { $item->getFromDB($row['items_id']); if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) { $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]); } } echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>" . sprintf(__('%1$s - %2$s'), $typename, $row["name"]) . "</a></td>"; echo "<td>" . Dropdown::getDropdownName("glpi_locations", $row["location"]) . "</td>"; echo "<td>" . nl2br($row["comment"]) . "</td>"; if ($showentity) { echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>"; } echo "</tr>\n"; $ok = true; } } } if ($ok) { echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>"; if (isset($_POST['reserve'])) { echo Html::hidden('begin', array('value' => $_POST['reserve']["begin"])); echo Html::hidden('end', array('value' => $_POST['reserve']["end"])); } echo "<input type='submit' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>\n"; } echo "</table>\n"; echo "<input type='hidden' name='id' value=''>"; echo "</form>"; // No CSRF token needed echo "</div>\n"; }
/** * Show visibility config for a reminder **/ function showVisibility() { global $DB, $CFG_GLPI; $ID = $this->fields['id']; $canedit = Session::haveRight('reminder_public', 'w'); echo "<div class='center'>"; $rand = mt_rand(); $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='remindervisibility_form{$rand}' id='remindervisibility_form{$rand}' "; echo " method='post' action='" . Toolbox::getItemTypeFormURL('Reminder') . "'>"; echo "<input type='hidden' name='reminders_id' value='{$ID}'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</tr>"; echo "<tr class='tab_bg_2'><td width='100px'>"; $types = array('Entity', 'Group', 'Profile', 'User'); $addrand = Dropdown::showItemTypes('_type', $types); $params = array('type' => '__VALUE__', 'right' => 'reminder_public'); Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params); echo "</td>"; echo "<td><span id='visibility{$rand}'></span>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $nb) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('deletevisibility' => _x('button', 'Delete permanently'))); if ($this->fields['users_id'] != Session::getLoginUserID()) { $paramsma['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.'); } Html::showMassiveActions(__CLASS__, $paramsma); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr>"; if ($canedit && $nb) { echo "<th width='10'>"; echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('Type') . "</th>"; echo "<th>" . _n('Recipient', 'Recipients', 2) . "</th>"; echo "</tr>"; // Users if (count($this->users)) { foreach ($this->users as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Reminder_User][" . $data["id"] . "]'\n value='1' >"; echo "</td>"; } echo "<td>" . __('User') . "</td>"; echo "<td>" . getUserName($data['users_id']) . "</td>"; echo "</tr>"; } } } // Groups if (count($this->groups)) { foreach ($this->groups as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Group_Reminder][" . $data["id"] . "]'\n value='1'>"; echo "</td>"; } echo "<td>" . __('Group') . "</td>"; $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1); $entname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false))); if ($data['entities_id'] >= 0) { $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id'])); if ($data['is_recursive']) { //TRANS: R for Recursive sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>"); } } echo "<td>" . $entname . "</td>"; echo "</tr>"; } } } // Entity if (count($this->entities)) { foreach ($this->entities as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Entity_Reminder][" . $data["id"] . "]'\n value='1'>"; echo "</td>"; } echo "<td>" . __('Entity') . "</td>"; $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1); $tooltip = Html::showToolTip($names["comment"], array('display' => false)); $entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip); if ($data['is_recursive']) { $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>"); } echo "<td>" . $entname . "</td>"; echo "</tr>"; } } } // Profiles if (count($this->profiles)) { foreach ($this->profiles as $key => $val) { foreach ($val as $data) { echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; echo "<input type='checkbox' name='item[Profile_Reminder][" . $data["id"] . "]'\n value='1'>"; echo "</td>"; } echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>"; $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1); $tooltip = Html::showToolTip($names["comment"], array('display' => false)); $entname = sprintf(__('%1$s %2$s'), $names["name"], $entname); if ($data['entities_id'] >= 0) { $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id'])); if ($data['is_recursive']) { $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>"); } } echo "<td>" . $entname . "</td>"; echo "</tr>"; } } } echo "</table>"; if ($canedit && $nb) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; // Add items return true; }