function showFormButtons($options = array())
{
global $CFG_GLPI;
// for single object like config
if (isset($this->fields['id'])) {
$ID = $this->fields['id'];
} else {
$ID = 1;
}
$params['colspan'] = 2;
$params['withtemplate'] = '';
$params['candel'] = true;
$params['canedit'] = true;
$params['addbuttons'] = array();
$params['formfooter'] = null;
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$params[$key] = $val;
}
}
if ($params['formfooter'] === null) {
$this->showDates($params);
}
if (!$params['canedit'] || !$this->canEdit($ID)) {
echo "</table></div>";
// Form Header always open form
if (!$params['canedit']) {
Html::closeForm();
}
return false;
}
echo "<tr class='tab_bg_2'>";
if ($params['withtemplate'] || $this->isNewID($ID)) {
echo "<td class='center' colspan='" . $params['colspan'] * 2 . "'>";
if ($ID <= 0 || $params['withtemplate'] == 2) {
echo Html::submit(_x('button', 'Add'), array('name' => 'add'));
} else {
//TRANS : means update / actualize
echo Html::submit(_x('button', 'Save'), array('name' => 'update'));
}
} else {
if ($params['candel'] && !$this->can($ID, DELETE) && !$this->can($ID, PURGE)) {
$params['candel'] = false;
}
if ($params['canedit'] && $this->can($ID, UPDATE)) {
echo "<td class='center' colspan='" . $params['colspan'] * 2 . "'>\n";
echo Html::submit(_x('button', 'Save'), array('name' => 'update'));
}
if ($params['candel']) {
if ($params['canedit'] && $this->can($ID, UPDATE)) {
echo "</td></tr><tr class='tab_bg_2'>\n";
}
if ($this->isDeleted()) {
if ($this->can($ID, DELETE)) {
echo "<td class='right' colspan='" . $params['colspan'] * 2 . "' >\n";
echo Html::submit(_x('button', 'Restore'), array('name' => 'restore'));
}
if ($this->can($ID, PURGE)) {
echo "<span class='very_small_space'>";
if (in_array($this->getType(), Item_Devices::getConcernedItems())) {
Html::showToolTip(__('Check to keep the devices while deleting this item'));
echo " ";
echo "<input type='checkbox' name='keep_devices' value='1'";
if (!empty($_SESSION['glpikeep_devices_when_purging_item'])) {
echo " checked";
}
echo "> ";
}
echo Html::submit(_x('button', 'Delete permanently'), array('name' => 'purge'));
echo "</span>";
}
} else {
echo "<td class='right' colspan='" . $params['colspan'] * 2 . "' >\n";
// If maybe dynamic : do not take into account is_deleted field
if (!$this->maybeDeleted() || $this->useDeletedToLockIfDynamic()) {
if ($this->can($ID, PURGE)) {
echo Html::submit(_x('button', 'Delete permanently'), array('name' => 'purge', 'confirm' => __('Confirm the final deletion?')));
}
} else {
if (!$this->isDeleted() && $this->can($ID, DELETE)) {
echo Html::submit(_x('button', 'Put in dustbin'), array('name' => 'delete'));
}
}
}
}
if ($this->isField('date_mod')) {
echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
}
}
if (!$this->isNewID($ID)) {
echo "<input type='hidden' name='id' value='{$ID}'>";
}
echo "</td>";
echo "</tr>\n";
if ($params['canedit'] && count($params['addbuttons'])) {
echo "<tr class='tab_bg_2'>";
if ($params['colspan'] * 2 - count($params['addbuttons']) > 0) {
echo "<td colspan='" . ($params['colspan'] * 2 - count($params['addbuttons'])) . "'> " . "</td>";
}
foreach ($params['addbuttons'] as $key => $val) {
echo "<td><input class='submit' type='submit' name='{$key}' value=\"" . Html::entities_deep($val) . "\"></td>";
}
echo "</tr>";
}
// Close for Form
echo "</table></div>";
Html::closeForm();
}