From f17474a8de3448e40da8d31c00019bd4bfafb13f Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 11 Jan 2021 16:56:19 +0100 Subject: [PATCH 01/48] 12.0 FIX Translation Permission777 FR --- htdocs/langs/fr_FR/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index c4025fb1577..097f2227790 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -848,6 +848,7 @@ Permission773=Supprimer les notes de frais Permission774=Lire toutes les notes de frais (même pour les utilisateurs en dehors de ma hierarchie) Permission775=Approuver les notes de frais Permission776=Payer les notes de frais +Permission777=Lire les notes de frais de tout le monde Permission779=Exporter les notes de frais Permission1001=Consulter les stocks Permission1002=Créer/modifier entrepôts From 77f213832ec9fbc1ec2925066739355b9e85fe27 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Jan 2021 19:40:44 +0100 Subject: [PATCH 02/48] fix: update group name --- htdocs/user/class/usergroup.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 4d858ffbaf9..2c29db85fc7 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -675,6 +675,10 @@ class UserGroup extends CommonObject { global $user, $conf; + if (empty($this->nom) && !empty($this->name)) { + $this->nom = $this->name; + } + $entity = $conf->entity; if (!empty($conf->multicompany->enabled) && $conf->entity == 1) { From 20fba8f4d24efb84e58cb221143a35056b2a5d8d Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 12 Jan 2021 05:46:24 +0100 Subject: [PATCH 03/48] FIX : Accountancy - FEC Export - Add trans & unaccent on journal label --- .../class/accountancyexport.class.php | 40 ++++++++++--------- .../class/accountingjournal.class.php | 2 +- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 1bcc4129821..28c049609f3 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -820,6 +820,8 @@ class AccountancyExport */ public function exportFEC($objectLines) { + global $langs; + $separator = "\t"; $end_line = "\r\n"; @@ -853,55 +855,55 @@ class AccountancyExport $date_validation = dol_print_date($line->date_validated, '%Y%m%d'); // FEC:JournalCode - print $line->code_journal.$separator; + print $line->code_journal . $separator; // FEC:JournalLib - print $line->journal_label.$separator; + print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator; // FEC:EcritureNum - print $line->piece_num.$separator; + print $line->piece_num . $separator; // FEC:EcritureDate - print $date_document.$separator; + print $date_document . $separator; // FEC:CompteNum - print $line->numero_compte.$separator; + print $line->numero_compte . $separator; // FEC:CompteLib - print dol_string_unaccent($line->label_compte).$separator; + print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum - print $line->subledger_account.$separator; + print $line->subledger_account . $separator; // FEC:CompAuxLib - print dol_string_unaccent($line->subledger_label).$separator; + print dol_string_unaccent($line->subledger_label) . $separator; // FEC:PieceRef - print $line->doc_ref.$separator; + print $line->doc_ref . $separator; // FEC:PieceDate - print dol_string_unaccent($date_creation).$separator; + print dol_string_unaccent($date_creation) . $separator; // FEC:EcritureLib - print dol_string_unaccent($line->label_operation).$separator; + print dol_string_unaccent($line->label_operation) . $separator; // FEC:Debit - print price2fec($line->debit).$separator; + print price2fec($line->debit) . $separator; // FEC:Credit - print price2fec($line->credit).$separator; + print price2fec($line->credit) . $separator; // FEC:EcritureLet - print $line->lettering_code.$separator; + print $line->lettering_code . $separator; // FEC:DateLet - print $date_lettering.$separator; + print $date_lettering . $separator; // FEC:ValidDate - print $date_validation.$separator; + print $date_validation . $separator; // FEC:Montantdevise - print $line->multicurrency_amount.$separator; + print $line->multicurrency_amount . $separator; // FEC:Idevise print $line->multicurrency_code; @@ -919,6 +921,8 @@ class AccountancyExport */ public function exportFEC2($objectLines) { + global $langs; + $separator = "\t"; $end_line = "\r\n"; @@ -955,7 +959,7 @@ class AccountancyExport print $line->code_journal . $separator; // FEC:JournalLib - print $line->journal_label . $separator; + print dol_string_unaccent($langs->transnoentities($line->journal_label)) . $separator; // FEC:EcritureNum print $line->piece_num . $separator; diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index a76be081471..6ee8a03d8ff 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -126,7 +126,7 @@ class AccountingJournal extends CommonObject $this->rowid = $obj->rowid; $this->code = $obj->code; - $this->ref = $obj->code; + $this->ref = $obj->code; $this->label = $obj->label; $this->nature = $obj->nature; $this->active = $obj->active; From 5d6ca5c6362e4c95ba1280476a8a790f024a582c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 12 Jan 2021 05:52:47 +0100 Subject: [PATCH 04/48] FIX: Accountancy - Add translation when journal label data is record --- htdocs/accountancy/journal/bankjournal.php | 6 +++--- htdocs/accountancy/journal/expensereportsjournal.php | 6 +++--- htdocs/accountancy/journal/purchasesjournal.php | 8 ++++---- htdocs/accountancy/journal/sellsjournal.php | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index d353041234f..c47255647cb 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -549,7 +549,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->debit = ($mt >= 0 ? $mt : 0); $bookkeeping->credit = ($mt < 0 ? -$mt : 0); $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_creation = $now; @@ -605,7 +605,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->debit = ($mt < 0 ? -$mt : 0); $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_creation = $now; @@ -737,7 +737,7 @@ if (!$error && $action == 'writebookkeeping') { $bookkeeping->debit = ($mt < 0 ? -$mt : 0); $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->date_creation = $now; $bookkeeping->label_compte = ''; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 26e2b4cdf77..70ec097cd27 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -223,7 +223,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -271,7 +271,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -329,7 +329,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 94f878527dd..611dde36af5 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -322,7 +322,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt <= 0) ? -$mt : 0; $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -372,7 +372,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -433,7 +433,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -484,7 +484,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 9f44e02aafa..62d2238a116 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -333,7 +333,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt >= 0) ? $mt : 0; $bookkeeping->credit = ($mt < 0) ? -$mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -383,7 +383,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt < 0) ? -$mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; @@ -443,7 +443,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt < 0) ? -$mt : 0; $bookkeeping->credit = ($mt >= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; - $bookkeeping->journal_label = $journal_label; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); $bookkeeping->fk_user_author = $user->id; $bookkeeping->entity = $conf->entity; From 19ac498f4e96861764afd9120b1b923fa8ccdfa2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 12 Jan 2021 06:03:57 +0100 Subject: [PATCH 05/48] FIX: Accountancy - Piece is a required field for FEC compatibility --- htdocs/accountancy/bookkeeping/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index d0f43cfe3dd..d9da5b02aef 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -224,9 +224,10 @@ if ($action == "confirm_update") { $action = 'create'; $error++; } - if (!GETPOST('next_num_mvt', 'alpha')) + if (!GETPOST('doc_ref', 'alpha')) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); + $action = 'create'; $error++; } @@ -371,7 +372,7 @@ if ($action == 'create') print ''; print ''; - print ''.$langs->trans("Piece").''; + print ''.$langs->trans("Piece").''; print ''; print ''; From 75323859e4c0e1ed90eb96bd4407335ccef15b39 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Jan 2021 13:58:16 +0100 Subject: [PATCH 06/48] Add some hooks to add new buttons (compensation of removal of tabs). --- htdocs/comm/action/index.php | 9 +++++++++ htdocs/comm/action/list.php | 15 +++++++++++---- htdocs/comm/action/pertype.php | 9 +++++++++ htdocs/comm/action/peruser.php | 9 +++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index dc0ada64eb3..016201be0f3 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -454,6 +454,15 @@ $viewmode .= ''; +// Add more views from hooks +$parameters = array(); $object = null; +$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); +if (empty($reshook)) { + $viewmode .= $hookmanager->resPrint; +} elseif ($reshook > 1) { + $viewmode = $hookmanager->resPrint; +} + $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2fe47ab39f1..f5a0a6783da 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -472,11 +472,9 @@ if ($resql) // Calendars from hooks $parameters = array(); $object = null; $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); - if (empty($reshook)) - { + if (empty($reshook)) { $s .= $hookmanager->resPrint; - } elseif ($reshook > 1) - { + } elseif ($reshook > 1) { $s = $hookmanager->resPrint; } @@ -513,6 +511,15 @@ if ($resql) $viewmode .= ''; + // Add more views from hooks + $parameters = array(); $object = null; + $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); + if (empty($reshook)) { + $viewmode .= $hookmanager->resPrint; + } elseif ($reshook > 1) { + $viewmode = $hookmanager->resPrint; + } + $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 29b86b96868..f956b5ae5f7 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -384,6 +384,15 @@ $viewmode .= ''; +// Add more views from hooks +$parameters = array(); $object = null; +$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); +if (empty($reshook)) { + $viewmode .= $hookmanager->resPrint; +} elseif ($reshook > 1) { + $viewmode = $hookmanager->resPrint; +} + $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 55e6725ba8d..2dc62a52e91 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -389,6 +389,15 @@ $viewmode .= ''; +// Add more views from hooks +$parameters = array(); $object = null; +$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action); +if (empty($reshook)) { + $viewmode .= $hookmanager->resPrint; +} elseif ($reshook > 1) { + $viewmode = $hookmanager->resPrint; +} + $newcardbutton = ''; if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) From 2e9f3b803de83010278872ea4554e67e6ea6f46e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Jan 2021 13:59:20 +0100 Subject: [PATCH 07/48] Add some hooks to add new buttons (compensation of removal of tabs). Signed-off-by: Laurent Destailleur --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 89b5a79df4b..d610203b3ad 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -156,6 +156,7 @@ class HookManager $method, array( 'addCalendarChoice', + 'addCalendarView', 'addMoreActionsButtons', 'addMoreMassActions', 'addSearchEntry', From 958b255822b6401132d48843bc872088f5db1bc4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Jan 2021 21:06:02 +0100 Subject: [PATCH 08/48] Fix #15949 by introducing 'alphawithlgt' as GETPOST possible param. --- htdocs/core/lib/functions.lib.php | 10 +++++++++- htdocs/core/tpl/card_presend.tpl.php | 2 +- test/phpunit/SecurityTest.php | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d6b67088e78..c5b58bace4b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -675,7 +675,7 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = case 'nohtml': $out = dol_string_nohtmltag($out, 0); break; - case 'alpha': // No html and no " and no ../ + case 'alpha': // No html and no ../ and " replaced with '' case 'alphanohtml': // Recommended for most scalar parameters and search parameters if (!is_array($out)) { // '"' is dangerous because param in url can close the href= or src= and add javascript functions. @@ -686,6 +686,14 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = $out = dol_string_nohtmltag($out, 0); } break; + case 'alphawithlgt': // No " and no ../ but we keep < > tags + if (!is_array($out)) { + // '"' is dangerous because param in url can close the href= or src= and add javascript functions. + // '../' is dangerous because it allows dir transversals + $out = str_replace(array('"', '"'), "", trim($out)); + $out = str_replace(array('../'), '', $out); + } + break; case 'restricthtml': // Recommended for most html textarea $out = dol_string_onlythesehtmltags($out, 0, 1, 1); break; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 92a767a23ea..5d3381b2719 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -196,7 +196,7 @@ if ($action == 'presend') } $formmail->withto = $liste; - $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto') ? GETPOST('sendto') : '1') : '1'); + $formmail->withtofree = (GETPOSTISSET('sendto') ? (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1') : '1'); $formmail->withtocc = $liste; $formmail->withtoccc = $conf->global->MAIN_EMAIL_USECCC; $formmail->withtopic = $topicmail; diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index d2405e9609d..a1459c22e27 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -287,6 +287,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $_POST["param8"]="Hackerobjnotdefined\''; + $_POST["param11"]=' Name '; $result=GETPOST('id', 'int'); // Must return nothing print __METHOD__." result=".$result."\n"; @@ -334,6 +335,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals($_GET["param5"], $result); + $result=GETPOST("param6", 'alpha'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('\'\'>', $result); + $result=GETPOST("param6", 'nohtml'); print __METHOD__." result=".$result."\n"; $this->assertEquals('">', $result); @@ -356,6 +361,14 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10'); + $result=GETPOST("param11", 'alphanohtml'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("Name", $result, 'Test an email string with alphanohtml'); + + $result=GETPOST("param11", 'alphawithlgt'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt'); + return $result; } From dae1794e3df84858af61c366cf5235f56f94ddc0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Jan 2021 11:08:33 +0100 Subject: [PATCH 09/48] FIX: Accountancy - Export Gestinum_v3 use facnumber for customer invoice --- htdocs/accountancy/class/accountancyexport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 28c049609f3..c57ee343b00 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -1638,15 +1638,15 @@ class AccountancyExport ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { if ($line->doc_type == 'customer_invoice') { // Get new customer invoice ref and company name - $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql = 'SELECT f.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; $sql .= ' WHERE f.rowid = ' . $line->fk_doc; $resql = $this->db->query($sql); if ($resql) { if ($obj = $this->db->fetch_object($resql)) { // Save invoice infos - $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); - $invoice_ref = $obj->facnumber; + $invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); + $invoice_ref = $obj->ref; $company_name = $obj->nom; } } From 8d65dff93d43e991d1dc1276aef345255d6b10a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Jan 2021 11:15:30 +0100 Subject: [PATCH 10/48] Fix missing param --- htdocs/compta/paiement/class/paiement.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 6b7f1612836..89737ca917f 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -578,9 +578,10 @@ class Paiement extends CommonObject * @param string $emetteur_nom Name of transmitter * @param string $emetteur_banque Name of bank * @param int $notrigger No trigger + * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. * @return int <0 if KO, bank_line_id if OK */ - public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0, $accountancycode = '') { global $conf, $langs, $user; @@ -625,7 +626,8 @@ class Paiement extends CommonObject '', $user, $emetteur_nom, - $emetteur_banque + $emetteur_banque, + $accountancycode ); // Mise a jour fk_bank dans llx_paiement From 2ea5b331b4ccf835666bf0b3686b0c13a5a86413 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Jan 2021 12:36:33 +0100 Subject: [PATCH 11/48] README --- htdocs/modulebuilder/template/README.md | 6 +++--- .../template/core/modules/modMyModule.class.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/template/README.md b/htdocs/modulebuilder/template/README.md index c3afa63e1b7..45c5e4b51eb 100644 --- a/htdocs/modulebuilder/template/README.md +++ b/htdocs/modulebuilder/template/README.md @@ -2,17 +2,17 @@ ## Features -Description... +Description of the module... -Other modules are available on [Dolistore.com](https://www.dolistore.com). +Other external modules are available on [Dolistore.com](https://www.dolistore.com). ## Translations -Translations can be define manually by editing files into directories *langs*. +Translations can be completed manually by editing files into directories *langs*. '; print ''; print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not - // use setup of keypress to select thirdparty and this hang browser on large database. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1); } else { print ''; print ''; print ''; @@ -672,18 +676,21 @@ if ($action == 'create') if ($action == "" || $action == 'add') { print '
'; + print ''; print ''; print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, ''); print ''; print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not - // use setup of keypress to select thirdparty and this hang browser on large database. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) - { + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); } else { print ''; print ''; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8a96877a35b..2b61078fd89 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6421,8 +6421,7 @@ class Form $value = $tmpvalue; $disabled = ''; $style = ''; } - if (!empty($disablebademail)) - { + if (!empty($disablebademail)) { if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) || ($disablebademail == 2 && preg_match('/---/', $value))) { @@ -6431,8 +6430,7 @@ class Form } } - if ($key_in_label) - { + if ($key_in_label) { if (empty($nohtmlescape)) $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value)); else $selectOptionValue = $key.' - '.($maxlen ?dol_trunc($value, $maxlen) : $value); } else { diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index d6f7b269da1..d8d365cf433 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -347,7 +347,7 @@ class FormAccounting extends Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of auxilary thirdparty accounts + * Return list of auxilary accounts. Cumulate list from customers, suppliers and users. * * @param string $selectid Preselected pcg_type * @param string $htmlname Name of field in html form @@ -372,7 +372,7 @@ class FormAccounting extends Form if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if (!empty($obj->code_compta)) { - $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')'; + $aux_account[$obj->code_compta] = $obj->code_compta.'
('.$obj->nom.')'; } } } else { @@ -392,7 +392,7 @@ class FormAccounting extends Form if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if ($obj->code_compta_fournisseur != "") { - $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; + $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; } } } else { @@ -412,7 +412,7 @@ class FormAccounting extends Form if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if (!empty($obj->accountancy_code)) { - $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')'; + $aux_account[$obj->accountancy_code] = $obj->accountancy_code.' ('.dolGetFirstLastname($obj->firstname, $obj->lastname).')'; } } } else { From ea60a824eee8992225373b5d7c2c783e531b079e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 11:07:48 +0100 Subject: [PATCH 15/48] Comment --- htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index 23e7d489e09..cf7897bf7a2 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -51,6 +51,6 @@ CREATE TABLE llx_accounting_bookkeeping journal_label varchar(255), -- FEC:JournalLib date_validated datetime, -- FEC:ValidDate | if empty: movement not validated / if not empty: movement validated (No deleting / No modification) date_export datetime DEFAULT NULL, -- - import_key varchar(14), + import_key varchar(14), -- ID of import when data was inserted by a mass import extraparams varchar(255) -- for other parameters with json format ) ENGINE=innodb; From 1cf86931b3328ec36aab517c41b79a36b383ad09 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 12:58:50 +0100 Subject: [PATCH 16/48] Fix graph of opportunity when a status has been removed. --- htdocs/langs/en_US/main.lang | 1 + htdocs/projet/graph_opportunities.inc.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 6d2892cddad..67c78bf2915 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -216,6 +216,7 @@ Value=Value PersonalValue=Personal value NewObject=New %s NewValue=New value +OldValue=Old value %s CurrentValue=Current value Code=Code Type=Type diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 2bb9332c2ae..97977406a48 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -20,9 +20,8 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { $sql = "SELECT p.fk_opp_status as opp_status, cls.code, COUNT(p.rowid) as nb, SUM(p.opp_amount) as opp_amount, SUM(p.opp_amount * p.opp_percent) as ponderated_opp_amount"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet as p, ".MAIN_DB_PREFIX."c_lead_status as cls"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls ON p.fk_opp_status = cls.rowid"; // If lead status has been removed, we must show it in stats as unknown $sql .= " WHERE p.entity IN (".getEntity('project').")"; - $sql .= " AND p.fk_opp_status = cls.rowid"; $sql .= " AND p.fk_statut = 1"; // Opend projects only if ($mine || empty($user->rights->projet->all->lire)) $sql .= " AND p.rowid IN (".$projectsListId.")"; if ($socid) $sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; @@ -66,7 +65,15 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '
'; print ''; print ''."\n"; + $listofstatus = array_keys($listofoppstatus); + // Complete with values found into database and not into the dictionary + foreach($valsamount as $key => $val) { + if (!in_array($key, $listofstatus)) { + $listofstatus[] = $key; + } + } + foreach ($listofstatus as $status) { $labelStatus = ''; @@ -74,6 +81,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $code = dol_getIdFromCode($db, $status, 'c_lead_status', 'rowid', 'code'); if ($code) $labelStatus = $langs->transnoentitiesnoconv("OppStatus".$code); if (empty($labelStatus)) $labelStatus = $listofopplabel[$status]; + if (empty($labelStatus)) $labelStatus = $langs->transnoentitiesnoconv('OldValue', $status); // When id is id of an entry no more in dictionary for example. //$labelStatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; //$labelStatus .= ' - '.price2num($listofoppstatus[$status]).'%'; From 446e3b9a9d0c231f95d81f3799eb1b56782d27b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 13:26:54 +0100 Subject: [PATCH 17/48] css --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index a35ffbad1b5..c5820db60b7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -768,7 +768,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; if (is_array($liste) && count($liste)) { - print $form->selectarray('users', $liste, '', 1); + print $form->selectarray('users', $liste, '', 1, 0, 0, '', 0, 0, 0, '', 'maxwidth500'); print ajax_combobox('users'); } print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - -======= ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { if ($line->doc_type == 'customer_invoice') { From c3046326cb50abe500458c385a693875e0d28a43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 12:42:40 +0100 Subject: [PATCH 25/48] Fix help --- htdocs/admin/system/perf.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 6d9e3574789..e589db3ca26 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -473,7 +473,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $resql = $db->query($sql); if ($resql) { - $limitforoptim = 10000; + $limitforoptim = 100000; $num = $db->num_rows($resql); $obj = $db->fetch_object($resql); $nb = $obj->nb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index bd83272a3e7..db54bd29cc2 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1308,7 +1308,7 @@ YouUseBestDriver=You use driver %s which is the best driver currently available. YouDoNotUseBestDriver=You use driver %s but driver %s is recommended. NbOfObjectIsLowerThanNoPb=You have only %s %s in the database. This does not require any particular optimization. SearchOptim=Search optimization -YouHaveXObjectUseSearchOptim=You have %s %s in the database. You should add the constant %s to 1 in Home-Setup-Other. Limit the search to the beginning of strings which makes it possible for the database to use indexes and you should get an immediate response. +YouHaveXObjectUseSearchOptim=You have %s %s in the database. You can add the constant %s to 1 in Home-Setup-Other. Limit the search to the beginning of strings which makes it possible for the database to use indexes and you should get an immediate response. YouHaveXObjectAndSearchOptimOn=You have %s %s in the database and constant %s is set to 1 in Home-Setup-Other. BrowserIsOK=You are using the %s web browser. This browser is ok for security and performance. BrowserIsKO=You are using the %s web browser. This browser is known to be a bad choice for security, performance and reliability. We recommend using Firefox, Chrome, Opera or Safari. From dc9cd28437d22f756c5805e76c648dbcb21e4ea8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 13:14:21 +0100 Subject: [PATCH 26/48] Look and feel v14 --- htdocs/comm/propal/card.php | 3 +-- htdocs/commande/card.php | 4 ++-- htdocs/core/class/html.form.class.php | 24 ++++++++++++++---------- htdocs/theme/eldy/global.inc.php | 10 ++++++++++ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 23c960d3a4b..c6903495f37 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1581,7 +1581,7 @@ if ($action == 'create') // Date print ''; // Validaty duration @@ -1644,7 +1644,6 @@ if ($action == 'create') // Delivery date (or manufacturing) print ''; print ''; // Date delivery planned print ''; print '\n"; print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f1cb972ee03..1d11f8848ca 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5707,14 +5707,17 @@ class Form $retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript $retstring .= '>'; - // Icone calendrier - if (!$disabled) - { - $retstring .= ''; - } else $retstring .= ''; + $retstringbuttom .= ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"'; + $retstringbuttom .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').''; + } else { + $retstringbuttom = ''; + } + $retstring = $retstringbuttom.$retstring; $retstring .= ''."\n"; $retstring .= ''."\n"; @@ -5744,7 +5747,7 @@ class Form if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) { $retstring .= " - showOn: 'button', + showOn: 'both', buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png', buttonImageOnly: true"; } @@ -5754,7 +5757,7 @@ class Form } // Zone de saisie manuelle de la date - $retstring .= '
'; + $retstring .= '
'; $retstring .= ''.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').''; + $retstringbutton = ''; + $retsring = $retstringbutton.$retstring; } $retstring .= '
'; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 79e327dd818..0a1dfdac2e9 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4372,6 +4372,16 @@ div.ui-tooltip.mytooltip { /* Calendar */ /* ============================================================================== */ +div.divfordateinput img.ui-datepicker-trigger { + float: left; + display: inline-block; + vertical-align: middle; + padding-top: 10px; +} +.hasDatepicker { + padding-bottom: 6px; +} + .ui-datepicker-calendar .ui-state-default, .ui-datepicker-calendar .ui-widget-content .ui-state-default, .ui-datepicker-calendar .ui-widget-header .ui-state-default, .ui-datepicker-calendar .ui-button, html .ui-datepicker-calendar .ui-button.ui-state-disabled:hover, html .ui-button.ui-state-disabled:active From d7a776ad8a0c5b7a8172e359cdb2d26f4512aed5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 13:23:59 +0100 Subject: [PATCH 27/48] Fix url --- 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 7250d673494..9d86e8d7e00 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4144,7 +4144,7 @@ if ($action == 'create') $result = $tmptemplate->fetch($object->fk_fac_rec_source); if ($result > 0) { print ' '; - print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).''); + print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).''); print ''; } } From 3e85aec9a56ede7b2c43e826a29c48c1b96e074d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 13:23:59 +0100 Subject: [PATCH 28/48] Fix url --- 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 1f5e0456937..2607a010f2d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4123,7 +4123,7 @@ if ($action == 'create') $result = $tmptemplate->fetch($object->fk_fac_rec_source); if ($result > 0) { print ' '; - print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).''); + print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).''); print ''; } } From e5126885fbf3ed819998120bcec4af79815487c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 13:27:45 +0100 Subject: [PATCH 29/48] Fix css --- 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 9d86e8d7e00..983840f8156 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4285,7 +4285,7 @@ if ($action == 'create') print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($usercancreate && $action != 'editmulticurrencyrate' && !empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) - print '
'; + print ''; print '
'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'
'; From ee7aacae54428212ee2a31155e327405cd0e68e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 15:19:56 +0100 Subject: [PATCH 18/48] More complete error message --- htdocs/societe/class/societe.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 62815300437..9b224200060 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3750,9 +3750,8 @@ class Societe extends CommonObject if (!empty($tmp[1])) { // If $conf->global->MAIN_INFO_SOCIETE_STATE is "id:code:label" $state_code = $tmp[1]; $state_label = $tmp[2]; - } else // For backward compatibility - { - dol_syslog("Your state setup use an old syntax. Reedit it using setup area.", LOG_ERR); + } else { // For backward compatibility + dol_syslog("Your state setup use an old syntax (entity=".$conf->entity."). Reedit it using setup area.", 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 0d704b07143e1d7f9579854eed75552555fdf66b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 19:09:57 +0100 Subject: [PATCH 19/48] FIX error managent and db transaction balance --- htdocs/commande/class/commande.class.php | 6 ++++-- htdocs/compta/paiement/class/paiement.class.php | 1 + htdocs/core/class/interfaces.class.php | 17 +++++++++++++---- .../fourn/class/fournisseur.commande.class.php | 8 +++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3cc0fa72ae6..908a7d3b175 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2896,19 +2896,21 @@ class Commande extends CommonOrder * Classify the order as invoiced * * @param User $user Object user making the change - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if KO, >0 if OK + * @param int $notrigger 1=Does not execute triggers, 0=execute triggers + * @return int <0 if KO, 0 if already billed, >0 if OK */ public function classifyBilled(User $user, $notrigger = 0) { $error = 0; $this->db->begin(); + if ($this->billed) { return 0; } + $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 89737ca917f..2c897968320 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -401,6 +401,7 @@ class Paiement extends CommonObject if ($result < 0) { $this->error = $invoice->error; + $this->errors = $invoice->errors; $error++; } } diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 19965250727..534d6b5803e 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -179,20 +179,29 @@ class Interfaces $objMod = new $modName($this->db); if ($objMod) { + $dblevelbefore = $this->db->transaction_opened; + $result = 0; - if (method_exists($objMod, 'runTrigger')) // New method to implement - { + if (method_exists($objMod, 'runTrigger')) { // New method to implement //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); $result = $objMod->runTrigger($action, $object, $user, $langs, $conf); - } elseif (method_exists($objMod, 'run_trigger')) // Deprecated method - { + } elseif (method_exists($objMod, 'run_trigger')) { // Deprecated method dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); $result = $objMod->run_trigger($action, $object, $user, $langs, $conf); } else { dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); } + $dblevelafter = $this->db->transaction_opened; + + if ($dblevelbefore != $dblevelafter) { + $errormessage = "Error, the balance begin/close of db transactions has been broken into trigger ".$modName." with action=".$action." before=".$dblevelbefore." after=".$dblevelafter; + $this->errors[] = $errormessage; + dol_syslog($errormessage, LOG_ERR); + $result = -1; + } + if ($result > 0) { // Action OK diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5464116c1ed..ee8fa746107 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -891,11 +891,17 @@ class CommandeFournisseur extends CommonOrder * Class invoiced the supplier order * * @param User $user Object user making the change - * @return int <0 if KO, >0 if KO + * @return int <0 if KO, 0 if already billed, >0 if OK */ public function classifyBilled(User $user) { $error = 0; + + if ($this->billed) + { + return 0; + } + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1'; From bcfe03216ae7b988949b62b6c83e9e1ccee66864 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Jan 2021 19:15:54 +0100 Subject: [PATCH 20/48] FIX error managent and db transaction balance --- htdocs/commande/class/commande.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 908a7d3b175..7ed6d5e7199 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2903,13 +2903,12 @@ class Commande extends CommonOrder { $error = 0; - $this->db->begin(); - if ($this->billed) { return 0; } + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; From d3cbcedce302e2845d0be253c659948e324f288a Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 15 Jan 2021 09:55:42 +0100 Subject: [PATCH 21/48] FIX 12.0 (ticket) - the "openall" filter on the ticket list does not include tickets with status READ --- htdocs/ticket/list.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 90cd1fd1ec9..def67225f6a 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -346,11 +346,12 @@ foreach ($search as $key => $val) $newarrayofstatus[] = $val2; } if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) { - $newarrayofstatus[] = Ticket::STATUS_NOT_READ; - $newarrayofstatus[] = Ticket::STATUS_ASSIGNED; - $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS; - $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO; - $newarrayofstatus[] = Ticket::STATUS_WAITING; + $newarrayofstatus[] = Ticket::STATUS_NOT_READ; + $newarrayofstatus[] = Ticket::STATUS_READ; + $newarrayofstatus[] = Ticket::STATUS_ASSIGNED; + $newarrayofstatus[] = Ticket::STATUS_IN_PROGRESS; + $newarrayofstatus[] = Ticket::STATUS_NEED_MORE_INFO; + $newarrayofstatus[] = Ticket::STATUS_WAITING; } if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) { $newarrayofstatus[] = Ticket::STATUS_CLOSED; From c6c7cbf208b7c0018200183dbc1cd01be6e690d6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 11:21:47 +0100 Subject: [PATCH 22/48] Fix trans --- htdocs/install/check.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/install/check.php b/htdocs/install/check.php index 06e9e5147e9..97ddb315ca9 100644 --- a/htdocs/install/check.php +++ b/htdocs/install/check.php @@ -122,7 +122,7 @@ if (!function_exists("imagecreate")) print 'Error '.$langs->trans("ErrorPHPDoesNotSupportGD")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportGD")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "GD")."
\n"; } @@ -133,7 +133,7 @@ if (!function_exists("curl_init")) print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCurl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportCurl")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "Curl")."
\n"; } // Check if PHP calendar extension is available @@ -141,7 +141,7 @@ if (!function_exists("easter_date")) { print 'Error '.$langs->trans("ErrorPHPDoesNotSupportCalendar")."
\n"; } else { - print 'Ok '.$langs->trans("PHPSupportCalendar")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "Calendar")."
\n"; } @@ -152,7 +152,7 @@ if (!function_exists("utf8_encode")) print 'Error '.$langs->trans("ErrorPHPDoesNotSupportUTF8")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportUTF8")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "UTF8")."
\n"; } @@ -165,7 +165,7 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc print 'Error '.$langs->trans("ErrorPHPDoesNotSupportIntl")."
\n"; // $checksok = 0; // If ko, just warning. So check must still be 1 (otherwise no way to install) } else { - print 'Ok '.$langs->trans("PHPSupportIntl")."
\n"; + print 'Ok '.$langs->trans("PHPSupport", "Intl")."
\n"; } } From 6db640d0d0b4412e261ae31f0d63f05476e319a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 11:41:09 +0100 Subject: [PATCH 23/48] Fix phpcs --- htdocs/projet/graph_opportunities.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 6d0bec6255d..9588951307a 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -68,7 +68,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) $listofstatus = array_keys($listofoppstatus); // Complete with values found into database and not into the dictionary - foreach($valsamount as $key => $val) { + foreach ($valsamount as $key => $val) { if (!in_array($key, $listofstatus)) { $listofstatus[] = $key; } From a16fa645963499d4127f0b91af11c3c4218431c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 11:42:54 +0100 Subject: [PATCH 24/48] Fix merge --- .../accountancy/bookkeeping/listbysubaccount.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 4800fb779c6..04b59fc7816 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -724,21 +724,6 @@ while ($i < min($num, $limit)) { } } -<<<<<<< HEAD - // Piece number - if (!empty($arrayfields['t.piece_num']['checked'])) { - print '
'; - $object->id = $line->id; - $object->piece_num = $line->piece_num; - print $object->getNomUrl(1, '', 0, '', 1); - print '
'.$langs->trans('Date').''; - print img_picto('', 'object_calendarday').' '.$form->selectDate('', '', '', '', '', "addprop", 1, 1); + print $form->selectDate('', '', '', '', '', "addprop", 1, 1); print '
'.$langs->trans("DeliveryDate").''; - print img_picto('', 'object_calendarday').' '; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6dd6fc6911a..ff17626132a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1616,14 +1616,14 @@ if ($action == 'create' && $usercancreate) // Date print '
'.$langs->trans('Date').''; - print img_picto('', 'object_calendarday').' '.$form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date + print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date print '
'.$langs->trans("DateDeliveryPlanned").''; $date_delivery = ($date_delivery ? $date_delivery : $object->date_delivery); - print img_picto('', 'object_calendarday').' '.$form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); + print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); print "
id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'
'; print ''; if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { From 39b6f2fb6a5cb86dafd47cd378bb324a26d5f83e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 13:36:24 +0100 Subject: [PATCH 30/48] Revert. restore old behaviour, the picto before the input field lead to confusion for some users and break presentation with some pages --- htdocs/core/class/html.form.class.php | 2 +- htdocs/theme/eldy/global.inc.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1d11f8848ca..502cb9d920e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5747,7 +5747,7 @@ class Form if (empty($conf->global->MAIN_POPUP_CALENDAR_ON_FOCUS)) { $retstring .= " - showOn: 'both', + showOn: 'button', /* both has problem with autocompletion */ buttonImage: '".DOL_URL_ROOT."/theme/".$conf->theme."/img/object_calendarday.png', buttonImageOnly: true"; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 0a1dfdac2e9..c6e7e726bc7 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4372,7 +4372,7 @@ div.ui-tooltip.mytooltip { /* Calendar */ /* ============================================================================== */ -div.divfordateinput img.ui-datepicker-trigger { +/*div.divfordateinput img.ui-datepicker-trigger { float: left; display: inline-block; vertical-align: middle; @@ -4380,7 +4380,7 @@ div.divfordateinput img.ui-datepicker-trigger { } .hasDatepicker { padding-bottom: 6px; -} +}*/ .ui-datepicker-calendar .ui-state-default, .ui-datepicker-calendar .ui-widget-content .ui-state-default, .ui-datepicker-calendar .ui-widget-header .ui-state-default, .ui-datepicker-calendar .ui-button, From cac7fdd0588c72f4ab2dc21f23bea9662485ac18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 14:02:18 +0100 Subject: [PATCH 31/48] Look and feel v13 --- htdocs/comm/propal/card.php | 7 ++++--- htdocs/commande/card.php | 3 ++- htdocs/compta/facture/card.php | 14 +++++++------- htdocs/fourn/commande/card.php | 5 +++-- htdocs/fourn/facture/card.php | 28 ++++++++++++++-------------- htdocs/supplier_proposal/card.php | 8 ++++---- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 997a5848434..a018438bc48 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1514,7 +1514,7 @@ if ($action == 'create') print ''; } else { print ''; - print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500'); + print img_picto('', 'company').$form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300 maxwidth500'); // reload page to retrieve customer informations if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { @@ -1621,7 +1621,7 @@ if ($action == 'create') $langs->load("projects"); print ''; print ''.$langs->trans("Project").''; - $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print ' id).'">'; print ''; print ''; @@ -1642,7 +1642,8 @@ if ($action == 'create') print ''.$langs->trans("DefaultModel").''; print ''; $liste = ModelePDFPropales::liste_modeles($db); - print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); + $preselected = ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF); + print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ""; // Multicurrency diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b06acda7105..42ad4ac6af6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1718,7 +1718,8 @@ if ($action == 'create' && $usercancreate) print ''; include_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); - print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); + $preselected = $conf->global->COMMANDE_ADDON_PDF; + print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ""; // Multicurrency diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 2607a010f2d..7565ddc1dee 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2935,7 +2935,7 @@ if ($action == 'create') } else { print ''.$langs->trans('Customer').''; print ''; - print $form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print img_picto('', 'company').$form->select_company($soc->id, 'socid', '((s.client = 1 OR s.client = 3) AND s.status=1)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // Option to reload page to retrieve customer informations. if (empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) { @@ -3423,11 +3423,11 @@ if ($action == 'create') if (!empty($conf->banque->enabled)) { if (GETPOSTISSET('fk_account')) { - $fk_account = GETPOST('fk_account'); + $fk_account = GETPOST('fk_account', 'int'); } print ''.$langs->trans('BankAccount').''; - $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + print img_picto('', 'bank_account', 'class="paddingrightonly"').$form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, '', 1); print ''; } @@ -3436,7 +3436,7 @@ if ($action == 'create') { $langs->load('projects'); print ''.$langs->trans('Project').''; - $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'; print ''; } @@ -3483,11 +3483,11 @@ if ($action == 'create') if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf $paramkey = 'FACTURE_ADDON_PDF_'.$object->type; - $curent = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF; + $preselected = !empty($conf->global->$paramkey) ? $conf->global->$paramkey : $conf->global->FACTURE_ADDON_PDF; } else { - $curent = $conf->global->FACTURE_ADDON_PDF; + $preselected = $conf->global->FACTURE_ADDON_PDF; } - print $form->selectarray('model', $liste, $curent); + print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ""; // Multicurrency diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 76ed1334499..ed8a6f75a1d 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1604,7 +1604,7 @@ if ($action == 'create') print $societe->getNomUrl(1); print ''; } else { - print $form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { @@ -1666,6 +1666,7 @@ if ($action == 'create') { $langs->load("bank"); print ''.$langs->trans('BankAccount').''; + print img_picto('', 'bank_account', 'class="paddingrightonly"'); $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print ''; } @@ -1677,7 +1678,7 @@ if ($action == 'create') $langs->load('projects'); print ''.$langs->trans('Project').''; - $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print '   id).'">'; print ''; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 65b8784cb37..ae708da80d5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1787,7 +1787,7 @@ if ($action == 'create') print $societe->getNomUrl(1); print ''; } else { - print $form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print img_picto('', 'company').$form->select_company($societe->id, 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); // reload page to retrieve supplier informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { @@ -2002,7 +2002,7 @@ if ($action == 'create') print '
'; $tmp = ' '; $text = $tmp.$langs->trans("InvoiceAvoir").' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromSupplierThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'."\n"; @@ -2053,17 +2053,7 @@ if ($action == 'create') if (!empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; - $form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1); - print ''; - } - - // Multicurrency - if (!empty($conf->multicurrency->enabled)) - { - print ''; - print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; - print ''; - print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ?GETPOST('multicurrency_code', 'alpha') : $currency_code), 'multicurrency_code'); + print img_picto('', 'bank_account').$form->select_comptes((GETPOSTISSET('fk_account') ?GETPOST('fk_account', 'alpha') : $fk_account), 'fk_account', 0, '', 1, '', 0, '', 1); print ''; } @@ -2074,7 +2064,7 @@ if ($action == 'create') $langs->load('projects'); print ''.$langs->trans('Project').''; - $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print ''; } @@ -2088,6 +2078,16 @@ if ($action == 'create') print ''; } + // Multicurrency + if (!empty($conf->multicurrency->enabled)) + { + print ''; + print ''.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).''; + print ''; + print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ?GETPOST('multicurrency_code', 'alpha') : $currency_code), 'multicurrency_code'); + print ''; + } + // Intracomm report if (!empty($conf->intracommreport->enabled)) { diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a9411e6d283..d7ee97e1b9d 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1151,7 +1151,7 @@ if ($action == 'create') print ''; } else { print ''; - print $form->select_company('', 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); + print img_picto('', 'company').$form->select_company('', 'socid', 's.fournisseur=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300'); print ' '; print ''; } @@ -1217,7 +1217,8 @@ if ($action == 'create') print ''.$langs->trans("DefaultModel").''; print ''; $liste = ModelePDFSupplierProposal::liste_modeles($db); - print $form->selectarray('model', $liste, ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)); + $preselected = ($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_DEFAULT : $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF); + print $form->selectarray('model', $liste, $preselected, 0, 0, 0, '', 0, 0, 0, '', '', 1); print ""; // Project @@ -1231,8 +1232,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("Project").''; - - $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); + print img_picto('', 'project').$formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); print '   id).'">'; print ''; From e8ed6a9f0947e26ccd09fceb77324d00145bf427 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 14:33:26 +0100 Subject: [PATCH 32/48] Trans --- htdocs/langs/en_US/boxes.lang | 4 ++-- htdocs/langs/fr_FR/boxes.lang | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index b8ba5073d03..1f0241ec7d1 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -95,8 +95,8 @@ LastXMonthRolling=The latest %s month rolling ChooseBoxToAdd=Add widget to your dashboard BoxAdded=Widget was added in your dashboard BoxTitleUserBirthdaysOfMonth=Birthdays of this month (users) -BoxLastManualEntries=Last manual entries in accountancy -BoxTitleLastManualEntries=%s latest manual entries +BoxLastManualEntries=Latest record in accountancy entered manually or without source document +BoxTitleLastManualEntries=%s latest record entered manually or without source document NoRecordedManualEntries=No manual entries record in accountancy BoxSuspenseAccount=Count accountancy operation with suspense account BoxTitleSuspenseAccount=Number of unallocated lines diff --git a/htdocs/langs/fr_FR/boxes.lang b/htdocs/langs/fr_FR/boxes.lang index c889696c75e..3f94cdb2202 100644 --- a/htdocs/langs/fr_FR/boxes.lang +++ b/htdocs/langs/fr_FR/boxes.lang @@ -95,8 +95,8 @@ LastXMonthRolling=Les %s derniers mois tournant ChooseBoxToAdd=Ajouter le widget au tableau de bord BoxAdded=Le widget a été ajouté dans votre tableau de bord BoxTitleUserBirthdaysOfMonth=Anniversaires de ce mois (utilisateurs) -BoxLastManualEntries=Dernières entrées manuelles en comptabilité -BoxTitleLastManualEntries=%s dernières entrées manuelles +BoxLastManualEntries=Dernières entrées manuelles ou sans pièce source en comptabilité +BoxTitleLastManualEntries=Les %s dernières entrées manuelles ou sans pièce source NoRecordedManualEntries=Pas d'entrées manuelles en comptabilité BoxSuspenseAccount=Comptage des opérations de comptabilité avec compte d'attente BoxTitleSuspenseAccount=Nombre de lignes non allouées From 82cedd9fd24a2332905f037b7b55b03cf7798849 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 14:36:02 +0100 Subject: [PATCH 33/48] Fix filter --- htdocs/accountancy/bookkeeping/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index c45419daabf..9c4142daf58 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -674,7 +674,7 @@ if (!empty($arrayfields['t.piece_num']['checked'])) // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { - print ''; + print ''; } // Date document if (!empty($arrayfields['t.doc_date']['checked'])) From c778eafc4ac7236b6bc5b0a01ef1fc610e537ce7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 14:54:23 +0100 Subject: [PATCH 34/48] Fix very slow effect. --- htdocs/core/js/lib_foot.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index de19f674659..9f4e69dcadf 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -65,7 +65,7 @@ print "jQuery(document).ready(function () {\n"; if (empty($conf->dol_no_mouse_hover)) { print 'jQuery(".classfortooltip").tooltip({ - show: { collision: "flipfit", effect:"toggle", delay:75, duration:150 }, + show: { collision: "flipfit", effect:"toggle", delay:50, duration: 20 }, hide: { delay: 250, duration: 20 }, tooltipClass: "mytooltip", content: function () { From 2970dc21516460e5b3822dcfd01760cc6a19a90a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 15:14:23 +0100 Subject: [PATCH 35/48] Fix warning --- htdocs/accountancy/customer/list.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index eb2743258d7..a45bccbf4e1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -606,13 +606,16 @@ if ($result) { { print '
'; $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; - $shelp = ''; + $shelp = ''; $ttype = 'help'; if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC"); elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT"); - elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber"); + elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { + $shelp = $langs->trans("SaleEECWithoutVATNumber"); + $ttype = 'warning'; + } elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport"); $s .= (empty($objp->code_sell_p) ? ''.$langs->trans("NotDefined").'' : length_accountg($objp->code_sell_p)); - print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1); } print ''; From 8e1128ef10a98187f8cb93a8471d72a565f0b7fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 15:33:12 +0100 Subject: [PATCH 36/48] FIX Bad balance of begin commit --- htdocs/compta/facture/class/facture-rec.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 29e78f90af8..1a50fadcc9c 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -2072,6 +2072,8 @@ class FactureLigneRec extends CommonInvoiceLine $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); $sql .= " WHERE rowid = ".$this->id; + $this->db->begin(); + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -2091,13 +2093,18 @@ class FactureLigneRec extends CommonInvoiceLine $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); if ($result < 0) { - $this->db->rollback(); - return -2; + $error++; } // End call triggers } - $this->db->commit(); - return 1; + + if ($error) { + $this->db->rollback(); + return -2; + } else { + $this->db->commit(); + return 1; + } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); From 62a5c8b6dab52af7ddf3284fe68853f5689fe7ef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 15:33:12 +0100 Subject: [PATCH 37/48] FIX Bad balance of begin commit --- htdocs/compta/facture/class/facture-rec.class.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 29e78f90af8..1a50fadcc9c 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -2072,6 +2072,8 @@ class FactureLigneRec extends CommonInvoiceLine $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null"); $sql .= " WHERE rowid = ".$this->id; + $this->db->begin(); + dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -2091,13 +2093,18 @@ class FactureLigneRec extends CommonInvoiceLine $result = $this->call_trigger('LINEBILLREC_UPDATE', $user); if ($result < 0) { - $this->db->rollback(); - return -2; + $error++; } // End call triggers } - $this->db->commit(); - return 1; + + if ($error) { + $this->db->rollback(); + return -2; + } else { + $this->db->commit(); + return 1; + } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); From 93507748082c555c8cde8a32ff5ca67415c6c9b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 16:06:22 +0100 Subject: [PATCH 38/48] Add option MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID --- htdocs/core/lib/functions.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 31d51ff290e..892c612428f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5488,6 +5488,10 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $isacompany = $thirdparty_buyer->isACompany(); if ($isacompany) { + if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID) && !isValidVATID($thirdparty_buyer)) { + //print 'VATRULE 6'; + return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + } //print 'VATRULE 3'; return 0; } else { From 0e636031ba38bdd96201d7d0268e3a50fd77feae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 16:06:22 +0100 Subject: [PATCH 39/48] Add option MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID --- htdocs/core/lib/functions.lib.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c5b58bace4b..b1c1cfb59f5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5488,6 +5488,10 @@ function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $isacompany = $thirdparty_buyer->isACompany(); if ($isacompany) { + if (!empty($conf->global->MAIN_USE_VAT_OF_PRODUCT_FOR_COMPANIES_IN_EEC_WITH_INVALID_VAT_ID) && !isValidVATID($thirdparty_buyer)) { + //print 'VATRULE 6'; + return get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice); + } //print 'VATRULE 3'; return 0; } else { From 4b66f6bcd3be81121967e1c8baea1b84e701477b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 17:43:54 +0100 Subject: [PATCH 40/48] Restrict list to customer and supplier only Merge 2 sql request in to 1 --- .../core/class/html.formaccounting.class.php | 29 ++++--------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e6236adffc5..002899c079d 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -441,38 +441,21 @@ class FormAccounting extends Form $aux_account = array(); - // Auxiliary customer account - $sql = "SELECT DISTINCT code_compta, nom "; + // Auxiliary thirdparties account + $sql = "SELECT code_compta, code_compta_fournisseur, nom as name"; $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " WHERE entity IN (".getEntity('societe').")"; - $sql .= " ORDER BY code_compta"; + $sql .= " AND client IN (1,3) OR fournisseur = 1"; dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { if (!empty($obj->code_compta)) { - $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')'; + $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->name.')'; } - } - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR); - return -1; - } - $this->db->free($resql); - - // Auxiliary supplier account - $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; - $sql .= " FROM ".MAIN_DB_PREFIX."societe"; - $sql .= " WHERE entity IN (".getEntity('societe').")"; - $sql .= " ORDER BY code_compta_fournisseur"; - dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - if ($obj->code_compta_fournisseur != "") { - $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; + if (!empty($obj->code_compta_fournisseur)) { + $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->name.')'; } } } else { From 32bd194f8e58fa78fbf124bd277e69976463dc9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 17:47:14 +0100 Subject: [PATCH 41/48] Sort array --- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/core/class/html.formaccounting.class.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 21077dececd..f4212e2702e 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -685,7 +685,7 @@ if ($action == 'create') // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + if (empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); } else { print ''; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 002899c079d..b95f73506b9 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -435,7 +435,7 @@ class FormAccounting extends Form * @param string $morecss More css * @return string String with HTML select */ - public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth200') + public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth250') { // phpcs:enable @@ -463,6 +463,9 @@ class FormAccounting extends Form dol_syslog(get_class($this)."::select_auxaccount ".$this->error, LOG_ERR); return -1; } + + ksort($aux_account); + $this->db->free($resql); // Auxiliary user account From 6d455352a3d9fe32da1a1b7f0d1becf254b27dcb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 17:47:39 +0100 Subject: [PATCH 42/48] Restore change for test --- htdocs/accountancy/bookkeeping/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index f4212e2702e..21077dececd 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -685,7 +685,7 @@ if ($action == 'create') // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. - if (empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { print $formaccounting->select_auxaccount('', 'subledger_account', 1); } else { print ''; From ea266c1f2d5513ff8a51e25fea3e71c3d9526f1d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 17:59:08 +0100 Subject: [PATCH 43/48] Fix missing alias --- htdocs/core/boxes/box_factures_fourn.php | 2 +- htdocs/core/boxes/box_factures_fourn_imp.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index d3c1ccd9017..26f24d41ab3 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -133,7 +133,7 @@ class box_factures_fourn extends ModeleBoxes $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; - //$thirdpartystatic->name_alias = $objp->name_alias; + $thirdpartystatic->name_alias = $objp->name_alias; $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdpartystatic->fournisseur = $objp->fournisseur; diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index b957e5bf0c1..d345f3d33b0 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -130,7 +130,7 @@ class box_factures_fourn_imp extends ModeleBoxes $thirdpartystatic->id = $objp->socid; $thirdpartystatic->name = $objp->name; - //$thirdpartystatic->name_alias = $objp->name_alias; + $thirdpartystatic->name_alias = $objp->name_alias; $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdpartystatic->fournisseur = $objp->fournisseur; From 80ed651c5ef2196277ff2e2031bbf27ace416347 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 19:23:56 +0100 Subject: [PATCH 44/48] Fix GETPOST --- htdocs/core/lib/functions.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b1c1cfb59f5..11dad21f25e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -672,15 +672,15 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) $out = ''; } break; - case 'nohtml': + case 'nohtml': // No html $out = dol_string_nohtmltag($out, 0); break; - case 'alpha': // No html and no ../ and " replaced with '' + case 'alpha': // No html and no ../ and " case 'alphanohtml': // Recommended for most scalar parameters and search parameters if (!is_array($out)) { // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - $out = str_replace(array('"', '"'), "''", trim($out)); + $out = str_replace(array('"', '"'), '', trim($out)); $out = str_replace(array('../'), '', $out); // keep lines feed $out = dol_string_nohtmltag($out, 0); @@ -690,7 +690,7 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = if (!is_array($out)) { // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals - $out = str_replace(array('"', '"'), "", trim($out)); + $out = str_replace(array('"', '"'), '', trim($out)); $out = str_replace(array('../'), '', $out); } break; From d36c406074b93d3fb6fe48aabdd7e15d956cb620 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 19:24:53 +0100 Subject: [PATCH 45/48] Code comment --- 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 11dad21f25e..efdadbe94ec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -686,7 +686,7 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = $out = dol_string_nohtmltag($out, 0); } break; - case 'alphawithlgt': // No " and no ../ but we keep < > tags + case 'alphawithlgt': // No " and no ../ but we keep < > tags. Can be used for email string like "Name " if (!is_array($out)) { // '"' is dangerous because param in url can close the href= or src= and add javascript functions. // '../' is dangerous because it allows dir transversals From 7d37183f2167500d7d0d6ab64aad8ea5233b95fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 15 Jan 2021 19:43:02 +0100 Subject: [PATCH 46/48] FIX Pb with VAT code when VAT code contains a number --- htdocs/fourn/facture/card.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ae708da80d5..00e0e33ea1e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -656,10 +656,10 @@ if (empty($reshook)) if ($ret < 0) $error++; $datefacture = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $datedue = dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear']); + $datedue = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); // Replacement invoice - if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT) + if (GETPOST('type') == FactureFournisseur::TYPE_REPLACEMENT) { if ($datefacture == '') { @@ -709,7 +709,7 @@ if (empty($reshook)) } // Credit note invoice - if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE) + if (GETPOST('type') == FactureFournisseur::TYPE_CREDIT_NOTE) { $sourceinvoice = GETPOST('fac_avoir', 'int'); if (!($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) @@ -828,7 +828,7 @@ if (empty($reshook)) } // Standard or deposit - if ($_POST['type'] == FactureFournisseur::TYPE_STANDARD || $_POST['type'] == FactureFournisseur::TYPE_DEPOSIT) + if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT) { if (GETPOST('socid', 'int') < 1) { @@ -857,10 +857,10 @@ if (empty($reshook)) $tmpproject = GETPOST('projectid', 'int'); // Creation facture - $object->ref = $_POST['ref']; - $object->ref_supplier = $_POST['ref_supplier']; - $object->socid = $_POST['socid']; - $object->libelle = $_POST['label']; + $object->ref = GETPOST('ref', 'nohtml'); + $object->ref_supplier = GETPOST('ref_supplier', 'nohtml'); + $object->socid = GETPOST('socid', 'int'); + $object->libelle = GETPOST('label', 'nohtml'); $object->date = $datefacture; $object->date_echeance = $datedue; $object->note_public = GETPOST('note_public', 'restricthtml'); @@ -881,7 +881,7 @@ if (empty($reshook)) $object->fetch_thirdparty(); // If creation from another object of another module - if (!$error && $_POST['origin'] && $_POST['originid']) + if (!$error && GETPOST('origin', 'alpha') && GETPOST('originid')) { // Parse element/subelement (ex: project_task) $element = $subelement = GETPOST('origin', 'alpha'); @@ -1367,7 +1367,9 @@ if (empty($reshook)) $fk_unit = GETPOST('units', 'alpha'); - $tva_tx = price2num($tva_tx); // When vat is text input field + if (!preg_match('/\((.*)\)/', $tva_tx)) { + $tva_tx = price2num($tva_tx); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' + } // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); From 820ab1a110471126a8ea33718fe409f03d7e5b9a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Jan 2021 13:03:34 +0100 Subject: [PATCH 47/48] Better error message --- htdocs/main.inc.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5c3fd8ee46b..85f5d775929 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -412,7 +412,7 @@ if (!defined('NOTOKENRENEWAL')) //$dolibarr_nocsrfcheck=1; // Check token if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) - || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set + || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set into page { // Check all cases that need a token (all POST actions, all actions and mass actions on pages with CSRFCHECK_WITH_TOKEN set, all sensitive GET actions) if ($_SERVER['REQUEST_METHOD'] == 'POST' || @@ -428,8 +428,12 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && !empty($conf->gl die; } else { dol_syslog("--- Access to ".$_SERVER["PHP_SELF"]." refused by CSRFCHECK_WITH_TOKEN protection. Token not provided."); - print "Access to this page this way (POST method or page with CSRFCHECK_WITH_TOKEN on or having a sensible value for action parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n"; - print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0 into setup).\n"; + if (defined('CSRFCHECK_WITH_TOKEN')) { + print "Access to a page that needs a token (constant CSRFCHECK_WITH_TOKEN is defined) is refused by CSRF protection in main.inc.php. Token not provided.\n"; + } else { + print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n"; + print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0 into setup).\n"; + } die; } } From b3d7783a297207ff8b0b517702f1f757bc1cfb11 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Jan 2021 13:41:27 +0100 Subject: [PATCH 48/48] Fix multicompany compatibility of preview of file in email form --- htdocs/core/class/html.formmail.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 1edcabf36a5..24e36cfecc2 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -859,9 +859,16 @@ class FormMail extends Form { foreach ($listofpaths as $key => $val) { + $relativepathtofile = substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))); + if ($conf->entity > 1) { + $relativepathtofile = str_replace($conf->entity.'/', '', $relativepathtofile); + } + // Try to extract data from full path + $formfile_params = array(); + preg_match('#^(/)(\w+)(/)(.+)$#', $relativepathtofile, $formfile_params); + $out .= '
'; // Preview of attachment - preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))), $formfile_params); $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); if (!$this->withfilereadonly)