Skip to content

Commit

Permalink
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
eldy committed Jul 5, 2024
2 parents 1d4e076 + e7f694c commit ea54a8a
Show file tree
Hide file tree
Showing 84 changed files with 434 additions and 228 deletions.
13 changes: 10 additions & 3 deletions dev/tools/rector/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@
__DIR__ . '/../../../scripts/',
__DIR__ . '/../../../test/phpunit/',
]);

$rectorConfig->skip([
'**/includes/**',
'**/custom/**',
'**/vendor/**',
'**/rector/**', // Disable this line to test the "test.php" file.
__DIR__ . '/../../../htdocs/custom/',
__DIR__ . '/../../../htdocs/install/doctemplates/*'
//'test.php',
]);
$rectorConfig->parallel(240);

Expand All @@ -70,9 +72,9 @@

//$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);


$rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
//Not yet ready: $rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class);
$rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);

Expand All @@ -82,11 +84,16 @@
$rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class);
//$rectorConfig->rule(Dolibarr\Rector\Renaming\UsePositiveExit::class);


// This fix <> into != but it breaks other rules, so added at end.
$rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);


// Add all predefined rules to migrate to up to php 71.
// Warning this break tab spacing of arrays on several lines
/*$rectorConfig->sets([
LevelSetList::UP_TO_PHP_70
]);*/
LevelSetList::UP_TO_PHP_70
]);*/
// Add predefined rules for a given version only
//$rectorConfig->import(SetList::PHP_70);
//$rectorConfig->import(SetList::PHP_71);
Expand Down
41 changes: 23 additions & 18 deletions dev/tools/rector/src/Renaming/GlobalToFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public function getRuleDefinition(): RuleDefinition
[new CodeSample(
'$conf->global->CONSTANT',
'getDolGlobalInt(\'CONSTANT\')'
)]
);
)]
);
}

/**
Expand Down Expand Up @@ -133,7 +133,7 @@ public function refactor(Node $node)
$node->dim = new FuncCall(
new Name('getDolGlobalString'),
[new Arg($constName)]
);
);
}
return $node;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ public function refactor(Node $node)
$leftConcat = new FuncCall(
new Name('getDolGlobalString'),
[new Arg($constName)]
);
);
$rightConcat = $node->right;
}
if ($this->isGlobalVar($node->right)) {
Expand All @@ -219,7 +219,7 @@ public function refactor(Node $node)
$rightConcat = new FuncCall(
new Name('getDolGlobalString'),
[new Arg($constName)]
);
);
$leftConcat = $node->left;
}
if (!isset($leftConcat, $rightConcat)) {
Expand All @@ -238,6 +238,7 @@ public function refactor(Node $node)
$node = $nodes->getFirstExpr();
}


// Now process all comparison like:
// $conf->global->... Operator Value

Expand All @@ -264,11 +265,14 @@ public function refactor(Node $node)
$typeofcomparison = 'NotIdentical';
//var_dump($node->left);
}

if (empty($typeofcomparison)) {
return;
}

if (!$this->isGlobalVar($node->left)) {
$isconfglobal = $this->isGlobalVar($node->left);
if (!$isconfglobal) {
// The left side is not conf->global->xxx, so we leave
return;
}

Expand All @@ -282,7 +286,8 @@ public function refactor(Node $node)
$funcName = 'getDolGlobalString';
break;
default:
return;
$funcName = 'getDolGlobalString';
break;
}

$constName = $this->getConstName($node->left);
Expand All @@ -295,9 +300,9 @@ public function refactor(Node $node)
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'NotEqual') {
return new NotEqual(
Expand All @@ -313,36 +318,36 @@ public function refactor(Node $node)
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'GreaterOrEqual') {
return new GreaterOrEqual(
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'Smaller') {
return new Smaller(
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'SmallerOrEqual') {
return new SmallerOrEqual(
new FuncCall(
new Name($funcName),
[new Arg($constName)]
),
),
$node->right
);
);
}
if ($typeofcomparison == 'NotIdentical') {
return new NotIdentical(
Expand Down Expand Up @@ -382,7 +387,7 @@ function (Node $node): bool {
}
return \true;
}
);
);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions htdocs/adherents/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -36,6 +36,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
Expand Down Expand Up @@ -1453,7 +1454,7 @@ function initfieldrequired() {
*/
$head = member_prepare_head($object);

print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user', 0, '', '', 0, '', 1);

// Confirm create user
if ($action == 'create_user') {
Expand Down
59 changes: 40 additions & 19 deletions htdocs/admin/dict.php
Original file line number Diff line number Diff line change
Expand Up @@ -1837,8 +1837,8 @@
}

// Active
print '<td class="liste_titre center">';
print $form->selectyesno('search_active', $search_active, 0, false, 1);
print '<td class="liste_titre center parentonrightofpage">';
print $form->selectyesno('search_active', $search_active, 0, false, 1, 1, 'maxwidth100 onrightofpage', 'Activated', 'Disabled');
print '</td>';
$colspan++;

Expand All @@ -1855,6 +1855,7 @@

print '</tr>';


// Title of lines
print '<!-- line title of record -->'."\n";
print '<tr class="liste_titre">';
Expand Down Expand Up @@ -2115,21 +2116,23 @@
}
// Favorite & EEC - Only activated on country dictionary
if ($id == DICT_COUNTRY) {
print getTitleFieldOfList($langs->trans("InEEC"), 0, $_SERVER["PHP_SELF"], "eec", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder, '', 0, $langs->trans("CountryIsInEEC"));
print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans("InEEC"), 0, $_SERVER["PHP_SELF"], "eec", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans("CountryIsInEEC"));
print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');
}

// Status
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder);
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center ');

// Action button
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
print getTitleFieldOfList('');
}
print '</tr>';


// Lines with values
if ($num) {
// Lines with values
print '<!-- lines of dict -->'."\n";
while ($i < $num) {
$obj = $db->fetch_object($resql);

Expand All @@ -2147,7 +2150,7 @@
$iserasable = 1;
$canbedisabled = 1;
$canbemodified = 1;
if (isset($obj->code) && $id != 10 && $id != 42) {
if (isset($obj->code) && $id != DICT_TVA && $id != DICT_PRODUCT_NATURE) {
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
$iserasable = 0;
$canbedisabled = 0;
Expand Down Expand Up @@ -2193,14 +2196,15 @@
if (empty($rowidcol) || in_array($id, array(DICT_ACTIONCOMM, DICT_CHARGESOCIALES, DICT_TYPENT, DICT_PAIEMENT, DICT_TYPE_FEES, DICT_EFFECTIF, DICT_STCOMM, DICT_HRM_PUBLIC_HOLIDAY))) {
$rowidcol = 'rowid';
}
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder;
$url .= '&rowid='.(isset($obj->$rowidcol) ? $obj->$rowidcol : (!empty($obj->code) ? urlencode($obj->code) : ''));
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder);
$url .= '&rowid='.(isset($obj->$rowidcol) ? ((int) $obj->$rowidcol) : (!empty($obj->code) ? urlencode($obj->code) : ''));
$url .= '&code='.(!empty($obj->code) ? urlencode($obj->code) : '');
if (!empty($param)) {
$url .= '&'.$param;
}
// If dictionary is different for each entity
if (!is_null($withentity)) {
$url .= '&entity='.$withentity;
$url .= '&entity='.((int) $withentity);
}
$url .= '&';

Expand Down Expand Up @@ -2254,6 +2258,8 @@
$error = $hookmanager->error;
$errors = $hookmanager->errors;

$langs->loadLangs(array("bills", "agenda", "propal"));

if (empty($reshook)) {
$withentity = null;

Expand Down Expand Up @@ -2300,15 +2306,13 @@
if ($value == 'private') {
$valuetoshow = yn($valuetoshow);
} elseif ($value == 'libelle_facture') {
$langs->load("bills");
$key = $langs->trans("PaymentCondition".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value);
$valuetoshow = nl2br($valuetoshow);
} elseif ($value == 'label' && $tabname[$id] == 'c_country') {
$key = $langs->trans("Country".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value);
} elseif ($value == 'label' && $tabname[$id] == 'c_availability') {
$langs->load("propal");
$key = $langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->$value);
} elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') {
Expand All @@ -2327,17 +2331,22 @@
$key = $langs->trans("Civility".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->$value);
} elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') {
$langs->load('agenda');
$key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->$value);
} elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') {
$langs->load("bills");
$key = $langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value);
} elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') {
$langs->load("bills");
$transavailableforcode = $langs->tab_translate["PaymentType".strtoupper($obj->code)];
$key = $langs->trans("PaymentType".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->$value);
$valuetoshow = $obj->$value;
if ($obj->code && $transavailableforcode) {
$htmltext = $form->textwithpicto($langs->trans("TranslationFound").': '.$key, $langs->trans("TheTranslationIsSearchedFromKey", "PaymentType".strtoupper($obj->code)));
} else {
$htmltext = $form->textwithpicto($langs->trans("TranslationFound").': '.$langs->trans("No"), $langs->trans("TheTranslationIsSearchedFromKey", "PaymentType".strtoupper($obj->code)));
}
//$valuetoshow = $form->textwithpicto($valuetoshow, $htmltext);
$valuetoshow .= '<br><span class="opacitymedium">'.$htmltext.'</span>';
} elseif ($value == 'type' && $tabname[$id] == 'c_paiement') {
$payment_type_list = array(0 => $langs->trans('PaymentTypeCustomer'), 1 => $langs->trans('PaymentTypeSupplier'), 2 => $langs->trans('PaymentTypeBoth'));
$valuetoshow = $payment_type_list[$valuetoshow];
Expand Down Expand Up @@ -2442,6 +2451,9 @@
}
}
$class .= ($class ? ' ' : '').'tddict';
if ($value == 'name') {
$class .= ' tdoverflowmax200';
}
if ($value == 'note' && $id == DICT_TVA) {
$class .= ' tdoverflowmax200';
}
Expand All @@ -2462,7 +2474,7 @@
}
// Show value for field
if ($showfield) {
print '<!-- '. $value .' --><td class="'.$class.'"'.($titletoshow ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>'.$valuetoshow.'</td>';
print '<!-- '. $value .' --><td class="'.$class.'"'.($titletoshow ? ' title="'.dolPrintHTMLForAttribute($titletoshow).'"' : '').'>'.$valuetoshow.'</td>';
}
}

Expand Down Expand Up @@ -2623,7 +2635,7 @@
*/
function fieldList($fieldlist, $obj = null, $tabname = '', $context = '')
{
global $conf, $langs, $db, $mysoc;
global $langs, $db, $mysoc;
global $form;
global $region_id;
global $elementList, $sourceList, $localtax_typeList, $type_vatList;
Expand All @@ -2641,6 +2653,7 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '')
}

if (in_array($value, array('code', 'libelle', 'type')) && $tabname == "c_actioncomm" && isset($obj->$value) && in_array($obj->type, array('system', 'systemauto'))) {
// Special case for c_actioncomm (field that should not be modified)
$hidden = (!empty($obj->{$value}) ? $obj->{$value} : '');
print '<td>';
print '<input type="hidden" name="'. $value .'" value="'.$hidden.'">';
Expand Down Expand Up @@ -2756,7 +2769,15 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '')
} elseif ($value == 'price' || preg_match('/^amount/i', $value)) {
print '<td><input type="text" class="flat minwidth75" value="'.price((!empty($obj->{$value}) ? $obj->{$value} : '')).'" name="'. $value .'"></td>';
} elseif ($value == 'code' && isset($obj->{$value})) {
print '<td><input type="text" class="flat minwidth75 maxwidth100" value="'.(!empty($obj->{$value}) ? $obj->{$value} : '').'" name="'. $value .'"></td>';
print '<td>';
if ($tabname == 'c_paiement' && in_array($obj->{$value}, array('LIQ', 'CB', 'CHQ', 'VIR'))) {
// Case of code that should not be modified
print '<input type="hidden" class="flat minwidth75 maxwidth100" value="'.(!empty($obj->{$value}) ? $obj->{$value} : '').'" name="'. $value .'">';
print $obj->{$value};
} else {
print '<input type="text" class="flat minwidth75 maxwidth100" value="'.(!empty($obj->{$value}) ? $obj->{$value} : '').'" name="'. $value .'">';
}
print '</td>';
} elseif ($value == 'unit') {
print '<td>';
$units = array(
Expand Down
Loading

0 comments on commit ea54a8a

Please sign in to comment.