diff --git a/htdocs/public/test/test_arrays.php b/htdocs/public/test/test_arrays.php index b2a87a75480..05fc13c0dbc 100644 --- a/htdocs/public/test/test_arrays.php +++ b/htdocs/public/test/test_arrays.php @@ -22,19 +22,22 @@ if (!defined("NOLOGIN")) { define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) } - require '../../main.inc.php'; +// Security if ($dolibarr_main_prod) { accessforbidden(); } -$usedolheader = 1; // 1 = Test inside a dolibarr page, 0 = Use hard coded header + + +/* + * View + */ $form = new Form($db); - - +$usedolheader = 1; // 1 = Test inside a dolibarr page, 0 = Use hard coded header // HEADER //-------- diff --git a/htdocs/public/test/test_csrf.php b/htdocs/public/test/test_csrf.php index c66ac19c423..94d76469f81 100644 --- a/htdocs/public/test/test_csrf.php +++ b/htdocs/public/test/test_csrf.php @@ -1,5 +1,38 @@ diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php new file mode 100644 index 00000000000..8464ba2eb4f --- /dev/null +++ b/htdocs/public/test/test_exec.php @@ -0,0 +1,72 @@ +\n"; +print 'PHP_SESSION_DISABLED='.PHP_SESSION_DISABLED."
\n"; +print 'PHP_SESSION_NONE='.PHP_SESSION_NONE."
\n"; +print 'PHP_SESSION_ACTIVE='.PHP_SESSION_ACTIVE."
\n"; +print '
'; + +print 'session_status='.session_status().' (before main.inc.php)'; +print '
'; + +require '../../main.inc.php'; + +// Security +if ($dolibarr_main_prod) { + accessforbidden(); +} + + +/* + * View + */ + +print 'session_status='.session_status().' (after main.inc.php)'; +print '
'; + +//print 'a'.$_SESSION['disablemodules'].'b'; + +print "\n
This page is visible. It means you are not locked by another page called in same session."; + +//session_write_close(); diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index d89e04e12a6..c025151bdb9 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -8,10 +8,16 @@ if (!defined('NOSESSION')) { require '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +// Security if ($dolibarr_main_prod) { accessforbidden(); } + +/* + * View + */ + llxHeader(); ?> diff --git a/htdocs/public/test/test_sessionlock.php b/htdocs/public/test/test_sessionlock.php index 18a1ef73d08..83d21f38aae 100644 --- a/htdocs/public/test/test_sessionlock.php +++ b/htdocs/public/test/test_sessionlock.php @@ -52,17 +52,34 @@ print '
'; require '../../main.inc.php'; -/* No need for this. +// Security if ($dolibarr_main_prod) { accessforbidden(); } -*/ -print 'session_status='.session_status().' (after main.inc.php)'; -print '
'; -//print 'a'.$_SESSION['disablemodules'].'b'; +/* + * View + */ -print "\n
This page is visible. It means you are not locked by another page called in same session."; +echo "Test\n"; +$out=''; +$ret=0; -//session_write_close(); +$file = '/tmp/aaa'; +$f=fopen($file, 'r'); +if ($f) { + $s=fread($f, 4096); + print $s; + fclose($f); +} else { + print "Failed to open file ".$file."\n"; +} + +exec('ls /dev/std*; sleep 1;', $out, $ret); +var_dump($ret); +var_dump($out); + +exec('/usr/bin/clamdscan --fdpass filethatdoesnotexists.php', $out, $ret); +var_dump($ret); +var_dump($out); From 0c27182c6a8fa9bff72c2d55711728d98adefea1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Nov 2021 20:58:34 +0100 Subject: [PATCH 050/576] Fix test --- htdocs/public/test/test_exec.php | 25 ++++++++++++++++++++----- htdocs/public/test/test_sessionlock.php | 23 +++++------------------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index 8464ba2eb4f..603671e893d 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -62,11 +62,26 @@ if ($dolibarr_main_prod) { * View */ -print 'session_status='.session_status().' (after main.inc.php)'; -print '
'; +echo "Test
\n"; +$out=''; +$ret=0; -//print 'a'.$_SESSION['disablemodules'].'b'; +$file = '/tmp/aaa'; +$f=fopen($file, 'r'); +if ($f) { + $s=fread($f, 4096); + print $s; + fclose($f); +} else { + print "Failed to open file ".$file."
\n"; +} -print "\n
This page is visible. It means you are not locked by another page called in same session."; +exec('ls /dev/std*; sleep 1;', $out, $ret); +print $ret."
\n"; +print_r($out); -//session_write_close(); +$ret = 0; +$out = null; +exec('/usr/bin/clamdscan --fdpass filethatdoesnotexists.php', $out, $ret); +print $ret."
\n"; +print_r($out); diff --git a/htdocs/public/test/test_sessionlock.php b/htdocs/public/test/test_sessionlock.php index 83d21f38aae..8464ba2eb4f 100644 --- a/htdocs/public/test/test_sessionlock.php +++ b/htdocs/public/test/test_sessionlock.php @@ -62,24 +62,11 @@ if ($dolibarr_main_prod) { * View */ -echo "Test\n"; -$out=''; -$ret=0; +print 'session_status='.session_status().' (after main.inc.php)'; +print '
'; -$file = '/tmp/aaa'; -$f=fopen($file, 'r'); -if ($f) { - $s=fread($f, 4096); - print $s; - fclose($f); -} else { - print "Failed to open file ".$file."\n"; -} +//print 'a'.$_SESSION['disablemodules'].'b'; -exec('ls /dev/std*; sleep 1;', $out, $ret); -var_dump($ret); -var_dump($out); +print "\n
This page is visible. It means you are not locked by another page called in same session."; -exec('/usr/bin/clamdscan --fdpass filethatdoesnotexists.php', $out, $ret); -var_dump($ret); -var_dump($out); +//session_write_close(); From b3e9e5c4628fb992952806a038f2d7096f013be4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Nov 2021 21:37:43 +0100 Subject: [PATCH 051/576] Enhance test --- htdocs/public/test/test_exec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index 603671e893d..a25e860021c 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -76,7 +76,7 @@ if ($f) { print "Failed to open file ".$file."
\n"; } -exec('ls /dev/std*; sleep 1;', $out, $ret); +exec('cat /aaa; ls /dev/std*; sleep 1;', $out, $ret); print $ret."
\n"; print_r($out); From 01038b190da15fdc8d2f053c2fb08476c71c7234 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Nov 2021 22:35:10 +0100 Subject: [PATCH 052/576] Better error report on id command that failed --- htdocs/admin/system/web.php | 7 ++++++- htdocs/langs/en_US/errors.lang | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/system/web.php b/htdocs/admin/system/web.php index 93af0097087..921fd839109 100644 --- a/htdocs/admin/system/web.php +++ b/htdocs/admin/system/web.php @@ -70,9 +70,14 @@ if ($labeluser && $labelgroup) { if (function_exists('exec')) { $arrayout = array(); $varout = 0; exec('id', $arrayout, $varout); + print ''.$langs->trans("WebUserGroup")." (real, 'id' command)"; if (empty($varout)) { // Test command is ok. Work only on Linux OS. - print ''.$langs->trans("WebUserGroup")." (real, 'id' command)".join(',', $arrayout)."\n"; + print join(',', $arrayout); + } else { + $langs->load("errors"); + print ''.$langs->trans("ErrorExecIdFailed").''; } + print "\n"; } print ''; print ''; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 114654aed3f..c51414e6833 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -270,6 +270,7 @@ ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Ev CheckVersionFail=Version check fail ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it ErrorNotInDictionaryPaymentConditions=Not in Payment Terms Dictionary, please modify. +ErrorExecIdFailed=Can't execute command "id" # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. From 124e7f9b8823e4c509b7d11bd69b9e9294a119f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 24 Nov 2021 23:07:06 +0100 Subject: [PATCH 053/576] enable societe.class.php in coding test --- htdocs/societe/class/societe.class.php | 12 ++++++------ test/phpunit/CodingPhpTest.php | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 22276cc7bee..84f551bbd93 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4752,12 +4752,12 @@ class Societe extends CommonObject * Function used to replace a thirdparty id with another one. * It must be used within a transaction to avoid trouble * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test * @param int $origin_id Old thirdparty id (will be removed) * @param int $dest_id New thirdparty id * @return bool True if success, False if error */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { if ($origin_id == $dest_id) { dol_syslog('Error: Try to merge a thirdparty into itself'); @@ -4774,9 +4774,9 @@ class Societe extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' WHERE fk_soc = '.(int) $origin_id.') '; - $resql = $db->query($sql); - while ($obj = $db->fetch_object($resql)) { - $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); + $resql = $dbs->query($sql); + while ($obj = $dbs->fetch_object($resql)) { + $dbs->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); } /** @@ -4792,7 +4792,7 @@ class Societe extends CommonObject 'societe_rib' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 383c37e95e5..b069140f420 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -213,12 +213,11 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase 'multicurrency.class.php', 'productbatch.class.php', 'reception.class.php', - 'societe.class.php' ))) { - // Must not found $db-> + // Must not find $db-> $ok=true; $matches=array(); - // Check string $db-> inside a class.php file (it should be $this->db-> insto such classes) + // Check string $db-> inside a class.php file (it should be $this->db-> into such classes) preg_match_all('/'.preg_quote('$db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { $ok=false; From b345c2463cf53e698e9d2bed8e820bc0d7e7b53a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 00:19:55 +0100 Subject: [PATCH 054/576] Fix warning on security page --- htdocs/admin/system/security.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 8a6d6bbb4ed..7bc527bf92c 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -88,9 +88,9 @@ if (function_exists('exec')) { } print '
'; -print "PHP session.use_strict_mode = ".(ini_get('session.use_strict_mode') ? ini_get('session.use_strict_mode') : yn(0)).'   ('.$langs->trans("RecommendedValueIs", '1').")
\n"; -print "PHP session.use_only_cookies = ".(ini_get('session.use_only_cookies') ? ini_get('session.use_only_cookies') : yn(0)).'   ('.$langs->trans("RecommendedValueIs", '1').")
\n"; -print "PHP session.cookie_httponly = ".(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').'   ('.$langs->trans("RecommendedValueIs", '1').")
\n"; +print "PHP session.use_strict_mode = ".(ini_get('session.use_strict_mode') ? '' : img_warning().' ').(ini_get('session.use_strict_mode') ? ini_get('session.use_strict_mode') : yn(0)).'   ('.$langs->trans("RecommendedValueIs", '1').")
\n"; +print "PHP session.use_only_cookies = ".(ini_get('session.use_only_cookies') ? '' : img_warning().' ').(ini_get('session.use_only_cookies') ? ini_get('session.use_only_cookies') : yn(0)).'   ('.$langs->trans("RecommendedValueIs", '1').")
\n"; +print "PHP session.cookie_httponly = ".(ini_get('session.cookie_httponly') ? '' : img_warning().' ').(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').'   ('.$langs->trans("RecommendedValueIs", '1').")
\n"; print "PHP session.cookie_samesite = ".(ini_get('session.cookie_samesite') ? ini_get('session.cookie_samesite') : 'None'); if (!ini_get('session.cookie_samesite') || ini_get('session.cookie_samesite') == 'Lax') { print '   ('.$langs->trans("RecommendedValueIs", 'Lax').")"; From e07008f6e9d9020a42b5058b0d6fcc993d82853e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 09:40:54 +0100 Subject: [PATCH 055/576] Fix tooltip --- htdocs/core/lib/admin.lib.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 1122d434498..e51e3147519 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -650,8 +650,9 @@ function modules_prepare_head($nbofactivatedmodules, $nboftotalmodules) $mode = empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common'; $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$mode; if ($nbofactivatedmodules <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only minimal initial modules enabled) - $head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc); - $head[$h][1] .= img_warning($langs->trans("YouMustEnableOneModule")); + //$head[$h][1] = $form->textwithpicto($langs->trans("AvailableModules"), $desc); + $head[$h][1] = $langs->trans("AvailableModules"); + $head[$h][1] .= $form->textwithpicto('', $langs->trans("YouMustEnableOneModule").'.

'.$desc.'', 1, warning); } else { //$head[$h][1] = $langs->trans("AvailableModules").$form->textwithpicto(''.$nbofactivatedmodules.' / '.$nboftotalmodules.'', $desc, 1, 'help', '', 1, 3); $head[$h][1] = $langs->trans("AvailableModules").''.$nbofactivatedmodules.' / '.$nboftotalmodules.''; From 0c54723185aba8d0e4ea56f599e48077ed56fc79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 10:28:37 +0100 Subject: [PATCH 056/576] css --- htdocs/admin/modules.php | 15 ++++++++++++--- htdocs/langs/en_US/admin.lang | 2 ++ htdocs/theme/eldy/global.inc.php | 10 ++++++++-- htdocs/theme/md/btn.inc.php | 5 +---- htdocs/theme/md/style.css.php | 20 +++++++++++++++++++- htdocs/user/card.php | 8 ++++---- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index a45154d72d4..4a6c04fb3ec 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -303,7 +303,7 @@ llxHeader('', $langs->trans("Setup"), $help_url, '', '', '', $morejs, $morecss, // Search modules dirs $modulesdir = dolGetModulesDirs(); -$arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']'); +$arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("NativeModules"), 'external'=>$langs->transnoentitiesnoconv("External").' - ['.$langs->trans("AllPublishers").']'); $arrayofwarnings = array(); // Array of warning each module want to show when activated $arrayofwarningsext = array(); // Array of warning each module want to show when we activate an external module $filename = array(); @@ -564,7 +564,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= '
'; $moreforfilter .= ''; $moreforfilter .= ' '; - $moreforfilter .= ''; + $moreforfilter .= ''; $moreforfilter .= '
'; $moreforfilter .= ''; @@ -597,6 +597,9 @@ if ($mode == 'common' || $mode == 'commonkanban') { $oldfamily = ''; $foundoneexternalmodulewithupdate = 0; $linenum = 0; + $atleastonequalified = 0; + $atleastoneforfamily = 0; + foreach ($orders as $key => $value) { $linenum++; $tab = explode('_', $value); @@ -685,7 +688,9 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } - // Load all lang files of module + $atleastonequalified++; + + // Load all language files of the qualified module if (isset($objMod->langfiles) && is_array($objMod->langfiles)) { foreach ($objMod->langfiles as $domain) { $langs->load($domain); @@ -972,6 +977,10 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } + if (!$atleastonequalified) { + print '
'.$langs->trans("NoDeployedModulesFoundWithThisSearchCriteria").'

'; + } + print dol_get_fiche_end(); print '
'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 4601f2c15b9..c258df38441 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2211,3 +2211,5 @@ IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, yo IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax PDF_USE_1A=Generate PDF with PDF/A-1b format MissingTranslationForConfKey = Missing translation for %s +NativeModules=Native modules +NoDeployedModulesFoundWithThisSearchCriteria=No modules found for these search criteria \ No newline at end of file diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 218d2a20be0..1b924cf427f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -505,7 +505,8 @@ div#moretabsList, div#moretabsListaction { hr { border: 0; border-top: 1px solid #ccc; } .tabBar hr { margin-top: 20px; margin-bottom: 17px; } -.button:not(.bordertransp):not(.buttonpayment), .buttonDelete:not(.bordertransp):not(.buttonpayment) { +.button:not(.bordertransp):not(.buttonpayment), +.buttonDelete:not(.bordertransp):not(.buttonpayment) { margin-bottom: 3px; margin-top: 3px; margin-left: 5px; @@ -3297,9 +3298,14 @@ input.button[name="upload"] { padding: 5px !important; font-size: 0.9em; } -input.button.smallpaddingimp { +input.button.smallpaddingimp, input.buttonreset.smallpaddingimp { font-size: 0.8em; } +input.buttonreset { + margin-top: 3px; + margin-bottom: 3px; + padding: 8px 15px; +} .nopaddingleft { padding-: 0px; } diff --git a/htdocs/theme/md/btn.inc.php b/htdocs/theme/md/btn.inc.php index 136af6b273e..0269bba74f2 100644 --- a/htdocs/theme/md/btn.inc.php +++ b/htdocs/theme/md/btn.inc.php @@ -44,10 +44,6 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { /* ============================================================================== */ -/*div.divButAction { - margin-bottom: 1.4em; -}*/ - div.tabsAction > a.butAction, div.tabsAction > a.butActionRefused, div.tabsAction > a.butActionDelete, div.tabsAction > span.butAction, div.tabsAction > span.butActionRefused, div.tabsAction > span.butActionDelete, div.tabsAction > div.divButAction > span.butAction, @@ -82,6 +78,7 @@ span.butAction, span.butActionDelete { text-decoration: none; text-transform: uppercase; font-weight: bold; + line-height: 1.8em; margin: 0em em; padding: 0.6em em; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 331c6add932..13b03bb5642 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -438,6 +438,24 @@ input, select { margin-bottom:1px; margin-top:1px; } +#mainbody input.button:not(.buttongen):not(.bordertransp), #mainbody a.button:not(.buttongen):not(.bordertransp) { + background: var(--butactionbg); + color: #FFF !important; + border-radius: 3px; + border-collapse: collapse; + border: none; + text-shadow: none; + text-transform: uppercase; + font-weight: bold; + margin: 0em 0.9em; + padding: 0.6em 0.7em; + line-height: 17px; +} +#mainbody input.button:not(.buttongen):not(.bordertransp):hover, #mainbody a.button:not(.buttongen):not(.bordertransp):hover { + -webkit-box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); + box-shadow: 0px 0px 6px 1px rgb(50 50 50 / 40%), 0px 0px 0px rgb(60 60 60 / 10%); +} + input.button.massactionconfirmed { margin: 4px; } @@ -4366,7 +4384,7 @@ div.boximport { .fieldrequired { font-weight: bold; color: #000055; } -.widthpictotitle { width: 40px; font-size: 1.4em; text-align: ; } +.widthpictotitle { width: 32px; font-size: 1.4em; text-align: ; } table.titlemodulehelp tr td img.widthpictotitle { width: 80px; } .dolgraphtitle { margin-top: 6px; margin-bottom: 4px; } diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6acc4701c90..cb46a33f594 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -370,8 +370,7 @@ if (empty($reshook)) { } if ($result > 0) { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); - exit; + $action = ''; } else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -1946,6 +1945,7 @@ if ($action == 'create' || $action == 'adduserldap') { print '
'."\n"; print ''; print ''; + print ''; } print ''."\n"; @@ -1955,7 +1955,7 @@ if ($action == 'create' || $action == 'adduserldap') { print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); print '   '; print ''; - print ''; + print ''; } print ''."\n"; @@ -1972,7 +1972,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; @@ -488,7 +488,7 @@ if ($object->id > 0) { dol_print_error($db, $object->error); } if ($amount_discount > 0) { - print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; } //else print $langs->trans("DiscountNone"); print ''; diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index b2900e65575..cdd8fefc4b0 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2021 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,18 +38,30 @@ if ($user->socid > 0) { } $backtopage = GETPOST('backtopage', 'alpha'); +$cancel = GETPOST('cancel', 'aplha'); +$action = GETPOST('action', 'aZ09'); + +// Security check +if ($user->socid > 0) { + $id = $user->socid; +} +$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); /* * Actions */ -if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { - header("Location: ".$backtopage); - exit; +if ($cancel) { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } else { + $action = ''; + } } -if (GETPOST('action', 'aZ09') == 'setremise') { +if ($action == 'setremise') { $object = new Societe($db); $object->fetch($id); @@ -74,11 +86,6 @@ if (GETPOST('action', 'aZ09') == 'setremise') { } } -// Security check -if ($user->socid > 0) { - $id = $user->socid; -} -$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); /* diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 38e1967c11b..4373f09fdb7 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -40,8 +40,8 @@ if (!isset($absolute_creditnote)) { } // Relative and absolute discounts -$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; -$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; +$addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; +$addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; $viewabsolutediscount = ''.$langs->trans("ViewAvailableGlobalDiscounts").''; $fixedDiscount = $thirdparty->remise_percent; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 16e89850ae4..fd3ec1fa34f 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -297,7 +297,7 @@ if ($object->id > 0) { print $langs->trans("CustomerRelativeDiscountShort"); print '
'; if ($caneditgroup) { - print ''; + print ''; print img_picto($langs->trans("RemoveFromGroup"), 'unlink'); print ''; } else { From 4cfec658bc1eb81e6f9d142dccac397c8afc82f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 14:11:18 +0100 Subject: [PATCH 057/576] css --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index e8dc79951f7..a4953cbf475 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -818,7 +818,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print '
'; print '
'; - print ''; + print '
'; // Description print '
'.$langs->trans("Description").''; From 78f94b1c76598a7fc2e46373aedf103048ae4327 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 14:17:20 +0100 Subject: [PATCH 058/576] Fix css and label for recurring invoices --- htdocs/compta/facture/card-rec.php | 4 ++-- htdocs/compta/facture/invoicetemplate_list.php | 5 +++-- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/langs/en_US/bills.lang | 1 + htdocs/projet/tasks/time.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index ced6ea152e4..b15599cc931 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -1066,7 +1066,7 @@ if ($action == 'create') { // Autogeneration $title = $langs->trans("Recurrence"); - print load_fiche_titre(' '.$title, '', ''); + print load_fiche_titre(img_picto('', 'recurring', 'class="pictofixedwidth"').$title, '', ''); print dol_get_fiche_head(null, '', '', 0); @@ -1457,7 +1457,7 @@ if ($action == 'create') { print ''; - print ''; + print ''; // if "frequency" is empty or = 0, the reccurence is disabled print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 869aa2343bc..03366e9bae1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3604,7 +3604,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'salary', 'shipment', 'state', 'supplier_invoice', 'supplier_invoicea', 'supplier_invoicer', 'supplier_invoiced', 'technic', 'ticket', 'error', 'warning', - 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', + 'recent', 'reception', 'recruitmentcandidature', 'recruitmentjobposition', 'resource', 'recurring', 'shapes', 'supplier', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda', 'uncheck', 'user-cog', 'website', 'workstation', @@ -3650,7 +3650,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'partnership'=>'handshake', 'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell', 'recent' => 'question', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', - 'refresh'=>'redo', 'region'=>'map-marked', 'resource'=>'laptop-house', + 'refresh'=>'redo', 'region'=>'map-marked', 'resource'=>'laptop-house', 'recurring'=>'history', 'state'=>'map-marked-alt', 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier'=>'building', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 6078942f574..68e01da9cf2 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -271,6 +271,7 @@ SetMode=Set Payment Type SetRevenuStamp=Set revenue stamp Billed=Billed RecurringInvoices=Recurring invoices +RecurringInvoice=Recurring invoice RepeatableInvoice=Template invoice RepeatableInvoices=Template invoices Repeatable=Template diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 9e27f026c9d..3c0fbecc7b0 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -729,7 +729,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) { print '
'; print '
'; - print '
'.$title.'
'.img_picto('', 'recurring', 'class="pictofixedwidth"').$title.'
'; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index d099bfd57bc..33c9228327f 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -131,7 +131,7 @@ $arrayfields = array( 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>1), 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>0), 'f.fk_cond_reglement'=>array('label'=>"PaymentTerm", 'checked'=>0), - 'recurring'=>array('label'=>"RecurringInvoiceTemplate", 'checked'=>1), + 'recurring'=>array('label'=>"RecurringInvoice", 'checked'=>1), 'f.frequency'=>array('label'=>"Frequency", 'checked'=>1), 'f.unit_frequency'=>array('label'=>"FrequencyUnit", 'checked'=>1), 'f.nb_gen_done'=>array('label'=>"NbOfGenerationDoneShort", 'checked'=>1), @@ -723,8 +723,9 @@ if ($resql) { $totalarray['nbfield']++; } } + // Is it a recurring invoice if (!empty($arrayfields['recurring']['checked'])) { - print ''.yn($objp->frequency ? 1 : 0).''.($objp->frequency ? img_picto($langs->trans("Frequency").': '.$objp->frequency.' '.$objp->unit_frequency, 'recurring', 'class="opacitymedium"').' ' : '').yn($objp->frequency ? 1 : 0).'
'; + print '
'; // Description print '
'.$langs->trans("Description").''; From 971c892d9888ff62e42908163b368b36f9176ce1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 14:20:31 +0100 Subject: [PATCH 059/576] Fix filter on recurrig field --- htdocs/compta/facture/invoicetemplate_list.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 33c9228327f..8c46f8df59a 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -329,7 +329,11 @@ if ($search_status != '' && $search_status >= -1) { $sql .= dolSqlDateFilter('f.date_last_gen', $search_day, $search_month, $search_year); $sql .= dolSqlDateFilter('f.date_when', $search_day_date_when, $search_month_date_when, $search_year_date_when); -$sql .= $db->order($sortfield, $sortorder); +$tmpsortfield = $sortfield; +if ($tmpsortfield == 'recurring') { + $tmpsortfield = 'f.frequency'; +} +$sql .= $db->order($tmpsortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { From f66f3e73554f8678adc1a80981e42ee7aa3c019d Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Thu, 25 Nov 2021 15:25:17 +0100 Subject: [PATCH 060/576] FIX #19476 --- htdocs/ticket/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 16fdaf315f1..ab2c2794e38 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -568,7 +568,7 @@ if (empty($reshook)) { if ($ret > 0) { $log_action = $langs->trans('TicketInitialMessageModified')." \n"; // include the Diff class - dol_include_once('/ticket/class/utils_diff.class.php'); + dol_include_once('/core/class/utils_diff.class.php'); // output the result of comparing two files as plain text $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); From 9d2fb782fafb8207f56204f0dda5efbf3ead0ceb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 25 Nov 2021 15:41:28 +0100 Subject: [PATCH 061/576] FIX Option MAIN_DIRECT_STATUS_UPDATE broken. Ajax on/off not saving value in DB after updating to version >=12 --- htdocs/core/ajax/objectonoff.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index f7bf1d6299c..20256da94d7 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -80,5 +80,9 @@ if (($action == 'set') && !empty($id)) { $format = 'int'; + $object->table_element = $tablename; + $object->id = $id; + $object->fields[$field] = array('type' => $format, 'enabled' => 1); + $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); } From 6e68eaaef4e7e6bb1062dede5e46f60ca789c882 Mon Sep 17 00:00:00 2001 From: "moreauf@theobald-groupe.com" Date: Thu, 25 Nov 2021 16:36:18 +0100 Subject: [PATCH 062/576] card Modif --- htdocs/product/stock/movement_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ebf655c77e5..b46eb9e0112 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -459,7 +459,7 @@ if ($action == "transfert_stock" && !$cancel) { } } } -}m.lalanne +} /* From 77505c570ff53770225fbde599ed251b793821a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 16:48:55 +0100 Subject: [PATCH 063/576] Avoid to commit external module --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 371c8be2f5e..e4790fe7b4e 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,4 @@ yarn.lock package-lock.json doc/install.lock +/factory/ From 312a741b80cd78d120ff6145e70ed7a782c8b579 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 21:42:42 +0100 Subject: [PATCH 064/576] Fix closing div --- htdocs/ticket/card.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 76d16aa53b6..16ef0f7bd77 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -854,6 +854,7 @@ if ($action == 'create' || $action == 'presend') { //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($projectstat); + print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); /* @@ -902,7 +903,7 @@ if ($action == 'create' || $action == 'presend') { print "
"; - print ''; + print dol_get_fiche_end(); } else { print "ErrorRecordNotFound"; } @@ -1178,6 +1179,8 @@ if ($action == 'create' || $action == 'presend') { } print '
'; + + print '
'; } From 198c5301792e9f87c43c7704086a990f516286c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 25 Nov 2021 21:51:07 +0100 Subject: [PATCH 065/576] Fix syntax error --- htdocs/product/stock/movement_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index ebf655c77e5..b46eb9e0112 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -459,7 +459,7 @@ if ($action == "transfert_stock" && !$cancel) { } } } -}m.lalanne +} /* From 419eaa217fad255c53b2e7352841a612d02cc020 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 26 Nov 2021 12:38:09 +0100 Subject: [PATCH 066/576] dejar igual que 13 --- htdocs/core/modules/modAdherent.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index a047d14371c..a3d9f7a5323 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -339,7 +339,7 @@ class modAdherent extends DolibarrModules 'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription' ); // Add extra fields - $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type != 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE type <> 'separate' AND elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; $resql = $this->db->query($sql); if ($resql) // This can fail when class is used on old database (during migration for example) { From 5265cd808415ccab398347fbe8b00b4777214c9c Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Fri, 26 Nov 2021 12:49:07 +0100 Subject: [PATCH 067/576] Fix: correctly display the products of a warehouse in the pdf --- .../stock/doc/pdf_standard.modules.php | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 55923d68a79..519da28a3b5 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -289,8 +289,8 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 80 + $top_shift; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_top = 65 + $top_shift; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 + $top_shift : 10); $tab_height = 130; @@ -323,7 +323,7 @@ class pdf_standard extends ModelePDFStock $i = 0; $nblines = $num; - $this->tabTitleHeight = 0; + $this->tabTitleHeight = 10; $nexY = $tab_top + $this->tabTitleHeight; for ($i = 0; $i < $nblines; $i++) @@ -362,7 +362,8 @@ class pdf_standard extends ModelePDFStock $showpricebeforepagebreak = 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 3, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -370,7 +371,8 @@ class pdf_standard extends ModelePDFStock $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); + $pdf->writeHTMLCell($this->wref, 4, $curX, $curY, $outputlangs->convToOutputCharset($objp->ref), 0, 1, false, true, 'J', true); + //pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text @@ -418,8 +420,8 @@ class pdf_standard extends ModelePDFStock $productstatic->status_batch = $objp->tobatch; // Ref. - $pdf->SetXY($this->posxdesc, $curY); - $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); + //$pdf->SetXY($this->posxdesc, $curY); + //$pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); // Label $pdf->SetXY($this->posxlabel + 0.8, $curY); @@ -506,7 +508,7 @@ class pdf_standard extends ModelePDFStock /** * Footer table */ - $nexY = $pdf->GetY(); + //$nexY = $pdf->GetY(); $nexY += 2; $curY = $nexY; @@ -572,11 +574,11 @@ class pdf_standard extends ModelePDFStock $height_note = 0; } - $iniY = $tab_top + 7; + /*$iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - $tab_top = $tab_top_newpage + 25 + $top_shift; + $tab_top = $tab_top_newpage + 25 + $top_shift;*/ // Show square if ($pagenb == 1) @@ -732,10 +734,12 @@ class pdf_standard extends ModelePDFStock $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R'); } - $pdf->SetDrawColor(200, 200, 200); - $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200))); - $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11); - $pdf->SetLineStyle(array('dash'=>0)); + if (empty($hidetop)) { + $pdf->SetDrawColor(200, 200, 200); + $pdf->SetLineStyle(array('dash' => '0', 'color' => array(200, 200, 200))); + $pdf->line($this->marge_gauche, $tab_top + 10, $this->page_largeur - $this->marge_droite, $tab_top + 10); + $pdf->SetLineStyle(array('dash' => 0)); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From ad8b071e817f1fa2cab758ea96c47f2dfc470315 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Nov 2021 14:13:29 +0100 Subject: [PATCH 068/576] Prepare code --- htdocs/admin/tools/export_files.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index ec2ad4a815a..7c96d487288 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -179,9 +179,9 @@ if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); } -// Redirect t backup page -header("Location: dolibarr_export.php"); - -$time_end = time(); +// Redirect to calling page +$returnto = 'dolibarr_export.php'; $db->close(); + +header("Location: ".$returnto); From 4548b4fcee8ace070bd49e1e57ded14dddc19673 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Nov 2021 17:09:07 +0100 Subject: [PATCH 069/576] css --- htdocs/admin/tools/dolibarr_export.php | 6 +++--- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 0785b6a91cb..e95d93ddf86 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -160,7 +160,7 @@ $title = $langs->trans("BackupDumpWizard"); print load_fiche_titre($title); -print ''; +print '
'; print ''; print ' - + '; +print ''; + +print ''; + // Desc print '"; + $counter = ""; } $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index eeca990ef28..a1f63b997e8 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -378,7 +378,7 @@ if ($cats < 0) { ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" : $categstatic->getObjectsInCateg($type, 1); - $counter = ""; + $counter = ""; } $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e8a8eb2843e..85987c8a3cf 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -860,7 +860,7 @@ abstract class CommonObject if (!empty($conf->socialnetworks->enabled)) { $outsocialnetwork = ''; - if (!empty($this->socialnetworks) && is_countable($this->socialnetworks) && count($this->socialnetworks) > 0) { + if (!empty($this->socialnetworks) && is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { $socialnetworksdict = getArrayOfSocialNetworks(); foreach ($this->socialnetworks as $key => $value) { if ($value) { From 2ba5f1369fe1e37a434835f055b6e0df4bfec229 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:53:55 +0100 Subject: [PATCH 102/576] Fix alternate --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f40c21778f5..0e192ff0212 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2366,7 +2366,7 @@ if ($action == 'generatesitemaps' && $usercanedit) { } if ($tmpshortlangcode != $shortlangcode) { $xhtmllink = $domtree->createElement('xhtml:link', ''); - $xhtmllink->setAttribute("rel", "alternante"); + $xhtmllink->setAttribute("rel", "alternate"); $xhtmllink->setAttribute("hreflang", $tmpshortlangcode); $xhtmllink->setAttribute("href", $domainname.($objp->fk_default_home == $tmppage->id ? '/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ? '/'.$tmpshortlangcode : '').'/'.$tmppage->pageurl.'.php')); $url->appendChild($xhtmllink); From 36eb79c14d49469deb17fbc03b7bffc6557a599d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 16:49:13 +0100 Subject: [PATCH 103/576] Fix filter on "Refuse emailing" --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index dc8c77d0e1e..695d4ead3cc 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -76,7 +76,7 @@ $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); $search_fax = GETPOST("search_fax", 'alpha'); $search_email = GETPOST("search_email", 'alpha'); if (!empty($conf->mailing->enabled)) { - $search_no_email = GETPOST("search_no_email", 'int'); + $search_no_email = GETPOSTISSET("search_no_email") ? GETPOST("search_no_email", 'int') : -1; } else { $search_no_email = -1; } From 2d92130c1ebe8331f9f24a80f7af0b480def138f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 19:25:58 +0100 Subject: [PATCH 104/576] External backups can be downloaded from the "About info page". --- ChangeLog | 1 + htdocs/admin/modulehelp.php | 7 ++++ htdocs/admin/tools/export_files.php | 56 +++++++++++++++++++++++------ htdocs/compta/accounting-files.php | 2 +- htdocs/conf/conf.php.example | 6 ++++ htdocs/core/lib/files.lib.php | 25 +++++++++---- 6 files changed, 79 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 059fc0d145c..4ba65941254 100644 --- a/ChangeLog +++ b/ChangeLog @@ -105,6 +105,7 @@ NEW: Use an ajax call for the clicktodial feature instead of href link. NEW: when multiple order linked to facture, show list into note. NEW: when we delete several objects with massaction, if somes object has child we must see which objects are concerned and nevertheless delete objects which can be deleted NEW: Editing a page in website module keep old page with name .back +NEW: External backups can be downloaded from the "About info page". For developers: diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index a3c7c3d5c08..4122e2b56ed 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -326,6 +326,13 @@ if ($mode == 'desc') { $textexternal = ''; if ($objMod->isCoreOrExternalModule() == 'external') { $textexternal .= '
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule").' - '.$langs->trans("InstalledInto", $dirofmodule); + + global $dolibarr_allow_download_external_modules; + if (!empty($dolibarr_allow_download_external_modules) && preg_match('/\/custom\//', $dirofmodule)) { + // Add a link to download a zip of the module + $textexternal .= ' '.img_picto('', 'download').''; + } + if ($objMod->editor_name != 'dolibarr') { $textexternal .= '
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name) ? $langs->trans("Unknown") : $objMod->editor_name); } diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index ff4b12efc9e..0b9272c2418 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -138,7 +138,23 @@ $dirtocompress = basename($fulldirtocompress); if ($compression == 'zip') { $file .= '.zip'; $excludefiles = '/(\.back|\.old|\.log|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i'; - $ret = dol_compress_dir($fulldirtocompress, $outputdir."/".$file, $compression, $excludefiles); + + //var_dump($fulldirtocompress); + //var_dump($outputdir."/".$file);exit; + + $rootdirinzip = ''; + if ($export_type == 'externalmodule' && !empty($what)) { + $rootdirinzip = $what; + + global $dolibarr_allow_download_external_modules; + if (empty($dolibarr_allow_download_external_modules)) { + print 'Download of external modules is not allowed by $dolibarr_allow_download_external_modules in conf.php file'; + $db->close(); + exit(); + } + } + + $ret = dol_compress_dir($fulldirtocompress, $outputdir."/".$file, $compression, $excludefiles, $rootdirinzip); if ($ret < 0) { if ($ret == -2) { $langs->load("errors"); @@ -183,17 +199,37 @@ if ($compression == 'zip') { unlink($outputdir."/".$file); } } -} - -if ($errormsg) { - setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); } else { - setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); + $errormsg = 'Bad value for compression method'; + print $errormsg; } -$db->close(); +if ($export_type != 'externalmodule' || empty($what)) { + if ($errormsg) { + setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); + } else { + setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); + } -// Redirect to calling page -$returnto = 'dolibarr_export.php'; + $db->close(); -header("Location: ".$returnto); + // Redirect to calling page + $returnto = 'dolibarr_export.php'; + + header("Location: ".$returnto); + exit(); +} else { + $zipname = $outputdir."/".$file; + + // Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.basename($zipname)); + header('Content-Length: '.filesize($zipname)); + readfile($zipname); + + dol_delete_file($zipname); + + $db->close(); + + exit(); +} diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 855505a40ec..1f821bf733b 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -499,7 +499,7 @@ if ($result && $action == "dl" && !$error) { $zip->addFromString('transactions.csv', $log); $zip->close(); - ///Then download the zipped file. + // Then download the zipped file. header('Content-Type: application/zip'); header('Content-disposition: attachment; filename='.basename($zipname)); header('Content-Length: '.filesize($zipname)); diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 71f0a82e32f..7bb58d6b701 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -331,6 +331,12 @@ $dolibarr_cron_allow_cli='0'; // Examples: // $dolibarr_strict_mode=0; +// dolibarr_allow_download_external_modules +// Provide a link to download the zip of an external modules installed into custom directory from the web admin. +// Default value: 0 +// Examples: +// $dolibarr_allow_download_external_modules=0; + //################################# diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 2bd4ada3ad0..7312faf6b5e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2004,11 +2004,15 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file - $filePath = $file->getRealPath(); - $relativePath = substr($filePath, strlen($rootPath) + 1); + $filePath = $file->getPath(); // the full path with filename using the $inputdir root. + $fileName = $file->getFilename(); + $fileFullRealPath = $file->getRealPath(); // the full path with name and transformed to use real path directory. + + //$relativePath = substr($fileFullRealPath, strlen($rootPath) + 1); + $relativePath = substr(($filePath ? $filePath.'/' : '').$fileName, strlen($rootPath) + 1); // Add current file to archive - $zip->addFile($filePath, $relativePath); + $zip->addFile($fileFullRealPath, $relativePath); } } @@ -2196,22 +2200,29 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = } // Create recursive directory iterator + // This does not return symbolic links /** @var SplFileInfo[] $files */ $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($inputdir), RecursiveIteratorIterator::LEAVES_ONLY ); + //var_dump($inputdir); foreach ($files as $name => $file) { // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file - $filePath = $file->getRealPath(); - $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($filePath, strlen($inputdir) + 1); + $filePath = $file->getPath(); // the full path with filename using the $inputdir root. + $fileName = $file->getFilename(); + $fileFullRealPath = $file->getRealPath(); // the full path with name and transformed to use real path directory. - if (empty($excludefiles) || !preg_match($excludefiles, $filePath)) { + //$relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr($fileFullRealPath, strlen($inputdir) + 1); + $relativePath = ($rootdirinzip ? $rootdirinzip.'/' : '').substr(($filePath ? $filePath.'/' : '').$fileName, strlen($inputdir) + 1); + + //var_dump($filePath);var_dump($fileFullRealPath);var_dump($relativePath); + if (empty($excludefiles) || !preg_match($excludefiles, $fileFullRealPath)) { // Add current file to archive - $zip->addFile($filePath, $relativePath); + $zip->addFile($fileFullRealPath, $relativePath); } } } From 5473dbd3f055ea10e218d60b3dd3928912172b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 28 Nov 2021 20:55:17 +0100 Subject: [PATCH 105/576] add direct print for contracts --- htdocs/contrat/card.php | 2 ++ htdocs/core/class/html.formfile.class.php | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 31405545dbb..c52b57e305f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -916,6 +916,8 @@ if (empty($reshook)) { } } + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to build doc $upload_dir = $conf->contrat->multidir_output[$object->entity]; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 7f141d684b7..e30f35758d1 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -442,7 +442,8 @@ class FormFile } $printer = 0; - if (in_array($modulepart, array('facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) { // The direct print feature is implemented only for such elements + // The direct print feature is implemented only for such elements + if (in_array($modulepart, array('contract', 'facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) { $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?true:false; } @@ -944,7 +945,7 @@ class FormFile $out .= '">'.img_picto($langs->trans("Delete"), 'delete').''; } if ($printer) { - $out .= ''.img_picto($langs->trans("PrintFile", $relativepath), 'printer.png').''; } From 81e74839113e5932e4040242d10936409c98ceb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 23:51:20 +0100 Subject: [PATCH 106/576] css --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index c543b9edd9b..c2cbc6de76b 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -429,7 +429,7 @@ if ($action == 'create') { print '
'; print ''; // Tags-Categories From bb38ea79f492a4aa88290f8587f7928ab25d094b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 00:05:42 +0100 Subject: [PATCH 107/576] css --- htdocs/theme/eldy/global.inc.php | 1 + htdocs/theme/md/style.css.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 1c8891202a7..37692f46c1e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1681,6 +1681,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select div.statusref { padding-right: 10px; + max-width: 55%; } div.statusref img { padding-right: 3px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index cbd8b4bb7fb..3118b576e1e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1744,6 +1744,7 @@ select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-select div.statusref { padding-right: 10px; + max-width: 55%; } div.statusref img { padding-right: 3px !important; From 186185267e7a0ee4c4f2dae7446a1606892bd26e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 00:49:18 +0100 Subject: [PATCH 108/576] Clean code for v15 --- htdocs/accountancy/admin/fiscalyear.php | 1 - htdocs/adherents/cartes/carte.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/extrafields.class.php | 139 +----------------- .../core/tpl/admin_extrafields_view.tpl.php | 2 +- ...terface_50_modTicket_TicketEmail.class.php | 2 +- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/hrm/admin/admin_establishment.php | 1 - htdocs/product/fournisseurs.php | 2 +- htdocs/public/ticket/create_ticket.php | 2 +- htdocs/public/ticket/list.php | 2 +- 11 files changed, 14 insertions(+), 143 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index 44c5309f531..2eb77815b60 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -127,7 +127,6 @@ if ($result) { $title = $langs->trans('AccountingPeriods'); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $addbutton, '', $limit, 1); - // Load attribute_label print '
'; print '
'; print $langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.'
'; @@ -569,7 +569,7 @@ print '
'; print load_fiche_titre($title ? $title : $langs->trans("BackupZipWizard")); -print '
'; +print '
'; $prefix = 'documents'; $ext = 'zip'; $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M"); @@ -617,7 +617,7 @@ print '
'; print ''; -print '
'; +print '
'; $filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); $result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles")); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 1b924cf427f..ba25200c674 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -608,6 +608,9 @@ button:focus { .fa-info-circle { padding-: 3px; } +.line-height-large { + line-height: 1.8em; +} th .button { -webkit-box-shadow: none !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 13b03bb5642..cbc06c26838 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -783,6 +783,9 @@ div.floatright button:focus { outline: none; } +.line-height-large { + line-height: 1.8em; +} th .button { -webkit-box-shadow: none !important; From f67c2e5b53937f6a286282a9d67167f55392e3e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 26 Nov 2021 17:20:11 +0100 Subject: [PATCH 070/576] Removed useless button --- htdocs/admin/modules.php | 6 ++++-- htdocs/theme/eldy/global.inc.php | 3 +++ htdocs/theme/md/style.css.php | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index fc54fbaf575..097d125708f 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -563,8 +563,10 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= ' '; $moreforfilter .= '
'; $moreforfilter .= ''; - $moreforfilter .= ' '; - $moreforfilter .= ''; + if ($search_keyword || $search_status || $search_nature || $search_version) { + $moreforfilter .= ' '; + $moreforfilter .= ''; + } $moreforfilter .= '
'; $moreforfilter .= '
'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index ba25200c674..d4754f444d5 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3308,6 +3308,9 @@ input.buttonreset { margin-top: 3px; margin-bottom: 3px; padding: 8px 15px; + text-decoration: underline; + color: var(--colortextlink); + cursor: pointer; } .nopaddingleft { padding-: 0px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index cbc06c26838..5870307123d 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3366,6 +3366,14 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd .smallpaddingimp { padding: 4px !important; } +input.buttonreset { + margin-top: 3px; + margin-bottom: 3px; + padding: 8px 15px; + text-decoration: underline; + color: var(--colortextlink); + cursor: pointer; +} .notopnoleft { border-collapse: collapse; From 1361abffe515722631dafbfba68ff0c20f553a10 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:22:31 +0100 Subject: [PATCH 071/576] FIX: holiday list: only mass delete if leave request is not in draft, canceled or refused, like in card --- htdocs/core/actions_massactions.inc.php | 6 ++++++ htdocs/langs/en_US/holiday.lang | 1 + 2 files changed, 7 insertions(+) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index abcdd690d5c..0c84b2d3781 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1280,6 +1280,12 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' continue; } + if ($objectclass == 'Holiday' && ! in_array($objecttmp->statut, array(Holiday::STATUS_DRAFT, Holiday::STATUS_CANCELED, Holiday::STATUS_REFUSED))) { + $nbignored++; + setEventMessage($langs->trans('ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted', $objecttmp->ref)); + continue; + } + if ($objectclass == "Task" && $objecttmp->hasChildren() > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task SET fk_task_parent = 0 WHERE fk_task_parent = ".$objecttmp->id; diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index eb2cd89adf1..ef96e72cc9d 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays +ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted From f5343c55c39791f4351afedc6669bf7483db6957 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:23:31 +0100 Subject: [PATCH 072/576] FIX: holiday mass deletion: correct return of record deleted --- htdocs/core/actions_massactions.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 0c84b2d3781..2ce94cad8ed 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1320,7 +1320,8 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if (!$error) { if ($nbok > 1) setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs'); - else setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + elseif ($nbok > 0) setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs'); $db->commit(); } else From dd953b6e5a684b9430990c6ce192064c5355d55e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 01:09:16 +0100 Subject: [PATCH 073/576] Fix filter --- htdocs/projet/list.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 444dc6d525f..4078afb20c0 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -751,6 +751,9 @@ $url = DOL_URL_ROOT.'/projet/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.$socid; } +if ($search_usage_event_organization == 1) { + $url .= '&usage_organize_event=1'; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewProject'), '', 'fa fa-plus-circle', $url, '', $user->rights->projet->creer); print ''; From 654e20e9fb9044e761b2e49eb119178923f9a3f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 01:11:59 +0100 Subject: [PATCH 074/576] CSS --- htdocs/contrat/tpl/linkedobjectblock.tpl.php | 2 +- htdocs/fourn/facture/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index fad5b67cf27..cdbda7a17b8 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?>
trans("Contract"); ?>getNomUrl(1); ?>getNomUrl(1); ?> date_contrat, 'day'); ?> '; if (!empty($arrayfields['f.ref']['checked'])) { - print ''; + print ''; print ''; // Picto + Ref From 7cc93986614cc4b06a6b12f5e5b72dc353fa9e7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 01:24:32 +0100 Subject: [PATCH 075/576] css --- htdocs/fourn/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index c05799bf5d2..e29b928140e 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -936,7 +936,7 @@ if ($resql) { $moreforfilter .= '
'; $tmptitle = $langs->trans('IncludingProductWithTag'); $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); - $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); $moreforfilter .= '
'; } @@ -1371,7 +1371,7 @@ if ($resql) { print '
'; // Picto + Ref - print ''; -print '
'; + print ''; print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); $filename = dol_sanitizeFileName($obj->ref); From 57670108bfa76d0cc18b6a08c083a0f56075c03c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 10:57:45 +0100 Subject: [PATCH 076/576] Prepare code to zip a module --- htdocs/admin/tools/dolibarr_export.php | 3 ++- htdocs/admin/tools/export.php | 3 +-- htdocs/admin/tools/export_files.php | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index e95d93ddf86..1eb19b2d0ff 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -145,6 +145,8 @@ print "\n"; print ''; print ''; print ''; +print ''; + print '
1'; print ''; @@ -498,7 +500,6 @@ print " \n"; print '
'; print '
'; print ''; -print ''; print '
'; print '
'; diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index c8a2a02498c..d21622d1f68 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -216,8 +216,7 @@ if ($errormsg) { }*/ } +$db->close(); // Redirect to backup page header("Location: dolibarr_export.php".(GETPOST('page_y', 'int') ? '?page_y='.GETPOST('page_y', 'int') : '')); - -$db->close(); diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 7c96d487288..871added47c 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -127,10 +127,18 @@ $result = dol_mkdir($outputdir); $utils = new Utils($db); +if ($export_type == 'externalmodule' && ! empty($what)) { + $fulldirtocompress = DOL_DOCUMENT_ROOT.'/custom/'.dol_sanitizeFileName($what); +} else { + $fulldirtocompress = DOL_DATA_ROOT; +} +$dirtoswitch = dirname($fulldirtocompress); +$dirtocompress = basename($fulldirtocompress); + if ($compression == 'zip') { $file .= '.zip'; $excludefiles = '/(\.back|\.old|\.log|[\/\\\]temp[\/\\\]|documents[\/\\\]admin[\/\\\]documents[\/\\\])/i'; - $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, $excludefiles); + $ret = dol_compress_dir($fulldirtocompress, $outputdir."/".$file, $compression, $excludefiles); if ($ret < 0) { if ($ret == -2) { $langs->load("errors"); @@ -147,7 +155,7 @@ if ($compression == 'zip') { $file .= '.tar'; // We also exclude '/temp/' dir and 'documents/admin/documents' - $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dirname(DOL_DATA_ROOT)." ".basename(DOL_DATA_ROOT); + $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dol_sanitizePathName($dirtoswitch)." ".dol_sanitizeFileName($dirtocompress); $result = $utils->executeCLI($cmd, $outputfile); @@ -177,11 +185,13 @@ if ($compression == 'zip') { if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); +} else { + setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); } +$db->close(); + // Redirect to calling page $returnto = 'dolibarr_export.php'; -$db->close(); - header("Location: ".$returnto); From 6e273e47e5d9f250c5b62fa7d0a1fd68155a3f0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 12:35:30 +0100 Subject: [PATCH 077/576] css --- htdocs/admin/hrm.php | 2 +- htdocs/admin/tools/dolibarr_export.php | 19 +++++++++++-------- htdocs/core/class/utils.class.php | 1 - htdocs/theme/eldy/global.inc.php | 6 +++++- htdocs/theme/md/style.css.php | 8 ++++++-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index c006688fca1..7fc315451a8 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -571,7 +571,7 @@ if ($action == 'edit') { } else { if (!empty($arrayofparameters)) { print ''; - print ''; + print ''; foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 1eb19b2d0ff..d6700cedf04 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -162,14 +162,15 @@ $title = $langs->trans("BackupDumpWizard"); print load_fiche_titre($title); -print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print '
'; print ''; print ''; print ''; print ''; +print '
'; print $langs->trans("DatabaseName").' : '.$dolibarr_main_db_name.'
'; print '
'; -print ''; + +print '
'; print ''; print ''; print ''; print '
'; @@ -399,11 +400,15 @@ print '
'; +print '
'; + + print ''; print '
'; -print ''; +print ''; print '
'; $prefix = 'dump'; $ext = '.sql'; @@ -439,9 +444,9 @@ if (in_array($type, array('mysql', 'mysqli'))) { // 'label' => $langs->trans("FormatZip") // ); $compression['bz'] = array( - 'function' => 'bzopen', - 'id' => 'radio_compression_bzip', - 'label' => $langs->trans("Bzip2") + 'function' => 'bzopen', + 'id' => 'radio_compression_bzip', + 'label' => $langs->trans("Bzip2") ); $compression['zstd'] = array( 'function' => 'zstd_compress', @@ -533,8 +538,6 @@ if (!empty($_SESSION["commandbackuptorun"])) { print "
\n"; -print '
'; print " \n"; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index e7ab489c60d..e081c59b14b 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -636,7 +636,6 @@ class Utils $execmethod = 1; } //$execmethod=1; - dol_syslog("Utils::executeCLI execmethod=".$execmethod." system:".$command, LOG_DEBUG); $output_arr = array(); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d4754f444d5..1c8891202a7 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -486,7 +486,11 @@ input:-webkit-autofill { input:-moz-placeholder { color: #ccc; } input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; } -fieldset { border: 1px solid #AAAAAA !important; } +fieldset { + border: 1px solid #AAAAAA !important; + padding-inline-start: 2em; + padding-inline-end: 2em; +} .legendforfieldsetstep { padding-bottom: 10px; } input#onlinepaymenturl, input#directdownloadlink { opacity: 0.7; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5870307123d..b49373fd300 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -688,7 +688,11 @@ input[type=checkbox], input[type=radio] { input:-moz-placeholder { color:#ccc; } input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; } -fieldset { border: 1px solid #AAAAAA !important; } +fieldset { + border: 1px solid #AAAAAA !important; + padding-inline-start: 2em; + padding-inline-end: 2em; +} .legendforfieldsetstep { padding-bottom: 10px; } input#onlinepaymenturl, input#directdownloadlink { opacity: 0.7; @@ -1806,7 +1810,7 @@ td.showDragHandle { } #id-right { /* This must stay id-right and not be replaced with echo $right */ width: 100%; - padding-bottom: 10px; + padding-bottom: 20px; padding-left: 229px; padding-top: 16px; From f3f91512ae7fd5bc02052e2456b6f67449ff40e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 12:36:35 +0100 Subject: [PATCH 078/576] FIX eclude of log files into backup --- htdocs/admin/tools/export_files.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 871added47c..ff4b12efc9e 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -154,10 +154,12 @@ if ($compression == 'zip') { $outputfile = $conf->admin->dir_temp.'/export_files.'.$userlogin.'.out'; // File used with popen method $file .= '.tar'; - // We also exclude '/temp/' dir and 'documents/admin/documents' - $cmd = "tar -cf ".$outputdir."/".$file." --exclude-vcs --exclude 'temp' --exclude 'dolibarr.log' --exclude 'dolibarr_*.log' --exclude 'documents/admin/documents' -C ".dol_sanitizePathName($dirtoswitch)." ".dol_sanitizeFileName($dirtocompress); - $result = $utils->executeCLI($cmd, $outputfile); + // We also exclude '/temp/' dir and 'documents/admin/documents' + // We make escapement here and call executeCLI without escapement because we don't want to have the '*.log' escaped. + $cmd = "tar -cf ".escapeshellcmd($outputdir."/".$file)." --exclude-vcs --exclude-caches-all --exclude='temp' --exclude='*.log' --exclude='documents/admin/documents' -C '".escapeshellcmd(dol_sanitizePathName($dirtoswitch))."' '".escapeshellcmd(dol_sanitizeFileName($dirtocompress))."'"; + + $result = $utils->executeCLI($cmd, $outputfile, 0, null, 1); $retval = $result['error']; if ($result['result'] || !empty($retval)) { From 7b68ef1fb85e65c44b0119e097ec2890ace6520c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 14:46:47 +0100 Subject: [PATCH 079/576] Clean/Debug module hrm. --- htdocs/admin/hrm.php | 6 +++- htdocs/hrm/class/skill.class.php | 35 ++++++++++++++----- htdocs/hrm/class/skilldet.class.php | 8 ++--- htdocs/hrm/skill_agenda.php | 2 +- htdocs/hrm/skill_card.php | 26 ++++++++------ htdocs/hrm/skill_contact.php | 2 +- htdocs/hrm/skill_document.php | 2 +- htdocs/hrm/skill_note.php | 2 +- htdocs/hrm/skill_tab.php | 4 +-- .../install/mysql/migration/14.0.0-15.0.0.sql | 24 ++----------- ...key.sql => llx_hrm_evaluation-hrm.key.sql} | 0 ...luation.sql => llx_hrm_evaluation-hrm.sql} | 0 ...lx_hrm_evaluation_extrafields-hrm.key.sql} | 0 ...=> llx_hrm_evaluation_extrafields-hrm.sql} | 0 ....sql => llx_hrm_evaluationdet-hrm.key.sql} | 0 ...ndet.sql => llx_hrm_evaluationdet-hrm.sql} | 0 ...hrm_evaluationdet_extrafields-hrm.key.sql} | 0 ...llx_hrm_evaluationdet_extrafields-hrm.sql} | 0 ...rm_job.key.sql => llx_hrm_job-hrm.key.sql} | 0 .../{llx_hrm_job.sql => llx_hrm_job-hrm.sql} | 0 ...ql => llx_hrm_job_extrafields-hrm.key.sql} | 0 ...ds.sql => llx_hrm_job_extrafields-hrm.sql} | 0 ...r.key.sql => llx_hrm_job_user-hrm.key.sql} | 0 ..._job_user.sql => llx_hrm_job_user-hrm.sql} | 0 .../llx_hrm_job_user_extrafields.key.sql | 21 ----------- .../tables/llx_hrm_job_user_extrafields.sql | 25 ------------- ...kill.key.sql => llx_hrm_skill-hrm.key.sql} | 0 ...lx_hrm_skill.sql => llx_hrm_skill-hrm.sql} | 0 ... => llx_hrm_skill_extrafields-hrm.key.sql} | 0 ....sql => llx_hrm_skill_extrafields-hrm.sql} | 0 ...t.key.sql => llx_hrm_skilldet-hrm.key.sql} | 0 ..._skilldet.sql => llx_hrm_skilldet-hrm.sql} | 6 ++-- .../llx_hrm_skilldet_extrafields.key.sql | 21 ----------- .../tables/llx_hrm_skilldet_extrafields.sql | 24 ------------- ....key.sql => llx_hrm_skillrank-hrm.key.sql} | 0 ...killrank.sql => llx_hrm_skillrank-hrm.sql} | 0 htdocs/install/step2.php | 18 +++++----- htdocs/install/step5.php | 2 +- htdocs/langs/en_US/hrm.lang | 2 +- 39 files changed, 72 insertions(+), 158 deletions(-) rename htdocs/install/mysql/tables/{llx_hrm_evaluation.key.sql => llx_hrm_evaluation-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluation.sql => llx_hrm_evaluation-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluation_extrafields.key.sql => llx_hrm_evaluation_extrafields-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluation_extrafields.sql => llx_hrm_evaluation_extrafields-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluationdet.key.sql => llx_hrm_evaluationdet-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluationdet.sql => llx_hrm_evaluationdet-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluationdet_extrafields.key.sql => llx_hrm_evaluationdet_extrafields-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_evaluationdet_extrafields.sql => llx_hrm_evaluationdet_extrafields-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_job.key.sql => llx_hrm_job-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_job.sql => llx_hrm_job-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_job_extrafields.key.sql => llx_hrm_job_extrafields-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_job_extrafields.sql => llx_hrm_job_extrafields-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_job_user.key.sql => llx_hrm_job_user-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_job_user.sql => llx_hrm_job_user-hrm.sql} (100%) delete mode 100644 htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql rename htdocs/install/mysql/tables/{llx_hrm_skill.key.sql => llx_hrm_skill-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_skill.sql => llx_hrm_skill-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_skill_extrafields.key.sql => llx_hrm_skill_extrafields-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_skill_extrafields.sql => llx_hrm_skill_extrafields-hrm.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_skilldet.key.sql => llx_hrm_skilldet-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_skilldet.sql => llx_hrm_skilldet-hrm.sql} (94%) delete mode 100644 htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql delete mode 100644 htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql rename htdocs/install/mysql/tables/{llx_hrm_skillrank.key.sql => llx_hrm_skillrank-hrm.key.sql} (100%) rename htdocs/install/mysql/tables/{llx_hrm_skillrank.sql => llx_hrm_skillrank-hrm.sql} (100%) diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 7fc315451a8..1ad84ce19ac 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -469,13 +469,17 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { print load_fiche_titre($langs->trans('OtherOptions'), '', ''); +if (empty($conf->global->HRM_MAXRANK)) { + $conf->global->HRM_MAXRANK = Skill::DEFAULT_MAX_RANK_PER_SKILL; +} + if ($action == 'edit') { print ''; print ''; print ''; print ''; - print ''; + print ''; foreach ($arrayofparameters as $constname => $val) { if ($val['enabled']==1) { diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 478b267ac1f..0b247e7f5f4 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -241,29 +241,46 @@ class Skill extends CommonObject } /** - * @param int $i rank from which we want to create skilldets + * createSkills + * + * @param int $i Rank from which we want to create skilldets (level $i to HRM_MAXRANK wil be created) * @return null */ public function createSkills($i = 1) { - global $conf, $user, $langs; $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : self::DEFAULT_MAX_RANK_PER_SKILL; $defaultSkillDesc = !empty($conf->global->HRM_DEFAULT_SKILL_DESCRIPTION) ? $conf->global->HRM_DEFAULT_SKILL_DESCRIPTION : 'no Description'; + + $error = 0; + require_once __DIR__ . '/skilldet.class.php'; + + $this->db->begin(); + + // Create level of skills for ($i; $i <= $MaxNumberSkill ; $i++) { $skilldet = new Skilldet($this->db); - $skilldet->description = $defaultSkillDesc . " " . $i ; - $skilldet->rank = $i; + $skilldet->description = $defaultSkillDesc . " " . $i; + $skilldet->rankorder = $i; $skilldet->fk_skill = $this->id; $result = $skilldet->create($user); - - if ($result > 0) { - setEventMessage($langs->trans('TraductionCreadted'), $i); + if ($result <= 0) { + $error++; } } + + if (! $error) { + $this->db->commit(); + + setEventMessage($langs->trans('SkillCreated'), $i); + return 1; + } else { + $this->db->rollback(); + return -1; + } } /** @@ -384,7 +401,7 @@ class Skill extends CommonObject /** * Load object lines in memory from the database * - * @return array|int <0 if KO, 0 if not found, array if OK + * @return array <0 if KO, array of skill level found */ public function fetchLines() { @@ -393,7 +410,7 @@ class Skill extends CommonObject $skilldet = new Skilldet($this->db); $this->lines = $skilldet->fetchAll('ASC', '', '', '', array('fk_skill' => $this->id), ''); - return (count($this->lines) > 0 ) ? $this->lines : 0; + return (count($this->lines) > 0 ) ? $this->lines : array(); } diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index c3acdd0982e..0e0ce87382f 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -104,18 +104,18 @@ class Skilldet extends CommonObject */ public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'rankorder' => array('type'=>'integer', 'label'=>'rank', 'enabled'=>'1', 'position'=>2, 'notnull'=>0, 'visible'=>2,), + 'fk_skill' => array('type'=>'integer:Skill:/hrm/class/skill.class.php', 'label'=>'fk_skill', 'enabled'=>'1', 'position'=>5, 'notnull'=>1, 'visible'=>0,), + 'rankorder' => array('type'=>'integer', 'label'=>'rank', 'enabled'=>'1', 'position'=>10, 'notnull'=>0, 'visible'=>2,), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>0,), - 'fk_skill' => array('type'=>'integer:Skill:/hrm/class/skill.class.php', 'label'=>'fk_skill', 'enabled'=>'1', 'position'=>513, 'notnull'=>1, 'visible'=>0,), ); public $rowid; + public $fk_skill; + public $rankorder; public $description; public $fk_user_creat; public $fk_user_modif; - public $fk_skill; - public $rank; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/hrm/skill_agenda.php b/htdocs/hrm/skill_agenda.php index 9c1821fb8d7..a352988c297 100644 --- a/htdocs/hrm/skill_agenda.php +++ b/htdocs/hrm/skill_agenda.php @@ -147,7 +147,7 @@ if ($object->id > 0) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; $morehtmlref.= $object->label; diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 3c72b5478ce..6fa601249db 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -21,8 +21,8 @@ /** * \file skill_card.php - * \ingroup hrm - * \brief Page to create/edit/view skill + * \ingroup hrm + * \brief Page to create/edit/view skill */ @@ -84,6 +84,8 @@ $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->enti if (empty($conf->hrm->enabled)) accessforbidden(); if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessforbidden(); +$MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; + /* * Actions @@ -98,14 +100,14 @@ if ($reshook < 0) { if (empty($reshook)) { $error = 0; - $backurlforlist = dol_buildpath('/hrm/skill_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php'; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = dol_buildpath('/hrm/skill_card.php', 1) . '?id=' . ($id > 0 ? $id : '__ID__'); + $backtopage = DOL_URL_ROOT.'/hrm/skill_card.php?id=' . ($id > 0 ? $id : '__ID__'); } } } @@ -166,8 +168,6 @@ if (empty($reshook)) { /* * View - * - * Put here all code to build page */ $form = new Form($db); @@ -186,9 +186,9 @@ if ($action == 'create') { print ''; print ''; print ''; - $backtopage .= "&objecttype=job"; + $backtopage .= (strpos($backtopage, '?') > 0 ? '&' : '?' ) ."objecttype=job"; if ($backtopage) { - print ''; + print ''; } if ($backtopageforcancel) { print ''; @@ -254,11 +254,16 @@ if (($id || $ref) && $action == 'edit') { // SKILLDET print dol_get_fiche_head(array(), ''); + $SkilldetRecords = $object->fetchLines(); + + if (is_array($SkilldetRecords) && count($SkilldetRecords) == 0) { + $object->createSkills(1); + } + if (is_array($SkilldetRecords) && count($SkilldetRecords) > 0) { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; foreach ($SkilldetRecords as $sk) { - $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; if ($sk->rank > $MaxNumberSkill) { continue; } @@ -397,7 +402,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref = '
'; @@ -691,7 +696,6 @@ if ($action != "create" && $action != "edit") { break; // Should not happen } - $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; if ($obj->rank > $MaxNumberSkill) { continue; } diff --git a/htdocs/hrm/skill_contact.php b/htdocs/hrm/skill_contact.php index f8ea2a04a9f..d8fecd74610 100644 --- a/htdocs/hrm/skill_contact.php +++ b/htdocs/hrm/skill_contact.php @@ -129,7 +129,7 @@ if ($object->id) { print dol_get_fiche_head($head, 'contact', '', -1, $object->picto); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; /* diff --git a/htdocs/hrm/skill_document.php b/htdocs/hrm/skill_document.php index 77f3325de15..65549dbfe7a 100644 --- a/htdocs/hrm/skill_document.php +++ b/htdocs/hrm/skill_document.php @@ -127,7 +127,7 @@ if ($object->id) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; $morehtmlref.= $object->label; diff --git a/htdocs/hrm/skill_note.php b/htdocs/hrm/skill_note.php index 1510f746e5e..45a0690f176 100644 --- a/htdocs/hrm/skill_note.php +++ b/htdocs/hrm/skill_note.php @@ -100,7 +100,7 @@ if ($id > 0 || !empty($ref)) { // Object card // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; $morehtmlref.= $object->label; diff --git a/htdocs/hrm/skill_tab.php b/htdocs/hrm/skill_tab.php index 9a9ea39e31d..e7c6798bbec 100644 --- a/htdocs/hrm/skill_tab.php +++ b/htdocs/hrm/skill_tab.php @@ -93,14 +93,14 @@ if ($reshook < 0) { if (empty($reshook)) { $error = 0; - $backurlforlist = dol_buildpath('/hrm/skill_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/hrm/skill_list.php'; if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = dol_buildpath('/hrm/skill_list.php', 1) . '?id=' . ($id > 0 ? $id : '__ID__'); + $backtopage = DOL_URL_ROOT.'/hrm/skill_list.php?id=' . ($id > 0 ? $id : '__ID__'); } } } diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 6091556037c..f3f92b39dae 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -306,17 +306,6 @@ ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_rowid (rowid); -- ALTER TABLE llx_hrm_job_user ADD INDEX idx_hrm_job_user_ref (ref); -create table llx_hrm_job_user_extrafields -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - fk_object integer NOT NULL, - import_key varchar(14) -- import key -) ENGINE=innodb; - -ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_object); - - CREATE TABLE llx_hrm_skill ( @@ -360,20 +349,11 @@ CREATE TABLE llx_hrm_skilldet rankorder integer ) ENGINE=innodb; +ALTER TABLE llx_hrm_skilldet ADD COLUMN rankorder integer NOT NULL DEFAULT '1'; + ALTER TABLE llx_hrm_skilldet ADD INDEX idx_hrm_skilldet_rowid (rowid); ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_user_creat FOREIGN KEY (fk_user_creat) REFERENCES llx_user(rowid); -create table llx_hrm_skilldet_extrafields -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - fk_object integer NOT NULL, - import_key varchar(14) -- import key -) ENGINE=innodb; - -ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object); - - CREATE TABLE llx_hrm_skillrank ( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluation.key.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluation-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluation.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluation-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluation_extrafields-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluationdet.key.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluationdet.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields.sql rename to htdocs/install/mysql/tables/llx_hrm_evaluationdet_extrafields-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job.key.sql b/htdocs/install/mysql/tables/llx_hrm_job-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_job.key.sql rename to htdocs/install/mysql/tables/llx_hrm_job-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job.sql b/htdocs/install/mysql/tables/llx_hrm_job-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_job.sql rename to htdocs/install/mysql/tables/llx_hrm_job-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_job_extrafields-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_job_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_hrm_job_extrafields-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_job_extrafields-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_job_extrafields.sql rename to htdocs/install/mysql/tables/llx_hrm_job_extrafields-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job_user.key.sql b/htdocs/install/mysql/tables/llx_hrm_job_user-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_job_user.key.sql rename to htdocs/install/mysql/tables/llx_hrm_job_user-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job_user.sql b/htdocs/install/mysql/tables/llx_hrm_job_user-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_job_user.sql rename to htdocs/install/mysql/tables/llx_hrm_job_user-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql deleted file mode 100644 index 99ed1f4c1bc..00000000000 --- a/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.key.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Copyright (C) 2021 Gauthier VERDOL --- Copyright (C) 2021 Greg Rastklan --- Copyright (C) 2021 Jean-Pascal BOUDET --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see https://www.gnu.org/licenses/. - - --- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_hrm_job_user_extrafields ADD INDEX idx_position_fk_object(fk_object); --- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql deleted file mode 100644 index 7495563f68d..00000000000 --- a/htdocs/install/mysql/tables/llx_hrm_job_user_extrafields.sql +++ /dev/null @@ -1,25 +0,0 @@ --- Copyright (C) 2021 Gauthier VERDOL --- Copyright (C) 2021 Greg Rastklan --- Copyright (C) 2021 Jean-Pascal BOUDET --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see https://www.gnu.org/licenses/. - -create table llx_hrm_job_user_extrafields -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - fk_object integer NOT NULL, - import_key varchar(14) -- import key -) ENGINE=innodb; - diff --git a/htdocs/install/mysql/tables/llx_hrm_skill.key.sql b/htdocs/install/mysql/tables/llx_hrm_skill-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skill.key.sql rename to htdocs/install/mysql/tables/llx_hrm_skill-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_skill.sql b/htdocs/install/mysql/tables/llx_hrm_skill-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skill.sql rename to htdocs/install/mysql/tables/llx_hrm_skill-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_skill_extrafields-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skill_extrafields.key.sql rename to htdocs/install/mysql/tables/llx_hrm_skill_extrafields-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_skill_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_skill_extrafields-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skill_extrafields.sql rename to htdocs/install/mysql/tables/llx_hrm_skill_extrafields-hrm.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet.key.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skilldet.key.sql rename to htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.sql similarity index 94% rename from htdocs/install/mysql/tables/llx_hrm_skilldet.sql rename to htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.sql index 0257d886813..18a1cdcf9dc 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skilldet.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.sql @@ -18,9 +18,9 @@ CREATE TABLE llx_hrm_skilldet( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, + fk_skill integer NOT NULL, + rankorder integer NOT NULL DEFAULT '1', description text, fk_user_creat integer NOT NULL, - fk_user_modif integer, - fk_skill integer NOT NULL, - rankorder integer + fk_user_modif integer ) ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql deleted file mode 100644 index 319eb193a18..00000000000 --- a/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.key.sql +++ /dev/null @@ -1,21 +0,0 @@ --- Copyright (C) 2021 Gauthier VERDOL --- Copyright (C) 2021 Greg Rastklan --- Copyright (C) 2021 Jean-Pascal BOUDET --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see https://www.gnu.org/licenses/. - - --- BEGIN MODULEBUILDER INDEXES -ALTER TABLE llx_hrm_skilldet_extrafields ADD INDEX idx_skilldet_fk_object(fk_object); --- END MODULEBUILDER INDEXES diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql deleted file mode 100644 index a6e14f476c0..00000000000 --- a/htdocs/install/mysql/tables/llx_hrm_skilldet_extrafields.sql +++ /dev/null @@ -1,24 +0,0 @@ --- Copyright (C) 2021 Gauthier VERDOL --- Copyright (C) 2021 Greg Rastklan --- Copyright (C) 2021 Jean-Pascal BOUDET --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see https://www.gnu.org/licenses/. - -create table llx_hrm_skilldet_extrafields -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - fk_object integer NOT NULL, - import_key varchar(14) -- import key -) ENGINE=innodb; - diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank.key.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skillrank.key.sql rename to htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.sql similarity index 100% rename from htdocs/install/mysql/tables/llx_hrm_skillrank.sql rename to htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.sql diff --git a/htdocs/install/step2.php b/htdocs/install/step2.php index 30bee881584..45b7d742f3e 100644 --- a/htdocs/install/step2.php +++ b/htdocs/install/step2.php @@ -154,8 +154,8 @@ if ($action == "set") { /************************************************************************************** * - * Chargement fichiers tables/*.sql (non *.key.sql) - * A faire avant les fichiers *.key.sql + * Load files tables/*.sql (not the *.key.sql). Files with '-xxx' in name are excluded (they will be loaded during activation o fmodule 'xxx'). + * To do before the files *.key.sql * ***************************************************************************************/ if ($ok && $createtables) { @@ -169,7 +169,7 @@ if ($action == "set") { $tabledata = array(); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file)) { + if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) { $tablefound++; $tabledata[] = $file; } @@ -252,8 +252,8 @@ if ($action == "set") { /*************************************************************************************** * - * Chargement fichiers tables/*.key.sql - * A faire apres les fichiers *.sql + * Load files tables/*.key.sql. Files with '-xxx' in name are excluded (they will be loaded during activation o fmodule 'xxx'). + * To do after the files *.sql * ***************************************************************************************/ if ($ok && $createkeys) { @@ -267,7 +267,7 @@ if ($action == "set") { $tabledata = array(); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file)) { + if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file) && !preg_match('/\-/', $file)) { $tablefound++; $tabledata[] = $file; } @@ -372,7 +372,7 @@ if ($action == "set") { /*************************************************************************************** * - * Chargement fichier functions.sql + * Lod the file 'functions.sql' * ***************************************************************************************/ if ($ok && $createfunctions) { @@ -449,7 +449,7 @@ if ($action == "set") { /*************************************************************************************** * - * Load files data/*.sql + * Load files data/*.sql. Files with '-xxx' in name are excluded (they will be loaded during activation o fmodule 'xxx'). * ***************************************************************************************/ if ($ok && $createdata) { @@ -463,7 +463,7 @@ if ($action == "set") { $tabledata = array(); if (is_resource($handle)) { while (($file = readdir($handle)) !== false) { - if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) { + if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\-/', $file)) { if (preg_match('/^llx_accounting_account_/', $file)) { continue; // We discard data file of chart of account. Will be loaded when a chart is selected. } diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index f9424f51a32..6effe4316a5 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -404,7 +404,7 @@ if ($action == "set" && $success) { // If upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { // Upgrade is finished - print 'Configuration '.$langs->trans("SystemIsUpgraded")."
"; + print 'Configuration '.$langs->trans("SystemIsUpgraded")."
"; $createlock = 0; diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang index dedbb1f5923..c571ec6ca8a 100644 --- a/htdocs/langs/en_US/hrm.lang +++ b/htdocs/langs/en_US/hrm.lang @@ -21,7 +21,7 @@ NewEmployee=New employee ListOfEmployees=List of employees HrmSetup=HRM module setup SkillsManagement=Skills management -HRM_MAXRANK=Maximum rank for a skill +HRM_MAXRANK=Maximum number of levels to rank a skill HRM_DEFAULT_SKILL_DESCRIPTION=Default description of ranks when skill is created deplacement=Shift DateEval=Evaluation date From 4376934e008825d5715e3915a67fc47460bc2f2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 14:56:21 +0100 Subject: [PATCH 080/576] css --- htdocs/theme/md/style.css.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index b49373fd300..cbd8b4bb7fb 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3918,8 +3918,7 @@ div.liste_titre_bydiv { display: table; padding: 2px 0px 2px 0; box-shadow: none; - /*width: calc(100% - 1px); 1px more, i don't know why so i remove */ - width: calc(100%); + width: calc(100% - 2px); /* -3px because the width for table class="tagtable" under this is cal(100% - 2px) so it is aligned. */ } tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr, tagtr.liste_titre { From 72493a5663cc6011395d694fbc59abbbd8b29342 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 15:13:36 +0100 Subject: [PATCH 081/576] Fix typo --- test/phpunit/SecurityTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 81eff830b49..6bece069cc9 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -594,7 +594,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." login=".$login."\n"; $this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); - $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authetntication method + $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method print __METHOD__." login=".$login."\n"; $this->assertEquals($login, 'admin'); @@ -749,42 +749,42 @@ class SecurityTest extends PHPUnit\Framework\TestCase $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow print __METHOD__." url=".$url."\n"; - $this->assertEquals(301, $tmp['http_code'], 'GET url 301 without following -> 301'); + $this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 without following -> 301'); $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page - $tmp = getURLContent($url); // We DO follow + $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 print __METHOD__." url=".$url."\n"; - $this->assertEquals(200, $tmp['http_code'], 'GET url 301 with following -> 200'); // Test error if return does not contains 'not supported' + $this->assertEquals(200, $tmp['http_code'], 'Should GET url 301 with following -> 200 but we get '.$tmp['http_code']); $url = 'http://localhost'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL $url = 'http://127.0.0.1'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL $url = 'http://127.0.2.1'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL $url = 'https://169.254.0.1'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL $url = 'http://[::1]'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL /*$url = 'localtest.me'; $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL print __METHOD__." url=".$url."\n"; - $this->assertEquals(400, $tmp['http_code'], 'GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL */ return 0; From 962ac263ba98266797dbcaee66eec0640be0773c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 15:29:48 +0100 Subject: [PATCH 082/576] Fix look and feel v15 --- htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php | 2 ++ .../modules/commande/doc/doc_generic_order_odt.modules.php | 2 ++ .../modules/contract/doc/doc_generic_contract_odt.modules.php | 2 ++ .../expedition/doc/doc_generic_shipment_odt.modules.php | 2 ++ .../modules/facture/doc/doc_generic_invoice_odt.modules.php | 2 ++ .../core/modules/member/doc/doc_generic_member_odt.class.php | 2 ++ htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php | 2 ++ .../modules/product/doc/doc_generic_product_odt.modules.php | 2 ++ .../modules/project/doc/doc_generic_project_odt.modules.php | 2 ++ .../modules/project/task/doc/doc_generic_task_odt.modules.php | 2 ++ .../modules/propale/doc/doc_generic_proposal_odt.modules.php | 2 ++ .../reception/doc/doc_generic_reception_odt.modules.php | 2 ++ htdocs/core/modules/societe/doc/doc_generic_odt.modules.php | 2 ++ .../core/modules/stock/doc/doc_generic_stock_odt.modules.php | 2 ++ .../doc/doc_generic_supplier_order_odt.modules.php | 2 ++ .../doc/doc_generic_supplier_proposal_odt.modules.php | 2 ++ .../modules/ticket/doc/doc_generic_ticket_odt.modules.php | 2 ++ htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php | 2 ++ .../usergroup/doc/doc_generic_usergroup_odt.modules.php | 2 ++ .../modules/mymodule/doc/doc_generic_myobject_odt.modules.php | 2 ++ .../doc/doc_generic_recruitmentjobposition_odt.modules.php | 4 +++- 21 files changed, 43 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 08d31e3cd95..3ba612c7ed3 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -176,7 +176,9 @@ class doc_generic_bom_odt extends ModelePDFBom $texte .= ''; $texte .= '
'; $texte .= ''; diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 1e6aeac79e5..ecfa3075fbd 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -189,7 +189,9 @@ class doc_generic_order_odt extends ModelePDFCommandes $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index a640d342ddc..41a442fc5df 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -174,7 +174,9 @@ class doc_generic_contract_odt extends ModelePDFContract $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index c504d97a854..9affbcda6e4 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -187,7 +187,9 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index ef20b4ff389..ecd645b3796 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -186,7 +186,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 593986d4b7d..c466b52af05 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -176,7 +176,9 @@ class doc_generic_member_odt extends ModelePDFMember $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index c2d697b4a4d..e4cd4f69b46 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -183,7 +183,9 @@ class doc_generic_mo_odt extends ModelePDFMo $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index d702299769e..e59fcf4f8d5 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -182,7 +182,9 @@ class doc_generic_product_odt extends ModelePDFProduct $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index f86f5b55a9c..a77ee9e33ab 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -474,7 +474,9 @@ class doc_generic_project_odt extends ModelePDFProjects $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 3890c6526bc..dbfc7c22e90 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -441,7 +441,9 @@ class doc_generic_task_odt extends ModelePDFTask $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index fb0991c8da1..e54538507da 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -214,7 +214,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 4729231ac8b..7f59efc47ce 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -181,7 +181,9 @@ class doc_generic_reception_odt extends ModelePdfReception $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 6427a6a60a3..26447005d01 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -172,7 +172,9 @@ class doc_generic_odt extends ModeleThirdPartyDoc $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 1d02b8003da..6755be2e230 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -185,7 +185,9 @@ class doc_generic_stock_odt extends ModelePDFStock $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index dfb05d2d55f..6984f2ab200 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -184,7 +184,9 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 18e5a210aa1..cff1ba4bd0e 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -211,7 +211,9 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index e20cbf44cf7..26d3657e8e2 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -173,7 +173,9 @@ class doc_generic_ticket_odt extends ModelePDFTicket $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 050eb43d44a..0313e639b5f 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -205,7 +205,9 @@ class doc_generic_user_odt extends ModelePDFUser $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index a934c7a50d9..399e603b96a 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -197,7 +197,9 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 9126da0070d..4ba9f101d41 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -182,7 +182,9 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texte .= ''; $texte .= ''; $texte .= ''; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 80d4e85435c..3be4cb73783 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -181,7 +181,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $texte .= ''; $texte .= ''; $texte .= ''; From 2acfba25ee4f46bb07724bcd9315ca9f31f98221 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 15:58:08 +0100 Subject: [PATCH 083/576] Comment dead code --- htdocs/public/members/new.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 4795338a938..04ae85041aa 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -174,6 +174,7 @@ function llxFooterVierge() /* * Actions */ + $parameters = array(); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); @@ -386,10 +387,17 @@ if (empty($reshook) && $action == 'add') { if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { + // The default behaviour $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount', 'alpha'))) { + + if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed + // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT + // It is not so important because a test is done on return of payment validation. + $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + } elseif (price2num(GETPOST('amount', 'alpha'))) { $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); } + if (GETPOST('email')) { $urlback .= '&email='.urlencode(GETPOST('email')); } @@ -400,7 +408,7 @@ if (empty($reshook) && $action == 'add') { $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { + /*} elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); if (price2num(GETPOST('amount', 'alpha'))) { $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); @@ -415,7 +423,7 @@ if (empty($reshook) && $action == 'add') { $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { + } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); if (price2num(GETPOST('amount', 'alpha'))) { $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); @@ -430,7 +438,7 @@ if (empty($reshook) && $action == 'add') { $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { + } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; if (price2num(GETPOST('amount', 'alpha'))) { $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); @@ -445,6 +453,7 @@ if (empty($reshook) && $action == 'add') { $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } + */ } else { dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment"); exit; @@ -452,7 +461,7 @@ if (empty($reshook) && $action == 'add') { } if (!empty($entity)) { - $urlback .= '&entity='.$entity; + $urlback .= '&entity='.((int) $entity); } dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); } else { @@ -733,7 +742,7 @@ if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = $amount ? $amount : (GETPOST('amount') ? price2num(GETPOST('amount'), 'MT', 2) : $conf->global->MEMBER_NEWFORM_AMOUNT); + $amount = $amount ? $amount : (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : $conf->global->MEMBER_NEWFORM_AMOUNT); } $amount = price2num($amount); From 66d9964861d2109bbc25b1f66836022d9f3bcbd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 16:19:12 +0100 Subject: [PATCH 084/576] Clean code --- .../adherents/class/adherent_type.class.php | 6 ++--- htdocs/public/members/new.php | 24 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index cdf021cfa68..90f160e7932 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -543,14 +543,13 @@ class AdherentType extends CommonObject } /** - * Return list of amount by type id + * Return the array of all amounts per membership type id * * @param int $status Filter on status of type - * @return array List of types of members + * @return array Array of membership type */ public function amountByType($status = null) { - global $conf, $langs; $amountbytype = array(); @@ -578,6 +577,7 @@ class AdherentType extends CommonObject } else { print $this->db->error(); } + return $amountbytype; } diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 04ae85041aa..caab1a0bbe3 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -730,21 +730,24 @@ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) { print ''."\n"; } -if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - // $conf->global->MEMBER_NEWFORM_SHOWAMOUNT is an amount +if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { + $amount = 0; + $typeid = $conf->global->MEMBER_NEWFORM_FORCETYPE ? $conf->global->MEMBER_NEWFORM_FORCETYPE : GETPOST('typeid', 'int'); - // Set amount for the subscription - $amountbytype = $adht->amountByType(1); - $amount = !empty($amountbytype[GETPOST('typeid', 'int')]) ? $amountbytype[GETPOST('typeid', 'int')] : (isset($amount) ? $amount : 0); - - if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + // Set amount for the subscription: + // - First check the amount of the member type. + $amountbytype = $adht->amountByType(1); // Load the array of amount per type + $amount = empty($amountbytype[$typeid]) ? (isset($amount) ? $amount : 0) : $amountbytype[$typeid]; + // - If not found, take the default amount + if (empty($amount) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { $amount = $conf->global->MEMBER_NEWFORM_AMOUNT; } - - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE)) { - $amount = $amount ? $amount : (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : $conf->global->MEMBER_NEWFORM_AMOUNT); + // - If not set, we accept ot have amount defined as parameter (for backward compatibility). + if (empty($amount)) { + $amount = (GETPOST('amount') ? price2num(GETPOST('amount', 'alpha'), 'MT', 2) : ''); } + // Clean the amount $amount = price2num($amount); // $conf->global->MEMBER_NEWFORM_PAYONLINE is 'paypal', 'paybox' or 'stripe' @@ -758,6 +761,7 @@ if (!empty($conf->global->MEMBER_NEWFORM_AMOUNT) || !empty($conf->global->MEMBER print ' '.$langs->trans("Currency".$conf->currency); print ''; } + print "
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
'; - $texte .= ''.$langs->trans("ExampleOfDirectoriesForModelGen").''; + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; $texte .= '
\n"; print dol_get_fiche_end(); From 2030d55c67b68144e9844c27aded4a899ba4726e Mon Sep 17 00:00:00 2001 From: Klaas Oldenburger Date: Sat, 27 Nov 2021 16:42:53 +0100 Subject: [PATCH 085/576] Update main.lang Did not complete earlier work. --- htdocs/langs/nl_NL/main.lang | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/langs/nl_NL/main.lang b/htdocs/langs/nl_NL/main.lang index 3043bba6410..1afc7f49fb7 100644 --- a/htdocs/langs/nl_NL/main.lang +++ b/htdocs/langs/nl_NL/main.lang @@ -17,12 +17,12 @@ FormatDateShortJQueryInput=mm/dd/yy FormatHourShortJQuery=HH:MI FormatHourShort=%I:%M %p FormatHourShortDuration=%H:%M -FormatDateTextShort=%b %d, %Y -FormatDateText=%B %d, %Y -FormatDateHourShort=%m/%d/%Y %I:%M %p -FormatDateHourSecShort=%m/%d/%Y %I:%M:%S %p -FormatDateHourTextShort=%b %d, %Y, %I:%M %p -FormatDateHourText=%B %d, %Y, %I:%M %p +FormatDateTextShort=%d %b %Y +FormatDateText=%d %B %Y +FormatDateHourShort=%d-%m-%Y %I:%M %p +FormatDateHourSecShort=%d-%m-%Y %I:%M:%S %p +FormatDateHourTextShort=%d %b %Y, %I:%M %p +FormatDateHourText=%d %B %Y, %I:%M %p DatabaseConnection=Databaseverbinding NoTemplateDefined=Geen sjabloon beschikbaar voor dit e-mailtype AvailableVariables=Beschikbare substitutievariabelen From 6e27abaed905cf511a1bafb65e42f6811eba03bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 17:19:16 +0100 Subject: [PATCH 086/576] FIX redirect to payment page when membership payment mode forced --- htdocs/adherents/class/adherent.class.php | 1 + htdocs/public/members/new.php | 88 ++++++----------------- htdocs/public/payment/newpayment.php | 7 +- htdocs/public/payment/paymentok.php | 59 ++++++++++----- 4 files changed, 68 insertions(+), 87 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index a0d542bd79e..324e3cdc491 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1398,6 +1398,7 @@ class Adherent extends CommonObject $this->photo = $obj->photo; $this->statut = $obj->statut; + $this->status = $obj->statut; $this->public = $obj->public; $this->datec = $this->db->jdate($obj->datec); diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index caab1a0bbe3..39b905acc8e 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -386,77 +386,29 @@ if (empty($reshook) && $action == 'add') { } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { - if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { - // The default behaviour - $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); + $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed - // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT - // It is not so important because a test is done on return of payment validation. - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } elseif (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } + if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed + // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT + // It is not so important because a test is done on return of payment validation. + $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + } elseif (price2num(GETPOST('amount', 'alpha'))) { + $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); + } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); + if (GETPOST('email')) { + $urlback .= '&email='.urlencode(GETPOST('email')); + } + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { + $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); + } else { + $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - /*} elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { - $urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { - $urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { - $urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; - if (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - */ - } else { - dol_print_error('', "Autosubscribe form is setup to ask an online payment for a not managed online payment"); - exit; + } + + if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') { + $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE); } } diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 8eefd77e746..c63cf3b6624 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -184,11 +184,12 @@ if ($source == 'organizedeventregistration') { } -$paymentmethod = GETPOST('paymentmethod', 'alphanohtml') ?GETPOST('paymentmethod', 'alphanohtml') : ''; // Empty in most cases. Defined when a payment mode is forced +$paymentmethod = GETPOST('paymentmethod', 'alphanohtml') ? GETPOST('paymentmethod', 'alphanohtml') : ''; // Empty in most cases. Defined when a payment mode is forced $validpaymentmethod = array(); // Detect $paymentmethod foreach ($_POST as $key => $val) { + $reg = array(); if (preg_match('/^dopayment_(.*)$/', $key, $reg)) { $paymentmethod = $reg[1]; break; @@ -480,7 +481,7 @@ if ($action == 'dopayment') { // Called when choosing Stripe mode. // When using the Charge API architecture, this code is called after clicking the 'dopayment' with the Charge API architecture. -// When using the PaymentIntent API architecture, the Stripe customer is already created when creating PaymentIntent when showing payment page and the payment is already ok. +// When using the PaymentIntent API architecture, the Stripe customer was already created when creating PaymentIntent when showing payment page, and the payment is already ok when action=charge. if ($action == 'charge' && !empty($conf->stripe->enabled)) { $amountstripe = $amount; @@ -1325,7 +1326,7 @@ if ($source == 'contractline') { $qty = 1; if (GETPOST('qty')) { - $qty = GETPOST('qty'); + $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); } // Creditor diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 18d6a2987c8..c46542ed3c4 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -386,7 +386,7 @@ if ($ispaymentok) { $adht = new AdherentType($db); $object = new Adherent($db); - $result1 = $object->fetch($tmptag['MEM']); + $result1 = $object->fetch((int) $tmptag['MEM']); $result2 = $adht->fetch($object->typeid); dol_syslog("We have to process member with id=".$tmptag['MEM']." result1=".$result1." result2=".$result2, LOG_DEBUG, 0, '_payment'); @@ -416,14 +416,41 @@ if ($ispaymentok) { // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { - $result = ($object->status == $object::STATUS_EXCLUDED) ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible - if ($result < 0 || empty($object->datevalid)) { - $error++; - $errmsg = $object->error; - $postactionmessages[] = $errmsg; - $postactionmessages = array_merge($postactionmessages, $object->errors); - $ispostactionok = -1; - dol_syslog("Failed to validate member: ".$errmsg, LOG_ERR, 0, '_payment'); + // Security protection: + if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If we didn't allow members to choose their membership amount + if ($object->status == $object::STATUS_DRAFT) { // If the member is not yet validated, we check that the amount is the same as expected. + $typeid = $object->typeid; + + // Set amount for the subscription: + // - First check the amount of the member type. + $amountbytype = $adht->amountByType(1); // Load the array of amount per type + $amountexpected = empty($amountbytype[$typeid]) ? 0 : $amountbytype[$typeid]; + // - If not found, take the default amount + if (empty($amountexpected) && !empty($conf->global->MEMBER_NEWFORM_AMOUNT)) { + $amountexpected = $conf->global->MEMBER_NEWFORM_AMOUNT; + } + + if ($amountexpected && $amountexpected != $FinalPaymentAmt) { + $error++; + $errmsg = 'Value of FinalPayment ('.$FinalPaymentAmt.') differs from value expected for membership ('.$amountexpected.'). May be a hack to try to pay a different amount ?'; + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + dol_syslog("Failed to validate member: ".$errmsg, LOG_ERR, 0, '_payment'); + } + } + } + + if (! $error) { + // We validate the member (no effect if it is already validated) + $result = ($object->status == $object::STATUS_EXCLUDED) ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible + if ($result < 0 || empty($object->datevalid)) { + $error++; + $errmsg = $object->error; + $postactionmessages[] = $errmsg; + $postactionmessages = array_merge($postactionmessages, $object->errors); + $ispostactionok = -1; + dol_syslog("Failed to validate member: ".$errmsg, LOG_ERR, 0, '_payment'); + } } // Subscription informations @@ -721,7 +748,7 @@ if ($ispaymentok) { // Record payment include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); - $result = $object->fetch($tmptag['INV']); + $result = $object->fetch((int) $tmptag['INV']); if ($result) { $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; @@ -827,7 +854,7 @@ if ($ispaymentok) { } elseif (array_key_exists('ORD', $tmptag) && $tmptag['ORD'] > 0) { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $object = new Commande($db); - $result = $object->fetch($tmptag['ORD']); + $result = $object->fetch((int) $tmptag['ORD']); if ($result) { $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; @@ -932,7 +959,7 @@ if ($ispaymentok) { } elseif (array_key_exists('DON', $tmptag) && $tmptag['DON'] > 0) { include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $don = new Don($db); - $result = $don->fetch($tmptag['DON']); + $result = $don->fetch((int) $tmptag['DON']); if ($result) { $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; @@ -1141,7 +1168,7 @@ if ($ispaymentok) { if (!$error) { // Validating the attendee $attendeetovalidate = new ConferenceOrBoothAttendee($db); - $resultattendee = $attendeetovalidate->fetch($tmptag['ATT']); + $resultattendee = $attendeetovalidate->fetch((int) $tmptag['ATT']); if ($resultattendee < 0) { $error++; setEventMessages(null, $attendeetovalidate->errors, "errors"); @@ -1325,7 +1352,7 @@ if ($ispaymentok) { if (!$error) { // Putting the booth to "suggested" state $booth = new ConferenceOrBooth($db); - $resultbooth = $booth->fetch($tmptag['BOO']); + $resultbooth = $booth->fetch((int) $tmptag['BOO']); if ($resultbooth < 0) { $error++; setEventMessages(null, $booth->errors, "errors"); @@ -1490,12 +1517,12 @@ if ($ispaymentok) { $topic = '['.$appli.'] '.$companylangs->transnoentitiesnoconv("NewOnlinePaymentReceived"); $content = ""; if (array_key_exists('MEM', $tmptag)) { - $url = $urlwithroot."/adherents/subscription.php?rowid=".$tmptag['MEM']; + $url = $urlwithroot."/adherents/subscription.php?rowid=".((int) $tmptag['MEM']); $content .= ''.$companylangs->trans("PaymentSubscription")."

\n"; $content .= $companylangs->trans("MemberId").': '.$tmptag['MEM']."
\n"; $content .= $companylangs->trans("Link").': '.$url.''."
\n"; } elseif (array_key_exists('INV', $tmptag)) { - $url = $urlwithroot."/compta/facture/card.php?id=".$tmptag['INV']; + $url = $urlwithroot."/compta/facture/card.php?id=".((int) $tmptag['INV']); $content .= ''.$companylangs->trans("Payment")."

\n"; $content .= $companylangs->trans("InvoiceId").': '.$tmptag['INV']."
\n"; //$content.=$companylangs->trans("ThirdPartyId").': '.$tmptag['CUS']."
\n"; From 54e335937f4568aa9a40766588319ed5894251f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 18:05:41 +0100 Subject: [PATCH 087/576] FIX Bad redirect url for payment of members after public registration --- htdocs/public/members/new.php | 22 ++++++---------------- htdocs/public/payment/newpayment.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 39b905acc8e..6589f2a17d0 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -386,35 +386,25 @@ if (empty($reshook) && $action == 'add') { } if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { - $urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT // It is not so important because a test is done on return of payment validation. - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); - } elseif (price2num(GETPOST('amount', 'alpha'))) { - $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha')); } + $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0); + if (GETPOST('email')) { $urlback .= '&email='.urlencode(GETPOST('email')); } - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2)); - } else { - $urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); - } - } - if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') { $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE); } + } else { + if (!empty($entity)) { + $urlback .= '&entity='.((int) $entity); + } } - if (!empty($entity)) { - $urlback .= '&entity='.((int) $entity); - } dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); } else { $error++; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index c63cf3b6624..bb58936d78d 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1461,9 +1461,12 @@ if ($source == 'member' || $source == 'membersubscription') { $langs->load("members"); require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; $member = new Adherent($db); + $adht = new AdherentType($db); + $result = $member->fetch('', $ref); if ($result <= 0) { $mesg = $member->error; @@ -1471,6 +1474,8 @@ if ($source == 'member' || $source == 'membersubscription') { } else { $member->fetch_thirdparty(); $subscription = new Subscription($db); + + $adht->fetch($member->typeid); } $object = $member; @@ -1479,6 +1484,11 @@ if ($source == 'member' || $source == 'membersubscription') { if (GETPOST("amount", 'alpha')) { $amount = GETPOST("amount", 'alpha'); } + // If amount still not defined, we take amount of the type of member + if (empty($amount)) { + $amount = $adht->amount; + } + $amount = price2num($amount, 'MT'); } From 5bb21a93a1fba9ac222b9062c471ac51751ca750 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 27 Nov 2021 18:25:38 +0100 Subject: [PATCH 088/576] FIX fatal error on cron list. --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/cron/list.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 03366e9bae1..9a5ab68f898 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8082,7 +8082,7 @@ function verifCond($strRights) //print $strRights."
\n"; $rights = true; - if ($strRights !== '') { + if (isset($strRights) && $strRights !== '') { $str = 'if(!('.$strRights.')) { $rights = false; }'; dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 4d829258b2b..686bb8a52a9 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -478,7 +478,7 @@ if ($num > 0) { if (empty($obj)) { break; } - if (!verifCond($obj->test)) { + if (isset($obj->test) && !verifCond($obj->test)) { continue; // Discard line with test = false } From 309f7da7ba6e35f92513611ed0d3852faef34cea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 18:29:31 +0100 Subject: [PATCH 089/576] Add log hidden into result page --- htdocs/public/payment/paymentok.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c46542ed3c4..c8222c4c4aa 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -412,7 +412,7 @@ if ($ispaymentok) { $currencyCodeType = $_SESSION['currencyCodeType']; - dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId, LOG_DEBUG, 0, '_payment'); + dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId." currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0, '_payment'); // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { @@ -440,6 +440,9 @@ if ($ispaymentok) { } } + // Security protection: + // TODO check that currency is same ? + if (! $error) { // We validate the member (no effect if it is already validated) $result = ($object->status == $object::STATUS_EXCLUDED) ? -1 : $object->validate($user); // if membre is excluded (status == -2) the new validation is not possible @@ -1684,6 +1687,8 @@ if ($ispaymentok) { print "\n\n"; +print "\n"; + htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); From 27ae8f61bd28c463c9fb75c68a04206d31c216ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 27 Nov 2021 19:04:39 +0100 Subject: [PATCH 090/576] FIX Check on Stripe REAL amount currency before validating membership --- htdocs/public/payment/newpayment.php | 16 +++++++++++- htdocs/public/payment/paymentok.php | 37 +++++++++------------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index bb58936d78d..27bf780de62 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -768,9 +768,23 @@ if ($action == 'charge' && !empty($conf->stripe->enabled)) { setEventMessages($paymentintent->status, null, 'errors'); $action = ''; } else { - // TODO We can alse record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method + // TODO We can also record the payment mode into llx_societe_rib with stripe $paymentintent->payment_method // Note that with other old Stripe architecture (using Charge API), the payment mode was not recorded, so it is not mandatory to do it here. //dol_syslog("Create payment_method for ".$paymentintent->payment_method, LOG_DEBUG, 0, '_stripe'); + + // Get here amount and currency used for payment and force value into $amount and $currency so the real amount is saved into session instead + // of the amount and currency retreived from the POST. + if (!empty($paymentintent->currency) && !empty($paymentintent->amount)) { + $currency = strtoupper($paymentintent->currency); + $amount = $paymentintent->amount; + + // Correct the amount according to unit of currency + // See https://support.stripe.com/questions/which-zero-decimal-currencies-does-stripe-support + $arrayzerounitcurrency = array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (!in_array($currency, $arrayzerounitcurrency)) { + $amount = $amount / 100; + } + } } } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c8222c4c4aa..c822bfcdf96 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -343,6 +343,9 @@ if (empty($FinalPaymentAmt)) { if (empty($paymentType)) { $paymentType = $_SESSION["paymentType"]; } +if (empty($currencyCodeType)) { + $currencyCodeType = $_SESSION['currencyCodeType']; +} $fulltag = $FULLTAG; $tmptag = dolExplodeIntoArray($fulltag, '.', '='); @@ -403,15 +406,12 @@ if ($ispaymentok) { $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; } if (empty($paymentTypeId)) { - $paymentType = $_SESSION["paymentType"]; if (empty($paymentType)) { $paymentType = 'CB'; } $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; - dol_syslog("FinalPaymentAmt=".$FinalPaymentAmt." paymentTypeId=".$paymentTypeId." currencyCodeType=".$currencyCodeType, LOG_DEBUG, 0, '_payment'); // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) @@ -435,13 +435,19 @@ if ($ispaymentok) { $errmsg = 'Value of FinalPayment ('.$FinalPaymentAmt.') differs from value expected for membership ('.$amountexpected.'). May be a hack to try to pay a different amount ?'; $postactionmessages[] = $errmsg; $ispostactionok = -1; - dol_syslog("Failed to validate member: ".$errmsg, LOG_ERR, 0, '_payment'); + dol_syslog("Failed to validate member (bad amount check): ".$errmsg, LOG_ERR, 0, '_payment'); } } } // Security protection: - // TODO check that currency is same ? + if ($currencyCodeType && $currencyCodeType != $conf->currency) { // Check that currency is the good one + $error++; + $errmsg = 'Value of currencyCodeType ('.$currencyCodeType.') differs from value expected for membership ('.$conf->currency.'). May be a hack to try to pay a different amount ?'; + $postactionmessages[] = $errmsg; + $ispostactionok = -1; + dol_syslog("Failed to validate member (bad currency check): ".$errmsg, LOG_ERR, 0, '_payment'); + } if (! $error) { // We validate the member (no effect if it is already validated) @@ -766,15 +772,12 @@ if ($ispaymentok) { $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; } if (empty($paymentTypeId)) { - $paymentType = $_SESSION["paymentType"]; if (empty($paymentType)) { $paymentType = 'CB'; } $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; - // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { $db->begin(); @@ -866,13 +869,10 @@ if ($ispaymentok) { if ($paymentmethod == 'paypal') $paymentTypeId = $conf->global->PAYPAL_PAYMENT_MODE_FOR_PAYMENTS; if ($paymentmethod == 'stripe') $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; if (empty($paymentTypeId)) { - $paymentType = $_SESSION["paymentType"]; if (empty($paymentType)) $paymentType = 'CB'; $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; - // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($conf->facture->enabled)) { if (!empty($FinalPaymentAmt) && $paymentTypeId > 0 ) { @@ -964,8 +964,6 @@ if ($ispaymentok) { $don = new Don($db); $result = $don->fetch((int) $tmptag['DON']); if ($result) { - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - $paymentTypeId = 0; if ($paymentmethod == 'paybox') { $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; @@ -977,15 +975,12 @@ if ($ispaymentok) { $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; } if (empty($paymentTypeId)) { - $paymentType = $_SESSION["paymentType"]; if (empty($paymentType)) { $paymentType = 'CB'; } $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; - // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { $db->begin(); @@ -1074,8 +1069,6 @@ if ($ispaymentok) { $object = new Facture($db); $result = $object->fetch($ref); if ($result) { - $FinalPaymentAmt = $_SESSION["FinalPaymentAmt"]; - $paymentTypeId = 0; if ($paymentmethod == 'paybox') { $paymentTypeId = $conf->global->PAYBOX_PAYMENT_MODE_FOR_PAYMENTS; @@ -1087,15 +1080,12 @@ if ($ispaymentok) { $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; } if (empty($paymentTypeId)) { - $paymentType = $_SESSION["paymentType"]; if (empty($paymentType)) { $paymentType = 'CB'; } $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; - // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { $resultvalidate = $object->validate($user); @@ -1271,15 +1261,12 @@ if ($ispaymentok) { $paymentTypeId = $conf->global->STRIPE_PAYMENT_MODE_FOR_PAYMENTS; } if (empty($paymentTypeId)) { - $paymentType = $_SESSION["paymentType"]; if (empty($paymentType)) { $paymentType = 'CB'; } $paymentTypeId = dol_getIdFromCode($db, $paymentType, 'c_paiement', 'code', 'id', 1); } - $currencyCodeType = $_SESSION['currencyCodeType']; - // Do action only if $FinalPaymentAmt is set (session variable is cleaned after this page to avoid duplicate actions when page is POST a second time) if (!empty($FinalPaymentAmt) && $paymentTypeId > 0) { $resultvalidate = $object->validate($user); @@ -1687,7 +1674,7 @@ if ($ispaymentok) { print "\n\n"; -print "\n"; +print "\n"; htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix); From af1baf057b099b97cf7cf28986e17726671f4c19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 12:01:42 +0100 Subject: [PATCH 091/576] FIX #yogosha7789 --- htdocs/core/lib/functions.lib.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5d495e52c60..36e6f300819 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -835,7 +835,7 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = $out = dol_string_onlythesehtmltags($out, 0, 1, 1); - // We should also exclude non expected attributes + // We should also exclude non expected HTML attributes and clean content of some attributes. if (!empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)) { // Warning, the function may add a LF so we are forced to trim to compare with old $out without having always a difference and an infinit loop. $out = trim(dol_string_onlythesehtmlattributes($out)); @@ -6476,9 +6476,27 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes if (is_object($dom)) { for ($els = $dom->getElementsByTagname('*'), $i = $els->length - 1; $i >= 0; $i--) { for ($attrs = $els->item($i)->attributes, $ii = $attrs->length - 1; $ii >= 0; $ii--) { - // Delete attribute if not into allowed_attributes - if (! empty($attrs->item($ii)->name) && ! in_array($attrs->item($ii)->name, $allowed_attributes)) { - $els->item($i)->removeAttribute($attrs->item($ii)->name); + //var_dump($attrs->item($ii)); + if (! empty($attrs->item($ii)->name)) { + // Delete attribute if not into allowed_attributes + if (! in_array($attrs->item($ii)->name, $allowed_attributes)) { + $els->item($i)->removeAttribute($attrs->item($ii)->name); + } elseif (in_array($attrs->item($ii)->name, array('style'))) { + $valuetoclean = $attrs->item($ii)->value; + + do { + $oldvaluetoclean = $valuetoclean; + $valuetoclean = preg_replace('/\/\*.*\*\//m', '', $valuetoclean); // clean css comments + $valuetoclean = preg_replace('/position\s*:\s*[a-z]+/mi', '', $valuetoclean); + if ($els->item($i)->tagName == 'a') { // more paranoiac cleaning for clickable tags. + $valuetoclean = preg_replace('/display\s*://m', '', $valuetoclean); + $valuetoclean = preg_replace('/z-index\s*://m', '', $valuetoclean); + $valuetoclean = preg_replace('/\s+(top|left|right|bottom)\s*://m', '', $valuetoclean); + } + } while ($oldvaluetoclean != $valuetoclean); + + $attrs->item($ii)->value = $valuetoclean; + } } } } From a75ae6a8cfd3a2526fc1fee9fa45b08262497680 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 28 Nov 2021 12:11:03 +0100 Subject: [PATCH 092/576] Fix missing formsetup elements --- htdocs/core/class/html.formsetup.class.php | 144 +++++++++++++++++- htdocs/modulebuilder/template/admin/setup.php | 85 ++++++----- 2 files changed, 189 insertions(+), 40 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 6f2ec2acfb6..a8ed08587ed 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -44,6 +44,47 @@ class FormSetup /** @var int */ protected $maxItemRank; + /** + * this is an html string display before output form + * @var string + */ + public $htmlBeforeOutputForm = ''; + + /** + * this is an html string display after output form + * @var string + */ + public $htmlAfterOutputForm = ''; + + /** + * this is an html string display on buttons zone + * @var string + */ + public $htmlOutputMoreButton = ''; + + + /** + * + * @var array + */ + public $formAttributes = array( + 'action' => '', // set in __construct + 'method' => 'POST' + ); + + /** + * an list of hidden inputs used only in edit mode + * @var array + */ + public $formHiddenInputs = array(); + + + /** + * the value of action attribute of form + * @var string + */ + public $formAction; + /** * Constructor * @@ -55,6 +96,11 @@ class FormSetup global $langs; $this->db = $db; $this->form = new Form($this->db); + $this->formAttributes['action'] = $_SERVER["PHP_SELF"]; + + $this->formHiddenInputs['token'] = newToken(); + $this->formHiddenInputs['action'] = 'update'; + if ($outputLangs) { $this->langs = $outputLangs; @@ -63,6 +109,38 @@ class FormSetup } } + /** + * a quick method to sanitize html attributes + * @param string $var the string to sanitize + * @return string + */ + static public function sanitizeHtmlAttribute($var) + { + $var = preg_replace("/\r|\n/", "", $var); + return htmlspecialchars($var, ENT_QUOTES); + } + + /** + * Generae an attributes string form an input array + * @param array $attributes an array of attributes keys and values, + * @return string + */ + static public function generateAttributesStringFromArray($attributes) + { + $Aattr = array(); + if (is_array($attributes)) { + foreach ($attributes as $attribute => $value) { + if (is_array($value) || is_object($value)) { + continue; + } + $Aattr[] = $attribute.'="'.self::sanitizeHtmlAttribute($value).'"'; + } + } + + return !empty($Aattr)?implode(' ', $Aattr):''; + } + + /** * @param bool $editMode true will display output on edit mod * @return string @@ -83,12 +161,70 @@ class FormSetup if ($reshook > 0) { return $hookmanager->resPrint; } else { - $out = ''; + $out = ''; + $out.= $this->htmlBeforeOutputForm; + if ($editMode) { - $out .= ''; + $out.= 'formAttributes) . ' >'; + + // generate hidden values from $this->formHiddenInputs + if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) { + foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) { + $out.= ''; + } + } } - $out .= ''; + // generate output table + $out .= $this->generateTableOutput($editMode); + + + $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutputButton', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + + if ($reshook > 0) { + return $hookmanager->resPrint; + } elseif ($editMode) { + $out .= '
'; // Todo : remove this
by adding style to form-setup-button-container css class in all themes + $out .= '
'; // Todo : remove .center by adding style to form-setup-button-container css class in all themes + $out.= $this->htmlOutputMoreButton; + $out .= ''; // Todo fix dolibarr style for
'; $out .= ''; $out .= ''; $out .= ' '; @@ -247,7 +383,7 @@ class FormSetup public function exportItemsAsParamsArray() { $arrayofparameters = array(); - foreach ($this->items as $key => $item) { + foreach ($this->items as $item) { $arrayofparameters[$item->confKey] = array( 'type' => $item->getType(), 'enabled' => $item->enabled diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 5690d18678b..6836585285c 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -88,6 +88,9 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), ); +$error = 0; +$setupnotempty = 0; + // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only $useFormSetup = 0; // Convert arrayofparameter into a formSetup object @@ -95,35 +98,44 @@ if (!empty($arrayofparameters) && $useFormSetup && (float) DOL_VERSION >= 15) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; $formSetup = new FormSetup($db); - foreach ($arrayofparameters as $key => $val) { - if ($val['enabled']) { - $item = $formSetup->newItem($key); + // you can use the param convertor + $formSetup->addItemsFromParamsArray($arrayofparameters); - if ($val['type'] == 'string') { - $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; - $item->cssClass = $val['css']; - } - if ($val['type'] == 'thirdparty_type') { - $item->setAsThirdpartyType(); - } - if ($val['type'] == 'yesno') { - $formSetup->newItem($key)->setAsYesNo(); - } - if ($val['type'] == 'emailtemplate:thirdparty') { - $formSetup->newItem($key)->setAsEmailTemplate('thirdparty'); - } - if ($val['type'] == 'securekey') { - $formSetup->newItem($key)->setAsSecureKey()->enabled = 0; // disabled - } - if ($val['type'] == 'product') { - $formSetup->newItem($key)->setAsProduct(); - } - } - } + // or use the new system see exemple as follow (or use both because you can ;-) ) + + /* + // Hôte + $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); + $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; + $item->cssClass = 'minwidth500'; + + // Setup conf MYMODULE_MYPARAM1 as a simple string input + $item = $formSetup->newItem('MYMODULE_MYPARAM1'); + + // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title + $item = $formSetup->newItem('MYMODULE_MYPARAM2'); + $item->nameText = $item->getNameText().' more html text '; + + // Setup conf MYMODULE_MYPARAM3 + $item = $formSetup->newItem('MYMODULE_MYPARAM3'); + $item->setAsThirdpartyType(); + + // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style + $formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); + + // Setup conf MYMODULE_MYPARAM5 + $formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); + + // Setup conf MYMODULE_MYPARAM6 + $formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + + // Setup conf MYMODULE_MYPARAM7 + $formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); + */ + + $setupnotempty = count($formSetup->items); } -$error = 0; -$setupnotempty = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -258,13 +270,13 @@ echo ''.$langs->trans("MyModuleSetupPage").'< if ($action == 'edit') { - print ''; - print ''; - print ''; - if ($useFormSetup && (float) DOL_VERSION >= 15) { print $formSetup->generateOutput(true); } else { + print ''; + print ''; + print ''; + print '
' . $this->langs->trans("Parameter") . '
'; print ''; @@ -350,18 +362,19 @@ if ($action == 'edit') { } } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - } - print '
'; - print ''; - print '
'; - print ''; + print '
'; + print ''; + print '
'; + + print ''; + } + print '
'; } else { if ($useFormSetup && (float) DOL_VERSION >= 15) { if (!empty($formSetup->items)) { print $formSetup->generateOutput(); - $setupnotempty = count($formSetup->items); } } else { if (!empty($arrayofparameters)) { From f08adef1e8d6eef6910eb8cd7803e3537216c138 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 28 Nov 2021 12:12:16 +0100 Subject: [PATCH 093/576] Fix ExpenseReport define template Can use template for expense report notification but not define it :/ --- htdocs/admin/mails_templates.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 7d8bc2f22b1..0adc526d69e 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -225,6 +225,9 @@ if (!empty($conf->contrat->enabled) && !empty($user->rights->contrat->lire)) { if (!empty($conf->ticket->enabled) && !empty($user->rights->ticket->read)) { $elementList['ticket_send'] = img_picto('', 'ticket', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTicket')); } +if (!empty($conf->expensereport->enabled) && !empty($user->rights->expensereport->lire)) { + $elementList['expensereport_send'] = img_picto('', 'trip', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToTExpenseReport')); +} if (!empty($conf->agenda->enabled)) { $elementList['actioncomm_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventPush')); } From 29437a22b9364314cafd4021547f885a2ab51c54 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 28 Nov 2021 12:15:31 +0100 Subject: [PATCH 094/576] Fix comment and remove not use global --- htdocs/core/class/html.formsetup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a8ed08587ed..149e416fd81 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -121,7 +121,7 @@ class FormSetup } /** - * Generae an attributes string form an input array + * Generate an attributes string form an input array * @param array $attributes an array of attributes keys and values, * @return string */ @@ -690,7 +690,7 @@ class FormSetupItem */ public function generateInputField() { - global $conf, $user; + global $conf; if (!empty($this->fieldOverride)) { return $this->fieldOverride; From e97e0e4f17d315c989d07ab1fd640febab4fb921 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 28 Nov 2021 12:18:09 +0100 Subject: [PATCH 095/576] Fix remove not used propertie --- htdocs/core/class/html.formsetup.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 149e416fd81..13dd3a8694c 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -79,12 +79,6 @@ class FormSetup public $formHiddenInputs = array(); - /** - * the value of action attribute of form - * @var string - */ - public $formAction; - /** * Constructor * From 5a165ae2bfd5d66e6b895120de4bb7acb1b1a3e8 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Sun, 28 Nov 2021 14:40:15 +0100 Subject: [PATCH 096/576] FIX PDF_NOLD_PRODUCT_LABEL --- htdocs/admin/pdf.php | 23 +++++++++++++++++++++++ htdocs/core/lib/pdf.lib.php | 19 ++++++++++++++----- htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/fr_FR/admin.lang | 2 ++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index c22d365d932..c4ae5d59225 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -170,6 +170,13 @@ if ($action == 'update') { dolibarr_set_const($db, "PDF_USE_A", GETPOST('PDF_USE_A', 'alpha'), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('PDF_BOLD_PRODUCT_LABEL')) { + dolibarr_set_const($db, "PDF_BOLD_PRODUCT_LABEL", GETPOST('PDF_BOLD_PRODUCT_LABEL', 'alpha'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')){ + dolibarr_set_const($db, "PDF_BOLD_PRODUCT_REF_AND_PERIOD", GETPOST('PDF_BOLD_PRODUCT_REF_AND_PERIOD', 'alpha'), 'chaine', 0, '', $conf->entity); + } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); @@ -499,6 +506,22 @@ if ($conf->use_javascript_ajax) { } print '
'.$langs->trans("BoldLabelOnPDF").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_BOLD_PRODUCT_LABEL'); +} else { + print $form->selectyesno('PDF_BOLD_PRODUCT_LABEL', (!empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) ? $conf->global->PDF_BOLD_PRODUCT_LABEL : 0, 1); +} +print '
'.$langs->trans("BoldRefAndPeriodOnPDF").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('PDF_BOLD_PRODUCT_REF_AND_PERIOD'); +} else { + print $form->selectyesno('PDF_BOLD_PRODUCT_REF_AND_PERIOD', (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) ? $conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD : 0, 1); +} +print '
'.$langs->trans("HideDescOnPDF").''; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 5121506087c..7a78db5a14e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1363,7 +1363,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description short of product line $libelleproduitservice = $label; if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) { - // This part of code is bugged. It introduces a HTML tag making the label a html string but without converting \n into br if it was a full text non html string before. + if (!dol_textishtml($libelleproduitservice)){ + $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); + } $libelleproduitservice = ''.$libelleproduitservice.''; } } @@ -1375,7 +1377,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($prodser->sousprods) && is_array($prodser->sousprods) && count($prodser->sousprods)) { $tmparrayofsubproducts = reset($prodser->sousprods); foreach ($tmparrayofsubproducts as $subprodval) { - $libelleproduitservice .= "\n * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'; + $libelleproduitservice .= "__N__ * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3].' ('.$subprodval[1].')'; } } } @@ -1419,7 +1421,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (empty($hidedesc)) { if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) { - $libelleproduitservice = $desc."\n".$libelleproduitservice; + $libelleproduitservice = $desc."__N__".$libelleproduitservice; } else { if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { $libelleproduitservice = $desc; @@ -1493,10 +1495,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { + if (!dol_textishtml($libelleproduitservice)){ + $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); + } $ref_prodserv = ''.$ref_prodserv.''; - } + // $prefix_prodserv and $ref_prodser are not HTML var + } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; - + // Add an additional description for the category products if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -1527,6 +1533,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } //print '>'.$outputlangs->charset_output.','.$period; if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { + if (!dol_textishtml($libelleproduitservice)){ + $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); + } $libelleproduitservice .= ''."__N__ ".$period.''; } else { $libelleproduitservice .= "__N__".$period; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c258df38441..c36f29fa0d7 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - admin +BoldRefAndPeriodOnPDF=Bold reference and period in PDF +BoldLabelOnPDF=Bold label in PDF Foundation=Foundation Version=Version Publisher=Publisher diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 0b4d7aa4f10..9d2de4d5ca8 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -1,4 +1,6 @@ # Dolibarr language file - Source file is en_US - admin +BoldRefAndPeriodOnPDF=Mettre en gras la référence et la période dans les PDF +BoldLabelOnPDF=Mettre en gras le label des produits dans les PDF Foundation=Association Version=Version Publisher=Editeur From a933793b8a43903fb6c514ae89da9df96690f9af Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 28 Nov 2021 13:42:25 +0000 Subject: [PATCH 097/576] Fixing style errors. --- htdocs/admin/pdf.php | 2 +- htdocs/core/lib/pdf.lib.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index c4ae5d59225..18a4ca0825f 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -173,7 +173,7 @@ if ($action == 'update') { if (GETPOSTISSET('PDF_BOLD_PRODUCT_LABEL')) { dolibarr_set_const($db, "PDF_BOLD_PRODUCT_LABEL", GETPOST('PDF_BOLD_PRODUCT_LABEL', 'alpha'), 'chaine', 0, '', $conf->entity); } - if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')){ + if (GETPOSTISSET('PDF_BOLD_PRODUCT_REF_AND_PERIOD')) { dolibarr_set_const($db, "PDF_BOLD_PRODUCT_REF_AND_PERIOD", GETPOST('PDF_BOLD_PRODUCT_REF_AND_PERIOD', 'alpha'), 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 7a78db5a14e..2d8ce3b2996 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1363,7 +1363,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description short of product line $libelleproduitservice = $label; if (!empty($libelleproduitservice) && !empty($conf->global->PDF_BOLD_PRODUCT_LABEL)) { - if (!dol_textishtml($libelleproduitservice)){ + if (!dol_textishtml($libelleproduitservice)) { $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); } $libelleproduitservice = ''.$libelleproduitservice.''; @@ -1495,14 +1495,14 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } if (!empty($ref_prodserv) && !empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { - if (!dol_textishtml($libelleproduitservice)){ + if (!dol_textishtml($libelleproduitservice)) { $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); } $ref_prodserv = ''.$ref_prodserv.''; // $prefix_prodserv and $ref_prodser are not HTML var - } + } $libelleproduitservice = $prefix_prodserv.$ref_prodserv.$libelleproduitservice; - + // Add an additional description for the category products if (!empty($conf->global->CATEGORY_ADD_DESC_INTO_DOC) && $idprod && !empty($conf->categorie->enabled)) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -1533,7 +1533,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } //print '>'.$outputlangs->charset_output.','.$period; if (!empty($conf->global->PDF_BOLD_PRODUCT_REF_AND_PERIOD)) { - if (!dol_textishtml($libelleproduitservice)){ + if (!dol_textishtml($libelleproduitservice)) { $libelleproduitservice = str_replace("\n", '__N__', $libelleproduitservice); } $libelleproduitservice .= ''."__N__ ".$period.''; From 5d31bd441eb5b094bcf1f91eb40d4039b4c41cda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:34:08 +0100 Subject: [PATCH 098/576] Fix php compatibility --- htdocs/core/lib/memory.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 557bbe6dcf5..032d567d35b 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists $rescode = $dolmemcache->getResultCode(); if ($rescode == 0) { - return is_countable($data) ? count($data) : 0; + return is_array($data) ? count($data) : 0; } else { return -$rescode; } @@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0) //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists if ($result) { - return is_countable($data) ? count($data) : 0; + return is_array($data) ? count($data) : 0; } else { return -1; } From ce651fae587669831f88ca3ac64ba31d10800299 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:34:08 +0100 Subject: [PATCH 099/576] Fix php compatibility --- htdocs/core/lib/memory.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index 1300c1b771f..b3fd7109343 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists $rescode = $dolmemcache->getResultCode(); if ($rescode == 0) { - return is_countable($data) ? count($data) : 0; + return is_array($data) ? count($data) : 0; } else { return -$rescode; } @@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0) //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists if ($result) { - return is_countable($data) ? count($data) : 0; + return is_array($data) ? count($data) : 0; } else { return -1; } From ca11dcae22ff60af1bed4464ba5ac22e6d1c1596 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:41:19 +0100 Subject: [PATCH 100/576] Fix php compatibility --- htdocs/core/lib/memory.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/memory.lib.php b/htdocs/core/lib/memory.lib.php index b3fd7109343..94884ea302d 100644 --- a/htdocs/core/lib/memory.lib.php +++ b/htdocs/core/lib/memory.lib.php @@ -93,7 +93,7 @@ function dol_setcache($memoryid, $data, $expire = 0) $dolmemcache->add($memoryid, $data, $expire); // This fails if key already exists $rescode = $dolmemcache->getResultCode(); if ($rescode == 0) { - return is_array($data) ? count($data) : 0; + return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0); } else { return -$rescode; } @@ -113,7 +113,7 @@ function dol_setcache($memoryid, $data, $expire = 0) //$dolmemcache->setOption(Memcached::OPT_COMPRESSION, false); $result = $dolmemcache->add($memoryid, $data, false, $expire); // This fails if key already exists if ($result) { - return is_array($data) ? count($data) : 0; + return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0); } else { return -1; } From c41578a3c360560b18f6af20d442306c03135ef8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 28 Nov 2021 15:43:22 +0100 Subject: [PATCH 101/576] Fix php compatibility --- htdocs/categories/index.php | 2 +- htdocs/categories/viewcat.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 708fb3a3e83..c585217dfda 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -186,7 +186,7 @@ foreach ($fulltree as $key => $val) { ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" : $categstatic->getObjectsInCateg($type, 1); - $counter = "".(is_countable($elements) ? count($elements) : '0')."".(is_array($elements) ? count($elements) : '0')."".(is_countable($elements) ? count($elements) : '0')."".(is_array($elements) ? count($elements) : '0')."
'.$langs->trans("Web").''; print img_picto('', 'globe', 'class="pictofixedwidth"'); - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index 271cb09fa81..93054dad234 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -119,7 +119,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { } //if (!empty($objp->$key)) // $objp->array_options[$tmpkey] = $objp->$key; - //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; + //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', $object->table_element); //$objp->$tmpkey; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5dd392ad065..040d3c519d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7862,7 +7862,7 @@ abstract class CommonObject switch ($mode) { case "view": - $out .= $extrafields->showOutputField($key, $value); + $out .= $extrafields->showOutputField($key, $value, '', $this->table_element); break; case "create": $out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 057b1d9ace9..e73f83d1340 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -42,12 +42,6 @@ class ExtraFields */ public $db; - /** - * @var array Array with type of element (for what object is the extrafield) - * @deprecated - */ - public $attribute_elementtype; - /** * @var array Array with type of the extra field * @deprecated @@ -60,90 +54,12 @@ class ExtraFields */ public $attribute_label; - /** - * @var array Array with size of extra field - * @deprecated - */ - public $attribute_size; - /** * @var array Array with list of possible values for some types of extra fields * @deprecated */ public $attribute_choice; - /** - * @var array Array to store compute formula for computed fields - * @deprecated - */ - public $attribute_computed; - - /** - * @var array Array to store default value - * @deprecated - */ - public $attribute_default; - - /** - * @var array Array to store if attribute is unique or not - * @deprecated - */ - public $attribute_unique; - - /** - * @var array Array to store if attribute is required or not - * @deprecated - */ - public $attribute_required; - - /** - * @var array Array to store parameters of attribute (used in select type) - * @deprecated - */ - public $attribute_param; - - /** - * @var array Array to store position of attribute - * @deprecated - */ - public $attribute_pos; - - /** - * @var array Array to store if attribute is editable regardless of the document status - * @deprecated - */ - public $attribute_alwayseditable; - - /** - * @var array Array to store permission to check - * @deprecated - */ - public $attribute_perms; - - /** - * @var array Array to store language file to translate label of values - * @deprecated - */ - public $attribute_langfile; - - /** - * @var array Array to store if field is visible by default on list - * @deprecated - */ - public $attribute_list; - - /** - * @var array Array to store if field is summable - * @deprecated - */ - public $attribute_totalizable; - - /** - * @var array Array to store entity id of extrafield - * @deprecated - */ - public $attribute_entityid; - /** * @var array New array to store extrafields definition @@ -203,17 +119,8 @@ class ExtraFields $this->attributes = array(); // For old usage - $this->attribute_elementtype = array(); $this->attribute_type = array(); $this->attribute_label = array(); - $this->attribute_size = array(); - $this->attribute_computed = array(); - $this->attribute_default = array(); - $this->attribute_unique = array(); - $this->attribute_required = array(); - $this->attribute_perms = array(); - $this->attribute_langfile = array(); - $this->attribute_list = array(); } /** @@ -238,7 +145,7 @@ class ExtraFields * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not * @param int $totalizable Is a measure. Must show a total on lists - * @param int $printable Is extrafield displayed on PDF + * @param int $printable Is extrafield displayed on PDF * @return int <=0 if KO, >0 if OK */ public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0, $printable = 0) @@ -873,7 +780,7 @@ class ExtraFields // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ... + * Load array this->attributes (and some old this->attribute_xxx like attribute_label, attribute_type, ... * * @param string $elementtype Type of element ('' = all or $object->table_element like 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...). * @param boolean $forceload Force load of extra fields whatever is status of cache. @@ -932,20 +839,6 @@ class ExtraFields // Old usage $this->attribute_type[$tab->name] = $tab->type; $this->attribute_label[$tab->name] = $tab->label; - $this->attribute_size[$tab->name] = $tab->size; - $this->attribute_elementtype[$tab->name] = $tab->elementtype; - $this->attribute_default[$tab->name] = $tab->fielddefault; - $this->attribute_computed[$tab->name] = $tab->fieldcomputed; - $this->attribute_unique[$tab->name] = $tab->fieldunique; - $this->attribute_required[$tab->name] = $tab->fieldrequired; - $this->attribute_param[$tab->name] = ($tab->param ? jsonOrUnserialize($tab->param) : ''); - $this->attribute_pos[$tab->name] = $tab->pos; - $this->attribute_alwayseditable[$tab->name] = $tab->alwayseditable; - $this->attribute_perms[$tab->name] = (strlen($tab->perms) == 0 ? 1 : $tab->perms); - $this->attribute_langfile[$tab->name] = $tab->langs; - $this->attribute_list[$tab->name] = $tab->list; - $this->attribute_totalizable[$tab->name] = $tab->totalizable; - $this->attribute_entityid[$tab->name] = $tab->entity; // New usage $this->attributes[$tab->elementtype]['type'][$tab->name] = $tab->type; @@ -1028,20 +921,10 @@ class ExtraFields $totalizable = $this->attributes[$extrafieldsobjectkey]['totalizable'][$key]; $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } else // Old usage - { + } else { + // Old usage $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; - $size = $this->attribute_size[$key]; - $elementtype = $this->attribute_elementtype[$key]; // Seems not used - $default = $this->attribute_default[$key]; - $computed = $this->attribute_computed[$key]; - $unique = $this->attribute_unique[$key]; - $required = $this->attribute_required[$key]; - $param = $this->attribute_param[$key]; - $langfile = $this->attribute_langfile[$key]; - $list = $this->attribute_list[$key]; - $totalizable = $this->attribute_totalizable[$key]; $hidden = (empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } @@ -1626,20 +1509,10 @@ class ExtraFields $list = dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) - } else // Old usage - { - //dol_syslog("Warning: parameter 'extrafieldsobjectkey' is missing", LOG_WARNING); + } else { + // Old usage $label = $this->attribute_label[$key]; $type = $this->attribute_type[$key]; - $size = $this->attribute_size[$key]; - $default = $this->attribute_default[$key]; - $computed = $this->attribute_computed[$key]; - $unique = $this->attribute_unique[$key]; - $required = $this->attribute_required[$key]; - $param = $this->attribute_param[$key]; - $perms = dol_eval($this->attribute_perms[$key], 1); - $langfile = $this->attribute_langfile[$key]; - $list = dol_eval($this->attribute_list[$key], 1); $help = ''; // Not supported with old syntax $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 0c1d34efa08..d1145229db7 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -41,7 +41,7 @@ $langs->load("modulebuilder"); print ''.$langs->trans("DefineHereComplementaryAttributes", $textobject).'
'."\n"; print '
'; -// Load attribute_label +// Load $extrafields->attributes $extrafields->fetch_name_optionals_label($elementtype); print '
'; diff --git a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php index 12b688d9b61..cab6779bf8c 100644 --- a/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php +++ b/htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php @@ -157,7 +157,7 @@ class InterfaceTicketEmail extends DolibarrTriggers if (is_array($object->array_options) && count($object->array_options) > 0) { foreach ($object->array_options as $key => $value) { $key = substr($key, 8); // remove "options_" - $message_admin .= '
  • '.$langs->trans($extraFields->attributes[$object->element]['label'][$key]).' : '.$extraFields->showOutputField($key, $value).'
  • '; + $message_admin .= '
  • '.$langs->trans($extraFields->attributes[$object->element]['label'][$key]).' : '.$extraFields->showOutputField($key, $value, '', $object->table_element).'
  • '; } } $message_admin .= ''; diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 5b523d8d7e8..fc3054fdd51 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -635,7 +635,7 @@ class ProductFournisseur extends Product * @param int $limit Limit * @param int $offset Offset * @param int $socid Filter on a third party id - * @return array Array of Products with new properties to define supplier price + * @return array Array of ProductFournisseur with new properties to define supplier price */ public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0, $socid = 0) { diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index dd17a2be4b0..11a34b939a2 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -99,7 +99,6 @@ if ($result) { $num = $db->num_rows($result); $i = 0; - // Load attribute_label print '
    '; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", "", "", $sortfield, $sortorder); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 02e0211c01d..b79fe5fb843 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -1211,7 +1211,7 @@ END; $obj = $db->fetch_object($resql); foreach ($extralabels as $key => $value) { if (!empty($arrayfields['ef.'.$key]['checked']) && !empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - print '"; + print '"; } } } diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 00eff71da78..1a11b16d1ea 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -297,7 +297,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { if (is_array($object->array_options) && count($object->array_options) > 0) { foreach ($object->array_options as $key => $value) { $key = substr($key, 8); // remove "options_" - $message_admin .= '
  • '.$langs->trans($extrafields->attributes[$object->element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value).'
  • '; + $message_admin .= '
  • '.$langs->trans($extrafields->attributes[$object->table_element]['label'][$key]).' : '.$extrafields->showOutputField($key, $value, '', $object->table_element).'
  • '; } } $message_admin .= ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index db5f5d8d754..4fbfd29106a 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -651,7 +651,7 @@ if ($action == "view_ticketlist") { } print '>'; $tmpkey = 'options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); + print $extrafields->showOutputField($key, $obj->$tmpkey, '', $object->table_element); print ''; } } From e3e4b154e7cddca44ad234642bdef9c2e2459657 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 01:04:32 +0100 Subject: [PATCH 109/576] Fix partnership --- htdocs/core/lib/company.lib.php | 1 + htdocs/langs/en_US/partnership.lang | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 313dd5d8fbe..2b8aad7453c 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -274,6 +274,7 @@ function societe_prepare_head(Societe $object) if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'thirdparty') { if (!empty($user->rights->partnership->read)) { + $langs->load("partnership"); $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; $head[$h][0] = DOL_URL_ROOT.'/societe/partnership.php?socid='.$object->id; $head[$h][1] = $langs->trans("Partnership"); diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index 0eb73c17920..f542bfab670 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -19,7 +19,7 @@ ModulePartnershipName=Partnership management PartnershipDescription=Module Partnership management PartnershipDescriptionLong= Module Partnership management - +Partnership=Partnership AddPartnership=Add partnership CancelPartnershipForExpiredMembers=Partnership: Cancel partnership of members with expired subscriptions PartnershipCheckBacklink=Partnership: Check referring backlink From 1fa3e9f37d1d971b4b00ed89533f8fa2ccaa4f18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 29 Nov 2021 01:13:43 +0100 Subject: [PATCH 110/576] Look and feel v15 --- htdocs/compta/bank/various_payment/card.php | 7 +++---- htdocs/compta/bank/various_payment/list.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index d4245594447..bd81a0433eb 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -415,7 +415,7 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''; } @@ -490,9 +490,8 @@ if ($action == 'create') { $langs->load("projects"); print ''; } diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index dda68a096a1..fec2d025c7a 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -160,7 +160,7 @@ $arrayfields = array( 'ref' =>array('label'=>"Ref", 'checked'=>1, 'position'=>100), 'label' =>array('label'=>"Label", 'checked'=>1, 'position'=>110), 'datep' =>array('label'=>"DatePayment", 'checked'=>1, 'position'=>120), - 'datev' =>array('label'=>"DateValue", 'checked'=>1, 'position'=>130), + 'datev' =>array('label'=>"DateValue", 'checked'=>-1, 'position'=>130), 'type' =>array('label'=>"PaymentMode", 'checked'=>1, 'position'=>140), 'project' =>array('label'=>"Project", 'checked'=>1, 'position'=>200, "enabled"=>!empty($conf->projet->enabled)), 'bank' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>300, "enabled"=>!empty($conf->banque->enabled)), diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 3118b576e1e..10768184b1b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3421,7 +3421,7 @@ tr.liste_titre.box_titre td table td, .bordernooddeven tr td { } table.border td, table.bordernooddeven td, div.border div div.tagtd { - padding: 2px 4px 2px 4px; + padding: 4px 4px 4px 4px; border: 1px solid #f0f0f0; border-collapse: collapse; } From 5bdaab8dcb6f35ee79f7f8e50f53d90f1536900e Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 29 Nov 2021 14:30:04 +0100 Subject: [PATCH 111/576] Fix duplicated code --- htdocs/core/class/commonobject.class.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 040d3c519d9..cc74c30c191 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4872,13 +4872,9 @@ abstract class CommonObject $reshook = 0; //if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) { if (is_object($hookmanager)) { // Old code is commented on preceding line. - if (empty($line->fk_parent_line)) { - $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); - $reshook = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } else { - $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines, 'fk_parent_line'=>$line->fk_parent_line); - $reshook = $hookmanager->executeHooks('printOriginObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } + $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); + if (!empty($line->fk_parent_line)) { $parameters['fk_parent_line'] = $line->fk_parent_line; } + $reshook = $hookmanager->executeHooks('printOriginObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } if (empty($reshook)) { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); From c529d1a928aef79b1a8c6518761b1f048d35b408 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 29 Nov 2021 15:00:23 +0100 Subject: [PATCH 112/576] update inventory add replace work --- .../inventory/ajax/searchfrombarcode.php | 9 ++--- .../inventory/class/inventory.class.php | 1 + htdocs/product/inventory/inventory.php | 40 ++++++++++++------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 884aff9ec12..1a613c7a837 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -50,8 +50,6 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } require '../../../main.inc.php'; -//include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; -$object = new Inventory($db); $action = GETPOST("action", "alpha"); @@ -87,12 +85,11 @@ if ($action == "existbarcode" && !empty($barcode)) { } else { $response = array('status'=>'success','message'=>'Warehouse found','warehouse'=>$warehouseid); } - $response = json_encode($response); } else { - $response = "No results found for barcode"; + $response = array('status'=>'error','errorcode'=>'NotFound','message'=>"No results found for barcode"); } } else { - $response = "Error on action"; + $response = array('status'=>'error','errorcode'=>'ActionError','message'=>"Error on action"); } - +$response = json_encode($response); echo $response; diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index b972e44245b..092d98ea854 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -26,6 +26,7 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 4dcda1bba41..910084c12fe 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -571,19 +571,19 @@ if ($object->id > 0) { if(productinput == ""){ productinput = 0 } - tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput}); + tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput,\'fetched\':false}); }) - tabproduct.forEach(product => { + textarray.forEach(function(element,index){ switch(barcodemode){ case "barcodeforautodetect": - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode",true); - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial",true); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode",true); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial",true); break; case "barcodeforproduct": //TODO: create product !exist + ajout - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"barcode"); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode"); break; case "barcodeforlotserial": - barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,"lotserial"); + barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial"); break; default: alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\""); @@ -601,8 +601,10 @@ if ($object->id > 0) { } - function barcodeserialforproduct(textarray,product,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ - textarray.forEach(function(element,index){ + function barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,mode,autodetect=false){ + BarcodeIsInProduct=0; + BarcodeSuccess=false; + tabproduct.forEach(product => { $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product}, type: \'POST\', @@ -611,6 +613,7 @@ if ($object->id > 0) { response = JSON.parse(response); if(response.status == "success"){ console.log(response.message); + BarcodeSucess=true; }else{ console.error(response.message); } @@ -618,9 +621,8 @@ if ($object->id > 0) { error : function(output) { console.error("Error on barcodeserialforproduct function"); }, - }); + }); console.log("Product "+(index+=1)+": "+element); - BarCodeDoesNotExist=0; if(mode == "barcode"){ testonproduct = product.Barcode }else if (mode == "lotserial"){ @@ -628,15 +630,23 @@ if ($object->id > 0) { } if(testonproduct == element){ if(selectaddorreplace == "add"){ - productqty = parseInt(product.Qty,10) - product.Qty = productqty + barcodeproductqty + productqty = parseInt(product.Qty,10); + product.Qty = productqty + parseInt(barcodeproductqty,10); }else if(selectaddorreplace == "replace"){ - product.Qty = barcodeproductqty + if(product.fetched == false){ + product.Qty = barcodeproductqty + product.fetched=true + }else{ + productqty = parseInt(product.Qty,10); + product.Qty = productqty + parseInt(barcodeproductqty,10); + } } - }else{ - BarCodeDoesNotExist+=1; + BarcodeIsInProduct+=1; } }) + if(BarcodeIsInProduct==0 && BarcodeSuccess){ + //addproduct to db and tabproduct + } } '; print ''; From 819a76e16a8dd33479a906cf674c4cadb1c111b5 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Fri, 27 Aug 2021 15:31:31 +0200 Subject: [PATCH 113/576] remove some deprecated html attributes https://developer.mozilla.org/en-US/docs/web/html/element/td#attr-align --- htdocs/bom/tpl/linkedobjectblock.tpl.php | 4 ++-- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 ++-- htdocs/reception/tpl/linkedobjectblock.tpl.php | 4 ++-- htdocs/theme/md/style.css.php | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index c42da9bdb19..2737b425c9c 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -54,7 +54,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; - echo ''; - echo ''; + echo ''; echo ''; echo ''; - echo ''; - echo ''; + echo ''; + echo ''; echo ' - - + + '; } @@ -622,6 +622,9 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index d7bd8bee9b4..781f2037dba 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -486,28 +486,36 @@ if (!empty($conf->global->MAIN_UPLOAD_DOC)) { $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $maxphp = @ini_get('upload_max_filesize'); // In unknown if (preg_match('/k$/i', $maxphp)) { + $maxphp = preg_replace('/k$/i', '', $maxphp); $maxphp = $maxphp * 1; } if (preg_match('/m$/i', $maxphp)) { + $maxphp = preg_replace('/m$/i', '', $maxphp); $maxphp = $maxphp * 1024; } if (preg_match('/g$/i', $maxphp)) { + $maxphp = preg_replace('/g$/i', '', $maxphp); $maxphp = $maxphp * 1024 * 1024; } if (preg_match('/t$/i', $maxphp)) { + $maxphp = preg_replace('/t$/i', '', $maxphp); $maxphp = $maxphp * 1024 * 1024 * 1024; } $maxphp2 = @ini_get('post_max_size'); // In unknown if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = preg_replace('/k$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1; } if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = preg_replace('/m$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024; } if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = preg_replace('/g$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024 * 1024; } if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = preg_replace('/t$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; } // Now $max and $maxphp and $maxphp2 are in Kb diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 7d261a73f7a..06d470b9b57 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -68,6 +68,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startyear = GETPOST('search_date_startyear', 'int'); @@ -87,6 +88,8 @@ $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $search_fk_projet=GETPOST("search_fk_projet", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$type = GETPOST("type", "int"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -498,7 +501,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; @@ -1298,6 +1301,9 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 3c987cd1cfa..5e85daf06ba 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('stocks', 'productbatch', 'other', 'users')); // Get parameters $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productlotlist'; // To manage different context of search @@ -64,7 +65,7 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $object = new Productlot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->productbatch->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('product_lotlist')); // Fetch optionals attributes and labels @@ -215,7 +216,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if ( !empty($extrafields->attributes[$object->table_element]['label']) && ($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } if ($object->ismultientitymanaged == 1) { @@ -340,7 +341,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -424,9 +425,9 @@ foreach ($object->fields as $key => $val) { if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + print $object->showInputField($val, $key, !empty($search[$key])?$search[$key]:0, '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print ''; } @@ -477,7 +478,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -535,6 +536,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { From 63c7ab0302d8aeeb10a7544b04bef6b8c6b0a676 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Wed, 1 Dec 2021 14:29:24 +0700 Subject: [PATCH 134/576] Fix typo 'usercanreceived' -> 'usercanreceive' in 'card.php' --- htdocs/fourn/commande/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 92501d57d1d..616cda0376f 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1082,7 +1082,7 @@ if (empty($reshook)) { } // Set status of reception (complete, partial, ...) - if ($action == 'livraison' && $usercanreceived) { + if ($action == 'livraison' && $usercanreceive) { if ($cancel) { $action = ''; } else { @@ -2510,7 +2510,7 @@ if ($action == 'create') { } if (in_array($object->statut, array(3, 4, 5))) { - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceived) { + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceive) { print ''; } else { print ''; @@ -2528,7 +2528,7 @@ if ($action == 'create') { // Classify received (this does not record reception) if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) { - if ($usercanreceived) { + if ($usercanreceive) { print ''; } } @@ -2647,7 +2647,7 @@ if ($action == 'create') { print '
    '; if ($action == 'classifyreception') { - if ($usercanreceived && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { + if ($usercanreceive && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) { // Set status to received (action=livraison) print ''."\n"; print '
    '; From efda10333cf8938f01db9b403537325957e6130f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 1 Dec 2021 10:40:10 +0100 Subject: [PATCH 135/576] FIX missing default value for more comprehensive --- htdocs/admin/ihm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index cf4c250a678..a4c6f27c4b2 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -417,7 +417,7 @@ print ''; // Show bugtrack link print '
    '; print ''; print ''; From 4575bbae82a88dcdbd18f863d968b45ef87e0023 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Dec 2021 12:00:19 +0100 Subject: [PATCH 136/576] Clean code for browser notifications --- htdocs/core/class/notify.class.php | 8 ++--- htdocs/core/js/lib_notification.js.php | 33 +++++++++++-------- ..._50_modNotification_Notification.class.php | 31 ++++------------- 3 files changed, 29 insertions(+), 43 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index a88f673405c..2df88f51c0d 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -62,13 +62,11 @@ class Notify */ public $fk_project; - // Les codes actions sont definis dans la table llx_notify_def - - // codes actions supported are - // @todo defined also into interface_50_modNotification_Notification.class.php - public $arrayofnotifsupported = array( + // This codes actions are defined into table llx_notify_def + static public $arrayofnotifsupported = array( 'BILL_VALIDATE', 'BILL_PAYED', + 'ORDER_CREATE', 'ORDER_VALIDATE', 'PROPAL_VALIDATE', 'PROPAL_CLOSE_SIGNED', diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index ee41555119a..f4a4e59526a 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -68,22 +68,27 @@ print ' var time_auto_update = '.$conf->global->MAIN_BROWSER_NOTIFICATION_FREQUE print ' var time_js_next_test;'."\n"; ?> -/* Check if permission ok */ -if (Notification.permission !== "granted") { - console.log("Ask Notification.permission"); - Notification.requestPermission() +/* Check if Notification is supported */ +if ("Notification" in window) { + /* Check if permission ok */ + if (Notification.permission !== "granted") { + console.log("Ask Notification.permission"); + Notification.requestPermission() + } + + /* Launch timer */ + + // We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. + //var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds + var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; + + setTimeout(first_execution, time_first_execution * 1000); + time_js_next_test = nowtime + time_first_execution; + console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" time_js_next_check = "+time_js_next_test); +} else { + console.log("This browser in this context does not support Notification."); } -/* Launch timer */ - -// We set a delay before launching first test so next check will arrive after the time_auto_update compared to previous one. -//var time_first_execution = (time_auto_update + (time_js_next_test - nowtime)) * 1000; //need milliseconds -var time_first_execution = global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION) ? 0 : $conf->global->MAIN_BROWSER_NOTIFICATION_CHECK_FIRST_EXECUTION); ?>; - -setTimeout(first_execution, time_first_execution * 1000); -time_js_next_test = nowtime + time_first_execution; -console.log("Launch browser notif check: setTimeout is set to launch 'first_execution' function after a wait of time_first_execution="+time_first_execution+". nowtime (time php page generation) = "+nowtime+" time_js_next_check = "+time_js_next_test); - function first_execution() { console.log("Call first_execution then set repeat time to time_auto_update = MAIN_BROWSER_NOTIFICATION_FREQUENCY = "+time_auto_update); diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index e2b359809dd..fe89a05ab20 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -23,6 +23,7 @@ * \brief File of class of triggers for notification module */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; /** @@ -30,26 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; */ class InterfaceNotification extends DolibarrTriggers { - // @todo Defined also into notify.class.php - public $listofmanagedevents = array( - 'BILL_VALIDATE', - 'BILL_PAYED', - 'ORDER_CREATE', - 'ORDER_VALIDATE', - 'PROPAL_VALIDATE', - 'PROPAL_CLOSE_SIGNED', - 'FICHINTER_VALIDATE', - 'FICHINTER_ADD_CONTACT', - 'ORDER_SUPPLIER_VALIDATE', - 'ORDER_SUPPLIER_APPROVE', - 'ORDER_SUPPLIER_REFUSE', - 'SHIPPING_VALIDATE', - 'EXPENSE_REPORT_VALIDATE', - 'EXPENSE_REPORT_APPROVE', - 'HOLIDAY_VALIDATE', - 'HOLIDAY_APPROVE', - 'ACTION_CREATE' - ); + public $listofmanagedevents = array(); /** * Constructor @@ -66,6 +48,8 @@ class InterfaceNotification extends DolibarrTriggers // 'development', 'experimental', 'dolibarr' or version $this->version = self::VERSION_DOLIBARR; $this->picto = 'email'; + + $this->listofmanagedevents = Notify::$arrayofnotifsupported; } /** @@ -85,15 +69,13 @@ class InterfaceNotification extends DolibarrTriggers return 0; // Module not active, we do nothing } - require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; - $notify = new Notify($this->db); - - if (!in_array($action, $notify->arrayofnotifsupported)) { + if (!in_array($action, $this->listofmanagedevents)) { return 0; } dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $notify = new Notify($this->db); $notify->send($action, $object); return 1; @@ -114,6 +96,7 @@ class InterfaceNotification extends DolibarrTriggers $sql = "SELECT rowid, code, label, description, elementtype"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger"; $sql .= $this->db->order("rang, elementtype, code"); + dol_syslog("getListOfManagedEvents Get list of notifications", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { From 7512305b449e0718513cc302c3117eed2215dba3 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 12:10:57 +0100 Subject: [PATCH 137/576] add porduct inventory but qty_view bug --- htdocs/product/inventory/ajax/searchfrombarcode.php | 7 +++++-- htdocs/product/inventory/inventory.php | 10 ++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 947a9904bf0..c4d53719d65 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -51,8 +51,9 @@ $fk_entrepot = GETPOST("fk_entrepot", "int"); $fk_inventory = GETPOST("fk_inventory", "int"); $fk_product = GETPOST("fk_product", "int"); $reelqty = GETPOST("reelqty", "int"); -$qtyview = GETPOST("Qty", "int"); +$qtyview = GETPOST("qty", "int"); $batch = GETPOST("batch", "int"); +$mode = GETPOST("mode", "aZ"); $warehousefound = 0; $warehouseid = 0; @@ -106,7 +107,9 @@ if ($action == "addnewlineproduct") { $inventoryline->fk_product = $fk_product; $inventoryline->qty_stock = $reelqty; $inventoryline->qty_view = $qtyview; - $inventoryline->batch = $batch; + if ($mode == "lotserial") { + $inventoryline->batch = $batch; + } $inventoryline->datec = dol_now(); $result = $inventoryline->create($user); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 58bdcbc0022..9376d583ad4 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -548,8 +548,8 @@ if ($object->id > 0) { var barcodeproductqty = $("input[name=barcodeproductqty]").val(); var textarea = $("textarea[name=barcodelist]").val(); var textarray = textarea.split("\n"); + var tabproduct = []; if(textarray[0] != ""){ - var tabproduct = []; $(".expectedqty").each(function(){ id = this.id; warehouse = $("#"+id+"_warehouse").children().first().text(); @@ -579,7 +579,7 @@ if ($object->id > 0) { barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode",true); barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial",true); break; - case "barcodeforproduct": //TODO: create product !exist + ajout + case "barcodeforproduct": barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"barcode"); break; case "barcodeforlotserial": @@ -595,7 +595,7 @@ if ($object->id > 0) { console.log("We change #"+product.Id+"_input to match input in scanner box"); if(product.hasOwnProperty("reelqty")){ $.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\', - data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty}, + data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":product.Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty}, type: \'POST\', async: false, success: function(response) { @@ -666,10 +666,8 @@ if ($object->id > 0) { } }) if(BarcodeIsInProduct==0 && newproductrow){ - //addproduct to tabproduct - tabproduct.push({\'Id\':tabproduct.length-1,\'Warehouse\':newproductrow.fk_warehouse,\'Barcode\':element,\'Batch\':"",\'Qty\':1,\'fetched\':true,\'reelqty\':object.reelqty}); + tabproduct.push({\'Id\':tabproduct.length-1,\'Warehouse\':newproductrow.fk_warehouse,\'Barcode\':element,\'Batch\':element,\'Qty\':barcodeproductqty,\'fetched\':true,\'reelqty\':newproductrow.reelqty,\'fk_product\':newproductrow.fk_product,\'mode\':mode}); } - return tabproduct; } '; print ''; From 50d422cdf6a6f9ced92120dddfcf8aabbf5d3616 Mon Sep 17 00:00:00 2001 From: lainwir3d Date: Wed, 1 Dec 2021 15:55:11 +0400 Subject: [PATCH 138/576] CLOSE #19531 Product REST API: allow list / search method to retrieve stock data. See feature request #19531 --- htdocs/product/class/api_products.class.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 6283b692a28..dc82c7a6e5c 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -172,9 +172,10 @@ class Products extends DolibarrApi * @param bool $ids_only Return only IDs of product instead of all properties (faster, above all if list is long) * @param int $variant_filter Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only) * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0 + * @param int $includestockdata Load also information about stock (slower) * @return array Array of product objects */ - public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false) + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0) { global $db, $conf; @@ -249,6 +250,21 @@ class Products extends DolibarrApi if (!$ids_only) { $product_static = new Product($this->db); if ($product_static->fetch($obj->rowid)) { + if ($includestockdata && DolibarrApiAccess::$user->rights->stock->lire) { + $product_static->load_stock(); + + if (is_array($product_static->stock_warehouse)) { + foreach ($product_static->stock_warehouse as $keytmp => $valtmp) { + if (is_array($product_static->stock_warehouse[$keytmp]->detail_batch)) { + foreach ($product_static->stock_warehouse[$keytmp]->detail_batch as $keytmp2 => $valtmp2) { + unset($product_static->stock_warehouse[$keytmp]->detail_batch[$keytmp2]->db); + } + } + } + } + } + + $obj_ret[] = $this->_cleanObjectDatas($product_static); } } else { @@ -1948,6 +1964,7 @@ class Products extends DolibarrApi if (empty(DolibarrApiAccess::$user->rights->stock->lire)) { unset($object->stock_reel); unset($object->stock_theorique); + unset($object->stock_warehouse); } return $object; From f8a55362f639f68d6bab626260ea2b43b0340ee2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Dec 2021 14:46:48 +0100 Subject: [PATCH 139/576] Typo --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 84f551bbd93..3e4a1eeb9f3 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4069,7 +4069,7 @@ class Societe extends CommonObject $state_code = $tmp[1]; $state_label = $tmp[2]; } else { // For backward compatibility - dol_syslog("Your setup of State an old syntax (entity=".$conf->entity."). Go in Home - Setup - Organization then Save should remove this error.", LOG_ERR); + dol_syslog("Your setup of State has an old syntax (entity=".$conf->entity."). Go in Home - Setup - Organization then Save should remove this error.", LOG_ERR); include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $state_code = getState($state_id, 2, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore $state_label = getState($state_id, 0, $this->db); // This need a SQL request, but it's the old feature that should not be used anymore From 4c92af9aca080572491c7ac6473f714a6454d37e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 15:24:25 +0100 Subject: [PATCH 140/576] fix php8.0 warnings --- htdocs/expedition/list.php | 1 + htdocs/product/stock/list.php | 4 +--- htdocs/product/stock/movement_list.php | 4 +--- htdocs/product/stock/productlot_list.php | 4 +--- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index f569501d440..fb8ba3b8990 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -771,6 +771,7 @@ print "\n"; $typenArray = $formcompany->typent_array(1); $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 52c18c9cc97..8f24fb9c110 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -196,6 +196,7 @@ $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ListOfWarehouses"); $totalarray = array(); +$totalarray['nbfield'] = 0; // Build and execute select // -------------------------------------------------------------------- @@ -622,9 +623,6 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { - if (!isset($totalarray['nbfield'])) { - $totalarray['nbfield'] = 0; - } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 06d470b9b57..97d381e4f93 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -1141,6 +1141,7 @@ $arrayofuniqueproduct = array(); $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); @@ -1301,9 +1302,6 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { - if (!isset($totalarray['nbfield'])) { - $totalarray['nbfield'] = 0; - } $totalarray['nbfield']++; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 5e85daf06ba..e5a8b05902e 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -491,6 +491,7 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // -------------------------------------------------------------------- $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); if (empty($obj)) { @@ -536,9 +537,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print ''; if (!$i) { - if (!isset($totalarray['nbfield'])) { - $totalarray['nbfield'] = 0; - } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { From c6a071622add08617bb20d108c749ccebabe1768 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Dec 2021 15:26:40 +0100 Subject: [PATCH 141/576] Avoid a useless select --- htdocs/compta/facture/class/facture.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 649b7b0c093..686f714827a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -463,11 +463,17 @@ class Facture extends CommonInvoice $this->status = self::STATUS_DRAFT; $this->statut = self::STATUS_DRAFT; - // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) - if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { - list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); + if (!empty($this->multicurrency_code)) { + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate of multicurrency_code only if not using original rate) + if (empty($this->multicurrency_tx)) { + // If original rate is not set, we take a default value from date + list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date); + } else { + // original rate multicurrency_tx and multicurrency_code are set, we use them + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } } else { - $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + $this->fk_multicurrency = 0; } if (empty($this->fk_multicurrency)) { $this->multicurrency_code = $conf->currency; From 3cb07fd1ec627930e28ff05024aeae98b6d880d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Dec 2021 15:37:31 +0100 Subject: [PATCH 142/576] Doc --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9d1800af742..51a72d6beb2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -550,7 +550,7 @@ abstract class CommonObject dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR); return -1; } - if ($ref || $ref_ext) { + if ($ref || $ref_ext) { // Because the same ref can exists in 2 different entities, we force the current one in priority $sql .= " AND entity = ".((int) $conf->entity); } From 171ecaa81d966a11d990a424d317e0bbbe5c7a0a Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 15:40:53 +0100 Subject: [PATCH 143/576] fix php8.0 warnings --- htdocs/reception/card.php | 1 + htdocs/reception/class/reception.class.php | 2 +- htdocs/reception/index.php | 1 + htdocs/reception/list.php | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 5b8727a3f0c..d9f8da644ea 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -85,6 +85,7 @@ if (empty($origin_id)) { } $ref = GETPOST('ref', 'alpha'); $line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; +$facid = GETPOST('facid', 'int'); $action = GETPOST('action', 'alpha'); //Select mail models is same action as presend diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 954e7f192cd..8024bac4f36 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1120,7 +1120,7 @@ class Reception extends CommonObject $result = ''; $label = img_picto('', $this->picto).' '.$langs->trans("Reception").''; $label .= '
    '.$langs->trans('Ref').': '.$this->ref; - $label .= '
    '.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); + $label .= '
    '.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : ''); $url = DOL_URL_ROOT.'/reception/card.php?id='.$this->id; diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index 580de4aca1a..ed5f3a715d2 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -39,6 +39,7 @@ $langs->loadLangs(array("orders", "receptions")); $reception = new Reception($db); // Security check +$socid = ''; if ($user->socid) { $socid = $user->socid; } diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 5a6db5b53b1..00c59e47336 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -479,7 +479,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; @@ -878,6 +878,7 @@ print "\n"; $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); From ed7bfb333b882411d3f8c103bdf655f28dd187d0 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 16:24:57 +0100 Subject: [PATCH 144/576] fix php8.0 errors --- htdocs/core/class/commonobject.class.php | 8 ++++---- htdocs/expedition/card.php | 18 +++++++++--------- htdocs/reception/card.php | 10 +++++----- htdocs/reception/stats/index.php | 3 ++- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9d1800af742..56537db2da9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4481,14 +4481,14 @@ abstract class CommonObject $qty = $line->qty ? $line->qty : 0; } - $weight = $line->weight ? $line->weight : 0; + $weight = !empty($line->weight) ? $line->weight : 0; ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; - $volume = $line->volume ? $line->volume : 0; + $volume = !empty($line->volume) ? $line->volume : 0; ($volume == 0 && !empty($line->product->volume)) ? $volume = $line->product->volume : 0; - $weight_units = $line->weight_units; + $weight_units = !empty($line->weight_units) ? $line->weight_units : 0; ($weight_units == 0 && !empty($line->product->weight_units)) ? $weight_units = $line->product->weight_units : 0; - $volume_units = $line->volume_units; + $volume_units = !empty($line->volume_units) ? $line->volume_units : 0; ($volume_units == 0 && !empty($line->product->volume_units)) ? $volume_units = $line->product->volume_units : 0; $weightUnit = 0; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 64a080e8f6e..fe09a4c521d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2103,7 +2103,7 @@ if ($action == 'create') { // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs); + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => !empty($outputlangs) ? $outputlangs: ''); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -2143,10 +2143,10 @@ if ($action == 'create') { $product_static->weight_units = $lines[$i]->weight_units; $product_static->length = $lines[$i]->length; $product_static->length_units = $lines[$i]->length_units; - $product_static->width = $lines[$i]->width; - $product_static->width_units = $lines[$i]->width_units; - $product_static->height = $lines[$i]->height; - $product_static->height_units = $lines[$i]->height_units; + $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; + $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; + $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; + $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; $product_static->surface = $lines[$i]->surface; $product_static->surface_units = $lines[$i]->surface_units; $product_static->volume = $lines[$i]->volume; @@ -2156,7 +2156,7 @@ if ($action == 'create') { $text .= ' - '.$label; $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
    '.dol_htmlentitiesbr($lines[$i]->description) : ''; } @@ -2181,7 +2181,7 @@ if ($action == 'create') { } $unit_order = ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit_order = measuringUnitString($lines[$i]->fk_unit); } @@ -2412,9 +2412,9 @@ if ($action == 'create') { // TODO Show all in same line by setting $display_type = 'line' if ($action == 'editline' && $line->id == $line_id) { - print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked, '', 0, 'card'); + print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } else { - print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked, '', 0, 'card'); + print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } } } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index d9f8da644ea..c636cfb7b19 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1751,7 +1751,7 @@ if ($action == 'create') { // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - print ''; // id of order line + print ''; // id of order line print '
    '; // # @@ -1776,7 +1776,7 @@ if ($action == 'create') { $text .= ' - '.$label; $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : 0, !empty($lines[$i]->date_end) ? $lines[$i]->date_end : 0); if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
    '.dol_htmlentitiesbr($lines[$i]->description) : ''; } @@ -1925,7 +1925,7 @@ if ($action == 'create') { // Weight print '"; // Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines) > 0) { + if (!empty($extralabelslines) && is_array($extralabelslines) && count($extralabelslines) > 0) { $colspan = empty($conf->productbatch->enabled) ? 8 : 9; $line = new CommandeFournisseurDispatch($db); $line->id = $lines[$i]->id; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 8f20ed58065..865d0e95082 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -59,7 +59,7 @@ llxHeader(); print load_fiche_titre($langs->trans("StatisticsOfReceptions"), '', 'dollyrevert'); - +$dir = (!empty($conf->reception->multidir_temp[$conf->entity]) ? $conf->reception->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); dol_mkdir($dir); $stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0)); @@ -78,6 +78,7 @@ if (empty($user->rights->societe->client->voir) || $user->socid) { $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); +$fileurlnb = ''; if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array(); From c0d00a859f1f9883c85abdeb1d22055ab798dee6 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 1 Dec 2021 16:59:30 +0100 Subject: [PATCH 145/576] use dol_escape_htmltag --- htdocs/core/class/html.formsetup.class.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 13dd3a8694c..1778b46995e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -103,17 +103,6 @@ class FormSetup } } - /** - * a quick method to sanitize html attributes - * @param string $var the string to sanitize - * @return string - */ - static public function sanitizeHtmlAttribute($var) - { - $var = preg_replace("/\r|\n/", "", $var); - return htmlspecialchars($var, ENT_QUOTES); - } - /** * Generate an attributes string form an input array * @param array $attributes an array of attributes keys and values, @@ -127,7 +116,7 @@ class FormSetup if (is_array($value) || is_object($value)) { continue; } - $Aattr[] = $attribute.'="'.self::sanitizeHtmlAttribute($value).'"'; + $Aattr[] = $attribute.'="'.dol_escape_htmltag($value).'"'; } } @@ -164,7 +153,7 @@ class FormSetup // generate hidden values from $this->formHiddenInputs if (!empty($this->formHiddenInputs) && is_array($this->formHiddenInputs)) { foreach ($this->formHiddenInputs as $hiddenKey => $hiddenValue) { - $out.= ''; + $out.= ''; } } } From bacf569e0b2974f32b401e7f4e91562d0f54bef8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Dec 2021 17:33:26 +0100 Subject: [PATCH 146/576] Fix phpcs --- htdocs/compta/facture/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index c05e109d585..da77b75d9a6 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1645,10 +1645,10 @@ if (empty($reshook)) { $discount->tva_tx = $lines[$i]->tva_tx; $discount->fk_user = $user->id; $discount->description = $desc; - $discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice); - $discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht); - $discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva); - $discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc); + $discount->multicurrency_subprice = abs($lines[$i]->multicurrency_subprice); + $discount->multicurrency_amount_ht = abs($lines[$i]->multicurrency_total_ht); + $discount->multicurrency_amount_tva = abs($lines[$i]->multicurrency_total_tva); + $discount->multicurrency_amount_ttc = abs($lines[$i]->multicurrency_total_ttc); $discountid = $discount->create($user); if ($discountid > 0) { From 10e126eb694b1fdcfda10be1e5c39707381f71e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 10:43:44 +0100 Subject: [PATCH 147/576] Clean code on pdf templates --- htdocs/compta/facture/card.php | 21 ++++++++------- .../core/modules/bank/doc/pdf_ban.modules.php | 4 +-- .../bank/doc/pdf_sepamandate.modules.php | 4 +-- .../commande/doc/pdf_eratosthene.modules.php | 6 +++-- .../delivery/doc/pdf_storm.modules.php | 6 ++--- .../delivery/doc/pdf_typhon.modules.php | 6 ++--- .../expedition/doc/pdf_espadon.modules.php | 6 ++--- .../expedition/doc/pdf_merou.modules.php | 4 +-- .../expedition/doc/pdf_rouget.modules.php | 6 ++--- .../doc/pdf_standard.modules.php | 4 +-- .../facture/doc/pdf_sponge.modules.php | 27 ++++++++++--------- .../fichinter/doc/pdf_soleil.modules.php | 4 +-- .../movement/doc/pdf_standard.modules.php | 10 +++---- .../modules/mrp/doc/pdf_vinci.modules.php | 6 +++-- .../product/doc/pdf_standard.modules.php | 4 +-- .../project/doc/pdf_baleine.modules.php | 4 +-- .../project/doc/pdf_beluga.modules.php | 4 +-- .../project/doc/pdf_timespent.modules.php | 4 +-- .../modules/propale/doc/pdf_cyan.modules.php | 5 ++-- .../reception/doc/pdf_squille.modules.php | 6 ++--- .../stock/doc/pdf_standard.modules.php | 8 ++---- .../supplier_order/doc/pdf_cornas.modules.php | 6 +++-- .../doc/pdf_standard.modules.php | 4 +-- 23 files changed, 81 insertions(+), 78 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 66dadaa3beb..20f289ae141 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4283,7 +4283,7 @@ if ($action == 'create') { print '
    '; print '
    '; - print '
    '.$extrafields->showOutputField($key, $obj->{$key})."'.$extrafields->showOutputField($key, $obj->{$key}, '', 'product_fournisseur_price')."
    '; print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).''; - $form->select_comptes($accountid, "accountid", 0, '', 2); // Affiche liste des comptes courant + print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes($accountid, "accountid", 0, '', 2, '', 0, '', 1); // Affiche liste des comptes courant print '
    '.$langs->trans("Project").''; - - $numproject = $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); - + print img_picto('', 'bank_account', 'class="pictofixedwidth"'); + print $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1); print '
    '.$objectlink->getNomUrl(1).''; + echo ''; $result = $product_static->fetch($objectlink->fk_product); if ($result < 0) { setEventMessage($product_static->error, 'errors'); @@ -62,7 +62,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $product_static->getNomUrl(1); } print ''.dol_print_date($objectlink->date_creation, 'day').''.dol_print_date($objectlink->date_creation, 'day').''; if ($user->rights->commande->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index aba881a63c6..2a6140aaeed 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -52,8 +52,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } echo ''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; if ($user->rights->commande->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index bb6777c0639..c8ff1196c0f 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -56,8 +56,8 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> getNomUrl(1); ?>date_delivery, 'day'); ?>date_delivery, 'day'); ?> rights->reception->lire) { $total = $total + $objectlink->total_ht; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 10768184b1b..f8ff67ae8ce 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1444,6 +1444,10 @@ table[summary="list_of_modules"] .fa-cog { min-width: 100px; } +.linkedcol-date { + text-align: center; +} + .img-skinthumb { width: 160px; height: 100px; From 6608f5f0d8f62ce290bf47a53b151c31699089f9 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Mon, 29 Nov 2021 15:09:18 +0100 Subject: [PATCH 114/576] update all script tags to be uniform. `language="javascript"` removed https://developer.mozilla.org/en-US/docs/web/html/element/script#attr-language --- htdocs/accountancy/admin/export.php | 2 +- htdocs/accountancy/admin/productaccount.php | 2 +- htdocs/accountancy/bookkeeping/balance.php | 2 +- htdocs/accountancy/customer/list.php | 2 +- htdocs/accountancy/expensereport/list.php | 2 +- htdocs/accountancy/index.php | 2 +- htdocs/accountancy/supplier/list.php | 2 +- htdocs/adherents/admin/website.php | 2 +- .../canvas/actions_adherentcard_common.class.php | 2 +- htdocs/adherents/card.php | 4 ++-- htdocs/adherents/subscription.php | 2 +- htdocs/admin/accountant.php | 2 +- htdocs/admin/company.php | 2 +- htdocs/admin/fckeditor.php | 2 +- htdocs/admin/mails.php | 2 +- htdocs/admin/mails_emailing.php | 2 +- htdocs/admin/mails_ticket.php | 2 +- htdocs/admin/menus/edit.php | 2 +- htdocs/admin/proxy.php | 2 +- htdocs/admin/system/perf.php | 2 +- htdocs/barcode/codeinit.php | 2 +- htdocs/barcode/printsheet.php | 2 +- htdocs/comm/action/card.php | 4 ++-- htdocs/comm/action/pertype.php | 2 +- htdocs/comm/action/peruser.php | 2 +- htdocs/comm/mailing/card.php | 2 +- htdocs/compta/bank/card.php | 4 ++-- htdocs/compta/bank/various_payment/card.php | 2 +- htdocs/compta/facture/card.php | 10 +++++----- htdocs/compta/paiement.php | 2 +- htdocs/compta/paiement/cheque/card.php | 2 +- htdocs/compta/paiement_charge.php | 2 +- htdocs/compta/paiement_vat.php | 2 +- htdocs/compta/tva/card.php | 2 +- .../canvas/actions_contactcard_common.class.php | 2 +- htdocs/contact/card.php | 8 ++++---- htdocs/core/ajax/ajaxdirtree.php | 2 +- htdocs/core/boxes/box_graph_invoices_permonth.php | 2 +- .../boxes/box_graph_invoices_supplier_permonth.php | 2 +- htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php | 2 +- htdocs/core/boxes/box_graph_orders_permonth.php | 2 +- .../core/boxes/box_graph_orders_supplier_permonth.php | 2 +- htdocs/core/boxes/box_graph_product_distribution.php | 2 +- htdocs/core/boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/boxes/box_task.php | 2 +- htdocs/core/class/doleditor.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formbarcode.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 ++-- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formsms.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 6 +++--- htdocs/core/class/openid.class.php | 2 +- htdocs/core/customreports.php | 2 +- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/core/lib/treeview.lib.php | 2 +- htdocs/core/photos_resize.php | 2 +- htdocs/cron/card.php | 2 +- htdocs/don/payment/payment.php | 2 +- htdocs/expedition/card.php | 2 +- htdocs/expensereport/card.php | 4 ++-- htdocs/expensereport/payment/payment.php | 2 +- htdocs/fourn/facture/card.php | 6 +++--- htdocs/fourn/facture/paiement.php | 4 ++-- htdocs/imports/import.php | 2 +- htdocs/includes/nusoap/lib/class.wsdl.php | 2 +- htdocs/includes/nusoap/lib/nusoap.php | 2 +- htdocs/install/upgrade2.php | 2 +- htdocs/loan/schedule.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/paybox/lib/paybox.lib.php | 2 +- htdocs/product/inventory/inventory.php | 4 ++-- htdocs/product/stock/product.php | 2 +- htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +- htdocs/projet/card.php | 4 ++-- htdocs/public/payment/newpayment.php | 2 +- htdocs/public/test/test_arrays.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/salaries/card.php | 2 +- htdocs/salaries/paiement_salary.php | 2 +- htdocs/societe/canvas/actions_card_common.class.php | 4 ++-- .../canvas/company/actions_card_company.class.php | 2 +- htdocs/societe/card.php | 6 +++--- htdocs/takepos/index.php | 2 +- htdocs/takepos/invoice.php | 4 ++-- htdocs/takepos/phone.php | 2 +- htdocs/ticket/index.php | 2 +- htdocs/user/hierarchy.php | 2 +- htdocs/user/param_ihm.php | 2 +- htdocs/website/index.php | 8 ++++---- htdocs/workstation/workstation_card.php | 2 +- 93 files changed, 121 insertions(+), 121 deletions(-) diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 9e393beeacd..8cef3a05cf4 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -142,7 +142,7 @@ $linkback = ''; print load_fiche_titre($langs->trans('ExportOptions'), $linkback, 'accountancy'); -print "\n".''; // This ajax service is called only when a directory $selecteddir is opened but not when closed. - //print ''; } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 65498ab6362..8179e134bcf 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -227,7 +227,7 @@ class box_graph_invoices_permonth extends ModeleBoxes if (!$mesg) { $stringtoshow = ''; - $stringtoshow .= ''; } else { // Default Header Redirect diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index b7f01de0aeb..1cede60f892 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -351,7 +351,7 @@ print $form->selectarray('objecttype', $newarrayoftype, $objecttype, 0, 0, 0, '' if (empty($conf->use_javascript_ajax)) { print ''; } else { - print ' -'; + $sectionwithinvoicelink .= ''; } } @@ -905,7 +905,7 @@ if ($action == "valid" || $action == "history" || $action == 'creditnote') { $form = new Form($db); ?> -'; From f39dd30a7f49b6cd9a542eb291e3c742090caf40 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 15:38:48 +0100 Subject: [PATCH 130/576] fix precommit --- htdocs/product/inventory/ajax/searchfrombarcode.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/inventory/ajax/searchfrombarcode.php b/htdocs/product/inventory/ajax/searchfrombarcode.php index 32cba249896..947a9904bf0 100644 --- a/htdocs/product/inventory/ajax/searchfrombarcode.php +++ b/htdocs/product/inventory/ajax/searchfrombarcode.php @@ -52,7 +52,7 @@ $fk_inventory = GETPOST("fk_inventory", "int"); $fk_product = GETPOST("fk_product", "int"); $reelqty = GETPOST("reelqty", "int"); $qtyview = GETPOST("Qty", "int"); -$batch = GETPOST("batch","int"); +$batch = GETPOST("batch", "int"); $warehousefound = 0; $warehouseid = 0; @@ -71,7 +71,7 @@ if ($action == "existbarcode" && !empty($barcode)) { for ($i=0; $i < $nbline; $i++) { $object = $db->fetch_object($result); if ($barcode == $object->barcode) { - $warehouse->fetch(0,$product["Warehouse"]); + $warehouse->fetch(0, $product["Warehouse"]); if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) { $warehousefound++; $warehouseid = $object->fk_entrepot; @@ -112,10 +112,10 @@ if ($action == "addnewlineproduct") { $result = $inventoryline->create($user); if ($result > 0) { $response = array('status'=>'success','message'=>'Success on creating line'); - }else { + } else { $response = array('status'=>'error','errorcode'=>'ErrorCreation','message'=>"Error on line creation"); } - }else { + } else { $response = array('status'=>'error','errorcode'=>'NoIdForInventory','message'=>"No id for inventory"); } } From 5d7f8d3831cdfc17bb9cbb80fa3b3ff2e9f1a79a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Nov 2021 15:54:28 +0100 Subject: [PATCH 131/576] Fix fatal error --- htdocs/core/boxes/box_funnel_of_prospection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 28c3b22788d..dd5bce78301 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -237,7 +237,7 @@ class box_funnel_of_prospection extends ModeleBoxes $dolgraph->setBorderColor(array_values($bordercolorseries)); $dolgraph->setShowLegend(2); if (!empty($conf->dol_optimize_smallscreen)) { - $px1->SetWidth(320); + $dolgraph->SetWidth(320); } $dolgraph->setShowPercent(1); $dolgraph->setMirrorGraphValues(true); From db06de0ac2e1e6c499184789ff86433c3647c351 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 30 Nov 2021 16:27:50 +0100 Subject: [PATCH 132/576] add printFieldListHaving hook --- htdocs/comm/propal/list.php | 5 +++++ htdocs/commande/list.php | 5 +++++ htdocs/expedition/list.php | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 4f59682abb8..3e467539c88 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -696,6 +696,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); $sql .= ', p.ref DESC'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9c278359acc..b534d915914 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -628,6 +628,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 6a1b26fa19f..79ed3b52215 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -373,6 +373,11 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; + $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; From 1c4a7a00cbcdc1bd8db5022f4321efc3124ef96d Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 16:35:46 +0100 Subject: [PATCH 133/576] fix php8.0 warning --- htdocs/expedition/card.php | 1 + htdocs/expedition/index.php | 1 + htdocs/expedition/list.php | 2 +- htdocs/product/stats/card.php | 2 +- htdocs/product/stock/list.php | 9 ++++++--- htdocs/product/stock/massstockmove.php | 8 ++++++++ htdocs/product/stock/movement_list.php | 8 +++++++- htdocs/product/stock/productlot_list.php | 16 ++++++++++------ 8 files changed, 35 insertions(+), 12 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 64a080e8f6e..f077d9360de 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -81,6 +81,7 @@ if (empty($origin_id)) { } $ref = GETPOST('ref', 'alpha'); $line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; +$facid = GETPOST('facid', 'int'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 49777518509..8a992e0c7ec 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $hookmanager = new HookManager($db); +$socid = GETPOST('socid', 'int'); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('sendingindex')); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index ac5704511ef..f569501d440 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -253,7 +253,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && sis_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index d2d9f289fd1..463297f043a 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -276,7 +276,7 @@ if ($result || !($id > 0)) { print '
    '; // Generation of graphs - $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); + $dir = (!empty($conf->product->multidir_temp[$conf->entity]) ? $conf->product->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); if ($object->id > 0) { // We are on statistics for a dedicated product if (!file_exists($dir.'/'.$object->id)) { if (dol_mkdir($dir.'/'.$object->id) < 0) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index bfd96716bb7..52c18c9cc97 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -78,7 +78,7 @@ if (!$sortorder) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('stocklist')); // Fetch optionals attributes and labels @@ -228,7 +228,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.rowid"); } -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot"; @@ -473,7 +473,7 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print '
    '.$langs->trans("ShowBugTrackLink", $langs->transnoentitiesnoconv("FindBug")).''; -print ''; +print ''; print ' 
    '; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + if (!empty($lines[$i]->fk_product_type) && $lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->weight * $lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); } else { print ' '; @@ -1934,7 +1934,7 @@ if ($action == 'create') { // Volume print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + if (!empty($lines[$i]->fk_product_type) && $lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->volume * $lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); } else { print ' '; @@ -1965,7 +1965,7 @@ if ($action == 'create') { print "
    '; + print '
    '; // Type print ''; @@ -478,7 +478,7 @@ if ($object->id > 0) { print $langs->trans("CustomerAbsoluteDiscountShort"); print '
    '.$langs->trans('Type').''; @@ -4364,7 +4364,7 @@ if ($action == 'create') { // Date invoice print '
    '; - print ''; if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { - // Actions + // Actions or link to stock movement print ''; + } else { + // Actions or link to stock movement + print ''; } print ''; @@ -799,7 +845,7 @@ if ($object->id > 0) { // Request to show lines of inventory (prefilled after start/validate step) $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; - $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; + $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated, id.fk_movement'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); @@ -826,6 +872,7 @@ if ($object->id > 0) { $cacheOfWarehouses[$warehouse_static->id] = $warehouse_static; } + // Load real stock we have now if (isset($cacheOfProducts[$obj->fk_product])) { $product_static = $cacheOfProducts[$obj->fk_product]; } else { @@ -834,7 +881,7 @@ if ($object->id > 0) { //$option = 'nobatch'; $option .= ',novirtual'; - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. $cacheOfProducts[$product_static->id] = $product_static; } @@ -855,14 +902,14 @@ if ($object->id > 0) { // Expected quantity = Quantity in stock when we start inventory print ''; } else { - print ''; + print ''; } print ''; diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index da06076fe97..a6bc6c2ec26 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -1071,7 +1071,7 @@ class MouvementStock extends CommonObject * Use this->id,this->lastname, this->firstname * * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to + * @param string $option On what the link point to ('' = Tab of stock movement of warehouse, 'movements' = list of movements) * @param integer $notooltip 1=Disable tooltip * @param int $maxlen Max length of visible user name * @param string $morecss Add more css on link @@ -1082,16 +1082,21 @@ class MouvementStock extends CommonObject global $langs, $conf, $db; $result = ''; - $companylink = ''; - $label = ''.$langs->trans("Movement").' '.$this->id.''; + $label = img_picto('', 'stock', 'class="pictofixedwidth"').''.$langs->trans("Movement").' '.$this->id.''; $label .= '
    '; $label .= ''.$langs->trans('Label').': '.$this->label; - $label .= '
    '.$langs->trans('Qty').': '.$this->qty; + $label .= '
    '.$langs->trans('Qty').': '.($this->qty > 0 ? '+' : '').$this->qty; $label .= '
    '; - $link = 'id; + } else { + $url = DOL_URL_ROOT.'/product/stock/movement_list.php?id='.$this->warehouse_id.'&msid='.$this->id; + } + + $link = ' Date: Tue, 14 Dec 2021 22:45:33 +0100 Subject: [PATCH 298/576] check for mbstring extension at install --- htdocs/install/check.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 14448841217..d3c5cba1290 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -149,11 +149,19 @@ if (!function_exists("easter_date")) { if (!function_exists("utf8_encode")) { $langs->load("errors"); print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
    \n"; - // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { print 'Ok '.$langs->trans("PHPSupport", "UTF8")."
    \n"; } +// Check for mbstring extension +if (!extension_loaded("mbstring")) { + $langs->load("errors"); + print 'Error '.$langs->trans("ErrorPHPDoesNotSupportMbstring")."
    \n"; + // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) +} else { + print 'Ok '.$langs->trans("PHPSupport", "mbstring")."
    \n"; +} // Check if intl methods are supported if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@localhost') { From a02cb4c9b11ce24058eecfac5d3fac6675fa7fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 14 Dec 2021 22:52:39 +0100 Subject: [PATCH 299/576] Update install.lang --- htdocs/langs/en_US/install.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index c1ffee936d7..989f6aa9793 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -21,6 +21,7 @@ ErrorPHPDoesNotSupportCurl=Your PHP installation does not support Curl. ErrorPHPDoesNotSupportCalendar=Your PHP installation does not support php calendar extensions. ErrorPHPDoesNotSupportUTF8=Your PHP installation does not support UTF8 functions. Dolibarr cannot work correctly. Resolve this before installing Dolibarr. ErrorPHPDoesNotSupportIntl=Your PHP installation does not support Intl functions. +ErrorPHPDoesNotSupportMbstring=Your PHP installation does not support mbstring functions. ErrorPHPDoesNotSupportxDebug=Your PHP installation does not support extend debug functions. ErrorPHPDoesNotSupport=Your PHP installation does not support %s functions. ErrorDirDoesNotExists=Directory %s does not exist. From 8e3b617671bdcde070936e6c0103eebbaa6ec0f6 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Wed, 15 Dec 2021 16:21:08 +0700 Subject: [PATCH 300/576] Fix search_user in stock/movement_list.php --- htdocs/product/stock/movement_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index a1d143335cd..e1418bed4c4 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -548,7 +548,7 @@ if ($search_warehouse != '' && $search_warehouse != '-1') { $sql .= natural_search('e.rowid', $search_warehouse, 2); } if (!empty($search_user)) { - $sql .= natural_search('u.login', $search_user); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); } if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); From fca26827ecd7fa1a9c576a8a9275658f90621f65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9lina?= Date: Wed, 15 Dec 2021 10:47:30 +0100 Subject: [PATCH 301/576] Add constant TAKEPOS_CHANGE_PRICE_HT --- htdocs/takepos/invoice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 2a951a505ae..61f955636f5 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -680,6 +680,8 @@ if ($action == "updateprice") { } else { if (empty($user->rights->takepos->editlines) || (empty($user->rights->takepos->editorderedlines) && $line->special_code == "4")) { dol_htmloutput_errors($langs->trans("NotEnoughPermissions", "TakePos"), null, 1); + } elseif ($conf->global->TAKEPOS_CHANGE_PRICE_HT == 1) { + $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } else { $result = $invoice->updateline($line->id, $line->desc, $number, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'TTC', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } From 7c1879a11a46f3239a2cbb91f69abcf5123f7c79 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Wed, 15 Dec 2021 16:52:57 +0700 Subject: [PATCH 302/576] Fix author searching include first and last name --- htdocs/fourn/facture/list.php | 2 +- htdocs/mrp/mo_movements.php | 2 +- htdocs/product/stock/movement_card.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 8b83048d8d3..e77ae1fea28 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -564,7 +564,7 @@ if ($search_multicurrency_montant_ttc != '') { $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); } if ($search_login) { - $sql .= natural_search('u.login', $search_login); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); } if ($search_status != '' && $search_status >= 0) { $sql .= " AND f.fk_statut = ".((int) $search_status); diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 3b1ac109e5d..f7c25a1ec83 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -468,7 +468,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $sql .= natural_search('e.rowid', $search_warehouse, 2); } if (!empty($search_user)) { - $sql .= natural_search('u.login', $search_user); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); } if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 25dac24b592..f9c0778eea4 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -489,7 +489,7 @@ if ($search_warehouse != '' && $search_warehouse != '-1') { $sql .= natural_search('e.rowid', $search_warehouse, 2); } if (!empty($search_user)) { - $sql .= natural_search('u.login', $search_user); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); } if (!empty($search_batch)) { $sql .= natural_search('m.batch', $search_batch); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a64ac94b169..c881203b2d8 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -364,7 +364,7 @@ if ($search_societe) { $sql .= natural_search('s.nom', $search_societe); } if ($search_login) { - $sql .= natural_search('u.login', $search_login); + $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); } if ($search_montant_ht) { $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); From 53be92fac3b146c62114d53b2b53449692e0591a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Dec 2021 17:32:15 +0100 Subject: [PATCH 303/576] FIX #19626 --- htdocs/core/lib/pdf.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 735e6892fcd..b7ef5925748 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -35,6 +35,8 @@ * \ingroup core */ +include_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php'; + /** * Return array head with list of tabs to view object informations. From f589121199a6cb60726d3e4b7fa7bfd10e4f683a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 01:17:22 +0100 Subject: [PATCH 304/576] Trans --- htdocs/langs/en_US/main.lang | 2 +- htdocs/theme/eldy/global.inc.php | 21 ++++++++++++++++----- htdocs/theme/md/style.css.php | 23 +++++++++++++++++------ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 027b7c428ec..06acd399d25 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1159,6 +1159,6 @@ Properties=Properties hasBeenValidated=%s has been validated ClientTZ=Client Time Zone (user) NotClosedYet=Not yet closed -ClearSignature=Signature reset +ClearSignature=Reset signature CanceledHidden=Canceled hidden CanceledShown=Canceled shown diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index da23e60498c..e413623fb0c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2883,11 +2883,18 @@ input.vmenusearchselectcombo[type=text] { .searchform input { font-size: 16px; } -a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { white-space: nowrap; font-family: ; text-align: ; } +a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { + white-space: nowrap; font-family: ; text-align: ; +} a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vmenu:link, span.vmenu:visited, span.vmenu:hover, span.vmenu:active { font-weight: bold; } /* bold = 600, 500 is ko with Edge on 1200x960 */ -span.vmenudisabled, font.vmenudisabled { font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; } /* bold = 600, 500 is ko with Edge on 1200x960 */ -a.vmenu:link, a.vmenu:visited { color: var(--colortextbackvmenu); } +span.vmenudisabled, font.vmenudisabled { + /* bold = 600, 500 is ko with Edge on 1200x960 */ + font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; +} +a.vmenu:link, a.vmenu:visited { + color: var(--colortextbackvmenu); +} a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font-family: ; @@ -2895,7 +2902,9 @@ a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { color: #202020; margin: 1px 1px 1px 6px; } -span.vsmenudisabled, font.vsmenudisabled { font-family: ; text-align: ; color: #aaa; } +span.vsmenudisabled, font.vsmenudisabled { + font-family: ; text-align: ; color: #aaa; +} a.vsmenu:link, a.vsmenu:visited { color: var(--colortextbackvmenu); white-space: nowrap; @@ -2903,7 +2912,9 @@ a.vsmenu:link, a.vsmenu:visited { span.vsmenudisabledmargin, font.vsmenudisabledmargin { margin: 1px 1px 1px 6px; } li a.vsmenudisabled, li.vsmenudisabled { color: #aaa !important; } -a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align: ; color: #aaa; text-decoration: none; } +a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { + text-align: ; color: #aaa; text-decoration: none; +} .helppresent, .helppresent:hover { /* color: #f3e4ac !important; */ } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 8873149a9be..a2a68168e8e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2462,7 +2462,7 @@ div.tmenucenter width: 100%; } div.menu_titre { - padding-bottom: 2px; + padding-bottom: 5px; overflow: hidden; text-overflow: ellipsis; } @@ -2959,16 +2959,27 @@ div.vmenu, td.vmenu { .searchform { padding-top: 10px; } .searchform .bordertransp { border: 0; } -a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; } +a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { + white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; +} span.vmenudisabled, font.vmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; } -a.vmenu:link, a.vmenu:visited { color: #; } +a.vmenu:link, a.vmenu:visited { + color: var(--colortextbackvmenu); +} a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #202020; margin: 1px 1px 1px 8px; } -span.vsmenudisabled, font.vsmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; } -a.vsmenu:link, a.vsmenu:visited { color: #; white-space: nowrap; } +span.vsmenudisabled, font.vsmenudisabled { + font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; +} +a.vsmenu:link, a.vsmenu:visited { + color: var(--colortextbackvmenu); + white-space: nowrap; +} span.vsmenudisabledmargin, font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } -a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { text-align: ; font-weight: normal; color: #999; text-decoration: none; } +a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { + text-align: ; font-weight: normal; color: #999; text-decoration: none; +} .helppresentcircle { color: var(--colorbackhmenu1); From cc12baed57bda34c2833fdfcba78926ea23c86a0 Mon Sep 17 00:00:00 2001 From: atm-gregr Date: Thu, 16 Dec 2021 10:19:42 +0100 Subject: [PATCH 305/576] fix info tab on customer invoice record not found --- htdocs/compta/facture/info.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index ccf6dca135c..340dfda2957 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -43,6 +43,12 @@ $ref = GETPOST("ref", 'alpha'); * View */ +$object = new Facture($db); +$object->fetch($id, $ref); +$object->fetch_thirdparty(); + +$object->info($object->id); + if (empty($object->id)) { llxHeader(); $langs->load('errors'); @@ -57,12 +63,6 @@ $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); -$object = new Facture($db); -$object->fetch($id, $ref); -$object->fetch_thirdparty(); - -$object->info($object->id); - $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); From 32ef42d163277ac67bc712900290335e9807f3fd Mon Sep 17 00:00:00 2001 From: Alain Rihs Date: Thu, 16 Dec 2021 10:22:43 +0100 Subject: [PATCH 306/576] Update notes.tpl.php See https://github.com/Dolibarr/dolibarr/issues/19580 The options of the advanced editor were not taken into account when editing public and private notes. I propose this code to fix this bug. --- htdocs/core/tpl/notes.tpl.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 6c01c44bc36..e0f0c5d9142 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -99,16 +99,26 @@ if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_ } else { $typeofdata = 'textarea:12:95%'; } +if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC)) { + $typeofdatapub = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note. +} else { + $typeofdatapub = 'textarea:12:95%'; +} +if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE)) { + $typeofdatapriv = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note. +} else { + $typeofdatapriv = 'textarea:12:95%'; +} print ''."\n"; print '
    '."\n"; print '
    '."\n"; $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_public); print '
    '."\n"; -print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); +print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdatapub, $moreparam, '', 0); print '
    '."\n"; print '
    '."\n"; -print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; +print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdatapub, '', null, null, $moreparam, 1)."\n"; print '
    '."\n"; print '
    '."\n"; if (empty($user->socid)) { @@ -116,10 +126,10 @@ if (empty($user->socid)) { print '
    '."\n"; $editmode = (GETPOST('action', 'aZ09') == 'edit'.$note_private); print '
    '."\n"; - print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); + print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdatapriv, $moreparam, '', 0); print '
    '."\n"; print '
    '."\n"; - print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); + print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdatapriv, '', null, null, $moreparam, 1); print '
    '."\n"; print '
    '."\n"; } From 41e4e70c6ec10eb3cf185d0c62525524ecaa922d Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Thu, 16 Dec 2021 16:28:45 +0700 Subject: [PATCH 307/576] Fix author searching include first and last name --- htdocs/compta/facture/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/mrp/mo_movements.php | 2 +- htdocs/product/stock/movement_card.php | 2 +- htdocs/product/stock/movement_list.php | 2 +- htdocs/product/stock/replenishorders.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fb27f03d72a..40b672cbd9e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -537,7 +537,7 @@ if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_status != '-1' && $search_status != '') diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 83e87e9b0f6..ab5fbe05e03 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -461,7 +461,7 @@ if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_status != '' && $search_status >= 0) $sql .= " AND f.fk_statut = ".$db->escape($search_status); if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".((int) $search_paymentmode); if ($search_paymentcond > 0) $sql .= " AND f.fk_cond_reglement = ".((int) $search_paymentcond); diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 600563f6cfd..c1d51bea6b0 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -428,7 +428,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); - if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); + if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index cf3cc67bdc2..5921679b238 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -464,7 +464,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login')', $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 47e28939e05..fa9cd293e1a 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -490,7 +490,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search('u.login', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if (!empty($product_id)) $sql .= natural_search('p.rowid', $product_id); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index c73c7b1ca39..9ee5ad40fd5 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -132,7 +132,7 @@ if (!$user->rights->societe->client->voir && !$socid) { } if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); -if ($suser) $sql .= natural_search('u.login', $suser); +if ($suser) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); $sql .= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 421ac40b447..ae1336c49d2 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -297,7 +297,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; if ($search_ref) $sql .= natural_search('sp.ref', $search_ref); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -if ($search_login) $sql .= natural_search('u.login', $search_login); +if ($search_login) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_login); if ($search_montant_ht) $sql .= natural_search('sp.total_ht=', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("sp.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("sp.total", $search_montant_ttc, 1); From d1495960439dd04dd377317b1f0394676bb9427f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 16 Dec 2021 10:33:53 +0100 Subject: [PATCH 308/576] fix test of method exist on wrong object --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 281e45baf51..7749a1176b2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1937,7 +1937,7 @@ function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookm if ($conf->global->SITUATION_DISPLAY_DIFF_ON_PDF) { $prev_progress = 0; - if (method_exists($object, 'get_prev_progress')) + if (method_exists($object->lines[$i], 'get_prev_progress')) { $prev_progress = $object->lines[$i]->get_prev_progress($object->id); } From e8eaf986feece47f1cc9c4eff0ecc0f398c8fd51 Mon Sep 17 00:00:00 2001 From: Jay Yeo Date: Thu, 16 Dec 2021 16:55:47 +0700 Subject: [PATCH 309/576] Fix author searching include first and last name --- htdocs/product/stock/movement_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 5921679b238..dd9e86f9737 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -464,7 +464,7 @@ if (!empty($search_inventorycode)) $sql .= natural_search('m.inventorycode', $se if (!empty($search_product_ref)) $sql .= natural_search('p.ref', $search_product_ref); if (!empty($search_product)) $sql .= natural_search('p.label', $search_product); if ($search_warehouse != '' && $search_warehouse != '-1') $sql .= natural_search('e.rowid', $search_warehouse, 2); -if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login')', $search_user); +if (!empty($search_user)) $sql .= natural_search(array('u.lastname', 'u.firstname', 'u.login'), $search_user); if (!empty($search_batch)) $sql .= natural_search('m.batch', $search_batch); if ($search_qty != '') $sql .= natural_search('m.value', $search_qty, 1); if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql .= natural_search('m.type_mouvement', $search_type_mouvement, 2); From 43e682b56f41e5cc080abb1dc3abab3170b5addd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 12:33:45 +0100 Subject: [PATCH 310/576] Fix several pb with down payments --- htdocs/compta/facture/card.php | 44 ++++++++++++++----- .../compta/paiement/class/paiement.class.php | 2 +- htdocs/core/class/commoninvoice.class.php | 1 + htdocs/fourn/facture/card.php | 5 ++- htdocs/install/mysql/migration/repair.sql | 3 ++ 5 files changed, 41 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index da77b75d9a6..80c7bafc3d7 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -970,10 +970,13 @@ if (empty($reshook)) { $object->fetch($id); if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0) { $paiement = new Paiement($db); - $result = $paiement->fetch(GETPOST('paiement_id')); + $result = $paiement->fetch(GETPOST('paiement_id', 'int')); if ($result > 0) { $result = $paiement->delete(); // If fetch ok and found - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + if ($result >= 0) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } } if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); @@ -3857,7 +3860,6 @@ if ($action == 'create') { // For example print 239.2 - 229.3 - 9.9; does not return 0. // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency @@ -3866,7 +3868,10 @@ if ($action == 'create') { $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); - $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + // Code to fix case of corrupted data + if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { + $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + } } if ($object->paye) { @@ -5297,7 +5302,7 @@ if ($action == 'create') { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); - // Reopen a standard paid invoice + // Reopen an invoice if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) || ($object->type == Facture::TYPE_DEPOSIT && empty($discount->id)) @@ -5362,14 +5367,18 @@ if ($action == 'create') { if ($objectidnext) { print ''.$langs->trans('DoPayment').''; } else { - //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) - // print '
    ' . $langs->trans('DoPayment') . '
    '; - //} else { + if ($object->type == Facture::TYPE_DEPOSIT && $resteapayer == 0) { + // For down payment, we refuse to receive more than amount to pay. + print ''.$langs->trans('DoPayment').''; + } else { + // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) print '
    '.$langs->trans('DoPayment').''; - //} + } } } + $sumofpayment = $object->getSommePaiement(); + // Reverse back money or convert to reduction if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) { // For credit note only @@ -5387,21 +5396,32 @@ if ($action == 'create') { } // For credit note if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercancreate - && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) + && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $sumofpayment == 0) ) { print ''.$langs->trans('ConvertToReduc').''; } // For deposit invoice if ($object->type == Facture::TYPE_DEPOSIT && $usercancreate && $object->statut > 0 && empty($discount->id)) { - print ''.$langs->trans('ConvertToReduc').''; + if (price2num($object->total_ttc, 'MT') == price2num($sumofpayment, 'MT')) { + // We can close a down payment only if paid amount is same than amount of down payment (by definition) + print ''.$langs->trans('ConvertToReduc').''; + } else { + print ''.$langs->trans('ConvertToReduc').''; + } } } // Classify paid if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) + || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && !empty($discount->id)) // If down payment is paid and then converted in credit, we can close it. ) { - print ''.$langs->trans('ClassifyPaid').''; + if (price2num($object->total_ttc, 'MT') == price2num($sumofpayment, 'MT')) { + // We can close a down payment only if paid amount is same than amount of down payment (by definition) + print ''.$langs->trans('ClassifyPaid').''; + } else { + print ''.$langs->trans('ClassifyPaid').''; + } } // Classify 'closed not completely paid' (possible if validated and not yet filed paid) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 971400afa5e..6b5ab4ef333 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -483,7 +483,7 @@ class Paiement extends CommonObject // Verifier si paiement porte pas sur une facture classee // Si c'est le cas, on refuse la suppression - $billsarray = $this->getBillsArray('fk_statut > 1'); + $billsarray = $this->getBillsArray('f.fk_statut > 1'); if (is_array($billsarray)) { if (count($billsarray)) { $this->error = "ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible"; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 605ffec63bd..f6edbd3f8d4 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -168,6 +168,7 @@ abstract class CommonInvoice extends CommonObject $discountstatic = new DiscountAbsolute($this->db); $result = $discountstatic->getSumDepositsUsed($this, $multicurrency); + if ($result >= 0) { return $result; } else { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 79a93cf3b0c..9efb21c4594 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2412,7 +2412,10 @@ if ($action == 'create') { $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); - $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + // Code to fix case of corrupted data + if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { + $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); + } } if ($object->paye) { diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 5208a733769..4935577cbf8 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -534,6 +534,9 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL --update llx_facture set paye = 1, fk_statut = 2 where rowid in (select rowid from tmp_invoice_deposit_mark_as_available); +-- TODO We should fix multicurrency_amount that are empty into llx_societe_remise_except, but we can't because we don't know what is the rate +-- We may retreive info fro minvoice line by using fk_facture_line or fk_facture_supplier_line +-- select * from llx_societe_remise_except where multicurrency_amount_ht = 0 and amount_ht <> 0; -- Note to migrate from old counter aquarium to new one From f1af5a41bf6a1c298e5e78c589c4657bda8546ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 12:53:46 +0100 Subject: [PATCH 311/576] Fix several pb with down payments --- htdocs/compta/facture/card.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 80c7bafc3d7..1ca81169cfb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5412,15 +5412,14 @@ if ($action == 'create') { } // Classify paid - if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0))) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && empty($discount->id)) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $object->total_ttc > 0 && $resteapayer == 0 && $usercanissuepayment && !empty($discount->id)) // If down payment is paid and then converted in credit, we can close it. + if (($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment + && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0) || ($object->type == Facture::TYPE_DEPOSIT && $object->total_ttc > 0))) ) { - if (price2num($object->total_ttc, 'MT') == price2num($sumofpayment, 'MT')) { + if ($object->type == Facture::TYPE_DEPOSIT && price2num($object->total_ttc, 'MT') != price2num($sumofpayment, 'MT')) { // We can close a down payment only if paid amount is same than amount of down payment (by definition) - print ''.$langs->trans('ClassifyPaid').''; - } else { print ''.$langs->trans('ClassifyPaid').''; + } else { + print ''.$langs->trans('ClassifyPaid').''; } } From 84400cf1d30df850a47a4ebe14e2d6c72d91eabb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 13:35:17 +0100 Subject: [PATCH 312/576] Fix backto page --- htdocs/comm/card.php | 6 +++--- htdocs/comm/remise.php | 27 +++++++++++++++--------- htdocs/core/tpl/object_discounts.tpl.php | 4 ++-- htdocs/fourn/card.php | 6 +++--- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index aaab987fd9c..2fe683f4f8e 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -465,7 +465,7 @@ if ($object->id > 0) { print $langs->trans("CustomerRelativeDiscountShort"); print '
    '; + print ''; if ($action != 'editinvoicedate' && !empty($object->brouillon) && $usercancreate && empty($conf->global->FAC_FORCE_DATE_VALIDATION)) { @@ -4385,7 +4385,7 @@ if ($action == 'create') { if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { // Date invoice print '
    '; print $langs->trans('DateInvoice'); print '
    '; - print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $oldyear = $year; } From 01893caa610240b48076a315697319a2fd5778aa Mon Sep 17 00:00:00 2001 From: atm-gregr Date: Wed, 8 Dec 2021 14:40:46 +0100 Subject: [PATCH 219/576] bad default value --- htdocs/contact/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 113fc5e74f7..1672bdd3f7f 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -96,6 +96,7 @@ $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); if ($search_status == '') $search_status = 1; // always display active customer first +if ($search_no_email == '') $search_no_email = -1; $optioncss = GETPOST('optioncss', 'alpha'); @@ -418,7 +419,7 @@ if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0"; -if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type From 8de8dacaa3c14396a594aa0b934fb2ec059bbf9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:07:55 +0100 Subject: [PATCH 220/576] Fix php warning --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a1bc165ee49..05ec2b969b3 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -274,7 +274,7 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { // Set the handler of session // if (ini_get('session.save_handler') == 'user') -if ($php_session_save_handler == 'db') { +if (!empty($php_session_save_handler) && $php_session_save_handler == 'db') { require_once 'core/lib/phpsessionin'.$php_session_save_handler.'.lib.php'; } From 5007282d7a0dc114bd327e16e448694788cb4993 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:16:06 +0100 Subject: [PATCH 221/576] Fix missing info popup on product --- htdocs/fourn/commande/dispatch.php | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 311cbd5f022..abeee1a9e26 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -788,6 +788,8 @@ if ($id > 0 || !empty($ref)) { $nbproduct = 0; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default) // or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on. + $conf->cache['product'] = array(); + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -815,11 +817,20 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; - $linktoprod = ''.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.''; + if (empty($conf->cache['product'][$objp->fk_product])) { + $tmpproduct = new Product($db); + $tmpproduct->fetch($objp->fk_product); + $conf->cache['product'][$objp->fk_product] = $tmpproduct; + } else { + $tmpproduct = $conf->cache['product'][$objp->fk_product]; + } + + $linktoprod = $tmpproduct->getNomUrl(1); $linktoprod .= ' - '.$objp->label."\n"; if (!empty($conf->productbatch->enabled)) { if ($objp->tobatch) { + // Product print '"; @@ -831,6 +842,7 @@ if ($id > 0 || !empty($ref)) { print ''; } } else { + // Product print '"; @@ -1150,10 +1162,11 @@ if ($id > 0 || !empty($ref)) { print '
    '; + print ''; print ''; @@ -4401,7 +4401,7 @@ if ($action == 'create') { // Payment term print ''; print ''; print '
    '; print $langs->trans('DatePointOfTax'); print 'id.'">'.img_edit($langs->trans('SetDate'), 1).'
    '; - print ''; print ''; print '
    '; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editconditions' && $usercancreate) { @@ -4422,7 +4422,7 @@ if ($action == 'create') { // Date payment term print ''; print ''; print '
    '; print $langs->trans('PaymentConditionsShort'); print '
    '; - print ''; print ''; print '
    '; + print ''; if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editpaymentterm' && $usercancreate) { @@ -4446,7 +4446,7 @@ if ($action == 'create') { // Payment mode print ''; print ''; print '
    '; print $langs->trans('DateMaxPayment'); print '
    '; - print ''; print ''; print '
    '; + print ''; if ($action != 'editmode' && $usercancreate) { @@ -4466,7 +4466,7 @@ if ($action == 'create') { // Multicurrency code print ''; print ''; print ''; print '
    '; print $langs->trans('PaymentMode'); print '
    '; - print ''; print ''; print '
    '; + print ''; if ($usercancreate && $action != 'editmulticurrencycode' && !empty($object->brouillon)) { @@ -4510,7 +4510,7 @@ if ($action == 'create') { // Bank Account if (!empty($conf->banque->enabled)) { print ''; print ''; print '
    '; print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print '
    '; - print ''; print ''; print '
    '; + print ''; print ''; print '
    '; print $langs->trans('BankAccount'); print ''; if (($action != 'editbankaccount') && $usercancreate) { @@ -4530,7 +4530,7 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { print '
    '; - print ''; print ''; print '
    '; + print ''; - // Bank Account + // Bank account if (!empty($conf->banque->enabled)) { print ''; + print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; + print ''; print '\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; print "\n"; @@ -768,7 +769,7 @@ if ($id) { if ($action == 'edit') { print $form->buttonsSaveCancel(); - print ""; + print "\n"; } From bfc8bb85a3d82b6ac989c740e0c515178b3f19e1 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 6 Dec 2021 18:23:47 +0100 Subject: [PATCH 207/576] FIX: thirparty ajax selector: no name or highlighting if at least ref and/or address displayed --- htdocs/societe/ajax/ajaxcompanies.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/ajax/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php index 89aa4f524b6..cbbcb14f361 100644 --- a/htdocs/societe/ajax/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -125,15 +125,17 @@ if (GETPOST('newcompany') || GETPOST('socid', 'int') || GETPOST('id_fourn', 'int if ($resql) { while ($row = $db->fetch_array($resql)) { $label = ''; - if ($conf->global->SOCIETE_ADD_REF_IN_LIST) { + if (! empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) { if (($row['client']) && (!empty($row['code_client']))) { $label = $row['code_client'].' - '; } if (($row['fournisseur']) && (!empty($row['code_fournisseur']))) { $label .= $row['code_fournisseur'].' - '; } - $label .= ' '.$row['name']; } + + $label .= $row['nom']; + if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) { $label .= ($row['address'] ? ' - '.$row['address'] : '').($row['zip'] ? ' - '.$row['zip'] : '').($row['town'] ? ' '.$row['town'] : ''); if (!empty($row['country_code'])) { From fe40668f43998bf28bba206fc4d3ff89516095ed Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 20:32:44 +0100 Subject: [PATCH 208/576] Parameter 4 extrafieldsobjectkey seems to be required now. --- ChangeLog | 1 + htdocs/core/class/extrafields.class.php | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00962b10419..a70ff0d00e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 61c40499150..4eefdd4c6bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1488,7 +1488,7 @@ class ExtraFields * @param string $key Key of attribute * @param string $value Value to show * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @param string $extrafieldsobjectkey If defined (for example $object->table_element), function uses the new method to get extrafields data + * @param string $extrafieldsobjectkey Required (for example $object->table_element). * @return string Formated value */ public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '') @@ -1510,11 +1510,9 @@ class ExtraFields $help = $this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden = (empty($list) ? 1 : 0); // If $list empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else { - // Old usage - $label = $this->attribute_label[$key]; - $type = $this->attribute_type[$key]; - $help = ''; // Not supported with old syntax - $hidden = 0; // hidden option only available for new syntax + // Old usage not allowed anymore + dol_syslog(get_class($this).'::showOutputField extrafieldsobjectkey required', LOG_WARNING); + return ''; } if ($hidden) { From ba507e7735ee91b9275487792af6244563f7cbe4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Dec 2021 20:53:01 +0100 Subject: [PATCH 209/576] css --- htdocs/theme/eldy/global.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 3c1a5abbe43..f61f5ab5c94 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -3607,7 +3607,7 @@ div.refidno { font-weight: normal; color: var(--refidnocolor); font-size: ; - line-height: 21px; + line-height: 1.4em; } div.refidno form { display: inline-block; From 5efa31204b4a6833e4d6b49e4f620fc3fde9f93c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 02:00:34 +0100 Subject: [PATCH 210/576] FIX ECM module was mixing contributions and vat and not showing salaries --- htdocs/core/ajax/ajaxdirpreview.php | 12 +++-- htdocs/core/ajax/ajaxdirtree.php | 4 +- htdocs/core/class/html.formfile.class.php | 9 +++- htdocs/ecm/index_auto.php | 57 ++++++++++++++--------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 63b4b3f7fc6..c4b79d89920 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -204,6 +204,8 @@ if ($type == 'directory') { 'contract', 'product', 'tax', + 'tax-vat', + 'salaries', 'project', 'project_task', 'fichinter', @@ -225,6 +227,7 @@ if ($type == 'directory') { // TODO change for multicompany sharing if ($module == 'company') { $upload_dir = $conf->societe->dir_output; + $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts. } elseif ($module == 'invoice') { $upload_dir = $conf->facture->dir_output; } elseif ($module == 'invoice_supplier') { @@ -243,6 +246,11 @@ if ($type == 'directory') { $upload_dir = $conf->product->dir_output; } elseif ($module == 'tax') { $upload_dir = $conf->tax->dir_output; + $excludefiles[] = '^vat$'; // The subdir 'vat' contains files of vats. + } elseif ($module == 'tax-vat') { + $upload_dir = $conf->tax->dir_output.'/vat'; + } elseif ($module == 'salaries') { + $upload_dir = $conf->salaries->dir_output; } elseif ($module == 'project') { $upload_dir = $conf->projet->dir_output; } elseif ($module == 'project_task') { @@ -280,10 +288,6 @@ if ($type == 'directory') { $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound"))); - if ($module == 'company') { - $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty. - } - $filter = preg_quote($search_doc_ref, '/'); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index d9a2c250b89..19c389ec7f8 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -125,7 +125,7 @@ $userstatic = new User($db); $form = new Form($db); $ecmdirstatic = new EcmDirectory($db); -// Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir +// Load full manual tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) { $sqltree = $ecmdirstatic->get_full_arbo(0); } @@ -169,7 +169,7 @@ if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) { print '
      '; - // Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir + // Load full manual tree from database. We will use it to define nbofsubdir and nboffilesinsubdir if (empty($sqltree)) { $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index e30f35758d1..cf3ff8dae4e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1676,6 +1676,12 @@ class FormFile } elseif ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; $object_instance = new ChargeSociales($this->db); + } elseif ($modulepart == 'tax-vat') { + include_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; + $object_instance = new Tva($this->db); + } elseif ($modulepart == 'salaries') { + include_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; + $object_instance = new Salary($this->db); } elseif ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $object_instance = new Project($this->db); @@ -1723,6 +1729,7 @@ class FormFile } //var_dump($filearray); + //var_dump($object_instance); // Get list of files stored into database for same relative directory $relativepathfromroot = preg_replace('/'.preg_quote(DOL_DATA_ROOT.'/', '/').'/', '', $upload_dir); @@ -1752,7 +1759,7 @@ class FormFile // To show ref or specific information according to view to show (defined by $modulepart) // $modulepart can be $object->table_name (that is 'mymodule_myobject') or $object->element.'-'.$module (for compatibility purpose) $reg = array(); - if ($modulepart == 'company' || $modulepart == 'tax') { + if ($modulepart == 'company' || $modulepart == 'tax' || $modulepart == 'tax-vat' || $modulepart == 'salaries') { preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); } elseif ($modulepart == 'invoice_supplier') { diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 7f098951fe7..c4ec6afc90b 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -310,59 +310,73 @@ $rowspan = 0; $sectionauto = array(); if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $langs->load("products"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); + $langs->load("products"); + $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); } if (!empty($conf->societe->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); + $rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); } if (!empty($conf->propal->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); + $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); } if (!empty($conf->contrat->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); + $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); } if (!empty($conf->commande->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); + $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); } if (!empty($conf->facture->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); + $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); } if (!empty($conf->supplier_proposal->enabled)) { - $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); + $langs->load("supplier_proposal"); + $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>$conf->supplier_proposal->enabled, 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); + $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); } if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); + $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); } if (!empty($conf->tax->enabled)) { - $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $langs->load("compta"); + $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); + $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>$conf->tax->enabled, 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT"))); + } + if (!empty($conf->salaries->enabled)) { + $langs->load("compta"); + $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>$conf->salaries->enabled, 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries"))); } if (!empty($conf->projet->enabled)) { - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project_task', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); + $rowspan++; $sectionauto[] = array('position'=>130, 'level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); + $rowspan++; $sectionauto[] = array('position'=>140, 'level'=>1, 'module'=>'project_task', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks"))); } if (!empty($conf->ficheinter->enabled)) { - $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); + $langs->load("interventions"); + $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); } if (!empty($conf->expensereport->enabled)) { - $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); + $langs->load("trips"); + $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); } if (!empty($conf->holiday->enabled)) { - $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); + $langs->load("holiday"); + $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); } if (!empty($conf->banque->enabled)) { - $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); + $langs->load("banks"); + $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); + $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>$conf->banque->enabled, 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt"))); } if (!empty($conf->mrp->enabled)) { - $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); + $langs->load("mrp"); + $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>$conf->mrp->enabled, 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); } if (!empty($conf->recruitment->enabled)) { - $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); + $langs->load("recruitment"); + $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>$conf->recruitment->enabled, 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); } - $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); + $rowspan++; $sectionauto[] = array('position'=>220, 'level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users"))); $parameters = array(); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); @@ -439,7 +453,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $act $oldvallevel = 0; foreach ($sectionauto as $key => $val) { if (empty($val['test'])) { - continue; // If condition to show is ok + continue; // If condition to show the ECM auto directory is ok } print '
    '; print ''; print '
    '; print $langs->trans('IncotermLabel'); print ''; if ($usercancreate) { @@ -4658,7 +4658,8 @@ if ($action == 'create') { print '
    '; print ''."\n"; - print ''; + print '
    '."\n"; + print '
    '; $sign = 1; if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && $object->type == $object::TYPE_CREDIT_NOTE) { diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index a87817cdc73..2a76b04fa41 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -186,9 +186,9 @@ class pdf_ban extends ModeleBankAccountDoc $pdf->SetTextColor(0, 0, 0); $tab_top = 50; - $tab_height = 200; $tab_top_newpage = 40; - $tab_height_newpage = 210; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Affiche notes if (!empty($object->note_public)) { diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 2259897f044..5d18a2ec8fc 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -198,9 +198,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc $pdf->SetTextColor(0, 0, 0); $tab_top = 50; - $tab_height = 200; $tab_top_newpage = 40; - $tab_height_newpage = 210; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show notes if (!empty($object->note_public)) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 01fde021cb0..e6ed244fc8f 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -388,6 +388,8 @@ class pdf_eratosthene extends ModelePDFCommandes $tab_top = 90 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { @@ -521,8 +523,8 @@ class pdf_eratosthene extends ModelePDFCommandes } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 9c549576818..903c8a233cd 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -342,8 +342,8 @@ class pdf_storm extends ModelePDFDeliveryOrder $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; $this->posxdesc = $this->marge_gauche + 1; @@ -352,7 +352,7 @@ class pdf_storm extends ModelePDFDeliveryOrder if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 19e319d0522..865bef37fbb 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -321,15 +321,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 2752f9a9c9b..fc1094ea949 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -324,8 +324,8 @@ class pdf_espadon extends ModelePdfExpedition $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift: 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; $this->posxdesc = $this->marge_gauche + 1; @@ -334,7 +334,7 @@ class pdf_espadon extends ModelePdfExpedition if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 56c8fb143fb..9a905422ff1 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -282,8 +282,8 @@ class pdf_merou extends ModelePdfExpedition $tab_top = 52; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter; - $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Display notes if (!empty($object->note_public)) { diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 4b542e4e636..211231b9812 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -349,15 +349,15 @@ class pdf_rouget extends ModelePdfExpedition $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index f5862bfc5f2..6fdc14ec1ad 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -313,8 +313,8 @@ class pdf_standard extends ModeleExpenseReport $tab_top = 95; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 65 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b919b90abfd..8d01927e1dc 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -411,18 +411,21 @@ class pdf_sponge extends ModelePDFFactures } $pagenb++; + // Output header (logo, ref and address blocks). This is first call for first page. $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90 + $top_shift; + // You can add more thing undr header here, if you increase top_shift too. + // TODO + + // $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks) + $tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases) $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); - $tab_height = 130 - $top_shift; - $tab_height_newpage = 150; - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { - $tab_height_newpage -= $top_shift; - } + + // Define heigth of table for lines (for first page) + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; $nexY = $tab_top - 1; @@ -447,7 +450,7 @@ class pdf_sponge extends ModelePDFFactures } } - // Displays notes + // Displays notes. Here we are still on code eecuted only for the first page. $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) { // Get first sale rep @@ -560,8 +563,8 @@ class pdf_sponge extends ModelePDFFactures } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; @@ -594,7 +597,7 @@ class pdf_sponge extends ModelePDFFactures // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); - // Table simulation to know the height of the title line + // Table simulation to know the height of the title line (this set this->tableTitleHeight) $pdf->startTransaction(); $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); @@ -1853,11 +1856,11 @@ class pdf_sponge extends ModelePDFFactures // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Show top header of page. + * Show top header of page. This include the logo, ref and address blocs * * @param TCPDF $pdf Object PDF * @param Facture $object Object to show - * @param int $showaddress 0=no, 1=yes + * @param int $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages) * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis * @return void diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index e23a0aa1701..719fb670672 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -271,8 +271,8 @@ class pdf_soleil extends ModelePDFFicheinter $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Display notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index 7f487fdcf94..bf06a1b73d2 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -499,14 +499,10 @@ class pdf_standard extends ModelePDFMovement $tab_top = 42; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; - /* ************************************************************************** */ - /* */ - /* Affichage de la liste des produits du MouvementStock */ - /* */ - /* ************************************************************************** */ + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + + // Show list of product of the MouvementStock $nexY += 5; $nexY = $pdf->GetY(); diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index d116976eb88..0927c795749 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -309,6 +309,8 @@ class pdf_vinci extends ModelePDFMo $tab_top = 90 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + // Affiche notes $notetoshow = empty($object->note_public) ? '' : $object->note_public; @@ -412,8 +414,8 @@ class pdf_vinci extends ModelePDFMo } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 815fc4d1c66..37aca08d146 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -270,8 +270,8 @@ class pdf_standard extends ModelePDFProduct $tab_top = 42; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Label of product $pdf->SetFont('', 'B', $default_font_size); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 373d41abc31..716c88e1f92 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -286,8 +286,8 @@ class pdf_baleine extends ModelePDFProjects $tab_top = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 170; - $tab_height_newpage = 190; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 30b9271a110..f71b0cdb6a7 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -327,8 +327,8 @@ class pdf_beluga extends ModelePDFProjects $tab_top = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 170; - $tab_height_newpage = 190; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index ef2ec4fcaf8..991ff794d72 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -286,8 +286,8 @@ class pdf_timespent extends ModelePDFProjects $tab_top = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 170; - $tab_height_newpage = 190; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Show public note $notetoshow = empty($object->note_public) ? '' : $object->note_public; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index d0e51fb8bc7..fd8b5c3389b 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -408,6 +408,7 @@ class pdf_cyan extends ModelePDFPropales $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); $tab_top = $nexY + 6; + $height_incoterms += 4; } } @@ -537,8 +538,8 @@ class pdf_cyan extends ModelePDFPropales } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 38344a5f486..9f03abef52c 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -263,15 +263,15 @@ class pdf_squille extends ModelePdfReception $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 0c627322d69..5d5e24f5fd1 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -293,14 +293,10 @@ class pdf_standard extends ModelePDFStock $tab_top = 80 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); - $tab_height = 130; + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; - /* ************************************************************************** */ - /* */ - /* Show list of product in warehouse */ - /* */ - /* ************************************************************************** */ + // Show list of product in warehouse */ $totalunit = 0; $totalvalue = $totalvaluesell = 0; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 436017cda0a..7738f1ec404 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -363,6 +363,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $tab_top = 90 + $top_shift; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + // Incoterm if (!empty($conf->incoterm->enabled)) { $desc_incoterms = $object->getIncotermsForPDF(); @@ -484,8 +486,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $height_note = $posyafter - $tab_top_newpage; $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else // No pagebreak - { + } else { + // No pagebreak $pdf->commitTransaction(); $posyafter = $pdf->GetY(); $height_note = $posyafter - $tab_top; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 5b9ffa062a3..beaddc3a33d 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -317,8 +317,8 @@ class pdf_standard extends ModelePDFSuppliersPayments $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); - $tab_height = 130; - $tab_height_newpage = 150; + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; // Incoterm $height_incoterms = 0; From ca6f22266285866c9479d9394f9e4da101f453ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 11:19:44 +0100 Subject: [PATCH 148/576] Fix notification (pb static var unknown) --- htdocs/core/class/notify.class.php | 6 +++--- htdocs/theme/eldy/global.inc.php | 22 +++++++++++++++++++++- htdocs/theme/md/style.css.php | 19 +++++++++++++++++++ test/phpunit/NumberingModulesTest.php | 6 ++++-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 2df88f51c0d..32ff4444a72 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -83,7 +83,6 @@ class Notify 'ACTION_CREATE' ); - /** * Constructor * @@ -92,6 +91,7 @@ class Notify public function __construct($db) { $this->db = $db; + $this->arrayofnotifsupported = self::$arrayofnotifsupported; } @@ -437,10 +437,10 @@ class Notify $notifcodedefid = $obj->adid; $trackid = ''; if ($obj->type_target == 'tocontactid') { - $trackid = 'con'.$obj->id; + $trackid = 'con'.$obj->cid; } if ($obj->type_target == 'touserid') { - $trackid = 'use'.$obj->id; + $trackid = 'use'.$obj->cid; } if (dol_strlen($obj->email)) { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 37692f46c1e..bd342be3f65 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4688,8 +4688,28 @@ div.ui-tooltip.mytooltip { background: var(--tooltipbgcolor) !important; color : var(--tooltipfontcolor); line-height: 1.6em; - min-width: 200px; + min-width: 550px; } +@media only screen and (max-width: 768px) +{ + div.ui-tooltip.mytooltip { + max-width: 400px; + } +} +@media only screen and (max-width: 480px) +{ + div.ui-tooltip.mytooltip { + max-width: 300px; + } +} +@media only screen and (max-width: 320px) +{ + div.ui-tooltip.mytooltip { + max-width: 230px; + } +} + + diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index dccd193454b..5d6cf2d8ead 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4642,6 +4642,25 @@ div.ui-tooltip.mytooltip { /*background: var(--tooltipbgcolor) !important; color : var(--tooltipfontcolor);*/ line-height: 1.6em; + min-width: 550px; +} +@media only screen and (max-width: 768px) +{ + div.ui-tooltip.mytooltip { + max-width: 400px; + } +} +@media only screen and (max-width: 480px) +{ + div.ui-tooltip.mytooltip { + max-width: 300px; + } +} +@media only screen and (max-width: 320px) +{ + div.ui-tooltip.mytooltip { + max-width: 230px; + } } diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index a34d3b28d1c..ceab1948732 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -144,13 +144,15 @@ class NumberingModulesTest extends PHPUnit\Framework\TestCase // First we try with a simple mask, with no reset // and we test counter is still increase second year. $conf->global->FACTURE_ADDON='mercure'; - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_DEPOSIT='{yyyy}-{0000}'; + $conf->global->FACTURE_MERCURE_MASK_REPLACEMENT='{yyyy}-{0000}'; $conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED=0; $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year (usefull only if numbering is {0000@1} $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); print __METHOD__." result=".$result."\n"; From bd0208b59574c08ab061fb4075e2b19c21d6e0b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 11:30:56 +0100 Subject: [PATCH 149/576] css --- htdocs/theme/md/style.css.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5d6cf2d8ead..6fd1a0f95f0 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3182,12 +3182,12 @@ div.tabBar { margin: 0px 0px 18px 0px; -webkit-border-radius: 3px; border-radius: 3px; - border-right: 1px solid #BBB; - border-left: 1px solid #BBB; + border-right: 1px solid #CCC; + border-left: 1px solid #CCC; border-top: 1px solid #CCC; + border-bottom: 1px solid #CCC; width: auto; background: var(--colorbacktabcard1); - border-bottom: 1px solid #aaa; } div.tabBar tr.titre td { From a3493d0132c1c15015550894bfe2f580b7af3a93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 11:33:51 +0100 Subject: [PATCH 150/576] Clean code --- htdocs/core/class/notify.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 32ff4444a72..a741af3d867 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -91,7 +91,6 @@ class Notify public function __construct($db) { $this->db = $db; - $this->arrayofnotifsupported = self::$arrayofnotifsupported; } @@ -346,7 +345,7 @@ class Notify global $dolibarr_main_url_root; global $action; - if (!in_array($notifcode, $this->arrayofnotifsupported)) { + if (!in_array($notifcode, Notify::$arrayofnotifsupported)) { return 0; } From 202b123aaaf0d5b5615e607d364a9009b38850b7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 2 Dec 2021 15:10:29 +0100 Subject: [PATCH 151/576] FIX compatibility with multicompany --- htdocs/societe/card.php | 4 ++-- htdocs/societe/website.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e5a624ec07f..fdff7c1940a 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -900,7 +900,7 @@ if (empty($reshook)) { // Actions to build doc $id = $socid; - $upload_dir = $conf->societe->dir_output; + $upload_dir = $conf->societe->multidir_output[$object->entity]; $permissiontoadd = $user->rights->societe->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -3006,7 +3006,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Presend form $modelmail = 'thirdparty'; $defaulttopic = 'Information'; - $diroutput = $conf->societe->dir_output; + $diroutput = $conf->societe->multidir_output[$object->entity]; $trackid = 'thi'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 0740200867d..7d79a429eea 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -159,7 +159,7 @@ if (empty($reshook)) { $objectlabel = 'WebsiteAccount'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; - $uploaddir = $conf->societe->dir_output; + $uploaddir = $conf->societe->multidir_output[$object->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } From b732d80ca5fc504799eeef70cd6f8a2965a5bd97 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 2 Dec 2021 15:56:34 +0100 Subject: [PATCH 152/576] Fix php 8.0 warnings --- htdocs/compta/facture/card.php | 10 ++++++---- htdocs/compta/facture/invoicetemplate_list.php | 6 +++++- htdocs/compta/facture/list.php | 8 ++++---- htdocs/compta/facture/stats/index.php | 6 +++--- htdocs/core/class/html.form.class.php | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 20f289ae141..c50f7a4e8e8 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -92,6 +92,8 @@ $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $fac_rec = GETPOST('fac_rec', 'int'); +$facid = GETPOST('facid', 'int'); +$ref_client = GETPOST('ref_client', 'int'); // PDF $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); @@ -2771,7 +2773,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; // Actions to build doc - $upload_dir = $conf->facture->multidir_output[$object->entity]; + $upload_dir = $conf->facture->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]; $permissiontoadd = $usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; @@ -3555,7 +3557,7 @@ if ($action == 'create') { print ''; - if ($conf->global->INVOICE_USE_RETAINED_WARRANTY) { + if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $rwStyle = 'display:none;'; if (in_array(GETPOST('type', 'int'), $retainedWarrantyInvoiceAvailableType)) { $rwStyle = ''; @@ -3631,7 +3633,7 @@ if ($action == 'create') { // Incoterms if (!empty($conf->incoterm->enabled)) { print ''; - print ''; + print ''; print ''; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index babadfe7366..c100263ac7f 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -380,11 +380,11 @@ foreach ($data as $val) { print ''; print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $oldyear = $year; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a6718531ff3..5423175859b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8435,7 +8435,7 @@ class Form 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, SUM(td.total_ht) as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('contract').') GROUP BY s.rowid, s.nom, s.client, t.rowid, t.ref, t.ref_customer, t.ref_supplier' ), - 'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), + 'fichinter'=>array('enabled'=>!empty($conf->ficheinter->enabled) ? $conf->ficheinter->enabled : 0, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('intervention').')'), 'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled, 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('supplier_proposal').')'), 'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled, 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande_fournisseur').')'), 'invoice_supplier'=>array('enabled'=>$conf->supplier_invoice->enabled, 'perms'=>1, 'label'=>'LinkToSupplierInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('facture_fourn').')'), From c171ba3a45dc9a12ece0e7f8a5bf238a9f86ac54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 16:07:33 +0100 Subject: [PATCH 153/576] Fix regression in cron jobs --- htdocs/core/class/conf.class.php | 5 +++-- htdocs/cron/class/cronjob.class.php | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 8776060b60f..581de47178c 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -167,15 +167,16 @@ class Conf * Load setup values into conf object (read llx_const) for a specified entity * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. * + * @param DoliDB $db Database handler * @param int $entity Entity to get * @return int < 0 if KO, >= 0 if OK */ - public function setEntityValues($entity) + public function setEntityValues($db, $entity) { if ($this->entity != $entity) { // If we ask to reload setup for a new entity $this->entity = $entity; - return $this->setValues($this->db); + return $this->setValues($db); } return 0; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 34fe7b6cd58..44564e1b0ab 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1081,7 +1081,7 @@ class Cronjob extends CommonObject dol_syslog("We try to run a job in entity ".$this->entity." when we are in entity ".$conf->entity, LOG_WARNING); } $savcurrententity = $conf->entity; - $conf->setEntityValues($this->entity); + $conf->setEntityValues($this->db, $this->entity); dol_syslog(get_class($this)."::run_jobs entity for running job is ".$conf->entity); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -1090,13 +1090,13 @@ class Cronjob extends CommonObject if ($result < 0) { $this->error = "User Error:".$user->error; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } else { if (empty($user->id)) { $this->error = " User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } } @@ -1126,7 +1126,7 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1241,7 +1241,7 @@ class Cronjob extends CommonObject if ($ret === false) { $this->error = $langs->trans('CronCannotLoadLib').': '.$libpath; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1250,7 +1250,7 @@ class Cronjob extends CommonObject $result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing if ($result < 0) { // If technical error dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } @@ -1316,11 +1316,11 @@ class Cronjob extends CommonObject $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return -1; } - $conf->setEntityValues($savcurrententity); + $conf->setEntityValues($this->db, $savcurrententity); return $error ?-1 : 1; } From 39ad96c230a9b5b5db6ede0951680d8897d10ca7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 17:47:03 +0100 Subject: [PATCH 154/576] css --- htdocs/holiday/list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 0ecdcb2dd69..207c7c31707 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -890,14 +890,15 @@ if ($resql) { $i++; } + // Add a line for total if there is a total to show if (!empty($arrayfields['duration']['checked'])) { - print ''; + print ''; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { if ($key == 'duration') { print ''; } else { - print ''; } } } From 075faded4760fde81266a01c4cc17822d0382155 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Oct 2021 11:58:21 +0200 Subject: [PATCH 155/576] FIX list of categories in stats of supplier invoices Conflicts: htdocs/compta/facture/stats/index.php --- htdocs/compta/facture/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index a42003e3c2a..8a32077cb54 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -309,7 +309,7 @@ if (!empty($conf->category->enabled)) { $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } print ''; - print ''; + print ''; print ''; $i++; From 1db52532ff34924a60757c9ec873c4c253bf3d66 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Dec 2021 01:50:17 +0100 Subject: [PATCH 163/576] FIX: do not update holiday for closed users --- htdocs/holiday/class/holiday.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 89760c4d1ac..9a45a735716 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1470,11 +1470,11 @@ class Holiday extends CommonObject $monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; //print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit; - // Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp + // If month date is not same than the one of last update (the one we saved in database), then we update the timestamp and balance of each open user. if ($month != $monthLastUpdate) { $this->db->begin(); - $users = $this->fetchUsers(false, false); + $users = $this->fetchUsers(false, false, ' AND u.statut > 0'); $nbUser = count($users); $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; @@ -1675,7 +1675,7 @@ class Holiday extends CommonObject * * @param boolean $stringlist If true return a string list of id. If false, return an array with detail. * @param boolean $type If true, read Dolibarr user list, if false, return vacation balance list. - * @param string $filters Filters + * @param string $filters Filters. Warning: This must not contains data from user input. * @return array|string|int Return an array */ public function fetchUsers($stringlist = true, $type = true, $filters = '') @@ -1776,7 +1776,7 @@ class Holiday extends CommonObject // Si faux donc return array // List for Dolibarr users if ($type) { - // If user of Dolibarr + // If we need users of Dolibarr $sql = "SELECT"; if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " DISTINCT"; From 1e845434e05569dc88d8b228a4b7d51547f42cf4 Mon Sep 17 00:00:00 2001 From: mbinformatique68 Date: Fri, 3 Dec 2021 09:42:50 +0100 Subject: [PATCH 164/576] Get societe terms of payment if getpost terms of payment is 0 --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 2d8887c7929..66191110de2 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1646,7 +1646,7 @@ if ($action == 'create') { // Terms of payment print ''; // Mode of payment From 093191aeebc6685290c317884cc9d2c526265aba Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 3 Dec 2021 10:37:48 +0100 Subject: [PATCH 165/576] FIx php8.0 warnings --- htdocs/fourn/paiement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index c4e18d50f90..5c76c1dddd0 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -348,7 +348,7 @@ if ($moreforfilter) { $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) { +if (!empty($massactionbutton)) { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } From 2f4fe2b898c445f44dfbb7efcc37033c7b5a323e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 3 Dec 2021 10:59:47 +0100 Subject: [PATCH 166/576] error message --- htdocs/hrm/class/skill.class.php | 8 ++++++- htdocs/hrm/lib/hrm_skillrank.lib.php | 36 +++++++++++++++------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 0b247e7f5f4..ebf568e68fe 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -410,7 +410,13 @@ class Skill extends CommonObject $skilldet = new Skilldet($this->db); $this->lines = $skilldet->fetchAll('ASC', '', '', '', array('fk_skill' => $this->id), ''); - return (count($this->lines) > 0 ) ? $this->lines : array(); + if (is_array($this->lines)) { + return (count($this->lines) > 0) ? $this->lines : array(); + } elseif ($this->lines < 0) { + $this->errors = array_merge($this->errors, $skilldet->errors); + $this->error = $skilldet->error; + return $this->lines; + } } diff --git a/htdocs/hrm/lib/hrm_skillrank.lib.php b/htdocs/hrm/lib/hrm_skillrank.lib.php index 2aca41504ad..78a53823c2d 100644 --- a/htdocs/hrm/lib/hrm_skillrank.lib.php +++ b/htdocs/hrm/lib/hrm_skillrank.lib.php @@ -115,44 +115,48 @@ function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode $skilldet = new Skilldet($db); $Lines = $skilldet->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); + if (!is_array($Lines) && $Lines<0) { + setEventMessages($skilldet->error, $skilldet->errors, 'errors'); + } if (empty($Lines)) return $langs->trans('SkillHasNoLines'); $ret = '0'; + if (is_array($Lines) && !empty($Lines)) { + foreach ($Lines as $line) { + $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; + if ($line->rank > $MaxNumberSkill) { + continue; + } - foreach ($Lines as $line) { - $MaxNumberSkill = isset($conf->global->HRM_MAXRANK) ? $conf->global->HRM_MAXRANK : Skill::DEFAULT_MAX_RANK_PER_SKILL; - if ($line->rank > $MaxNumberSkill) { - continue; + $ret .= '' . $line->rank . ''; } - $ret.= ''.$line->rank.''; - } - - if ($mode == 'edit') { - $ret.= ' - + if ($mode == 'edit') { + $ret .= ' + '; + } } return $ret; From b024bf20ed699b1cf7cb17d0adb35931569a823c Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Fri, 3 Dec 2021 13:57:34 +0100 Subject: [PATCH 167/576] Update html.form.class.php When you pay an invoice, you can send the payment multiple times. --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5813c45047a..7f7f3313139 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5018,7 +5018,7 @@ class Form } $formconfirm .= '
    '; - if (empty($conf->use_javascript_ajax)) { + if (!empty($conf->use_javascript_ajax)) { $formconfirm .= ''; $formconfirm .= ''; From 7018fe9530e75a1eb13e5d4eb2f28f076cb3c60c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 16:48:39 +0100 Subject: [PATCH 203/576] Update changelog ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 00962b10419..023b70ec79e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed From 6af2626f081e18f736f92dbf30d980039ea56659 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 6 Dec 2021 16:55:51 +0100 Subject: [PATCH 204/576] FIX: contact card: bad colspan value for separator extrafield in creation/modification form --- htdocs/contact/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 5110e08e2fc..a43c7c34e7f 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -850,7 +850,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Other attributes - $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3); + $parameters = array('socid' => $socid, 'objsoc' => $objsoc, 'colspan' => ' colspan="3"', 'cols' => 3, 'colspanvalue' => 3); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; print "
    '; $incoterm_id = GETPOST('incoterm_id'); $incoterm_location = GETPOST('location_incoterms'); @@ -3644,7 +3646,7 @@ if ($action == 'create') { } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid); + $parameters = array('objectsrc' => !empty($objectsrc) ? $objectsrc : 0, 'colspan' => ' colspan="2"', 'cols' => '2', 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 9619e1a9ddd..d785ccbce93 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -692,6 +692,10 @@ if ($resql) { if ($num > 0) { $i = 0; $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['f.total_ht'] = 0; + $totalarray['val']['f.total_tva'] = 0; + $totalarray['val']['f.total_ttc'] = 0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); if (empty($objp)) { @@ -701,7 +705,7 @@ if ($resql) { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; - $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid; + $invoicerectmp->id = !empty($objp->id) ? $objp->id : $objp->facid; $invoicerectmp->frequency = $objp->frequency; $invoicerectmp->suspended = $objp->suspended; $invoicerectmp->unit_frequency = $objp->unit_frequency; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 52b2fcceee0..02ce893b96d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -805,7 +805,7 @@ if (!$sall) { } } // Add GroupBy from hooks - $parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); + $parameters = array('all' => !empty($all) ? $all : 0, 'fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; } else { @@ -1650,7 +1650,7 @@ if ($resql) { $facturestatic->note_public = $obj->note_public; $facturestatic->note_private = $obj->note_private; - if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_WARRANTY) { + if (!empty($conf->global->INVOICE_USE_SITUATION) && !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { $facturestatic->retained_warranty = $obj->retained_warranty; $facturestatic->retained_warranty_date_limit = $obj->retained_warranty_date_limit; $facturestatic->situation_final = $obj->retained_warranty_date_limit; @@ -1846,8 +1846,8 @@ if ($resql) { } // Alias if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - print dol_escape_htmltag($obj->name_alias); + print ''; + print dol_escape_htmltag((!empty($obj->name_alias) ? $obj->name_alias : '')); print '
    0 ? '&userid='.$userid : '').'">'.$year.''.$val['nb'].''.($val['nb_diff'] < 0 ? '' : '+').round($val['nb_diff']).'%'.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.price(price2num($val['total'], 'MT'), 1).''.($val['total_diff'] < 0 ? '' : '+').round($val['total_diff']).'%'.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.price(price2num($val['avg'], 'MT'), 1).''.($val['avg_diff'] < 0 ? '' : '+').round($val['avg_diff']).'%'.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%
    '.$totalduration.' '.$langs->trans('DurationDays').''; + print '
    '.$cat_label.''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + $cate_arbo = $form->select_all_categories($cat_type, null, 'parent', null, null, 1); print img_picto('', 'category', 'class="pictofixedwidth"'); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), 0, 0, 'widthcentpercentminusx maxwidth300'); //print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); From 7e835ec91534435873758e7ba110537e092c7559 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 19:06:44 +0100 Subject: [PATCH 156/576] Fix css --- htdocs/theme/eldy/info-box.inc.php | 12 ++++++------ htdocs/theme/md/info-box.inc.php | 31 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 3fe2552c86a..40a62dbf18a 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -330,15 +330,15 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { color: #b06080 !important; } /* Color for customer object */ -.infobox-propal:not(.pictotitle), -.infobox-facture:not(.pictotitle), -.infobox-commande:not(.pictotitle) { +.infobox-propal:not(.pictotitle):not(.error), +.infobox-facture:not(.pictotitle):not(.error), +.infobox-commande:not(.pictotitle):not(.error) { color: #65953d !important; } /* Color for vendor object */ -.infobox-supplier_proposal:not(.pictotitle), -.infobox-invoice_supplier:not(.pictotitle), -.infobox-order_supplier:not(.pictotitle){ +.infobox-supplier_proposal:not(.pictotitle):not(.error), +.infobox-invoice_supplier:not(.pictotitle):not(.error), +.infobox-order_supplier:not(.pictotitle):not(.error) { color: #599caf !important; } .infobox-contrat, .infobox-ticket{ diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index a363475c409..02f263900c6 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -28,7 +28,7 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { ?> .customer-back { - background-color: #99a17d !important; + background-color: #65953d !important; color: #FFF !important; padding: 2px; margin: 2px; @@ -56,15 +56,11 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { .bg-infobox-action{ color: #a47080 !important; } -.bg-infobox-propal, -.bg-infobox-facture, -.bg-infobox-commande{ - color: #99a17d !important; +.bg-infobox-propal, .bg-infobox-facture, .bg-infobox-commande { + color: #65953d !important; } -.bg-infobox-supplier_proposal, -.bg-infobox-invoice_supplier, -.bg-infobox-order_supplier{ - color: #599caf !important; +.bg-infobox-supplier_proposal, .bg-infobox-invoice_supplier, .bg-infobox-order_supplier { + color: #599caf !important; } .bg-infobox-contrat, .bg-infobox-ticket{ color: #46a676 !important; @@ -92,16 +88,19 @@ if (GETPOSTISSET('THEME_SATURATE_RATIO')) { .infobox-action{ color: #a47080 !important; } -.infobox-propal, -.infobox-facture, -.infobox-commande{ - color: #99a17d !important; +/* Color for customer object */ +.infobox-propal:not(.pictotitle):not(.error), +.infobox-facture:not(.pictotitle):not(.error), +.infobox-commande:not(.pictotitle):not(.error) { + color: #65953d !important; } -.infobox-supplier_proposal, -.infobox-invoice_supplier, -.infobox-order_supplier{ +/* Color for vendor object */ +.infobox-supplier_proposal:not(.pictotitle):not(.error), +.infobox-invoice_supplier:not(.pictotitle):not(.error), +.infobox-order_supplier:not(.pictotitle):not(.error) { color: #599caf !important; } + .infobox-contrat, .infobox-ticket{ color: #46a676 !important; } From 9c083071b8e3eda104c14b0b32f716d072d18406 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 20:39:53 +0100 Subject: [PATCH 157/576] Better test --- htdocs/public/test/test_exec.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index a25e860021c..f805cc19b5c 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -66,7 +66,7 @@ echo "Test
    \n"; $out=''; $ret=0; -$file = '/tmp/aaa'; +$file = '/tmp/test.txt'; $f=fopen($file, 'r'); if ($f) { $s=fread($f, 4096); @@ -76,10 +76,14 @@ if ($f) { print "Failed to open file ".$file."
    \n"; } -exec('cat /aaa; ls /dev/std*; sleep 1;', $out, $ret); +print '

    '."\n"; + +exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); print $ret."
    \n"; print_r($out); +print '

    '."\n"; + $ret = 0; $out = null; exec('/usr/bin/clamdscan --fdpass filethatdoesnotexists.php', $out, $ret); From 2300f1710188dc467e1e4f73c58b389f5fc414cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 20:40:41 +0100 Subject: [PATCH 158/576] test --- htdocs/public/test/test_exec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index f805cc19b5c..3fd66b40635 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -78,7 +78,7 @@ if ($f) { print '

    '."\n"; -exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); +exec('cat /test.txt; ls /dev/std*; id; sleep 1;', $out, $ret); print $ret."
    \n"; print_r($out); From ac17378972b2168501a0e901f2a8604c3a481937 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 20:41:13 +0100 Subject: [PATCH 159/576] revert --- htdocs/public/test/test_exec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/test/test_exec.php b/htdocs/public/test/test_exec.php index 3fd66b40635..f805cc19b5c 100644 --- a/htdocs/public/test/test_exec.php +++ b/htdocs/public/test/test_exec.php @@ -78,7 +78,7 @@ if ($f) { print '

    '."\n"; -exec('cat /test.txt; ls /dev/std*; id; sleep 1;', $out, $ret); +exec('cat /test.txt; ls /dev/std*; sleep 1;', $out, $ret); print $ret."
    \n"; print_r($out); From c23914f367eaf1555bff2569d77e800c6e5205ca Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 2 Dec 2021 23:05:18 +0100 Subject: [PATCH 160/576] FIX load css file --- htdocs/takepos/split.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index 75599d0160f..dbe474968a9 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -137,7 +137,7 @@ if ($invoiceid > 0) { } } -$arrayofcss = array('/takepos/css/pos.css.php', '/takepos/css/split.css.php'); +$arrayofcss = array('/takepos/css/pos.css.php'); $arrayofjs = array(); $head = ''; @@ -225,4 +225,4 @@ $( document ).ready(function() { - \ No newline at end of file + From 2b5bcda8d8a7a9ce0fadcbf0b0c6d287c5ce348e Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 2 Dec 2021 23:08:22 +0100 Subject: [PATCH 161/576] FIX Avoid move line to the same place in TakePOS --- htdocs/takepos/split.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/split.php b/htdocs/takepos/split.php index dbe474968a9..02c37cb75e5 100644 --- a/htdocs/takepos/split.php +++ b/htdocs/takepos/split.php @@ -84,6 +84,7 @@ if ($action=="split") { $db->query($sql); } elseif ($split==0) { // Unsplit line $invoice = new Facture($db); + if ($place=="SPLIT") $place="0"; // Avoid move line to the same place (from SPLIT to SPLIT place) $ret = $invoice->fetch('', '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')'); if ($ret > 0) { $placeid = $invoice->id; From d9aa4713709d3082d40795cddc4a18353efc581a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Dec 2021 01:39:16 +0100 Subject: [PATCH 162/576] Fix color status --- htdocs/hrm/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 6bd777401f7..ef231b48eff 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -223,6 +223,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { $holidaystatic->id = $obj->rowid; $holidaystatic->ref = $obj->ref; $holidaystatic->statut = $obj->status; + $holidaystatic->date_debut = $db->jdate($obj->date_start); $userstatic->id = $obj->uid; $userstatic->lastname = $obj->lastname; @@ -243,7 +244,7 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) { print '
    '.dol_print_date($db->jdate($obj->date_start), 'day').' '.$langs->trans($listhalfday[$starthalfday]).''; print ''.dol_print_date($db->jdate($obj->date_end), 'day').' '.$langs->trans($listhalfday[$endhalfday]).''; print ''.dol_print_date($db->jdate($obj->dm), 'day').''.$holidaystatic->LibStatut($obj->status, 3).''.$holidaystatic->LibStatut($obj->status, 3, $holidaystatic->date_debut).'
    '.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'paiment'); - $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id), 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements((GETPOSTISSET('cond_reglement_id') && GETPOST('cond_reglement_id') != 0) ? GETPOST('cond_reglement_id', 'int') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print '

    "; @@ -1161,7 +1161,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3'); + $parameters = array('colspan' => ' colspan="3"', 'cols'=> '3', 'colspanvalue'=> '3'); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; $object->load_ref_elements(); From 16c4dec6dac82cc1f672b11e6c3f2de82626f056 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 6 Dec 2021 17:36:00 +0100 Subject: [PATCH 205/576] Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 023b70ec79e..9fa65871f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -144,6 +144,7 @@ Following changes may create regressions for some external modules, but were nec * Method getDictvalue has been renamed into getDictionaryValue to match camel case rule. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php * ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed From 1caaa335d16b5b5bfb1dbff16ae23cfb4ab9d36a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Dec 2021 18:18:31 +0100 Subject: [PATCH 206/576] Fix missing section with files on social contribution page --- htdocs/compta/sociales/card.php | 132 ++++++++++++++++++++++++++------ htdocs/compta/tva/card.php | 13 ++-- 2 files changed, 114 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 8207802feaa..98ebe32f970 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -26,11 +26,11 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -46,8 +46,14 @@ if (!empty($conf->accounting->enabled)) { $langs->loadLangs(array('compta', 'bills', 'banks', 'hrm')); $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); -$confirm = GETPOST('confirm'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); +$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); + $fk_project = (GETPOST('fk_project') ? GETPOST('fk_project', 'int') : 0); $dateech = dol_mktime(GETPOST('echhour'), GETPOST('echmin'), GETPOST('echsec'), GETPOST('echmonth'), GETPOST('echday'), GETPOST('echyear')); @@ -56,11 +62,28 @@ $label = GETPOST('label', 'alpha'); $actioncode = GETPOST('actioncode'); $fk_user = GETPOST('userid', 'int'); +// Initialize technical objects $object = new ChargeSociales($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->tax->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('taxsocialcontributioncard', 'globalcard')); + +if (empty($action) && empty($id) && empty($ref)) { + $action = 'view'; +} + +// Load object if ($id > 0) { $object->fetch($id); } +$permissiontoread = $user->rights->tax->charges->lire; +$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1]; + // Security check $socid = GETPOST('socid', 'int'); if ($user->socid) { @@ -74,6 +97,12 @@ $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges') * Actions */ +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + // Classify paid if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') { $object->fetch($id); @@ -122,7 +151,7 @@ if ($action == 'setmode' && $user->rights->tax->charges->creer) { } } -// bank account +// Bank account if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); @@ -151,7 +180,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { // Add social contribution if ($action == 'add' && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); @@ -189,7 +218,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) { if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (!$dateech) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); @@ -297,6 +326,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char */ $form = new Form($db); +$formfile = new FormFile($db); $formsocialcontrib = new FormSocialContrib($db); $bankaccountstatic = new Account($db); if (!empty($conf->projet->enabled)) { @@ -308,7 +338,7 @@ $help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividen llxHeader("", $title, $help_url); -// Mode creation +// Form to create a social contribution if ($action == 'create') { print load_fiche_titre($langs->trans("NewSocialContribution")); @@ -411,11 +441,7 @@ if ($action == 'create') { print ''; } -/* *************************************************************************** */ -/* */ -/* Card Mode */ -/* */ -/* *************************************************************************** */ +// View mode if ($id > 0) { $object = new ChargeSociales($db); $result = $object->fetch($id); @@ -594,7 +620,7 @@ if ($id > 0) { } print '
    '; print ''; } + // Other attributes + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
    '; @@ -614,6 +640,11 @@ if ($id > 0) { print '
    '; print ''; @@ -627,7 +658,7 @@ if ($id > 0) { /* * Payments */ - $sql = "SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount,"; + $sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,"; $sql .= " c.code as type_code,c.libelle as paiement_type,"; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -637,7 +668,7 @@ if ($id > 0) { $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= " WHERE p.fk_charge = ".((int) $id); $sql .= " AND p.fk_charge = cs.rowid"; - $sql .= " AND cs.entity IN (".getEntity('tax').")"; + $sql .= " AND cs.entity IN (".getEntity('sc').")"; $sql .= " ORDER BY dp DESC"; //print $sql; @@ -735,22 +766,15 @@ if ($id > 0) { print dol_get_fiche_end(); if ($action == 'edit') { - print '
    '; - print ''; - print '   '; - print ''; - print '
    '; - } + print $form->buttonsSaveCancel(); - if ($action == 'edit') { print "\n"; } - /* - * Actions buttons - */ + // Buttons for actions + if ($action != 'edit') { print '
    '."\n"; @@ -788,6 +812,64 @@ if ($id > 0) { print "
    "; } + + + // Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + if ($action != 'presend') { + print '
    '; + print ''; // ancre + + $includedocgeneration = 1; + + // Documents + if ($includedocgeneration) { + $objref = dol_sanitizeFileName($object->ref); + $relativepath = $objref.'/'.$objref.'.pdf'; + $filedir = $conf->tax->dir_output.'/'.$objref; + $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; + //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content + $genallowed = 0; + $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('tax', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); + } + + // Show links to link elements + //$linktoelem = $form->showLinkToObjectBlock($object, null, array('myobject')); + //$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + + + print '
    '; + + /* + $MAXEVENT = 10; + + $morehtmlcenter = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', dol_buildpath('/mymodule/myobject_agenda.php', 1).'?id='.$object->id); + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, $object->element.'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1, '', $MAXEVENT, '', $morehtmlcenter); + */ + + print '
    '; + } + + //Select mail models is same action as presend + if (GETPOST('modelselected')) { + $action = 'presend'; + } + + // Presend form + $modelmail = 'sc'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->tax->dir_output; + $trackid = 'sc'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } else { /* Social contribution not found */ dol_print_error('', $object->error); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index ef09cd5aabc..530d18d17f9 100755 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -306,7 +306,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') { } if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) { - $amount = price2num(GETPOST('amount')); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); if (empty($amount)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); @@ -317,7 +317,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->cr } else { $result = $object->fetch($id); - $object->amount = price2num($amount); + $object->amount = $amount; $result = $object->update($user); if ($result <= 0) { @@ -339,8 +339,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->fetch($id); if ($object->id > 0) { - $object->paye = 0; $object->id = $object->ref = null; + $object->paye = 0; if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); @@ -535,7 +535,7 @@ if ($action == 'create') { } // View mode -if ($id) { +if ($id > 0) { $head = vat_prepare_head($object); $totalpaye = $object->getSommePaiement(); @@ -705,7 +705,8 @@ if ($id) { $objp = $db->fetch_object($resql); print '
    '; - print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."
    '; diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 8a3a6a142aa..3d2dee9a286 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -347,7 +347,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 8e4860bd2f2..7da90915b18 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -260,7 +260,7 @@ if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index babadfe7366..cc94deb4ba6 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -102,7 +102,7 @@ if ($mode == 'customer') { $stats->where .= ' AND f.fk_statut IN ('.$db->sanitize($object_status).')'; } if (is_array($custcats) && !empty($custcats)) { - $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)'; + $stats->from .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cat OmdN (f.fk_soc = cat.fk_soc)'; $stats->where .= ' AND cat.fk_categorie IN ('.$db->sanitize(implode(',', $custcats)).')'; } } @@ -341,7 +341,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index bb7d6b314aa..f56bdcd15ac 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -233,7 +233,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index fc8d69e4ce7..b97af33cb6e 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -238,7 +238,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index 500fe874747..ded5a7a3805 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -249,7 +249,7 @@ if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index f1247adb457..9e49d9bc4b5 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -245,7 +245,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index 878b80165d5..f41651e15d8 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -298,7 +298,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 5fd6b47407c..70c093f46e3 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -168,7 +168,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 8f20ed58065..35569dd7035 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -233,7 +233,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/salaries/stats/index.php b/htdocs/salaries/stats/index.php index 7eefe7982fc..cb8eb14a05b 100644 --- a/htdocs/salaries/stats/index.php +++ b/htdocs/salaries/stats/index.php @@ -212,7 +212,7 @@ if (!in_array($year, $arrayyears)) { $arrayyears[$year] = $year; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index d76800f6da5..37273ee4d1d 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -243,7 +243,7 @@ if (!in_array($nowyear, $arrayyears)) { $arrayyears[$nowyear] = $nowyear; } arsort($arrayyears); -print $form->selectarray('year', $arrayyears, $year, 0); +print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); print '
    '; From 5f5c284af750111839586ed763b1b6b77a5bb078 Mon Sep 17 00:00:00 2001 From: Vincent Dieltiens Date: Thu, 2 Dec 2021 18:20:06 +0100 Subject: [PATCH 212/576] Fixes https://github.com/Dolibarr/dolibarr/issues/19541 --- htdocs/expensereport/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 8880a60f351..38f7703f744 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1098,6 +1098,7 @@ if (empty($reshook)) { $arrayoffiles = GETPOST('attachfile', 'array'); if (is_array($arrayoffiles) && !empty($arrayoffiles[0])) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $entityprefix = ($conf->entity != '1') ? $conf->entity.'/' : ''; $relativepath = 'expensereport/'.$object->ref.'/'.$arrayoffiles[0]; $ecmfiles = new EcmFiles($db); $ecmfiles->fetch(0, '', $relativepath); From b2384190204b1f8eaacb7cfad91b0c8eff7bf485 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 13:39:06 +0100 Subject: [PATCH 213/576] Clean code --- htdocs/admin/system/xdebug.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index fd10aad05e8..8c3a70ff6ec 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -73,10 +73,10 @@ if (function_exists('socket_create')) { print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."
    \n"; print "
    \n"; - echo "To run a debug session, add parameter
    "; - echo "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.
    \n"; - echo "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter
    \n"; - echo "* XDEBUG_PROFILE=aname on each URL.
    "; + print "To run a debug session, add parameter
    "; + print "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.
    \n"; + print "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter
    \n"; + print "* XDEBUG_PROFILE=aname on each URL.
    "; print "
    "; print "Test debugger server (Eclipse for example):
    \n"; @@ -89,12 +89,12 @@ if (function_exists('socket_create')) { //$client = socket_accept($sock); $client = socket_connect($socket, $address, $port); if ($client) { - echo "Connection established: ".$client." - address=".$address." port=".$port."
    \n"; - echo "There is a Remote debug server at this address.
    \n"; - echo "
    \n"; - echo "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n"; - echo "your php.ini file with this :
    \n"; - echo '\n"; print "

    \n"; - echo 'Then check in your debug server (Eclipse), you have setup:
    + print 'Then check in your debug server (Eclipse), you have setup:
    XDebug with same port than in php.ini
    Allow Remote debug=yes or prompt
    '."\n"; print "
    \n"; } else { print socket_strerror(socket_last_error()); - echo "Failed to connect to address=".$address." port=".$port."
    \n"; - echo "There is no Remote debug server at this address.\n"; + print " - Failed to connect to address=".$address." port=".$port."
    \n"; + print "There is no Remote debug server at this address.\n"; } socket_close($socket); } else { From 0e7d23e169169816c67bb6e9946db9780e89ea0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 14:14:13 +0100 Subject: [PATCH 214/576] Fix constraint and loading on module activation. --- htdocs/core/modules/DolibarrModules.class.php | 50 ++++++++++++++++--- htdocs/core/modules/modHRM.class.php | 6 +-- .../tables/llx_hrm_evaluationdet-hrm.key.sql | 2 +- .../mysql/tables/llx_hrm_skilldet-hrm.key.sql | 2 +- .../tables/llx_hrm_skillrank-hrm.key.sql | 2 +- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 9ecb73234de..1ed58b2905a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1049,15 +1049,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps,PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** - * Create tables and keys required by module. - * Files module.sql and module.key.sql with create table and create keys - * commands must be stored in directory reldir='/module/sql/' - * This function is called by this->init + * Create tables and keys required by module: + * - Files module.sql files with create table instructions + * - Then files modules.key.sql with create keys instructions + * - Then data_xxx.sql (usualy provided by external modules only) + * - Then update_xxx.sql (usualy provided by external modules only) + * Files must be stored in directory defined by reldir (Example: '/install/mysql/tables' or '/module/sql/') + * This function is usually called by the this->init of module descriptors. * - * @param string $reldir Relative directory where to scan files - * @return int <=0 if KO, >0 if OK + * @param string $reldir Relative directory where to scan files. Example: '/install/mysql/tables' or '/module/sql/' + * @param string $onlywithsuffix Only with the defined suffix + * @return int <=0 if KO, >0 if OK */ - protected function _load_tables($reldir) + protected function _load_tables($reldir, $onlywithsuffix = '') { // phpcs:enable global $conf; @@ -1088,6 +1092,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { @@ -1105,6 +1117,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'llx_' && substr($file, 0, 4) != 'data') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { @@ -1122,6 +1142,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 4) == 'data') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { @@ -1139,6 +1167,14 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } sort($files); foreach ($files as $file) { + if ($onlywithsuffix) { + if (!preg_match('/\-'.preg_quote($onlywithsuffix, '/').'\./i', $file)) { + //print 'File '.$file.' does not match suffix '.$onlywithsuffix.' so it is discarded
    '."\n"; + continue; + } else { + //print 'File '.$file.' match suffix '.$onlywithsuffix.' so we keep it
    '."\n"; + } + } if (preg_match('/\.sql$/i', $file) && !preg_match('/\.key\.sql$/i', $file) && substr($file, 0, 6) == 'update') { $result = run_sql($dir.$file, empty($conf->global->MAIN_DISPLAY_SQL_INSTALL_LOG) ? 1 : 0, '', 1); if ($result <= 0) { diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 8feb6bd7ac0..a72479115c5 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -56,7 +56,7 @@ class modHRM extends DolibarrModules // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) $this->description = "HRM"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'development'; + $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. @@ -268,10 +268,10 @@ class modHRM extends DolibarrModules // Permissions $this->remove($options); - /*$result = $this->_load_tables('/hrm/sql/'); + $result = $this->_load_tables('/install/mysql/tables/', 'hrm'); if ($result < 0) { return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default') - }*/ + } $sql = array(); diff --git a/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql b/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql index 05309ce57e2..5a3bbc844c2 100644 --- a/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_evaluationdet-hrm.key.sql @@ -25,5 +25,5 @@ ALTER TABLE llx_hrm_evaluationdet ADD INDEX idx_hrm_evaluationdet_fk_evaluation --ALTER TABLE llx_hrm_evaluationdet ADD UNIQUE INDEX uk_hrm_evaluationdet_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +ALTER TABLE llx_hrm_evaluationdet ADD CONSTRAINT llx_hrm_evaluationdet_fk_evaluation FOREIGN KEY (fk_evaluation) REFERENCES llx_hrm_evaluation(rowid); diff --git a/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql index 289276e07b5..00dd26e6817 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skilldet-hrm.key.sql @@ -23,5 +23,5 @@ ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_user_creat FOREI --ALTER TABLE llx_hrm_skilldet ADD UNIQUE INDEX uk_hrm_skilldet_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +ALTER TABLE llx_hrm_skilldet ADD CONSTRAINT llx_hrm_skilldet_fk_skill FOREIGN KEY (fk_skill) REFERENCES llx_hrm_skill(rowid); diff --git a/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql b/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql index 11d89b0187c..c8cc19641b2 100644 --- a/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql +++ b/htdocs/install/mysql/tables/llx_hrm_skillrank-hrm.key.sql @@ -23,5 +23,5 @@ ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_user_creat FOR --ALTER TABLE llx_hrm_skillrank ADD UNIQUE INDEX uk_hrm_skillrank_fieldxy(fieldx, fieldy); ---ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_field FOREIGN KEY (fk_field) REFERENCES llx_hrm_myotherobject(rowid); +ALTER TABLE llx_hrm_skillrank ADD CONSTRAINT llx_hrm_skillrank_fk_skill FOREIGN KEY (fk_skill) REFERENCES llx_hrm_skill(rowid); From 20f4b5389b00dec1807f32ca050651cc38b860e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Dec 2021 17:39:28 +0100 Subject: [PATCH 215/576] Fix the experimental feature to manage session in database --- ChangeLog | 2 +- htdocs/conf/conf.php.example | 18 +++- htdocs/core/lib/phpsessionindb.lib.php | 120 +++++++++++++++++++------ htdocs/main.inc.php | 9 +- htdocs/master.inc.php | 10 +-- 5 files changed, 119 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 00962b10419..f6fe916c13b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -133,7 +133,7 @@ NEW: printFieldListFrom hook call on several lists NEW: Use lang selector when using a field key 'lang' in modulebuilder NEW: we need to be able to put more filters on deleteByParentField() function NEW: make it easier to set the `keyword`, `keywords` and `description` attributes of an ecm file object - +NEW: Experimental feature to manage user sessions in database Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 7bb58d6b701..6bf2873b50c 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -282,18 +282,21 @@ $dolibarr_nocsrfcheck='0'; // If set to 1, you will be able to define some command line in the internale Job scheduler module. // Default value: '0' // Examples: '1' +// $dolibarr_cron_allow_cli='0'; // dolibarr_mailing_limit_sendbyweb -// Can set a limit for mailing send by web. This overwrite database value. Can be used to restrict on OS level. +// Can set a limit for mailing send by web. This overwrite database value. Can be used to restrict on system level. // Default value: '25' // Examples: '-1' (sending by web is forbidden) +// // $dolibarr_mailing_limit_sendbyweb='25'; // dolibarr_mailing_limit_sendbycli -// Can set a limit for mailing send by cli. This overwrite database value. Can be used to restrict on OS level. +// Can set a limit for mailing send by cli. This overwrite database value. Can be used to restrict on system level. // Default value: '0' (no hard limit, use soft database value if exists) // Examples: '-1' (sending by cli is forbidden) +// // $dolibarr_mailing_limit_sendbycli='0'; // MAIN_ANTIVIRUS_COMMAND (as a constant) @@ -308,6 +311,17 @@ $dolibarr_cron_allow_cli='0'; // Example: '--fdpass'; // define('MAIN_ANTIVIRUS_PARAM', '--fdpass'); +// php_session_save_handler +// Try to use the Dolibarr internal session handler that uses a database instead of the PHP handler (experimental). +// If you enable this feature to 'db', you may also want to enable the following constants: +// $dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass +// $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_type = $dolibarr_main_db_port +// Default value: '' +// Example: 'db'; +// +// $php_session_save_handler=''; + + //################## // Other diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 132036ba23d..71711eb6ba6 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -29,15 +29,29 @@ /** * The session open handler called by PHP whenever a session is initialized. * - * @param string $database_name Database NamedConstraint - * @param string $table_name Table name + * @param string $save_path Value of session.save_path into php.ini + * @param string $session_name Session name (Example: 'DOLSESSID_xxxxxx') * @return boolean Always true */ -function dolSessionOpen($database_name, $table_name) +function dolSessionOpen($save_path, $session_name) { - global $conf, $dbsession; + global $dbsession; - $dbsession = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); + global $dolibarr_main_db_type, $dolibarr_main_db_host; + global $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name, $dolibarr_main_db_port; + + global $dolibarr_session_db_type, $dolibarr_session_db_host; + global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port; + + if (empty($dolibarr_session_db_type)) { $dolibarr_session_db_type = $dolibarr_main_db_type; } + if (empty($dolibarr_session_db_host)) { $dolibarr_session_db_host = $dolibarr_main_db_host; } + if (empty($dolibarr_session_db_user)) { $dolibarr_session_db_user = $dolibarr_main_db_user; } + if (empty($dolibarr_session_db_pass)) { $dolibarr_session_db_pass = $dolibarr_main_db_pass; } + if (empty($dolibarr_session_db_name)) { $dolibarr_session_db_name = $dolibarr_main_db_name; } + if (empty($dolibarr_session_db_port)) { $dolibarr_session_db_port = $dolibarr_main_db_port; } + //var_dump('open '.$database_name.' '.$table_name); + + $dbsession = getDoliDBInstance($dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port); return true; } @@ -51,8 +65,10 @@ function dolSessionOpen($database_name, $table_name) function dolSessionRead($sess_id) { global $dbsession; + global $sessionlastvalueread; + global $sessionidfound; - $sql = "SELECT session_variable FROM ".MAIN_DB_PREFIX."session"; + $sql = "SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX."session"; $sql .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; // Execute the query @@ -60,10 +76,16 @@ function dolSessionRead($sess_id) $num_rows = $dbsession->num_rows($resql); if ($num_rows == 0) { // No session found - return an empty string + $sessionlastvalueread = ''; + $sessionidfound = ''; return ''; } else { // Found a session - return the serialized string $obj = $dbsession->fetch_object($resql); + $sessionlastvalueread = $obj->session_variable; + $sessionidfound = $obj->session_id; + //var_dump($sessionlastvalueread); + //var_dump($sessionidfound); return $obj->session_variable; } } @@ -79,42 +101,84 @@ function dolSessionRead($sess_id) function dolSessionWrite($sess_id, $val) { global $dbsession; + global $sessionlastvalueread; + global $sessionidfound; - $time_stamp = dol_now(); + /*var_dump('write '.$sess_id); + var_dump($val); + var_dump('sessionlastvalueread='.$sessionlastvalueread.' sessionidfound='.$sessionidfound); + */ - $sql = "SELECT session_id FROM ".MAIN_DB_PREFIX."session"; - $sql .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; + //$sessionlastvalueread=''; + if ($sessionlastvalueread != $val) { + $time_stamp = dol_now(); - // Execute the query - $resql = $dbsession->query($sql); - $num_rows = $dbsession->num_rows($resql); - if ($num_rows == 0) { - // No session found, insert a new one - $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; - $insert_query .= "(session_id, session_variable, last_accessed)"; - $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."')"; - $dbsession->query($insert_query); - } else { - // Existing session found - Update the session variables - $update_query = "UPDATE ".MAIN_DB_PREFIX."session"; - $update_query .= "SET session_variable = '".$dbsession->escape($val)."',"; - $update_query .= " last_accessed = '".$dbsession->idate($time_stamp)."'"; - $update_query .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; - $dbsession->query($update_query); + if (empty($sessionidfound)) { + // No session found, insert a new one + $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; + $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + + $result = $dbsession->query($insert_query); + if (!$result) { + dol_print_error($dbsession); + return false; + } + } else { + if ($sessionidfound != $sess_id) { + // oops. How can this happen ? + dol_print_error($dbsession, 'Oops sess_id received in dolSessionWrite differs from the cache value $sessionidfound. How can this happen ?'); + return false; + } + /*$sql = "SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX."session"; + $sql .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; + + // Execute the query + $resql = $dbsession->query($sql); + $num_rows = $dbsession->num_rows($resql); + if ($num_rows == 0) { + // No session found, insert a new one + $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; + $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + var_dump($insert_query); + $result = $dbsession->query($insert_query); + if (!$result) { + dol_print_error($dbsession); + return false; + } + } else { + */ + // Existing session found - Update the session variables + $update_query = "UPDATE ".MAIN_DB_PREFIX."session"; + $update_query .= " SET session_variable = '".$dbsession->escape($val)."',"; + $update_query .= " last_accessed = '".$dbsession->idate($time_stamp)."',"; + $update_query .= " remote_ip = '".$dbsession->escape(getUserRemoteIP())."',"; + $update_query .= " user_agent = '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."'"; + $update_query .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; + + $result = $dbsession->query($update_query); + if (!$result) { + dol_print_error($dbsession); + return false; + } + } } + return true; } /** * This function is executed on shutdown of the session. * - * @param string $sess_id Session ID * @return boolean Always returns true. */ -function dolSessionClose($sess_id) +function dolSessionClose() { global $dbsession; + //var_dump('close'); + $dbsession->close(); return true; @@ -130,6 +194,8 @@ function dolSessionDestroy($sess_id) { global $dbsession; + //var_dump('destroy'); + $delete_query = "DELETE FROM ".MAIN_DB_PREFIX."session"; $delete_query .= " WHERE session_id = '".$dbsession->escape($sess_id)."'"; $dbsession->query($delete_query); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a15b17b8566..a1bc165ee49 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -272,10 +272,10 @@ if (!empty($_POST["DOL_AUTOSET_COOKIE"])) { } } - // Set the handler of session -if (ini_get('session.save_handler') == 'user') { - require_once 'core/lib/phpsessionindb.lib.php'; +// if (ini_get('session.save_handler') == 'user') +if ($php_session_save_handler == 'db') { + require_once 'core/lib/phpsessionin'.$php_session_save_handler.'.lib.php'; } // Init session. Name of session is specific to Dolibarr instance. @@ -294,7 +294,8 @@ if (!empty($_COOKIE[$sessiontimeout])) { if (!defined('NOSESSION')) { session_set_cookie_params(0, '/', null, (empty($dolibarr_main_force_https) ? false : true), true); // Add tag secure and httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start. session_name($sessionname); - session_start(); + session_start(); // This call the open and read of session handler + //exit; // this exist generates a call to write and close } diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index e04adb4ee86..7a92402224b 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -161,9 +161,10 @@ if (!defined('NOREQUIREDB')) { } // Now database connexion is known, so we can forget password -//unset($dolibarr_main_db_pass); // We comment this because this constant is used in a lot of pages +//unset($dolibarr_main_db_pass); // We comment this because this constant is used in some other pages unset($conf->db->pass); // This is to avoid password to be shown in memory/swap dump + /* * Object $user */ @@ -171,9 +172,9 @@ if (!defined('NOREQUIREUSER')) { $user = new User($db); } + /* * Load object $conf - * After this, all parameters conf->global->CONSTANTS are loaded */ // By default conf->entity is 1, but we change this if we ask another value. @@ -190,15 +191,12 @@ if (session_id() && !empty($_SESSION["dol_entity"])) { // For public page with MultiCompany module $conf->entity = constant('DOLENTITY'); } - // Sanitize entity if (!is_numeric($conf->entity)) { $conf->entity = 1; } - -//print "We work with data into entity instance number '".$conf->entity."'"; - // Here we read database (llx_const table) and define $conf->global->XXX var. +//print "We work with data into entity instance number '".$conf->entity."'"; $conf->setValues($db); // Create object $mysoc (A thirdparty object that contains properties of companies managed by Dolibarr. From 6f22827ff2c2f40fe255813e59ff90bc00236c54 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 8 Dec 2021 09:33:42 +0100 Subject: [PATCH 216/576] fix stuff --- htdocs/hrm/lib/hrm_skillrank.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/hrm/lib/hrm_skillrank.lib.php b/htdocs/hrm/lib/hrm_skillrank.lib.php index 78a53823c2d..5872ec6f037 100644 --- a/htdocs/hrm/lib/hrm_skillrank.lib.php +++ b/htdocs/hrm/lib/hrm_skillrank.lib.php @@ -113,7 +113,7 @@ function displayRankInfos($selected_rank, $fk_skill, $inputname = 'TNote', $mode // On charge les différentes notes possibles pour la compétence $fk_skill $skilldet = new Skilldet($db); - $Lines = $skilldet->fetchAll('ASC', 'rank', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); + $Lines = $skilldet->fetchAll('ASC', 'rankorder', 0, 0, array('customsql'=>'fk_skill = '.$fk_skill)); if (!is_array($Lines) && $Lines<0) { setEventMessages($skilldet->error, $skilldet->errors, 'errors'); From 386771cffc96106afb570f96867db49a60ab660b Mon Sep 17 00:00:00 2001 From: atm-gregr Date: Wed, 8 Dec 2021 14:21:42 +0100 Subject: [PATCH 217/576] fix display contat line on list --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 7397cf8b61f..113fc5e74f7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -418,7 +418,7 @@ if (count($search_roles) > 0) { $sql .= " AND p.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".implode(',', $search_roles)."))"; } if ($search_no_email != -1 && $search_no_email > 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) > 0"; -if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0 AND p.email IS NOT NULL AND p.email <> ''"; +if ($search_no_email != -1 && $search_no_email == 0) $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) = 0"; if ($search_status != '' && $search_status >= 0) $sql .= " AND p.statut = ".$db->escape($search_status); if ($search_import_key) $sql .= natural_search("p.import_key", $search_import_key); if ($type == "o") // filtre sur type From b4de28f1db88b1767f2891d49c504632fdeb6a88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 14:36:34 +0100 Subject: [PATCH 218/576] Update index.php --- htdocs/compta/facture/stats/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index c100263ac7f..ba787b46307 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -380,11 +380,11 @@ foreach ($data as $val) { print '
    0 ? '&userid='.$userid : '').'">'.$year.''.$val['nb'].''.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.(!empty($val['nb_diff']) && $val['nb_diff'] < 0 ? '' : '+').round(!empty($val['nb_diff']) ? $val['nb_diff'] : 0).'%'.price(price2num($val['total'], 'MT'), 1).''.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.( !empty($val['total_diff']) && $val['total_diff'] < 0 ? '' : '+').round(!empty($val['total_diff']) ? $val['total_diff'] : 0).'%'.price(price2num($val['avg'], 'MT'), 1).''.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%'.(!empty($val['avg_diff']) && $val['avg_diff'] < 0 ? '' : '+').round(!empty($val['avg_diff']) ? $val['avg_diff'] : 0).'%
    '; print $linktoprod; print "'; print $linktoprod; print "
    '; print ''; + // Reception ref if ($conf->reception->enabled) { print ''; } - + // Product print ''; print ''; print ''; @@ -1181,9 +1194,14 @@ if ($id > 0 || !empty($ref)) { print "\n"; + while ($i < $num) { $objp = $db->fetch_object($resql); + $tmpproduct->id = $objp->fk_product; + $tmpproduct->ref = $objp->ref; + $tmpproduct->label = $objp->label; + if ($action == 'editline' && $lineid == $objp->dispatchlineid) { print ' @@ -1194,6 +1212,7 @@ if ($id > 0 || !empty($ref)) { print ''; + // Reception ref if (!empty($conf->reception->enabled)) { print '"; } + // Product print '\n"; print ''; From 9b65bb2085b8ef70f89d42bc600e298b428615a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:29:16 +0100 Subject: [PATCH 222/576] Update list.php --- htdocs/contact/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 1672bdd3f7f..45454485b70 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -95,8 +95,8 @@ $search_roles = GETPOST("search_roles", 'array'); $search_level = GETPOST("search_level", "array"); $search_stcomm = GETPOST('search_stcomm', 'int'); -if ($search_status == '') $search_status = 1; // always display active customer first -if ($search_no_email == '') $search_no_email = -1; +if ($search_status === '') $search_status = 1; // always display active customer first +if ($search_no_email === '') $search_no_email = -1; $optioncss = GETPOST('optioncss', 'alpha'); From 8ff0d1f366c15c56b6aab6fb74b7108ebc0cf35e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 15:49:52 +0100 Subject: [PATCH 223/576] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index dd05038f968..4d9c5f49440 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1169,8 +1169,10 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) */ function dol_string_unaccent($str) { + global $conf; + if (utf8_check($str)) { - if (extension_loaded('intl')) { + if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); return $transliterator->transliterate($str); } From 74ecb0792575424571a6c26dab22374b09f3e63d Mon Sep 17 00:00:00 2001 From: atm-florian Date: Wed, 8 Dec 2021 16:03:21 +0100 Subject: [PATCH 224/576] FIX: printFieldListWhere called twice (at different locations) for the same SQL query, can result in syntax errors --- htdocs/product/stock/replenish.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index c925d7f0f62..64f77eead74 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -505,11 +505,6 @@ if ($includeproductswithoutdesiredqty == 'on') { $includeproductswithoutdesiredqtychecked = 'checked'; } -// Add where from hooks -$parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql .= $hookmanager->resPrint; - $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); From 6501bb7cbff1a4583cb5db7351727896dc8f9ba8 Mon Sep 17 00:00:00 2001 From: habot-it <58470575+habot-it@users.noreply.github.com> Date: Wed, 8 Dec 2021 16:43:11 +0100 Subject: [PATCH 225/576] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 762605b8e1e..587bcdcdfbc 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1148,7 +1148,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $parameters = array('line1' => $line1, 'line2' => $line2, 'line3' => $line3, 'line4' => $line4, 'outputlangs'=>$outputlangs); $action = ''; $hookmanager->executeHooks('pdf_pagefoot', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($hookmanager->resPrint) and $hidefreetext == 0) { + if (!empty($hookmanager->resPrint) && $hidefreetext == 0) { $mycustomfooter = $hookmanager->resPrint; $mycustomfooterheight = pdfGetHeightForHtmlContent($pdf, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); From af6e21910d8e62524db3848cde71333aeb86f990 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 16:47:46 +0100 Subject: [PATCH 226/576] FIX #19536 --- htdocs/core/lib/ticket.lib.php | 6 +++--- htdocs/opensurvey/fonctions.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 16b39354de9..25da4bdacfc 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -178,16 +178,16 @@ function showDirectPublicLink($object) /** * Generate a random id * - * @param int $car Length of string to generate key + * @param int $car Length of string to generate key * @return string */ function generate_random_id($car = 16) { $string = ""; $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; - srand((double) microtime() * 1000000); + mt_srand((double) microtime() * 1000000); for ($i = 0; $i < $car; $i++) { - $string .= $chaine[rand() % strlen($chaine)]; + $string .= $chaine[mt_rand() % strlen($chaine)]; } return $string; } diff --git a/htdocs/opensurvey/fonctions.php b/htdocs/opensurvey/fonctions.php index 3d8d76c5c1e..f844921720b 100644 --- a/htdocs/opensurvey/fonctions.php +++ b/htdocs/opensurvey/fonctions.php @@ -206,7 +206,7 @@ function getUrlSondage($id, $admin = false) /** * Generate a random id * - * @param string $car Char to generate key + * @param int $car Length of string to generate key * @return string */ function dol_survey_random($car) From 8f7b222764ce2cd10bd0fcba6a34fdb1431365b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:37:07 +0100 Subject: [PATCH 227/576] Fix phpcs --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 6b627e51ab6..f8e5726d344 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2070,7 +2070,7 @@ class ExtraFields continue; } if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && $this->attributes[$object->table_element]['type'][$key] != 'boolean') { - //when unticking boolean field, it's not set in POST + //when unticking boolean field, it's not set in POST continue; } From 9d11d265ec95d6180a6c5e969d35d6959245b085 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:37:52 +0100 Subject: [PATCH 228/576] Fix phpcs --- htdocs/product/stock/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index d1bd49629c6..440e082e8ff 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -183,7 +183,7 @@ if (empty($reshook)) { $object->fax = GETPOST("fax"); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); + $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) { $error++; } From 51e7484d55a848311923e758bb341bc10aefd1d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:49:57 +0100 Subject: [PATCH 229/576] Fix var not defined --- htdocs/expedition/card.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index fe09a4c521d..b49a464faba 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2041,9 +2041,10 @@ if ($action == 'create') { print "\n"; print ''; + $outputlangs = $langs; + if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); - $outputlangs = $langs; $newlang = ''; if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { $newlang = GETPOST('lang_id', 'aZ09'); @@ -2103,7 +2104,7 @@ if ($action == 'create') { // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => !empty($outputlangs) ? $outputlangs: ''); + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); From 90cff6aed91fb9214c7d2b418847105c79f10a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 18:50:42 +0100 Subject: [PATCH 230/576] Update list.php --- htdocs/expedition/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index fb8ba3b8990..1665b1a43c0 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -253,7 +253,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; -if (!empty($extrafields->attributes[$object->table_element]['label']) && sis_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; } if ($sall || $search_product_category > 0) { From 22c271966d4f409f698746fe311d1180f82709d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 19:14:02 +0100 Subject: [PATCH 231/576] Fix the existing method dolEscapeXML should be enough. --- .../class/bonprelevement.class.php | 56 ++++++------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index f25fcf1e397..365969436dd 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -121,26 +121,6 @@ class BonPrelevement extends CommonObject $this->fetched = 0; } - /** - * Remove any illegal characters for SEPA - * - * @param string $str String to remove illegal chars - * @return string Cleaned string - * - */ - public static function removeIllegalChars($str) - { - /* - Valid XML Characters: - a b c d e f g h i j k l m n o p q r s t u v w x y z - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - 0 1 2 3 4 5 6 7 8 9 - / – ? : ( ) . , ‘ + - Space - */ - return preg_replace('/[^A-Za-z0-9 \.,\-\/\+():?]/', '', dol_string_unaccent($str)); - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add invoice to withdrawal @@ -1572,7 +1552,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1688,7 +1668,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1938,11 +1918,11 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper($this->removeIllegalChars($row_nom))).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf; } @@ -1989,11 +1969,11 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper($this->removeIllegalChars($row_nom))).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper($row_nom)).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc($addressline1, 70, 'right', 'UTF-8', true)).''.$CrLf; } @@ -2161,16 +2141,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2227,16 +2207,16 @@ class BonPrelevement extends CommonObject */ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.strtoupper($this->removeIllegalChars($this->raison_sociale)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper($this->raison_sociale)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $addressline1 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => ""))); - $addressline2 = $this->removeIllegalChars(strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => ""))); + $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.$addressline1.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline1).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.$addressline2.''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML($addressline2).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; From 646ba34f89a320c9d613a601bf9724dc3ec48984 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Dec 2021 19:15:35 +0100 Subject: [PATCH 232/576] Update functions.lib.php --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4d9c5f49440..9202cc89466 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1170,7 +1170,7 @@ function dol_sanitizeUrl($stringtoclean, $type = 1) function dol_string_unaccent($str) { global $conf; - + if (utf8_check($str)) { if (extension_loaded('intl') && !empty($conf->global->MAIN_UNACCENT_USE_TRANSLITERATOR)) { $transliterator = \Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: NFC;', \Transliterator::FORWARD); From d0413f423fea63ce36f81dbd8e0def4459dbf052 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:33:00 +0100 Subject: [PATCH 233/576] FIX - Missing one html conversion --- htdocs/core/lib/pdf.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 686a442ec2f..22316ab1b08 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1413,6 +1413,9 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { + if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { + str_replace("\n",'
    ', $desc); + } if ($idprod) { // Check if description must be output if (!empty($object->element)) { From 1123bf3cde436caafd38b07255cfe8959d6e327b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 9 Dec 2021 09:34:00 +0100 Subject: [PATCH 234/576] =?UTF-8?q?Fix=20#18586=20:=20special=20char=20"?= =?UTF-8?q?=E2=80=A6"=20not=20allowed=20in=20XML=20file=20and=20added=20by?= =?UTF-8?q?=20dol=5Ftrunc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/compta/prelevement/class/bonprelevement.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 721d7c10111..92c0db1f55e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1936,7 +1936,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) - $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1968,7 +1968,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; // A string with some information on payment - 140 max - $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_DEBITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).''.$CrLf; // 140 max $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; return $XML_DEBITOR; @@ -1978,7 +1978,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; // Add EndToEndId. Must be a unique ID for each payment (for example by including bank, buyer or seller, date, checksum) - $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('AS-'.dol_trunc($row_ref, 20, 'right', 'UTF-8', true)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.round($row_somme, 2).''.$CrLf; @@ -2015,7 +2015,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; // A string with some information on payment - 140 max - $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135)).''.$CrLf; // 140 max + $XML_CREDITOR .= ' '.(($conf->global->PRELEVEMENT_USTRD != "") ? $conf->global->PRELEVEMENT_USTRD : dol_trunc($row_ref, 135, 'right', 'UTF-8', true)).''.$CrLf; // 140 max $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; return $XML_CREDITOR; From f74077a2e73a5b1c2ddae4a3269c2e28df0ba4cf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 9 Dec 2021 08:35:12 +0000 Subject: [PATCH 235/576] Fixing style errors. --- htdocs/core/lib/pdf.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 22316ab1b08..0e1164bce30 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1413,8 +1413,8 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { - if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { - str_replace("\n",'
    ', $desc); + if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { + str_replace("\n", '
    ', $desc); } if ($idprod) { // Check if description must be output From abd984bc14057244f47700cc4deeb7223a75310f Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:39:22 +0100 Subject: [PATCH 236/576] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 0e1164bce30..bda030187b3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1414,7 +1414,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { - str_replace("\n", '
    ', $desc); + $desc = str_replace("\n", '
    ', $desc); } if ($idprod) { // Check if description must be output From 7ce60099588336097aa573f004f451c13cf87170 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 09:53:32 +0100 Subject: [PATCH 237/576] Removed deprecated option --- htdocs/compta/paiement/list.php | 5 +---- htdocs/fourn/paiement/list.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index f5160c51757..0d928cf188f 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -528,10 +528,7 @@ while ($i < min($num, $limit)) { // Date if (!empty($arrayfields['p.datep']['checked'])) { - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) { - $dateformatforpayment = 'dayhour'; - } + $dateformatforpayment = 'dayhour'; print '
    '; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index 5c76c1dddd0..f9df30c2f54 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -497,10 +497,7 @@ while ($i < min($num, $limit)) { // Date if (!empty($arrayfields['p.datep']['checked'])) { - $dateformatforpayment = 'day'; - if (!empty($conf->global->INVOICE_USE_HOURS_FOR_PAYMENT)) { - $dateformatforpayment = 'dayhour'; - } + $dateformatforpayment = 'dayhour'; print ''; if (!$i) { $totalarray['nbfield']++; From 92a0c9e4fba7513969da026eebf30b230a59f624 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 10:00:42 +0100 Subject: [PATCH 238/576] Fix sql error in repair.php --- htdocs/install/repair.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index ad3a3ca13a3..4aba1d10c4b 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1178,9 +1178,9 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { $listofmods = ''; foreach ($conf->modules as $key => $val) { - $listofmods .= ($listofmods ? ',' : '')."'".$val."'"; + $listofmods .= ($listofmods ? ',' : '')."'".$db->escape($val)."'"; } - $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods).') AND id > 100000'; + $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods, 1).') AND id > 100000'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); From 10984260052e26aa47c756220d7432b28ee074d4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Dec 2021 10:31:02 +0100 Subject: [PATCH 239/576] FIX wrong syntax of sql request --- htdocs/core/class/html.formaccounting.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index fbfde88198b..dc6e6d8c6cd 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -456,7 +456,7 @@ class FormAccounting extends Form $sql = "SELECT code_compta, code_compta_fournisseur, nom as name"; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " WHERE entity IN (".getEntity('societe').")"; - $sql .= " AND client IN (1,3) OR fournisseur = 1"; + $sql .= " AND (client IN (1,3) OR fournisseur = 1)"; $resql = $this->db->query($sql); if ($resql) { From b5d1ea4629381216edf750580b74b9188bccc251 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 11:07:38 +0100 Subject: [PATCH 240/576] FIX select too large into addrights (pb of missing parenthesis) --- htdocs/core/modules/DolibarrModules.class.php | 28 ++++++++++--------- htdocs/user/class/user.class.php | 13 +++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 1ed58b2905a..b90ea227037 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1736,10 +1736,10 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it /** * Adds access rights * - * @param int $reinitadminperms If 1, we also grant them to all admin users - * @param int $force_entity Force current entity - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int Error count (0 if OK) + * @param int $reinitadminperms If 1, we also grant them to all admin users + * @param int $force_entity Force current entity + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return int Error count (0 if OK) */ public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) { @@ -1761,16 +1761,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if ($resql) { $obj = $this->db->fetch_object($resql); + if ($obj !== null && !empty($obj->value) && !empty($this->rights)) { + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + // If the module is active foreach ($this->rights as $key => $value) { - $r_id = $this->rights[$key][0]; + $r_id = $this->rights[$key][0]; // permission id in llx_rights_def (not unique because primary key is couple id-entity) $r_desc = $this->rights[$key][1]; $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] : ''; $r_def = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3]; $r_perms = $this->rights[$key][4]; $r_subperms = isset($this->rights[$key][5]) ? $this->rights[$key][5] : ''; - $r_modul = empty($this->rights_class) ?strtolower($this->name) : $this->rights_class; + $r_modul = empty($this->rights_class) ? strtolower($this->name) : $this->rights_class; if (empty($r_type)) { $r_type = 'w'; @@ -1823,21 +1826,20 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // If we want to init permissions on admin users if ($reinitadminperms) { - if (!class_exists('User')) { - include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; - } $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 1"; dol_syslog(get_class($this)."::insert_permissions Search all admin users", LOG_DEBUG); + $resqlseladmin = $this->db->query($sql, 1); + if ($resqlseladmin) { $num = $this->db->num_rows($resqlseladmin); $i = 0; while ($i < $num) { - $obj2 = $this->db->fetch_object($resqlseladmin); - dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); + $obj2 = $this->db->fetch_object($resqlseladmin); + dol_syslog(get_class($this)."::insert_permissions Add permission id '.$r_id.' to user id=".$obj2->rowid); - $tmpuser = new User($this->db); - $result = $tmpuser->fetch($obj2->rowid); + $tmpuser = new User($this->db); + $result = $tmpuser->fetch($obj2->rowid); if ($result > 0) { $tmpuser->addrights($r_id, '', '', 0, 1); } else { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 1780c73fc69..58a38e8380b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -786,9 +786,10 @@ class User extends CommonObject { global $conf, $user, $langs; - $entity = (!empty($entity) ? $entity : $conf->entity); + $entity = (empty($entity) ? $conf->entity : $entity); + + dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity, $notrigger for user id=".$this->id); - dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity"); $error = 0; $whereforadd = ''; @@ -797,7 +798,7 @@ class User extends CommonObject if (!empty($rid)) { $module = $perms = $subperms = ''; - // Si on a demande ajout d'un droit en particulier, on recupere les caracteristiques (module, perms et subperms) de ce droit. + // If we ask to add a given permission, we first load properties of this permission (module, perms and subperms). $sql = "SELECT module, perms, subperms"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE id = ".((int) $rid); @@ -817,9 +818,9 @@ class User extends CommonObject dol_print_error($this->db); } - // Where pour la liste des droits a ajouter + // Define the where for the permission to add $whereforadd = "id=".((int) $rid); - // Ajout des droits induits + // Add also inherited permissions if (!empty($subperms)) { $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))"; } elseif (!empty($perms)) { @@ -848,7 +849,7 @@ class User extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE entity = ".((int) $entity); if (!empty($whereforadd) && $whereforadd != 'allmodules') { - $sql .= " AND ".$whereforadd; + $sql .= " AND (".$whereforadd.")"; // Note: parenthesis are important because wheretoand can contains OR. Also note that $whereforadd is already sanitized } $result = $this->db->query($sql); From a9bdefa3587bb05b6b94523ebc91e1260db48f5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 11:12:40 +0100 Subject: [PATCH 241/576] FIX select too large into addrights (pb of missing parenthesis) --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 09bb34ddef3..be1db952aa0 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -738,7 +738,7 @@ class User extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE entity = ".((int) $entity); if (!empty($whereforadd) && $whereforadd != 'allmodules') { - $sql .= " AND ".$whereforadd; + $sql .= " AND (".$whereforadd.")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized } $result = $this->db->query($sql); @@ -864,7 +864,7 @@ class User extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " WHERE entity = ".((int) $entity); if (!empty($wherefordel) && $wherefordel != 'allmodules') { - $sql .= " AND ".$wherefordel; + $sql .= " AND (".$wherefordel.")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized } // avoid admin can remove his own important rights From 0c2dce372f71b5c7e6ebc55ad1318a3acb94d2df Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Thu, 9 Dec 2021 11:24:03 +0100 Subject: [PATCH 242/576] FIX In the card of a direct debit FIX In the card of a direct debit, if you change the limit, it gets disordered and vice versa --- htdocs/compta/prelevement/card.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 8a232377ab7..95d30becd03 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -382,6 +382,9 @@ if ($id > 0 || $ref) { $i = 0; $urladd = "&id=".urlencode($id); + if ($limit > 0 && $limit != $conf->liste_limit) { + $urladd .= '&limit='.urlencode($limit); + } print ''."\n"; print ''; @@ -392,6 +395,12 @@ if ($id > 0 || $ref) { if (!empty($limit)) { print ''; } + if (!empty($sortfield)) { + print ''; + } + if (!empty($sortorder)) { + print ''; + } print_barre_liste($langs->trans("Lines"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '', 0, '', '', $limit); print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table From 93356d9dc4f3bfb7595966eb0e0a42cf323e0a5a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 9 Dec 2021 10:25:58 +0000 Subject: [PATCH 243/576] Fixing style errors. --- htdocs/compta/prelevement/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 95d30becd03..c29cadf564d 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -383,7 +383,7 @@ if ($id > 0 || $ref) { $urladd = "&id=".urlencode($id); if ($limit > 0 && $limit != $conf->liste_limit) { - $urladd .= '&limit='.urlencode($limit); + $urladd .= '&limit='.urlencode($limit); } print ''."\n"; From 7ea8b7851a03f0d5c67e35f190a3146917dbe4a2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 11:56:54 +0100 Subject: [PATCH 244/576] Code comment --- htdocs/user/class/user.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 2bb07dab48b..467a572193e 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1075,12 +1075,14 @@ class User extends CommonObject // First user permissions $sql = "SELECT DISTINCT r.module, r.perms, r.subperms"; - $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; - $sql .= ", ".MAIN_DB_PREFIX."rights_def as r"; + $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur,"; + $sql .= " ".MAIN_DB_PREFIX."rights_def as r"; $sql .= " WHERE r.id = ur.fk_id"; if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) { + // on old version, we use entity defined into table r $sql .= " AND r.entity IN (0,".(!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").$conf->entity.")"; } else { + // we must now use entity into table ur $sql .= " AND ur.entity = ".((int) $conf->entity); } $sql .= " AND ur.fk_user= ".((int) $this->id); From ecf98530bb6fa1d74dada6490feabcf2460c4213 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 12:42:04 +0100 Subject: [PATCH 245/576] Debug SEPA payment module --- htdocs/compta/bank/card.php | 4 +- htdocs/compta/prelevement/create.php | 89 +++++++++++++++++----------- htdocs/langs/en_US/withdrawals.lang | 2 +- 3 files changed, 56 insertions(+), 39 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index fddd0ee2493..9f000786b7f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -1067,12 +1067,12 @@ if ($action == 'create') { if ($conf->prelevement->enabled) { print '
    '; - print ''; + print ''; } if ($conf->paymentbybanktransfer->enabled) { print ''; - print ''; + print ''; } print ''; print ''; From f3da457b2be58ea9181983f6294ac6089eb826f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 14:26:28 +0100 Subject: [PATCH 262/576] Clean comment --- htdocs/core/bookmarks_page.php | 2 +- htdocs/core/multicompany_page.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php index 32e2be230b9..11f8b884762 100644 --- a/htdocs/core/bookmarks_page.php +++ b/htdocs/core/bookmarks_page.php @@ -58,7 +58,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Bookmarks"); // URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a bookmark selection page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php index ad1d8934dbb..4a3bcba51fb 100644 --- a/htdocs/core/multicompany_page.php +++ b/htdocs/core/multicompany_page.php @@ -81,7 +81,7 @@ if (GETPOST('acction', 'aZ') == 'switchentity') { $title = $langs->trans("Multicompanies"); // URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; // This is used by DoliDroid to know page is a multicompany selection page +$head = ''."\n"; // This is used by DoliDroid to know page is a multicompany selection page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); From dcd8c0f53d58552882696375cb6ee6deb103a097 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 14:50:20 +0100 Subject: [PATCH 263/576] css --- htdocs/admin/company.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index a10fab3b8c2..04f516374c6 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -381,9 +381,8 @@ print ''.$langs->trans("CompanyFundationDesc", $lang print "

    \n"; -/** - * Edit parameters - */ +// Edit parameters + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; } } diff --git a/htdocs/theme/eldy/ckeditor/config.js b/htdocs/theme/eldy/ckeditor/config.js index e041516a292..b6b6aa2596c 100644 --- a/htdocs/theme/eldy/ckeditor/config.js +++ b/htdocs/theme/eldy/ckeditor/config.js @@ -61,7 +61,7 @@ CKEDITOR.editorConfig = function( config ) ['Undo','Redo','-','Find','Replace'], ['CreateDiv','ShowBlocks'], ['Format','Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor','Image','Table','HorizontalRule','SpecialChar'], @@ -75,7 +75,7 @@ CKEDITOR.editorConfig = function( config ) ['SpellChecker', 'Scayt'], // 'Cut','Copy','Paste','-', are useless, can be done with right click, even on smarpthone ['Undo','Redo','-','Find','Replace'], ['Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Image','Table','HorizontalRule','SpecialChar'], diff --git a/htdocs/theme/md/ckeditor/config.js b/htdocs/theme/md/ckeditor/config.js index acd38268f8f..83f124f2f2c 100644 --- a/htdocs/theme/md/ckeditor/config.js +++ b/htdocs/theme/md/ckeditor/config.js @@ -61,7 +61,7 @@ CKEDITOR.editorConfig = function( config ) ['Undo','Redo','-','Find','Replace'], ['CreateDiv','ShowBlocks'], ['Format','Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Anchor','Image','Table','HorizontalRule','SpecialChar'], @@ -75,7 +75,7 @@ CKEDITOR.editorConfig = function( config ) ['SpellChecker', 'Scayt'], // 'Cut','Copy','Paste','-', are useless, can be done with right click, even on smarpthone ['Undo','Redo','-','Find','Replace'], ['Format','Font','FontSize'], - ['Bold','Italic','Underline','Strike','Superscript','-','TextColor','RemoveFormat'], + ['Bold','Italic','Underline','Strike','-','TextColor','RemoveFormat'], ['NumberedList','BulletedList','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['Link','Unlink','Image','Table','HorizontalRule','SpecialChar'], From 49853adf82edef706d389d5fe275559708cf1eb8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 09:35:27 +0100 Subject: [PATCH 281/576] Fix pb with cache --- htdocs/core/bookmarks_page.php | 12 ++++++++++++ htdocs/core/get_menudiv.php | 12 ++++++++++++ htdocs/core/modules/modHRM.class.php | 8 ++------ htdocs/core/search_page.php | 12 ++++++++++++ htdocs/hrm/css/radio_js_number.css | 18 ------------------ htdocs/theme/eldy/global.inc.php | 23 +++++++++++++++++++++++ htdocs/theme/md/style.css.php | 23 +++++++++++++++++++++++ 7 files changed, 84 insertions(+), 24 deletions(-) delete mode 100644 htdocs/hrm/css/radio_js_number.css diff --git a/htdocs/core/bookmarks_page.php b/htdocs/core/bookmarks_page.php index 9915a259570..9c3b5abb266 100644 --- a/htdocs/core/bookmarks_page.php +++ b/htdocs/core/bookmarks_page.php @@ -55,6 +55,18 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); * View */ +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) { + header('Cache-Control: max-age='.GETPOST('cache', 'int').', public'); + // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT'); + // HTTP/1.0 + header('Pragma: token=public'); +} else { + // HTTP/1.0 + header('Cache-Control: no-cache'); +} + $title = $langs->trans("Bookmarks"); // URL http://mydolibarr/core/bookmarks_page?dol_use_jmobile=1 can be used for tests diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index e04971ce8c3..77b0416956b 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -81,6 +81,18 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); * View */ +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) { + header('Cache-Control: max-age='.GETPOST('cache', 'int').', public, must-revalidate'); + // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT'); + // HTTP/1.0 + header('Pragma: token=public'); +} else { + // HTTP/1.0 + header('Cache-Control: no-cache'); +} + $title = $langs->trans("Menu"); // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index a72479115c5..3e75f8efcd5 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -85,13 +85,9 @@ class modHRM extends DolibarrModules // Set this to 1 if module has its own theme directory (theme) 'theme' => 0, // Set this to relative path of css file if module has its own css file - 'css' => array( - '/hrm/css/radio_js_number.css', - ), + 'css' => array(), // Set this to relative path of js file if module must load a js on all pages - 'js' => array( - // '/hrm/js/hrm.js.php', - ), + 'js' => array(), // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 0341c1116ef..4f6911497e4 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -55,6 +55,18 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); * View */ +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) { + header('Cache-Control: max-age='.GETPOST('cache', 'int').', public'); + // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server + header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT'); + // HTTP/1.0 + header('Pragma: token=public'); +} else { + // HTTP/1.0 + header('Cache-Control: no-cache'); +} + $title = $langs->trans("Search"); // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests diff --git a/htdocs/hrm/css/radio_js_number.css b/htdocs/hrm/css/radio_js_number.css deleted file mode 100644 index 320b0ddc1f2..00000000000 --- a/htdocs/hrm/css/radio_js_number.css +++ /dev/null @@ -1,18 +0,0 @@ -.radio_js_bloc_number { - display:inline-block; - padding:5px 7px; - min-width:20px; - border-radius:3px; - border:1px solid #ccc; - background:#eee; - color:#555; - cursor:pointer; - margin:2px; - text-align:center; -} -.radio_js_bloc_number.selected { - transition:0.2s ease background; - background:#888; - color:#fff; - border-color:#555; -} \ No newline at end of file diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index fedb4f9d67e..d8bd4673d5c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -6967,6 +6967,29 @@ div.clipboardCPValue.hidewithsize { } +/* ============================================================================== */ +/* CSS style used for hrm skill/rank (may be we can remove this) */ +/* ============================================================================== */ + +.radio_js_bloc_number { + display:inline-block; + padding:5px 7px; + min-width:20px; + border-radius:3px; + border:1px solid #ccc; + background:#eee; + color:#555; + cursor:pointer; + margin:2px; + text-align:center; +} +.radio_js_bloc_number.selected { + transition:0.2s ease background; + background:#888; + color:#fff; + border-color:#555; +} + /* ============================================================================== */ /* CSS style used for small screen */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 79d7c929927..6805f2c620e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -6854,6 +6854,29 @@ div.clipboardCPValue.hidewithsize { } +/* ============================================================================== */ +/* CSS style used for hrm skill/rank (may be we can remove this) */ +/* ============================================================================== */ + +.radio_js_bloc_number { + display:inline-block; + padding:5px 7px; + min-width:20px; + border-radius:3px; + border:1px solid #ccc; + background:#eee; + color:#555; + cursor:pointer; + margin:2px; + text-align:center; +} +.radio_js_bloc_number.selected { + transition:0.2s ease background; + background:#888; + color:#fff; + border-color:#555; +} + /* ============================================================================== */ /* CSS style used for small screen */ From df9b337a571dabf74c7d476639d92e1575df6956 Mon Sep 17 00:00:00 2001 From: Je2fb <46494485+Je2fb@users.noreply.github.com> Date: Mon, 13 Dec 2021 09:44:00 +0100 Subject: [PATCH 282/576] Fix #19418 --- htdocs/core/class/html.formadmin.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 4196fb32b68..bab9ab61b57 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -75,7 +75,7 @@ class FormAdmin // If the language to select is not inside the list of available language and empty value is not available, we must find // an alternative as the language code to pre-select (to avoid to have first element in list pre-selected). - if ($selected && !in_array($selected, $langs_available) && empty($showempty)) { + if ($selected && !isset($langs_available[$selected]) && empty($showempty)) { $tmparray = explode('_', $selected); if (!empty($tmparray[1])) { $selected = getLanguageCodeFromCountryCode($tmparray[1]); From 85dc6006c45087e04c34faaea86bbd6697edd513 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 16:09:06 +0100 Subject: [PATCH 283/576] Code comment --- htdocs/contrat/class/contrat.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index fe8edd30ea4..27e8cc6bf95 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -913,10 +913,11 @@ class Contrat extends CommonObject return -3; } + // Now set the global properties on contract not stored into database. $this->nbofservices = count($this->lines); - $this->total_ttc = price2num($total_ttc); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_tva = price2num($total_vat); // TODO For the moment value is false as value is not stored in database for line linked to products - $this->total_ht = price2num($total_ht); // TODO For the moment value is false as value is not stored in database for line linked to products + $this->total_ttc = price2num($total_ttc); + $this->total_tva = price2num($total_vat); + $this->total_ht = price2num($total_ht); return $this->lines; } From ac8538a812158762e850a4559a635d2085bb1240 Mon Sep 17 00:00:00 2001 From: jpb Date: Mon, 13 Dec 2021 16:53:34 +0100 Subject: [PATCH 284/576] add info for acces right --- htdocs/compta/bank/info.php | 2 ++ htdocs/compta/bank/line.php | 3 ++- htdocs/core/lib/security.lib.php | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php index c61f6e50bff..8be615c4827 100644 --- a/htdocs/compta/bank/info.php +++ b/htdocs/compta/bank/info.php @@ -34,10 +34,12 @@ $ref = GETPOST('ref', 'alpha'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); + $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } + $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) { accessforbidden(); diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 05aed6a215e..f75a8240e00 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -51,7 +51,7 @@ if (!empty($conf->salaries->enabled)) { } -$id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int')); +$id = (GETPOST('rowid', 'int') ? GETPOST('rowid', 'int') : GETPOST('account', 'int')); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); @@ -66,6 +66,7 @@ $fieldtype = (!empty($ref) ? 'ref' : 'rowid'); if ($user->socid) { $socid = $user->socid; } + $result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype); if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) { accessforbidden(); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 475649701ae..57ed0791300 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -227,6 +227,10 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if ($features == 'product') { $features = 'produit'; } + if ($features == 'banque') { + $parentfortableentity = 'fk_account@bank_account'; + } + // Get more permissions checks from hooks $parameters = array('features'=>$features, 'originalfeatures'=>$originalfeatures, 'objectid'=>$objectid, 'dbt_select'=>$dbt_select, 'idtype'=>$dbt_select, 'isdraft'=>$isdraft); From 2419784bdb743efe197745e1876eeb2578cbeb29 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Mon, 13 Dec 2021 16:54:42 +0100 Subject: [PATCH 285/576] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 03a9d518021..85fc0922913 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4881,7 +4881,7 @@ abstract class CommonObject if (is_object($hookmanager)) { // Old code is commented on preceding line. $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); if (!empty($line->fk_parent_line)) { $parameters['fk_parent_line'] = $line->fk_parent_line; } - $reshook = $hookmanager->executeHooks('printOriginObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } if (empty($reshook)) { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); From e7b7c3281e910aafad4cc573dcc90ddd7a8bd8ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 17:42:10 +0100 Subject: [PATCH 286/576] Fix page of accountancy transaction --- htdocs/accountancy/bookkeeping/card.php | 38 +++++++++++++++++++------ htdocs/langs/en_US/accountancy.lang | 3 +- htdocs/theme/eldy/global.inc.php | 4 +++ htdocs/theme/md/style.css.php | 3 ++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index b772da3ce08..195f7fcb26b 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -618,9 +618,10 @@ if ($action == 'create') { print ''."\n"; print ''."\n"; - print '
    '.$langs->trans("Reception").''.$langs->trans("Product").''.$langs->trans("DateCreation").''.$langs->trans("DateDeliveryPlanned").'
    '; if (!empty($objp->fk_reception)) { @@ -1205,8 +1224,16 @@ if ($id > 0 || !empty($ref)) { print "'; - print ''.img_object($langs->trans("ShowProduct"), 'product').' '.$objp->ref.''; + if (empty($conf->cache['product'][$objp->fk_product])) { + $tmpproduct = new Product($db); + $tmpproduct->fetch($objp->fk_product); + $conf->cache['product'][$objp->fk_product] = $tmpproduct; + } else { + $tmpproduct = $conf->cache['product'][$objp->fk_product]; + } + print $tmpproduct->getNomUrl(1); print ' - '.$objp->label; print "'.dol_print_date($db->jdate($objp->datec), 'day').'
    '.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).'
    '.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')
    '.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')
    '.$langs->trans("BankAccountDomiciliation").''; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 42bf73eaae6..3f00a4f0660 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -45,9 +45,12 @@ $type = GETPOST('type', 'aZ09'); $action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list + $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $format = GETPOST('format', 'aZ09'); $id_bankaccount = GETPOST('id_bankaccount', 'int'); +$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { @@ -67,6 +70,8 @@ if ($type == 'bank-transfer') { $result = restrictedArea($user, 'prelevement', '', '', 'bons'); } +$error = 0; + /* * Actions @@ -92,8 +97,10 @@ if (empty($reshook)) { if ($action == 'create') { $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); - if ($id_bankaccount != $conf->global->{$default_account}) { - $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); //Set as default + //var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit; + + if ($id_bankaccount != $conf->global->$default_account) { + $res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default } require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -104,44 +111,39 @@ if (empty($reshook)) { ) { $errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}')); setEventMessages($errormessage, null, 'errors'); - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php'); - exit; + $action = ''; + $error++; } - $delayindays = 0; - if ($type != 'bank-transfer') { - $delayindays = $conf->global->PRELEVEMENT_ADDDAYS; - } else { - $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; - } $bprev = new BonPrelevement($db); - $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int')); - // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) - $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); - if ($result < 0) { - setEventMessages($bprev->error, $bprev->errors, 'errors'); - } elseif ($result == 0) { - $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format); - setEventMessages($mesg, null, 'errors'); - $mesg .= '
    '."\n"; - foreach ($bprev->invoice_in_error as $key => $val) { - $mesg .= ''.$val."
    \n"; - } - } else { - if ($type != 'bank-transfer') { - $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}'); - $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); - setEventMessages($texttoshow, null); + if (!$error) { + // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore) + $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type); + if ($result < 0) { + setEventMessages($bprev->error, $bprev->errors, 'errors'); + } elseif ($result == 0) { + $mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format); + setEventMessages($mesg, null, 'errors'); + $mesg .= '
    '."\n"; + foreach ($bprev->invoice_in_error as $key => $val) { + $mesg .= ''.$val."
    \n"; + } } else { - $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}'); - $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); - setEventMessages($texttoshow, null); - } + if ($type != 'bank-transfer') { + $texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}'); + $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); + setEventMessages($texttoshow, null); + } else { + $texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}'); + $texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow); + setEventMessages($texttoshow, null); + } - header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id); - exit; + header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type)); + exit; + } } } $objectclass = "BonPrelevement"; @@ -250,11 +252,25 @@ if ($nb) { } print $title; print img_picto('', 'bank_account'); - print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1); + + $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); + + print $form->select_comptes($conf->global->$default_account, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1); print ' - '; + if (empty($executiondate)) { + $delayindays = 0; + if ($type != 'bank-transfer') { + $delayindays = $conf->global->PRELEVEMENT_ADDDAYS; + } else { + $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; + } + + $executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd'); + } + print $langs->trans('ExecutionDate').' '; - $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $datere = $executiondate; print $form->selectDate($datere, 're'); @@ -276,7 +292,8 @@ if ($nb) { if ($type == 'bank-transfer') { $title = $langs->trans("CreateFileForPaymentByBankTransfer"); } - print ''.$title."\n"; + print ''."\n"; + print ''."\n"; } } else { if ($mysoc->isInEEC()) { diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index a3773a427a1..7b18c1a0d70 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -80,7 +80,7 @@ StatusMotif7=Judicial Decision StatusMotif8=Other reason CreateForSepaFRST=Create direct debit file (SEPA FRST) CreateForSepaRCUR=Create direct debit file (SEPA RCUR) -CreateAll=Create direct debit file (all) +CreateAll=Create direct debit file CreateFileForPaymentByBankTransfer=Create file for credit transfer CreateSepaFileForPaymentByBankTransfer=Create credit transfer file (SEPA) CreateGuichet=Only office From 6b9636c3b8e1cc9ad1699f167a507b4897e12688 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 12:54:08 +0100 Subject: [PATCH 246/576] FIX deletion of direct debit or credit transfer --- htdocs/compta/prelevement/card.php | 4 +++- htdocs/core/lib/security.lib.php | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index a2de75123a0..d35061363a4 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -67,6 +67,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist')); $type = $object->type; + if ($type == 'bank-transfer') { $result = restrictedArea($user, 'paymentbybanktransfer', '', '', ''); } else { @@ -86,9 +87,10 @@ if ($reshook < 0) { if (empty($reshook)) { if ($action == 'confirm_delete') { + $savtype = $object->type; $res = $object->delete($user); if ($res > 0) { - if ($object->type == 'bank-transfer') { + if ($savtype == 'bank-transfer') { header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php'); } else { header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php'); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 58d69842f66..80150a5c53e 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -566,6 +566,14 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (empty($user->rights->adherent->supprimer)) { $deleteok = 0; } + } elseif ($feature == 'paymentbybanktransfer') { + if (empty($user->rights->paymentbybanktransfer->create)) { // There is no delete permission + $deleteok = 0; + } + } elseif ($feature == 'prelevement') { + if (empty($user->rights->prelevement->bons->creer)) { // There is no delete permission + $deleteok = 0; + } } elseif (!empty($feature2)) { // This is for permissions on 2 levels foreach ($feature2 as $subfeature) { if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) { From 9462481e83641ac260419d428bfef06c6f61b0bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 14:51:35 +0100 Subject: [PATCH 247/576] Doc --- htdocs/compta/prelevement/card.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index d35061363a4..2ec611e99c2 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -99,7 +99,7 @@ if (empty($reshook)) { } } - // Seems to no be used and replaced with $action == 'infocredit' + // Seems to not be used and replaced with $action == 'infocredit' if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes') { if ($object->statut == 2) { $res = -1; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index ebdf4825551..05a51afacdb 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -28,7 +28,7 @@ //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs //if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters //if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu From 8b2002fbfb755ca55ab4aee813a9dd76618b090e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 9 Dec 2021 15:17:18 +0100 Subject: [PATCH 248/576] Fix php 8.0 warnings of modulebuilder --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/modulebuilder/template/class/myobject.class.php | 8 ++++---- htdocs/modulebuilder/template/myobject_agenda.php | 2 +- htdocs/modulebuilder/template/myobject_card.php | 4 ++-- htdocs/modulebuilder/template/myobject_document.php | 2 +- htdocs/modulebuilder/template/myobject_note.php | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2e8ca8540d5..f4dcf711b65 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8528,7 +8528,7 @@ abstract class CommonObject } } } else { - $queryarray[$field] = $this->{$field}; + $queryarray[$field] = !empty($this->{$field}) ? $this->{$field} : 0; } if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 6e5d6efcff4..ca9de1cc5ab 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -362,7 +362,7 @@ class MyObject extends CommonObject if (!$error) { // copy external contacts if same company - if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { + if (!empty($object->socid) && property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) { if ($this->copy_linked_contact($object, 'external') < 0) { $error++; } @@ -918,19 +918,19 @@ class MyObject extends CommonObject if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; - if ($obj->fk_user_author) { + if (!empty($obj->fk_user_author)) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_valid) { + if (!empty($obj->fk_user_valid)) { $vuser = new User($this->db); $vuser->fetch($obj->fk_user_valid); $this->user_validation = $vuser; } - if ($obj->fk_user_cloture) { + if (!empty($obj->fk_user_cloture)) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index add786498b2..b7d3fcfaa80 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -129,7 +129,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->mymodule->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index ebdf4825551..c8959444449 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -92,7 +92,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -//$lineid = GETPOST('lineid', 'int'); +$lineid = GETPOST('lineid', 'int'); // Initialize technical objects $object = new MyObject($db); @@ -505,7 +505,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Clone - print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', $permissiontoadd); + print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid)?'&socid='.$object->socid:'').'&action=clone&token='.newToken(), '', $permissiontoadd); /* if ($permissiontoadd) { diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 5e8d09db179..e77fec58167 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -98,7 +98,7 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("pa if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) { diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index d1c4e4c8837..6733919289b 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -98,7 +98,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->mymodule->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->mymodule->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php From d80f83caf47599e64a8a0c5d59f6be972b42815c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 17:19:31 +0100 Subject: [PATCH 249/576] Clean code --- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/expedition/list.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/modulebuilder/template/myobject_list.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index c9566b73e62..e56e3b32666 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -700,7 +700,7 @@ $sql .= $hookmanager->resPrint; // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); $sql .= ', p.ref DESC'; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e03438b4e3b..e71b5ae9edd 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -633,7 +633,7 @@ $sql .= $hookmanager->resPrint; // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 02ce893b96d..7456a13146d 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -815,7 +815,7 @@ if (!$sall) { // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 ".$hookmanager->resPrint) : ""; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= ' ORDER BY '; $listfield = explode(',', $sortfield); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 526fb05dc64..8d0a5e40cc6 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -383,7 +383,7 @@ $sql .= $hookmanager->resPrint; // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (' HAVING 1=1 ' . $hookmanager->resPrint) : ''; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a1db1826684..d966a94769d 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -209,7 +209,7 @@ class FactureFournisseur extends CommonInvoice /** * @var int ID */ - public $fk_account; + public $fk_account; // default bank account public $mode_reglement_id; public $mode_reglement_code; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index e29b928140e..8b83048d8d3 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -655,7 +655,7 @@ if (!$search_all) { // Add HAVING from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : ""; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 9f1150d2194..e4965533440 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -349,7 +349,7 @@ $sql = preg_replace('/,\s*$/', '', $sql); /* $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrint) : ""; +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; */ // Count total nb of records diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3e4a1eeb9f3..ed18ec208f0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -209,10 +209,10 @@ class Societe extends CommonObject 'mode_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Mode reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>295), 'cond_reglement' =>array('type'=>'tinyint(4)', 'label'=>'Cond reglement', 'enabled'=>1, 'visible'=>-1, 'position'=>300), 'mode_reglement_supplier' =>array('type'=>'integer', 'label'=>'Mode reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>305), + 'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>308), 'outstanding_limit' =>array('type'=>'double(24,8)', 'label'=>'OutstandingBill', 'enabled'=>1, 'visible'=>-1, 'position'=>310, 'isameasure'=>1), 'order_min_amount' =>array('type'=>'double(24,8)', 'label'=>'Order min amount', 'enabled'=>'!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)', 'visible'=>-1, 'position'=>315, 'isameasure'=>1), 'supplier_order_min_amount' =>array('type'=>'double(24,8)', 'label'=>'Supplier order min amount', 'enabled'=>'!empty($conf->commande->enabled) && !empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)', 'visible'=>-1, 'position'=>320, 'isameasure'=>1), - 'cond_reglement_supplier' =>array('type'=>'integer', 'label'=>'Cond reglement supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>325), 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'Fk shipping method', 'enabled'=>1, 'visible'=>-1, 'position'=>330), 'tva_assuj' =>array('type'=>'tinyint(4)', 'label'=>'Tva assuj', 'enabled'=>1, 'visible'=>-1, 'position'=>335), 'localtax1_assuj' =>array('type'=>'tinyint(4)', 'label'=>'Localtax1 assuj', 'enabled'=>1, 'visible'=>-1, 'position'=>340), From baabfd380fd6ba863f8d3cd28cb3511db15e77b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 17:25:06 +0100 Subject: [PATCH 250/576] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index bda030187b3..ba2e0b1039e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1413,9 +1413,6 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromExcessPaid", $discount->ref_invoice_supplier_source); } else { - if (dol_textishtml($libelleproduitservice) && !dol_textishtml($desc)) { - $desc = str_replace("\n", '
    ', $desc); - } if ($idprod) { // Check if description must be output if (!empty($object->element)) { @@ -1431,12 +1428,12 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($conf->global->HIDE_LABEL_VARIANT_PDF) && $prodser->isVariant()) { $libelleproduitservice = $desc; } else { - $libelleproduitservice .= $desc; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } } else { - $libelleproduitservice .= $desc; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desc); } } } From 783ddcc6716052556970206af718d42000206fb3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 18:01:44 +0100 Subject: [PATCH 251/576] Fix phpcs --- htdocs/install/repair.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 4aba1d10c4b..9ce982cb458 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -1180,7 +1180,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { foreach ($conf->modules as $key => $val) { $listofmods .= ($listofmods ? ',' : '')."'".$db->escape($val)."'"; } - $sql = 'SELECT id, libelle as label, module from '.MAIN_DB_PREFIX.'rights_def WHERE module NOT IN ('.$db->sanitize($listofmods, 1).') AND id > 100000'; + $sql = "SELECT id, libelle as label, module from ".MAIN_DB_PREFIX."rights_def WHERE module NOT IN (".$db->sanitize($listofmods, 1).") AND id > 100000"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -1191,7 +1191,7 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { if ($obj->id > 0) { print '
    Found line with id '.$obj->id.', label "'.$obj->label.'" of module "'.$obj->module.'" to delete'; if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') { - $sqldelete = 'DELETE FROM '.MAIN_DB_PREFIX.'rights_def WHERE id = '.$obj->id; + $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE id = ".((int) $obj->id); $resqldelete = $db->query($sqldelete); if (!$resqldelete) { dol_print_error($db); From c37377626eb83e07653f0c122ce7c038477efcc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 19:43:23 +0100 Subject: [PATCH 252/576] Revert change --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f4dcf711b65..f2471d122af 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8528,7 +8528,9 @@ abstract class CommonObject } } } else { - $queryarray[$field] = !empty($this->{$field}) ? $this->{$field} : 0; + // Note: If $this->{$field} is not defined, it means there is a bug into definition of ->fields or a missing declaration of property + // We should keep the warning generated by this because it is a bug somewhere else in code, not here. + $queryarray[$field] = $this->{$field}; } if ($info['type'] == 'timestamp' && empty($queryarray[$field])) { From 20a3fab437c4d118bedabcb0cfe411fe24baa60b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Dec 2021 20:58:23 +0100 Subject: [PATCH 253/576] Fix pb when several output hooks --- htdocs/core/class/hookmanager.class.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index c113f2c3bb9..d1b1e08710e 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -146,7 +146,7 @@ class HookManager * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) * @return mixed For 'addreplace' hooks (doActions, formConfirm, formObjectOptions, pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. - * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0 if we want to keep standard actions, >0 uf we want to stop/replace standard actions (at least one > 0 and replacement will be done), <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. */ @@ -242,6 +242,7 @@ class HookManager $this->resArray = array(); $this->resNbOfHooks = 0; + // Here, the value for $method and $hooktype are given. // Loop on each hook to qualify modules that have declared context $modulealreadyexecuted = array(); $resaction = 0; @@ -265,7 +266,7 @@ class HookManager $this->resNbOfHooks++; - $modulealreadyexecuted[$module] = $module; // Use the $currentcontext in method to avoid running twice + $modulealreadyexecuted[$module] = $module; // Clean class (an error may have been set from a previous call of another method for same module/hook) $actionclassinstance->error = 0; @@ -274,6 +275,7 @@ class HookManager dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".get_class($actionclassinstance).'->'.$method.", context=".$context.", module=".$module.", action=".$action.((is_object($object) && property_exists($object, 'id')) ? ', object id='.$object->id : '').((is_object($object) && property_exists($object, 'element')) ? ', object element='.$object->element : ''), LOG_DEBUG); // Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; + // Note: The hook can use the $currentcontext in its code to avoid to be ran twice or be ran for one given context only $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace') if ($hooktype == 'addreplace') { @@ -310,7 +312,8 @@ class HookManager } //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); - $resaction = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) + $resactiontmp = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) + $resaction += $resactiontmp; if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) { $this->resArray = array_merge($this->resArray, $actionclassinstance->results); @@ -318,23 +321,23 @@ class HookManager if (!empty($actionclassinstance->resprints)) { $this->resPrint .= $actionclassinstance->resprints; } - if (is_numeric($resaction) && $resaction < 0) { + if (is_numeric($resactiontmp) && $resactiontmp < 0) { $error++; $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); } - // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string - if (!is_array($resaction) && !is_numeric($resaction)) { + + // TODO dead code to remove (do not disable this, but fix your hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string + if (!is_array($resactiontmp) && !is_numeric($resactiontmp)) { dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); if (empty($actionclassinstance->resprints)) { - $this->resPrint .= $resaction; - $resaction = 0; + $this->resPrint .= $resactiontmp; } } } - //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
    \n"; + //print "After hook context=".$context." ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
    \n"; unset($actionclassinstance->results); unset($actionclassinstance->resprints); From 0027335e3bd3f8fb3fe07611982be1b7160bdbf0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 03:25:07 +0100 Subject: [PATCH 254/576] Fix regression --- htdocs/core/lib/pdf.lib.php | 8 ++------ test/phpunit/PdfDocTest.php | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 668ba11b58e..735e6892fcd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1418,10 +1418,6 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Description long of product line if (!empty($desc) && ($desc != $label)) { - if ($libelleproduitservice && empty($hidedesc)) { - $libelleproduitservice .= '__N__'; - } - if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount = new DiscountAbsolute($db); $discount->fetch($object->lines[$i]->fk_remise_except); @@ -1547,7 +1543,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, // Adding the descriptions if they are filled $desccateg = $cate->description; if ($desccateg) { - $libelleproduitservice .= '__N__'.$desccateg; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $desccateg); } } } @@ -1572,7 +1568,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, } $libelleproduitservice .= '
    '.$period.''; } else { - $libelleproduitservice .= "__N__".$period; + $libelleproduitservice = dol_concatdesc($libelleproduitservice, $period); } //print $libelleproduitservice; } diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index f7181f8a4f9..35350c3bdae 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -160,11 +160,11 @@ class PdfDocTest extends PHPUnit\Framework\TestCase $result=pdf_getlinedesc($localobject, 0, $langs); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, "PINKDRESS - Label 1
    This is a description with a é accent
    (Country of origin: France)"); + $this->assertEquals("PINKDRESS - Label 1
    This is a description with a é accent
    (Country of origin: France)", $result); $result=doc_getlinedesc($localobject->lines[0], $langs); print __METHOD__." result=".$result."\n"; - $this->assertEquals($result, "PINKDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)"); + $this->assertEquals("PINKDRESS - Label 1\nThis is a description with a é accent\n(Country of origin: France)", $result); } /** From 8cdc5726a0aae8cf6f9ff232ef385ae6725b533c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 10:26:20 +0100 Subject: [PATCH 255/576] Fix column length --- htdocs/core/lib/phpsessionindb.lib.php | 4 ++-- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 1 + htdocs/install/mysql/tables/llx_session.sql | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 71711eb6ba6..8001b3ece60 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -117,7 +117,7 @@ function dolSessionWrite($sess_id, $val) // No session found, insert a new one $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; - $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape(substr($_SERVER['HTTP_USER_AGENT'], 0, 255))."')"; $result = $dbsession->query($insert_query); if (!$result) { @@ -140,7 +140,7 @@ function dolSessionWrite($sess_id, $val) // No session found, insert a new one $insert_query = "INSERT INTO ".MAIN_DB_PREFIX."session"; $insert_query .= "(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)"; - $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape($_SERVER['HTTP_USER_AGENT'])."')"; + $insert_query .= " VALUES ('".$dbsession->escape($sess_id)."', '".$dbsession->escape($val)."', '".$dbsession->idate($time_stamp)."', 0, '".$dbsession->escape(getUserRemoteIP())."', '".$dbsession->escape(substr($_SERVER['HTTP_USER_AGENT'], 0, 255)."')"; var_dump($insert_query); $result = $dbsession->query($insert_query); if (!$result) { diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index f3f92b39dae..5ec019cf253 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -475,3 +475,4 @@ ALTER TABLE llx_propal ADD COLUMN online_sign_name varchar(64); ALTER TABLE llx_entrepot ADD COLUMN warehouse_usage integer DEFAULT 1; +ALTER TABLE llx_session MODIFY COLUMN user_agent VARCHAR(255) NULL; diff --git a/htdocs/install/mysql/tables/llx_session.sql b/htdocs/install/mysql/tables/llx_session.sql index 5be31733c22..c466bda72dd 100644 --- a/htdocs/install/mysql/tables/llx_session.sql +++ b/htdocs/install/mysql/tables/llx_session.sql @@ -24,5 +24,5 @@ create table llx_session last_accessed datetime NOT NULL, fk_user integer NOT NULL, remote_ip varchar(64) NULL, - user_agent varchar(128) NULL + user_agent varchar(255) NULL )ENGINE=innodb; From 0fc9be27bc902312a4dad41bcc217294310190e2 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 10 Dec 2021 11:26:19 +0100 Subject: [PATCH 256/576] Fix #19545 : supplier order modification --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 616cda0376f..0ee5a80ce58 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2007,7 +2007,7 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); + $morehtmlref .= $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 1, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= ''; } else { From b609c579b6140d5e97ec67fedbd7c3da5ce814a1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 10 Dec 2021 11:40:25 +0100 Subject: [PATCH 257/576] FIX : postgresql compatibility, "" as is not authorized --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 944b5761bf6..16cbf52613f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1836,7 +1836,7 @@ function addMailingEventTypeSQL($actioncode, $objcon, $filterobj) $langs->load("mails"); $sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type"; - $sql2 .= ", '' as fk_element, '' as elementtype, '' as contact_id"; + $sql2 .= ", null as fk_element, '' as elementtype, null as contact_id"; $sql2 .= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto"; $sql2 .= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2 .= ", '' as lastname, '' as firstname"; From 9fbe0dee9be10e73343843d4bae4ce7c2f6ccd42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 12:36:51 +0100 Subject: [PATCH 258/576] Fix trans --- htdocs/core/lib/security.lib.php | 2 ++ htdocs/langs/en_US/errors.lang | 1 + htdocs/main.inc.php | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 80150a5c53e..1b8e91f78e5 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -909,9 +909,11 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) { + $langs->loadLangs(array("errors")); if ($user->login) { print $langs->trans("CurrentLogin").': '.$user->login.'
    '; print $langs->trans("ErrorForbidden2", $langs->transnoentitiesnoconv("Home"), $langs->transnoentitiesnoconv("Users")); + print $langs->trans("ErrorForbidden4"); } else { print $langs->trans("ErrorForbidden3"); } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0c0c3c7699d..cb0d4f1def0 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -111,6 +111,7 @@ ErrorFailedToLoadRSSFile=Fails to get RSS feed. Try to add constant MAIN_SIMPLEX ErrorForbidden=Access denied.
    You try to access to a page, area or feature of a disabled module or without being in an authenticated session or that is not allowed to your user. ErrorForbidden2=Permission for this login can be defined by your Dolibarr administrator from menu %s->%s. ErrorForbidden3=It seems that Dolibarr is not used through an authenticated session. Take a look at Dolibarr setup documentation to know how to manage authentications (htaccess, mod_auth or other...). +ErrorForbidden4=Note: clear your browser cookies to destroy existing sessions for this login. ErrorNoImagickReadimage=Class Imagick is not found in this PHP. No preview can be available. Administrators can disable this tab from menu Setup - Display. ErrorRecordAlreadyExists=Record already exists ErrorLabelAlreadyExists=This label already exists diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 05ec2b969b3..3e06d0a2a2d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1166,7 +1166,7 @@ if (!defined('NOLOGIN')) { // Check if user is active if ($user->statut < 1) { // If not active, we refuse the user - $langs->load("other"); + $langs->loadLangs(array("errors", "other")); dol_syslog("Authentication KO as login is disabled", LOG_NOTICE); accessforbidden($langs->trans("ErrorLoginDisabled")); exit; From 4d1e247a5c9f8b0ed328921afaa2c513cffa8f7c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 12:51:00 +0100 Subject: [PATCH 259/576] Trans --- htdocs/langs/en_US/products.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index a8ec90a47ab..a8942bd337f 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -404,7 +404,7 @@ PMPValueShort=WAP mandatoryperiod=Mandatory periods mandatoryPeriodNeedTobeSet=Note: Period (start and end date) must be defined mandatoryPeriodNeedTobeSetMsgValidate=A service requires a start and end period -mandatoryHelper=Message to the user on the need to enter a start date and an end date on a service when creating / validating an invoice, commercial proposal, sales order.
    This action is not blocking in the process of confirmation +mandatoryHelper=Check this if you want a message to the user when creating / validating an invoice, commercial proposal, sales order without entering a start and end date on lines with this service.
    Note that the message is a warning and not a blocking error. DefaultBOM=Default BOM DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. Rank=Rank From b2611e4cdb087dedc14a5aa231c54986f54fe90f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 10 Dec 2021 13:56:51 +0100 Subject: [PATCH 260/576] CSS --- htdocs/comm/action/index.php | 1 + htdocs/core/class/html.form.class.php | 2 +- htdocs/core/get_menudiv.php | 2 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/multicompany_page.php | 2 +- htdocs/core/search_page.php | 2 +- htdocs/theme/md/style.css.php | 3 +++ 7 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 5f7349fab3c..8696bbc82d4 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -217,6 +217,7 @@ if ($action == 'delete_action') { /* * View */ + $parameters = array( 'socid' => $socid, 'status' => $status, diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 364ca716aeb..705f007a7f1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2080,7 +2080,7 @@ class Form if ($num) { // Enhance with select2 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname); + $out = ajax_combobox($htmlname).$out; } } else { dol_print_error($this->db); diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 84be9ff8e0f..e04971ce8c3 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -84,7 +84,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Menu"); // URL http://mydolibarr/core/get_menudiv.php?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a menu page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 667a2808f58..69e83326707 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -73,11 +73,11 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print '
    '; // Type - print ''; $multiselect = 0; if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { // We use an option here because it adds bugs when used on agenda page "peruser" and "list" $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } + print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect, 0, 'maxwidth500'); print '
    '; diff --git a/htdocs/core/multicompany_page.php b/htdocs/core/multicompany_page.php index 5c55efc78db..ad1d8934dbb 100644 --- a/htdocs/core/multicompany_page.php +++ b/htdocs/core/multicompany_page.php @@ -81,7 +81,7 @@ if (GETPOST('acction', 'aZ') == 'switchentity') { $title = $langs->trans("Multicompanies"); // URL http://mydolibarr/core/multicompany_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a multicompany selection page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 2b82501208a..0341c1116ef 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -58,7 +58,7 @@ $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); $title = $langs->trans("Search"); // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests -$head = ''."\n"; +$head = ''."\n"; // This is used by DoliDroid to know page is a search page $arrayofjs = array(); $arrayofcss = array(); top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f9750df7fb6..f8abcceb51c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1058,6 +1058,9 @@ body[class*="colorblind-"] .text-success{ font-size: 1.5em; vertical-align: text-bottom; } +.fawidth30 { + width: 20px; +} .floatnone { float: none !important; } From 611bae4c3a2faf41a03fc3ebb474104a6926fe94 Mon Sep 17 00:00:00 2001 From: fr69400 <82267780+fr69400@users.noreply.github.com> Date: Fri, 10 Dec 2021 14:20:04 +0100 Subject: [PATCH 261/576] FIX - unasigned variable $action given to hook printOriginObjectSubLine --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2471d122af..03a9d518021 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4855,7 +4855,7 @@ abstract class CommonObject */ public function printOriginLinesList($restrictlist = '', $selectedLines = array()) { - global $langs, $hookmanager, $conf, $form; + global $langs, $hookmanager, $conf, $form, $action; print '
    '.$langs->trans('Ref').'
    '; - if (count($object->linesmvt) > 0) { + print '
    '; + print '
    '; + $total_debit = 0; $total_credit = 0; @@ -670,8 +671,14 @@ if ($action == 'create') { print ''; print ''; } else { - $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; + $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); + print ''; print ''; print ''; - print ''; } print "\n"; @@ -733,12 +748,16 @@ if ($action == 'create') { print ''; print ''; print ''; - print ''; + print ''; print ''; } - print '
    '.$accountingaccount->getNomUrl(0, 1, 1, '', 0).''; + if ($resultfetch > 0) { + $accountingaccount->getNomUrl(0, 1, 1, '', 0); + } else { + print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + } + print ''.length_accounta($line->subledger_account); if ($line->subledger_label) { print ' - '.$line->subledger_label.''; @@ -681,11 +688,15 @@ if ($action == 'create') { print ''.price($line->debit).''.price($line->credit).''; + print ''; if (empty($line->date_export) && empty($line->date_validation)) { print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; print img_edit('', 0, 'class="marginrightonly"'); print '  '; + } else { + print ''; + print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); + print '  '; } if (empty($line->date_validation)) { @@ -696,9 +707,13 @@ if ($action == 'create') { print ''; print img_delete(); + print ''; + } else { + print ''; + print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); + print ''; } - print ''; print '
    '; + print ''; + print '
    '; } + print '
    '; + print ''; + if ($mode == '_tmp' && $action == '') { print '
    '; print '
    '; @@ -753,8 +772,9 @@ if ($action == 'create') { print "
    "; } - print ''; } + + print ''; } } else { print load_fiche_titre($langs->trans("NoRecords")); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 01487ba3e83..8781bc13f86 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -387,7 +387,8 @@ SaleExport=Export sale SaleEEC=Sale in EEC SaleEECWithVAT=Sale in EEC with a VAT not null, so we suppose this is NOT an intracommunautary sale and the suggested account is the standard product account. SaleEECWithoutVATNumber=Sale in EEC with no VAT but the VAT ID of thirdparty is not defined. We fallback on the product account for standard sales. You can fix the VAT ID of thirdparty or the product account if needed. - +ForbiddenTransactionAlreadyExported=Forbidden: The transaction has been validated and/or exported. +ForbiddenTransactionAlreadyValidated=Forbidden: The transaction has been validated. ## Dictionary Range=Range of accounting account Calculated=Calculated diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d8bd4673d5c..da23e60498c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -884,6 +884,10 @@ body[class*="colorblind-"] .text-success{ .editfieldlang:hover { color: var(--colortexttitle) !important; } +a.editfielda.nohover *:hover:before { + color: #ccc !important; +} + .fawidth30 { width: 20px; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 6805f2c620e..8873149a9be 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1050,6 +1050,9 @@ body[class*="colorblind-"] .text-success{ .editfielda span.fa-pencil-alt:hover, .editfielda span.fa-trash:hover { color: var(--colortexttitle) !important; } +a.editfielda.nohover *:hover:before { + color: #ccc !important; +} .size15x { font-size: 1.5em !important; } .fa-toggle-on, .fa-toggle-off, .size2x { font-size: 2em; } From 6d94c6150b4d481cfd80c6aa24e6eb160c3c1b79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 17:56:28 +0100 Subject: [PATCH 287/576] FIX sign of unit price into the supplier credit note --- htdocs/fourn/class/fournisseur.facture.class.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d966a94769d..6dd88d68374 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2147,10 +2147,12 @@ class FactureFournisseur extends CommonInvoice $line->context = $this->context; $line->description = $desc; - $line->subprice = $pu_ht; - $line->pu_ht = $pu_ht; - $line->pu_ttc = $pu_ttc; - $line->qty = $qty; + + $line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $line->pu_ht = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $line->pu_ttc = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ttc) : $pu_ttc); // For credit note, unit price always negative, always positive otherwise + $line->remise_percent = $remise_percent; $line->ref_supplier = $ref_supplier; @@ -2163,11 +2165,13 @@ class FactureFournisseur extends CommonInvoice $line->localtax2_tx = $txlocaltax2; $line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; + $line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); $line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); $line->total_localtax1 = $total_localtax1; $line->total_localtax2 = $total_localtax2; $line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); + $line->fk_product = $idproduct; $line->product_type = $product_type; $line->info_bits = $info_bits; From d0bc32047d974b0410bc39d76b3d1496a2357312 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 18:11:17 +0100 Subject: [PATCH 288/576] FIX Create and clone negative social contribution --- htdocs/compta/sociales/class/chargesociales.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index c18d83ec52c..431f0bcba72 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -198,7 +198,7 @@ class ChargeSociales extends CommonObject $newamount = price2num($this->amount, 'MT'); // Validation of parameters - if (!($newamount > 0) || empty($this->date_ech) || empty($this->periode)) { + if ($newamount == 0 || empty($this->date_ech) || empty($this->periode)) { return false; } From 582caf0e7a72c01d0da9df764aaa5ad466e22a15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2021 19:04:25 +0100 Subject: [PATCH 289/576] FIX message for automatic binding not clear of what was done or not --- htdocs/accountancy/customer/index.php | 8 ++++++-- htdocs/accountancy/expensereport/index.php | 4 +++- htdocs/accountancy/supplier/index.php | 6 +++++- htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/fr_FR/accountancy.lang | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 2b7e624676f..e2ed822e35a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -93,7 +93,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { */ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) { - // Clean database + // Clean database by removing binding done on non existing or no more existing accounts $db->begin(); $sql1 = "UPDATE ".MAIN_DB_PREFIX."facturedet as fd"; $sql1 .= " SET fk_code_ventilation = 0"; @@ -119,6 +119,8 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; + $nbbinddone = 0; + $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind @@ -277,6 +279,8 @@ if ($action == 'validatehistory') { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; + } else { + $nbbinddone++; } } @@ -288,7 +292,7 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); } } diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 61b942e99bd..0987afb0c6a 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -131,8 +131,10 @@ if ($action == 'validatehistory') { $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { + $nbbinddone = $db->affected_rows($resql1); + $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); } } diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 406701d2500..1a0c8909829 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -117,6 +117,8 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; + $nbbinddone = 0; + $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind @@ -273,6 +275,8 @@ if ($action == 'validatehistory') { $error++; setEventMessages($db->lasterror(), null, 'errors'); break; + } else { + $nbbinddone++; } } @@ -284,7 +288,7 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone'), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); } } diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8781bc13f86..b9f84588079 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Validate movements DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible ValidateHistory=Bind Automatically -AutomaticBindingDone=Automatic binding done +AutomaticBindingDone=Automatic bindings done (%s) ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s | Credit = %s diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 5ac5b2b5d10..675e9ac338e 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Valider les mouvements DescValidateMovements=Toute modification ou suppression d'écriture, de lettrage et de suppression sera interdite. Toutes les entrées pour un exercice doivent être validées, sinon la fermeture ne sera pas possible ValidateHistory=Lier automatiquement -AutomaticBindingDone=Liaison automatique faite +AutomaticBindingDone=Liaisons automatiques faites (%s) ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas détruire de compte comptable car il est utilisé MvtNotCorrectlyBalanced=Mouvement non équilibré. Débit = %s| Crédit = %s From cf05f38e5417f4cd7989db995a329229901c647e Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Mon, 13 Dec 2021 19:56:06 +0100 Subject: [PATCH 290/576] Update functions.lib.php Change exists to isset in price2num --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 01e8acf4896..0084a4a33c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4784,7 +4784,7 @@ function price2num($amount, $rounding = '', $option = 0) $nbofdectoround = ''; if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; - elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; + elseif ($rounding == 'MS') $nbofdectoround = !isset($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; elseif ($rounding == 'CR') $nbofdectoround = 8; elseif (is_numeric($rounding)) $nbofdectoround = $rounding; //print "RR".$amount.' - '.$nbofdectoround.'
    '; From 8c844c96dfd4b21ec3b4c3e14c7efb4db16fc94f Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Mon, 13 Dec 2021 20:33:42 +0100 Subject: [PATCH 291/576] Update card_presend.tpl.php Add hidden feature ORDER_SUPPLIER_EMAIL_SENDER as sender address for purchase order emails --- htdocs/core/tpl/card_presend.tpl.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index aaaa043e39b..27a4172c27e 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -147,6 +147,11 @@ if ($action == 'presend') $formmail->fromname = ''; $formmail->fromtype = 'special'; } + if ($object->element === 'order_supplier' && !empty($conf->global->ORDER_SUPPLIER_EMAIL_SENDER)) { + $formmail->frommail = $conf->global->ORDER_SUPPLIER_EMAIL_SENDER; + $formmail->fromname = ''; + $formmail->fromtype = 'special'; + } $formmail->trackid=$trackid; if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set From 3b65d46b53a408ffe05ac8887099512b88d4169a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 14 Dec 2021 11:19:41 +0100 Subject: [PATCH 292/576] FIX avoid blank page with error --- htdocs/core/lib/pdf.lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 735e6892fcd..187687a0fe2 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -707,9 +707,12 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) // Add a background image on document only if good setup of const if (!empty($conf->global->MAIN_USE_BACKGROUND_ON_PDF) && ($conf->global->MAIN_USE_BACKGROUND_ON_PDF != '-1')) { // Warning, this option make TCPDF generation being crazy and some content disappeared behind the image - $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - $pdf->Image($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); - $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + $filepath = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_USE_BACKGROUND_ON_PDF; + if (file_exists($filepath)) { + $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image + $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); + $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak + } } } From 1d8cf297de0d115a07c1b50f77c4e7594f912e96 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 14 Dec 2021 12:10:09 +0100 Subject: [PATCH 293/576] Update html.formsetup.class.php --- htdocs/core/class/html.formsetup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 1778b46995e..a3f8a58d88e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -45,7 +45,7 @@ class FormSetup protected $maxItemRank; /** - * this is an html string display before output form + * this is an html string display before output form * @var string */ public $htmlBeforeOutputForm = ''; From 66c486c8788b6c65e496542461db39343d0056ad Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 14 Dec 2021 11:12:54 +0000 Subject: [PATCH 294/576] Fixing style errors. --- htdocs/core/class/html.formsetup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a3f8a58d88e..1778b46995e 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -45,7 +45,7 @@ class FormSetup protected $maxItemRank; /** - * this is an html string display before output form + * this is an html string display before output form * @var string */ public $htmlBeforeOutputForm = ''; From b971efb0626915b7ba10804c59e1fe3debee2ebd Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 14 Dec 2021 12:25:43 +0100 Subject: [PATCH 295/576] FIX : marginInfos array should be used by reference to allow to update it with a hook without draw again margin table --- htdocs/core/class/html.formmargin.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index d578f19ff2f..f39680d1fe3 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -213,7 +213,7 @@ class FormMargin $marginInfo = $this->getMarginInfosArray($object, $force_price); - $parameters=array('marginInfo'=>$marginInfo); + $parameters=array('marginInfo'=>&$marginInfo); $reshook = $hookmanager->executeHooks('displayMarginInfos', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); From aeb16d69d14604c30f4bdb67536f17825754a0ba Mon Sep 17 00:00:00 2001 From: javieralapps4up Date: Tue, 14 Dec 2021 17:15:18 +0100 Subject: [PATCH 296/576] FIX: When creating an invoice, extrafields with visibility = 4 are displayed When creating an invoice, extrafields with visibility = 4 are displayed --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 99bf843f50b..f6d217b2d83 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3652,7 +3652,7 @@ if ($action == 'create') { } }; - print $object->showOptionals($extrafields, 'edit', $parameters); + print $object->showOptionals($extrafields, 'create', $parameters); } // Template to use by default From f9e426600798da29516336f7904dcb2a28c96865 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 14 Dec 2021 19:37:44 +0100 Subject: [PATCH 297/576] FIX debug inventory feature (missing link to mvt, bad label of mvt) --- htdocs/core/class/commonobject.class.php | 9 ++- .../inventory/class/inventory.class.php | 2 +- htdocs/product/inventory/inventory.php | 76 ++++++++++++++++--- .../stock/class/mouvementstock.class.php | 17 +++-- 4 files changed, 85 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2471d122af..a83cfae3000 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4174,9 +4174,16 @@ abstract class CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql .= " SET ".$fieldstatus." = ".((int) $status); // If status = 1 = validated, update also fk_user_valid - if ($status == 1 && $elementTable == 'expensereport') { + // TODO Replace the test on $elementTable by doing a test on existence of the field in $this->fields + if ($status == 1 && in_array($elementTable, array('expensereport', 'inventory'))) { $sql .= ", fk_user_valid = ".((int) $user->id); } + if ($status == 1 && in_array($elementTable, array('expensereport'))) { + $sql .= ", date_valid = '".$this->db->idate(dol_now())."'"; + } + if ($status == 1 && in_array($elementTable, array('inventory'))) { + $sql .= ", date_validation = '".$this->db->idate(dol_now())."'"; + } $sql .= " WHERE rowid=".((int) $elementId); dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 092d98ea854..7a87f344e68 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -626,7 +626,7 @@ class Inventory extends CommonObject $statusType = 'status'.$status; if ($status == self::STATUS_RECORDED) { - $statusType = 'status5'; + $statusType = 'status6'; } return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode); diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index b6fa70ad551..c467b4367df 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -121,6 +121,8 @@ if (empty($reshook)) { $stockmovment = new MouvementStock($db); $stockmovment->setOrigin($object->element, $object->id); + $cacheOfProducts = array(); + $db->begin(); $sql = 'SELECT id.rowid, id.datec as date_creation, id.tms as date_modification, id.fk_inventory, id.fk_warehouse,'; @@ -139,8 +141,30 @@ if (empty($reshook)) { $qty_stock = $line->qty_stock; $qty_view = $line->qty_view; // The quantity viewed by inventorier, the qty we target + + // Load real stock we have now. + if (isset($cacheOfProducts[$line->fk_product])) { + $product_static = $cacheOfProducts[$line->fk_product]; + } else { + $product_static = new Product($db); + $result = $product_static->fetch($line->fk_product, '', '', '', 1, 1, 1); + + //$option = 'nobatch'; + $option .= ',novirtual'; + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. + + $cacheOfProducts[$product_static->id] = $product_static; + } + + // Get the real quantity in stock now, but before the stock move for inventory. + $realqtynow = $product_static->stock_warehouse[$line->fk_warehouse]->real; + if ($conf->productbatch->enabled && $product_static->hasbatch()) { + $realqtynow = $product_static->stock_warehouse[$line->fk_warehouse]->detail_batch[$line->batch]->qty; + } + + if (!is_null($qty_view)) { - $stock_movement_qty = price2num($qty_view - $qty_stock, 'MS'); + $stock_movement_qty = price2num($qty_view - $realqtynow, 'MS'); if ($stock_movement_qty != 0) { if ($stock_movement_qty < 0) { $movement_type = 1; @@ -152,15 +176,20 @@ if (empty($reshook)) { //$inventorycode = 'INV'.$object->id; $inventorycode = 'INV-'.$object->ref; - $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->id), $inventorycode, $datemovement, '', '', $line->batch); + $idstockmove = $stockmovment->_create($user, $line->fk_product, $line->fk_warehouse, $stock_movement_qty, $movement_type, 0, $langs->trans('LabelOfInventoryMovemement', $object->ref), $inventorycode, $datemovement, '', '', $line->batch); if ($idstockmove < 0) { $error++; setEventMessages($stockmovment->error, $stockmovment->errors, 'errors'); break; } - // Update line with id of stock movement - $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet SET fk_movement = ".((int) $idstockmove)." WHERE rowid = ".((int) $line->rowid); + // Update line with id of stock movement (and the start quantity if it has changed this last recording) + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventorydet"; + $sqlupdate .= " SET fk_movement = ".((int) $idstockmove); + if ($qty_stock != $realqtynow) { + $sqlupdate .= ", qty_stock = ".((float) $realqtynow); + } + $sqlupdate .= " WHERE rowid = ".((int) $line->rowid); $resqlupdate = $db->query($sqlupdate); if (! $resqlupdate) { $error++; @@ -215,7 +244,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("FieldCannotBeNegative", $langs->transnoentitiesnoconv("RealQty")), null, 'errors'); } if ($result > 0) { - $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value we want + $inventoryline->qty_stock = price2num(GETPOST('stock_qty_'.$lineid, 'alpha'), 'MS'); // The new value that was set in as hidden field $inventoryline->qty_view = $qtytoupdate; // The new value we want $resultupdate = $inventoryline->update($user); } @@ -236,6 +265,18 @@ if (empty($reshook)) { } } + // Update line with id of stock movement (and the start quantity if it has changed this last recording) + if (! $error) { + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."inventory"; + $sqlupdate .= " SET fk_user_modif = ".((int) $user->id); + $sqlupdate .= " WHERE rowid = ".((int) $object->id); + $resqlupdate = $db->query($sqlupdate); + if (! $resqlupdate) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + } + } + if (!$error) { $db->commit(); } else { @@ -766,9 +807,14 @@ if ($object->id > 0) { print $form->textwithpicto($langs->trans("RealQty"), $langs->trans("InventoryRealQtyHelp")); print '
    '; print ''; + //print $langs->trans("StockMovement"); + print '
    '; + $valuetoshow = $obj->qty_stock; + // For inventory not yet close, we overwrite with the real value in stock now if ($object->status == $object::STATUS_DRAFT || $object->status == $object::STATUS_VALIDATED) { if ($conf->productbatch->enabled && $product_static->hasbatch()) { $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->detail_batch[$obj->batch]->qty; } else { $valuetoshow = $product_static->stock_warehouse[$obj->fk_warehouse]->real; } - } else { - $valuetoshow = $obj->qty_stock; } print price2num($valuetoshow, 'MS'); print ''; @@ -891,9 +938,16 @@ if ($object->id > 0) { print ''; print ''; + print ''; print $obj->qty_view; // qty found print ''; + if ($obj->fk_movement > 0) { + $stockmovment = new MouvementStock($db); + $stockmovment->fetch($obj->fk_movement); + print $stockmovment->getNomUrl(1, 'movements'); + } + print '
    '; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print '
    '; print '
    '.($object->remise_percent ? ''.$object->remise_percent.'%' : '').''; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print '
    '; print '
    '; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print '
    '; print ''.($object->remise_supplier_percent ? ''.$object->remise_supplier_percent.'%' : '').''; @@ -310,7 +310,7 @@ if ($object->id > 0) { print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; if ($user->rights->societe->creer && !$user->socid > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''; @@ -320,7 +320,7 @@ if ($object->id > 0) { dol_print_error($db, $object->error); } if ($amount_discount > 0) { - print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; + print ''.price($amount_discount, 1, $langs, 1, -1, -1, $conf->currency).''; } //else print $langs->trans("DiscountNone"); print ''; From 9465edd8ec34aed0199986b64256ce40151a033f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 14:09:56 +0100 Subject: [PATCH 313/576] Add warning making payment if pending direct debit or credit trans --- htdocs/compta/paiement.php | 26 ++++++++++++++++++++++++- htdocs/fourn/facture/paiement.php | 30 +++++++++++++++++++++++++++-- htdocs/langs/en_US/withdrawals.lang | 2 ++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index b68374b84b9..cf0fb079fcb 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -726,7 +726,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; // Remain to take or to pay back - print ''.price($sign * $remaintopay).''; + print ''; + print price($sign * $remaintopay); + if (!empty($conf->prelevement->enabled)) { + $numdirectdebitopen = 0; + $totaldirectdebit = 0; + $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " WHERE fk_facture = ".((int) $objp->facid); + $sql .= " AND pfd.traite = 0"; + $sql .= " AND pfd.ext_payment_id IS NULL"; + + $result_sql = $db->query($sql); + if ($result_sql) { + $obj = $db->fetch_object($result_sql); + $numdirectdebitopen = $obj->nb; + $totaldirectdebit = $obj->amount; + } else { + dol_print_error($db); + } + if ($numdirectdebitopen) { + $langs->load("withdrawals"); + print img_warning($langs->trans("WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip'); + } + } + print ''; //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); // Amount diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index ba7027b28ee..08a5d2f3c44 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -519,7 +519,9 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql .= ' AND f.type = 2'; // If paying back a credit note, we show all credit notes } // Group by because we have a total - $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc, f.multicurrency_total_ttc, f.datef, f.date_lim_reglement'; + $sql .= ' GROUP BY f.datef, f.ref, f.ref_supplier, f.rowid, f.type, f.total_ht, f.total_ttc,'; + $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,'; + $sql .= ' f.datef, f.date_lim_reglement'; // Sort invoices by date and serial number: the older one comes first $sql .= ' ORDER BY f.datef ASC, f.ref ASC'; @@ -685,7 +687,31 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ''; - print ''.price($sign * $remaintopay).''; + print ''; + print price($sign * $remaintopay); + if (!empty($conf->paymentbybanktransfer->enabled)) { + $numdirectdebitopen = 0; + $totaldirectdebit = 0; + $sql = "SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; + $sql .= " WHERE fk_facture_fourn = ".((int) $objp->facid); + $sql .= " AND pfd.traite = 0"; + $sql .= " AND pfd.ext_payment_id IS NULL"; + + $result_sql = $db->query($sql); + if ($result_sql) { + $obj = $db->fetch_object($result_sql); + $numdirectdebitopen = $obj->nb; + $totaldirectdebit = $obj->amount; + } else { + dol_print_error($db); + } + if ($numdirectdebitopen) { + $langs->load("withdrawals"); + print img_warning($langs->trans("WarningSomeCreditTransferAlreadyExists", $numdirectdebitopen, price(price2num($totaldirectdebit, 'MT'), 0, $langs, 1, -1, -1, $conf->currency)), '', 'classfortooltip'); + } + } + print ''; // Amount print ''; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 7b18c1a0d70..68ac879c510 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -150,3 +150,5 @@ ModeWarning=Option for real mode was not set, we stop after this simulation ErrorCompanyHasDuplicateDefaultBAN=Company with id %s has more than one default bank account. No way to know wich one to use. ErrorICSmissing=Missing ICS in Bank account %s TotalAmountOfdirectDebitOrderDiffersFromSumOfLines=Total amount of direct debit order differs from sum of lines +WarningSomeDirectDebitOrdersAlreadyExists=Warning: There is already some pending Direct Debit orders (%s) requested for an amount of %s +WarningSomeCreditTransferAlreadyExists=Warning: There is already some pending Credit Transfer (%s) requested for an amount of %s \ No newline at end of file From a5b8d0cd4bab0e7f299ca5d9d42214410bf7505a Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 16 Dec 2021 15:41:13 +0100 Subject: [PATCH 314/576] FIX Take into consideration work leave over serveral months --- htdocs/holiday/month_report.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 0444157704b..b71bea7bd34 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -84,7 +84,12 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; $sql .= " WHERE cp.rowid > 0"; $sql .= " AND cp.statut = 3"; // Approved -$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; +$sql .= " AND ("; +$sql .= " (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; +$sql .= " OR"; +// For work leave over several months +$sql .= " (date_format(cp.date_debut, '%Y-%m') < '".$db->escape($year_month)."' AND date_format(cp.date_fin, '%Y-%m') > '".$db->escape($year_month)."') "; +$sql .= " )"; $sql .= " ORDER BY u.lastname, cp.date_debut"; $resql = $db->query($sql); From d92535ec5982f88f1c502ea10b5b51899a278556 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 15:41:23 +0100 Subject: [PATCH 315/576] FIX Debug transfert in accountancy for expense report --- .../class/accountingaccount.class.php | 2 +- htdocs/accountancy/customer/index.php | 16 ++-- htdocs/accountancy/expensereport/index.php | 77 +++++++++++++------ htdocs/accountancy/expensereport/lines.php | 3 +- htdocs/accountancy/supplier/index.php | 12 ++- htdocs/expensereport/card.php | 18 ++++- .../class/expensereport.class.php | 4 +- htdocs/langs/en_US/accountancy.lang | 2 +- htdocs/langs/fr_FR/accountancy.lang | 2 +- 9 files changed, 95 insertions(+), 41 deletions(-) diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 730e52c805a..cdfa3602e73 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -166,7 +166,7 @@ class AccountingAccount extends CommonObject * * @param int $rowid Id * @param string $account_number Account number - * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active char of account + * @param int|boolean $limittocurrentchart 1 or true=Load record only if it is into current active chart of account * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @return int <0 if KO, 0 if not found, Id of record if OK and found */ diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index e2ed822e35a..62f613a940b 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -120,6 +120,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $notpossible = 0; $db->begin(); @@ -156,14 +157,13 @@ if ($action == 'validatehistory') { } else { $sql .= " s.accountancy_code_sell as company_code_sell"; } - $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity); } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facturedet as l ON f.rowid = l.fk_facture"; // the main table $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity); @@ -174,8 +174,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_sell = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; - $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql .= " AND l.product_type <= 2"; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0 AND l.product_type <= 2 AND f.entity = ".((int) $conf->entity); if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } @@ -256,7 +255,7 @@ if ($action == 'validatehistory') { $suggestedid = 0; $return=$accountingAccount->getAccountingCodeToBind($thirdpartystatic, $mysoc, $product_static, $facture_static, $facture_static_det, $accountingAccountArray, 'customer'); - if (!is_array($return) && $return<0) { + if (!is_array($return) && $return < 0) { setEventMessage($accountingAccount->error, 'errors'); } else { $suggestedid = $return['suggestedid']; @@ -282,17 +281,22 @@ if ($action == 'validatehistory') { } else { $nbbinddone++; } + } else { + $notpossible++; } $i++; } + if ($num_lines > 10000) { + $notpossible += ($num_lines - 10000); + } } if ($error) { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); } } diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 0987afb0c6a..37abd56a21d 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -99,42 +99,69 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; + $nbbinddone = 0; + $notpossible = 0; + $db->begin(); // Now make the binding - if ($db->type == 'pgsql') { - $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; - $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; - $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; - if ($validatemonth && $validateyear) { - $sql1 .= dolSqlDateFilter('date', 0, $validatemonth, $validateyear); - } - } else { - $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; - $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; - $sql1 .= " AND erd.fk_code_ventilation = 0"; - if ($validatemonth && $validateyear) { - $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear); - } + $sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid"; + $sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id"; + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.entity =".((int) $conf->entity); + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as syst ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND syst.active = 1,'; + $sql1 .= " ".MAIN_DB_PREFIX."expensereport as er"; + $sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity); + $sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; + if ($validatemonth && $validateyear) { + $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear); } dol_syslog('htdocs/accountancy/expensereport/index.php'); - $resql1 = $db->query($sql1); - if (!$resql1) { + $result = $db->query($sql1); + if (!$result) { $error++; - $db->rollback(); setEventMessages($db->lasterror(), null, 'errors'); } else { - $nbbinddone = $db->affected_rows($resql1); + $num_lines = $db->num_rows($result); + $i = 0; + while ($i < min($num_lines, 10000)) { // No more than 10000 at once + $objp = $db->fetch_object($result); + + $lineid = $objp->rowid; + $suggestedid = $objp->suggestedid; + + if ($suggestedid > 0) { + $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."expensereport_det"; + $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid); + $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND rowid = ".((int) $lineid); + + $resqlupdate = $db->query($sqlupdate); + if (!$resqlupdate) { + $error++; + setEventMessages($db->lasterror(), null, 'errors'); + break; + } else { + $nbbinddone++; + } + } else { + $notpossible++; + } + + $i++; + } + if ($num_lines > 10000) { + $notpossible += ($num_lines - 10000); + } + } + + if ($error) { + $db->rollback(); + } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); } } @@ -157,7 +184,7 @@ print '
    '; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index b262f85367a..fb3bf1a6e04 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -394,11 +394,12 @@ if ($result) { print ''.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).''; // Accounting account affected - print ''; + print ''; print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1); print ' '; print img_edit(); print ''; + print ''; print ""; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 1a0c8909829..51c9e66cebe 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -118,6 +118,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $notpossible = 0; $db->begin(); @@ -154,7 +155,6 @@ if ($action == 'validatehistory') { } else { $sql .= " s.accountancy_code_buy as company_code_buy"; } - $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -172,8 +172,7 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON " . $alias_product_perentity . ".accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa2.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON " . $alias_product_perentity . ".accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa3.entity = ".$conf->entity; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa4 ON " . $alias_societe_perentity . ".accountancy_code_buy = aa4.account_number AND aa4.active = 1 AND aa4.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND aa4.entity = ".$conf->entity; - $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; - $sql .= " AND l.product_type <= 2"; + $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0 AND l.product_type <= 2 AND f.entity = ".((int) $conf->entity); if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } @@ -278,17 +277,22 @@ if ($action == 'validatehistory') { } else { $nbbinddone++; } + } else { + $notpossible++; } $i++; } + if ($num_lines > 10000) { + $notpossible += ($num_lines - 10000); + } } if ($error) { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); } } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 38f7703f744..db358964f16 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2094,8 +2094,22 @@ if ($action == 'create') { print ''; } + $titlealt = ''; + if (!empty($conf->accounting->enabled)) { + $accountingaccount = new AccountingAccount($db); + $resaccountingaccount = $accountingaccount->fetch(0, $line->type_fees_accountancy_code, 1); + //$titlealt .= ''; + $titlealt .= $langs->trans("AccountancyCode").': '; + if ($resaccountingaccount > 0) { + $titlealt .= $accountingaccount->account_number; + } else { + $titlealt .= $langs->trans("NotFound"); + } + //$titlealt .= ''; + } + // Type of fee - print ''; + print ''; $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); print $labeltype; print ''; @@ -2109,8 +2123,10 @@ if ($action == 'create') { // Comment print ''.dol_nl2br($line->comments).''; + // VAT rate print ''.vatrate($line->vatrate.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), true).''; + // Unit price HT print ''; if (!empty($line->value_unit_ht)) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 877a7c79ade..d5695c7e49a 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -999,7 +999,7 @@ class ExpenseReport extends CommonObject $sql .= ' de.fk_ecm_files,'; $sql .= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql .= ' de.total_localtax1, de.total_localtax2, de.rule_warning_message,'; - $sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; + $sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees, ctf.accountancy_code as accountancy_code_type_fees,'; $sql .= ' p.ref as ref_projet, p.title as title_projet'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON de.fk_c_type_fees = ctf.id'; @@ -1043,6 +1043,7 @@ class ExpenseReport extends CommonObject $deplig->type_fees_code = empty($objp->code_type_fees) ? 'TF_OTHER' : $objp->code_type_fees; $deplig->type_fees_libelle = $objp->libelle_type_fees; + $deplig->type_fees_accountancy_code = $objp->accountancy_code_type_fees; $deplig->tva_tx = $objp->tva_tx; $deplig->vatrate = $objp->tva_tx; @@ -2579,6 +2580,7 @@ class ExpenseReportLine public $type_fees_code; public $type_fees_libelle; + public $type_fees_accountancy_code; public $projet_ref; public $projet_title; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index b9f84588079..7999d46363e 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Validate movements DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible ValidateHistory=Bind Automatically -AutomaticBindingDone=Automatic bindings done (%s) +AutomaticBindingDone=Automatic bindings done (%s) - Automatic binding not possible for some record (%s) ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s | Credit = %s diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 675e9ac338e..f5b9b5dcf3e 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -286,7 +286,7 @@ ValidateMovements=Valider les mouvements DescValidateMovements=Toute modification ou suppression d'écriture, de lettrage et de suppression sera interdite. Toutes les entrées pour un exercice doivent être validées, sinon la fermeture ne sera pas possible ValidateHistory=Lier automatiquement -AutomaticBindingDone=Liaisons automatiques faites (%s) +AutomaticBindingDone=Liaisons automatiques faites (%s) - Liaison automatique non possible pour certains cas (%s) ErrorAccountancyCodeIsAlreadyUse=Erreur, vous ne pouvez pas détruire de compte comptable car il est utilisé MvtNotCorrectlyBalanced=Mouvement non équilibré. Débit = %s| Crédit = %s From 8c73ef4bbf52bd39d176fed9851f341d53cefb79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 16:30:42 +0100 Subject: [PATCH 316/576] Fix menu perm --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8f73eb5a88c..ebeb4ab40f7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1618,7 +1618,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/product/card.php?leftmenu=service&action=create&type=1", $langs->trans("NewService"), 1, $user->rights->service->creer); $newmenu->add("/product/list.php?leftmenu=service&type=1", $langs->trans("List"), 1, $user->rights->service->lire); if (!empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->facture->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_proposal->enabled) || !empty($conf->supplier_oder->enabled) || !empty($conf->supplier_invoice->enabled)) { - $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire && $user->rights->propale->lire); + $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=1", $langs->trans("Statistics"), 1, $user->rights->service->lire || $user->rights->product->lire); } // Categories if (!empty($conf->categorie->enabled)) { From f8e6befe35771ceeec75e091c5b5e274029b29e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 16:47:11 +0100 Subject: [PATCH 317/576] Fix link on user --- htdocs/supplier_proposal/list.php | 14 +++++++++++--- htdocs/user/class/user.class.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index a64ac94b169..4c92387a613 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -302,7 +302,7 @@ $sql .= " p.rowid as project_id, p.ref as project_ref,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; } -$sql .= " u.firstname, u.lastname, u.photo, u.login"; +$sql .= " u.firstname, u.lastname, u.photo, u.login, u.statut as status, u.admin, u.employee, u.email as uemail"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -1092,12 +1092,20 @@ if ($resql) { $userstatic->id = $obj->fk_user_author; $userstatic->login = $obj->login; + $userstatic->status = $obj->status; + $userstatic->lastname = $obj->name; + $userstatic->firstname = $obj->firstname; + $userstatic->photo = $obj->photo; + $userstatic->admin = $obj->admin; + $userstatic->ref = $obj->fk_user_author; + $userstatic->employee = $obj->employee; + $userstatic->email = $obj->uemail; // Author if (!empty($arrayfields['u.login']['checked'])) { print ''; - if ($userstatic->id) { - print $userstatic->getLoginUrl(1); + if ($userstatic->id > 0) { + print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1); } else { print ' '; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 467a572193e..d5fc9c8ece2 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2797,7 +2797,7 @@ class User extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut(isset($this->statut) ? $this->statut : $this->status, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps From bef1afc7b89842cb7f4d6ce2fffa7e778ef73e0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:01:15 +0100 Subject: [PATCH 318/576] Clean code --- htdocs/admin/fckeditor.php | 3 ++- htdocs/core/modules/modFckeditor.class.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 19367c8b50d..51247ac0b35 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -159,11 +159,12 @@ if (empty($conf->use_javascript_ajax)) { continue; } + $constante = 'FCKEDITOR_ENABLE_'.$const; + print ''."\n"; print ''; print ''.img_object("", $picto[$const]).''; print ''.$langs->trans($desc).''; print ''; - $constante = 'FCKEDITOR_ENABLE_'.$const; $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); if ($value == 0) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 3dfd0f233e5..8c30d8a0a51 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -69,8 +69,8 @@ class modFckeditor extends DolibarrModules // Constants $this->const = array(); - $this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for description and note (except products/services)"); - $this->const[1] = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for products/services description and note"); + $this->const[0] = array("FCKEDITOR_ENABLE_SOCIETE", "yesno", "1", "WYSIWIG for the fields descriptions of elements (except products/services)"); + $this->const[1] = array("FCKEDITOR_ENABLE_PRODUCTDESC", "yesno", "1", "WYSIWIG for the fields description of products/services"); $this->const[2] = array("FCKEDITOR_ENABLE_MAILING", "yesno", "1", "WYSIWIG for mass emailings"); $this->const[3] = array("FCKEDITOR_ENABLE_DETAILS", "yesno", "1", "WYSIWIG for products details lines for all entities"); $this->const[4] = array("FCKEDITOR_ENABLE_USERSIGN", "yesno", "1", "WYSIWIG for user signature"); From dc1118a3dfaebac1f5a217357b1032c08625550c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:04:25 +0100 Subject: [PATCH 319/576] Update info.php --- htdocs/compta/facture/info.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 340dfda2957..e08b237d5ea 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -38,31 +38,30 @@ $langs->loadLangs(array('companies', 'bills')); $id = GETPOST("facid", "int"); $ref = GETPOST("ref", 'alpha'); +$object = new Facture($db); +$object->fetch($id, $ref); + /* * View */ -$object = new Facture($db); -$object->fetch($id, $ref); -$object->fetch_thirdparty(); - -$object->info($object->id); - -if (empty($object->id)) { - llxHeader(); - $langs->load('errors'); - echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; - llxFooter(); - exit; -} - $form = new Form($db); $title = $langs->trans('InvoiceCustomer')." - ".$langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); +if (empty($object->id)) { + $langs->load('errors'); + echo '
    '.$langs->trans("ErrorRecordNotFound").'
    '; + llxFooter(); + exit; +} + +$object->fetch_thirdparty(); +$object->info($object->id); + $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); From e9b7fd0ef875943e09a5d1b9932dd1d3a1c79b16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:05:12 +0100 Subject: [PATCH 320/576] Update info.php --- htdocs/compta/facture/info.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index e08b237d5ea..abfbfabea21 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -39,7 +39,9 @@ $id = GETPOST("facid", "int"); $ref = GETPOST("ref", 'alpha'); $object = new Facture($db); -$object->fetch($id, $ref); +if ($id > 0 || !empty($ref)) { + $object->fetch($id, $ref); +} /* From c5bdb7b4d8c685d1e2bd3c88b62cb86ce71c72bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:29:04 +0100 Subject: [PATCH 321/576] Revert "Update card_presend.tpl.php" --- htdocs/core/tpl/card_presend.tpl.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 93b17b6dc86..7cc95c81fe0 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -143,13 +143,6 @@ if ($action == 'presend') { $formmail->fromtype = 'special'; } - $formmail->trackid=$trackid; - if (!empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set - { - include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $formmail->frommail = dolAddEmailTrackId($formmail->frommail, $trackid); - } - $formmail->trackid = $trackid; From cf01018a90b6dc3b37631fd174951bf4a1003246 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:42:09 +0100 Subject: [PATCH 322/576] Update ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 527d6acd9e6..283b8fc5146 100644 --- a/ChangeLog +++ b/ChangeLog @@ -147,7 +147,7 @@ Following changes may create regressions for some external modules, but were nec * Class file expeditionbatch.class.php renamed to expeditionlinebatch.class.php * ExpeditionLineBatch::fetchAll is not static anymore and first parameter $db is removed * ExtraFields->showOutputField parameter 4 'extrafieldsobjectkey' is now required -* CommonObject method add_object_linked now sets targettype to 'mymodule_myobject' iso 'myobject', +* CommonObject method add_object_linked now sets targettype to 'mymodule_myobject' instead of 'myobject', you can use hook 'setLinkedObjectSourceTargetType' to set your usual targettype From 6c053abfd991f9b092c1d44dfe15db7115d25926 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 17:58:08 +0100 Subject: [PATCH 323/576] Standardize code --- htdocs/mrp/class/mo.class.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index cdad4e71968..2e7b4186a87 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1319,19 +1319,15 @@ class Mo extends CommonObject if (!empty($this->lines)) { foreach ($this->lines as $line) { - /*if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line))) - { - if (empty($line->fk_parent_line)) - { - $parameters = array('line'=>$line, 'i'=>$i); - $action = ''; - $result = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - } + $reshook = 0; + if (is_object($hookmanager)) { + $parameters = array('line'=>$line, 'i'=>$i, 'restrictlist'=>$restrictlist, 'selectedLines'=> $selectedLines); + if (!empty($line->fk_parent_line)) { $parameters['fk_parent_line'] = $line->fk_parent_line; } + $reshook = $hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks } - else - {*/ + if (empty($reshook)) { $this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines); - //} + } $i++; } From 517355972aa052d0633338862925eb94a0bf618a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 19:01:11 +0100 Subject: [PATCH 324/576] Fix duplicate table for online signature --- htdocs/core/class/commonobject.class.php | 2 +- .../mysql/tables/llx_online_signatures.sql | 29 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_online_signatures.sql diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a83cfae3000..94bea1e56b4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5308,7 +5308,7 @@ abstract class CommonObject // Set the public "share" key $setsharekey = false; if ($this->element == 'propal') { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + $useonlinesignature = 1; // Replace this with 1 when feature to make online signature is ok if ($useonlinesignature) { $setsharekey = true; } diff --git a/htdocs/install/mysql/tables/llx_online_signatures.sql b/htdocs/install/mysql/tables/llx_online_signatures.sql deleted file mode 100644 index fbba814dd4d..00000000000 --- a/htdocs/install/mysql/tables/llx_online_signatures.sql +++ /dev/null @@ -1,29 +0,0 @@ --- ============================================================================ --- Copyright (C) 2017 Laurent Destailleur --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- ============================================================================ - -create table llx_onlinesignature -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, - object_type varchar(32) NOT NULL, - object_id integer NOT NULL, - datec datetime NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - name varchar(255) NOT NULL, - ip varchar(128), - pathoffile varchar(255) -)ENGINE=innodb; From 3895438b85f8dd552e293ecc4e7b02dd31bfe7b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Dec 2021 23:53:05 +0100 Subject: [PATCH 325/576] Fix responsive --- htdocs/core/class/html.form.class.php | 2 +- htdocs/product/stats/card.php | 9 ++++++--- htdocs/theme/eldy/global.inc.php | 4 ++++ htdocs/theme/md/style.css.php | 27 +++++++++++++++++++-------- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1d63bbaf332..0525ad6f3c8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2347,7 +2347,7 @@ class Form $out .= img_picto($langs->trans("Search"), 'search'); } } - $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out .= 'global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { $out .= img_picto($langs->trans("Search"), 'search'); } diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 463297f043a..f45a851ecad 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -192,20 +192,20 @@ if ($result || !($id > 0)) { // Type print ''.$langs->trans("Type").''; $array = array('-1'=>' ', '0'=>$langs->trans('Product'), '1'=>$langs->trans('Service')); - print $form->selectarray('type', $array, $type); + print $form->selectarray('type', $array, $type, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100'); print ''; // Product print ''.$langs->trans("ProductOrService").''; print img_picto('', 'product', 'class="pictofixedwidth"'); - print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, 'maxwidth500'); + print $form->select_produits($id, 'id', '', 0, 0, 1, 2, '', ($conf->dol_optimize_smallscreen ? 1 : 0), array(), 0, '1', 0, 'widthcentpercentminusx maxwidth400'); print ''; // Tag if ($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; $moreforfilter .= img_picto($langs->trans("Categories"), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth300'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1, 1, 'widthcentpercentminusx maxwidth400'); print $moreforfilter; print ''; } @@ -465,7 +465,9 @@ if ($result || !($id > 0)) { $linktoregenerate .= img_picto($langs->trans("ReCalculate").' ('.$dategenerated.')', 'refresh'); $linktoregenerate .= ''; + // Show graph + print '
    '; print ''; // Label print ''; print '
    '; @@ -478,6 +480,7 @@ if ($result || !($id > 0)) { print $graphfiles[$key]['output']; print '
    '; + print '
    '; if ($i % 2 == 0) { print "\n".''."\n"; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e413623fb0c..11cf7f8e867 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -7249,6 +7249,10 @@ div.clipboardCPValue.hidewithsize { padding-left: 12px; padding-right: 12px; } + + .a-mesure, .a-mesure-disabled { + text-align: center; + } } @media only screen and (max-width: 320px) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index a2a68168e8e..570a4eaa6b3 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -688,8 +688,8 @@ input[type=checkbox], input[type=radio] { input:-moz-placeholder { color:#ccc; } input[name=price], input[name=weight], input[name=volume], input[name=surface], input[name=sizeheight], input[name=net_measure], select[name=incoterm_id] { margin-right: 6px; } -fieldset { - border: 1px solid #AAAAAA !important; +fieldset { + border: 1px solid #AAAAAA !important; padding-inline-start: 2em; padding-inline-end: 2em; } @@ -2959,8 +2959,8 @@ div.vmenu, td.vmenu { .searchform { padding-top: 10px; } .searchform .bordertransp { border: 0; } -a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { - white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; +a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { + white-space: nowrap; font-size:px; font-family: ; text-align: ; font-weight: bold; } span.vmenudisabled, font.vmenudisabled { font-size:px; font-family: ; text-align: ; font-weight: bold; color: #aaa; margin-left: 4px; white-space: nowrap; } a.vmenu:link, a.vmenu:visited { @@ -2968,8 +2968,8 @@ a.vmenu:link, a.vmenu:visited { } a.vsmenu:link, a.vsmenu:visited, a.vsmenu:hover, a.vsmenu:active, span.vsmenu { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #202020; margin: 1px 1px 1px 8px; } -span.vsmenudisabled, font.vsmenudisabled { - font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; +span.vsmenudisabled, font.vsmenudisabled { + font-size:px; font-family: ; text-align: ; font-weight: normal; color: #aaa; } a.vsmenu:link, a.vsmenu:visited { color: var(--colortextbackvmenu); @@ -2978,7 +2978,7 @@ a.vsmenu:link, a.vsmenu:visited { span.vsmenudisabledmargin, font.vsmenudisabledmargin { margin: 1px 1px 1px 8px; } a.help:link, a.help:visited, a.help:hover, a.help:active, span.help { - text-align: ; font-weight: normal; color: #999; text-decoration: none; + text-align: ; font-weight: normal; color: #999; text-decoration: none; } .helppresentcircle { @@ -6997,7 +6997,7 @@ div.clipboardCPValue.hidewithsize { border-right: 1px solid rgba(0,0,0,0.3); top: auto; } - + div#tmenu_tooltip { display:none; @@ -7070,6 +7070,17 @@ div.clipboardCPValue.hidewithsize { boerder-right: unset; padding-left: 5px; } + + .a-mesure, .a-mesure-disabled { + display: block; + margin-bottom: 6px; + padding-left: 12px; + padding-right: 12px; + } + + .a-mesure, .a-mesure-disabled { + text-align: center; + } } From f3430d94d5fe6736d28a5c75144a10dad06652d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Dec 2021 00:48:13 +0100 Subject: [PATCH 326/576] css --- htdocs/admin/dav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 9edc123a784..e12848e3de1 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -123,12 +123,12 @@ if ($action == 'edit') { print ''.$langs->trans("Parameter").''.$langs->trans("Value").''; foreach ($arrayofparameters as $key => $val) { - print ''; + print ''; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $label = $langs->trans($key); if ($key == 'DAV_RESTICT_ON_IP') { $label = $langs->trans("RESTRICT_ON_IP"); - $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); + $label .= ' '.$langs->trans("Example").': '.$langs->trans("IPListExample").''; } print $form->textwithpicto($label, $tooltiphelp); print ''; From fcb10df5704cec71b64f857a26593b0a1e2199d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Dec 2021 09:54:03 +0100 Subject: [PATCH 327/576] Fix size of origintype --- htdocs/install/mysql/migration/14.0.0-15.0.0.sql | 1 + htdocs/install/mysql/tables/llx_stock_mouvement.sql | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 263e94e4575..cd24a252a04 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -479,3 +479,4 @@ ALTER TABLE llx_session MODIFY COLUMN user_agent VARCHAR(255) NULL; ALTER TABLE llx_inventorydet ADD COLUMN fk_movement integer NULL; +ALTER TABLE llx_stock_mouvement MODIFY COLUMN origintype varchar(64); diff --git a/htdocs/install/mysql/tables/llx_stock_mouvement.sql b/htdocs/install/mysql/tables/llx_stock_mouvement.sql index 2cd094c1b05..ec3465a6c2d 100644 --- a/htdocs/install/mysql/tables/llx_stock_mouvement.sql +++ b/htdocs/install/mysql/tables/llx_stock_mouvement.sql @@ -35,7 +35,7 @@ create table llx_stock_mouvement inventorycode varchar(128), -- Code used to group different movement line into one operation (may be an inventory, a mass picking) fk_project integer, fk_origin integer, - origintype varchar(32), + origintype varchar(64), model_pdf varchar(255), fk_projet integer NOT NULL DEFAULT 0 )ENGINE=innodb; From e60f65db7d417ae8a96fffb50ff2e06c003d6fda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Dec 2021 10:00:10 +0100 Subject: [PATCH 328/576] Trans --- htdocs/product/popuprop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 32a2cd08cc9..dbffe79d0c0 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -30,7 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page -$langs->loadLangs(array('commande', 'propal', 'bills', 'other')); +$langs->loadLangs(array('commande', 'propal', 'bills', 'other', 'products')); $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); From dfbd03140cfba9e3235a90d0ca0a058b6af7c2a8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 17 Dec 2021 11:10:08 +0100 Subject: [PATCH 329/576] FIX: manage multientity in ticket public page by querystring --- htdocs/public/ticket/create_ticket.php | 8 +++++- htdocs/public/ticket/index.php | 11 +++++---- htdocs/public/ticket/list.php | 20 +++++++++------ htdocs/public/ticket/view.php | 26 ++++++++++++-------- htdocs/ticket/class/actions_ticket.class.php | 3 +++ 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 1a11b16d1ea..9efa561341e 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -47,6 +47,12 @@ if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; @@ -342,7 +348,7 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('save', 'alpha')) { $messagetoshow = str_replace(array('{s1}', '{s2}'), array(''.$object->track_id.'', ''.$object->ref.''), $messagetoshow); setEventMessages($messagetoshow, null, 'warnings'); setEventMessages($langs->trans('PleaseRememberThisId'), null, 'warnings'); - header("Location: index.php"); + header("Location: index.php".(!empty($entity) && !empty($conf->multicompany->enabled)?'?entity='.$entity:'')); exit; } } else { diff --git a/htdocs/public/ticket/index.php b/htdocs/public/ticket/index.php index 6abeb5f8b12..83acf828893 100644 --- a/htdocs/public/ticket/index.php +++ b/htdocs/public/ticket/index.php @@ -40,7 +40,6 @@ if (!defined('NOBROWSERNOTIF')) { // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php -// TODO This should be useless. Because entity must be retrieve from object ref and not from url. $entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) { define("DOLENTITY", $entity); @@ -54,6 +53,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; + + + // Load translation files required by the page $langs->loadLangs(array('companies', 'other', 'ticket', 'errors')); @@ -77,7 +79,6 @@ if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { print $langs->trans('TicketPublicInterfaceForbidden'); exit; } - $arrayofjs = array(); $arrayofcss = array('/ticket/css/styles.css.php'); @@ -86,9 +87,9 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); print ''; diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 4fbfd29106a..ef16b716db2 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -40,6 +40,13 @@ if (!defined('NOBROWSERNOTIF')) { } // If this page is public (can be called outside logged session) +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) { + define("DOLENTITY", $entity); +} + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; @@ -154,10 +161,6 @@ if ($action == "view_ticketlist") { } } -//$object->doActions($action); - - - /* * View */ @@ -215,6 +218,9 @@ if ($action == "view_ticketlist") { $filter = array(); $param = 'action=view_ticketlist'; + if (!empty($entity) && !empty($conf->multicompany->enabled)) { + $param .= '&entity='.$entity; + } // Definition of fields for list $arrayfields = array( @@ -392,7 +398,7 @@ if ($action == "view_ticketlist") { print_barre_liste($langs->trans('TicketList'), $page, 'public/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); // Search bar - print '
    '."\n"; + print ''."\n"; print ''; print ''; print ''; @@ -674,7 +680,7 @@ if ($action == "view_ticketlist") { print ''; print '
    '; - print '