function showForSLT(SLT $slt)
{
global $DB;
$ID = $slt->getField('id');
if (!$slt->can($ID, READ)) {
return false;
}
$canedit = $slt->can($ID, UPDATE);
$rand = mt_rand();
if ($canedit) {
echo "<div class='center first-bloc'>";
echo "<form name='slalevel_form{$rand}' id='slalevel_form{$rand}' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add an escalation level') . "</tr>";
echo "<tr class='tab_bg_2'><td class='center'>" . __('Name') . "";
echo "<input type='hidden' name='slts_id' value='{$ID}'>";
echo "<input type='hidden' name='entities_id' value='" . $slt->getEntityID() . "'>";
echo "<input type='hidden' name='is_recursive' value='" . $slt->isRecursive() . "'>";
echo "<input type='hidden' name='match' value='AND'>";
echo "</td><td><input name='name' value=''>";
echo "</td><td class='center'>" . __('Execution') . "</td><td>";
$delay = $slt->getSLTTime();
self::dropdownExecutionTime('execution_time', array('max_time' => $delay, 'used' => self::getAlreadyUsedExecutionTime($slt->fields['id'])));
echo "</td><td class='center'>" . __('Active') . "</td><td>";
Dropdown::showYesNo("is_active", 1);
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
$query = "SELECT *\n FROM `glpi_slalevels`\n WHERE `slts_id` = '{$ID}'\n ORDER BY `execution_time`";
$result = $DB->query($query);
$numrows = $DB->numrows($result);
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr>";
if ($canedit && $numrows) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('Execution') . "</th>";
echo "<th>" . __('Active') . "</th>";
echo "</tr>";
Session::initNavigateListItems('SlaLevel', sprintf(__('%1$s = %2$s'), SLT::getTypeName(1), $slt->getName()));
while ($data = $DB->fetch_assoc($result)) {
Session::addToNavigateListItems('SlaLevel', $data["id"]);
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
}
echo "<td>";
if ($canedit) {
echo "<a href='" . Toolbox::getItemTypeFormURL('SlaLevel') . "?id=" . $data["id"] . "'>";
}
echo $data["name"];
if (empty($data["name"])) {
echo "(" . $data['id'] . ")";
}
if ($canedit) {
echo "</a>";
}
echo "</td>";
echo "<td>" . ($data["execution_time"] != 0 ? Html::timestampToString($data["execution_time"], false) : __('Time to resolve')) . "</td>";
echo "<td>" . Dropdown::getYesNo($data["is_active"]) . "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'><td colspan='2'>";
$this->getRuleWithCriteriasAndActions($data['id'], 1, 1);
$this->showCriteriasList($data["id"], array('readonly' => true));
echo "</td><td colspan='2'>";
$this->showActionsList($data["id"], array('readonly' => true));
echo "</td></tr>";
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}