Skip to content

Commit

Permalink
Merge branch 'Dolibarr:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JonBendtsen authored Nov 29, 2024
2 parents 232a049 + c73cff0 commit d735d0a
Show file tree
Hide file tree
Showing 138 changed files with 965 additions and 1,165 deletions.
446 changes: 1 addition & 445 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
61 changes: 42 additions & 19 deletions htdocs/accountancy/admin/subaccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@
$search_label = GETPOST('search_label', 'alpha');
$search_type = GETPOST('search_type', 'intcomma');

// Security check
if ($user->socid > 0) {
accessforbidden();
}
if (!$user->hasRight('accounting', 'chartofaccount')) {
accessforbidden();
}

// Load variable for pagination
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
Expand Down Expand Up @@ -92,6 +84,14 @@
unset($arrayfields['reconcilable']);
}

// Security check
if ($user->socid > 0) {
accessforbidden();
}
if (!$user->hasRight('accounting', 'chartofaccount')) { // after this test, $user->hasRight('accounting', 'chartofaccount') is always valid
accessforbidden();
}


/*
* Actions
Expand Down Expand Up @@ -124,6 +124,13 @@
$search_type = "";
$search_array_options = array();
}

if ($action == 'enable' /* && $user->hasRight('accounting', 'chartofaccount') */) { // test useless
setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors');
}
if ($action == 'disable' /* && $user->hasRight('accounting', 'chartofaccount') */) {
setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors');
}
}


Expand All @@ -142,7 +149,7 @@


// Customer
$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature";
$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity, sa.client as nature, sa.fournisseur as nature2";
$sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " WHERE sa.entity IN (".getEntity('societe').")";
$sql .= " AND sa.code_compta <> ''";
Expand All @@ -163,7 +170,6 @@
}
}

//var_dump($search_subaccount); exit;
if ($search_subaccount_tmp) {
if ($weremovedsomezero) {
$search_subaccount_tmp_clean = $search_subaccount_tmp;
Expand All @@ -190,7 +196,8 @@

// Supplier
$sql .= " UNION ";
$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, '0' as nature FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity, sa.client as nature, sa.fournisseur as nature2";
$sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " WHERE sa.entity IN (".getEntity('societe').")";
$sql .= " AND sa.code_compta_fournisseur <> ''";
//print $sql;
Expand Down Expand Up @@ -237,7 +244,8 @@

// User - Employee
$sql .= " UNION ";
$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature FROM ".MAIN_DB_PREFIX."user u";
$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity, '0' as nature, '0' as nature2";
$sql .= " FROM ".MAIN_DB_PREFIX."user u";
$sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.accountancy_code <> ''";
//print $sql;
Expand Down Expand Up @@ -368,7 +376,7 @@
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
}
if (!empty($arrayfields['type']['checked'])) {
print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer').' / '.$langs->trans("Prospect"), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
}
if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
if (!empty($arrayfields['reconcilable']['checked'])) {
Expand Down Expand Up @@ -409,12 +417,25 @@
}
print "</tr>\n";

$companystatic = new Societe($db);

$totalarray = array();
$totalarray['nbfield'] = 0;
$i = 0;
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);

if ($obj->type == 1) {
$companystatic->id = $obj->id;
$companystatic->client = $obj->nature;
$companystatic->fournisseur = 0;
}
if ($obj->type == 2) {
$companystatic->id = $obj->id;
$companystatic->client = 0;
$companystatic->fournisseur = $obj->nature2;
}

print '<tr class="oddeven">';

// Action column
Expand Down Expand Up @@ -466,7 +487,12 @@

// Customer
if ($obj->type == 1) {
$s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>';
$s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">';
$s .= $langs->trans("Customer");
$s .= '</a>';
if ($obj->nature == 2) {
$s .= ' <span class="warning">('.$langs->trans("Prospect").')</span>';
}
} elseif ($obj->type == 2) {
// Supplier
$s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
Expand All @@ -475,9 +501,6 @@
$s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->rowid.'">'.$langs->trans("Employee").'</a>';
}
print $s;
if ($obj->nature == 2) {
print ' <span class="warning bold">('.$langs->trans("Prospect").')</span>';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
Expand All @@ -489,11 +512,11 @@
if (!empty($arrayfields['reconcilable']['checked'])) {
print '<td class="center">';
if (empty($obj->reconcilable)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&token='.newToken().'">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&page='.$page.'&token='.newToken().'">';
print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a>';
} else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&token='.newToken().'">';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&page='.$page.'&token='.newToken().'">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a>';
}
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
16 changes: 10 additions & 6 deletions htdocs/adherents/admin/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
$res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity);
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
$res7 = dolibarr_set_const($db, 'MEMBER_PUBLIC_ENABLED', GETPOST('MEMBER_PUBLIC_ENABLED', 'alpha'), 'chaine', 0, '', $conf->entity);
if (GETPOSTISSET('MEMBER_PUBLIC_ENABLED')) {
$res7 = dolibarr_set_const($db, 'MEMBER_PUBLIC_ENABLED', GETPOST('MEMBER_PUBLIC_ENABLED', 'alpha'), 'chaine', 0, '', $conf->entity);
}
$res8 = dolibarr_set_const($db, 'MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF', GETPOST('MEMBER_SUBSCRIPTION_START_FIRST_DAY_OF', 'alpha'), 'chaine', 0, '', $conf->entity);
$res9 = dolibarr_set_const($db, 'MEMBER_SUBSCRIPTION_START_AFTER', GETPOST('MEMBER_SUBSCRIPTION_START_AFTER', 'alpha'), 'chaine', 0, '', $conf->entity);
// Use vat for invoice creation
Expand All @@ -138,7 +140,7 @@
$res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
}
}
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0) {
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0 || $res7 < 0 || $res8 < 0 || $res9 < 0) {
setEventMessages('ErrorFailedToSaveData', null, 'errors');
$db->rollback();
} else {
Expand Down Expand Up @@ -549,10 +551,12 @@
print "</td></tr>\n";

// Publish member information on public annuary
$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.((int) $conf->entity) : '');
print '<tr class="oddeven"><td>'.$langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).'</td><td>';
print $form->selectyesno('MEMBER_PUBLIC_ENABLED', getDolGlobalInt('MEMBER_PUBLIC_ENABLED'), 1, false, 0, 1);
print "</td></tr>\n";
/* Feature disabled by default for security purpose.
$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.((int) $conf->entity) : '');
print '<tr class="oddeven"><td>'.$langs->trans("Public", getDolGlobalString('MAIN_INFO_SOCIETE_NOM'), $linkofpubliclist).'</td><td>';
print $form->selectyesno('MEMBER_PUBLIC_ENABLED', getDolGlobalInt('MEMBER_PUBLIC_ENABLED'), 1, false, 0, 1);
print "</td></tr>\n";
*/

// Allow members to change type on renewal forms
/* To test during next beta
Expand Down
20 changes: 12 additions & 8 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 Expand Up @@ -3300,7 +3304,7 @@ public function getKanbanView($option = '', $arraydata = null)
$return .= '<div class="info-box info-box-sm">';
$return .= '<span class="info-box-icon bg-infobox-action">';
if (property_exists($this, 'photo') || !empty($this->photo)) {
$return .= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1);
$return .= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photowithmargin photologintooltip', 'small', 0, 1);
} else {
$return .= img_picto('', 'user');
}
Expand Down
2 changes: 2 additions & 0 deletions htdocs/adherents/stats/geo.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
//dol_mkdir($dir);
$data = array();
$tab = null;
$label = '';

if ($mode) {
// Define sql
Expand Down Expand Up @@ -263,6 +264,7 @@

// Show graphics
if (count($arrayjs) && $mode == 'memberbycountry') {
global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet;
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
if (is_readable($color_file)) {
include $color_file;
Expand Down
Loading

0 comments on commit d735d0a

Please sign in to comment.