db = $db; } /** * Output the buttons to submit a creation/edit form * * @param string $save_label Alternative label for save button * @param string $cancel_label Alternative label for cancel button * @param array $morebuttons Add additional buttons between save and cancel * @param bool $withoutdiv Option to remove enclosing centered div * @param string $morecss More CSS * @param string $dol_openinpopup If the button are shown in a context of a page shown inside a popup, we put here the string name of popup. * @return string Html code with the buttons */ public function buttonsSaveCancel($save_label = 'Save', $cancel_label = 'Cancel', $cancelURL = '', $morebuttons = array(), $withoutdiv = 0, $morecss = '', $dol_openinpopup = '') { global $langs; $buttons = array(); $save = array( 'name' => 'save', 'label_key' => $save_label, ); if ($save_label == 'Create' || $save_label == 'Add') { $save['name'] = 'add'; } elseif ($save_label == 'Modify') { $save['name'] = 'edit'; } $cancel = array( 'name' => 'cancel', 'label_key' => 'Cancel', ); !empty($save_label) ? $buttons[] = $save : ''; if (!empty($morebuttons)) { $buttons[] = $morebuttons; } //!empty($cancel_label) ? $buttons[] = $cancel : ''; $retstring = $withoutdiv ? '' : '
'; foreach ($buttons as $button) { $addclass = empty($button['addclass']) ? '' : $button['addclass']; $retstring .= ''; } if ($cancel_label == "Cancel") { $retstring .= '' . $langs->trans($cancel['label_key']) . ''; } $retstring .= $withoutdiv ? '' : '
'; if ($dol_openinpopup) { $retstring .= '' . "\n"; $retstring .= ''; } return $retstring; } }