Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
ldestailleur 2025-07-09 17:57:48 +02:00
commit daa4968077
102 changed files with 659 additions and 2002 deletions

View file

@ -1854,12 +1854,6 @@ parameters:
count: 2
path: ../../../htdocs/api/class/api_documents.class.php
-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 1
path: ../../../htdocs/api/class/api_documents.class.php
-
message: '#^Variable \$disablevirusscan in empty\(\) always exists and is always falsy\.$#'
identifier: empty.variable
@ -3822,24 +3816,6 @@ parameters:
count: 1
path: ../../../htdocs/commande/contact.php
-
message: '#^Variable \$addu might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/commande/customer.php
-
message: '#^Variable \$begin might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../../htdocs/commande/customer.php
-
message: '#^Variable \$maxlen might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/commande/customer.php
-
message: '#^Variable \$socid might not be defined\.$#'
identifier: variable.undefined
@ -9396,54 +9372,6 @@ parameters:
count: 1
path: ../../../htdocs/core/lib/files.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_cdup expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_chdir expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_close expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_delete expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_get expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_mkdir expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_put expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Parameter \#1 \$ftp of function ftp_rmdir expects FTP\\Connection, resource given\.$#'
identifier: argument.type
count: 1
path: ../../../htdocs/core/lib/ftp.lib.php
-
message: '#^Call to function is_array\(\) with array\<string, mixed\> will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -9540,36 +9468,6 @@ parameters:
count: 1
path: ../../../htdocs/core/lib/functions.lib.php
-
message: '#^Property CommonObject\:\:\$firstname \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/core/lib/functions.lib.php
-
message: '#^Property CommonObject\:\:\$id \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/core/lib/functions.lib.php
-
message: '#^Property CommonObject\:\:\$lastname \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/core/lib/functions.lib.php
-
message: '#^Property CommonObject\:\:\$multicurrency_code \(array\<string\>\|string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/core/lib/functions.lib.php
-
message: '#^Property CommonObject\:\:\$multicurrency_total_ttc \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 3
path: ../../../htdocs/core/lib/functions.lib.php
-
message: '#^Result of && is always true\.$#'
identifier: booleanAnd.alwaysTrue
@ -10698,12 +10596,6 @@ parameters:
count: 2
path: ../../../htdocs/core/modules/member/doc/pdf_standard_member.class.php
-
message: '#^Property Adherent\:\:\$photo \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/core/modules/member/doc/pdf_standard_member.class.php
-
message: '#^Property DolibarrModules\:\:\$import_convertvalue_array \(array\<array\<array\{rule\: string, file\: string, class\: string, method\: string\}\>\>\) does not accept non\-empty\-array\<array\<array\{rule\: ''accountingaccount''\}\|array\{rule\: ''compute'', type\: ''double'', classfile\: ''/accountancy/class…'', class\: ''AccountancyImport'', method\: ''cleanAmount''\|''computeAmount'', element\: ''Accountancy''\}\|array\{rule\: ''compute'', type\: ''int'', classfile\: ''/accountancy/class…'', class\: ''AccountancyImport'', method\: ''computePieceNum'', element\: ''Accountancy''\}\|array\{rule\: ''compute'', type\: ''varchar'', classfile\: ''/accountancy/class…'', class\: ''AccountancyImport'', method\: ''computeDirection'', element\: ''Accountancy''\}\|array\{rule\: string, file\: string, class\: string, method\: string\}\>\>\.$#'
identifier: assign.propertyType
@ -18642,78 +18534,6 @@ parameters:
count: 1
path: ../../../htdocs/product/stock/massstockmove.php
-
message: '#^Negated boolean expression is always false\.$#'
identifier: booleanNot.alwaysFalse
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Property Product\:\:\$pmp \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$backtopage might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$comref might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$contextpage in empty\(\) always exists and is not falsy\.$#'
identifier: empty.variable
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$d_eatby might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$d_sellby might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$massaction might not be defined\.$#'
identifier: variable.undefined
count: 4
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$obj might not be defined\.$#'
identifier: variable.undefined
count: 3
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$sall might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$toselect might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Variable \$totalarray might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_card.php
-
message: '#^Loose comparison using \=\= between 1 and 2 will always evaluate to false\.$#'
identifier: equal.alwaysFalse
@ -18732,12 +18552,6 @@ parameters:
count: 2
path: ../../../htdocs/product/stock/movement_list.php
-
message: '#^Property Product\:\:\$pmp \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/product/stock/movement_list.php
-
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse
@ -18750,18 +18564,6 @@ parameters:
count: 1
path: ../../../htdocs/product/stock/movement_list.php
-
message: '#^Variable \$d_eatby might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_list.php
-
message: '#^Variable \$d_sellby might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/product/stock/movement_list.php
-
message: '#^Variable \$diroutputmassaction in empty\(\) always exists and is not falsy\.$#'
identifier: empty.variable
@ -18804,12 +18606,6 @@ parameters:
count: 1
path: ../../../htdocs/product/stock/product.php
-
message: '#^Property Product\:\:\$pmp \(float\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/product/stock/product.php
-
message: '#^Variable \$sortfield might not be defined\.$#'
identifier: variable.undefined
@ -20040,12 +19836,6 @@ parameters:
count: 1
path: ../../../htdocs/public/members/new.php
-
message: '#^Property Adherent\:\:\$photo \(string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
count: 1
path: ../../../htdocs/public/members/public_card.php
-
message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
@ -20196,12 +19986,6 @@ parameters:
count: 1
path: ../../../htdocs/public/payment/paymentok.php
-
message: '#^Variable \$service might not be defined\.$#'
identifier: variable.undefined
count: 7
path: ../../../htdocs/public/payment/paymentok.php
-
message: '#^Call to function is_numeric\(\) with int will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType

View file

@ -9,24 +9,24 @@
*/
return [
// # Issue statistics:
// PhanUndeclaredProperty : 450+ occurrences
// PhanUndeclaredProperty : 440+ occurrences
// PhanTypeMismatchProperty : 100+ occurrences
// PhanTypeMismatchArgument : 90+ occurrences
// PhanUndeclaredGlobalVariable : 90+ occurrences
// PhanTypeMismatchArgument : 85+ occurrences
// PhanTypeMismatchArgumentNullable : 30+ occurrences
// PhanTypeExpectedObjectPropAccess : 20+ occurrences
// PhanTypeInvalidDimOffset : 20+ occurrences
// PhanTypeMismatchDimFetch : 15+ occurrences
// PhanUndeclaredConstant : 15+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 10+ occurrences
// PhanTypeMismatchArgumentProbablyReal : 9 occurrences
// PhanUndeclaredMethod : 9 occurrences
// PhanPossiblyUndeclaredGlobalVariable : 6 occurrences
// PhanTypeArraySuspiciousNull : 6 occurrences
// PhanTypeComparisonFromArray : 6 occurrences
// PhanPluginDuplicateExpressionBinaryOp : 5 occurrences
// PhanPluginUndeclaredVariableIsset : 5 occurrences
// PhanParamTooMany : 4 occurrences
// PhanPluginDuplicateArrayKey : 4 occurrences
// PhanPluginDuplicateExpressionBinaryOp : 4 occurrences
// PhanTypeMismatchDimAssignment : 2 occurrences
// PhanTypeMismatchReturn : 2 occurrences
// PhanTypeSuspiciousStringExpression : 2 occurrences
@ -36,12 +36,7 @@ return [
// Currently, file_suppressions and directory_suppressions are the only supported suppressions
'file_suppressions' => [
'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
'htdocs/adherents/list.php' => ['PhanUndeclaredGlobalVariable'],
'htdocs/admin/agenda_other.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/admin/bom.php' => ['PhanTypeMismatchArgument'],
'htdocs/admin/defaultvalues.php' => ['PhanTypeMismatchArgumentProbablyReal'],
'htdocs/api/class/api_documents.class.php' => ['PhanPluginDuplicateExpressionBinaryOp'],
'htdocs/accountancy/class/accountancyexport.class.php' => ['PhanTypeMismatchArgument'],
'htdocs/api/class/api_setup.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchReturn'],
'htdocs/asset/class/asset.class.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanTypeInvalidDimOffset'],
'htdocs/asset/class/assetdepreciationoptions.class.php' => ['PhanTypeInvalidDimOffset'],
@ -336,9 +331,6 @@ return [
'htdocs/webservices/server_thirdparty.php' => ['PhanUndeclaredProperty'],
'htdocs/webservices/server_user.php' => ['PhanUndeclaredProperty'],
'htdocs/website/websiteaccount_card.php' => ['PhanUndeclaredProperty'],
'htdocs/workstation/class/workstation.class.php' => ['PhanUndeclaredProperty'],
'htdocs/workstation/workstation_card.php' => ['PhanUndeclaredProperty'],
'htdocs/zapier/class/hook.class.php' => ['PhanUndeclaredProperty'],
'internal' => ['PhanUndeclaredConstant'],
],
// 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed.

View file

@ -1193,7 +1193,7 @@ class BookKeeping extends CommonObject
// Manage filter
if (is_array($filter)) { // deprecated, use $filter = USF syntax
dol_syslog("You are using a deprecated use of fetchAll. filter parameter mus be an USF string now.", LOG_WARNING);
dol_syslog("You are using a deprecated use of fetchAll. filter parameter must be an USF string now.", LOG_WARNING);
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {

View file

@ -5,7 +5,7 @@
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2022 Open-DSI <support@open-dsi.fr>
* Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2017-2025 Frédéric France <frederic.france@free.fr>
@ -673,7 +673,7 @@ if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'b
$accountingaccountpayment->fetch(0, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
$accountingaccountexpensereport = new AccountingAccount($db);
$accountingaccountexpensereport->fetch(0, $conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT, true);
$accountingaccountexpensereport->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
$accountingaccountsuspense = new AccountingAccount($db);
$accountingaccountsuspense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);

View file

@ -70,12 +70,12 @@ class Adherent extends CommonObject
public $mesgs;
/**
* @var string login of member
* @var ?string login of member
*/
public $login;
/**
* @var string Clear password in memory
* @var ?string Clear password in memory
*/
public $pass;
@ -186,7 +186,7 @@ class Adherent extends CommonObject
public $default_lang;
/**
* @var string photo of member
* @var ?string photo of member
*/
public $photo;
@ -225,7 +225,7 @@ class Adherent extends CommonObject
public $typeid;
/**
* @var string label type member
* @var ?string label type member
*/
public $type;
@ -536,6 +536,10 @@ class Adherent extends CommonObject
global $langs;
$birthday = dol_print_date($this->birth, 'day');
$photo = isset($this->photo) ? $this->photo : '';
$login = isset($this->login) ? $this->login : '';
$type = isset($this->type) ? $this->type : '';
$pass = isset($this->pass) ? $this->pass : '';
$msgishtml = 0;
if (dol_textishtml($text, 1)) {
@ -560,11 +564,11 @@ class Adherent extends CommonObject
$infos .= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n";
$infos .= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n";
if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
$infos .= $langs->transnoentities("Login").": ".$this->login."\n";
$infos .= $langs->transnoentities("Password").": ".$this->pass."\n";
$infos .= $langs->transnoentities("Login").": ".$login."\n";
$infos .= $langs->transnoentities("Password").": ".$pass."\n";
}
$infos .= $langs->transnoentities("Birthday").": ".$birthday."\n";
$infos .= $langs->transnoentities("Photo").": ".$this->photo."\n";
$infos .= $langs->transnoentities("Photo").": ".$photo."\n";
$infos .= $langs->transnoentities("Public").": ".yn($this->public);
// Substitutions
@ -583,13 +587,13 @@ class Adherent extends CommonObject
'__COUNTRY__' => $msgishtml ? dol_htmlentitiesbr($this->country) : ($this->country ? $this->country : ''),
'__EMAIL__' => $msgishtml ? dol_htmlentitiesbr((string) $this->email) : ($this->email ? $this->email : ''),
'__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''),
'__PHOTO__' => $msgishtml ? dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo : ''),
'__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($this->login) : ($this->login ? $this->login : ''),
'__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass : ''),
'__PHOTO__' => $msgishtml ? dol_htmlentitiesbr($photo) : $photo,
'__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($login) : $login,
'__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($pass) : $pass,
'__PHONE__' => $msgishtml ? dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''),
'__PHONEPRO__' => $msgishtml ? dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''),
'__PHONEMOBILE__' => $msgishtml ? dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : ''),
'__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '')
'__TYPE__' => $msgishtml ? dol_htmlentitiesbr($type) : $type,
);
complete_substitutions_array($substitutionarray, $langs, $this);
@ -956,9 +960,6 @@ class Adherent extends CommonObject
$result = $luser->fetch($this->user_id);
if ($result >= 0) {
//var_dump($this->user_login);exit;
//var_dump($this->login);exit;
// If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one.
if (!getDolGlobalString('ADHERENT_LOGIN_NOT_REQUIRED')) {
$luser->login = $this->login;
@ -969,7 +970,7 @@ class Adherent extends CommonObject
$luser->firstname = $this->firstname;
$luser->lastname = $this->lastname;
$luser->gender = $this->gender;
$luser->pass = $this->pass;
$luser->pass = isset($this->pass) ? $this->pass : '';
//$luser->socid=$this->fk_soc; // We do not enable this. This may transform a user into an external user.
$luser->birth = $this->birth;
@ -1776,7 +1777,7 @@ class Adherent extends CommonObject
* @param string $emetteur_banque Name of bank of cheque
* @param int $autocreatethirdparty Auto create new thirdparty if member not yet linked to a thirdparty and we request an option that generate invoice.
* @param string $ext_payment_id External id of payment (for example Stripe charge id)
* @param string $ext_payment_site Name of external paymentmode (for example 'stripe')
* @param string $ext_payment_site Name of external paymentmode (for example 'StripeLive', 'StripeTest', 'paypal', ...)
* @return int Return integer <0 if KO, >0 if OK
*/
public function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0, $ext_payment_id = '', $ext_payment_site = '')
@ -2463,7 +2464,7 @@ class Adherent extends CommonObject
($morecss ? ' usertext'.$morecss : '').'">';
}
if ($mode == 'login') {
$result .= dol_trunc($this->login, $maxlen);
$result .= dol_trunc(isset($this->login) ? $this->login : '', $maxlen);
} elseif ($mode == 'ref') {
$result .= $this->ref;
} else {

View file

@ -292,7 +292,7 @@ while ($i <= $MAXAGENDA) {
print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ' . $key . '" value="' . (GETPOST('AGENDA_EXT_OFFSETTZ' . $key) ? GETPOST('AGENDA_EXT_OFFSETTZ' . $key) : getDolGlobalString($offsettz)) . '" size="2"></td>';
// Color (Possible colors are limited by Google)
print '<td class="nowraponall right">';
print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR" . $key) ? GETPOST("AGENDA_EXT_COLOR" . $key) : getDolGlobalString($color)), "AGENDA_EXT_COLOR" . $key, 'extsitesconfig', 1, array(), 'hideifnotset');
print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR" . $key) ? GETPOST("AGENDA_EXT_COLOR" . $key) : getDolGlobalString($color)), "AGENDA_EXT_COLOR" . $key, '', 1, array(), 'hideifnotset');
print '</td>';
// Calendar active by default
print '<td class="nowrap right">';

View file

@ -478,7 +478,7 @@ if (getDolGlobalInt('BANK_COLORIZE_MOVEMENT')) {
print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
// Color
print '<td class="nowrap right">';
print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ? GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : getDolGlobalString($color)), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, array(), 'right hideifnotset');
print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ? GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : getDolGlobalString($color)), "BANK_COLORIZE_MOVEMENT_COLOR".$key, '', 1, array(), 'right hideifnotset');
print '</td>';
print "</tr>";
$i++;

View file

@ -778,8 +778,8 @@ class ExternalModules
}
}
if (!empty($request['response']['curl_error_msg'])) {
$error_message .= ' - ' . $request['response']['curl_error_msg'];
if (!empty($request['curl_error_msg'])) {
$error_message .= ' - ' . $request['curl_error_msg'];
}
// Return the formatted error message

View file

@ -363,15 +363,22 @@ if ($mode == 'overwrite') {
$disablededit = ' disabled';
}
$infoOnTransProcess = '<div class="justify"><span class="opacitymedium">';
$infoOnTransProcess .= img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
$text = $langs->trans("SomeTranslationAreUncomplete");
$urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation';
$infoOnTransProcess .= ' ('.str_replace('{s1}', '<a href="'.$urlwikitranslatordoc.'" target="_blank" rel="noopener noreferrer external">'.$langs->trans("Here").'</a>', $langs->trans("SeeAlso", '{s1}')).')<br>';
$infoOnTransProcess .= '<br>';
$text .= ' - <a href="'.$urlwikitranslatordoc.'" target="_blank" rel="noopener noreferrer external">'.$langs->trans("SeeAlso", $langs->transnoentitiesnoconv("Here")).' '.img_picto('', 'url').'</a>.<br>';
$infoOnTransProcess = info_admin($text);
$infoOnTransProcess .= '<div class="justify">';
$infoOnTransProcess .= '<span class="opacitymedium">';
$infoOnTransProcess .= $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("TranslationKey"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
$infoOnTransProcess .= ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
$infoOnTransProcess .= '</span></div>';
// If a cache for translation is on, show a warning.
if (isModEnabled('memcached') || getDolGlobalInt('MAIN_USE_CACHE_FOR_TRANSLATION')) {
$infoOnTransProcess .= info_admin($langs->trans("CacheForTranslationIsUsed"), 0, 0, '1', 'warning');
}
print $infoOnTransProcess;
print '<br>';

View file

@ -124,7 +124,7 @@ class DolibarrApiAccess implements iAuthenticate
$api_key = preg_replace('/^Bearer\s+/i', '', empty($headers['Authorization']) ? '' : $headers['Authorization']);
};
$api_key = dol_string_nounprintableascii($api_key);
$api_key = dol_string_nounprintableascii($api_key, 1);
if (preg_match('/^dolcrypt:/i', $api_key)) {
throw new RestException(503, 'Bad value for the API key. An API key should not start with dolcrypt:');

View file

@ -116,7 +116,7 @@ class Boms extends DolibarrApi
$obj_ret = array();
$tmpobject = new BOM($this->db);
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$socid = DolibarrApiAccess::$user->socid ?: '';
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View file

@ -1442,16 +1442,20 @@ class BOM extends CommonObject
$this->error = $tmpproduct->error;
return -1;
}
$unit_cost = (!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp;
$line->unit_cost = (float) price2num($unit_cost);
if (empty($line->unit_cost)) {
$unit_cost = (float) (is_null($tmpproduct->cost_price) ? $tmpproduct->pmp : $tmpproduct->cost_price);
if (empty($unit_cost)) { // @phpstan-ignore-line phpstan thinks this is always false. No,if unit_cost is 0, it is not.
if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) {
if ($productFournisseur->fourn_remise_percent != "0") {
$line->unit_cost = $productFournisseur->fourn_unitprice_with_discount;
} else {
$line->unit_cost = $productFournisseur->fourn_unitprice;
}
} else {
$line->unit_cost = 0;
}
} else {
$line->unit_cost = (float) price2num($unit_cost);
}
$line->total_cost = (float) price2num($line->qty * $line->unit_cost, 'MT');

View file

@ -130,7 +130,7 @@ class AgendaEvents extends DolibarrApi
}
// case of external user
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -525,7 +525,7 @@ if (empty($reshook)) {
$object->contact_id = GETPOSTINT('contactid');
$object->fk_project = GETPOSTINT('projectid');
$object->model_pdf = GETPOST('model', 'alphanohtml');
$object->author = $user->id; // deprecated
$object->author = $user; // deprecated
$object->user_author_id = $user->id;
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
@ -555,7 +555,8 @@ if (empty($reshook)) {
$object->contact_id = GETPOSTINT('contactid');
$object->fk_project = GETPOSTINT('projectid');
$object->model_pdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->author = $user; // deprecated
$object->user_author_id = $user->id;
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
$object->fk_incoterms = GETPOSTINT('incoterm_id');

View file

@ -193,7 +193,7 @@ class Proposals extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -197,6 +197,7 @@ class Propal extends CommonObject
/**
* @var User user identified by user_author_id
* @deprecated Set only $user_author_id
*/
public $author;

View file

@ -2978,7 +2978,7 @@ if ($action == 'create' && $usercancreate) {
print '<table class="nobordernopadding centpercent"><tr><td>';
print $form->textwithpicto($langs->trans('PointOfSale'), $langs->trans('POSInfo'));
print '</td>';
if ($action != 'editposinfo' && $object->status == $object::STATUS_DRAFT && $usercancreate) {
if ($action != 'editposinfo' && $usercancreate) {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editposinfo&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetPOSInfo'), 1).'</a></td>';
}
print '</tr></table>';

View file

@ -186,7 +186,7 @@ class Orders extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -80,13 +80,9 @@ if (!$sortfield) {
llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-commande page-customer');
$thirdpartystatic = new Societe($db);
// Mode List
/*
* Mode List
*/
$sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec, s.datea,";
$sql = "SELECT s.rowid, s.nom as name, s.client, s.town, s.datec,";
$sql .= " st.libelle as stcomm, s.prefix_comm, s.code_client, s.code_compta as code_compta_client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st, ".MAIN_DB_PREFIX."commande as c";
$sql .= " WHERE s.fk_stcomm = st.id AND c.fk_soc = s.rowid";
@ -100,9 +96,6 @@ if (GETPOST("search_compta")) {
if (GETPOST("search_code_client")) {
$sql .= natural_search("s.code_client", GETPOST("search_code_client"));
}
if (dol_strlen($begin)) {
$sql .= " AND s.nom LIKE '".$db->escape($begin)."'";
}
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!$user->hasRight('societe', 'client', 'voir')) {
@ -121,7 +114,7 @@ if ($socid) {
$sql .= " AND c.fk_soc = ".((int) $socid);
}
$sql .= " AND c.fk_statut in (1, 2) AND c.facture = 0";
$sql .= " GROUP BY s.nom";
$sql .= " GROUP BY s.nom, s.rowid";
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
@ -155,7 +148,7 @@ if ($resql) {
print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "s.town", "", "", 'valign="center"', $sortfield, $sortorder);
print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", "", 'align="left"', $sortfield, $sortorder);
print_liste_field_titre("AccountancyCode", $_SERVER["PHP_SELF"], "s.code_compta", "", "", 'align="left"', $sortfield, $sortorder);
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", $addu, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "datec", "", "", 'class="right"', $sortfield, $sortorder);
print "</tr>\n";
// Fields title search
@ -184,7 +177,7 @@ if ($resql) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>';
print '<td class="tdoverflowmax150">';
$result = '';
$link = $linkend = '';
@ -192,7 +185,7 @@ if ($resql) {
$linkend = '</a>';
$name = $obj->name;
$result .= ($link.img_object($langs->trans("ShowCompany").': '.$name, 'company').$linkend);
$result .= $link.(dol_trunc($name, $maxlen)).$linkend;
$result .= $link.$name.$linkend;
print $result;
print '</td>';

View file

@ -5251,7 +5251,7 @@ if ($action == 'create') {
print '<table class="nobordernopadding centpercent"><tr><td>';
print $form->textwithpicto($langs->trans('PointOfSale'), $langs->trans('POSInfo'));
print '</td>';
if ($action != 'editposinfo' && $object->status == $object::STATUS_DRAFT && $usercancreate) {
if ($action != 'editposinfo' && $usercancreate) {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editposinfo&token='.newToken().'&facid='.$object->id.'">'.img_edit($langs->trans('SetPOSInfo'), 1).'</a></td>';
}
print '</tr></table>';

View file

@ -203,7 +203,7 @@ class Invoices extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -213,7 +213,7 @@ class Facture extends CommonInvoice
public $situation_cycle_ref;
/**
* @var int Situation counter inside the cycle
* @var ?int Situation counter inside the cycle
*/
public $situation_counter;
@ -1080,7 +1080,7 @@ class Facture extends CommonInvoice
0,
$fk_parent_line,
$fk_product_fournisseur_price,
$buyprice,
is_null($buyprice) ? '' : $buyprice, // do not use (float) here, it may be ''
$_facrec->lines[$i]->label,
empty($_facrec->lines[$i]->array_options) ? null : $_facrec->lines[$i]->array_options,
100, // situation percent is undefined on recurring invoice lines

View file

@ -170,11 +170,6 @@ class Paiement extends CommonObject
*/
public $num_payment;
/**
* @var string Id of external payment mode
*/
public $ext_payment_id;
/**
* @var int Id of prelevement
*/
@ -186,7 +181,12 @@ class Paiement extends CommonObject
public $num_prelevement;
/**
* @var string Name of external payment mode
* @var string Id of external payment mode (With Stripe: 'pi_xxx:cus_ccc@pk_ppp', ...)
*/
public $ext_payment_id;
/**
* @var string Name of external payment mode ('StripeLive', 'StripeTest', 'stripe' on old version, 'paypal', ...)
*/
public $ext_payment_site;

View file

@ -80,8 +80,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'inclu
$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
$type = $object->type;
// check if salary pl
// Check if salary or invoice
$salaryBonPl = $object->checkIfSalaryBonPrelevement();
// Security check
if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'paymentbybanktransfer', '', '', '');
@ -99,7 +102,6 @@ if ($type == 'bank-transfer') {
}
/*
* Actions
*/
@ -197,7 +199,6 @@ if (empty($reshook)) {
}
/*
* View
*/

View file

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2025 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -46,7 +46,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
*/
// Load translation files required by the page
$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills'));
$langs->loadLangs(array("banks", "categories", "companies", 'withdrawals', 'bills'));
// Security check
if ($user->socid > 0) {
@ -76,6 +76,9 @@ $object = new BonPrelevement($db);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
// Check if salary or invoice
$salaryBonPl = $object->checkIfSalaryBonPrelevement();
// Security check
if ($user->socid > 0) {
accessforbidden();
@ -89,7 +92,6 @@ if ($type == 'bank-transfer') {
}
/*
* View
*/
@ -225,11 +227,8 @@ $sql .= " WHERE p.rowid=".((int) $object->id);
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND p.entity IN (".getEntity('facture').")";
$sql .= " AND pl.fk_soc = s.rowid";
$sql .= " AND pl.statut = 3 ";
$sql .= " AND pl.statut = 3";
$sql .= " AND pr.fk_prelevement_lignes = pl.rowid";
/*if ($socid) {
$sql .= " AND s.rowid = ".((int) $socid);
}*/
$sql .= " ORDER BY pl.amount DESC";
// Count total nb of records
@ -252,16 +251,20 @@ if ($resql) {
// @phan-suppress-next-line PhanPluginSuspiciousParamOrder
print_barre_liste($langs->trans("Rejects"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
$param = '&id='.((int) $object->id);
print"\n<!-- debut table -->\n";
print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Line").'</td><td>'.$langs->trans("ThirdParty").'</td><td class="right">'.$langs->trans("Amount").'</td>';
print '<td>'.$langs->trans("Reason").'</td><td align="center">'.$langs->trans("ToBill").'</td>';
print '<td class="center">';
print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "pl.rowid", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre((!$salaryBonPl ? "ThirdParty" : "Employee"), $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", '', $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Reason", $_SERVER["PHP_SELF"], "pr.motif", '', $param, '', $sortfield, $sortorder);
print_liste_field_titre("ToBill", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("");
// Invoice to charge the error. No yet implemented.
//print $langs->trans("Invoice");
print '</td>';
print '</tr>';
$total = 0;

View file

@ -845,7 +845,7 @@ if ($limit > 0 && $limit != $conf->liste_limit) {
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
$param .= '&begin='.urlencode((string) ($begin)).'&userid='.urlencode((string) ($userid)).'&contactname='.urlencode((string) ($search_all));
$param .= '&userid='.urlencode((string) $userid).'&contactname='.urlencode((string) $search_all);
$param .= '&type='.urlencode($type).'&view='.urlencode($view);
if (!empty($search_sale) && $search_sale != '-1') {
$param .= '&search_sale='.urlencode($search_sale);

View file

@ -114,7 +114,7 @@ class Contracts extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -149,10 +149,7 @@ $hookmanager->initHooks(array('contractlist'));
$result = restrictedArea($user, 'contrat', $id);
$diroutputmassaction = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id;
$staticcontrat = new Contrat($db);
$staticcontratligne = new ContratLigne($db);
$diroutputmassaction = $conf->contract->dir_output.'/temp/massgeneration/'.$user->id;
if ($search_status == '') {
$search_status = 1;
@ -161,6 +158,7 @@ if ($search_status == '') {
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$object = new Contrat($db);
$extrafields = new ExtraFields($db);
$staticcontratligne = new ContratLigne($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
@ -252,7 +250,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_town = '';
$search_zip = "";
$search_state = "";
$search_type = '';
$search_type_thirdparty = '';
$search_country = '';
$search_contract = "";
$search_ref_customer = "";
@ -288,7 +286,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
$search_status = "";
$search_signed_status = '';
$toselect = array();
$search_type_thirdparty = '';
$searchCategoryCustomerList = array();
$search_array_options = array();
}
@ -296,7 +293,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (empty($reshook)) {
$objectclass = 'Contrat';
$objectlabel = 'Contracts';
$uploaddir = $conf->contrat->dir_output;
$uploaddir = $conf->contract->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -343,11 +340,11 @@ $sql = preg_replace('/,\s*$/', '', $sql);
$sqlfields = $sql; // $sql fields to remove for count total
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (c.fk_soc = s.rowid)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)";
$sql .= ", ".MAIN_DB_PREFIX."contrat as c";
if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (c.rowid = ef.fk_object)";
}
@ -356,8 +353,11 @@ if ($search_user > 0) {
$sql .= ", ".MAIN_DB_PREFIX."element_contact as ec";
$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
}
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= ' AND c.entity IN ('.getEntity('contract').')';
// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " WHERE c.entity IN (".getEntity('contract').")";
if ($search_type_thirdparty != '' && $search_type_thirdparty > 0) {
$sql .= " AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).')';
}
@ -394,9 +394,6 @@ if ($search_town) {
if ($search_country && $search_country != '-1') {
$sql .= " AND s.fk_pays IN (".$db->sanitize($search_country).')';
}
/*if ($search_sale > 0) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
}*/
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}

View file

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -102,7 +103,7 @@ if ($action == "getCategories") {
}
*/
foreach ($cate_arbo as $categ) {
$response[] = array('id' => $categ['id'], 'label' => $categ['label'], 'fulllabel' => $categ['fulllabel'], 'htmlforoption' => dolPrintHTML($categ['fulllabel']), 'htmlforattribute' => dolPrintHTMLForAttribute($categ['data-html']), 'color' => $categ['color']);
$response[] = array('id' => $categ['id'], 'label' => $categ['label'], 'fulllabel' => $categ['fulllabel'], 'htmlforoption' => dolPrintHTML((string) $categ['fulllabel']), 'htmlforattribute' => dolPrintHTMLForAttribute((string) $categ['data-html']), 'color' => $categ['color']);
}
$response =json_encode($response);
echo $response;

View file

@ -91,6 +91,8 @@ trait CommonIncoterm
*/
public function getIncotermsForPDF()
{
global $langs;
$sql = "SELECT code FROM ".$this->db->prefix()."c_incoterms WHERE rowid = ".(int) $this->fk_incoterms;
$resql = $this->db->query($sql);
if ($resql) {
@ -98,7 +100,7 @@ trait CommonIncoterm
if ($num > 0) {
$res = $this->db->fetch_object($resql);
if ($res) {
return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
return $langs->trans("IncotermLabel").': '.$res->code.' - '.$this->location_incoterms;
} else {
return $res;
}

View file

@ -9773,7 +9773,7 @@ abstract class CommonObject
* @param float $unitPrice Product unit price
* @param float $discountPercent Line discount percent
* @param int $fk_product Product id
* @return float|int<-1,-1> Return buy price if OK, integer <0 if KO
* @return float|int<-2,-1> Return buy price if OK, integer <0 if KO
*/
public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0)
{
@ -9826,7 +9826,8 @@ abstract class CommonObject
}
}
}
return $buyPrice;
return (float) $buyPrice;
}
/**

View file

@ -1293,7 +1293,7 @@ class Conf extends stdClass
$this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com/api/';
}
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
$this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
$this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorepublicapi';
}
// Enable by default the CSRF protection by token.

View file

@ -1,5 +1,4 @@
<?php
/* Copyright (c) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
@ -5823,7 +5822,7 @@ class Form
* @param int<0,1> $include [=0] Removed or 1=Keep only
* @param string $morecss More CSS
* @param int<0,2> $useempty 0=No empty value, 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. Default is 1.
* @return string|array<int,string>|array<int,array{id:int,fulllabel:string,color:string,picto:string}>|array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string}> String list or Array of categories
* @return string|array<int,string>|array<int,array{id:int,fulllabel:string,data-html?:string,color:string,picto:string}>|array<int,array{rowid:int,id:int,fk_parent:int,label:string,description:string,color:string,position:string,visible:int,ref_ext:string,picto:string,fullpath:string,fulllabel:string,data-html?:string}> String list or Array of categories
* @see select_categories()
*/
public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $fromid = 0, $outputmode = 0, $include = 0, $morecss = '', $useempty = 1)
@ -10821,18 +10820,18 @@ class Form
/**
* Return HTML code to output a photo
*
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param Societe|Adherent|Contact|User|CommonObject $object Object containing data to retrieve file name
* @param int $width Width of photo
* @param int $height Height of photo (auto if 0)
* @param int<0,1> $caneditfield Add edit fields
* @param string $cssclass CSS name to use on img for photo
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int<0,1> $addlinktofullsize Add link to fullsize image
* @param int<0,1> $cache 1=Accept to use image in cache
* @param ''|'user'|'environment' $forcecapture '', 'user' or 'environment'. Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param int<0,1> $noexternsourceoverwrite No overwrite image with extern source (like 'gravatar' or other module)
* @return string HTML code to output photo
* @param int $width Width of photo
* @param int $height Height of photo (auto if 0)
* @param int<0,1> $caneditfield Add edit fields
* @param string $cssclass CSS name to use on img for photo
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int<0,1> $addlinktofullsize Add link to fullsize image
* @param int<0,1> $cache 1=Accept to use image in cache
* @param ''|'user'|'environment' $forcecapture '', 'user' (user-facing camera) or 'environment' ('outward-facing camera'). Force the parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param int<0,1> $noexternsourceoverwrite No overwrite image with extern source (like 'gravatar' or other module)
* @return string HTML code to output photo
* @see getImagePublicURLOfObject()
*/
public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass = 'photowithmargin', $imagesize = '', $addlinktofullsize = 1, $cache = 0, $forcecapture = '', $noexternsourceoverwrite = 0)
@ -11010,7 +11009,7 @@ class Form
if ($maxmin > 0) {
$ret .= '<input type="hidden" name="MAX_FILE_SIZE" value="' . ($maxmin * 1024) . '">'; // MAX_FILE_SIZE must precede the field type=file
}
$ret .= '<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ? ' capture="' . $capture . '"' : '') . '>';
$ret .= '<input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput" accept="image/*"' . ($capture ? ' capture="' . dolPrintHTMLForAttribute($capture) . '"' : '') . '>';
$ret .= '</td></tr>';
$ret .= '</table>';
}

View file

@ -1575,7 +1575,7 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab
*/
function activateModulesRequiredByCountry($country_code)
{
global $db, $conf, $langs;
global $db;
$modulesdir = dolGetModulesDirs();
@ -1736,8 +1736,8 @@ function complete_elementList_with_modules(&$elementList)
/**
* Show array with constants to edit
*
* @param array<string,array{type:string,label:string}>|array<int,string> $tableau Array of constants array('key'=>array('type'=>type, 'label'=>label)
* where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ...
* @param array<string,array{type:string,label:string,tooltip?:string}>|array<int,string> $tableau Array of constants array('key'=>array('type'=>type, 'label'=>label, 'tooltip'=>tooltip)
* where type can be 'string', 'text', 'textarea', 'html', 'yesno', 'emailtemplate:xxx', ...
* @param int<2,3> $strictw3c 0=Include form into table (deprecated), 1=Form is outside table to respect W3C (deprecated), 2=No form nor button at all, 3=No form nor button at all and each field has a unique name (form is output by caller, recommended) (typed as int<2,3> to highlight the deprecated values)
* @param string $helptext Tooltip help to use for the column name of values
* @param string $text Text to use for the column name of values

View file

@ -1657,7 +1657,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
// Photo - Name
if (!empty($arrayfields['t.name']['checked'])) {
print '<td class="tdoverflowmax150">';
print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, '1');
print $form->showphoto('contact', $contactstatic, 0, 0, 0, 'photorefnoborder valignmiddle marginrightonly', 'small', 1, 0, 'user');
print $contactstatic->getNomUrl(0, '', 0, '&backtopage='.urlencode($backtopage));
print '</td>';
}

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2022-2023 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2022-2025 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2022 Anthony Berton <bertonanthony@gmail.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
@ -122,9 +122,9 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
/**
* Tell if an entry is a FTP directory
*
* @param resource $connect_id Connection handler
* @param string $dir Directory
* @return int 1=directory, 0=not a directory
* @param resource|FTP\Connection $connect_id Connection handler
* @param string $dir Directory
* @return int 1=directory, 0=not a directory
*/
function ftp_isdir($connect_id, $dir)
{
@ -139,13 +139,11 @@ function ftp_isdir($connect_id, $dir)
/**
* Tell if an entry is a FTP directory
*
* @param resource $connect_id Connection handler
* @return boolean Result of closing
* @param resource|FTP\Connection $connect_id Connection handler
* @return boolean Result of closing
*/
function dol_ftp_close($connect_id)
{
global $conf;
// Close FTP connection
if ($connect_id) {
if (!getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
@ -158,21 +156,18 @@ function dol_ftp_close($connect_id)
/**
* Delete a FTP file
*
* @param resource $connect_id Connection handler
* @param string $file File
* @param string $newsection $newsection
* @param resource|FTP\Connection $connect_id Connection handler
* @param string $file File
* @param string $newsection Directory
* @return bool
*/
function dol_ftp_delete($connect_id, $file, $newsection)
{
global $conf;
if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
@ -188,22 +183,19 @@ function dol_ftp_delete($connect_id, $file, $newsection)
/**
* Download a FTP file
*
* @param resource $connect_id Connection handler
* @param string $localfile The local file path
* @param string $file The remote file path
* @param string $newsection $newsection
* @param resource|FTP\Connection $connect_id Connection handler
* @param string $localfile The local file path
* @param string $file The remote file path
* @param string $newsection Directory
* @return bool|resource
*/
function dol_ftp_get($connect_id, $localfile, $file, $newsection)
{
global $conf;
if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
@ -217,22 +209,19 @@ function dol_ftp_get($connect_id, $localfile, $file, $newsection)
/**
* Upload a FTP file
*
* @param resource $connect_id Connection handler
* @param string $file File name
* @param string $localfile The path to the local file
* @param string $newsection $newsection
* @param resource|FTP\Connection $connect_id Connection handler
* @param string $file File name
* @param string $localfile The path to the local file
* @param string $newsection Directory
* @return bool
*/
function dol_ftp_put($connect_id, $file, $localfile, $newsection)
{
global $conf;
if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
@ -246,21 +235,18 @@ function dol_ftp_put($connect_id, $file, $localfile, $newsection)
/**
* Remove FTP directory
*
* @param resource $connect_id Connection handler
* @param string $file File
* @param string $newsection $newsection
* @param resource|FTP\Connection $connect_id Connection handler
* @param string $file File
* @param string $newsection Directory
* @return bool
*/
function dol_ftp_rmdir($connect_id, $file, $newsection)
{
global $conf;
if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
// Remote file
$filename = $file;
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
$newremotefileiso = mb_convert_encoding($remotefile, 'ISO-8859-1');
@ -275,15 +261,13 @@ function dol_ftp_rmdir($connect_id, $file, $newsection)
/**
* Remove FTP directory
*
* @param resource $connect_id Connection handler
* @param string $newdir Dir create
* @param string $newsection $newsection
* @param resource|FTP\Connection $connect_id Connection handler
* @param string $newdir Dir create
* @param string $newsection Directory
* @return bool|string
*/
function dol_ftp_mkdir($connect_id, $newdir, $newsection)
{
global $conf;
if (getDolGlobalString('FTP_CONNECT_WITH_SFTP')) {
$newsection = ssh2_sftp_realpath($connect_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}

View file

@ -1996,7 +1996,7 @@ function dol_string_nounprintableascii($str, $removetabcrlf = 1)
}
/**
* Returns text slugified (no special char, separator is "-".
* Returns text slugified (lowercase and no special char, separator is "-").
*
* @param string $stringtoslugify String to slugify
* @return string Slugified string
@ -6514,7 +6514,7 @@ function print_liste_field_titre($name, $file = "", $field = "", $begin = "", $m
* @param int<0,2> $thead 0=To use with standard table format, 1=To use inside <thead><tr>, 2=To use with <div>
* @param string $file Url used when we click on sort picto
* @param string $field Field to use for new sorting. Empty if this field is not sortable. Example "t.abc" or "t.abc,t.def"
* @param string $begin ("" by default)
* @param string $begin ("" by default)
* @param string $moreparam Add more parameters on sort url links ("" by default)
* @param string $moreattrib Add more attributes on th ("" by default). To add more css class, use param $prefix.
* @param ?string $sortfield Current field used to sort (Ex: 'd.datep,d.id')
@ -6588,8 +6588,8 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin
}
}
$sortordertouseinlink = preg_replace('/,$/', '', $sortordertouseinlink);
$out .= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder='.$sortordertouseinlink.'&begin='.$begin.$options.'"';
//$out .= (empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : '');
$out .= '<a class="reposition" href="'.$file.'?sortfield='.urlencode($field).'&sortorder='.urlencode($sortordertouseinlink).'&begin='.urlencode($begin).$options.'"';
//$out .= (getDolGlobalString('MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE') ? '' : ' title="'.dol_escape_htmltag($langs->trans($name)).'"');
$out .= '>';
}
if ($tooltip) {
@ -6617,17 +6617,12 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin
}
if (!$sortorder || ($field1 != $sortfield1)) {
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
// Nothing
} else {
if (preg_match('/^DESC/', $sortorder)) {
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
$sortimg .= '<span class="nowrap">'.img_up("Z-A", 0, 'paddingright').'</span>';
}
if (preg_match('/^ASC/', $sortorder)) {
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
//$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
$sortimg .= '<span class="nowrap">'.img_down("A-Z", 0, 'paddingright').'</span>';
}
}
@ -7058,7 +7053,7 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0,
* Function to format a value into an amount for visual output
* Function used into PDF and HTML pages
*
* @param string|float $amount Amount value to format
* @param int|float|string|null $amount Amount value to format
* @param int<0,1> $form Type of formatting: 1=HTML, 0=no formatting (no by default)
* @param Translate|string|null $outlangs Object langs for output. '' use default lang. 'none' use international separators.
* @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accuracy) before being inserted into database or after a computation, so this parameter should be useless.
@ -7178,7 +7173,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* Function to use on each input amount before any numeric test or database insert. A better name for this function
* should be roundtext2num().
*
* @param string|float $amount Amount to convert/clean or round
* @param int|float|string|null $amount Amount to convert/clean or round
* @param ''|'MU'|'MT'|'MS'|'CU'|'CT'|int<0,max> $rounding ''=No rounding
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
@ -9428,6 +9423,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
} else {
'@phan-var-force Adherent|Delivery $object';
/** @var Adherent|Delivery $object */
$substitutionarray['__ID__'] = $object->id;
$substitutionarray['__REF__'] = $object->ref;
$substitutionarray['__NEWREF__'] = $object->newref;
@ -9468,6 +9464,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && ($object->element == 'adherent' || $object->element == 'member') && $object->id > 0) {
'@phan-var-force Adherent $object';
/** @var Adherent $object */
$birthday = (empty($object->birth) ? '' : dol_print_date($object->birth, 'day'));
$substitutionarray['__MEMBER_ID__'] = (isset($object->id) ? $object->id : '');
@ -9566,12 +9563,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'recruitmentcandidature') {
'@phan-var-force RecruitmentCandidature $object';
/** @var RecruitmentCandidature $object */
$substitutionarray['__CANDIDATE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__CANDIDATE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__CANDIDATE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
}
if (is_object($object) && $object->element == 'conferenceorboothattendee') {
'@phan-var-force ConferenceOrBoothAttendee $object';
/** ConferenceOrBoothAttendee $object */
$substitutionarray['__ATTENDEE_FULLNAME__'] = $object->getFullName($outputlangs);
$substitutionarray['__ATTENDEE_FIRSTNAME__'] = isset($object->firstname) ? $object->firstname : '';
$substitutionarray['__ATTENDEE_LASTNAME__'] = isset($object->lastname) ? $object->lastname : '';
@ -9579,6 +9578,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'project') {
'@phan-var-force Project $object';
/** @var Project $object */
$substitutionarray['__PROJECT_ID__'] = $object->id;
$substitutionarray['__PROJECT_REF__'] = $object->ref;
$substitutionarray['__PROJECT_NAME__'] = $object->title;
@ -9612,22 +9612,26 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'facture') {
'@phan-var-force Facture $object';
/** @var Facture $object */
$substitutionarray['__INVOICE_SITUATION_NUMBER__'] = isset($object->situation_counter) ? $object->situation_counter : '';
}
if (is_object($object) && $object->element == 'shipping') {
'@phan-var-force Expedition $object';
/** @var Expedition $object */
$substitutionarray['__SHIPPINGTRACKNUM__'] = $object->tracking_number;
$substitutionarray['__SHIPPINGTRACKNUMURL__'] = $object->tracking_url;
$substitutionarray['__SHIPPINGMETHOD__'] = $object->shipping_method;
}
if (is_object($object) && $object->element == 'reception') {
'@phan-var-force Reception $object';
/** @var Reception $object */
$substitutionarray['__RECEPTIONTRACKNUM__'] = $object->tracking_number;
$substitutionarray['__RECEPTIONTRACKNUMURL__'] = $object->tracking_url;
}
if (is_object($object) && $object->element == 'contrat' && $object->id > 0 && is_array($object->lines)) {
'@phan-var-force Contrat $object';
/** @var Contrat $object */
$dateplannedstart = '';
$datenextexpiration = '';
foreach ($object->lines as $line) {
@ -9649,6 +9653,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
// add substitution variables for ticket
if (is_object($object) && $object->element == 'ticket') {
'@phan-var-force Ticket $object';
/** @var Ticket $object */
$substitutionarray['__TICKET_TRACKID__'] = $object->track_id;
$substitutionarray['__TICKET_SUBJECT__'] = $object->subject;
$substitutionarray['__TICKET_TYPE__'] = $object->type_code;
@ -9779,46 +9784,55 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
if (is_object($object) && $object->element == 'propal') {
'@phan-var-force Propal $object';
/** @var Propal $object */
$substitutionarray['__URL_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/comm/propal/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'commande') {
'@phan-var-force Commande $object';
/** @var Commande $object */
$substitutionarray['__URL_ORDER__'] = DOL_MAIN_URL_ROOT."/commande/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'facture') {
'@phan-var-force Facture $object';
/** @var Facture $object */
$substitutionarray['__URL_INVOICE__'] = DOL_MAIN_URL_ROOT."/compta/facture/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'contrat') {
'@phan-var-force Contrat $object';
/** @var Contrat $object */
$substitutionarray['__URL_CONTRACT__'] = DOL_MAIN_URL_ROOT."/contrat/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'contract', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'fichinter') {
'@phan-var-force Fichinter $object';
/** @var Fichinter $object */
$substitutionarray['__URL_FICHINTER__'] = DOL_MAIN_URL_ROOT."/fichinter/card.php?id=".$object->id;
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
$substitutionarray['__ONLINE_SIGN_FICHINTER_URL__'] = getOnlineSignatureUrl(0, 'fichinter', $object->ref, 1, $object);
}
if (is_object($object) && $object->element == 'supplier_proposal') {
'@phan-var-force SupplierProposal $object';
/** @var SupplierProposal $object */
$substitutionarray['__URL_SUPPLIER_PROPOSAL__'] = DOL_MAIN_URL_ROOT."/supplier_proposal/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'invoice_supplier') {
'@phan-var-force FactureFournisseur $object';
/** @var FactureFournisseur $object */
$substitutionarray['__URL_SUPPLIER_INVOICE__'] = DOL_MAIN_URL_ROOT."/fourn/facture/card.php?id=".$object->id;
}
if (is_object($object) && $object->element == 'shipping') {
'@phan-var-force Expedition $object';
/** @var Expedition $object */
$substitutionarray['__URL_SHIPMENT__'] = DOL_MAIN_URL_ROOT."/expedition/card.php?id=".$object->id;
}
}
if (is_object($object) && $object->element == 'action') {
'@phan-var-force ActionComm $object';
/** @var ActionComm $object */
$substitutionarray['__EVENT_LABEL__'] = $object->label;
$substitutionarray['__EVENT_TYPE__'] = $outputlangs->trans("Action".$object->type_code);
$substitutionarray['__EVENT_DATE__'] = dol_print_date($object->datep, 'day', 'auto', $outputlangs);
@ -9828,6 +9842,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
}
if ((empty($exclude) || !in_array('objectamount', $exclude)) && (empty($include) || in_array('objectamount', $include))) {
'@phan-var-force Facture|FactureRec $object';
/** @var Facture|FactureRec|null $object */
include_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
$substitutionarray['__DATE_YMD__'] = is_object($object) ? (isset($object->date) ? dol_print_date($object->date, 'day', false, $outputlangs) : null) : '';
@ -9926,6 +9941,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
'__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])),
'__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort'.sprintf("%02d", $tmp['mon'])),
'__YEAR__' => (string) $tmp['year'],
'__YEAR_PREVIOUS_MONTH__' => (string) $tmp3['year'],
'__YEAR_NEXT_MONTH__' => (string) $tmp5['year'],
'__PREVIOUS_DAY__' => (string) $tmp2['day'],
'__PREVIOUS_MONTH__' => (string) $tmp3['month'],
'__PREVIOUS_MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp3['month'])),

View file

@ -178,7 +178,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
do {
if ($maxRedirection < 1) {
break;
return array('http_code' => 400, 'content' => 'Maximum number of redirections reached', 'curl_error_no' => 1, 'curl_error_msg' => 'Maximum number of redirections reached');
}
curl_setopt($ch, CURLOPT_URL, $newUrl);
@ -192,7 +192,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
if (in_array($hosttocheck, array('metadata.google.internal'))) {
$info['http_code'] = 400;
$info['content'] = 'Error bad hostname '.$hosttocheck.' (Used by Google metadata). This value for hostname is not allowed.';
break;
return array('http_code' => 400, 'content' => $info['content'], 'curl_error_no' => 1, 'curl_error_msg' => $info['content']);
}
// Clean host name $hosttocheck to convert it into an IP $iptocheck
@ -220,7 +220,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation =
if ($tmpresult) {
$info['http_code'] = 400;
$info['content'] = $tmpresult;
break;
return array('http_code' => 400, 'content' => $tmpresult, 'curl_error_no' => 1, 'curl_error_msg' => $tmpresult);
}
}

View file

@ -121,7 +121,7 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit
return false;
}
// Step 3: retrieve user info using token
// Step 3: retrieve user info (login, email, ...) from OIDC server using token
$userinfo_headers = array('Authorization: Bearer '.$token_content->access_token);
$userinfo_response = getURLContent(getDolGlobalString('MAIN_AUTHENTICATION_OIDC_USERINFO_URL'), 'GET', '', 1, $userinfo_headers, array('https'), 2);
$userinfo_content = json_decode($userinfo_response['content']);
@ -159,7 +159,12 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit
// Success: retrieve claim to return to Dolibarr as login
$sql = 'SELECT login, entity, datestartvalidity, dateendvalidity';
$sql .= ' FROM '.MAIN_DB_PREFIX.'user';
$sql .= " WHERE login = '".$db->escape($userinfo_content->$login_claim)."'";
if ($login_claim === 'email') {
// If login claim is email, check both login and email fields
$sql .= " WHERE (login = '".$db->escape($userinfo_content->$login_claim)."' OR email = '".$db->escape($userinfo_content->$login_claim)."')";
} else {
$sql .= " WHERE login = '".$db->escape($userinfo_content->$login_claim)."'";
}
$sql .= ' AND entity IN (0,'.(array_key_exists('dol_entity', $_SESSION) ? ((int) $_SESSION["dol_entity"]) : 1).')';
dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG);
@ -169,6 +174,11 @@ function check_user_password_openid_connect($usertotest, $passwordtotest, $entit
dol_syslog("functions_openid_connect::check_user_password_openid_connect::Error with sql query (".$db->error().")");
return false;
}
$numres = $db->num_rows($resql);
if ($numres > 1) {
dol_syslog("functions_openid_connect::check_user_password_openid_connect::Error more than 1 result from the query");
return false;
}
$obj = $db->fetch_object($resql);
if (!$obj) {
dol_syslog("functions_openid_connect::check_user_password_openid_connect::Error no result from the query");

View file

@ -95,7 +95,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
*/
public function info($langs)
{
global $conf, $langs;
global $langs;
// Load traductions files required by page
$langs->loadLangs(array("companies", "errors"));

View file

@ -71,7 +71,7 @@ class InterfaceEventOrganization extends DolibarrTriggers
*/
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
if (empty($conf->eventorganization) || empty($conf->eventorganization->enabled)) {
if (!isModEnabled('eventorganization')) {
return 0; // Module not active, we do nothing
}

View file

@ -65,7 +65,7 @@ class InterfaceTicketEmail extends DolibarrTriggers
$ok = 0;
if (empty($conf->ticket) || !isModEnabled('ticket')) {
if (!isModEnabled('ticket')) {
return 0; // Module not active, we do nothing
}

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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
@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/datapolicy/lib/datapolicy.lib.php';
*/
// Translations
$langs->loadLangs(array('admin', 'companies', 'members', 'datapolicy'));
$langs->loadLangs(array('admin', 'companies', 'cron', 'members', 'datapolicy'));
// Parameters
$action = GETPOST('action', 'aZ09');

View file

@ -110,7 +110,7 @@ class Donations extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids)) {

View file

@ -87,6 +87,8 @@ if (!$sortfield) {
$search_all = trim(GETPOST('search_all', 'alphanohtml'));
$object = new Don($db);
$morejs = array();
$morecss = array();
@ -163,7 +165,6 @@ if (empty($reshook)) {
*/
$form = new Form($db);
$donationstatic = new Don($db);
$companystatic = new Societe($db);
$bankline = new AccountLine($db);
$accountstatic = new Account($db);
@ -471,7 +472,7 @@ if (!empty($arrayfields['c.code']['checked'])) {
$totalarray['nbfield']++;
}
if (!empty($arrayfields['pd.num_paiement']['checked'])) {
print_liste_field_titre($arrayfields['pd.num_paiement']['label'], $_SERVER["PHP_SELF"], "pd.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['p.num_paiement']['tooltip']);
print_liste_field_titre($arrayfields['pd.num_paiement']['label'], $_SERVER["PHP_SELF"], "pd.num_payment", '', $param, '', $sortfield, $sortorder, '', $arrayfields['pd.num_paiement']['tooltip']);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['transaction']['checked'])) {
@ -565,7 +566,7 @@ while ($i < $imaxinloop) {
if ($obj->soc_id > 0) {
print $companystatic->getNomUrl(1, '', 24);
} else {
print $donationstatic->societe = $obj->societe;
print $object->societe = $obj->societe;
}
print '</td>';
if (!$i) {

View file

@ -332,7 +332,7 @@ class ConferenceOrBooth extends ActionComm
// Manage filter
if (is_array($filter)) { // deprecated, use $filter = USF syntax
dol_syslog("You are using a deprecated use of fetchAll. filter parameter mus be an USF string now.", LOG_WARNING);
dol_syslog("You are using a deprecated use of fetchAll. filter parameter must be an USF string now.", LOG_WARNING);
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {

View file

@ -476,7 +476,7 @@ class ConferenceOrBoothAttendee extends CommonObject
// Manage filter
if (is_array($filter)) { // deprecated, use $filter = USF syntax
dol_syslog("You are using a deprecated use of fetchAll. filter parameter mus be an USF string now.", LOG_WARNING);
dol_syslog("You are using a deprecated use of fetchAll. filter parameter must be an USF string now.", LOG_WARNING);
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {

View file

@ -213,7 +213,7 @@ if (empty($reshook)) {
setEventMessages($object->error, $object->errors, 'errors');
}
$result = $object->setValueFrom('ref_customer', GETPOST('ref_customer', 'alpha'), '', null, 'text', '', $user, 'SHIPMENT_MODIFY');
$result = $object->setValueFrom('ref_customer', GETPOST('ref_customer', 'alpha'), '', null, 'text', '', $user, 'SHIPPING_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$action = 'editref_customer';
@ -236,7 +236,7 @@ if (empty($reshook)) {
if (!$error) {
// Actions on extra fields
$result = $object->updateExtraField($attribute_name, 'SHIPMENT_MODIFY');
$result = $object->updateExtraField($attribute_name, 'SHIPPING_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;

View file

@ -112,7 +112,7 @@ class Shipments extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -209,7 +209,7 @@ if (empty($reshook)) {
}
if (!$error) {
$result = $object->updateExtraField($attribute_name, 'SHIPMENT_MODIFY');
$result = $object->updateExtraField($attribute_name, 'SHIPPING_MODIFY');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
$error++;

View file

@ -174,6 +174,7 @@ $permissiontoadd = $user->hasRight('expensereport', 'creer'); // Used by the inc
/*
* Actions
*/
$error = 0;
$value_unit_ht = price2num(GETPOST('value_unit_ht', 'alpha'), 'MU');
@ -410,9 +411,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -529,9 +530,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -643,9 +644,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -761,9 +762,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -879,9 +880,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -995,9 +996,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -1036,9 +1037,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -1049,9 +1050,13 @@ if (empty($reshook)) {
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
}
if ($action == 'set_paid' && $id > 0 && $user->hasRight('expensereport', 'to_paid')) {
$object = new ExpenseReport($db);
$object->fetch($id);
@ -1067,9 +1072,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -1083,74 +1088,78 @@ if (empty($reshook)) {
}
if ($result > 0) {
// Send mail
// TODO We must never send an email without a setup or confirm option to choose if email is
// sent or not. So we add a hidden constant to avoid this for the moment.
if (getDolGlobalString('EXPENSEREPORT_SEND_EMAIL_ON_STATUS_PAID')) {
// Send mail
// TO
$destinataire = new User($db);
$destinataire->fetch($object->fk_user_author);
$emailTo = $destinataire->email;
// TO
$destinataire = new User($db);
$destinataire->fetch($object->fk_user_author);
$emailTo = $destinataire->email;
// FROM
$expediteur = new User($db);
$expediteur->fetch($user->id);
$emailFrom = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
// FROM
$expediteur = new User($db);
$expediteur->fetch($user->id);
$emailFrom = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
if ($emailFrom && $emailTo) {
$filename = array();
$filedir = array();
$mimetype = array();
if ($emailFrom && $emailTo) {
$filename = array();
$filedir = array();
$mimetype = array();
// SUBJECT
$societeName = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
$societeName = getDolGlobalString('MAIN_APPLICATION_TITLE');
}
// SUBJECT
$societeName = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
if (getDolGlobalString('MAIN_APPLICATION_TITLE')) {
$societeName = getDolGlobalString('MAIN_APPLICATION_TITLE');
}
$subject = $societeName." - ".$langs->transnoentities("ExpenseReportPaid");
$subject = $societeName." - ".$langs->transnoentities("ExpenseReportPaid");
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$link = '<a href="'.$link.'">'.$link.'</a>';
$message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$link = '<a href="'.$link.'">'.$link.'</a>';
$message = $langs->transnoentities("ExpenseReportPaidMessage", $object->ref, $destinataire->getFullName($langs), $expediteur->getFullName($langs), $link);
// Generate pdf before attachment
$object->setDocModel($user, "");
$resultPDF = expensereport_pdf_create($db, $object, '', "", $langs);
// Generate pdf before attachment
$object->setDocModel($user, "");
$resultPDF = expensereport_pdf_create($db, $object, '', "", $langs);
// PREPARE SEND
$mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
// PREPARE SEND
$mailfile = new CMailFile($subject, $emailTo, $emailFrom, $message, $filedir, $mimetype, $filename, '', '', 0, -1);
if (empty($mailfile->error)) {
// SEND
$result = $mailfile->sendfile();
if ($result) {
$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
setEventMessages($mesg, null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
} else {
$langs->load("other");
if ($mailfile->error) {
$mesg = '';
$mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
$mesg .= '<br>'.$mailfile->error;
setEventMessages($mesg, null, 'errors');
if (empty($mailfile->error)) {
// SEND
$result = $mailfile->sendfile();
if ($result) {
$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($emailFrom, 2), $mailfile->getValidAddress($emailTo, 2));
setEventMessages($mesg, null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
} else {
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
$langs->load("other");
if ($mailfile->error) {
$mesg = '';
$mesg .= $langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
$mesg .= '<br>'.$mailfile->error;
setEventMessages($mesg, null, 'errors');
} else {
setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
}
}
} else {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
}
} else {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action = '';
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
}
} else {
setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
$action = '';
}
} else {
setEventMessages($langs->trans("FailedToSetPaid"), null, 'warnings');
$action = '';
}
$action = '';
}
if ($action == "addline" && $user->hasRight('expensereport', 'creer')) {
@ -1245,12 +1254,12 @@ if (empty($reshook)) {
$outputlangs = $langs;
$newlang = GETPOST('lang_id', 'alpha');
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (empty($newlang)) {
$newlang = $langs;
$newlang = $langs->defaultlang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -1303,9 +1312,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -1402,9 +1411,9 @@ if (empty($reshook)) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
$user = new User($db);
$user->fetch($object->fk_user_author);
$newlang = $user->lang;
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$newlang = $tmpuser->lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
@ -1425,9 +1434,6 @@ if (empty($reshook)) {
unset($fk_project);
unset($date);
}
//header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
//exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
@ -1603,6 +1609,7 @@ if ($action == 'create') {
// End of page
llxFooter();
$db->close();
exit;
@ -1611,7 +1618,7 @@ if ($action == 'create') {
$head = expensereport_prepare_head($object);
if ($action == 'edit' && ($object->status < 3 || $object->status == ExpenseReport::STATUS_REFUSED)) {
if ($action == 'edit' && ($object->status <= ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED)) {
print "<form name='update' action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="id" value="'.$id.'">';
@ -2067,13 +2074,16 @@ if ($action == 'create') {
$remaintopay = price2num($object->total_ttc - (float) $totalpaid);
$resteapayeraffiche = $remaintopay;
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
if ($remaintopay > 0) {
$cssforamountpaymentcomplete = 'amountremaintopay';
} else {
$cssforamountpaymentcomplete = 'amountpaymentcomplete';
}
if ($object->status == ExpenseReport::STATUS_REFUSED) {
$cssforamountpaymentcomplete = 'amountpaymentneutral';
$resteapayeraffiche = 0;
} elseif ($object->paid == 0) {
$cssforamountpaymentcomplete = 'amountpaymentneutral';
$cssforamountpaymentcomplete = 'amountpaymentneutral strikefordisabled';
} elseif ($object->paid == 1 && $remaintopay > 0) {
$cssforamountpaymentcomplete = 'amountpaymentneutral strikefordisabled';
}
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AlreadyPaid").':</td><td class="right">'.price($totalpaid).'</td><td></td></tr>';
print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AmountExpected").':</td><td class="right">'.price($object->total_ttc).'</td><td></td></tr>';
@ -2803,11 +2813,11 @@ if ($action != 'create' && $action != 'edit' && $action != 'editline') {
}
}
/* Si l'état est "Brouillon"
/* If status is "Draft"
* ET user à droit "creer/supprimer"
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
*/
if ($user->hasRight('expensereport', 'creer') && $object->status == ExpenseReport::STATUS_DRAFT) {
if (in_array($object->fk_user_author, $childids) || $user->hasRight('expensereport', 'writeall_advance')) {
// Modify
@ -2820,7 +2830,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'editline') {
}
}
/* Si l'état est "Refusée"
/* If status if "Refused"
* ET user à droit "creer/supprimer"
* ET fk_user_author == user courant
* Afficher : "Enregistrer" / "Modifier" / "Supprimer"
@ -2902,6 +2912,9 @@ if ($action != 'create' && $action != 'edit' && $action != 'editline') {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Cancel").'</a></div>';
}
// If status is Closed
// ---------------------
// TODO Replace this. It should be SetUnpaid and should go back to status unpaid not canceled.
if (($user->hasRight('expensereport', 'approve') || $user->hasRight('expensereport', 'to_paid')) && $object->status == ExpenseReport::STATUS_CLOSED) {
// Cancel

View file

@ -131,7 +131,7 @@ class ExpenseReports extends DolibarrApi
$obj_ret = array();
// case of external user, $societe param is ignored and replaced by user's socid
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
//$socid = DolibarrApiAccess::$user->socid ?: $societe;
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport AS t LEFT JOIN ".MAIN_DB_PREFIX."expensereport_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields

View file

@ -815,7 +815,7 @@ class ExpenseReport extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."expensereport";
$sql .= " SET fk_statut = ".self::STATUS_CLOSED.", paid=1";
$sql .= " SET fk_statut = ".self::STATUS_CLOSED.", paid = 1";
$sql .= " WHERE rowid = ".((int) $id)." AND fk_statut = ".self::STATUS_APPROVED;
dol_syslog(get_class($this)."::setPaid", LOG_DEBUG);
@ -834,6 +834,10 @@ class ExpenseReport extends CommonObject
if (empty($error)) {
$this->db->commit();
$this->status = self::STATUS_CLOSED;
$this->paid = 1;
return 1;
} else {
$this->db->rollback();

View file

@ -89,7 +89,7 @@ $help_url = "EN:Module_Expense_Reports|FR:Module_Notes_de_frais";
llxHeader('', $langs->trans("TripsAndExpenses"), $help_url);
$label = $somme = $nb = array();
$label = $somme = array();
$totalnb = $totalsum = 0;
$sql = "SELECT tf.code, tf.label, count(de.rowid) as nb, sum(de.total_ht) as km";
@ -102,7 +102,6 @@ if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expenserep
$childids[] = $user->id;
$sql .= " AND d.fk_user_author IN (".$db->sanitize(implode(',', $childids)).")\n";
}
$sql .= " GROUP BY tf.code, tf.label";
$result = $db->query($sql);
@ -230,8 +229,8 @@ if ($result) {
print '<th class="right">'.$langs->trans("AmountTTC").'</th>';
print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
print '<th>';
print '<a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">';
print img_picto($langs->trans("FullList"), 'expensereport');
print '<a class="badge" title="'.$langs->trans("FullList").'" href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">';
print '...';
print '</a>';
print '</th>';
print '</tr>';

View file

@ -147,7 +147,7 @@ class Interventions extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -122,7 +122,7 @@ if ($idprod > 0) {
}
}
$prices[] = array("id" => 'pmpprice', "price" => price2num($price), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
$prices[] = array("id" => 'pmpprice', "price" => price2num($price, 'MU'), "label" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency), "title" => $langs->trans("PMPValueShort").': '.price($price, 0, $langs, 0, 0, -1, $conf->currency)); // For price field, we must use price2num(), for label or title, price()
}
// Add price for costprice (at end)

View file

@ -117,7 +117,7 @@ class SupplierInvoices extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -111,7 +111,7 @@ class SupplierOrders extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -90,7 +90,7 @@ if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "cp.ref";
$sortfield = "cp.date_debut";
}
$search_all = trim(GETPOST('search_all', 'alphanohtml'));

View file

@ -19,7 +19,7 @@
create table llx_c_ziptown
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
code varchar(5) DEFAULT NULL, -- ex: code insee pour la France
code varchar(5) DEFAULT NULL, -- ex: code insee pour la France (not always used)
fk_county integer, -- State id in llx_c_departements
fk_pays integer NOT NULL DEFAULT 0, -- Country id in llx_c_country
zip varchar(10) NOT NULL, -- Zip code

View file

@ -147,7 +147,7 @@ class KnowledgeManagement extends DolibarrApi
throw new RestException(403);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View file

@ -2677,3 +2677,4 @@ Synchronize=Synchronize
ByDefault=By default
Sources=Sources
XYearSupport=%s-year support
CacheForTranslationIsUsed=Warning, translation files seems loaded into a cache system. If you force some translations from here, think to reset the cache to have the change effective.

View file

@ -34,5 +34,6 @@ ResourceTypeCode=Resource type code
ImportDataset_resource_1=Resources
ErrorResourcesAlreadyInUse=Some resources are in use
ErrorResourceUseInEvent=%s used in %s event
MaxUsers=Maximum users (places, seats, etc.)
MaxUsers=Maximum number of users
MaxUsersResourceDesc=If the resource can be used by several people at once (car, room, ...), you can enter here the maximum number of users allowed to use the resource at the same time (number of seats, places, ...).
MaxUsersLabel=Maximum users

View file

@ -121,7 +121,7 @@ class MyModuleApi extends DolibarrApi
throw new RestException(403);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View file

@ -108,7 +108,7 @@ class Mos extends DolibarrApi
$obj_ret = array();
$tmpobject = new Mo($this->db);
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View file

@ -966,7 +966,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Inventory code
if (!empty($arrayfields['m.inventorycode']['checked'])) {
print '<td class="tdoverflowmax150" title="'.dol_escape_htmltag($objp->inventorycode).'">';
//print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_card.php' . '?id=' . $objp->entrepot_id . '&amp;search_inventorycode=' . $objp->inventorycode . '&amp;search_type_mouvement=' . $objp->type_mouvement . '">';
//print '<a href="' . DOL_URL_ROOT . '/product/stock/movement_list.php' . '?id=' . ((int) $objp->entrepot_id) . '&search_inventorycode=' . urlencode($objp->inventorycode) . '&search_type_mouvement=' . urlencode($objp->type_mouvement) . '">';
print dol_escape_htmltag($objp->inventorycode);
//print '</a>';
print '</td>';

View file

@ -113,7 +113,7 @@ class Partnerships extends DolibarrApi
throw new RestException(403);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View file

@ -196,15 +196,13 @@ class Products extends DolibarrApi
*/
public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0, $properties = '')
{
global $db, $conf;
if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) {
throw new RestException(403);
}
$obj_ret = array();
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$socid = DolibarrApiAccess::$user->socid ?: '';
$sql = "SELECT t.rowid, t.ref, t.ref_ext";
$sql .= " FROM ".$this->db->prefix()."product as t";
@ -798,7 +796,7 @@ class Products extends DolibarrApi
throw new RestException(400, 'API not available: this mode of pricing is not enabled by setup');
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$socid = DolibarrApiAccess::$user->socid ?: '';
if ($socid > 0 && $socid != $thirdparty_id) {
throw new RestException(403, 'Getting prices for all customers or for the customer ID '.$thirdparty_id.' is not allowed for login '.DolibarrApiAccess::$user->login);
}
@ -918,7 +916,7 @@ class Products extends DolibarrApi
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$socid = DolibarrApiAccess::$user->socid ?: '';
if ($socid > 0 && $socid != $fourn_id) {
throw new RestException(403, 'Adding purchase price for the supplier ID '.$fourn_id.' is not allowed for login '.DolibarrApiAccess::$user->login);
}
@ -1016,7 +1014,7 @@ class Products extends DolibarrApi
$obj_ret = array();
// Force id of company for external users
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$socid = DolibarrApiAccess::$user->socid ?: '';
if ($socid > 0) {
if ($supplier != $socid || empty($supplier)) {
throw new RestException(403, 'As an external user, you can request only for your supplier id = '.$socid);
@ -1129,7 +1127,7 @@ class Products extends DolibarrApi
throw new RestException(403);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
$socid = DolibarrApiAccess::$user->socid ?: '';
$result = $this->product->fetch($id, $ref, $ref_ext, $barcode);
if (!$result) {

View file

@ -363,12 +363,14 @@ class Product extends CommonObject
/**
* Cost price
*
* @var float
* @var ?float
*/
public $cost_price;
/**
* @var float Average price value for product entry in stock (PMP)
* Average price value for product entry into stock (PMP)
*
* @var ?float
*/
public $pmp;
@ -3056,7 +3058,7 @@ class Product extends CommonObject
$this->price_min = $obj->price_min;
$this->price_min_ttc = $obj->price_min_ttc;
$this->price_base_type = $obj->price_base_type;
$this->cost_price = $obj->cost_price;
$this->cost_price = isset($obj->cost_price) ? (float) $obj->cost_price : null;
$this->default_vat_code = $obj->default_vat_code;
$this->tva_tx = $obj->tva_tx;
//! French VAT NPR
@ -6109,7 +6111,7 @@ class Product extends CommonObject
* @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove)
* @param int<0,1> $movement 0 = add, 1 = remove
* @param string $label Label of stock movement
* @param float $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
* @param int|float $price Unit price HT of product, used to calculate average weighted price (PMP in french). If 0, average weighted price is not changed.
* @param string $inventorycode Inventory code
* @param string $origin_element Origin element type
* @param ?int $origin_id Origin id of element
@ -6165,22 +6167,22 @@ class Product extends CommonObject
/**
* Adjust stock in a warehouse for product with batch number
*
* @param User $user user asking change
* @param int $id_entrepot id of warehouse
* @param float $nbpiece nb of units (should be always positive, use $movement to decide if we add or remove)
* @param int<0,1> $movement 0 = add, 1 = remove
* @param string $label Label of stock movement
* @param float $price Price to use for stock eval
* @param int|string $dlc eat-by date
* @param int|string $dluo sell-by date
* @param string $lot Lot number
* @param string $inventorycode Inventory code
* @param string $origin_element Origin element type
* @param ?int $origin_id Origin id of element
* @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct)
* @param ?ExtraFields $extrafields Array of extrafields
* @param boolean $force_update_batch Force update batch
* @return int Return integer <0 if KO, >0 if OK
* @param User $user User asking change
* @param int $id_entrepot Id of warehouse
* @param float $nbpiece Nb of units (should be always positive, use $movement to decide if we add or remove)
* @param int<0,1> $movement 0 = add, 1 = remove
* @param string $label Label of stock movement
* @param int|float $price Price to use for stock eval
* @param int|string $dlc eat-by date
* @param int|string $dluo sell-by date
* @param string $lot Lot number
* @param string $inventorycode Inventory code
* @param string $origin_element Origin element type
* @param ?int $origin_id Origin id of element
* @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct)
* @param ?ExtraFields $extrafields Array of extrafields
* @param boolean $force_update_batch Force update batch
* @return int Return integer <0 if KO, >0 if OK
*/
public function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label = '', $price = 0, $dlc = '', $dluo = '', $lot = '', $inventorycode = '', $origin_element = '', $origin_id = null, $disablestockchangeforsubproduct = 0, $extrafields = null, $force_update_batch = false)
{

View file

@ -1149,7 +1149,7 @@ if ($resql) {
}
$pmp_valuation = $pmp_expected * $valuetoshow;
print '<td class="right">';
print price($pmp_expected);
print is_null($pmp_expected) ? '' : price($pmp_expected);
print '<input type="hidden" name="expectedpmp_'.$obj->rowid.'" value="'.$pmp_expected.'"/>';
print '</td>';
print '<td class="right">';
@ -1171,7 +1171,7 @@ if ($resql) {
$pmp_real = $product_static->pmp;
}
$pmp_valuation_real = $pmp_real * $qty_view;
print '<input type="text" class="maxwidth75 right realpmp'.$obj->fk_product.'" name="realpmp_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input_pmp" value="'.price2num($pmp_real).'">';
print '<input type="text" class="maxwidth75 right realpmp'.$obj->fk_product.'" name="realpmp_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input_pmp" value="'.(is_null($pmp_real) ? '' : price2num($pmp_real)).'">';
print '</td>';
print '<td class="right">';
print '<input type="text" class="maxwidth75 right realvaluation'.$obj->fk_product.'" name="realvaluation_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input_real_valuation" value="'.$pmp_valuation_real.'">';
@ -1198,7 +1198,7 @@ if ($resql) {
print '</td>';
} else {
if (getDolGlobalString('INVENTORY_MANAGE_REAL_PMP')) {
//PMP Expected
// PMP Expected
if (!empty($obj->pmp_expected)) {
$pmp_expected = $obj->pmp_expected;
} else {
@ -1206,7 +1206,7 @@ if ($resql) {
}
$pmp_valuation = $pmp_expected * $valuetoshow;
print '<td class="right">';
print price($pmp_expected);
print is_null($pmp_expected) ? '' : price($pmp_expected);
print '</td>';
print '<td class="right">';
print price($pmp_valuation);
@ -1216,7 +1216,7 @@ if ($resql) {
print $obj->qty_view; // qty found
print '</td>';
//PMP Real
// PMP Real
print '<td class="right">';
if (!empty($obj->pmp_real)) {
$pmp_real = $obj->pmp_real;
@ -1224,7 +1224,7 @@ if ($resql) {
$pmp_real = $product_static->pmp;
}
$pmp_valuation_real = $pmp_real * $obj->qty_view;
print price($pmp_real);
print is_null($pmp_real) ? '' : price($pmp_real);
print '</td>';
print '<td class="right">';
print price($pmp_valuation_real);

View file

@ -48,7 +48,7 @@ class StockMovements extends DolibarrApi
*/
public function __construct()
{
global $db, $conf;
global $db;
$this->db = $db;
$this->stockmovement = new MouvementStock($this->db);
}
@ -89,7 +89,7 @@ class StockMovements extends DolibarrApi
* @param string $sortorder Sort order
* @param int $limit Limit for list
* @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.product_id:=:1) and (t.date_creation:<:'20160101')"
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.fk_product:=:1) and (t.date_creation:<:'20160101')"
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @return array Array of warehouse objects
* @phan-return MouvementStock[]
@ -99,8 +99,6 @@ class StockMovements extends DolibarrApi
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
{
global $conf;
$obj_ret = array();
if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
@ -172,8 +170,8 @@ class StockMovements extends DolibarrApi
* @param string $dluo Sell-by date. {@from body} {@type date}
* @param string $origin_type Origin type (Element of source object, like 'project', 'inventory', ...)
* @param int $origin_id Origin id (Id of source object)
*
* @return int ID of stock movement
*
* @throws RestException
*/
public function post($product_id, $warehouse_id, $qty, $type = 2, $lot = '', $movementcode = '', $movementlabel = '', $price = '', $datem = '', $dlc = '', $dluo = '', $origin_type = '', $origin_id = 0)

View file

@ -46,7 +46,7 @@ class Warehouses extends DolibarrApi
*/
public function __construct()
{
global $db, $conf;
global $db;
$this->db = $db;
$this->warehouse = new Entrepot($this->db);
}
@ -99,8 +99,6 @@ class Warehouses extends DolibarrApi
*/
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $category = 0, $sqlfilters = '', $properties = '')
{
global $db, $conf;
$obj_ret = array();
if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) {
@ -288,9 +286,6 @@ class Warehouses extends DolibarrApi
// phpcs:enable
$object = parent::_cleanObjectDatas($object);
// Remove the subscriptions because they are handled as a subresource.
//unset($object->subscriptions);
return $object;
}

View file

@ -205,7 +205,7 @@ class MouvementStock extends CommonObject
* 0=input (stock increase by a stock transfer), 1=output (stock decrease by a stock transfer),
* 2=output (stock decrease), 3=input (stock increase)
* Note that qty should be > 0 with 0 or 3, < 0 with 1 or 2.
* @param float $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed.
* @param int|float $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed.
* @param string $label Label of stock movement
* @param string $inventorycode Inventory code
* @param int|string $datem Force date of movement

View file

@ -216,7 +216,7 @@ if ($action == 'createmovements' && $user->hasRight('stock', 'mouvement', 'creer
// Define value of products moved
$pricesrc = 0;
if (!empty($product->pmp)) {
$pricesrc = $product->pmp;
$pricesrc = (float) $product->pmp;
}
$pricedest = $pricesrc;

File diff suppressed because it is too large Load diff

View file

@ -400,8 +400,6 @@ if ($action == "correct_stock" && $permissiontoadd) {
if ($product->hasbatch()) {
$batch = GETPOST('batch_number', 'alphanohtml');
//$eatby=GETPOST('eatby');
//$sellby=GETPOST('sellby');
$eatby = dol_mktime(0, 0, 0, GETPOSTINT('eatbymonth'), GETPOSTINT('eatbyday'), GETPOSTINT('eatbyyear'));
$sellby = dol_mktime(0, 0, 0, GETPOSTINT('sellbymonth'), GETPOSTINT('sellbyday'), GETPOSTINT('sellbyyear'));
@ -510,17 +508,16 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
if ($product->hasbatch()) {
$pdluo = new Productbatch($db);
$srcwarehouseid = 0;
$eatby = -1;
$sellby = -1;
$eatby = dol_mktime(0, 0, 0, GETPOSTINT('eatbymonth'), GETPOSTINT('eatbyday'), GETPOSTINT('eatbyyear'));
$sellby = dol_mktime(0, 0, 0, GETPOSTINT('sellbymonth'), GETPOSTINT('sellbyday'), GETPOSTINT('sellbyyear'));
if ($pdluoid > 0) {
$result = $pdluo->fetch($pdluoid);
if ($result) {
$srcwarehouseid = $pdluo->warehouseid;
$batch = $pdluo->batch;
$eatby = $pdluo->eatby;
$sellby = $pdluo->sellby;
} else {
setEventMessages($pdluo->error, $pdluo->errors, 'errors');
$error++;
@ -528,8 +525,6 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
} else {
$srcwarehouseid = $id;
$batch = GETPOST('batch_number', 'alphanohtml');
$eatby = $d_eatby;
$sellby = $d_sellby;
}
$result1 = -1;
@ -542,7 +537,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
GETPOSTFLOAT("nbpiece"),
1,
GETPOST("label", 'san_alpha'),
$pricesrc,
(float) $pricesrc,
$eatby,
$sellby,
$batch,
@ -559,7 +554,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
GETPOSTFLOAT("nbpiece"),
0,
GETPOST("label", 'san_alpha'),
$pricedest,
(float) $pricedest,
$eatby,
$sellby,
$batch,
@ -578,7 +573,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
GETPOSTFLOAT("nbpiece"),
1,
GETPOST("label", 'san_alpha'),
$pricesrc,
(float) $pricesrc,
GETPOST('inventorycode', 'alphanohtml'),
'',
null,
@ -593,7 +588,7 @@ if ($action == "transfert_stock" && $permissiontoadd && !$cancel) {
GETPOSTFLOAT("nbpiece"),
0,
GETPOST("label", 'san_alpha'),
$pricedest,
(float) $pricedest,
GETPOST('inventorycode', 'alphanohtml'),
'',
null,
@ -831,10 +826,6 @@ if ($id > 0 || $ref) {
}
}
// Output page
// --------------------------------------------------------------------
$i = 0;
$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
if ($msid) {
@ -1001,6 +992,8 @@ if ($action == "correction") {
// Transfer of units
if ($action == "transfert") {
$d_eatby = GETPOSTDATE('eatby'); // used by the tpl
$d_sellby = GETPOSTDATE('sellby'); // used by the tpl
include DOL_DOCUMENT_ROOT.'/product/stock/tpl/stocktransfer.tpl.php';
print '<br>';
}

View file

@ -434,7 +434,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) {
(float) $nbpiece,
1,
GETPOST("label", 'alphanohtml'),
$pricesrc,
(float) $pricesrc,
$eatby,
$sellby,
$batch,
@ -452,7 +452,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) {
(float) $nbpiece,
0,
GETPOST("label", 'alphanohtml'),
$pricedest,
(float) $pricedest,
$eatby,
$sellby,
(string) $batch,
@ -471,7 +471,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) {
(float) $nbpiece,
1,
GETPOST("label", 'alphanohtml'),
$pricesrc,
(float) $pricesrc,
GETPOST('inventorycode', 'alphanohtml')
);
if ($result1 < 0) {
@ -486,7 +486,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) {
(float) $nbpiece,
0,
GETPOST("label", 'alphanohtml'),
$pricedest,
(float) $pricedest,
GETPOST('inventorycode', 'alphanohtml')
);
if ($result2 < 0) {

View file

@ -15,20 +15,20 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* $object must be defined
* $backtopage
*/
/**
* @var Conf $conf
* @var DoliDB $db
* @var Form $form
* @var Product|MouvementStock $object
* @var FormProduct $formproduct
* @var Translate $langs
* @var Product|Entrepot|MouvementStock $object
*
* @var string $backtopage
* @var string $backtopage
* @var ?int $id
* @var int $d_eatby
* @var int $d_sellby
*/
// Protection to avoid direct call of template
@ -38,7 +38,7 @@ if (empty($conf) || !is_object($conf)) {
}
'
@phan-var-force Entrepot|MouvementStock $object
@phan-var-force Entrepot|Product|MouvementStock $object
@phan-var-force FormProduct $formproduct
@phan-var-force string $backtopage
';
@ -86,7 +86,7 @@ if ($pdluoid) {
}
print '<table class="border centpercent">';
// Source warehouse or product
// Source product or stock movement
print '<tr>';
if ($object->element == 'product') {
/** @var Product $object */

View file

@ -209,7 +209,7 @@ class Projects extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -120,7 +120,7 @@ class Tasks extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socids = DolibarrApiAccess::$user->socid ?: 0;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -1415,7 +1415,7 @@ class Project extends CommonObject
*
* @param int<0,2> $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option Variant where the link point to ('', 'nolink')
* @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string
* @param int $addlabel 0=Default, 1=Add label into string, n>1=Add the n first chars of label in ref, -1=Label replace the ref
* @param string $moreinpopup Text to add into popup
* @param string $sep Separator between ref and label if option addlabel is set
* @param int<0,1> $notooltip 1=Disable tooltip
@ -1505,11 +1505,15 @@ class Project extends CommonObject
$result .= img_object(($notooltip ? '' : $label), $picto, 'class="pictofixedwidth em088"', 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
if ($addlabel >= 0) {
$result .= $this->ref;
} else {
$result .= $this->title;
}
}
$result .= $linkend;
if ($withpicto != 2) {
$result .= (($addlabel && $this->title) ? '<span class="opacitymedium">'.$sep.dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)).'</span>' : '');
$result .= (($addlabel > 0 && $this->title) ? '<span class="opacitymedium">'.$sep.dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)).'</span>' : '');
}
global $action;

View file

@ -1010,7 +1010,7 @@ class Task extends CommonObjectLine
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param string $option 'withproject' or ''
* @param string $mode Mode 'task', 'time', 'contact', 'note', document' define page to link to.
* @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string
* @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string, -1=Label replace the ref
* @param string $sep Separator between ref and label if option addlabel is set
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
@ -1072,11 +1072,15 @@ class Task extends CommonObjectLine
$result .= img_object(($notooltip ? '' : $label), $picto, 'class="paddingright"', 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
if ($addlabel >= 0) {
$result .= $this->ref;
} else {
$result .= $this->label;
}
}
$result .= $linkend;
if ($withpicto != 2) {
$result .= (($addlabel && $this->label) ? $sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
$result .= (($addlabel > 0 && $this->label) ? '<span class="opacitymedium">'.$sep.dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)).'</span>' : '');
}
$parameters = array('id' => $this->id, 'getnomurl' => &$result);

View file

@ -1,5 +1,4 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2023 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
@ -1490,7 +1489,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print $langs->trans('ServiceToUseOnLines');
print '</td>';
print '<td>';
$form->select_produits(0, 'productid', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500');
$form->select_produits(0, 'productid', 1, 0, $projectstatic->thirdparty->price_level, 1, 2, '', 0, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500');
print '</td>';
print '</tr>';
}
@ -1884,7 +1883,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
if (isModEnabled("service") && !empty($projectstatic->thirdparty) && $projectstatic->thirdparty->id > 0 && $projectstatic->usage_bill_time) {
print '<td class="nowraponall">';
print img_picto('', 'service');
print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOSTINT("fk_product") : ''), 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1);
print $form->select_produits((GETPOSTISSET('fk_product') ? GETPOSTINT("fk_product") : ''), 'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth150', 0, '', null, 1);
print '</td>';
}
}
@ -2065,11 +2064,11 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
if (!empty($allprojectforuser)) {
if (!empty($arrayfields['p.project_ref']['checked'])) {
print_liste_field_titre("Project", $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['p.project_ref']['label'], $_SERVER['PHP_SELF'], 'p.ref', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['p.project_label']['checked'])) {
print_liste_field_titre("ProjectLabel", $_SERVER['PHP_SELF'], 'p.title', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['p.project_label']['label'], $_SERVER['PHP_SELF'], 'p.title', '', $param, '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
}
@ -2260,10 +2259,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
// Project ref & label
if (!empty($allprojectforuser)) {
// Project ref
if (!empty($arrayfields['p.project_ref']['checked'])) {
print '<td class="nowraponall">';
if (empty($conf->cache['project'][$task_time->fk_projet])) {
$tmpproject = new Project($db);
$tmpproject->fetch($task_time->fk_projet);
@ -2271,12 +2269,14 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} else {
$tmpproject = $conf->cache['project'][$task_time->fk_projet];
}
print '<td class="nowraponall">';
print $tmpproject->getNomUrl(1);
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Project label
if (!empty($arrayfields['p.project_label']['checked'])) {
if (empty($conf->cache['project'][$task_time->fk_projet])) {
$tmpproject = new Project($db);
@ -2285,8 +2285,12 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
} else {
$tmpproject = $conf->cache['project'][$task_time->fk_projet];
}
print '<td class="tdoverflowmax250" title="'.dol_escape_htmltag($tmpproject->title).'">';
print dol_escape_htmltag($tmpproject->title);
print '<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($tmpproject->title).'">';
if (!empty($arrayfields['p.project_ref']['checked'])) {
print dolPrintHTML($tmpproject->title);
} else {
print $tmpproject->getNomUrl(1, '', -1);
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2318,8 +2322,15 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Task label
if (!empty($arrayfields['t.element_label']['checked'])) {
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
print '<td class="tdoverflowmax250" title="'.dol_escape_htmltag($task_time->label).'">';
print dol_escape_htmltag($task_time->label);
print '<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($task_time->label).'">';
if (!empty($arrayfields['t.element_ref']['checked'])) {
print dolPrintHTML($task_time->label);
} else {
$tasktmp->id = $task_time->fk_element;
$tasktmp->ref = $task_time->ref;
$tasktmp->label = $task_time->label;
print $tasktmp->getNomUrl(1, 'withproject', 'time', -1);
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
@ -2327,9 +2338,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
}
}
// By User
// User
if (!empty($arrayfields['author']['checked'])) {
print '<td class="minwidth100 tdoverflowmax125">';
print '<td class="tdoverflowmax100">';
if ($action == 'editline' && GETPOSTINT('lineid') == $task_time->rowid) {
// Here $object is task. TODO Add a cache
if (empty($object->id)) {
@ -2415,7 +2426,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<td class="nowraponall">';
if ($action == 'editline' && GETPOSTINT('lineid') == $task_time->rowid) {
print img_picto('', 'service');
print $form->select_produits($task_time->fk_product, 'fk_product', '1', 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500', 0, '', null, 1);
print $form->select_produits($task_time->fk_product, 'fk_product', 1, 0, $projectstatic->thirdparty->price_level, 1, 2, '', 1, array(), $projectstatic->thirdparty->id, 'None', 0, 'maxwidth500', 0, '', null, 1);
} elseif (!empty($task_time->fk_product)) {
$product = new Product($db);
$resultFetch = $product->fetch($task_time->fk_product);
@ -2744,7 +2755,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Date
if (!empty($arrayfields['t.element_date']['checked'])) {
print '<td class="nowrap">';
print '<td class="nowraponall">';
if ($action == 'splitline' && GETPOSTINT('lineid') == $task_time->rowid) {
if (empty($task_time->element_date_withhour)) {
print $form->selectDate(($date2 ? $date2 : $date1), 'timeline_2', 3, 3, 2, "timespent_date", 1, 0);
@ -2759,20 +2770,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Thirdparty
if (!empty($arrayfields['p.fk_soc']['checked'])) {
print '<td class="nowrap">';
print '<td>';
print '</td>';
}
// Thirdparty alias
if (!empty($arrayfields['s.name_alias']['checked'])) {
print '<td class="nowrap">';
print '<td>';
print '</td>';
}
// Project ref
if (!empty($allprojectforuser)) {
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
print '<td class="nowrap">';
print '<td>';
print '</td>';
}
}
@ -2780,7 +2791,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Task ref
if (!empty($arrayfields['t.element_ref']['checked'])) {
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
print '<td class="nowrap">';
print '<td class="nowraponall">';
$tasktmp->id = $task_time->fk_element;
$tasktmp->ref = $task_time->ref;
$tasktmp->label = $task_time->label;
@ -2792,7 +2803,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Task label
if (!empty($arrayfields['t.element_label']['checked'])) {
if ((empty($id) && empty($ref)) || !empty($projectidforalltimes)) { // Not a dedicated task
print '<td class="nowrap">';
print '<td class="tdoverflowmax125" title="'.dol_escape_htmltag($task_time->label).'">';
print dol_escape_htmltag($task_time->label);
print '</td>';
}
@ -2861,7 +2872,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
// Value spent
if (!empty($arrayfields['value']['checked'])) {
print '<td class="right">';
print '<span class="amount">';
print '<span class="amount nowraponall">';
$value = 0;
print price($value, 1, $langs, 1, -1, -1, $conf->currency);
print '</span>';
@ -2873,7 +2884,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<td class="right">';
$valuebilled = price2num($task_time->total_ht, '', 1);
if (isset($task_time->total_ht)) {
print '<span class="amount">';
print '<span class="amount nowraponall">';
print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency);
print '</span>';
}

View file

@ -290,11 +290,12 @@ if (empty($doactionsthenredirect)) {
// Add steps to validate payment is complete when we enter this page
$service = $paymentmethod; // to have a default value. We may change it later for 'StripeLive' or 'StripeTest'...
// For Paypal: validate the payment (Paypal need another step after the callback return to validate the payment).
if (isModEnabled('paypal') && $paymentmethod === 'paypal') { // We call this page only if payment is ok on payment system
if (!empty($PAYPALTOKEN)) {
// TODO: Move this block to the top to ensure all session variables (e.g., TRANSACTIONID, FinalPaymentAmt, currencyCodeType, etc.) are loaded before executing checks for any payment module.
// Get on url call
$onlinetoken = $PAYPALTOKEN;
$fulltag = $FULLTAG;
@ -371,24 +372,99 @@ if (isModEnabled('paypal') && $paymentmethod === 'paypal') { // We call this pag
}
// For Paybox
if (isModEnabled('paybox')) {
if ($paymentmethod === 'paybox') {
// TODO Add a check to validate that payment is ok.
$ispaymentok = true; // We call this page only if payment is ok on payment system
}
if (isModEnabled('paybox') && $paymentmethod === 'paybox') {
// TODO Add a check to validate that payment is ok.
$ispaymentok = true; // We will do the rest of code
}
// For Stripe
if (isModEnabled('stripe')) {
if ($paymentmethod === 'stripe') {
// Check we are coming from the newpaymentpage
if (GETPOST('paymentoksessionkey') == $_SESSION['paymentoksessionkey']) {
// We can also request Stripe with payment_intent and payment_intent_client_secret the sameway we do in newpayment after comment "// Get here amount and currency used for payment".
$ispaymentok = true; // We call this page only if payment is ok on payment system
} else {
$ispaymentok = false; // We call this page only if payment is ok on payment system
if (isModEnabled('stripe') && $paymentmethod === 'stripe') {
// TODO: Move this block to the top to ensure all session variables (e.g., TRANSACTIONID, FinalPaymentAmt, currencyCodeType, etc.) are loaded before executing checks for any payment module.
if (empty($TRANSACTIONID)) {
$TRANSACTIONID = empty($_SESSION['TRANSACTIONID']) ? '' : $_SESSION['TRANSACTIONID']; // pi_... or ch_...
if (empty($TRANSACTIONID) && GETPOST('payment_intent', 'alphanohtml')) {
// For the case we use STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 2
$TRANSACTIONID = GETPOST('payment_intent', 'alphanohtml');
}
}
$FinalPaymentAmt = empty($_SESSION["FinalPaymentAmt"]) ? '' : $_SESSION["FinalPaymentAmt"];
$currencyCodeType = empty($_SESSION['currencyCodeType']) ? '' : $_SESSION['currencyCodeType'];
$service = 'StripeTest';
$servicestatus = 0;
if (getDolGlobalString('STRIPE_LIVE') && !GETPOSTINT('forcesandbox')) {
$service = 'StripeLive';
$servicestatus = 1;
}
// Check we are coming from the newpaymentpage
if (GETPOST('paymentoksessioncode') !== $_SESSION['paymentoksessioncode']) {
$error++;
$errmsg = 'Attempted direct access to the paymentok page without a valid session.';
dol_syslog($errmsg, LOG_ERR, 0, '_payment');
}
// Check on payment platform that the payment has been really validated
if (!$error && $TRANSACTIONID) {
// Stripe payment verification via Stripe API
try {
include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
$stripe = new Stripe($db);
$stripeacc = $stripe->getStripeAccount($service);
// Use the correct Stripe API key
global $stripearrayofkeysbyenv;
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']);
try {
if (empty($stripeacc)) {
$paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID);
} else {
$paymentIntent = \Stripe\PaymentIntent::retrieve($TRANSACTIONID, array("stripe_account" => $stripeacc));
}
// Check amount and currency
$expectedAmount = (int) round($FinalPaymentAmt * 100); // Stripe uses cents
$expectedCurrency = strtolower($currencyCodeType);
if ((int) $paymentIntent->amount !== $expectedAmount || strtolower($paymentIntent->currency) !== $expectedCurrency) {
$error++;
$errmsg = 'Stripe payment information mismatch: expected amount ' . $expectedAmount . ' and currency ' . $expectedCurrency . ', got amount ' . $paymentIntent->amount . ' and currency ' . $paymentIntent->currency;
dol_syslog($errmsg, LOG_ERR, 0, '_payment');
}
if ($paymentIntent->status !== 'succeeded') {
$error++;
$errmsg = 'Stripe payment not succeeded. Status: ' . $paymentIntent->status;
dol_syslog($errmsg, LOG_ERR, 0, '_payment');
}
} catch (\Stripe\Exception\ApiErrorException $e) {
$error++;
$errormessage = "Stripe API error: ".$e->getMessage();
dol_syslog($errormessage, LOG_ERR, 0, '_payment');
setEventMessages($e->getMessage(), null, 'errors');
} catch (Exception $e) {
$error++;
$errormessage = "CantRetrievePaymentIntent: ".$e->getMessage();
dol_syslog($errormessage, LOG_ERR, 0, '_payment');
setEventMessages($e->getMessage(), null, 'errors');
}
} catch (Exception $e) {
$error++;
$errmsg = 'Stripe API error: ' . $e->getMessage();
dol_syslog($errmsg, LOG_ERR, 0, '_payment');
}
} else {
$error++;
$errmsg = 'Stripe payment verification failed: TRANSACTIONID is not set or session key does not match.';
dol_syslog($errmsg, LOG_ERR, 0, '_payment');
setEventMessages($errmsg, null, 'errors');
}
if (!$error) {
$ispaymentok = true; // We will do the rest of code
} else {
$ispaymentok = false; // We won't do the rest of code
}
}
// For other payment modules
@ -407,6 +483,7 @@ if (!in_array($paymentmethod, array('paypal', 'paybox', 'stripe'))) {
}
}
// TODO: Move this block to the top to ensure all session variables (e.g., TRANSACTIONID, FinalPaymentAmt, currencyCodeType, etc.) are loaded before executing checks for any payment module.
// Get variable into the session env
if (empty($ipaddress)) {
$ipaddress = $_SESSION['ipaddress'];
@ -716,7 +793,7 @@ if ($ispaymentok) {
}
if (!$error) {
// If payment using Strip, save the Stripe payment info into societe_account
// If payment using Stripe, save the Stripe payment info into societe_account
if ($paymentmethod == 'stripe' && $autocreatethirdparty && $option == 'bankviainvoice') {
$thirdparty_id = ($object->socid ? $object->socid : $object->fk_soc);
@ -1117,7 +1194,7 @@ if ($ispaymentok) {
$paiement->paiementid = $paymentTypeId;
$paiement->num_payment = '';
$paiement->note_public = 'Online payment ' . dol_print_date($now, 'standard') . ' from ' . $ipaddress;
$paiement->ext_payment_id = $TRANSACTIONID; // pi_... for Stripe, ...
$paiement->ext_payment_id = $TRANSACTIONID; // 'pi_...' for Stripe, ... TODO Use 'pi_...:cus_...@pk_...'
$paiement->ext_payment_site = $service; // 'StripeLive' or 'Stripe', or ...
if (!$error) {
@ -1251,8 +1328,8 @@ if ($ispaymentok) {
$paiement->paymenttype = $paymentTypeId;
$paiement->num_payment = '';
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress;
$paiement->ext_payment_id = $TRANSACTIONID;
$paiement->ext_payment_site = $service;
$paiement->ext_payment_id = $TRANSACTIONID; // 'pi_...' for Stripe, ... TODO Use 'pi_...:cus_...@pk_...'
$paiement->ext_payment_site = $service; // 'StripeLive' or 'Stripe', or ...
if (!$error) {
$paiement_id = $paiement->create($user, 1);
@ -1386,8 +1463,8 @@ if ($ispaymentok) {
$paiement->paiementid = $paymentTypeId;
$paiement->num_payment = '';
$paiement->note_public = 'Online payment '.dol_print_date($now, 'standard').' from '.$ipaddress.' for event registration';
$paiement->ext_payment_id = $TRANSACTIONID;
$paiement->ext_payment_site = $service;
$paiement->ext_payment_id = $TRANSACTIONID; // 'pi_...' for Stripe, ... TODO Use 'pi_...:cus_...@pk_...'
$paiement->ext_payment_site = $service; // 'StripeLive' or 'Stripe', or ...
if (!$error) {
$paiement_id = $paiement->create($user, 1); // This include closing invoices and regenerating documents

View file

@ -133,10 +133,16 @@ try {
$event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
} catch (UnexpectedValueException $e) {
// Invalid payload
dol_syslog("***** Stripe IPN was called with UnexpectedValueException (invalid payload) service=".$service);
dol_syslog("***** Stripe IPN was called with UnexpectedValueException (invalid payload) service=".$service, LOG_DEBUG, 0, '_payment');
httponly_accessforbidden('Invalid payload', 400);
} catch (\Stripe\Exception\SignatureVerificationException $e) {
httponly_accessforbidden('Invalid signature. May be a hook for an event created by another Stripe env ? Check setup of your keys whsec_...', 400);
dol_syslog("***** Stripe IPN was called with SignatureVerificationException service=".$service);
dol_syslog("***** Stripe IPN was called with SignatureVerificationException service=".$service, LOG_DEBUG, 0, '_payment');
httponly_accessforbidden('Invalid signature. May be a hook for an event created by another Stripe env or a hack attempt ? Check setup of your keys whsec_...', 400);
} catch (Exception $e) {
dol_syslog("***** Stripe IPN was called with Exception (".$e->getMessage().") service=".$service);
dol_syslog("***** Stripe IPN was called with Exception (".$e->getMessage().") service=".$service, LOG_DEBUG, 0, '_payment');
httponly_accessforbidden('Error '.$e->getMessage(), 400);
}
@ -360,14 +366,14 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
global $stripearrayofkeysbyenv;
$error = 0;
$object = $event->data->object;
$TRANSACTIONID = $object->id; // Example pi_123456789...
$TRANSACTIONID = $object->id; // Example 'pi_123456789...'
$ipaddress = $object->metadata->ipaddress;
$now = dol_now();
$currencyCodeType = strtoupper($object->currency);
$paymentmethodstripeid = $object->payment_method;
$customer_id = $object->customer;
$invoice_id = "";
$paymentTypeCode = ""; // payment type according to Stripe
$paymentTypeCode = ""; // payment type according to Stripe
$paymentTypeCodeInDolibarr = ""; // payment type according to Dolibarr
$payment_amount = 0;
$payment_amountInDolibarr = 0;
@ -449,7 +455,9 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
}
$payment_amount = $payment_amountInDolibarr;
// TODO Check payment_amount in Stripe (received) is same than the one in Dolibarr
// TODO Add this checks ? May not be required because the message is already decoded with $event = \Stripe\Webhook::constructEvent($payload, $sig_header, $endpoint_secret);
// - Check payment_amount in Stripe (received) is same than the one in Dolibarr
// - Check that payment intent is succeed (to avoid forged json webhook sent by malicious users)
$postactionmessages = array();

View file

@ -112,7 +112,7 @@ class Receptions extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -152,7 +152,7 @@ class Recruitments extends DolibarrApi
throw new RestException(403);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object
@ -268,7 +268,7 @@ class Recruitments extends DolibarrApi
throw new RestException(403);
}
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : 0;
$socid = DolibarrApiAccess::$user->socid ?: 0;
$restrictonsocid = 0; // Set to 1 if there is a field socid in table of object

View file

@ -46,9 +46,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$langs->loadLangs(array('resource', 'companies', 'other', 'main'));
// Get parameters
$id = GETPOSTINT('id');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
$address = GETPOST('address', 'alpha');
$zip = GETPOST('zipcode', 'alpha');
@ -164,6 +166,8 @@ if (empty($reshook)) {
if (!$error) {
$res = $object->fetch($id);
if ($res > 0) {
$oldref = $object->ref;
$object->ref = $ref;
$object->address = $address;
$object->zip = $zip;
@ -185,6 +189,14 @@ if (empty($reshook)) {
$result = $object->update($user);
if ($result > 0) {
if ($oldref != $ref) {
// We renamed the ref so we must change the directory too
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$srcdir = $conf->resource->dir_output.'/'.dol_sanitizeFileName($oldref);
$destdir = $conf->resource->dir_output.'/'.dol_sanitizeFileName($ref);
dol_move_dir($srcdir, $destdir);
}
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@ -269,7 +281,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
// Ref
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("ResourceFormLabel_ref").'</td>';
print '<td><input class="minwidth200" name="ref" value="'.($ref ?: $object->ref).'" autofocus="autofocus"></td></tr>';
print '<td><input class="minwidth200" name="ref" value="'.($ref ?: $object->ref).'" autofocus="autofocus" spellcheck="false"></td></tr>';
// Type
print '<tr><td>'.$langs->trans("ResourceType").'</td>';
@ -343,21 +355,21 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_email', 'class="pictofixedwidth"');
print '<input type="email" name="email" id="email" value="'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>';
print '<input type="email" name="email" id="email" value="'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'" spellcheck="false"></td>';
print '</tr>';
// Max users
print '<tr><td>'.$form->editfieldkey('MaxUsers', 'max_users', '', $object, 0).'</td>';
print '<tr><td>'.$form->editfieldkey('MaxUsers', 'max_users', '', $object, 0, 'string', '', 0, 0, 'id', $langs->trans('MaxUsersResourceDesc')).'</td>';
print '<td>';
print img_picto('', 'object_user', 'class="pictofixedwidth"');
print '<input type="text" class="width75 right" name="max_users" id="max_users" value="'.(GETPOSTISSET('max_users') ? GETPOST('max_users', 'int') : $object->max_users).'"></td>';
print '<input type="text" class="width75 right" name="max_users" id="max_users" value="'.(GETPOSTISSET('max_users') ? GETPOST('max_users', 'int') : ($object->max_users > 0 ? $object->max_users : '')).'"></td>';
print '</tr>';
// URL
print '<tr><td>'.$form->editfieldkey('URL', 'url', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_url', 'class="pictofixedwidth"');
print '<input type="url" name="url" id="url" value="'.(GETPOSTISSET('url') ? GETPOST('url', 'alpha') : $object->url).'"></td>';
print '<input type="url" class="minwidth300" name="url" id="url" value="'.(GETPOSTISSET('url') ? GETPOST('url', 'alpha') : $object->url).'" spellcheck="false"></td>';
print '</tr>';
// Other attributes
@ -390,7 +402,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
print $formconfirm;
$linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&id='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref');
@ -420,7 +432,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) {
print '<tr>';
print '<td>'.$langs->trans("MaxUsers").'</td>';
print '<td>';
print $object->max_users;
print $object->max_users > 0 ? $object->max_users : '';
print '</td>';
print '</tr>';

View file

@ -206,21 +206,6 @@ if ($action == "setaccountancycodecustomerinvoicemandatory") {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
/* This code is not needed anymore as we can use the setprofid functions instead with key = 'VAT_INTRA'
//Activate Set vat id unique
if ($action == "setvatintraunique") {
$setvatintraunique = GETPOSTINT('value');
$res = dolibarr_set_const($db, "SOCIETE_VAT_INTRA_UNIQUE", $setvatintraunique, 'yesno', 0, '', $conf->entity);
if (!($res > 0)) {
$error++;
}
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
*/
//Activate Set ref in list
if ($action == "setaddrefinlist") {
@ -627,22 +612,15 @@ foreach ($dirsociete as $dirroot) {
// Activate / Disable
if (in_array($name, $def)) {
print "<td class=\"center\">\n";
//if ($conf->global->COMPANY_ADDON_PDF != "$name")
//{
print '<td class="center">'."\n";
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&token='.newToken().'&value='.urlencode($name).'&token='.newToken().'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
//}
//else
//{
// print img_picto($langs->trans("Enabled"),'on');
//}
print "</td>";
} else {
if (versioncompare($module->phpmin, versionphparray()) > 0) {
print '<td class="center">'."\n";
print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", implode('.', $module->phpmin))), 'switch_off');
print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", implode('.', $module->phpmin))), 'switch_off', 'class="opacitymedium"');
print "</td>";
} else {
print '<td class="center">'."\n";

View file

@ -1449,8 +1449,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
// Prospect/Customer/Supplier
$selected = $object->client;
$selectedcustomer = 0;
$selectedprospect = 0;
$selectedcustomer = (getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==1 || getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==3 ? 1 : 0);
$selectedprospect = (getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==2 || getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')==3 ? 1 : 0);
switch ($selected) {
case 1:
$selectedcustomer = 1;

View file

@ -193,7 +193,7 @@ class Contacts extends DolibarrApi
}
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -345,22 +345,22 @@ class Stripe extends CommonObject
* Note: This is used when option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on when making a payment from the public/payment/newpayment.php page
* but not when using the STRIPE_USE_NEW_CHECKOUT.
*
* @param float $amount Amount
* @param string $currency_code Currency code
* @param string $tag Tag
* @param string $description Description
* @param ?CommonObject $object Object to pay with Stripe
* @param ?string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe()
* @param ?string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
* @param int<0,1> $status Status (0=test, 1=live)
* @param int<0,1> $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt
* @param 'automatic'|'manual' $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent
* @param bool $confirmnow false=default, true=try to confirm immediately after create (if conditions are ok)
* @param ?string $payment_method 'pm_....' (if known)
* @param int<0,1> $off_session If we use an already known payment method to pay when customer is not available during the checkout flow.
* @param int<0,1> $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent
* @param int $did ID of an existing line into llx_prelevement_demande (Dolibarr intent). If provided, no new line will be created.
* @return ?\Stripe\PaymentIntent Stripe PaymentIntent or null if not found and failed to create
* @param float $amount Amount
* @param string $currency_code Currency code
* @param string $tag Tag
* @param string $description Description
* @param ?CommonObject $object Object to pay with Stripe
* @param ?string $customer Stripe customer ref 'cus_xxxxxxxxxxxxx' via customerStripe()
* @param ?string $key ''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
* @param int<0,1> $status Status (0=test, 1=live)
* @param int<0,1> $usethirdpartyemailforreceiptemail 1=use thirdparty email for receipt
* @param 'automatic'|'manual'|'terminal' $mode Automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent, terminal=manual
* @param bool $confirmnow False=default, true=try to confirm immediately after create (if conditions are ok)
* @param ?string $payment_method 'pm_....' (if known)
* @param int<0,1> $off_session If we use an already known payment method to pay when customer is not available during the checkout flow.
* @param int<0,1> $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent
* @param int $did ID of an existing line into llx_prelevement_demande (Dolibarr intent). If provided, no new line will be created.
* @return ?\Stripe\PaymentIntent Stripe PaymentIntent or null if not found and failed to create
*/
public function getPaymentIntent($amount, $currency_code, $tag, $description = '', $object = null, $customer = null, $key = null, $status = 0, $usethirdpartyemailforreceiptemail = 0, $mode = 'automatic', $confirmnow = false, $payment_method = null, $off_session = 0, $noidempotency_key = 1, $did = 0)
{
@ -454,6 +454,8 @@ class Stripe extends CommonObject
}
}
$stripemode = $mode;
// list of payment method types
$paymentmethodtypes = array("card");
$descriptor = dol_trunc($tag, 10, 'right', 'UTF-8', 1);
@ -476,8 +478,11 @@ class Stripe extends CommonObject
if (getDolGlobalInt('STRIPE_SOFORT')) {
$paymentmethodtypes[] = "sofort";
}
if (getDolGlobalInt('STRIPE_CARD_PRESENT') && $mode == 'terminal') {
$paymentmethodtypes = array("card_present");
if ($mode == 'terminal') {
if (getDolGlobalInt('STRIPE_CARD_PRESENT')) {
$paymentmethodtypes = array("card_present");
}
$stripemode = 'manual';
}
global $dolibarr_main_url_root;
@ -486,7 +491,7 @@ class Stripe extends CommonObject
$dataforintent = array(
"confirm" => $confirmnow, // try to confirm immediately after create (if conditions are ok)
"confirmation_method" => $mode,
"confirmation_method" => $stripemode,
"amount" => $stripeamount,
"currency" => $currency_code,
"payment_method_types" => $paymentmethodtypes, // When payment_method_types is set, return_url is not required but payment mode can't be managed from dashboard

View file

@ -238,7 +238,7 @@ class SupplierProposals extends DolibarrApi
$obj_ret = array();
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
$socids = DolibarrApiAccess::$user->socid ?: $thirdparty_ids;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;

View file

@ -79,7 +79,7 @@ if (!$user->hasRight('takepos', 'run')) {
top_htmlhead('', '', 1);
if ((string) $place != '') {
if ((string) $place != '' && !empty($_SESSION["takeposterminal"])) {
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref = '(PROV-POS".$db->escape($_SESSION["takeposterminal"]."-".$place).")'";
$sql .= " AND entity IN (".getEntity('invoice').")";

View file

@ -7800,6 +7800,9 @@ dd.dropdowndd ul li {
white-space: nowrap;
}
div.kanban.column div.ui-sortable-helper {
transform: rotate(4deg);
}
/* ============================================================================== */
/* Markdown rendering */

View file

@ -7680,6 +7680,10 @@ dd.dropdowndd ul li {
white-space: nowrap;
}
div.kanban.column div.ui-sortable-helper {
transform: rotate(4deg);
}
/* ============================================================================== */
/* Markdown rendering */

View file

@ -213,7 +213,7 @@ class Tickets extends DolibarrApi
$obj_ret = array();
$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $socid;
$socid = DolibarrApiAccess::$user->socid ?: $socid;
$search_sale = null;
// If the internal user must only see his customers, force searching by him

View file

@ -90,7 +90,7 @@ class Users extends DolibarrApi
$obj_ret = array();
// case of external user, $societe param is ignored and replaced by user's socid
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
//$socid = DolibarrApiAccess::$user->socid ?: $societe;
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."user AS t LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields
@ -645,7 +645,7 @@ class Users extends DolibarrApi
}
// case of external user, $societe param is ignored and replaced by user's socid
//$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe;
//$socid = DolibarrApiAccess::$user->socid ?: $societe;
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."usergroup AS t LEFT JOIN ".MAIN_DB_PREFIX."usergroup_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields

View file

@ -590,21 +590,25 @@ class User extends CommonObject
$sql .= " LEFT JOIN ".$this->db->prefix()."c_departements as d ON u.fk_state = d.rowid";
$sql .= " LEFT JOIN ".$this->db->prefix()."establishment as s ON u.fk_establishment = s.rowid";
if ($entity < 0) {
if ((!isModEnabled('multicompany') || !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (!empty($user->entity))) {
$sql .= " WHERE u.entity IN (0, ".((int) $conf->entity).")";
} else {
$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
}
if ($id > 0) {
$sql .= " WHERE u.rowid = ".((int) $id);
} else {
// The fetch was forced on an entity
if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
if ($entity < 0) {
if ((! isModEnabled('multicompany') || ! getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (! empty($user->entity))) {
$sql .= " WHERE u.entity IN (0, " . ((int) $conf->entity) . ")";
} else {
$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
}
} else {
if ($entity != '' && $entity == 0) { // If $entity = 0
$sql .= " WHERE u.entity = 0";
} else { // if $entity is -1 or > 0
$sql .= " WHERE u.entity IN (0, ".((int) ($entity > 0 ? $entity : $conf->entity)).")";
// The fetch was forced on an entity
if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
$sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
} else {
if ($entity != '' && $entity == 0) { // If $entity = 0
$sql .= " WHERE u.entity = 0";
} else { // if $entity is -1 or > 0
$sql .= " WHERE u.entity IN (0, " . ((int) ($entity > 0 ? $entity : $conf->entity)) . ")";
}
}
}
}
@ -622,9 +626,8 @@ class User extends CommonObject
$sql .= ")";
} elseif ($fk_socpeople > 0) {
$sql .= " AND u.fk_socpeople = ".((int) $fk_socpeople);
} else {
$sql .= " AND u.rowid = ".((int) $id);
}
$sql .= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
if ($sid) {

View file

@ -561,7 +561,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
$sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."c_country";
$sql .= " WHERE active = 1";
$sql .= " AND code='".$db->escape($thirdparty->country_code)."'";
$sql .= " AND code = '".$db->escape($thirdparty->country_code)."'";
$resql = $db->query($sql);
if ($resql) {
@ -575,13 +575,12 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
$thirdparty->fax = $thirdpartywithuser['fax'];
$thirdparty->email = $thirdpartywithuser['email'];
$thirdparty->url = $thirdpartywithuser['url'];
$thirdparty->ape = $thirdpartywithuser['ape'];
$thirdparty->idprof1 = $thirdpartywithuser['prof1'];
$thirdparty->idprof2 = $thirdpartywithuser['prof2'];
$thirdparty->idprof3 = $thirdpartywithuser['prof3'];
$thirdparty->idprof4 = $thirdpartywithuser['prof4'];
$thirdparty->idprof5 = $thirdpartywithuser['prof5'];
$thirdparty->idprof6 = $thirdpartywithuser['prof6'];
$thirdparty->idprof1 = $thirdpartywithuser['profid1'];
$thirdparty->idprof2 = $thirdpartywithuser['profid2'];
$thirdparty->idprof3 = $thirdpartywithuser['profid3'];
$thirdparty->idprof4 = $thirdpartywithuser['profid4'];
$thirdparty->idprof5 = $thirdpartywithuser['profid5'];
$thirdparty->idprof6 = $thirdpartywithuser['profid6'];
$thirdparty->client = (int) $thirdpartywithuser['client'];
$thirdparty->fournisseur = (int) $thirdpartywithuser['fournisseur'];

Some files were not shown because too many files have changed in this diff Show more