Skip to content

Commit

Permalink
Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 20, 2025
2 parents 9f4692e + 736890b commit 1b42078
Show file tree
Hide file tree
Showing 33 changed files with 244 additions and 24 deletions.
6 changes: 6 additions & 0 deletions htdocs/adherents/class/api_members.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ public function put($id, $request_data = null)
}
}
} else {
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$member->array_options[$index] = $this->_checkValForAPI($field, $val, $member);
}
continue;
}
$member->$field = $value;
}
}
Expand Down
6 changes: 6 additions & 0 deletions htdocs/adherents/class/api_memberstypes.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$membertype->array_options[$index] = $this->_checkValForAPI($field, $val, $membertype);
}
continue;
}
// Process the status separately because it must be updated using
// the validate(), resiliate() and exclude() methods of the class AdherentType.
$membertype->$field = $value;
Expand Down
6 changes: 6 additions & 0 deletions htdocs/adherents/class/api_subscriptions.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$subscription->array_options[$index] = $this->_checkValForAPI($field, $val, $subscription);
}
continue;
}
$subscription->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/bom/class/api_boms.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->bom->array_options[$index] = $this->_checkValForAPI($field, $val, $this->bom);
}
continue;
}
$this->bom->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/categories/class/api_categories.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->category->array_options[$index] = $this->_checkValForAPI($field, $val, $this->category);
}
continue;
}
$this->category->$field = $value;
}

Expand Down
7 changes: 6 additions & 1 deletion htdocs/comm/action/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,12 @@ function setdatefields()
// related contact
print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>';
print '<div class="maxwidth200onsmartphone">';
print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts(empty($conf->global->MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT) ? $object->socid : 0, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid');
if (getDolGlobalInt('MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT')) {
$select_contact_default = 0; // select "all" contacts by default : avoid to use it if there is a lot of contacts
} else {
$select_contact_default = -1; // select "none" by default
}
print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts(!empty($object->socid) ? $object->socid : $select_contact_default, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid');
print '</div>';
print '</td>';
print '</tr>';
Expand Down
8 changes: 5 additions & 3 deletions htdocs/comm/action/class/actioncomm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public function create(User $user, $notrigger = 0)
foreach ($this->userassigned as $key => $val) {
// Common value with new behavior is to have $val = array('id'=>iduser, 'transparency'=>0|1) and $this->userassigned is an array of iduser => $val.
if (!is_array($val)) { // For backward compatibility when $val='id'.
$val = array('id'=>$val);
$val = array('id' => $val);
}

if ($val['id'] > 0) {
Expand Down Expand Up @@ -1258,9 +1258,11 @@ public function update(User $user, $notrigger = 0)
$already_inserted = array();
foreach (array_keys($this->socpeopleassigned) as $key => $val) {
if (!is_array($val)) { // For backward compatibility when val=id
$val = array('id'=>$val);
$val = array('id' => $val);
}
if (!empty($already_inserted[$val['id']])) {
continue;
}
if (!empty($already_inserted[$val['id']])) continue;

$sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
$sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $val['id']).", 0, 0, 0)";
Expand Down
6 changes: 6 additions & 0 deletions htdocs/comm/action/class/api_agendaevents.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ public function put($id, $request_data = null)
continue;
}

if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->actioncomm->array_options[$index] = $this->_checkValForAPI($field, $val, $this->actioncomm);
}
continue;
}
$this->actioncomm->$field = $this->_checkValForAPI($field, $value, $this->actioncomm);
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/comm/propal/class/api_proposals.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->propal->array_options[$index] = $this->_checkValForAPI($field, $val, $this->propal);
}
continue;
}
$this->propal->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/commande/class/api_orders.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->commande->array_options[$index] = $this->_checkValForAPI($field, $val, $this->commande);
}
continue;
}
$this->commande->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/compta/bank/class/api_bankaccounts.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$account->array_options[$index] = $this->_checkValForAPI($field, $val, $account);
}
continue;
}
$account->$field = $this->_checkValForAPI($field, $value, $account);
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/compta/facture/class/api_invoices.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->invoice->array_options[$index] = $this->_checkValForAPI($field, $val, $this->invoice);
}
continue;
}
$this->invoice->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/contrat/class/api_contracts.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->contract->array_options[$index] = $this->_checkValForAPI($field, $val, $this->contract);
}
continue;
}
$this->contract->$field = $value;
}

Expand Down
27 changes: 15 additions & 12 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -9155,10 +9155,11 @@ function dol_osencode($str)
* @param string $fieldid Field to get
* @param int $entityfilter Filter by entity
* @param string $filters Filters to add. WARNING: string must be escaped for SQL and not coming from user input.
* @param bool $useCache If true (default), cache will be queried and updated.
* @return int <0 if KO, Id of code if OK
* @see $langs->getLabelFromKey
*/
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '')
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '', $useCache = true)
{
global $cache_codes;

Expand All @@ -9168,8 +9169,8 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
}

// Check in cache
if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
return $cache_codes[$tablename][$key][$fieldid]; // Found in cache
if ($useCache && isset($cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key])) { // Can be defined to 0 or ''
return $cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key]; // Found in cache
}

dol_syslog('dol_getIdFromCode (value for field '.$fieldid.' from key '.$key.' not found into cache)', LOG_DEBUG);
Expand All @@ -9187,13 +9188,15 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid =
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$valuetoget = '';
if ($obj) {
$cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
} else {
$cache_codes[$tablename][$key][$fieldid] = '';
$valuetoget = $obj->valuetoget;
}
$db->free($resql);
return $cache_codes[$tablename][$key][$fieldid];
if ($useCache) {
$cache_codes[$tablename][$fieldkey][$fieldid][$entityfilter][$filters][$key] = $valuetoget;
}
return $valuetoget;
} else {
return -1;
}
Expand Down Expand Up @@ -11158,11 +11161,11 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* 'classOverride' => '' // to replace class attribute of the button
* ],
* 'confirm' => [
* 'url' => 'http://', // Overide Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm.
* 'title' => '', // Overide title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key
* 'action-btn-label' => '', // Overide label of action button, if empty default label use "Confirm" lang key
* 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key
* 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key
* 'url' => 'http://', // Override Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm.
* 'title' => '', // Override title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key
* 'action-btn-label' => '', // Override label of action button, if empty default label use "Confirm" lang key
* 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key
* 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key
* 'modal' => true, // true|false to display dialog as a modal (with dark background)
* 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background)
* ],
Expand Down
53 changes: 46 additions & 7 deletions htdocs/core/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1425,12 +1425,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
{
global $db, $conf, $langs;

$idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
$label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : ''));
$desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : ''));
$ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);
$multilangsactive = getDolGlobalInt('MAIN_MULTILANGS');

if ($issupplierline) {
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
Expand All @@ -1444,10 +1439,54 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
}
}

//id
$idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false);
if ($idprod) {
$prodser->fetch($idprod);
//load multilangs
if ($multilangsactive) {
$prodser->getMultiLangs();
$object->lines[$i]->multilangs = $prodser->multilangs;
}
}
//label
if (!empty($object->lines[$i]->label)) {
$label = $object->lines[$i]->label;
} else {
if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['label']) && $multilangsactive) {
$label = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['label'];
} else {
if (!empty($object->lines[$i]->product_label)) {
$label = $object->lines[$i]->product_label;
} else {
$label = '';
}
}
}
//description
if (!empty($object->lines[$i]->desc)) {
$desc = $object->lines[$i]->desc;
} else {
if (!empty($object->lines[$i]->multilangs[$outputlangs->defaultlang]['description']) && $multilangsactive) {
$desc = $object->lines[$i]->multilangs[$outputlangs->defaultlang]['description'];
} else {
if (!empty($object->lines[$i]->description)) {
$desc = $object->lines[$i]->description;
} else {
$desc = '';
}
}
}
//ref supplier
$ref_supplier = (!empty($object->lines[$i]->ref_supplier) ? $object->lines[$i]->ref_supplier : (!empty($object->lines[$i]->ref_fourn) ? $object->lines[$i]->ref_fourn : '')); // TODO Not yet saved for supplier invoices, only supplier orders
//note
$note = (!empty($object->lines[$i]->note) ? $object->lines[$i]->note : '');
//dbatch
$dbatch = (!empty($object->lines[$i]->detail_batch) ? $object->lines[$i]->detail_batch : false);

if ($idprod) {
// If a predefined product and multilang and on other lang, we renamed label with label translated
if (getDolGlobalInt('MAIN_MULTILANGS') && ($outputlangs->defaultlang != $langs->defaultlang)) {
if ($multilangsactive && ($outputlangs->defaultlang != $langs->defaultlang)) {
$translatealsoifmodified = (!empty($conf->global->MAIN_MULTILANG_TRANSLATE_EVEN_IF_MODIFIED)); // By default if value was modified manually, we keep it (no translation because we don't have it)

// TODO Instead of making a compare to see if param was modified, check that content contains reference translation. If yes, add the added part to the new translation
Expand Down
6 changes: 6 additions & 0 deletions htdocs/don/class/api_donations.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->don->array_options[$index] = $this->_checkValForAPI($field, $val, $this->don);
}
continue;
}
$this->don->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/expedition/class/api_shipments.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->shipment->array_options[$index] = $this->_checkValForAPI($field, $val, $this->shipment);
}
continue;
}
$this->shipment->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/expensereport/class/api_expensereports.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->expensereport->array_options[$index] = $this->_checkValForAPI($field, $val, $this->expensereport);
}
continue;
}
$this->expensereport->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/fourn/class/api_supplier_invoices.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->invoice->array_options[$index] = $this->_checkValForAPI($field, $val, $this->invoice);
}
continue;
}
$this->invoice->$field = $value;
}

Expand Down
6 changes: 6 additions & 0 deletions htdocs/fourn/class/api_supplier_orders.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->order->array_options[$index] = $this->_checkValForAPI($field, $val, $this->order);
}
continue;
}
$this->order->$field = $value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ public function put($id, $request_data = null)
if ($field == 'id') {
continue;
}
if ($field == 'array_options' && is_array($value)) {
foreach ($value as $index => $val) {
$this->knowledgerecord->array_options[$index] = $this->_checkValForAPI($field, $val, $this->knowledgerecord);
}
continue;
}
$this->knowledgerecord->$field = $this->_checkValForAPI($field, $value, $this->knowledgerecord);
}

Expand Down
Loading

0 comments on commit 1b42078

Please sign in to comment.