From e64c27e1c308f1157f24442020aad31f22a2f111 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 8 Jun 2021 10:27:33 +0200 Subject: [PATCH 001/103] FIX : need to add payment sum to getlibstatus function in object linked block --- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index a02a0fc1682..1e18eb6bfeb 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -85,7 +85,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) } } print ''; - print ''.$objectlink->getLibStatut(3).''; + print ''.$objectlink->getLibStatut(3, $objectlink->getSommePaiement()).''; print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; print "\n"; } From 33553f33476efd363b93cf6c5257943b560b59a0 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 14 Jun 2021 17:01:59 +0200 Subject: [PATCH 002/103] FIX : same thing on supplier orders --- htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index 1b85082616a..1e5ed8c724c 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -65,7 +65,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) echo ''.price($objectlink->total_ht).''; } } ?> - getLibStatut(3); ?> + getLibStatut(3, $objectlink->getSommePaiement()); ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> Date: Mon, 14 Jun 2021 17:08:16 +0200 Subject: [PATCH 003/103] FIX : method exists --- htdocs/compta/facture/tpl/linkedobjectblock.tpl.php | 5 ++++- htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 1e18eb6bfeb..1b81446c243 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -85,7 +85,10 @@ foreach ($linkedObjectBlock as $key => $objectlink) } } print ''; - print ''.$objectlink->getLibStatut(3, $objectlink->getSommePaiement()).''; + print ''; + if(method_exists($objectlink, 'getSommePaiement')) print $objectlink->getLibStatut(3, $objectlink->getSommePaiement()); + else print $objectlink->getLibStatut(3); + print ''; print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; print "\n"; } diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index 1e5ed8c724c..5bb6e45a8c8 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -65,7 +65,10 @@ foreach ($linkedObjectBlock as $key => $objectlink) echo ''.price($objectlink->total_ht).''; } } ?> - getLibStatut(3, $objectlink->getSommePaiement()); ?> + getLibStatut(3, $objectlink->getSommePaiement()); + else echo $objectlink->getLibStatut(3); + ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> Date: Mon, 14 Jun 2021 15:10:24 +0000 Subject: [PATCH 004/103] Fixing style errors. --- htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index 5bb6e45a8c8..20969cddf22 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -66,9 +66,9 @@ foreach ($linkedObjectBlock as $key => $objectlink) } } ?> getLibStatut(3, $objectlink->getSommePaiement()); + if(method_exists($objectlink, 'getSommePaiement')) echo $objectlink->getLibStatut(3, $objectlink->getSommePaiement()); else echo $objectlink->getLibStatut(3); - ?> + ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> Date: Sun, 20 Jun 2021 18:21:10 +0200 Subject: [PATCH 005/103] fix warning there is already an array called $option --- htdocs/admin/syslog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index dfdc53e0f18..a0454a5c8b2 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -180,8 +180,8 @@ if (!$defaultsyslogfacility) { if (!$defaultsyslogfile) { $defaultsyslogfile = 'dolibarr.log'; } - -if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity) { +$optionmc = ''; +if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY) && $user->entity) { print '
'.$langs->trans("ContactSuperAdminForChange").'
'; $option = 'disabled'; } @@ -199,7 +199,7 @@ print ''; print ''; print ''; print ''; -print ''; +print ''; print "\n"; foreach ($syslogModules as $moduleName) { From cff5edd6047b9173bef737c9a40ccffdfff536ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Jun 2021 18:24:00 +0200 Subject: [PATCH 006/103] Update syslog.php --- htdocs/admin/syslog.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index a0454a5c8b2..7a885c0b74f 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -279,11 +279,11 @@ print ''; print '
'.$langs->trans("Type").''.$langs->trans("Value").'
'; print ''; print ''; -print ''; +print ''; print "\n"; print ''; -print ''; print ''."\n"; print ''; -// Example with a yes / no select +/* No more need for this, you can set that a profile is public when saving it. print ''; print ''; print ''; print ''; +*/ print ''; print ''; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index d352b996ef2..991e3cb37cc 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -110,7 +110,7 @@ class FormOther * @param string $htmlname Nom de la zone select * @param string $type Type des modeles recherches * @param int $useempty Show an empty value in list - * @param int $fk_user User that has created the template (this is set to null to get all export model when EXPORTS_SHARE_MODELS is on) + * @param int $fk_user User we want templates * @return void */ public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) @@ -121,8 +121,8 @@ class FormOther $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; $sql .= " WHERE type = '".$this->db->escape($type)."'"; - if (!empty($fk_user)) { - $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $fk_user).")"; } $sql .= " ORDER BY label"; $result = $this->db->query($sql); @@ -132,6 +132,8 @@ class FormOther print ''; } + $tmpuser = new User($this->db); + $num = $this->db->num_rows($result); $i = 0; while ($i < $num) { @@ -140,8 +142,7 @@ class FormOther $label = $obj->label; if ($obj->fk_user == 0) { $label .= ' ('.$langs->trans("Everybody").')'; - } elseif (!empty($conf->global->EXPORTS_SHARE_MODELS) && empty($fk_user) && is_object($user) && $user->id != $obj->fk_user) { - $tmpuser = new User($this->db); + } elseif ($obj->fk_user > 0) { $tmpuser->fetch($obj->fk_user); $label .= ' ('.$tmpuser->getFullName($langs).')'; } @@ -171,7 +172,7 @@ class FormOther * @param string $htmlname Nom de la zone select * @param string $type Type des modeles recherches * @param int $useempty Affiche valeur vide dans liste - * @param int $fk_user User that has created the template (this is set to null to get all export model when EXPORTS_SHARE_MODELS is on) + * @param int $fk_user User that has created the template * @return void */ public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0, $fk_user = null) @@ -182,10 +183,10 @@ class FormOther $sql = "SELECT rowid, label, fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; $sql .= " WHERE type = '".$this->db->escape($type)."'"; - if (!empty($fk_user)) { - $sql .= " AND fk_user IN (0, ".$fk_user.")"; // An export model + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $fk_user).")"; } - $sql .= " ORDER BY rowid"; + $sql .= " ORDER BY label"; $result = $this->db->query($sql); if ($result) { print ''; print '
'; print ''.$langs->trans("SelectExportFields").' '; - if (empty($conf->global->EXPORTS_SHARE_MODELS)) { - $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id); - } else { - $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1); - } + $htmlother->select_export_model($exportmodelid, 'exportmodelid', $datatoexport, 1, $user->id); print ' '; print ''; print '
'; @@ -1007,20 +1004,28 @@ if ($step == 4 && $datatoexport) { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("SyslogLevel").''; $texte .= ''; $texte .= ''; - if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { + if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) { $texte .= ''; $texte .= ''; $texte .= ''; @@ -166,7 +166,7 @@ class doc_generic_user_odt extends ModelePDFUser if (count($listofdir)) { $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; - if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { + if (!empty($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT)) { // Model for creation $list = ModelePDFUser::liste_modeles($this->db); $texte .= ''; From 9ee95562004e35f4582609dd62fa6179607a9e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Jun 2021 18:37:43 +0200 Subject: [PATCH 008/103] Update user.php --- htdocs/admin/user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 6d8cfe21f00..da3a1913d64 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -268,7 +268,7 @@ foreach ($dirmodels as $reldir) { // Defaut print '\n"; /* - echo '
'; - echo '
'; - echo '
'; - echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); - echo '
'."\n"; - echo "
\n"; - */ + echo '
'; + echo '
'; + echo '
'; + echo show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, -1); + echo '
'."\n"; + echo "
\n"; + */ echo '
'; - if ($conf->global->USER_ADDON_PDF == $name) { + if (getDolGlobalString('USER_ADDON_PDF_ODT') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; From c9c3cef5d768830cad64496c16d2a629fb32d493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Jun 2021 20:15:19 +0200 Subject: [PATCH 009/103] Update syslog.php --- htdocs/admin/syslog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 7a885c0b74f..10b3d1bd47b 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -183,7 +183,7 @@ if (!$defaultsyslogfile) { $optionmc = ''; if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY) && $user->entity) { print '
'.$langs->trans("ContactSuperAdminForChange").'
'; - $option = 'disabled'; + $optionmc = 'disabled'; } From c8326c1365a54f060c7a5358219df6cc3ff6feb5 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 20 Jun 2021 21:55:48 +0200 Subject: [PATCH 010/103] FIX Accoutancy Limit date payment not register on purchases operations --- htdocs/accountancy/journal/purchasesjournal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 42bff74097f..5238ee993e1 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -92,7 +92,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,"; +$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; From 0dc16b135d27d30c546808ddcd7c3df1924a7b34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 00:05:01 +0200 Subject: [PATCH 011/103] FIX allow disabling of a module (not dangerous) even if pb with token. --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 56b6e6e1f01..674cbbf52f5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -28,7 +28,7 @@ * \brief Page to activate/disable all modules */ -if (!defined('CSRFCHECK_WITH_TOKEN')) { +if (!defined('CSRFCHECK_WITH_TOKEN') && (empty($_GET['action']) || $_GET['action'] != 'reset')) { // We do not force security to disable modules so we can do it if problem define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET } From 9fd06537b7961c1594d1d0c60fa55aa7bce95575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 21 Jun 2021 10:42:20 +0200 Subject: [PATCH 012/103] move admin warnings on top instead bottom --- htdocs/index.php | 62 +++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 7eaf517b321..0f457b0f40b 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2015 Marcos García + * Copyright (C) 2021 Frédéric France * * 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 @@ -101,7 +102,36 @@ if (!empty($conf->global->MAIN_MOTD)) { } } +/* + * Show security warnings + */ +// Security warning repertoire install existe (si utilisateur admin) +if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) { + $message = ''; + + // Check if install lock file is present + $lockfile = DOL_DATA_ROOT.'/install.lock'; + if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) { + $langs->load("errors"); + //if (! empty($message)) $message.='
'; + $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); + } + + // Conf files must be in read only mode + if (is_writable($conffile)) { + $langs->load("errors"); + //$langs->load("other"); + //if (! empty($message)) $message.='
'; + $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); + } + + if ($message) { + print $message; + //$message.='
'; + //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); + } +} /* * Dashboard Dolibarr states (statistics) @@ -722,38 +752,6 @@ print $boxlist; print ''; - -/* - * Show security warnings - */ - -// Security warning repertoire install existe (si utilisateur admin) -if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) { - $message = ''; - - // Check if install lock file is present - $lockfile = DOL_DATA_ROOT.'/install.lock'; - if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) { - $langs->load("errors"); - //if (! empty($message)) $message.='
'; - $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); - } - - // Conf files must be in read only mode - if (is_writable($conffile)) { - $langs->load("errors"); - //$langs->load("other"); - //if (! empty($message)) $message.='
'; - $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); - } - - if ($message) { - print $message; - //$message.='
'; - //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install")); - } -} - //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage(); // End of page From 59a7d5b89d1ed250bb91cab2c1fe0a7b4197a604 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 11:13:30 +0200 Subject: [PATCH 013/103] Introduce option MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL --- htdocs/core/lib/functions.lib.php | 35 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 531af8fe73a..20b944b4da2 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5867,36 +5867,41 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, } // Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. - // Not supported + // 'VATRULE 3' - Not supported // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise) alors TVA par defaut=0. Fin de regle // Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle if (($seller_in_cee && $buyer_in_cee)) { $isacompany = $thirdparty_buyer->isACompany(); - if ($isacompany) { - if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if (!isValidVATID($thirdparty_buyer)) { - //print 'VATRULE 6'; - return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); - } + if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if (!isValidVATID($thirdparty_buyer)) { + $isacompany = 0; } - //print 'VATRULE 3'; - return 0; - } else { + } + + if (!$isacompany) { //print 'VATRULE 4'; return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + } else { + //print 'VATRULE 5'; + return 0; } } - // Si (vendeur en France et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle - if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee) && !$thirdparty_buyer->isACompany()) { - return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + // Si (vendeur dans Communaute europeene et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle + // I don't see any use case that need this rule + if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee)) { + $isacompany = $thirdparty_buyer->isACompany(); + if (!$isacompany) { + return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + //print 'VATRULE extra'; + } } // Sinon la TVA proposee par defaut=0. Fin de regle. // Rem: Cela signifie qu'au moins un des 2 est hors Communaute europeenne et que le pays differe - //print 'VATRULE 5'; + //print 'VATRULE 6'; return 0; } From 5bfd82e5284211673f9030953a096354d3e0f97d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 11:23:53 +0200 Subject: [PATCH 014/103] Clean code --- ChangeLog | 1 + htdocs/core/lib/company.lib.php | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fdb321822f..ef4f01d84c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -225,6 +225,7 @@ Following changes may create regressions for some external modules, but were nec * If your database is MySQL or MariaDB, you need at least version 5.1 * Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules * removed deprecated subtituion key __REFCLIENT__ (replaced with __REF_CLIENT__) +* Removed constant MAIN_COUNTRIES_IN_EEC. You can now set if country is in Europe or not from the dictionary of countries. ***** ChangeLog for 13.0.3 compared to 13.0.2 ***** diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index f6d07e32f01..21b6f9a68e4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -715,10 +715,7 @@ function getCountriesInEEC() global $conf, $db; $country_code_in_EEC = array(); - if (!empty($conf->global->MAIN_COUNTRIES_IN_EEC)) { - // For example MAIN_COUNTRIES_IN_EEC = 'AT,BE,BG,CY,CZ,DE,DK,EE,ES,FI,FR,GB,GR,HR,NL,HU,IE,IM,IT,LT,LU,LV,MC,MT,PL,PT,RO,SE,SK,SI,UK' - $country_code_in_EEC = explode(',', $conf->global->MAIN_COUNTRIES_IN_EEC); - } elseif (!empty($conf->cache['country_code_in_EEC'])) { + if (!empty($conf->cache['country_code_in_EEC'])) { // Use of cache to reduce number of database requests $country_code_in_EEC = $conf->cache['country_code_in_EEC']; } else { From bb8d5cec1b88759e06d6642c20d2f0f65b55b3fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 11:36:28 +0200 Subject: [PATCH 015/103] More complete management of MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL --- htdocs/core/lib/functions.lib.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 20b944b4da2..fed3f697cb6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5811,12 +5811,12 @@ function get_product_localtax_for_country($idprod, $local, $thirdparty_seller) /** * Function that return vat rate of a product line (according to seller, buyer and product vat rate) - * Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. - * Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. - * Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier ou entreprise sans num TVA intra) alors TVA par defaut=TVA du produit vendu. Fin de regle - * Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise avec num TVA) intra alors TVA par defaut=0. Fin de regle - * Sinon TVA proposee par defaut=0. Fin de regle. + * VATRULE 1: Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. + * VATRULE 2: Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle. + * VATRULE 3: Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. + * VATRULE 4: Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle + * VATRULE 5: Si (vendeur et acheteur dans Communaute europeenne) et (acheteur = entreprise) alors TVA par defaut=0. Fin de regle + * VATRULE 6: Sinon TVA proposee par defaut=0. Fin de regle. * * @param Societe $thirdparty_seller Objet societe vendeuse * @param Societe $thirdparty_buyer Objet societe acheteuse @@ -5845,9 +5845,19 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, // If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm) // we use the buyer VAT. if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) { - if ($seller_in_cee && $buyer_in_cee && !$thirdparty_buyer->isACompany()) { - //print 'VATRULE 0'; - return get_product_vat_for_country($idprod, $thirdparty_buyer, $idprodfournprice); + if ($seller_in_cee && $buyer_in_cee) { + $isacompany = $thirdparty_buyer->isACompany(); + if ($isacompany && !empty($conf->global->MAIN_USE_VAT_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID_ARE_INDIVIDUAL)) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + if (!isValidVATID($thirdparty_buyer)) { + $isacompany = 0; + } + } + + if (!$isacompany) { + //print 'VATRULE 0'; + return get_product_vat_for_country($idprod, $thirdparty_buyer, $idprodfournprice); + } } } @@ -5890,7 +5900,7 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, } // Si (vendeur dans Communaute europeene et acheteur hors Communaute europeenne et acheteur particulier) alors TVA par defaut=TVA du produit vendu. Fin de regle - // I don't see any use case that need this rule + // I don't see any use case that need this rule. if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_INDIVIDUAL_CUSTOMER_OUT_OF_EEC) && empty($buyer_in_cee)) { $isacompany = $thirdparty_buyer->isACompany(); if (!$isacompany) { From ab2e50ef49d9b20d98a3a0dffcd6752940564538 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 12:46:03 +0200 Subject: [PATCH 016/103] Fix css --- htdocs/comm/action/index.php | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 465f1be8701..d619fafe850 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -363,9 +363,9 @@ if ($action == 'show_day') { //print dol_print_date($firstdaytoshow,'dayhour').' '.dol_print_date($lastdaytoshow,'dayhour'); /*$title = $langs->trans("DoneAndToDoActions"); -if ($status == 'done') $title = $langs->trans("DoneActions"); -if ($status == 'todo') $title = $langs->trans("ToDoActions"); -*/ + if ($status == 'done') $title = $langs->trans("DoneActions"); + if ($status == 'todo') $title = $langs->trans("ToDoActions"); + */ $param = ''; if ($actioncode || GETPOSTISSET('search_actioncode')) { @@ -454,13 +454,13 @@ $param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : ''); /*$tabactive = ''; -if ($action == 'show_month') $tabactive = 'cardmonth'; -if ($action == 'show_week') $tabactive = 'cardweek'; -if ($action == 'show_day') $tabactive = 'cardday'; -if ($action == 'show_list') $tabactive = 'cardlist'; -if ($action == 'show_pertuser') $tabactive = 'cardperuser'; -if ($action == 'show_pertype') $tabactive = 'cardpertype'; -*/ + if ($action == 'show_month') $tabactive = 'cardmonth'; + if ($action == 'show_week') $tabactive = 'cardweek'; + if ($action == 'show_day') $tabactive = 'cardday'; + if ($action == 'show_list') $tabactive = 'cardlist'; + if ($action == 'show_pertuser') $tabactive = 'cardperuser'; + if ($action == 'show_pertype') $tabactive = 'cardpertype'; + */ $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param); $paramnoactionodate = preg_replace('/action=[a-z_]+/', '', $paramnodate); @@ -502,14 +502,12 @@ $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="p //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewDay").''; -$viewmode .= ''; +$viewmode .= ''; //$viewmode .= ''; $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"'); //$viewmode .= ''; $viewmode .= ''.$langs->trans("ViewPerUser").''; -$viewmode .= ''; - // Add more views from hooks $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); @@ -519,6 +517,8 @@ if (empty($reshook)) { $viewmode = $hookmanager->resPrint; } +$viewmode .= ''; // To add a space before the navigation tools + $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { @@ -925,13 +925,13 @@ if ($showbirthday) { $eventarray[$daykey][] = $event; /*$loop = true; - $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); - do { - $eventarray[$daykey][] = $event; - $daykey += 60 * 60 * 24; - if ($daykey > $event->date_end_in_calendar) $loop = false; - } while ($loop); - */ + $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee); + do { + $eventarray[$daykey][] = $event; + $daykey += 60 * 60 * 24; + if ($daykey > $event->date_end_in_calendar) $loop = false; + } while ($loop); + */ $i++; } } else { @@ -1543,13 +1543,13 @@ if (empty($action) || $action == 'show_month') { // View by month echo "
'; print ''; @@ -1793,10 +1793,10 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } else { if ($user->rights->agenda->allactions->create || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { - $cssclass .= " movable cursormove"; - } else { - $cssclass .= " unmovable"; - } + $cssclass .= " movable cursormove"; + } else { + $cssclass .= " unmovable"; + } } $h = ''; $nowrapontd = 1; From aca190d97723be3310aef5c26da7909a776eb0ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 12:46:24 +0200 Subject: [PATCH 017/103] Fix css --- htdocs/comm/action/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index d619fafe850..9b76329d8da 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1794,9 +1794,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($user->rights->agenda->allactions->create || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { $cssclass .= " movable cursormove"; - } else { - $cssclass .= " unmovable"; - } + } else { + $cssclass .= " unmovable"; + } } $h = ''; $nowrapontd = 1; From ac8564dc34f3df651970e31873ab1371b809689b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 13:06:40 +0200 Subject: [PATCH 018/103] Fix disable token renewal on .css.php, .js.php and .json.php --- htdocs/main.inc.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 437e024a3ae..2301ca75161 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -413,15 +413,17 @@ if ((!empty($conf->global->MAIN_VERSION_LAST_UPGRADE) && ($conf->global->MAIN_VE } // Creation of a token against CSRF vulnerabilities -if (!defined('NOTOKENRENEWAL')) -{ - // Rolling token at each call ($_SESSION['token'] contains token of previous page) - if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; +if (!defined('NOTOKENRENEWAL')) { + // No token renewal on .css.php, .js.php and .json.php + if (!preg_match('/\.(css|js|json)\.php$/', $_SERVER["PHP_SELF"])) { + // Rolling token at each call ($_SESSION['token'] contains token of previous page) + if (isset($_SESSION['newtoken'])) $_SESSION['token'] = $_SESSION['newtoken']; - // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] - $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number - $_SESSION['newtoken'] = $token; - dol_syslog("NEW TOKEN reclaimed by : " . $_SERVER['PHP_SELF'], LOG_DEBUG); + // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] + $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number + $_SESSION['newtoken'] = $token; + dol_syslog("NEW TOKEN generated by : " . $_SERVER['PHP_SELF'], LOG_DEBUG); + } } //dol_syslog("aaaa - ".defined('NOCSRFCHECK')." - ".$dolibarr_nocsrfcheck." - ".$conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN." - ".$_SERVER['REQUEST_METHOD']." - ".GETPOST('token', 'alpha').' '.$_SESSION['token']); From 5697e86c090b98b051b57cdf6022200a51dd597a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 14:11:59 +0200 Subject: [PATCH 019/103] Fix columns for export/import profile --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 9 ++++++--- htdocs/install/mysql/tables/llx_export_model.sql | 2 +- htdocs/install/mysql/tables/llx_import_model.sql | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index deb40d9c7fd..8caf6e9a401 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -67,9 +67,6 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI'); -ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); - - INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 11, 'US-BASE', 'USA basic chart of accounts', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 14, 'CA-ENG-BASE', 'Canadian basic chart of accounts - English', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 154, 'SAT/24-2019', 'Catalogo y codigo agrupador fiscal del 2019', 1); @@ -84,6 +81,12 @@ DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', ' -- For v14 +ALTER TABLE llx_import_model MODIFY COLUMN type varchar(64); +ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64); + +ALTER TABLE llx_import_model ADD COLUMN entity integer DEFAULT 0 NOT NULL; +ALTER TABLE llx_export_model ADD COLUMN entity integer DEFAULT 0 NOT NULL; + ALTER TABLE llx_product_lot ADD COLUMN eol_date datetime NULL; ALTER TABLE llx_product_lot ADD COLUMN manufacturing_date datetime NULL; ALTER TABLE llx_product_lot ADD COLUMN scrapping_date datetime NULL; diff --git a/htdocs/install/mysql/tables/llx_export_model.sql b/htdocs/install/mysql/tables/llx_export_model.sql index 7e68eab4ad5..cfdb2fdc530 100644 --- a/htdocs/install/mysql/tables/llx_export_model.sql +++ b/htdocs/install/mysql/tables/llx_export_model.sql @@ -22,10 +22,10 @@ create table llx_export_model ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 0, -- by default on all entities for compatibility fk_user integer DEFAULT 0 NOT NULL, label varchar(50) NOT NULL, type varchar(64) NOT NULL, field text NOT NULL, filter text - )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_import_model.sql b/htdocs/install/mysql/tables/llx_import_model.sql index 2a110a2d80a..ceb3ae9f323 100644 --- a/htdocs/install/mysql/tables/llx_import_model.sql +++ b/htdocs/install/mysql/tables/llx_import_model.sql @@ -21,8 +21,9 @@ create table llx_import_model ( rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 0 NOT NULL, -- by default on all entities for compatibility fk_user integer DEFAULT 0 NOT NULL, label varchar(50) NOT NULL, - type varchar(50) NOT NULL, + type varchar(64) NOT NULL, field text NOT NULL )ENGINE=innodb; From 31db1dc412549476fd2713f0be0628f5676c6f30 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 15:03:45 +0200 Subject: [PATCH 020/103] Fix management of visibility of export/import templates. --- htdocs/admin/export.php | 3 +- htdocs/core/class/html.formother.class.php | 24 +++++++------- htdocs/exports/class/export.class.php | 8 ++--- htdocs/exports/export.php | 37 +++++++++++++++------- htdocs/imports/class/import.class.php | 19 +++++++++-- htdocs/imports/import.php | 34 +++++++++++++++++--- 6 files changed, 89 insertions(+), 36 deletions(-) diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index b83b15571b8..9b154e88789 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -86,13 +86,14 @@ print '
 
'.$langs->trans("EXPORTS_SHARE_MODELS").' '; print ajax_constantonoff('EXPORTS_SHARE_MODELS'); print '
'.$langs->trans("ExportCsvSeparator").'
'; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; + print ''; + $tmpuser = new User($db); + // List of existing export profils - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, fk_user, entity"; $sql .= " FROM ".MAIN_DB_PREFIX."export_model"; $sql .= " WHERE type = '".$db->escape($datatoexport)."'"; - if (empty($conf->global->EXPORTS_SHARE_MODELS)) { - $sql .= " AND fk_user=".$user->id; + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $user->id).")"; } $sql .= " ORDER BY rowid"; $resql = $db->query($sql); @@ -1029,9 +1034,19 @@ if ($step == 4 && $datatoexport) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + print ''; + print ''; + print '
'.$langs->trans("ExportModelName").' '.$langs->trans("Visibility").'
'; + print ''; + $arrayvisibility = array('private'=>$langs->trans("Private"), 'all'=>$langs->trans("Everybody")); + print $form->selectarray('visibility', $arrayvisibility, 'private'); + print ''; print ''; print '
'; print $obj->label; - print ''; + print ''; + if (empty($obj->fk_user)) { + print $langs->trans("Everybody"); + } else { + $tmpuser->fetch($obj->fk_user); + print $tmpuser->getNomUrl(1); + } + print ''; print 'rowid.'">'; print img_delete(); print ''; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 567aaf754a8..44ec5935d49 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -55,6 +55,12 @@ class Import */ public $errors = array(); + // To store import templates + public $hexa; // List of fields in the export profile + public $datatoimport; + public $model_name; // Name of export profile + public $fk_user; + /** * Constructor @@ -266,11 +272,18 @@ class Import $this->db->begin(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'import_model ('; - $sql .= 'fk_user, label, type, field'; + $sql .= 'fk_user,'; + $sql .= ' label,'; + $sql .= ' type,'; + $sql .= ' field'; $sql .= ')'; - $sql .= " VALUES (".($user->id > 0 ? $user->id : 0).", '".$this->db->escape($this->model_name)."', '".$this->db->escape($this->datatoimport)."', '".$this->db->escape($this->hexa)."')"; + $sql .= " VALUES ("; + $sql .= (isset($this->fk_user) ? (int) $this->fk_user : 'null').","; + $sql .= " '".$this->db->escape($this->model_name)."',"; + $sql .= " '".$this->db->escape($this->datatoimport)."',"; + $sql .= " '".$this->db->escape($this->hexa)."'"; + $sql .= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $this->db->commit(); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 20a846123f1..4c5975ecb43 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -226,6 +226,7 @@ if ($action == 'add_import_model') { $objimport->model_name = $import_name; $objimport->datatoimport = $datatoimport; $objimport->hexa = $hexa; + $objimport->fk_user = (GETPOST('visibility', 'aZ09') == 'all' ? 0 : $user->id); $result = $objimport->create($user); if ($result >= 0) { @@ -968,7 +969,7 @@ if ($step == 4 && $datatoimport) { $s = str_replace('{s1}', img_picto('', 'grip_title', '', false, 0, 0, '', '', 0), $s); print $s; print ' '; - $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1); + $htmlother->select_import_model($importmodelid, 'importmodelid', $datatoimport, 1, $user->id); print ''; print ''; print ''; @@ -1249,28 +1250,51 @@ if ($step == 4 && $datatoimport) { print ''; print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; + print ''; // List of existing import profils - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, label, fk_user, entity"; $sql .= " FROM ".MAIN_DB_PREFIX."import_model"; $sql .= " WHERE type = '".$db->escape($datatoimport)."'"; + if (empty($conf->global->EXPORTS_SHARE_MODELS)) { // EXPORTS_SHARE_MODELS means all templates are visible, whatever is owner. + $sql .= " AND fk_user IN (0, ".((int) $user->id).")"; + } $sql .= " ORDER BY rowid"; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); + + $tmpuser = new user($db); + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + print ''; + print ''; + print '
'.$langs->trans("ImportModelName").' '.$langs->trans("Visibility").'
'; + print ''; + $arrayvisibility = array('private'=>$langs->trans("Private"), 'all'=>$langs->trans("Everybody")); + print $form->selectarray('visibility', $arrayvisibility, 'private'); + print ''; print ''; print '
'; print $obj->label; - print ''; + print ''; + if (empty($obj->fk_user)) { + print $langs->trans("Everybody"); + } else { + $tmpuser->fetch($obj->fk_user); + print $tmpuser->getNomUrl(1); + } + print ''; print 'rowid.'&filetoimport='.urlencode($filetoimport).'">'; print img_delete(); print ''; From f48b2812a3d263da54e08818168e8f68a1e9d5be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 15:26:14 +0200 Subject: [PATCH 021/103] Doc --- ChangeLog | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef4f01d84c7..98c22d90bf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -64,7 +64,7 @@ NEW: VAT payment request and VAT payment are now 2 different steps in workflow o NEW: VAT report - Optimisation & collapse by rate NEW: When a doc file is shared, link is visible from the main page of doc. NEW: #16378 more E-Mail Contact substitution Values for better salutation -NEW: option to keep the "Automatically create a total payment" checkbox empty on the tax creation page +NEW: option to keep the "Automatically create the payment" checkbox empty on the tax creation page Accountancy NEW: Accountancy - Add FEC import @@ -285,7 +285,6 @@ FIX: test must be === and not == FIX: test on link type FIX: type link extrafield case for advanced target emailing FIX: Write right on document ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git ***** ChangeLog for 13.0.2 compared to 13.0.1 ***** From 05bb2c720d06501eb6e744996201e0b9c5b0bd7e Mon Sep 17 00:00:00 2001 From: damien clochard Date: Mon, 21 Jun 2021 18:24:52 +0200 Subject: [PATCH 022/103] FIX #17996: Avoid implicit type casts for llx_adherent_type.subscription The llx_adherent_type.subscription column is VARCHAR so we need to compare it with a string, not an int. --- htdocs/adherents/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 7a4a7d5bc1f..d669270b565 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -363,13 +363,13 @@ if ($search_type > 0) { $sql .= " AND t.rowid=".((int) $search_type); } if ($search_filter == 'withoutsubscription') { - $sql .= " AND (datefin IS NULL OR t.subscription = 0)"; + $sql .= " AND (datefin IS NULL OR t.subscription = '0')"; } if ($search_filter == 'uptodate') { - $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)"; + $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = '0')"; } if ($search_filter == 'outofdate') { - $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)"; + $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = '1')"; } if ($search_status != '') { // Peut valoir un nombre ou liste de nombre separes par virgules From a0b594fbdc5b490a99107a10903aea89d87c5a3b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jun 2021 19:47:43 +0200 Subject: [PATCH 023/103] Debug emailcollector --- htdocs/admin/emailcollector_card.php | 28 +-- htdocs/core/class/commonobject.class.php | 10 +- htdocs/core/class/translate.class.php | 2 +- .../class/emailcollector.class.php | 5 +- .../template/class/myobject.class.php | 4 + test/phpunit/AllTests.php | 4 + test/phpunit/EmailCollector.php | 235 ++++++++++++++++++ 7 files changed, 269 insertions(+), 19 deletions(-) create mode 100644 test/phpunit/EmailCollector.php diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 724c4ab6dd4..4e2c9e34bf9 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -482,13 +482,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Filters - print '
'; - print ''; - print ''; + print '
'; + print '
'; + print ''; print ''; print ''; // Add filter - print ''; + print ''; print '
'.$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'
'; $arrayoftypes = array( 'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')), @@ -518,7 +518,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1), 'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1) ); - print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 1, '', 2); + print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1, '', 2); print "\n"; print '