Skip to content

Commit

Permalink
Merge branch 'develop' into fix_updatelines_propal
Browse files Browse the repository at this point in the history
  • Loading branch information
frederic34 authored Nov 28, 2024
2 parents 722fa49 + 286c3d1 commit 8a4ced4
Show file tree
Hide file tree
Showing 63 changed files with 358 additions and 690 deletions.
308 changes: 1 addition & 307 deletions build/phpstan/phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev/initdemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Init demo

The script `initdemo.sh` will erase the current database with data from `dev/initdemo/mysqldump_dolibarr_x.y.z.sql` and copy files from `documents_demo` to the official document directory.

You many to execute `chmod 700 initdemo.sh`
You may need to execute `chmod 700 initdemo.sh`
then run `./initdemo.sh` to launch the Graphical User Interface.

After loading the demo files, the admin login may be one of the following:
Expand Down
13 changes: 11 additions & 2 deletions dev/initdemo/initdemo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ then
fi


# ----------------------------- check if dialog available
command -v dialog >/dev/null 2>&1 || {
echo "Error: command dialog not found. On Linux, you can install it with: apt install dialog"
exit
}


# ----------------------------- if no params on command line
if [ "$passwd" = "" ]
then
Expand Down Expand Up @@ -179,17 +186,19 @@ fi
if [ "$passwd" != "" ]
then
export passwd="-p$passwd"
export passwdshown="-p*****"
fi
#echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile"
#mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
#echo "drop old table"
echo "drop table"
echo "drop table if exists llx_accounting_account;" | mysql "-P$port" "-u$admin" "$passwd" "$base"
echo "mysql -P$port -u$admin -p***** $base < '$mydir/$dumpfile'"
echo "mysql -P$port -u$admin $passwdshown $base < '$mydir/$dumpfile'"
mysql "-P$port" "-u$admin" "$passwd" "$base" < "$mydir/$dumpfile"
export res=$?

if [ $res -ne 0 ]; then
echo "Error to load database dump with mysql -P$port -u$admin -p***** $base < '$mydir/$dumpfile'"
echo "Error to load database dump with: mysql -P$port -u$admin $passwdshown $base < '$mydir/$dumpfile'"
exit
fi

Expand Down
10 changes: 6 additions & 4 deletions dev/setup/pre-commit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ the project: `pre-commit-config.yaml`.
If you do not have python installed, install [python](https://www.python.org) first.\
`sudo apt install python3`

If you do not have [`pip`](https://pypi.org/project/pip), install that as well.\\
`sudo apt install pip`
If you do not have [`pip`](https://pypi.org/project/pip), install that as well.\
`sudo apt install pip`

Then you can install pre-commit tool:
Then you can install pre-commit tool:\
`python3 -m pip install pre-commit`

2. In your local git clone of the project, run `pre-commit install` to add the hooks
Expand Down Expand Up @@ -96,4 +96,6 @@ CI also runs pre-commit to help maintain code quality.

Note:
Code for precommits are saved into:
.cache/pre-commit/repo*/py_env-python3/lib/python*/site-packages/pre_commit_hooks/no_commit_to_branch.py
.cache/pre-commit/repo.../pre_commit_hooks/php-....sh
and
.cache/pre-commit/repo.../py_env-python3/lib/python.../site-packages/pre_commit_hooks/no_commit_to_branch.py
2 changes: 1 addition & 1 deletion dev/tools/apstats.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@

$output_arrtd = array();
if ($dirphpstan != 'disabled') {
$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$PHPSTANLEVEL.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 8G --error-format=github -c ~/preview.dolibarr.org/dolibarr/phpstan.v1.neon';
$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$PHPSTANLEVEL.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 8G --error-format=github -c ~/preview.dolibarr.org/dolibarr/dev/tools/phpstan/phpstan_v1_apstats.neon';
print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n";
$resexectd = 0;
exec($commandcheck, $output_arrtd, $resexectd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ parameters:
treatPhpDocTypesAsCertain: false
ignoreErrors:
- '#.*phan-var#'
- '#is always#'
internalErrorsCountLimit: 50
cache:
nodesByFileCountMax: 512
Expand Down
1 change: 0 additions & 1 deletion dev/translation/ignore_translation_keys.lst
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@ NewProperty
NoActiveEstablishmentDefined
NoAddMember
NoAuthorityURLDefined
NoBankAccountFound
NoCurrencyRateSelected
NoEntriesToShow
NoEstablishmentFound
Expand Down
2 changes: 2 additions & 0 deletions htdocs/accountancy/bookkeeping/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@
$permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->hasRight('societe', 'creer');
$uploaddir = $conf->societe->dir_output;

global $error;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';

if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
Expand Down
2 changes: 2 additions & 0 deletions htdocs/accountancy/bookkeeping/listbyaccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@
$permissiontodelete = $user->hasRight('societe', 'supprimer');
$permissiontoadd = $user->hasRight('societe', 'creer');
$uploaddir = $conf->societe->dir_output;

global $error;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';

if (!$error && $action == 'deletebookkeepingwriting' && $confirm == "yes" && $user->hasRight('accounting', 'mouvements', 'supprimer')) {
Expand Down
4 changes: 2 additions & 2 deletions htdocs/accountancy/class/accountancycategory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* Copyright (C) 2016 Jamal Elbaz <[email protected]>
* Copyright (C) 2016-2017 Alexandre Spangaro <[email protected]>
* Copyright (C) 2018-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
*
* 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 @@ -129,7 +129,7 @@ class AccountancyCategory // extends CommonObject
public $sdc;

/**
* @var array Sum debit credit per month
* @var array<string,float> Sum debit credit per month
*/
public $sdcpermonth;

Expand Down
18 changes: 11 additions & 7 deletions htdocs/adherents/class/adherent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


/**
* Class to manage members of a foundation
* Class to manage members of a foundation.
*/
class Adherent extends CommonObject
{
Expand Down Expand Up @@ -829,7 +829,8 @@ public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass =
$sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest
$sql .= " WHERE rowid = ".((int) $this->id);

// If we change the type of membership, we set also label of new type
// If we change the type of membership, we set also label of new type..
'@phan-var-force Adherent $oldcopy';
if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) {
$sql2 = "SELECT libelle as label";
$sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type";
Expand Down Expand Up @@ -3104,11 +3105,14 @@ public function sendReminderForExpiredSubscription($daysbeforeendlist = '10', $f
$nbko++;
$listofmembersko[$adherent->id] = $adherent->id;
} else {
$adherent->fetch_thirdparty();

// Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company.
$languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
$languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
$thirdpartyres = $adherent->fetch_thirdparty();
if ($thirdpartyres === -1 ) {
$languagecodeformember = $mysoc->default_lang;
} else {
// Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company.
$languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
$languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
}

// Send reminder email
$outputlangs = new Translate('', $conf);
Expand Down
10 changes: 5 additions & 5 deletions htdocs/admin/mails.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

$usersignature = $user->signature;
// For action = test or send, we ensure that content is not html, even for signature, because for this we want a test with NO html.
if ($action == 'test' || ($action == 'send' && $trackid = 'test')) {
if ($action == 'test' || ($action == 'send' && $trackid == 'test')) {
$usersignature = dol_string_nohtmltag($usersignature, 2);
}

Expand Down Expand Up @@ -1003,7 +1003,7 @@ function change_smtp_auth_method() {

if (!getDolGlobalString('MAIN_DISABLE_ALL_MAILS')) {
if (getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail') != 'mail' || !$linuxlike) {
if (function_exists('fsockopen') && $port && $server) {
if (function_exists('fsockopen') /* && $port && $server */) { // $port and $server can't be empty
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect&token='.newToken().'&date='.dol_now().'#formmailaftertstconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
}
} else {
Expand Down Expand Up @@ -1044,19 +1044,19 @@ function change_smtp_auth_method() {
// mthode php mail
if (getDolGlobalString('MAIN_EXTERNAL_MAIL_SPF_STRING_TO_ADD')) { // Not defined by default. Depend on platform.
// List of string to add in SPF if the setup use the mail method. Example 'include:sendgrid.net include:spf.mydomain.com'
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPFDMARC");
$text .= /* ($text ? '<br><br>' : ''). */$langs->trans("WarningPHPMailSPFDMARC");
} else {
// MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS is list of IPs where email is sent from. Example: '1.2.3.4, [aaaa:bbbb:cccc:dddd]'.
if (getDolGlobalString('MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS')) {
// List of IP shown as record to add in SPF if we use the mail method
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPFDMARC");
$text .= /* ($text ? '<br><br>' : ''). */$langs->trans("WarningPHPMailSPFDMARC");
}
}
} else {
// method smtps or swiftmail
if (getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD')) { // Should be required only if you have preset the Dolibarr to use your own SMTP and you want to warn users to update their domain name to match your SMTP server.
// List of string to add in SPF if we use the smtp method. Example 'include:spf.mydomain.com'
$text .= ($text ? '<br><br>' : '').$langs->trans("WarningPHPMailSPF", getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
$text .= /* ($text ? '<br><br>' : ''). */$langs->trans("WarningPHPMailSPF", getDolGlobalString('MAIN_EXTERNAL_SMTP_SPF_STRING_TO_ADD'));
}
if (getDolGlobalString('MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS')) { // Not defined by default. Depend on platform.
// List of IP shown as record to add as allowed IP if we use the smtp method. Value is '1.2.3.4, [aaaa:bbbb:cccc:dddd]'
Expand Down
6 changes: 0 additions & 6 deletions htdocs/asset/class/asset.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,6 @@ class Asset extends CommonObject
*/
public $status;

/**
* @var static object oldcopy
*/
public $oldcopy;


/**
* @var AssetDepreciationOptions Used for computed fields of depreciation options class.
*/
Expand Down
4 changes: 2 additions & 2 deletions htdocs/comm/action/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist');

// Define list of all external calendars
$listofextcals = array();
// $listofextcals = array(); Not used yet in lists

$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
Expand Down Expand Up @@ -494,7 +494,7 @@
} else {
if (is_array($actioncode)) {
$sql .= " AND c.code IN (".$db->sanitize("'".implode("','", $actioncode)."'", 1).")";
} else {
} elseif ($actioncode !== '-1') {
$sql .= " AND c.code IN (".$db->sanitize("'".implode("','", explode(',', $actioncode))."'", 1).")";
}
}
Expand Down
5 changes: 0 additions & 5 deletions htdocs/comm/propal/class/propal.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,6 @@ class Propal extends CommonObject
*/
public $ref_customer;

/**
* @var static oldcopy with propal properties
*/
public $oldcopy;

/**
* Status of the quote
* @var int
Expand Down
1 change: 1 addition & 0 deletions htdocs/commande/class/commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ public function create($user, $notrigger = 0)
$this->fk_multicurrency = 0;
$this->multicurrency_tx = 1;
}
// setEntity will set entity with the right value if empty or change it for the right value if multicompany module is active
$this->entity = setEntity($this);

dol_syslog(get_class($this)."::create user=".$user->id);
Expand Down
9 changes: 0 additions & 9 deletions htdocs/compta/facture/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -4254,15 +4254,6 @@ function setRadioForTypeOfInvoice() {
* Show object in view mode
*/

$result = $object->fetch($id, $ref);
if ($result <= 0) {
dol_print_error($db, $object->error, $object->errors);
exit();
}

// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);

if ($user->socid > 0 && $user->socid != $object->socid) {
accessforbidden('', 0, 1);
}
Expand Down
5 changes: 0 additions & 5 deletions htdocs/compta/facture/class/facture.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,6 @@ class Facture extends CommonInvoice
*/
public $tab_next_situation_invoice = array();

/**
* @var static object oldcopy
*/
public $oldcopy;

/**
* @var float percentage of retainage
*/
Expand Down
1 change: 1 addition & 0 deletions htdocs/compta/facture/prelevement.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@
$title = $langs->trans("NewPaymentByBankTransfer");
}

print '<!-- form to select BAN -->';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="id" value="'.$object->id.'" />';
Expand Down
7 changes: 0 additions & 7 deletions htdocs/contact/class/contact.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,6 @@ class Contact extends CommonObject
public $ip;
// END MODULEBUILDER PROPERTIES


/**
* Old copy
* @var static
*/
public $oldcopy; // To contain a clone of this when we need to save old properties of object

/**
* @var array<int,array{id:int,socid:int,element:string,source:string,code:string,label:string}> roles
*/
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contact/perso.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

$result = $object->update_perso($id, $user);
if ($result > 0) {
$object->oldcopy = dol_clone($object, 2); // @phan-suppres-current-line PhanTypeMismatchProperty
$object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty

// Logo/Photo save
$dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos';
Expand Down
3 changes: 3 additions & 0 deletions htdocs/core/actions_dellink.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
foreach ($addlinkids as $addlinkid) {
$result = $object->add_object_linked($addlink, $addlinkid);
}
$object->clearObjectLinkedCache();
}

// Link by reference
Expand All @@ -69,6 +70,7 @@
if (isset($_POST['reftolinkto'])) {
unset($_POST['reftolinkto']);
}
$object->clearObjectLinkedCache();
} elseif ($ret < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
} else {
Expand All @@ -81,6 +83,7 @@
// Delete link in table llx_element_element
if ($action == 'dellink' && !empty($permissiondellink) && !$cancellink && $dellinkid > 0) {
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
$object->clearObjectLinkedCache();
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
Expand Down
1 change: 1 addition & 0 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* @var string $objectclass
* @var string $uploaddir
* @var string $confirm
* @var int $error
*/
'
@phan-var-force ?string $permissiontoread
Expand Down
5 changes: 0 additions & 5 deletions htdocs/core/class/comment.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ class Comment extends CommonObject

public $comments = array();

/**
* @var static Object oldcopy
*/
public $oldcopy;


/**
* Constructor
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/commonobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ abstract class CommonObject
public $multicurrency_total_localtax2; // not in database

/**
* @var string
* @var ?string
* @see SetDocModel()
*/
public $model_pdf;
Expand Down
Loading

0 comments on commit 8a4ced4

Please sign in to comment.