";
// Public note
@@ -1202,7 +1202,7 @@ if ($action == 'create') {
$morehtmlref .= '';
} else {
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index 1cd6a7835ce..40eb5da3c03 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -216,7 +216,11 @@ if (!defined('DONOTLOADCONF') && file_exists($conffile) && filesize($conffile) >
}
// Clean parameters
- $dolibarr_main_data_root = isset($dolibarr_main_data_root) ? trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.'/../documents';
+ // isset() is true on an empty string, which would let DOL_DATA_ROOT
+ // resolve to '' and the lock file to /install.lock (rejected by a
+ // restrictive open_basedir). Use !empty() so an empty value falls
+ // back to the default relative documents path.
+ $dolibarr_main_data_root = !empty($dolibarr_main_data_root) ? trim($dolibarr_main_data_root) : DOL_DOCUMENT_ROOT.'/../documents';
$dolibarr_main_url_root = isset($dolibarr_main_url_root) ? trim($dolibarr_main_url_root) : '';
$dolibarr_main_url_root_alt = isset($dolibarr_main_url_root_alt) ? trim($dolibarr_main_url_root_alt) : '';
$dolibarr_main_document_root = isset($dolibarr_main_document_root) ? trim($dolibarr_main_document_root) : '';
@@ -268,7 +272,7 @@ if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) {
define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : ''));
define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir
-define('DOL_DATA_ROOT', (isset($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.'/../documents'));
+define('DOL_DATA_ROOT', (!empty($dolibarr_main_data_root) ? $dolibarr_main_data_root : DOL_DOCUMENT_ROOT.'/../documents'));
define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root
$uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
$suburi = strstr($uri, '/'); // $suburi contains url without domain
diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php
index c308c61a7eb..a5a94d9079a 100644
--- a/htdocs/product/ajax/products.php
+++ b/htdocs/product/ajax/products.php
@@ -295,9 +295,10 @@ if ($action == 'fetch' && !empty($id)) {
'qty' => $outqty,
'discount' => $outdiscount,
'mandatory_period' => $mandatory_period,
+
'array_options' => $object->array_options,
- 'default_unit'=>$default_unit
+ 'default_unit' => $default_unit
);
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 60157c83fa4..b5ae2109fed 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1053,6 +1053,19 @@ class Product extends CommonObject
$this->accountancy_code_sell_intra = trim((string) $this->accountancy_code_sell_intra);
$this->accountancy_code_sell_export = trim((string) $this->accountancy_code_sell_export);
+ // Normalize the accountancy codes the way the admin dropdown does it, so an API client that
+ // sends '606111000' ends up with the same '606111' value the GUI stores (see issue #32343).
+ // When ACCOUNTING_MANAGE_ZERO is on, trailing zeros are part of the code and must be kept.
+ if (!getDolGlobalString('ACCOUNTING_MANAGE_ZERO')) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+ $this->accountancy_code_buy = clean_account($this->accountancy_code_buy);
+ $this->accountancy_code_buy_intra = clean_account($this->accountancy_code_buy_intra);
+ $this->accountancy_code_buy_export = clean_account($this->accountancy_code_buy_export);
+ $this->accountancy_code_sell = clean_account($this->accountancy_code_sell);
+ $this->accountancy_code_sell_intra = clean_account($this->accountancy_code_sell_intra);
+ $this->accountancy_code_sell_export = clean_account($this->accountancy_code_sell_export);
+ }
+
// Barcode value
$this->barcode = trim($this->barcode);
$this->mandatory_period = empty($this->mandatory_period) ? 0 : $this->mandatory_period;
@@ -1488,6 +1501,19 @@ class Product extends CommonObject
$this->accountancy_code_sell_intra = trim($this->accountancy_code_sell_intra);
$this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export);
+ // Normalize the accountancy codes the way the admin dropdown does it, so an API client that
+ // sends '606111000' ends up with the same '606111' value the GUI stores (see issue #32343).
+ // When ACCOUNTING_MANAGE_ZERO is on, trailing zeros are part of the code and must be kept.
+ if (!getDolGlobalString('ACCOUNTING_MANAGE_ZERO')) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+ $this->accountancy_code_buy = clean_account($this->accountancy_code_buy);
+ $this->accountancy_code_buy_intra = clean_account($this->accountancy_code_buy_intra);
+ $this->accountancy_code_buy_export = clean_account($this->accountancy_code_buy_export);
+ $this->accountancy_code_sell = clean_account($this->accountancy_code_sell);
+ $this->accountancy_code_sell_intra = clean_account($this->accountancy_code_sell_intra);
+ $this->accountancy_code_sell_export = clean_account($this->accountancy_code_sell_export);
+ }
+
$this->db->begin();
$result = 0;
diff --git a/htdocs/product/list.php b/htdocs/product/list.php
index 514e33be040..083d58e0e70 100644
--- a/htdocs/product/list.php
+++ b/htdocs/product/list.php
@@ -126,7 +126,14 @@ $type = GETPOST("type", 'alpha');
// Show/hide child product variants
$show_childproducts = 0;
if (isModEnabled('variants')) {
- $show_childproducts = GETPOST('search_show_childproducts');
+ // An HTML checkbox does not submit anything when unchecked, so a hidden
+ // "search_show_childproducts=0" companion field is emitted next to the
+ // checkbox (see below). GETPOSTISSET() then let's us distinguish a
+ // resubmission with the checkbox off from a request that does not carry
+ // the filter at all, and the value is read as a strict 0/1 flag.
+ if (GETPOSTISSET('search_show_childproducts')) {
+ $show_childproducts = GETPOSTINT('search_show_childproducts');
+ }
}
$diroutputmassaction = $conf->product->dir_output.'/temp/massgeneration/'.$user->id;
@@ -400,7 +407,7 @@ if (empty($reshook)) {
$search_finished = '';
//$search_type=''; // There is 2 types of list: a list of product and a list of services. No list with both. So when we clear search criteria, we must keep the filter on type.
- $show_childproducts = '';
+ $show_childproducts = 0;
$search_import_key = '';
$search_stockable_product = '';
$search_accountancy_code_sell = '';
@@ -827,7 +834,7 @@ if ($fourn_id > 0) {
$param .= "&fourn_id=".urlencode((string) ($fourn_id));
}
if ($show_childproducts) {
- $param .= ($show_childproducts ? "&search_show_childproducts=".urlencode($show_childproducts) : "");
+ $param .= "&search_show_childproducts=".urlencode((string) $show_childproducts);
}
if ($type != '') {
$param .= '&type='.urlencode((string) ($type));
@@ -984,7 +991,11 @@ if (isModEnabled('category') && $user->hasRight('categorie', 'read')) {
// Show/hide child variant products
if (isModEnabled('variants')) {
$moreforfilter .= '
';
- $moreforfilter .= '';
+ // Companion hidden field ensures search_show_childproducts is always
+ // posted, even when the checkbox below is unchecked, so the unchecked
+ // state survives the filter/pagination submit and is parsed as 0/1.
+ $moreforfilter .= '';
+ $moreforfilter .= '';
$moreforfilter .= ' ';
$moreforfilter .= '
';
}
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 5dc6a840ab2..1170bd877bd 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -1684,6 +1684,16 @@ class Task extends CommonObjectLine
$ret = -1;
}
+ // Propagate trigger handler messages from $this->errors (plural array)
+ // to $this->error (singular string) so callers like the REST API can
+ // surface a useful message instead of an empty error tail.
+ if ($ret <= 0 && empty($this->error) && !empty($this->errors)) {
+ foreach ($this->errors as $errmsg) {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
+ }
+ }
+
if ($ret > 0) {
// Recalculate amount of time spent for task and update denormalized field
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
@@ -2146,6 +2156,16 @@ class Task extends CommonObjectLine
$ret = -1;
}
+ // Propagate trigger handler messages from $this->errors (plural array)
+ // to $this->error (singular string) so callers like the REST API can
+ // surface a useful message instead of an empty error tail.
+ if ($ret < 0 && empty($this->error) && !empty($this->errors)) {
+ foreach ($this->errors as $errmsg) {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
+ }
+ }
+
if ($ret == 1 && (($this->timespent_old_duration != $this->timespent_duration) || getDolGlobalString('TIMESPENT_ALWAYS_UPDATE_THM'))) {
if ($this->timespent_old_duration != $this->timespent_duration) {
// Recalculate amount of time spent for task and update denormalized field
diff --git a/htdocs/recruitment/class/api_recruitments.class.php b/htdocs/recruitment/class/api_recruitments.class.php
index 87fb02e4b57..d2e240e2cef 100644
--- a/htdocs/recruitment/class/api_recruitments.class.php
+++ b/htdocs/recruitment/class/api_recruitments.class.php
@@ -375,7 +375,7 @@ class Recruitments extends DolibarrApi
}
// Check mandatory fields
- $result = $this->_validate($request_data);
+ $result = $this->_validate($request_data, $this->jobposition);
foreach ($request_data as $field => $value) {
if ($field === 'caller') {
@@ -414,8 +414,10 @@ class Recruitments extends DolibarrApi
throw new RestException(403);
}
- // Check mandatory fields
- $result = $this->_validate($request_data);
+ // Check mandatory fields. Validate against the candidature model so the API
+ // rejects with the actual missing candidature fields (e.g. email) instead of
+ // the unrelated job position fields (see issue #38429).
+ $result = $this->_validate($request_data, $this->candidature);
foreach ($request_data as $field => $value) {
if ($field === 'caller') {
@@ -686,25 +688,26 @@ class Recruitments extends DolibarrApi
* Validate fields before create or update object
*
* @param ?array $data Array of data to validate
+ * @param CommonObject $object Object to validate against
* @return array
*
* @throws RestException
*/
- private function _validate($data)
+ private function _validate($data, $object)
{
if ($data === null) {
$data = array();
}
- $jobposition = array();
- foreach ($this->jobposition->fields as $field => $propfield) {
+ $result = array();
+ foreach ($object->fields as $field => $propfield) {
if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || empty($propfield['notnull']) || $propfield['notnull'] != 1) {
continue; // Not a mandatory field
}
if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
}
- $jobposition[$field] = $data[$field];
+ $result[$field] = $data[$field];
}
- return $jobposition;
+ return $result;
}
}
diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php
index de468d5e5a5..1969d97b1f1 100644
--- a/htdocs/takepos/receipt.php
+++ b/htdocs/takepos/receipt.php
@@ -406,14 +406,19 @@ if (getDolGlobalString('TAKEPOS_TICKET_VAT_GROUPPED')) {
// Now show local taxes if company uses them
-if (price2num($object->total_localtax1, 'MU') || $mysoc->useLocalTax(1)) { ?>
+// $mysoc->useLocalTax(N) is a country-wide flag (true as soon as the country has a
+// matching c_tva row with a localtaxN_type), so on its own it always prints the line
+// for Spanish companies even when the company is "No sujeto a RE / IRPF". Mirror the
+// pattern used by compta/facture/card.php, card-rec.php and prelevement.php and gate
+// the country check on $mysoc->localtaxN_assuj == "1".
+if (($mysoc->localtax1_assuj == "1" && $mysoc->useLocalTax(1)) || price2num($object->total_localtax1, 'MU')) { ?>