예제 #1
0
 /**
  * @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>";
 }
예제 #2
0
파일: slt.class.php 프로젝트: stweil/glpi
 /**
  * Print the HTML array for SLTs linked to a SLA
  *
  * @param SLA $sla
  * @return boolean
  */
 static function showForSla(SLA $sla)
 {
     global $CFG_GLPI;
     $instID = $sla->fields['id'];
     $slt = new self();
     $calendar = new Calendar();
     if (!$sla->can($instID, READ)) {
         return false;
     }
     $canedit = $sla->canEdit($instID) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewslt{$instID}{$rand}'></div>\n";
         echo "<script type='text/javascript' >";
         echo "function viewAddSlt{$instID}{$rand}() {";
         $params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => -1);
         Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "}";
         echo "</script>";
         echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddSlt{$instID}{$rand}();'>";
         echo __('Add a new SLT') . "</a></div>\n";
     }
     // SLT list
     $sltList = $slt->find("`slas_id` = '" . $instID . "'");
     Session::initNavigateListItems('SLT', sprintf(__('%1$s = %2$s'), $sla::getTypeName(1), $sla->getName()));
     echo "<div class='spaced'>";
     if (count($sltList)) {
         if ($canedit) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         $header_begin = "<tr>";
         $header_top = '';
         $header_bottom = '';
         $header_end = '';
         if ($canedit) {
             $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_top .= "</th>";
             $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_bottom .= "</th>";
         }
         $header_end .= "<th>" . __('Name') . "</th>";
         $header_end .= "<th>" . __('Type') . "</th>";
         $header_end .= "<th>" . __('Maximum time') . "</th>";
         $header_end .= "<th>" . __('Calendar') . "</th>";
         echo $header_begin . $header_top . $header_end;
         foreach ($sltList as $val) {
             $edit = $canedit ? "style='cursor:pointer' onClick=\"viewEditSlt" . $instID . $val["id"] . "{$rand}();\"" : '';
             echo "\n<script type='text/javascript' >\n";
             echo "function viewEditSlt" . $instID . $val["id"] . "{$rand}() {\n";
             $params = array('type' => $slt->getType(), 'parenttype' => $sla->getType(), $sla->getForeignKeyField() => $instID, 'id' => $val["id"]);
             Ajax::updateItemJsCode("viewslt{$instID}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
             echo "};";
             echo "</script>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td width='10' {$edit}>";
             if ($canedit) {
                 Html::showMassiveActionCheckBox($slt->getType(), $val['id']);
             }
             echo "</td>";
             $slt->getFromDB($val['id']);
             echo "<td {$edit}>" . $slt->getLink() . "</td>";
             echo "<td {$edit}>" . $slt->getSpecificValueToDisplay('type', $slt->fields['type']) . "</td>";
             echo "<td {$edit}>";
             echo $slt->getSpecificValueToDisplay('number_time', array('number_time' => $slt->fields['number_time'], 'definition_time' => $slt->fields['definition_time']));
             echo "</td>";
             if (!$sla->fields['calendars_id']) {
                 $link = __('24/7');
             } else {
                 if ($sla->fields['calendars_id'] == -1) {
                     $link = __('Calendar of the ticket');
                 } else {
                     if ($calendar->getFromDB($sla->fields['calendars_id'])) {
                         $link = $calendar->getLink();
                     }
                 }
             }
             echo "<td {$edit}>" . $link . "</td>";
             echo "</tr>";
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
     } else {
         echo __('No item to display');
     }
     echo "</div>";
 }
예제 #3
0
 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] . "&nbsp;: ";
         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] . "&nbsp;: ";
         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] . "&nbsp;: ";
         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 "&nbsp;";
                 }
                 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>";
 }