diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 264613ac597..9a0851afc8d 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -320,6 +320,8 @@ if (empty($reshook)) {
$db->begin();
+ $nbOrders = is_array($orders) ? count($orders) : 1;
+
foreach ($orders as $id_order) {
$cmd = new Commande($db);
if ($cmd->fetch($id_order) <= 0) {
@@ -455,10 +457,11 @@ if (empty($reshook)) {
$objecttmp->context['createfromclone'];
- $rang = $lines[$i]->rang;
+ $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
//there may already be rows from previous orders
- if (!empty($createbills_onebythird))
+ if (!empty($createbills_onebythird)) {
$rang = $TFactThirdNbLines[$cmd->socid];
+ }
$result = $objecttmp->addline(
$desc,
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index baae549c050..86d9f46b8c3 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -2018,6 +2018,7 @@ class ExtraFields
}
if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')))) {
+ //when unticking boolean field, it's not set in POST
continue;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 6d87116fd6b..a529bed6a6e 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5458,9 +5458,10 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
* @param boolean $addpercent Add a percent % sign in output
* @param int $info_bits Miscellaneous information on vat (0=Default, 1=French NPR vat)
* @param int $usestarfornpr -1=Never show, 0 or 1=Use '*' for NPR vat rates
+ * @param int $html Used for html output
* @return string String with formated amounts ('19,6' or '19,6%' or '8.5% (NPR)' or '8.5% *' or '19,6 (CODEX)')
*/
-function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0)
+function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
{
$morelabel = '';
@@ -5468,9 +5469,11 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0)
$rate = str_replace('%', '', $rate);
$addpercent = true;
}
+ $reg = array();
if (preg_match('/\((.*)\)/', $rate, $reg)) {
$morelabel = ' ('.$reg[1].')';
$rate = preg_replace('/\s*'.preg_quote($morelabel, '/').'/', '', $rate);
+ $morelabel = ' '.($html ? '' : '').'('.$reg[1].')'.($html ? '' : '');
}
if (preg_match('/\*/', $rate)) {
$rate = str_replace('*', '', $rate);
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 580e30db650..ea53ae065e3 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -954,6 +954,7 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0)
$i++;
$total += $obj->total_ht;
$total_ttc += $obj->total_ttc;
+ $totalam += $obj->am;
continue;
}
diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php
index b43ead29e7f..1d1d37ac240 100644
--- a/htdocs/core/modules/modResource.class.php
+++ b/htdocs/core/modules/modResource.class.php
@@ -239,22 +239,26 @@ class modResource extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r] = array(array("resource", "read"));
- $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification");
+
+ $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.rowid'=>'ResourceTypeID', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceTypeLabel', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification");
$this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text');
$this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource");
+
$keyforselect = 'resource';
$keyforelement = 'resource';
$keyforaliasextra = 'extra';
+
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r';
- $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.code = r.fk_code_type_resource';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid';
$this->export_sql_end[$r] .= ' WHERE r.entity IN ('.getEntity('resource').')';
+
// Imports
//--------
$r = 0;
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index 690558fc9ad..77de9a72926 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -960,7 +960,7 @@ class ProductFournisseur extends Product
public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array())
{
// phpcs:enable
- global $langs;
+ global $conf, $langs;
$out = '';
$langs->load("suppliers");
@@ -978,7 +978,7 @@ class ProductFournisseur extends Product
}
$out .= '';
} else {
- $out = ($showunitprice ? price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' (' : '');
+ $out = ($showunitprice ? price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise, 0, $langs, 1, -1, -1, $conf->currency).' '.$langs->trans("HT").' (' : '');
$out .= ($showsuptitle ? ''.$langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->ref_supplier;
$out .= ($showunitprice ? ')' : '');
}
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index bf85d5dd15b..618e5cc6a78 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -1177,7 +1177,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_
if (empty($positiverates)) {
$positiverates = '0';
}
- echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr);
+ echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr, 0, 1);
/*
if ($object->default_vat_code)
{
diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php
index 7f9227fee88..0e8f69958dc 100644
--- a/htdocs/variants/class/ProductCombination.class.php
+++ b/htdocs/variants/class/ProductCombination.class.php
@@ -608,6 +608,10 @@ class ProductCombination
$prodcomb2val = new ProductCombination2ValuePair($this->db);
$prodcomb = new ProductCombination($this->db);
+ $features = array_filter($features, function ($v) {
+ return !empty($v);
+ });
+
foreach ($features as $attr => $attr_val) {
$actual_comp[$attr] = $attr_val;
}