Contract::showForm PHP Method

showForm() public method

Print the contract form
public showForm ( $ID, $options = [] ) : boolean
$ID integer ID of the item
$options array - target filename : where to go when done. - withtemplate boolean : template or basic item
return boolean item found
    function showForm($ID, $options = array())
    {
        $this->initForm($ID, $options);
        $this->showFormHeader($options);
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Name') . "</td><td>";
        Html::autocompletionTextField($this, "name");
        echo "</td>";
        echo "<td>" . __('Contract type') . "</td><td >";
        ContractType::dropdown(array('value' => $this->fields["contracttypes_id"]));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . _x('phone', 'Number') . "</td>";
        echo "<td>";
        Html::autocompletionTextField($this, "num");
        echo "</td>";
        echo "<td colspan='2'></td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Start date') . "</td>";
        echo "<td>";
        Html::showDateField("begin_date", array('value' => $this->fields["begin_date"]));
        echo "</td>";
        echo "<td>" . __('Initial contract period') . "</td><td>";
        Dropdown::showNumber("duration", array('value' => $this->fields["duration"], 'min' => 1, 'max' => 120, 'step' => 1, 'toadd' => array(0 => Dropdown::EMPTY_VALUE), 'unit' => 'month'));
        if (!empty($this->fields["begin_date"])) {
            echo " -> " . Infocom::getWarrantyExpir($this->fields["begin_date"], $this->fields["duration"], 0, true);
        }
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Notice') . "</td><td>";
        Dropdown::showNumber("notice", array('value' => $this->fields["notice"], 'min' => 0, 'max' => 120, 'step' => 1, 'toadd' => array(), 'unit' => 'month'));
        if (!empty($this->fields["begin_date"]) && $this->fields["notice"] > 0) {
            echo " -> " . Infocom::getWarrantyExpir($this->fields["begin_date"], $this->fields["duration"], $this->fields["notice"], true);
        }
        echo "</td>";
        echo "<td>" . __('Account number') . "</td><td>";
        Html::autocompletionTextField($this, "accounting_number");
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Contract renewal period') . "</td><td>";
        Dropdown::showNumber("periodicity", array('value' => $this->fields["periodicity"], 'min' => 12, 'max' => 60, 'step' => 12, 'toadd' => array(0 => Dropdown::EMPTY_VALUE, 1 => sprintf(_n('%d month', '%d months', 1), 1), 2 => sprintf(_n('%d month', '%d months', 2), 2), 3 => sprintf(_n('%d month', '%d months', 3), 3), 6 => sprintf(_n('%d month', '%d months', 6), 6)), 'unit' => 'month'));
        echo "</td>";
        echo "<td>" . __('Invoice period') . "</td>";
        echo "<td>";
        Dropdown::showNumber("billing", array('value' => $this->fields["billing"], 'min' => 12, 'max' => 60, 'step' => 12, 'toadd' => array(0 => Dropdown::EMPTY_VALUE, 1 => sprintf(_n('%d month', '%d months', 1), 1), 2 => sprintf(_n('%d month', '%d months', 2), 2), 3 => sprintf(_n('%d month', '%d months', 3), 3), 6 => sprintf(_n('%d month', '%d months', 6), 6)), 'unit' => 'month'));
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'><td>" . __('Renewal') . "</td><td>";
        self::dropdownContractRenewal("renewal", $this->fields["renewal"]);
        echo "</td>";
        echo "<td>" . __('Max number of items') . "</td><td>";
        Dropdown::showNumber("max_links_allowed", array('value' => $this->fields["max_links_allowed"], 'min' => 1, 'max' => 200, 'step' => 1, 'toadd' => array(0 => __('Unlimited'))));
        echo "</td></tr>";
        if (Entity::getUsedConfig("use_contracts_alert", $this->fields["entities_id"])) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Email alarms') . "</td>";
            echo "<td>";
            self::dropdownAlert(array('name' => "alert", 'value' => $this->fields["alert"]));
            Alert::displayLastAlert(__CLASS__, $ID);
            echo "</td>";
            echo "<td colspan='2'>&nbsp;</td>";
            echo "</tr>";
        }
        echo "<tr class='tab_bg_1'><td class='top'>" . __('Comments') . "</td>";
        echo "<td class='center' colspan='3'>";
        echo "<textarea cols='50' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
        echo "</td></tr>";
        echo "<tr class='tab_bg_2'><td>" . __('Support hours') . "</td>";
        echo "<td colspan='3'>&nbsp;</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('on week') . "</td>";
        echo "<td colspan='3'>";
        echo "<table width='100%'><tr><td width='20%'>&nbsp;</td>";
        echo "<td width='20%'>";
        echo "<span class='small_space'>" . __('Start') . "</span>";
        echo "</td><td width='20%'>";
        Dropdown::showHours("week_begin_hour", array('value' => $this->fields["week_begin_hour"]));
        echo "</td><td width='20%'>";
        echo "<span class='small_space'>" . __('End') . "</span></td><td width='20%'>";
        Dropdown::showHours("week_end_hour", array('value' => $this->fields["week_end_hour"]));
        echo "</td></tr></table>";
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('on Saturday') . "</td>";
        echo "<td colspan='3'>";
        echo "<table width='100%'><tr><td width='20%'>";
        Dropdown::showYesNo("use_saturday", $this->fields["use_saturday"]);
        echo "</td><td width='20%'>";
        echo "<span class='small_space'>" . __('Start') . "</span>";
        echo "</td><td width='20%'>";
        Dropdown::showHours("saturday_begin_hour", array('value' => $this->fields["saturday_begin_hour"]));
        echo "</td><td width='20%'>";
        echo "<span class='small_space'>" . __('End') . "</span>";
        echo "</td><td width='20%'>";
        Dropdown::showHours("saturday_end_hour", array('value' => $this->fields["saturday_end_hour"]));
        echo "</td></tr></table>";
        echo "</td></tr>";
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Sundays and holidays') . "</td>";
        echo "<td colspan='3'>";
        echo "<table width='100%'><tr><td width='20%'>";
        Dropdown::showYesNo("use_monday", $this->fields["use_monday"]);
        echo "</td><td width='20%'>";
        echo "<span class='small_space'>" . __('Start') . "</span>";
        echo "</td><td width='20%'>";
        Dropdown::showHours("monday_begin_hour", array('value' => $this->fields["monday_begin_hour"]));
        echo "</td><td width='20%'>";
        echo "<span class='small_space'>" . __('End') . "</span>";
        echo "</td><td width='20%'>";
        Dropdown::showHours("monday_end_hour", array('value' => $this->fields["monday_end_hour"]));
        echo "</td></tr></table>";
        echo "</td></tr>";
        $this->showFormButtons($options);
        return true;
    }

Usage Example

Example #1
0
        $contract->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $contract->check($_POST['id'], 'd');
            if ($contract->restore($_POST)) {
                Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            }
            $contract->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $contract->check($_POST['id'], 'd');
                if ($contract->delete($_POST, 1)) {
                    Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                }
                $contract->redirectToList();
            } else {
                if (isset($_POST["update"])) {
                    $contract->check($_POST['id'], 'w');
                    if ($contract->update($_POST)) {
                        Event::log($_POST["id"], "contracts", 4, "financial", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                    }
                    Html::back();
                } else {
                    Html::header(Contract::getTypeName(2), $_SERVER['PHP_SELF'], "financial", "contract");
                    $contract->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
                    Html::footer();
                }
            }
        }
    }
}
All Usage Examples Of Contract::showForm