From b7c0594ab73a51a872806c33b7848fa2a87ecdcf Mon Sep 17 00:00:00 2001 From: Florian Date: Thu, 21 Oct 2021 23:28:58 +0200 Subject: [PATCH 01/55] FIX ISSUE DB_ERROR_SYNTAX-#18921 --- htdocs/ticket/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 6991516ede8..0d0e97336cd 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -391,7 +391,7 @@ foreach ($search as $key => $val) { continue; } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '') { + if ($search[$key] != '' && !empty($val)) { $sql .= natural_search($key, $search[$key], $mode_search); } } @@ -609,9 +609,9 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if (is_array($val) && count($val)) { + foreach ($val as $skey) { + $param .= (!empty($val)) ? '&search_'.$key.'[]='.urlencode($skey) : ""; } } else { $param .= '&search_'.$key.'='.urlencode($search[$key]); From 763cb29c0c3a845d48ec8fa3b794d5b3926f6ac6 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 24 Oct 2021 00:26:28 +0200 Subject: [PATCH 02/55] Check that the value is not an array --- htdocs/ticket/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 0d0e97336cd..4caffd173c3 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -391,7 +391,7 @@ foreach ($search as $key => $val) { continue; } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if ($search[$key] != '' && !empty($val)) { + if ($search[$key] != '' && !is_array($val)) { $sql .= natural_search($key, $search[$key], $mode_search); } } From ec1f78424742205349ca757190a67eb7ac03bc3a Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 26 Jan 2022 11:43:44 +0100 Subject: [PATCH 03/55] replace restricthtml to nohtml. --- htdocs/exports/export.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index c0a48b97222..544a9ead888 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -391,14 +391,14 @@ if ($step == 4 && $action == 'submitFormField') { $newcode = (string) preg_replace('/\./', '_', $code); //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'restricthtml') == '') { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'nohtml') == '') { $filterqualified = 0; - } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'restricthtml')) && GETPOST($newcode, 'restricthtml') <= 0)) { + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'nohtml')) && GETPOST($newcode, 'nohtml') <= 0)) { $filterqualified = 0; } if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; - $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'restricthtml'); + $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'nohtml'); } } $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : ''); From 23e5ff08ebcee4a9d0997d644cec5f5d481ebe11 Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 26 Jan 2022 12:07:06 +0100 Subject: [PATCH 04/55] change to alphawithlgt --- htdocs/exports/export.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 544a9ead888..3373a299586 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -391,14 +391,14 @@ if ($step == 4 && $action == 'submitFormField') { $newcode = (string) preg_replace('/\./', '_', $code); //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'nohtml') == '') { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'alphawithlgt') == '') { $filterqualified = 0; - } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'nohtml')) && GETPOST($newcode, 'nohtml') <= 0)) { + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'alphawithlgt')) && GETPOST($newcode, 'alphawithlgt') <= 0)) { $filterqualified = 0; } if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; - $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'nohtml'); + $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'alphawithlgt'); } } $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : ''); From 42f252b636fec9f16cf133c470c30408e6944aa5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jan 2022 12:39:41 +0100 Subject: [PATCH 05/55] Add one more test --- test/phpunit/SecurityTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 6bece069cc9..2d14a35dce9 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -359,7 +359,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $_POST['param8b']='objnotdefined\''; @@ -501,6 +501,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase print __METHOD__." result param7 = ".$result."\n"; $this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result); + $result=GETPOST("param8e", 'restricthtml'); + print __METHOD__." result param8e = ".$result."\n"; + $this->assertEquals('', $result); + $result=GETPOST("param12", 'restricthtml'); print __METHOD__." result=".$result."\n"; $this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml'); @@ -519,7 +523,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase $result=GETPOST("param15", 'restricthtml'); // src=>0xbeefed print __METHOD__." result=".$result."\n"; - $this->assertEquals("0xbeefed", $result, 'Test 15a'); // The GETPOST return a harmull string + $this->assertEquals("0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string // Test with restricthtml + MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES to test disabling of bad atrributes $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; From 60fff852abbad96965bb66c3a2b87af9427efd9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jan 2022 12:53:06 +0100 Subject: [PATCH 06/55] Merge branch '14.0' of git@github.com:Dolibarr/dolibarr.git into 14.0 --- htdocs/core/modules/modUser.class.php | 2 +- htdocs/exports/export.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index f7b6b9aec69..c4043779c64 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -239,7 +239,7 @@ class modUser extends DolibarrModules 'u.accountancy_code'=>'Text', 'u.address'=>"Text", 'u.zip'=>"Text", 'u.town'=>"Text", 'u.office_phone'=>'Text', 'u.user_mobile'=>'Text', 'u.office_fax'=>'Text', - 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.datelastlogin'=>'Date', + 'u.email'=>'Text', 'u.datec'=>"Date", 'u.tms'=>"Date", 'u.admin'=>"Boolean", 'u.statut'=>'Status', 'u.note'=>"Text", 'u.signature'=>"Text", 'u.datelastlogin'=>'Date', 'u.fk_user'=>"List:user:login", 'u.birth'=>'Date', 'u.datepreviouslogin'=>'Date', 'u.fk_soc'=>"List:societe:nom:rowid", 'u.fk_member'=>"List:adherent:firstname", diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 3373a299586..df03b6a1cdc 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -389,16 +389,17 @@ if ($step == 4 && $action == 'submitFormField') { $_SESSION["export_filtered_fields"] = array(); foreach ($objexport->array_export_TypeFields[0] as $code => $type) { // $code: s.fieldname $value: Text|Boolean|List:ccc $newcode = (string) preg_replace('/\./', '_', $code); - //print 'xxx'.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; + //print 'xxx '.$code."=".$newcode."=".$type."=".$_POST[$newcode]."\n
"; + $check = 'alphanohtml'; $filterqualified = 1; - if (!GETPOSTISSET($newcode) || GETPOST($newcode, 'alphawithlgt') == '') { + if (!GETPOSTISSET($newcode) || GETPOST($newcode, $check) == '') { $filterqualified = 0; - } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, 'alphawithlgt')) && GETPOST($newcode, 'alphawithlgt') <= 0)) { + } elseif (preg_match('/^List/', $type) && (is_numeric(GETPOST($newcode, $check)) && GETPOST($newcode, $check) <= 0)) { $filterqualified = 0; } if ($filterqualified) { //print 'Filter on '.$newcode.' type='.$type.' value='.$_POST[$newcode]."\n"; - $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, 'alphawithlgt'); + $objexport->array_export_FilterValue[0][$code] = GETPOST($newcode, $check); } } $array_filtervalue = (!empty($objexport->array_export_FilterValue[0]) ? $objexport->array_export_FilterValue[0] : ''); From 2e525a719d11eb77d0aa81f2720a6f8c8c9596dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Jan 2022 19:12:02 +0100 Subject: [PATCH 07/55] Fix selection of migration script --- htdocs/install/upgrade.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index 70257bba79e..1bc372c4c00 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -307,8 +307,8 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ $filelist = array(); $i = 0; $ok = 0; - $from = '^'.$newversionfrom; - $to = $newversionto.'\.sql$'; + $from = '^'.preg_quote($newversionfrom, '/'); + $to = preg_quote($newversionto.'.sql', '/').'$'; // Get files list $filesindir = array(); @@ -326,9 +326,9 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ // Define which file to run foreach ($filesindir as $file) { - if (preg_match('/'.$from.'/i', $file)) { + if (preg_match('/'.$from.'\-/i', $file)) { $filelist[] = $file; - } elseif (preg_match('/'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.* + } elseif (preg_match('/\-'.$to.'/i', $file)) { // First test may be false if we migrate from x.y.* to x.y.* $filelist[] = $file; } } From 5f0999665f232ed6647931856b76939ce1516929 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 27 Jan 2022 02:27:36 +0100 Subject: [PATCH 08/55] FIX Invoice - Clone - Don't report contact on an another thirdparty --- htdocs/compta/facture/class/facture.class.php | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f8f246924e3..4feeb3d60b6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1,22 +1,23 @@ - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2014 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010-2020 Juanjo Menent - * Copyright (C) 2012-2014 Christophe Battarel - * Copyright (C) 2012-2015 Marcos García - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2012-2014 Raphaël Doursenaud - * Copyright (C) 2013 Cedric Gross - * Copyright (C) 2013 Florian Henry - * Copyright (C) 2016 Ferran Marcet - * Copyright (C) 2018 Alexandre Spangaro - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (C) 2002-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2014 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2010-2020 Juanjo Menent + * Copyright (C) 2012-2014 Christophe Battarel + * Copyright (C) 2012-2015 Marcos García + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2013 Cedric Gross + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2018 Alexandre Spangaro + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2022 Sylvain Legrand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1159,6 +1160,9 @@ class Facture extends CommonInvoice $object->fetch($fromid); + // Load source object + $objFrom = clone $object; + // Change socid if needed if (!empty($this->socid) && $this->socid != $object->socid) { $objsoc = new Societe($this->db); @@ -1239,13 +1243,13 @@ class Facture extends CommonInvoice $this->errors = $object->errors; } else { // copy internal contacts - if ($object->copy_linked_contact($this, 'internal') < 0) { + if ($object->copy_linked_contact($objFrom, 'internal') < 0) { $error++; $this->error = $object->error; $this->errors = $object->errors; - } elseif ($this->socid == $object->socid) { + } elseif ($object->socid == $objFrom->socid) { // copy external contacts if same company - if ($object->copy_linked_contact($this, 'external') < 0) { + if ($object->copy_linked_contact($objFrom, 'external') < 0) { $error++; $this->error = $object->error; $this->errors = $object->errors; @@ -1256,7 +1260,7 @@ class Facture extends CommonInvoice if (!$error) { // Hook of thirdparty module if (is_object($hookmanager)) { - $parameters = array('objFrom'=>$this); + $parameters = array('objFrom'=>$objFrom); $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { From 4b5792899e4ab614ad06e44ddaafb392c6629e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 15:51:18 +0100 Subject: [PATCH 09/55] FIX Presentation of qty already order duplicated on reception card --- htdocs/fourn/commande/dispatch.php | 5 +- htdocs/reception/card.php | 175 +++++++++++++++++------------ 2 files changed, 106 insertions(+), 74 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 0df79fce096..9a8ab1fa7ef 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -612,10 +612,11 @@ if ($id > 0 || !empty($ref)) { // if ($mesg) print $mesg; print '
'; - $disabled = 1; + /*$disabled = 1; if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $disabled = 0; - } + }*/ + $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0. // Line of orders if ($object->statut <= CommandeFournisseur::STATUS_ACCEPTED || $object->statut >= CommandeFournisseur::STATUS_CANCELED) { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index e0f84f24df4..e5f5fccffad 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1031,9 +1031,17 @@ if ($action == 'create') { print "\n"; } + // $objectsrc->lines contains the line of the purchase order + // $dispatchLines is list of lines with dispatching detail (with product, qty and warehouse). One purchase order line may have n of this dispatch lines. + + $arrayofpurchaselinealreadyoutput= array(); + + // $_POST contains fk_commandefourndet_X_Y where Y is num of product line and X is number of splitted line $indiceAsked = 1; - while ($indiceAsked <= $numAsked) { + while ($indiceAsked <= $numAsked) { // Loop on $dispatchLines. Warning: $dispatchLines must be sorted by fk_commandefourndet (it is a regroupment key on output) $product = new Product($db); + + // We search the purchase order line that is linked to the dispatchLines foreach ($objectsrc->lines as $supplierLine) { if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) { $line = $supplierLine; @@ -1055,7 +1063,6 @@ if ($action == 'create') { print ''."\n"; print ''."\n"; - // Product label if ($line->fk_product > 0) { // If predefined product $product->fetch($line->fk_product); @@ -1064,42 +1071,45 @@ if ($action == 'create') { print ''; print ''; // ancre pour retourner sur la ligne - print ''; + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + print ''; - // Show product and description - $product_static = $product; + // Show product and description + $product_static = $product; - $text = $product_static->getNomUrl(1); - $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); - $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); + $text = $product_static->getNomUrl(1); + $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); + $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); - // Show range - print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + // Show range + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); - // Add description in form - if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; + // Add description in form + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + print ($line->desc && $line->desc != $line->product_label) ? '
'.dol_htmlentitiesbr($line->desc) : ''; + } } - print ''; } else { print ""; - if ($type == 1) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + if ($type == 1) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } - if (!empty($line->label)) { - $text .= ' '.$line->label.''; - print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); - } else { - print $text.' '.nl2br($line->desc); - } + if (!empty($line->label)) { + $text .= ' '.$line->label.''; + print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); + } else { + print $text.' '.nl2br($line->desc); + } - // Show range - print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + // Show range + print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); + } print "\n"; } @@ -1110,8 +1120,11 @@ if ($action == 'create') { print ''; print ''; - // Qty - print ''.$line->qty; + // Qty in source purchase order line + print ''; + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + print $line->qty; + } print ''; print ''; print ''; @@ -1121,7 +1134,9 @@ if ($action == 'create') { // Qty already received print ''; $quantityDelivered = $objectsrc->receptions[$line->id]; - print $quantityDelivered; + if (! array_key_exists($line->id, $arrayofpurchaselinealreadyoutput)) { // Add test to avoid to show qty twice + print $quantityDelivered; + } print ''; print ''; @@ -1190,6 +1205,9 @@ if ($action == 'create') { } } } + + $arrayofpurchaselinealreadyoutput[$line->id] = $line->id; + print "\n"; $extralabelslines = $extrafields->attributes[$line->table_element]; @@ -1756,7 +1774,9 @@ if ($action == 'create') { //var_dump($alreadysent); } - // Loop on each product to send/sent + $arrayofpurchaselinealreadyoutput = array(); + + // Loop on each product to send/sent. Warning: $lines must be sorted by ->fk_commandefourndet (it is a regroupment key on output) for ($i = 0; $i < $num_prod; $i++) { print ''; // id of order line print ''; @@ -1778,32 +1798,35 @@ if ($action == 'create') { } print ''; - - $text = $lines[$i]->product->getNomUrl(1); - $text .= ' - '.$label; - $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); - if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { - print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + $text = $lines[$i]->product->getNomUrl(1); + $text .= ' - '.$label; + $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { + print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + } } print "\n"; } else { print ""; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + if ($lines[$i]->product_type == Product::TYPE_SERVICE) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); + } - if (!empty($lines[$i]->label)) { - $text .= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } + if (!empty($lines[$i]->label)) { + $text .= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); + } else { + print $text.' '.nl2br($lines[$i]->description); + } - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + } print "\n"; } @@ -1815,33 +1838,39 @@ if ($action == 'create') { // Qty ordered - print ''.$lines[$i]->qty_asked.''; + print ''; + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + print $lines[$i]->qty_asked; + } + print ''; // Qty in other receptions (with reception and warehouse used) if ($origin && $origin_id > 0) { print ''; - foreach ($alreadysent as $key => $val) { - if ($lines[$i]->fk_commandefourndet == $key) { - $j = 0; - foreach ($val as $receptionline_id => $receptionline_var) { - if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) { - continue; // We want to show only "other receptions" - } + if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { + foreach ($alreadysent as $key => $val) { + if ($lines[$i]->fk_commandefourndet == $key) { + $j = 0; + foreach ($val as $receptionline_id => $receptionline_var) { + if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) { + continue; // We want to show only "other receptions" + } - $j++; - if ($j > 1) { - print '
'; - } - $reception_static->fetch($receptionline_var['reception_id']); - print $reception_static->getNomUrl(1); - print ' - '.$receptionline_var['qty']; + $j++; + if ($j > 1) { + print '
'; + } + $reception_static->fetch($receptionline_var['reception_id']); + print $reception_static->getNomUrl(1); + print ' - '.$receptionline_var['qty']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); - if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) { - $warehousestatic->fetch($receptionline_var['warehouse']); - $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); + if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) { + $warehousestatic->fetch($receptionline_var['warehouse']); + $htmltext .= '
'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); } - print ' '.$form->textwithpicto('', $htmltext, 1); } } } @@ -1971,6 +2000,8 @@ if ($action == 'create') { } print ""; + $arrayofpurchaselinealreadyoutput[$lines[$i]->fk_commandefourndet] = $lines[$i]->fk_commandefourndet; + // Display lines extrafields $extralabelslines = $extrafields->attributes[$lines[$i]->table_element]; if (is_array($extralabelslines) && count($extralabelslines) > 0) { From 0d534f0c37063feb8ec45a60bfff9f695ee6535a Mon Sep 17 00:00:00 2001 From: ksar <35605507+ksar-ksar@users.noreply.github.com> Date: Wed, 2 Feb 2022 10:56:32 +0100 Subject: [PATCH 10/55] FIX #19974 : llx_onlinesignature.sql allready exist FIX #19974 : llx_onlinesignature.sql allready exist --- .../mysql/tables/llx_online_signatures.sql | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 htdocs/install/mysql/tables/llx_online_signatures.sql diff --git a/htdocs/install/mysql/tables/llx_online_signatures.sql b/htdocs/install/mysql/tables/llx_online_signatures.sql deleted file mode 100644 index fbba814dd4d..00000000000 --- a/htdocs/install/mysql/tables/llx_online_signatures.sql +++ /dev/null @@ -1,29 +0,0 @@ --- ============================================================================ --- Copyright (C) 2017 Laurent Destailleur --- --- This program is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- ============================================================================ - -create table llx_onlinesignature -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, - object_type varchar(32) NOT NULL, - object_id integer NOT NULL, - datec datetime NOT NULL, - tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - name varchar(255) NOT NULL, - ip varchar(128), - pathoffile varchar(255) -)ENGINE=innodb; From 815dd74de05b4394dae7bae9fdec840b85c06e13 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Feb 2022 14:03:09 +0100 Subject: [PATCH 11/55] Fix missing information propagated to trigger --- htdocs/compta/facture/card.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9df6688a4e5..4230a22daaf 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1109,6 +1109,8 @@ if (empty($reshook)) { $facture_source->fetchPreviousNextSituationInvoice(); } } + + $id = $object->create($user); if ($id < 0) { $error++; @@ -1236,6 +1238,7 @@ if (empty($reshook)) { $line->multicurrency_total_tva = -$line->multicurrency_total_tva; $line->multicurrency_total_ttc = -$line->multicurrency_total_ttc; + $line->context['createcreditnotefrominvoice'] = 1; $result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked $object->lines[] = $line; // insert new line in current object From 6035a374b728b3278777bd5ccca41b6c91594e11 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 2 Feb 2022 14:44:38 +0100 Subject: [PATCH 12/55] fix bad array index --- htdocs/fourn/facture/card.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 37ef9c813a2..57d0ae6a1a0 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -527,14 +527,13 @@ if (empty($reshook)) { $i = 0; foreach ($object->lines as $line) { if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null - $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; - $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht; - $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva; - $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc; + $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; + $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; + $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; $i++; } } From 95833135f4b19805206d7a7d5c97f86bcc35601c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Feb 2022 10:44:19 +0100 Subject: [PATCH 13/55] FIX #19974 --- htdocs/install/mysql/data/llx_c_tva.sql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index cae269783e4..1a14967357f 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -192,7 +192,7 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (14 -- MALI (id country=147) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1471, 147, '0','0','VAT rate 0', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1471, 147, '18','0','VAT rate - standard', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1472, 147, '18','0','VAT rate - standard', 1); -- MONACO (id country=27) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 271, 27, '0','0','VAT rate 0 ou non applicable',1); @@ -379,10 +379,6 @@ INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 4 INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 462, 46, '15','0','VAT 15%',1); INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES ( 463, 46, '7.5','0','VAT 7.5%',1); --- SOUTH AFRICA (id country=205) -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2051,205, '0','0','No VAT',1); -INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (2052,205, '14','0','VAT 14%',1); - -- VENEZUELA (id country=232) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2321,232, '0','0','No VAT',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); From 15dca77330e3412e7fb445a20f3aecbf32c84eac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Feb 2022 11:00:16 +0100 Subject: [PATCH 14/55] Fix filter on search_categ --- htdocs/product/reassort.php | 8 ++++---- htdocs/product/reassortlot.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index c327b24e8f0..a711c630414 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -146,11 +146,11 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; } // We'll need this table joined to the select in order to filter by categ -if ($search_categ) { +if ($search_categ > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ } if ($sall) { @@ -267,7 +267,7 @@ if ($resql) { if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ) { + if ($search_categ > 0) { $param .= "&search_categ=".urlencode($search_categ); } if ($toolowstock) { @@ -344,7 +344,7 @@ if ($resql) { if ($toolowstock) { $param .= "&toolowstock=".urlencode($toolowstock); } - if ($search_categ) { + if ($search_categ > 0) { $param .= "&search_categ=".urlencode($search_categ); } diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 65e69b91384..21bca9c4aa8 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -135,11 +135,11 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e on ps.fk_entrepot = e.rowid' $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_batch as pb on pb.fk_product_stock = ps.rowid'; // Detail for each lot on each warehouse $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl on pl.fk_product = p.rowid AND pl.batch = pb.batch'; // Link on unique key // We'll need this table joined to the select in order to filter by categ -if ($search_categ) { +if ($search_categ > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_product as cp"; } $sql .= " WHERE p.entity IN (".getEntity('product').")"; -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ } if ($sall) { @@ -178,7 +178,7 @@ if ($fourn_id > 0) { $sql .= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".((int) $fourn_id); } // Insert categ filter -if ($search_categ) { +if ($search_categ > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_categ); } if ($search_warehouse) { @@ -277,7 +277,7 @@ if ($resql) { if ($search_sale) { $param .= "&search_sale=".urlencode($search_sale); } - if ($search_categ) { + if ($search_categ > 0) { $param .= "&search_categ=".urlencode($search_categ); } /*if ($eatby) $param.="&eatby=".$eatby; From d09303d27c2374f496a289f65a86ad860221adc2 Mon Sep 17 00:00:00 2001 From: El-dge Date: Fri, 4 Feb 2022 12:31:40 +0100 Subject: [PATCH 15/55] Issue on stock virtuel : fix Dolibarr/dolibarr#18634 --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1e60a0f63d3..f69016d1576 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5026,7 +5026,7 @@ class Product extends CommonObject if ($result < 0) dol_print_error($this->db, $this->error); $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->reception->enabled)) { $filterStatus = '4'; if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; From 3f87db08d4addbae2b1e9193e60417a7b6c21698 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Feb 2022 12:55:31 +0100 Subject: [PATCH 16/55] Update product.class.php --- htdocs/product/class/product.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f69016d1576..ce7a5858a6a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5026,16 +5026,18 @@ class Product extends CommonObject if ($result < 0) dol_print_error($this->db, $this->error); $stock_commande_fournisseur = $this->stats_commande_fournisseur['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->reception->enabled)) + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) { + // Case module reception is not used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; $result = $this->load_stats_reception(0, $filterStatus, 1); if ($result < 0) dol_print_error($this->db, $this->error); $stock_reception_fournisseur = $this->stats_reception['qty']; } - if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->reception->enabled)) + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->reception->enabled)) { + // Case module reception is used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) $filterStatus = '0,'.$filterStatus; $result = $this->load_stats_reception(0, $filterStatus, 1); // Use same tables than when module reception is not used. From 63d35ecffdd3662e8685eb395ac0c180eccec32c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Feb 2022 19:05:11 +0100 Subject: [PATCH 17/55] Fix phpcs --- htdocs/product/class/product.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a6ec1b980da..9b36c67643d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5288,11 +5288,12 @@ class Product extends CommonObject $filterStatus = '0,'.$filterStatus; } $result = $this->load_stats_reception(0, $filterStatus, 1); - if ($result < 0) dol_print_error($this->db, $this->error); + if ($result < 0) { + dol_print_error($this->db, $this->error); + } $stock_reception_fournisseur = $this->stats_reception['qty']; } - if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->reception->enabled)) - { + if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && !empty($conf->reception->enabled)) { // Case module reception is used $filterStatus = '4'; if (isset($includedraftpoforvirtual)) { From ea83b9c11cce2d1f3b68cffe4a54768d6f8e2a6f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 6 Feb 2022 13:56:57 +0100 Subject: [PATCH 18/55] FIX Propal - Missing field import_key in import propal line --- .../install/mysql/migration/13.0.0-14.0.0.sql | 2 + htdocs/install/mysql/tables/llx_propaldet.sql | 93 ++++++++++--------- 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index ac032d3541d..d03d6b1f75c 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -649,3 +649,5 @@ ALTER TABLE llx_facture_fourn CHANGE COLUMN fk_mode_transport fk_transport_mode ALTER TABLE llx_c_socialnetworks DROP INDEX idx_c_socialnetworks_code; ALTER TABLE llx_c_socialnetworks ADD UNIQUE INDEX idx_c_socialnetworks_code_entity (code, entity); + +ALTER TABLE llx_propaldet ADD COLUMN import_key varchar(14); diff --git a/htdocs/install/mysql/tables/llx_propaldet.sql b/htdocs/install/mysql/tables/llx_propaldet.sql index 7156d90af2f..6b4699d3188 100644 --- a/htdocs/install/mysql/tables/llx_propaldet.sql +++ b/htdocs/install/mysql/tables/llx_propaldet.sql @@ -1,8 +1,9 @@ -- =================================================================== --- Copyright (C) 2002-2003 Rodolphe Quiedeville --- Copyright (C) 2005-2012 Regis Houssin --- Copyright (C) 2010 Juanjo Menent --- Copyright (C) 2012 Cédric Salvador +-- Copyright (C) 2002-2003 Rodolphe Quiedeville +-- Copyright (C) 2005-2012 Regis Houssin +-- Copyright (C) 2010 Juanjo Menent +-- Copyright (C) 2012 Cédric Salvador +-- Copyright (C) 2022 OpenDSI -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -21,47 +22,49 @@ create table llx_propaldet ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_propal integer NOT NULL, - fk_parent_line integer NULL, - fk_product integer NULL, - label varchar(255) DEFAULT NULL, - description text, - fk_remise_except integer NULL, -- Lien vers table des remises fixes - vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. - tva_tx double(6,3) DEFAULT 0, -- Vat rate - localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate - localtax1_type varchar(10) NULL, -- localtax1 type - localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate - localtax2_type varchar(10) NULL, -- localtax2 type - qty real, -- quantity - remise_percent real DEFAULT 0, -- pourcentage de remise - remise real DEFAULT 0, -- montant de la remise (obsolete) - price real, -- prix final (obsolete) - subprice double(24,8) DEFAULT 0, -- prix unitaire article - total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale - total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale - total_localtax1 double(24,8) DEFAULT 0, -- Total localtax1 - total_localtax2 double(24,8) DEFAULT 0, -- Total localtax2 - total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale - product_type integer DEFAULT 0, -- 0 or 1. Value 9 may be used by some modules (amount of line may not be included into generated discount if value is 9). - date_start datetime DEFAULT NULL, -- date debut si service - date_end datetime DEFAULT NULL, -- date fin si service - info_bits integer DEFAULT 0, -- TVA NPR ou non - - buy_price_ht double(24,8) DEFAULT 0, -- buying price - fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) - - special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) - rang integer DEFAULT 0, -- ordre affichage sur la propal - fk_unit integer DEFAULT NULL, -- lien vers table des unités - - fk_multicurrency integer, - multicurrency_code varchar(255), - multicurrency_subprice double(24,8) DEFAULT 0, - multicurrency_total_ht double(24,8) DEFAULT 0, - multicurrency_total_tva double(24,8) DEFAULT 0, - multicurrency_total_ttc double(24,8) DEFAULT 0 + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_propal integer NOT NULL, + fk_parent_line integer NULL, + fk_product integer NULL, + label varchar(255) DEFAULT NULL, + description text, + fk_remise_except integer NULL, -- Lien vers table des remises fixes + vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. + tva_tx double(6,3) DEFAULT 0, -- Vat rate + localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate + localtax1_type varchar(10) NULL, -- localtax1 type + localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate + localtax2_type varchar(10) NULL, -- localtax2 type + qty real, -- quantity + remise_percent real DEFAULT 0, -- pourcentage de remise + remise real DEFAULT 0, -- montant de la remise (obsolete) + price real, -- prix final (obsolete) + subprice double(24,8) DEFAULT 0, -- prix unitaire article + total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale + total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale + total_localtax1 double(24,8) DEFAULT 0, -- Total localtax1 + total_localtax2 double(24,8) DEFAULT 0, -- Total localtax2 + total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale + product_type integer DEFAULT 0, -- 0 or 1. Value 9 may be used by some modules (amount of line may not be included into generated discount if value is 9). + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service + info_bits integer DEFAULT 0, -- TVA NPR ou non + + buy_price_ht double(24,8) DEFAULT 0, -- buying price + fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) + + special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) + rang integer DEFAULT 0, -- ordre affichage sur la propal + fk_unit integer DEFAULT NULL, -- lien vers table des unités + + fk_multicurrency integer, + multicurrency_code varchar(255), + multicurrency_subprice double(24,8) DEFAULT 0, + multicurrency_total_ht double(24,8) DEFAULT 0, + multicurrency_total_tva double(24,8) DEFAULT 0, + multicurrency_total_ttc double(24,8) DEFAULT 0, + + import_key varchar(14) )ENGINE=innodb; -- From 3e4150fbc23ed40cfd0b47c1c82ef6b1ea4f45ab Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 7 Feb 2022 05:02:59 +0100 Subject: [PATCH 19/55] Translation --- htdocs/install/mysql/tables/llx_propaldet.sql | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_propaldet.sql b/htdocs/install/mysql/tables/llx_propaldet.sql index 6b4699d3188..fea9bad9bdc 100644 --- a/htdocs/install/mysql/tables/llx_propaldet.sql +++ b/htdocs/install/mysql/tables/llx_propaldet.sql @@ -28,7 +28,7 @@ create table llx_propaldet fk_product integer NULL, label varchar(255) DEFAULT NULL, description text, - fk_remise_except integer NULL, -- Lien vers table des remises fixes + fk_remise_except integer NULL, -- Link to table of fixed discounts vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. tva_tx double(6,3) DEFAULT 0, -- Vat rate localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate @@ -36,26 +36,26 @@ create table llx_propaldet localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_type varchar(10) NULL, -- localtax2 type qty real, -- quantity - remise_percent real DEFAULT 0, -- pourcentage de remise - remise real DEFAULT 0, -- montant de la remise (obsolete) - price real, -- prix final (obsolete) - subprice double(24,8) DEFAULT 0, -- prix unitaire article - total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantite et incluant remise ligne et globale - total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantite et incluant remise ligne et globale + remise_percent real DEFAULT 0, -- discount percentage + remise real DEFAULT 0, -- discount amount (obsolete) + price real, -- final price (obsolete) + subprice double(24,8) DEFAULT 0, -- unit price article + total_ht double(24,8) DEFAULT 0, -- Total excluding VAT of the line all quantities and including line and global discount + total_tva double(24,8) DEFAULT 0, -- Total VAT of the line any quantity and including discount line and global total_localtax1 double(24,8) DEFAULT 0, -- Total localtax1 total_localtax2 double(24,8) DEFAULT 0, -- Total localtax2 - total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale + total_ttc double(24,8) DEFAULT 0, -- Total TTC of the line all quantity and including line and global discount product_type integer DEFAULT 0, -- 0 or 1. Value 9 may be used by some modules (amount of line may not be included into generated discount if value is 9). - date_start datetime DEFAULT NULL, -- date debut si service - date_end datetime DEFAULT NULL, -- date fin si service - info_bits integer DEFAULT 0, -- TVA NPR ou non + date_start datetime DEFAULT NULL, -- start date if service + date_end datetime DEFAULT NULL, -- end date if service + info_bits integer DEFAULT 0, -- VAT NPR or not buy_price_ht double(24,8) DEFAULT 0, -- buying price fk_product_fournisseur_price integer DEFAULT NULL, -- reference of supplier price when line was added (may be used to update buy_price_ht current price when future invoice will be created) special_code integer DEFAULT 0, -- code for special lines (may be 1=transport, 2=ecotax, 3=option, moduleid=...) - rang integer DEFAULT 0, -- ordre affichage sur la propal - fk_unit integer DEFAULT NULL, -- lien vers table des unités + rang integer DEFAULT 0, -- order display on the propal + fk_unit integer DEFAULT NULL, -- link to table of units fk_multicurrency integer, multicurrency_code varchar(255), @@ -68,9 +68,9 @@ create table llx_propaldet )ENGINE=innodb; -- --- Liste des codes pour special_code +-- List of codes for special_code -- --- 1 : frais de port --- 2 : ecotaxe --- 3 : produit/service propose en option +-- 1 : shipping costs +-- 2 : ecotax +-- 3 : optional product/service -- From 228142684b5c2eecde9965bd7e03c70b3b445348 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 7 Feb 2022 16:33:27 +0100 Subject: [PATCH 20/55] fix: if capital is not numeric just display input value --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3d0422b1205..5963b1bc57f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1064,7 +1064,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); } else { - $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $tmpamounttoshow, $outputlangs); + $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $fromcompany->capital, $outputlangs); } } // Prof Id 1 From 30779be77e7f35eae1feedc2fc2f1019d00974f8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 7 Feb 2022 16:36:47 +0100 Subject: [PATCH 21/55] fix: if capital is not numeric just display input value --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 5963b1bc57f..20b2608e3b9 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1063,7 +1063,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); - } else { + } elseif (!empty($fromcompany->capital)) { $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", $fromcompany->capital, $outputlangs); } } From c496e6eb51502791708e377c8230d28acb999291 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 7 Feb 2022 20:53:13 +0100 Subject: [PATCH 22/55] doc --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 20b2608e3b9..1755378f7d4 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1060,7 +1060,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } // Capital if ($fromcompany->capital) { - $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string + $tmpamounttoshow = price2num($fromcompany->capital); // This field is a free string or a float if (is_numeric($tmpamounttoshow) && $tmpamounttoshow > 0) { $line3 .= ($line3 ? " - " : "").$outputlangs->transnoentities("CapitalOf", price($tmpamounttoshow, 0, $outputlangs, 0, 0, 0, $conf->currency)); } elseif (!empty($fromcompany->capital)) { From 4c6fd42e3ae458bf05dd3fdd1bcf6b483f789e83 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 9 Feb 2022 09:47:48 +0100 Subject: [PATCH 23/55] fix with eldy recommendations --- htdocs/fourn/facture/card.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 57d0ae6a1a0..596c55b53ad 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -527,13 +527,14 @@ if (empty($reshook)) { $i = 0; foreach ($object->lines as $line) { if ($line->product_type < 9 && $line->total_ht != 0) { // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null + $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); - $amount_ht[$line->tva_tx] += $line->total_ht; - $amount_tva[$line->tva_tx] += $line->total_tva; - $amount_ttc[$line->tva_tx] += $line->total_ttc; - $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; - $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; - $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; + $amount_ht[$keyforvatrate] += $line->total_ht; + $amount_tva[$keyforvatrate] += $line->total_tva; + $amount_ttc[$keyforvatrate] += $line->total_ttc; + $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht; + $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva; + $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc; $i++; } } From e4c1978e12efef49615d75320568da96f8bb31c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Wed, 9 Feb 2022 12:24:33 +0100 Subject: [PATCH 24/55] Change of SQL request when fetching CommandeFournisseurLigne --- htdocs/fourn/class/fournisseur.commande.class.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index dbb454ef800..1c9a86838b7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -460,13 +460,17 @@ class CommandeFournisseur extends CommonOrder $sql .= " l.date_start, l.date_end,"; $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; + $sql .= ", pfp.rowid as fk_pfp, pfp.packaging, MAX(pfp.quantity) as max_qty"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn AND pfp.fk_soc = ".((int) $this->socid); $sql .= " WHERE l.fk_commande = ".$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql.= " AND l.qty >= pfp.quantity "; + $sql.= " GROUP BY l.rowid HAVING max_qty = MAX(pfp.quantity) "; + } $sql .= " ORDER BY l.rang, l.rowid"; //print $sql; @@ -3488,12 +3492,15 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ' cd.date_start, cd.date_end, cd.fk_unit,'; $sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql .= ", pfp.rowid as fk_pfp, pfp.packaging"; + $sql .= ", pfp.rowid as fk_pfp, pfp.packaging, MAX(pfp.quantity) as max_qty"; $sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn"; $sql .= ' WHERE cd.rowid = '.$rowid; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= " AND cd.qty >= pfp.quantity GROUP BY cd.rowid HAVING max_qty = MAX(pfp.quantity)"; + } $result = $this->db->query($sql); if ($result) { From 793e43c7c6583807f0ea4d818796adc76bb99249 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Feb 2022 09:29:11 +0100 Subject: [PATCH 25/55] Update fournisseur.commande.class.php --- htdocs/fourn/class/fournisseur.commande.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 89222b4d55e..8642ea6d8eb 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -463,8 +463,9 @@ class CommandeFournisseur extends CommonOrder $sql .= ", pfp.rowid as fk_pfp, pfp.packaging, MAX(pfp.quantity) as max_qty"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn AND pfp.fk_soc = ".$this->socid; + if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON pfp.entity IN (".getEntity('product_fournisseur_price').") AND l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn AND pfp.fk_soc = ".((int) $this->socid); + } $sql .= " WHERE l.fk_commande = ".$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) { From 8dffa020b45e575f758004e7a063b5de54b119ed Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 10 Feb 2022 09:54:09 +0100 Subject: [PATCH 26/55] FIX broken feature, wrong div name --- htdocs/compta/bank/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 989ab236a1c..5a8ac046ce4 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -326,7 +326,7 @@ if ($action == 'create') { if ($conf->use_javascript_ajax) { print "\n".'