Change_Problem::showForChange PHP 메소드

showForChange() 정적인 공개 메소드

Show problems for a change
static public showForChange ( Change $change )
$change Change Change object
    static function showForChange(Change $change)
    {
        global $DB, $CFG_GLPI;
        $ID = $change->getField('id');
        if (!$change->can($ID, READ)) {
            return false;
        }
        $canedit = $change->canEdit($ID);
        $rand = mt_rand();
        $showentities = Session::isMultiEntitiesMode();
        $query = "SELECT DISTINCT `glpi_changes_problems`.`id` AS linkID,\n                                `glpi_problems`.*\n                FROM `glpi_changes_problems`\n                LEFT JOIN `glpi_problems`\n                     ON (`glpi_changes_problems`.`problems_id` = `glpi_problems`.`id`)\n                WHERE `glpi_changes_problems`.`changes_id` = '{$ID}'\n                ORDER BY `glpi_problems`.`name`";
        $result = $DB->query($query);
        $problems = array();
        $used = array();
        if ($numrows = $DB->numrows($result)) {
            while ($data = $DB->fetch_assoc($result)) {
                $problems[$data['id']] = $data;
                $used[$data['id']] = $data['id'];
            }
        }
        if ($canedit) {
            echo "<div class='firstbloc'>";
            echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
            echo "<table class='tab_cadre_fixe'>";
            echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a problem') . "</th></tr>";
            echo "<tr class='tab_bg_2'><td>";
            echo "<input type='hidden' name='changes_id' value='{$ID}'>";
            Problem::dropdown(array('used' => $used, 'entity' => $change->getEntityID()));
            echo "</td><td class='center'>";
            echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
            echo "</td></tr></table>";
            Html::closeForm();
            echo "</div>";
        }
        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 class='noHover'><th colspan='12'>" . Problem::getTypeName($numrows) . "</th>";
        echo "</tr>";
        if ($numrows) {
            Problem::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
            Session::initNavigateListItems('Problem', sprintf(__('%1$s = %2$s'), Change::getTypeName(1), $change->fields["name"]));
            $i = 0;
            foreach ($problems as $data) {
                Session::addToNavigateListItems('Problem', $data["id"]);
                Problem::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
                $i++;
            }
            Problem::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
        }
        echo "</table>";
        if ($canedit && $numrows) {
            $massiveactionparams['ontop'] = false;
            Html::showMassiveActions($massiveactionparams);
            Html::closeForm();
        }
        echo "</div>";
    }

Usage Example

예제 #1
0
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     switch ($item->getType()) {
         case 'Change':
             Change_Problem::showForChange($item);
             break;
         case 'Ticket':
             Problem_Ticket::showForTicket($item);
             break;
         case __CLASS__:
             switch ($tabnum) {
                 case 1:
                     $item->showAnalysisForm();
                     break;
                 case 2:
                     if (!isset($_POST['load_kb_sol'])) {
                         $_POST['load_kb_sol'] = 0;
                     }
                     $item->showSolutionForm($_POST['load_kb_sol']);
                     break;
                 case 4:
                     $item->showStats();
                     break;
             }
     }
     return true;
 }