/** * @since version 0.84.3 * * @see CommonDBTM::post_getFromDB() */ function post_getFromDB() { // Get correct itemtype if defult one is used if (static::$itemtype == 'Rule') { $rule = new Rule(); if ($rule->getFromDB($this->fields['rules_id'])) { static::$itemtype = $rule->fields['sub_type']; } } }
/** form for rule criteria * * @since version 0.85 * * @param $ID integer Id of the criteria * @param $options array of possible options: * - rule Object : the rule **/ function showForm($ID, $options = array()) { global $CFG_GLPI; // Yllen: you always have parent for criteria $rule = $options['parent']; if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[static::$items_id] = $rule->getField('id'); //force itemtype of parent static::$itemtype = get_class($rule); $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . _n('Criterion', 'Criteria', 1) . "</td><td colspan='3'>"; echo "<input type='hidden' name='" . $rule->getRuleIdField() . "' value='" . $this->fields[$rule->getRuleIdField()] . "'>"; $rand = $rule->dropdownCriteria(array('value' => $this->fields['criteria'])); $params = array('criteria' => '__VALUE__', 'rand' => $rand, 'sub_type' => $rule->getType()); Ajax::updateItemOnSelectEvent("dropdown_criteria{$rand}", "criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params); if (isset($this->fields['criteria']) && !empty($this->fields['criteria'])) { $params['criteria'] = $this->fields['criteria']; $params['condition'] = $this->fields['condition']; $params['pattern'] = $this->fields['pattern']; echo "<script type='text/javascript' >\n"; Ajax::updateItemJsCode("criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params); echo '</script>'; } if ($rule->specific_parameters) { $itemtype = get_class($rule) . 'Parameter'; echo "<img alt='' title=\"" . __s('Add a criterion') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('addcriterion' . $rand) . ".dialog('open');\">"; Ajax::createIframeModalWindow('addcriterion' . $rand, Toolbox::getItemTypeFormURL($itemtype), array('reloadonclose' => true)); } echo "</td></tr>"; echo "<tr><td colspan='4'><span id='criteria_span'>\n"; echo "</span></td></tr>\n"; $this->showFormButtons($options); }
/** * Print the sla form * * @param $ID integer ID of the item * @param $options array of possible options: * - target filename : where to go when done. * - withtemplate boolean : template or basic item * *@return boolean item found **/ function showForm($ID, $options = array()) { $rowspan = 4; if ($ID > 0) { $rowspan = 6; } // Get SLA object $sla = new SLA(); if (isset($options['parent'])) { $sla = $options['parent']; } else { $sla->getFromDB($this->fields['slas_id']); } if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[static::$items_id] = $sla->getField('id'); //force itemtype of parent static::$itemtype = get_class($sla); $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name", array('value' => $this->fields["name"])); echo "<td rowspan='" . $rowspan . "'>" . __('Comments') . "</td>"; echo "<td rowspan='" . $rowspan . "'>\n <textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('SLA') . "</td>"; echo "<td>"; echo $sla->getLink(); echo "<input type='hidden' name='slas_id' value='" . $this->fields['slas_id'] . "'>"; echo "</td></tr>"; if ($ID > 0) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Last update') . "</td>"; echo "<td>" . ($this->fields["date_mod"] ? Html::convDateTime($this->fields["date_mod"]) : __('Never')); echo "</td></tr>"; } echo "<tr class='tab_bg_1'><td>" . __('Type') . "</td>"; echo "<td>"; self::getSltTypeDropdown(array('value' => $this->fields["type"])); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td>" . __('Maximum time') . "</td>"; echo "<td>"; Dropdown::showNumber("number_time", array('value' => $this->fields["number_time"], 'min' => 0)); $possible_values = array('minute' => _n('Minute', 'Minutes', Session::getPluralNumber()), 'hour' => _n('Hour', 'Hours', Session::getPluralNumber()), 'day' => _n('Day', 'Days', Session::getPluralNumber())); $rand = Dropdown::showFromArray('definition_time', $possible_values, array('value' => $this->fields["definition_time"], 'on_change' => 'appearhideendofworking()')); echo "\n<script type='text/javascript' >\n"; echo "function appearhideendofworking() {\n"; echo "if (\$('#dropdown_definition_time{$rand} option:selected').val() == 'day') {\n \$('#title_endworkingday').show();\n \$('#dropdown_endworkingday').show();\n } else {\n \$('#title_endworkingday').hide();\n \$('#dropdown_endworkingday').hide();\n }"; echo "}\n"; echo "appearhideendofworking();\n"; echo "</script>\n"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td><div id='title_endworkingday'>" . __('End of working day') . "</div></td>"; echo "<td><div id='dropdown_endworkingday'>"; Dropdown::showYesNo("end_of_working_day", $this->fields["end_of_working_day"]); echo "</div></td></tr>"; $this->showFormButtons($options); return true; }
/** form for rule action * * @since version 0.85 * * @param $ID integer : Id of the action * @param $options array of possible options: * - rule Object : the rule **/ function showForm($ID, $options = array()) { global $CFG_GLPI; // Yllen: you always have parent for action $rule = $options['parent']; if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[static::$items_id] = $rule->getField('id'); //force itemtype of parent static::$itemtype = get_class($rule); $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1 center'>"; echo "<td>" . _n('Action', 'Actions', 1) . "</td><td colspan='3'>"; echo "<input type='hidden' name='" . $rule->getRuleIdField() . "' value='" . $this->fields[static::$items_id] . "'>"; $used = $this->getAlreadyUsedForRuleID($this->fields[static::$items_id], $rule->getType()); // On edit : unset selected value if ($ID && isset($used[$this->fields['field']])) { unset($used[$this->fields['field']]); } $rand = $rule->dropdownActions(array('value' => $this->fields['field'], 'used' => $used)); $params = array('field' => '__VALUE__', 'sub_type' => $rule->getType(), 'ruleactions_id' => $this->getID(), $rule->getRuleIdField() => $this->fields[static::$items_id]); Ajax::updateItemOnSelectEvent("dropdown_field{$rand}", "action_span", $CFG_GLPI["root_doc"] . "/ajax/ruleaction.php", $params); if (isset($this->fields['field']) && !empty($this->fields['field'])) { $params['field'] = $this->fields['field']; $params['action_type'] = $this->fields['action_type']; $params['value'] = $this->fields['value']; echo "<script type='text/javascript' >\n"; Ajax::updateItemJsCode("action_span", $CFG_GLPI["root_doc"] . "/ajax/ruleaction.php", $params); echo '</script>'; } echo "</td></tr>"; echo "<tr><td colspan='4'><span id='action_span'>\n"; echo "</span></td>\n"; echo "</tr>\n"; $this->showFormButtons($options); }
/** * @param $rule_type (default 'Rule) **/ function __construct($rule_type = 'Rule') { static::$itemtype = $rule_type; }