/** * @param $sla SLA object **/ function showForSLA(SLA $sla) { global $DB; $ID = $sla->getField('id'); if (!$sla->can($ID, READ)) { return false; } $canedit = $sla->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='slas_id' value='{$ID}'>"; echo "<input type='hidden' name='entities_id' value='" . $sla->getEntityID() . "'>"; echo "<input type='hidden' name='is_recursive' value='" . $sla->isRecursive() . "'>"; echo "<input type='hidden' name='match' value='AND'>"; echo "</td><td><input name='name' value=''>"; echo "</td><td class='center'>" . __('Execution') . "</td><td>"; $resolution_time = $sla->getResolutionTime(); self::dropdownExecutionTime('execution_time', array('max_time' => $resolution_time, 'used' => self::getAlreadyUsedExecutionTime($sla->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 `slas_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'), SLA::getTypeName(1), $sla->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) : __('Due date')) . "</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>"; }
function showForSLA(SLA $sla) { global $DB, $CFG_GLPI, $LANG; $ID = $sla->getField('id'); if (!$sla->can($ID, 'r')) { return false; } $canedit = $sla->can($ID, 'w'); $rand = mt_rand(); echo "<form name='slalevel_form{$rand}' id='slalevel_form{$rand}' method='post' action='"; echo getItemTypeFormURL(__CLASS__) . "'>"; if ($canedit) { echo "<div class='center first-bloc'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['sla'][4] . "</tr>"; echo "<tr class='tab_bg_2'><td class='center'>" . $LANG['common'][16] . " : "; echo "<input type='hidden' name='slas_id' value='{$ID}'>"; echo "<input type='hidden' name='entities_id' value='" . $sla->getEntityID() . "'>"; echo "<input type='hidden' name='is_recursive' value='" . $sla->isRecursive() . "'>"; echo "<input name='name' value=''>"; echo "</td><td class='center'>" . $LANG['sla'][3] . " : "; self::dropdownExecutionTime('execution_time', array('max_time' => $sla->fields['resolution_time'], 'used' => self::getAlreadyUsedExecutionTime($sla->fields['id']))); echo "</td><td class='center'>" . $LANG['common'][60] . " : "; Dropdown::showYesNo("is_active", array('value' => 1)); echo "</td><td class='center'>"; echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td></tr>"; echo "</table></div>"; $query = "SELECT *\n FROM `glpi_slalevels`\n WHERE `slas_id` = '{$ID}'\n ORDER BY `execution_time`"; $result = $DB->query($query); if ($DB->numrows($result) > 0) { echo "<div class='center'><table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='2'>" . $LANG['common'][16] . "</th>"; echo "<th>" . $LANG['sla'][3] . "</th>"; echo "<th>" . $LANG['common'][60] . "</th>"; echo "</tr>"; initNavigateListItems('SlaLevel', $LANG['sla'][1] . " - " . $sla->getName()); while ($data = $DB->fetch_array($result)) { addToNavigateListItems('SlaLevel', $data["id"]); echo "<tr class='tab_bg_2'>"; echo "<td width='10'>"; if ($canedit) { echo "<input type='checkbox' name='item[" . $data["id"] . "]' value='1'>"; } else { echo " "; } echo "</td>"; echo "<td>"; if ($canedit) { echo "<a href='" . 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 ? timestampToString($data["execution_time"], false) : $LANG['sla'][5]) . "</td>"; echo "<td>" . Dropdown::getYesNo($data["is_active"]) . "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'><td colspan='4'>"; $this->getRuleWithCriteriasAndActions($data['id'], 0, 1); $this->showActionsList($data["id"], array('readonly' => true)); echo "</td></tr>"; } openArrowMassive("slalevel_form{$rand}", true); closeArrowMassive('delete', $LANG['buttons'][6]); echo "</table></div>"; } } echo "</form>"; }