From ec1f78424742205349ca757190a67eb7ac03bc3a Mon Sep 17 00:00:00 2001 From: jpb Date: Wed, 26 Jan 2022 11:43:44 +0100 Subject: [PATCH 01/11] 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 047c55bd0228f2137a19f99f78d49ae3689d9d31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 08:49:47 +0100 Subject: [PATCH 06/11] Fix look and feel v15 --- htdocs/product/price.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index d21574e696e..45ecbd9bafa 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1278,22 +1278,30 @@ if (!$action || $action == 'delete' || $action == 'showlog_customer_price' || $a if (empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("UpdateDefaultPrice") . '
'; } } if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("AddCustomerPrice") . '
'; } } if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("UpdateVAT") . '
'; } if ($user->rights->produit->creer || $user->rights->service->creer) { print ''; + } else { + print '
' . $langs->trans("UpdateLevelPrices") . '
'; } } } From 5ff37febe3a05064cdaa94cff6973089fa8f6e33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 09:58:58 +0100 Subject: [PATCH 07/11] Trans --- htdocs/blockedlog/class/blockedlog.class.php | 6 +++--- htdocs/langs/en_US/blockedlog.lang | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 83ab700f59a..578e1afa497 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -320,12 +320,12 @@ class BlockedLog $this->error++; } } elseif ($this->action == 'MODULE_SET') { - return 'System to track events into unalterable logs were enabled'; + return ''.$langs->trans("BlockedLogEnabled").''; } elseif ($this->action == 'MODULE_RESET') { if ($this->signature == '0000000000') { - return 'System to track events into unalterable logs were disabled after some recording were done. We saved a special Fingerprint to track the chain as broken.'; + return ''.$langs->trans("BlockedLogDisabled").''; } else { - return 'System to track events into unalterable logs were disabled. This is possible because no record were done yet.'; + return ''.$langs->trans("BlockedLogDisabledBis").''; } } diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 44cb183050a..a1046827559 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -52,3 +52,6 @@ BlockedLogDisableNotAllowedForCountry=List of countries where usage of this modu OnlyNonValid=Non-valid TooManyRecordToScanRestrictFilters=Too many records to scan/analyze. Please restrict list with more restrictive filters. RestrictYearToExport=Restrict month / year to export +BlockedLogEnabled=System to track events into unalterable logs has been enabled +BlockedLogDisabled=System to track events into unalterable logs has been disabled after some recording were done. We saved a special Fingerprint to track the chain as broken +BlockedLogDisabledBis=System to track events into unalterable logs has been disabled. This is possible because no record were done yet. \ No newline at end of file From 34f3ec8a39e9e743980d9557b2069a1fba3d49b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 11:11:36 +0100 Subject: [PATCH 08/11] Try a fix with php that return a fatal error on some mysql --- htdocs/core/db/mysqli.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 4dd71f0e351..fa24e4a70ac 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -210,6 +210,8 @@ class DoliDBMysqli extends DoliDB { dol_syslog(get_class($this)."::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name", LOG_DEBUG); + //mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); + // Can also be // mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); // return mysqli::real_connect($host, $user, $pass, $db, $port); @@ -255,6 +257,8 @@ class DoliDBMysqli extends DoliDB return false; } + + /** * Execute a SQL request and return the resultset * @@ -288,11 +292,16 @@ class DoliDBMysqli extends DoliDB } } - if (!$this->database_name) { - // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) - $ret = $this->db->query($query, $result_mode); - } else { - $ret = $this->db->query($query, $result_mode); + try { + if (!$this->database_name) { + // Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE) + $ret = $this->db->query($query, $result_mode); + } else { + $ret = $this->db->query($query, $result_mode); + } + } catch (Exception $e) { + dol_syslog(get_class($this)."::query Exception in query instead of returning an error: ".$e->getMessage(), LOG_ERR); + $ret = false; } if (!preg_match("/^COMMIT/i", $query) && !preg_match("/^ROLLBACK/i", $query)) { From da744f5cb9de1b41f6a65d10cba718aa3667df7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 13:44:15 +0100 Subject: [PATCH 09/11] Fix link --- htdocs/core/boxes/box_scheduled_jobs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 53cf5c79571..94695034cce 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -170,7 +170,7 @@ class box_scheduled_jobs extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="center"', - 'textnoformat' => ($nbjobsinerror ? '
'.$nbjobsinerror.'
' : '
0
') + 'textnoformat' => ($nbjobsinerror ? '
'.$nbjobsinerror.'
' : '
0
') ); } else { $this->info_box_contents[0][0] = array( From bd2d7792f453c5ba20f004eca7647348a590e7cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 13:52:42 +0100 Subject: [PATCH 10/11] css --- htdocs/core/lib/product.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 10c838b4c43..117871b4712 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -382,7 +382,7 @@ function show_stats_for_company($product, $socid) } $langs->load("propal"); print ''; - print ''.img_object('', 'propal', 'class="paddingright"').$langs->trans("Proposals").''; + print ''.img_object('', 'propal', 'class="pictofixedwidth"').$langs->trans("Proposals").''; print ''; print $product->stats_propale['customers']; print ''; @@ -401,7 +401,7 @@ function show_stats_for_company($product, $socid) } $langs->load("supplier_proposal"); print ''; - print ''.img_object('', 'supplier_proposal', 'class="paddingright"').$langs->trans("SupplierProposals").''; + print ''.img_object('', 'supplier_proposal', 'class="pictofixedwidth"').$langs->trans("SupplierProposals").''; print ''; print $product->stats_proposal_supplier['suppliers']; print ''; @@ -420,7 +420,7 @@ function show_stats_for_company($product, $socid) } $langs->load("orders"); print ''; - print ''.img_object('', 'order', 'class="paddingright"').$langs->trans("CustomersOrders").''; + print ''.img_object('', 'order', 'class="pictofixedwidth"').$langs->trans("CustomersOrders").''; print ''; print $product->stats_commande['customers']; print ''; @@ -439,7 +439,7 @@ function show_stats_for_company($product, $socid) } $langs->load("orders"); print ''; - print ''.img_object('', 'supplier_order', 'class="paddingright"').$langs->trans("SuppliersOrders").''; + print ''.img_object('', 'supplier_order', 'class="pictofixedwidth"').$langs->trans("SuppliersOrders").''; print ''; print $product->stats_commande_fournisseur['suppliers']; print ''; @@ -458,7 +458,7 @@ function show_stats_for_company($product, $socid) } $langs->load("bills"); print ''; - print ''.img_object('', 'bill').' '.$langs->trans("CustomersInvoices").''; + print ''.img_object('', 'bill', 'class="pictofixedwidth"').$langs->trans("CustomersInvoices").''; print ''; print $product->stats_facture['customers']; print ''; @@ -477,7 +477,7 @@ function show_stats_for_company($product, $socid) } $langs->load("bills"); print ''; - print ''.img_object('', 'supplier_invoice', 'class="paddingright"').$langs->trans("SuppliersInvoices").''; + print ''.img_object('', 'supplier_invoice', 'class="pictofixedwidth"').$langs->trans("SuppliersInvoices").''; print ''; print $product->stats_facture_fournisseur['suppliers']; print ''; @@ -497,7 +497,7 @@ function show_stats_for_company($product, $socid) } $langs->load("contracts"); print ''; - print ''.img_object('', 'contract', 'class="paddingright"').$langs->trans("Contracts").''; + print ''.img_object('', 'contract', 'class="pictofixedwidth"').$langs->trans("Contracts").''; print ''; print $product->stats_contrat['customers']; print ''; @@ -518,7 +518,7 @@ function show_stats_for_company($product, $socid) $langs->load("mrp"); print ''; - print ''.img_object('', 'bom', 'class="paddingright"').$langs->trans("BOM").''; + print ''.img_object('', 'bom', 'class="pictofixedwidth"').$langs->trans("BOM").''; print ''; print ''; @@ -540,7 +540,7 @@ function show_stats_for_company($product, $socid) } $langs->load("mrp"); print ''; - print ''.img_object('', 'mrp', 'class="paddingright"').$langs->trans("MO").''; + print ''.img_object('', 'mrp', 'class="pictofixedwidth"').$langs->trans("MO").''; print ''; print $form->textwithpicto($product->stats_mo['customers_toconsume'], $langs->trans("ToConsume")); print $form->textwithpicto($product->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed")); From 4b5792899e4ab614ad06e44ddaafb392c6629e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jan 2022 15:51:18 +0100 Subject: [PATCH 11/11] 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) {