CommonITILObject::showSolutionForm PHP Метод

showSolutionForm() публичный Метод

Form to add a solution to an ITIL object
public showSolutionForm ( $knowbase_id_toload )
$knowbase_id_toload integer load a kb article as solution (0 = no load by default) (default 0)
    function showSolutionForm($knowbase_id_toload = 0)
    {
        global $CFG_GLPI;
        $this->check($this->getField('id'), READ);
        $canedit = $this->canSolve();
        $options = array();
        if ($knowbase_id_toload > 0) {
            $kb = new KnowbaseItem();
            if ($kb->getFromDB($knowbase_id_toload)) {
                $this->fields['solution'] = $kb->getField('answer');
            }
        }
        // Alert if validation waiting
        $validationtype = $this->getType() . 'Validation';
        if (method_exists($validationtype, 'alertValidation')) {
            $validationtype::alertValidation($this, 'solution');
        }
        $this->showFormHeader($options);
        $show_template = $canedit;
        $rand_template = mt_rand();
        $rand_text = $rand_type = 0;
        if ($canedit) {
            $rand_text = mt_rand();
            $rand_type = mt_rand();
        }
        if ($show_template) {
            echo "<tr class='tab_bg_2'>";
            echo "<td>" . _n('Solution template', 'Solution templates', 1) . "</td><td>";
            SolutionTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'toupdate' => array('value_fieldname' => 'value', 'to_update' => 'solution' . $rand_text, 'url' => $CFG_GLPI["root_doc"] . "/ajax/solution.php", 'moreparams' => array('type_id' => 'dropdown_solutiontypes_id' . $rand_type))));
            echo "</td><td colspan='2'>";
            if (Session::haveRightsOr('knowbase', array(READ, KnowbaseItem::READFAQ))) {
                echo "<a class='vsubmit' title=\"" . __s('Search a solution') . "\"\n                   href='" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.php?item_itemtype=" . $this->getType() . "&amp;item_items_id=" . $this->getField('id') . "&amp;forcetab=Knowbase\$1'>" . __('Search a solution') . "</a>";
            }
            echo "</td></tr>";
        }
        echo "<tr class='tab_bg_2'>";
        echo "<td>" . __('Solution type') . "</td><td>";
        $current = $this->fields['status'];
        // Settings a solution will set status to solved
        if ($canedit) {
            SolutionType::dropdown(array('value' => $this->getField('solutiontypes_id'), 'rand' => $rand_type, 'entity' => $this->getEntityID()));
        } else {
            echo Dropdown::getDropdownName('glpi_solutiontypes', $this->getField('solutiontypes_id'));
        }
        echo "</td><td colspan='2'>&nbsp;</td></tr>";
        if ($canedit && Session::haveRight('knowbase', UPDATE)) {
            echo "<tr class='tab_bg_2'><td>" . __('Save and add to the knowledge base') . "</td><td>";
            Dropdown::showYesNo('_sol_to_kb', false);
            echo "</td><td colspan='2'>&nbsp;</td></tr>";
        }
        echo "<tr class='tab_bg_2'>";
        echo "<td>" . __('Description') . "</td><td colspan='3'>";
        if ($canedit) {
            $rand = mt_rand();
            Html::initEditorSystem("solution{$rand}");
            echo "<div id='solution{$rand_text}'>";
            echo "<textarea id='solution{$rand}' name='solution' rows='12' cols='80'>" . $this->getField('solution') . "</textarea></div>";
        } else {
            echo Toolbox::unclean_cross_side_scripting_deep($this->getField('solution'));
        }
        echo "</td></tr>";
        $options['candel'] = false;
        $options['canedit'] = $canedit;
        $this->showFormButtons($options);
    }
CommonITILObject