diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f600f1a5fcb..48a00919d65 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -10079,14 +10079,15 @@ class Form /** * 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 - * @return string Html code with the buttons + * @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', $morebuttons = array(), $withoutdiv = 0, $morecss = '') + public function buttonsSaveCancel($save_label = 'Save', $cancel_label = 'Cancel', $morebuttons = array(), $withoutdiv = 0, $morecss = '', $dol_openinpopup = '') { global $langs; @@ -10124,6 +10125,19 @@ class Form } $retstring .= $withoutdiv ? '': ''; + if ($dol_openinpopup) { + $retstring .= ''."\n"; + $retstring .= ''; + // TODO @LDR for the save button, in action "add", set parent var to return data and close the window + //$retstring .= 'setid '; + //$retstring .= 'setlabel'; + } + return $retstring; } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 14281e47a69..8776381b922 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1575,36 +1575,70 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = * Such buttons must be included inside a HTML form. * * @param string $name A name for the html component - * @param string $label Label of button + * @param string $label Label shown in Popup title top bar * @param string $buttonstring button string * @param string $url Url to open * @param string $disabled Disabled text + * @param string $morecss More CSS + * @param string $backtopagejsfields The back to page must be managed using javascript instead of a redirect. + * Value is 'Name of html component to set with id:Name of html component to set with label' + * TODO Support this mode, for example when used from the page create a project on thirdparty creation. * @return string HTML component with button */ -function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '') +function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled = '', $morecss = 'button bordertransp', $backtopagejsfields = '') { if (strpos($url, '?') > 0) { - $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup=1'; + $url .= '&dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name); } else { - $url .= '?dol_hide_menuinpopup=1&dol_hide_leftmenu=1&dol_openinpopup=1'; + $url .= '?dol_hide_topmenu=1&dol_hide_leftmenu=1&dol_openinpopup='.urlencode($name); + } + + $out .= ''; + + $backtopagejsfieldsid = ''; $backtopagejsfieldslabel = ''; + if ($backtopagejsfields) { + $url .= '&backtopagejsfields='.urlencode($backtopagejsfields); + $tmpbacktopagejsfields = explode(':', $backtopagejsfields); + $backtopagejsfieldsid = empty($tmpbacktopagejsfields[0]) ? '' : $tmpbacktopagejsfields[0]; + $backtopagejsfieldslabel = empty($tmpbacktopagejsfields[1]) ? '' : $tmpbacktopagejsfields[1]; } //print ''; - $out = ''.$buttonstring.''; + $out .= ''."\n"; + $out .= ''.$buttonstring.''; + $out .= '