/** form for Cartridge * * @since version 0.84 * * @param $ID integer Id of the cartridge * @param $options array of possible options: * - parent Object : the printers where the cartridge is used **/ function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; if (isset($options['parent']) && !empty($options['parent'])) { $printer = $options['parent']; } if (!$this->getFromDB($ID)) { return false; } $printer = new Printer(); $printer->check($this->getField('printers_id'), UPDATE); $cartitem = new CartridgeItem(); $cartitem->getFromDB($this->getField('cartridgeitems_id')); $is_old = !empty($this->fields['date_out']); $is_used = !empty($this->fields['date_use']); $options['colspan'] = 2; $options['candel'] = false; // Do not permit delete here $options['canedit'] = $is_used; // Do not permit edit if cart is not used $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . _n('Printer', 'Printers', 1) . "</td><td>"; echo $printer->getLink(); echo "<input type='hidden' name='printers_id' value='" . $this->getField('printers_id') . "'>\n"; echo "<input type='hidden' name='cartridgeitems_id' value='" . $this->getField('cartridgeitems_id') . "'>\n"; echo "</td>\n"; echo "<td>" . _n('Cartridge model', 'Cartridge models', 1) . "</td>"; echo "<td>" . $cartitem->getLink() . "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Add date') . "</td>"; echo "<td>" . Html::convDate($this->fields["date_in"]) . "</td>"; echo "<td>" . __('Use date') . "</td><td>"; if ($is_used && !$is_old) { Html::showDateField("date_use", array('value' => $this->fields["date_use"], 'maybeempty' => false, 'canedit' => true, 'min' => $this->fields["date_in"])); } else { echo Html::convDate($this->fields["date_use"]); } echo "</td></tr>\n"; if ($is_old) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('End date') . "</td><td>"; Html::showDateField("date_out", array('value' => $this->fields["date_out"], 'maybeempty' => false, 'canedit' => true, 'min' => $this->fields["date_use"])); echo "</td>"; echo "<td>" . __('Printer counter') . "</td><td>"; echo "<input type='text' name='pages' value=\"" . $this->fields['pages'] . "\">"; echo "</td></tr>\n"; } $this->showFormButtons($options); return true; }