From e7b3280c172e9c3cb439ae39da27950d1de0b6b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 11 Jul 2021 01:12:52 +0200 Subject: [PATCH] Debug v14 with nojs --- htdocs/admin/accountant.php | 8 +- htdocs/admin/company.php | 8 +- htdocs/core/class/extrafields.class.php | 48 ++--- htdocs/core/class/html.form.class.php | 248 ++++++++++++----------- htdocs/core/tpl/extrafields_view.tpl.php | 1 - htdocs/product/card.php | 88 ++++---- htdocs/societe/card.php | 2 +- 7 files changed, 210 insertions(+), 193 deletions(-) diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index 7c82775abad..24df7e0cb68 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -99,14 +99,16 @@ print "
\n"; /** * Edit parameters */ -print "\n".''."\n"; + print ''."\n"; +} print '
'; print ''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index d2dac38b500..b33c0adde29 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -384,14 +384,16 @@ print "
\n"; /** * Edit parameters */ -print "\n".''."\n"; + print ''."\n"; +} print ''; print ''; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 54d812aeafb..f6a5ba93d61 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2006,30 +2006,32 @@ class ExtraFields $collapse_display = ((isset($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key]) || GETPOST('ignorecollapsesetup', 'int')) ? ($_COOKIE['DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key] ? true : false) : ($extrafield_collapse_display_value == 2 ? false : true)); $extrafields_collapse_num = $this->attributes[$object->table_element]['pos'][$key].(!empty($object->id)?'_'.$object->id:''); - $out .= ''."\n"; - $out .= ''."\n"; } - $out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').'").click(function(){'."\n"; - $out .= ' console.log("We click on collapse/uncollapse .trextrafields_collapse'.$extrafields_collapse_num.'");'."\n"; - $out .= ' jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").toggle(300, function(){'."\n"; - $out .= ' if (jQuery(".trextrafields_collapse'.$extrafields_collapse_num.'").is(":hidden")) {'."\n"; - $out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-plus-square").removeClass("fa-minus-square");'."\n"; - $out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=0; path='.$_SERVER["PHP_SELF"].'"'."\n"; - $out .= ' } else {'."\n"; - $out .= ' jQuery("#trextrafieldseparator'.$key.(!empty($object->id)?'_'.$object->id:'').' '.$tagtype_dyn.' span").addClass("fa-minus-square").removeClass("fa-plus-square");'."\n"; - $out .= ' document.cookie = "DOLCOLLAPSE_'.$object->table_element.'_extrafields_'.$key.'=1; path='.$_SERVER["PHP_SELF"].'"'."\n"; - $out .= ' }'."\n"; - $out .= ' });'."\n"; - $out .= ' });'."\n"; - $out .= '});'."\n"; - $out .= ''."\n"; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 048fbb0cad3..816e0a79225 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7067,7 +7067,7 @@ class Form public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) { global $conf, $langs; - global $delayedhtmlcontent; + global $delayedhtmlcontent; // Will be used later outside of this function // TODO Use an internal dolibarr component instead of select2 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { @@ -7076,68 +7076,71 @@ class Form $out = ''; - $tmpplugin = 'select2'; - $outdelayed = "\n".' - '; + }); + '; + } if ($acceptdelayedhtml) { $delayedhtmlcontent .= $outdelayed; @@ -7168,7 +7171,7 @@ class Form public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) { global $conf, $langs; - global $delayedhtmlcontent; + global $delayedhtmlcontent; // Will be used later outside of this function // TODO Use an internal dolibarr component instead of select2 if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT')) { @@ -7187,74 +7190,77 @@ class Form $formattedarrayresult[] = $o; } - $tmpplugin = 'select2'; - $outdelayed = "\n".' - '; + '.($callurlonselect ? ' + /* Code to execute a GET when we select a value */ + $(".'.$htmlname.'").change(function() { + var selected = $(".'.$htmlname.'").val(); + console.log("We select "+selected) + + $(".'.$htmlname.'").val(""); /* reset visible combo value */ + $.each( saveRemoteData, function( key, value ) { + if (key == selected) + { + console.log("selectArrayFilter - Do a redirect to "+value.url) + location.assign(value.url); + } + }); + });' : '').' + + }); + '; + } if ($acceptdelayedhtml) { $delayedhtmlcontent .= $outdelayed; @@ -7297,7 +7303,7 @@ class Form } // Add code for jquery to use multiselect - if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) { $out .= "\n".''; $out .= "\n".''."\n"; + print ''."\n"; + } // Load object modCodeProduct $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON : 'mod_codeproduct_leopard'); @@ -1551,14 +1553,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - print ''."\n"; + } // We set country_id, country_code and country for the selected country $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $object->country_id; @@ -1646,46 +1650,48 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $inherited_mask_sn = getDolGlobalString('SN_ADVANCED_MASK'); print ''; print $form->textwithpicto('', $tooltip, 1, 1); - - print ''; + '; + } print ''; } } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 76ae78fdb51..b62c277cdf2 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1859,7 +1859,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $sub2 = 1; } - if ($conf->use_javascript_ajax) { + if (!empty($conf->use_javascript_ajax)) { print "\n".'