static function showInventoryOptions(Entity $entity)
{
$ID = $entity->getField('id');
if (!$entity->can($ID, READ)) {
return false;
}
// Notification right applied
$canedit = Infocom::canUpdate() && Session::haveAccessToEntity($ID);
echo "<div class='spaced'>";
if ($canedit) {
echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>" . __('Autofill dates for financial and administrative information') . "</th></tr>";
$options[0] = __('No autofill');
if ($ID > 0) {
$options[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
foreach (getAllDatasFromTable('glpi_states') as $state) {
$options[Infocom::ON_STATUS_CHANGE . '_' . $state['id']] = sprintf(__('Fill when shifting to state %s'), $state['name']);
}
$options[Infocom::COPY_WARRANTY_DATE] = __('Copy the start date of warranty');
//Buy date
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Date of purchase') . "</td>";
echo "<td>";
Dropdown::showFromArray('autofill_buy_date', $options, array('value' => $entity->getField('autofill_buy_date')));
echo "</td>";
//Order date
echo "<td> " . __('Order date') . "</td>";
echo "<td>";
$options[Infocom::COPY_BUY_DATE] = __('Copy the date of purchase');
Dropdown::showFromArray('autofill_order_date', $options, array('value' => $entity->getField('autofill_order_date')));
echo "</td></tr>";
//Delivery date
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Delivery date') . "</td>";
echo "<td>";
$options[Infocom::COPY_ORDER_DATE] = __('Copy the order date');
Dropdown::showFromArray('autofill_delivery_date', $options, array('value' => $entity->getField('autofill_delivery_date')));
echo "</td>";
//Use date
echo "<td> " . __('Startup date') . " </td>";
echo "<td>";
$options[Infocom::COPY_DELIVERY_DATE] = __('Copy the delivery date');
Dropdown::showFromArray('autofill_use_date', $options, array('value' => $entity->getField('autofill_use_date')));
echo "</td></tr>";
//Warranty date
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Start date of warranty') . "</td>";
echo "<td>";
$options = array(0 => __('No autofill'), Infocom::COPY_BUY_DATE => __('Copy the date of purchase'), Infocom::COPY_ORDER_DATE => __('Copy the order date'), Infocom::COPY_DELIVERY_DATE => __('Copy the delivery date'));
if ($ID > 0) {
$options[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
Dropdown::showFromArray('autofill_warranty_date', $options, array('value' => $entity->getField('autofill_warranty_date')));
echo "</td>";
//Decommission date
echo "<td> " . __('Decommission date') . "</td>";
echo "<td>";
$options = array(0 => __('No autofill'), Infocom::COPY_BUY_DATE => __('Copy the date of purchase'), Infocom::COPY_ORDER_DATE => __('Copy the order date'), Infocom::COPY_DELIVERY_DATE => __('Copy the delivery date'));
if ($ID > 0) {
$options[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
foreach (getAllDatasFromTable('glpi_states') as $state) {
$options[Infocom::ON_STATUS_CHANGE . '_' . $state['id']] = sprintf(__('Fill when shifting to state %s'), $state['name']);
}
Dropdown::showFromArray('autofill_decommission_date', $options, array('value' => $entity->getField('autofill_decommission_date')));
echo "</td></tr>";
echo "<tr><th colspan='4'>" . _n('Software', 'Software', Session::getPluralNumber()) . "</th></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Entity for software creation') . "</td>";
echo "<td>";
$toadd = array(self::CONFIG_NEVER => __('No change of entity'));
// Keep software in PC entity
if ($ID > 0) {
$toadd[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
$entities = array($entity->fields['entities_id']);
foreach (getAncestorsOf('glpi_entities', $entity->fields['entities_id']) as $ent) {
if (Session::haveAccessToEntity($ent)) {
$entities[] = $ent;
}
}
self::dropdown(array('name' => 'entities_id_software', 'value' => $entity->getField('entities_id_software'), 'toadd' => $toadd, 'entity' => $entities, 'comments' => false));
if ($entity->fields['entities_id_software'] == self::CONFIG_PARENT) {
$tid = self::getUsedConfig('entities_id_software', $entity->getField('entities_id'));
echo "<font class='green'> ";
echo self::getSpecificValueToDisplay('entities_id_software', $tid);
echo "</font>";
}
echo "</td><td colspan='2'></td></tr>";
if ($canedit) {
echo "<tr>";
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
} else {
echo "</table>";
}
echo "</div>";
}