Skip to content

Commit

Permalink
Merge branch '17.0' of https://github.com/Dolibarr/dolibarr into 17.0…
Browse files Browse the repository at this point in the history
…_koesio
  • Loading branch information
atm-lena committed Jan 16, 2025
2 parents 594b9f2 + f68cf00 commit 4aa0b80
Show file tree
Hide file tree
Showing 35 changed files with 319 additions and 89 deletions.
33 changes: 15 additions & 18 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ jobs:
with:
path: ~/.cache/pre-commit/
key: pre-commit-4|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Extract PHP version
id: extract-php-version
run: |
PHP_VERSION=$(sed -n 's/.*\$arrayphpmaxversionwarning\s*=\s*array\s*(\s*\([0-9]\+\)\s*,\s*\([0-9]\+\).*/\1.\2/p' htdocs/install/check.php)
echo "PHP_VERSION=$PHP_VERSION" >> $GITHUB_ENV
- name: Setup PHPCS
uses: shivammathur/setup-php@v2
# Install proper php version, and also install phpcs which may be needed
with:
php-version: ${{ env.PHP_VERSION }} # Version from check.php
coverage: none # disable xdebug, pcov
tools: phpcs

# Run all the precommit tools (defined into pre-commit-config.yaml).
# We can force exclusion of some of them here.
- name: Run pre-commit hooks
Expand All @@ -62,24 +77,6 @@ jobs:
# files: |
# **.php

- name: Setup PHPCS
uses: shivammathur/setup-php@v2
# Install when we're going to run phpcs
if: |
steps.changed-php.outputs.any_changed == 'true'
||
(
github.event_name == 'push'
&& (
github.event.ref == 'refs/heads/develop'
|| endsWith(github.event.ref, '.0')
)
)
with:
php-version: 8.1
coverage: none # disable xdebug, pcov
tools: phpcs

- name: Run some pre-commit hooks on selected changed files only
if: steps.changed-php.outputs.any_changed == 'true'
env:
Expand Down
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 @@ -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->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
8 changes: 7 additions & 1 deletion htdocs/comm/action/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1442,8 +1442,14 @@ function init_repeat()
$preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int');
}
if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int');
// select "all" or "none" contact by default
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"');
print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid');
print $form->selectcontacts(GETPOSTISSET('socid') ? GETPOSTINT('socid') : $select_contact_default, $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid');
print '</td></tr>';
}

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 @@ -697,6 +697,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 @@ -652,6 +652,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 @@ -627,6 +627,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 @@ -531,6 +531,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
2 changes: 0 additions & 2 deletions htdocs/contrat/services_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,7 @@
$sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'";
}
if ($search_name) {
/** BACKPORT #32654 */
$sql .= natural_search("s.nom", $search_name);
/** BACKPORT #32654 */
}
if ($search_contract) {
$sql .= natural_search("c.ref", $search_contract);
Expand Down
47 changes: 25 additions & 22 deletions htdocs/core/lib/functions.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8876,10 +8876,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 @@ -8889,8 +8890,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 @@ -8908,13 +8909,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 @@ -10839,21 +10842,21 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* @param int|boolean $userRight User action right
* // phpcs:disable
* @param array $params = [ // Various params for future : recommended rather than adding more function arguments
* 'attr' => [ // to add or override button attributes
* 'xxxxx' => '', // your xxxxx attribute you want
* 'class' => 'reposition', // to add more css class to the button class attribute
* '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
* '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)
* ],
* ]
* 'attr' => [ // to add or override button attributes
* 'xxxxx' => '', // your xxxxx attribute you want
* 'class' => 'reposition', // to add more css class to the button class attribute
* 'classOverride' => '' // to replace class attribute of the button
* ],
* 'confirm' => [
* '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)
* ],
* ]
* // phpcs:enable
* @return string html button
*/
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 @@ -1410,12 +1410,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 @@ -1429,10 +1424,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
Loading

0 comments on commit 4aa0b80

Please sign in to comment.