Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into new-api-rest-tokens

This commit is contained in:
yannis 2025-07-01 09:10:41 +02:00
commit e67d3095ed
50 changed files with 364 additions and 403 deletions

View file

@ -972,12 +972,6 @@ parameters:
count: 1
path: ../../../htdocs/adherents/list.php
-
message: '#^Variable \$diroutputmassaction might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/adherents/list.php
-
message: '#^Variable \$contextpage in empty\(\) always exists and is not falsy\.$#'
identifier: empty.variable
@ -1860,18 +1854,6 @@ parameters:
count: 2
path: ../../../htdocs/api/class/api_documents.class.php
-
message: '#^Loose comparison using \!\= between ''adherent''\|''agenda''\|''commande''\|''contact''\|''contrat''\|''expensereport''\|''facture''\|''fichinter''\|''mrp''\|''product''\|''produit''\|''produit\|service''\|''project''\|''project_task''\|''projet''\|''propale''\|''service''\|''supplier_invoice''\|''supplier_order'' and ''ecm'' will always evaluate to true\.$#'
identifier: notEqual.alwaysTrue
count: 1
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
@ -3273,7 +3255,7 @@ parameters:
-
message: '#^Ternary operator condition is always true\.$#'
identifier: ternary.alwaysTrue
count: 6
count: 4
path: ../../../htdocs/comm/action/peruser.php
-
@ -6678,12 +6660,6 @@ parameters:
count: 1
path: ../../../htdocs/core/actions_setmoduleoptions.inc.php
-
message: '#^Variable \$modulepart might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../../htdocs/core/actions_setmoduleoptions.inc.php
-
message: '#^Variable \$result might not be defined\.$#'
identifier: variable.undefined
@ -19368,12 +19344,6 @@ parameters:
count: 1
path: ../../../htdocs/projet/element.php
-
message: '#^Variable \$margin in isset\(\) always exists and is not nullable\.$#'
identifier: isset.variable
count: 2
path: ../../../htdocs/projet/element.php
-
message: '#^Variable \$total_time in isset\(\) always exists and is not nullable\.$#'
identifier: isset.variable

View file

@ -243,6 +243,7 @@ class BookKeeping extends CommonObject
}
if (isset($this->doc_ref)) {
$this->doc_ref = trim($this->doc_ref);
$this->doc_ref = dol_trunc($this->doc_ref, 300); // We limit to 300 chars to avoid problems with too long ref in DB
}
if (isset($this->fk_doc)) {
$this->fk_doc = (int) $this->fk_doc;
@ -1192,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) {
@ -3903,4 +3904,9 @@ class BookKeepingLine extends CommonObjectLine
* @var int|string
*/
public $date_lim_reglement;
/**
* @var string
*/
public $code_tiers;
}

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

@ -101,7 +101,7 @@ if ($action == 'set') {
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
$defaultValues = new DefaultValues($db);
$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page' => 'comm/action/card.php', 't.param' => 'complete', 't.user_id' => '0', 't.type' => 'createform', 't.entity' => (string) $conf->entity));
$result = $defaultValues->fetchAll('', '', 0, 0, "(t.page:=:'comm/action/card.php') AND (t.param:=:'complete') AND (t.user_id:=:0) AND (t.type:=:'createform') AND (t.entity:=:".((int) $conf->entity).")");
if (!is_array($result) && $result < 0) {
setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
} elseif (count($result) > 0) {
@ -391,7 +391,7 @@ print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right nowrap">'."\n";
$defval = 'na';
$defaultValues = new DefaultValues($db);
$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page' => 'comm/action/card.php', 't.param' => 'complete', 't.user_id' => '0', 't.type' => 'createform', 't.entity' => (string) $conf->entity));
$result = $defaultValues->fetchAll('', '', 0, 0, "(t.page:=:'comm/action/card.php') AND (t.param:=:'complete') AND (t.user_id:=:0) AND (t.type:=:'createform') AND (t.entity:=:".((int) $conf->entity).")");
if (!is_array($result) && $result < 0) {
setEventMessages($defaultValues->error, $defaultValues->errors, 'errors');
} elseif (count($result) > 0) {

View file

@ -368,8 +368,8 @@ if (!getDolGlobalString('MAIN_ENABLE_DEFAULT_VALUES')) {
print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add">';
print '</td>'."\n";
print '</tr>'."\n";
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type' => $mode, 't.entity' => array($user->entity,$conf->entity)));
//"(t.type:=:".$mode.") AND (t.entity:in:("((int)$user->entity).", ".((int)$conf->entity)."))"
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, "(t.type:=:'".$mode."') AND (t.entity:in:".((int) $user->entity).", ".((int) $conf->entity).")");
if (!is_array($result) && $result < 0) {
setEventMessages($object->error, $object->errors, 'errors');

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

@ -548,7 +548,7 @@ class Documents extends DolibarrApi
} elseif ($modulepart == 'knowledgemanagement') {
require_once DOL_DOCUMENT_ROOT.'/knowledgemanagement/class/knowledgerecord.class.php';
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read') && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
if (!DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) {
throw new RestException(403);
}

View file

@ -234,6 +234,7 @@ if (empty($reshook)) {
}
}
/*
* View
*/
@ -403,16 +404,16 @@ if ($search_label) {
$param .= '&search_label='.urlencode($search_label);
}
if ($search_datep_start) {
$param .= '&search_datep_start='.urlencode($search_datep_start);
$param .= '&search_datep_start='.urlencode((string) $search_datep_start);
}
if ($search_datep_end) {
$param .= '&search_datep_end='.urlencode($search_datep_end);
$param .= '&search_datep_end='.urlencode((string) $search_datep_end);
}
if ($search_datev_start) {
$param .= '&search_datev_start='.urlencode($search_datev_start);
$param .= '&search_datev_start='.urlencode((string) $search_datev_start);
}
if ($search_datev_end) {
$param .= '&search_datev_end='.urlencode($search_datev_end);
$param .= '&search_datev_end='.urlencode((string) $search_datev_end);
}
if ($search_type_id > 0) {
$param .= '&search_type_id='.urlencode((string) ($search_type_id));

View file

@ -6189,7 +6189,7 @@ class Facture extends CommonInvoice
} else {
$sql .= " AND f.date_lim_reglement = '".$this->db->idate($tmpidate, 'gmt')."'";
}
$sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // One batch process only one company (no sharing)
$sql .= " AND f.entity IN (".getEntity('facture', 0).")"; // One batch processes only one company (no sharing)
if (!empty($paymentmode) && $paymentmode != 'all') {
$sql .= " AND f.fk_mode_reglement = cp.id AND cp.code = '".$this->db->escape($paymentmode)."'";
}
@ -6199,6 +6199,7 @@ class Facture extends CommonInvoice
} else {
$sql .= $this->db->order("date_lim_reglement", "ASC");
}
// TODO Add a date date_last_remind_email in select. We can update date after the result of sendfile() later. To avoid to send it twiceif we rerun the batch.
$resql = $this->db->query($sql);
@ -6215,210 +6216,217 @@ class Facture extends CommonInvoice
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
if (!$error) {
// Load event
$res = $tmpinvoice->fetch($obj->id);
if ($res > 0) {
$tmpinvoice->fetch_thirdparty();
// Create a loopError that is reset at each loop, this counter is added to the global counter at the end of loop
$loopError = 0;
$outputlangs = new Translate('', $conf);
if ($tmpinvoice->thirdparty->default_lang) {
$outputlangs->setDefaultLang($tmpinvoice->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "bills"));
} else {
$outputlangs = $langs;
}
// Load event
$res = $tmpinvoice->fetch($obj->id);
if ($res > 0) {
$tmpinvoice->fetch_thirdparty();
// Select email template according to language of recipient
$arraymessage = $formmail->getEMailTemplate($this->db, 'facture_send', $user, $outputlangs, (is_numeric($template) ? $template : 0), 1, (is_numeric($template) ? '' : $template));
if (is_numeric($arraymessage) && $arraymessage <= 0) {
$langs->load("errors");
$this->output .= $langs->trans('ErrorFailedToFindEmailTemplate', $template);
return 0;
}
$outputlangs = new Translate('', $conf);
if ($tmpinvoice->thirdparty->default_lang) {
$outputlangs->setDefaultLang($tmpinvoice->thirdparty->default_lang);
$outputlangs->loadLangs(array("main", "bills"));
} else {
$outputlangs = $langs;
}
// PREPARE EMAIL
$errormesg = '';
// Select email template according to language of recipient
$arraymessage = $formmail->getEMailTemplate($this->db, 'facture_send', $user, $outputlangs, (is_numeric($template) ? $template : 0), 1, (is_numeric($template) ? '' : $template));
if (is_numeric($arraymessage) && $arraymessage <= 0) {
$langs->load("errors");
$this->output .= $langs->trans('ErrorFailedToFindEmailTemplate', $template);
return 0;
}
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $tmpinvoice);
// PREPARE EMAIL
$errormesg = '';
complete_substitutions_array($substitutionarray, $outputlangs, $tmpinvoice);
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $tmpinvoice);
// Topic
$sendTopic = make_substitutions(empty($arraymessage->topic) ? $outputlangs->transnoentitiesnoconv('InformationMessage') : $arraymessage->topic, $substitutionarray, $outputlangs, 1);
complete_substitutions_array($substitutionarray, $outputlangs, $tmpinvoice);
// Content
$content = $outputlangs->transnoentitiesnoconv($arraymessage->content);
// Topic
$sendTopic = make_substitutions(empty($arraymessage->topic) ? $outputlangs->transnoentitiesnoconv('InformationMessage') : $arraymessage->topic, $substitutionarray, $outputlangs, 1);
$sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1);
// Content
$content = $outputlangs->transnoentitiesnoconv($arraymessage->content);
// Recipient
$to = array();
if ($forcerecipient) { // If a recipient was forced
$to = array($forcerecipient);
} else {
$res = $tmpinvoice->fetch_thirdparty();
$recipient = $tmpinvoice->thirdparty;
if ($res > 0) {
$tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING');
if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
foreach ($tmparraycontact as $data_email) {
if (!empty($data_email['email'])) {
$to[] = $tmpinvoice->thirdparty->contact_get_property($data_email['id'], 'email');
}
$sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1);
// Recipient
$to = array();
if ($forcerecipient) { // If a recipient was forced
$to = array($forcerecipient);
} else {
$res = $tmpinvoice->fetch_thirdparty();
$recipient = $tmpinvoice->thirdparty;
if ($res > 0) {
$tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING');
if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
foreach ($tmparraycontact as $data_email) {
if (!empty($data_email['email'])) {
$to[] = $tmpinvoice->thirdparty->contact_get_property($data_email['id'], 'email');
}
}
if (empty($to) && !empty($recipient->email)) {
$to[] = $recipient->email;
}
if (empty($to)) {
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for invoice or customer.";
$error++;
}
} else {
$errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid;
$error++;
}
if (empty($to) && !empty($recipient->email)) {
$to[] = $recipient->email;
}
if (empty($to)) {
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for invoice or customer.";
$loopError++;
}
} else {
$errormesg = "Failed to load recipient with thirdparty id=".$tmpinvoice->socid;
$loopError++;
}
// Sender
$from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
if (!empty($arraymessage->email_from)) { // If a sender is defined into template, we use it in priority
$from = (string) $arraymessage->email_from;
}
if (empty($from)) {
$errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
$error++;
}
if (!$error && !empty($to)) {
$this->db->begin();
$to = implode(',', $to);
if (!empty($arraymessage->email_to)) { // If a recipient is defined into template, we add it
$to = $to.','.$arraymessage->email_to;
}
// Errors Recipient
$errors_to = getDolGlobalString('MAIN_MAIL_ERRORS_TO');
$trackid = 'inv'.$tmpinvoice->id;
$sendcontext = 'standard';
$email_tocc = '';
if (!empty($arraymessage->email_tocc)) { // If a CC is defined into template, we use it
$email_tocc = (string) $arraymessage->email_tocc;
}
$email_tobcc = '';
if (!empty($arraymessage->email_tobcc)) { // If a BCC is defined into template, we use it
$email_tobcc = (string) $arraymessage->email_tobcc;
}
//join file is asked
$joinFile = [];
$joinFileName = [];
$joinFileMime = [];
if ($arraymessage->joinfiles == 1 && !empty($tmpinvoice->last_main_doc)) {
$joinFile[] = DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc;
$joinFileName[] = basename($tmpinvoice->last_main_doc);
$joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc);
}
// Mail Creation
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, $joinFile, $joinFileMime, $joinFileName, $email_tocc, $email_tobcc, 0, 1, $errors_to, '', $trackid, '', $sendcontext, '');
// Sending Mail
if ($cMailFile->sendfile()) {
$nbMailSend++;
// Add a line into event table
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$actioncomm->socid = $tmpinvoice->thirdparty->id; // To link to a company
$actioncomm->contact_id = 0;
$actioncomm->code = 'AC_EMAIL';
$actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateOK (nbdays='.$nbdays.' paymentmode='.$paymentmode.' template='.$template.' datetouse='.$datetouse.' forcerecipient='.$forcerecipient.')';
$actioncomm->note_private = $sendContent;
$actioncomm->fk_project = $tmpinvoice->fk_project;
$actioncomm->datep = dol_now();
$actioncomm->datef = $actioncomm->datep;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $cMailFile->msgid;
$actioncomm->email_subject = $sendTopic;
$actioncomm->email_from = $from;
$actioncomm->email_sender = '';
$actioncomm->email_to = $to;
//$actioncomm->email_tocc = $sendtocc;
//$actioncomm->email_tobcc = $sendtobcc;
//$actioncomm->email_subject = $subject;
$actioncomm->errors_to = $errors_to;
$actioncomm->elementtype = 'invoice';
$actioncomm->elementid = $tmpinvoice->id;
$actioncomm->fk_element = $tmpinvoice->id;
//$actioncomm->extraparams = $extraparams;
$actioncomm->create($user);
} else {
$errormesg = $cMailFile->error.' : '.$to;
$error++;
// Add a line into event table
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$actioncomm->socid = $tmpinvoice->thirdparty->id; // To link to a company
$actioncomm->contact_id = 0;
$actioncomm->code = 'AC_EMAIL';
$actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateKO';
$actioncomm->note_private = $errormesg;
$actioncomm->fk_project = $tmpinvoice->fk_project;
$actioncomm->datep = dol_now();
$actioncomm->datef = $actioncomm->datep;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $cMailFile->msgid;
$actioncomm->email_from = $from;
$actioncomm->email_sender = '';
$actioncomm->email_to = $to;
//$actioncomm->email_tocc = $sendtocc;
//$actioncomm->email_tobcc = $sendtobcc;
//$actioncomm->email_subject = $subject;
$actioncomm->errors_to = $errors_to;
//$actioncomm->extraparams = $extraparams;
$actioncomm->create($user);
}
$this->db->commit(); // We always commit
}
if ($errormesg) {
$errorsMsg[] = $errormesg;
}
} else {
$errorsMsg[] = 'Failed to fetch record invoice with ID = '.$obj->id;
$error++;
}
// Sender
$from = getDolGlobalString('MAIN_MAIL_EMAIL_FROM');
if (!empty($arraymessage->email_from)) { // If a sender is defined into template, we use it in priority
$from = (string) $arraymessage->email_from;
}
if (empty($from)) {
$errormesg = "Failed to get sender into global setup MAIN_MAIL_EMAIL_FROM";
$loopError++;
}
if (!$loopError && !empty($to)) {
$to = implode(',', $to);
if (!empty($arraymessage->email_to)) { // If a recipient is defined into template, we add it
$to = $to.','.$arraymessage->email_to;
}
// Errors Recipient
$errors_to = getDolGlobalString('MAIN_MAIL_ERRORS_TO');
$trackid = 'inv'.$tmpinvoice->id;
$sendcontext = 'standard';
$email_tocc = '';
if (!empty($arraymessage->email_tocc)) { // If a CC is defined into template, we use it
$email_tocc = (string) $arraymessage->email_tocc;
}
$email_tobcc = '';
if (!empty($arraymessage->email_tobcc)) { // If a BCC is defined into template, we use it
$email_tobcc = (string) $arraymessage->email_tobcc;
}
//join file is asked
$joinFile = [];
$joinFileName = [];
$joinFileMime = [];
if ($arraymessage->joinfiles == 1 && !empty($tmpinvoice->last_main_doc)) {
$joinFile[] = DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc;
$joinFileName[] = basename($tmpinvoice->last_main_doc);
$joinFileMime[] = dol_mimetype(DOL_DATA_ROOT.'/'.$tmpinvoice->last_main_doc);
}
// Mail Creation
$cMailFile = new CMailFile($sendTopic, $to, $from, $sendContent, $joinFile, $joinFileMime, $joinFileName, $email_tocc, $email_tobcc, 0, 1, $errors_to, '', $trackid, '', $sendcontext, '');
$resultsendmail = $cMailFile->sendfile();
$this->db->begin();
// Sending Mail
if ($resultsendmail) {
$nbMailSend++;
// Add a line into event table
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$actioncomm->socid = $tmpinvoice->thirdparty->id; // To link to a company
$actioncomm->contact_id = 0;
$actioncomm->code = 'AC_EMAIL';
$actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateOK (nbdays='.$nbdays.' paymentmode='.$paymentmode.' template='.$template.' datetouse='.$datetouse.' forcerecipient='.$forcerecipient.')';
$actioncomm->note_private = $sendContent;
$actioncomm->fk_project = $tmpinvoice->fk_project;
$actioncomm->datep = dol_now();
$actioncomm->datef = $actioncomm->datep;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $cMailFile->msgid;
$actioncomm->email_subject = $sendTopic;
$actioncomm->email_from = $from;
$actioncomm->email_sender = '';
$actioncomm->email_to = $to;
//$actioncomm->email_tocc = $sendtocc;
//$actioncomm->email_tobcc = $sendtobcc;
//$actioncomm->email_subject = $subject;
$actioncomm->errors_to = $errors_to;
$actioncomm->elementtype = 'invoice';
$actioncomm->elementid = $tmpinvoice->id;
//$actioncomm->extraparams = $extraparams;
$actioncomm->create($user);
} else {
$errormesg = $cMailFile->error.' : '.$to;
$loopError++;
// Add a line into event table
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Event insert into agenda automatically
$actioncomm->socid = $tmpinvoice->thirdparty->id; // To link to a company
$actioncomm->contact_id = 0;
$actioncomm->code = 'AC_EMAIL';
$actioncomm->label = 'sendEmailsRemindersOnInvoiceDueDateKO';
$actioncomm->note_private = $errormesg;
$actioncomm->fk_project = $tmpinvoice->fk_project;
$actioncomm->datep = dol_now();
$actioncomm->datef = $actioncomm->datep;
$actioncomm->percentage = -1; // Not applicable
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
// Fields when action is an email (content should be added into note)
$actioncomm->email_msgid = $cMailFile->msgid;
$actioncomm->email_from = $from;
$actioncomm->email_sender = '';
$actioncomm->email_to = $to;
//$actioncomm->email_tocc = $sendtocc;
//$actioncomm->email_tobcc = $sendtobcc;
//$actioncomm->email_subject = $subject;
$actioncomm->errors_to = $errors_to;
$actioncomm->elementtype = 'invoice';
$actioncomm->elementid = $tmpinvoice->id;
//$actioncomm->extraparams = $extraparams;
$actioncomm->create($user);
}
$this->db->commit(); // We always commit
}
if ($errormesg) {
$errorsMsg[] = $errormesg;
}
} else {
$errorsMsg[] = 'Failed to fetch record invoice with ID = '.$obj->id;
$loopError++;
}
$error += $loopError;
}
} else {
$error++;

View file

@ -664,7 +664,7 @@ if ($search_date_creation_startday) {
$param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
}
if ($search_date_creation_start) {
$param .= '&search_date_creation_start='.urlencode($search_date_creation_start);
$param .= '&search_date_creation_start='.urlencode((string) $search_date_creation_start);
}
if ($search_date_creation_endmonth) {
$param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
@ -676,7 +676,7 @@ if ($search_date_creation_endday) {
$param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday));
}
if ($search_date_creation_end) {
$param .= '&search_date_creation_end='.urlencode($search_date_creation_end);
$param .= '&search_date_creation_end='.urlencode((string) $search_date_creation_end);
}
if ($search_date_modif_startmonth) {
$param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth));
@ -688,7 +688,7 @@ if ($search_date_modif_startday) {
$param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
}
if ($search_date_modif_start) {
$param .= '&search_date_modif_start='.urlencode($search_date_modif_start);
$param .= '&search_date_modif_start='.urlencode((string) $search_date_modif_start);
}
if ($search_date_modif_endmonth) {
$param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
@ -700,7 +700,7 @@ if ($search_date_modif_endday) {
$param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
}
if ($search_date_modif_end) {
$param .= '&search_date_modif_end=' . urlencode($search_date_modif_end);
$param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end);
}
if ($search_date_startday > 0) {
$param .= '&search_date_startday='.urlencode((string) ($search_date_startday));

View file

@ -29,20 +29,29 @@
// $permissiontoadd must be defined
// $upload_dir must be defined (example $conf->project->dir_output . "/";)
// $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not.
/**
* @var Conf $conf
* @var Translate $langs
* @var User $user
* @var CommonObject $object
*
* @var string $action
* @var int $id
* @var CommonObject $object
* @var ?int $permissiontocreate
* @var ?int $permissioncreate
* @var ?int $usercangeneratedoc
* @var int $permissiontoadd
* @var string $upload_dir
*
* @var ?int $hidedetails
* @var ?int $hidedesc
* @var ?int $hideref
* @var ?array<string,mixed> $moreparams
*/
'
@phan-var-force ?array<string,mixed> $moreparams
';
if (!empty($permissioncreate) && empty($permissiontoadd)) {
$permissiontoadd = $permissioncreate; // For backward compatibility
}
@ -87,18 +96,10 @@ if ($action == 'builddoc' && ($permissiontoadd || !empty($usercangeneretedoc)))
}
// To be sure vars is defined
if (empty($hidedetails)) {
$hidedetails = 0;
}
if (empty($hidedesc)) {
$hidedesc = 0;
}
if (empty($hideref)) {
$hideref = 0;
}
if (empty($moreparams)) {
$moreparams = null;
}
$hidedetails = isset($hidedetails) ? $hidedetails : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
$hidedesc = isset($hidedesc) ? $hidedesc : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
$hideref = isset($hideref) ? $hideref : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
$moreparams = isset($moreparams) ? $moreparams : null;
$result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if ($result <= 0) {

View file

@ -34,6 +34,7 @@
// $permissiontoread, $permissiontoadd, $permissiontodelete, $permissiontoclose may be defined
// $uploaddir may be defined (example to $conf->project->dir_output."/";)
// $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not.
// $toselect may be defined
// $diroutputmassaction may be defined
// $confirm
@ -65,6 +66,11 @@
* @var string $month
* @var string $year
* @var int $error
*
* @var ?int $hidedetails
* @var ?int $hidedesc
* @var ?int $hideref
* @var ?array<string,mixed> $moreparams
*/
'
@phan-var-force ?string $permissiontoread
@ -76,6 +82,7 @@
@phan-var-force ?string $objectlabel
@phan-var-force ?string $option
@phan-var-force int $deliveryreceipt
@phan-var-force ?array<string,mixed> $moreparams
';
@ -1082,13 +1089,14 @@ if (!$error && $massaction == 'validate' && $permissiontoadd) {
}
$model = $objecttmp->model_pdf;
$ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records
// To be sure vars is defined
$hidedetails = !empty($hidedetails) ? $hidedetails : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
$hidedesc = !empty($hidedesc) ? $hidedesc : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
$hideref = !empty($hideref) ? $hideref : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
$moreparams = !empty($moreparams) ? $moreparams : null;
$result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
// To be sure vars is defined
$hidedetails = isset($hidedetails) ? $hidedetails : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
$hidedesc = isset($hidedesc) ? $hidedesc : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
$hideref = isset($hideref) ? $hideref : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
$moreparams = isset($moreparams) ? $moreparams : null;
$result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if ($result < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
}
@ -1246,18 +1254,10 @@ EOPHAN;
}
// To be sure vars is defined
if (empty($hidedetails)) {
$hidedetails = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
}
if (empty($hidedesc)) {
$hidedesc = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
}
if (empty($hideref)) {
$hideref = (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
}
if (empty($moreparams)) {
$moreparams = null;
}
$hidedetails = isset($hidedetails) ? $hidedetails : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0);
$hidedesc = isset($hidedesc) ? $hidedesc : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0);
$hideref = isset($hideref) ? $hideref : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0);
$moreparams = isset($moreparams) ? $moreparams : null;
$result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);

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

@ -125,7 +125,7 @@ abstract class CommonObject
/**
* @var int<0,1>|string Does this object support multicompany module ?
* 0=No test on entity, 1=Test with field entity for internal and external users, 'field@table'=Test with link by field@table (example 'fk_soc@societe')
* 0=No test on entity, 1=Test with field entity in local table, 'field@table'=Test entity into the field@table (example 'fk_soc@societe')
*/
public $ismultientitymanaged;

View file

@ -6188,8 +6188,8 @@ class Form
$formconfirm .= '
resizable: false,
height: \'' . ((int) $height) . '\',
width: \'' . ((int) $width) . '\',
height: \'' . dol_escape_js($height) . '\',
width: \'' . dol_escape_js($width) . '\',
modal: true,
closeOnEscape: false,
buttons: {
@ -9105,7 +9105,7 @@ class Form
$sql .= " LEFT JOIN " . $this->db->prefix() . "product as p ON p.rowid = t.fk_product";
}
if (!empty($objecttmp->ismultientitymanaged)) {
if ($objecttmp->ismultientitymanaged == 1) {
if ($objecttmp->ismultientitymanaged == 1) { // @phan-suppress-current-line PhanPluginEmptyStatementIf
// No need to join/link another table
}
if (!is_numeric($objecttmp->ismultientitymanaged)) {
@ -9127,6 +9127,8 @@ class Form
$sql .= $hookmanager->resPrint;
} else {
$sql .= " WHERE 1=1";
// If table need a multientity restriction
if (!empty($objecttmp->ismultientitymanaged)) {
if ($objecttmp->ismultientitymanaged == 1) {
$sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
@ -9142,23 +9144,14 @@ class Form
$sql .= " WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $user->id).")";
}
}
// If user is external user, we also make a test on llx_societe_commerciaux
if (!empty($user->socid)) {
if ($objecttmp->ismultientitymanaged == 1) {
if ($objecttmp->element == 'societe') {
$sql .= " AND t.rowid = " . ((int) $user->socid);
} else {
$sql .= " AND t.fk_soc = " . ((int) $user->socid);
}
}
if (!is_numeric($objecttmp->ismultientitymanaged)) {
$sql .= " AND t." . $this->db->sanitize($tmparray[0])." = ".((int) $user->socid);
}
// If the parent table is llx_societe and user is an external user,
// then we must also check that user has permissions
if ($objecttmp->ismultientitymanaged === 'fk_soc@societe') {
$sql .= " AND t.fk_soc = ".((int) $user->socid);
}
}
// If user is external user, we must also make a test on llx_societe_commerciaux
if (!empty($user->socid)) {
if ($objecttmp->element == 'societe') {
$sql .= " AND t.rowid = " . ((int) $user->socid);
} elseif (!empty($objecttmp->fields['fk_soc']) || !empty($objecttmp->fields['t.fk_soc']) || property_exists($objecttmp, 'fk_soc') || property_exists($objecttmp, 'socid')) {
$sql .= " AND t.fk_soc = " . ((int) $user->socid);
}
}

View file

@ -1399,10 +1399,10 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$param .= '&search_note_private='.urlencode($search_note_private);
}
if ($search_birthday_dtstart != '') {
$param .= '&search_birthday_dtstart='.urlencode($search_birthday_dtstart);
$param .= '&search_birthday_dtstart='.urlencode((string) $search_birthday_dtstart);
}
if ($search_birthday_dtend != '') {
$param .= '&search_birthday_dtend='.urlencode($search_birthday_dtend);
$param .= '&search_birthday_dtend='.urlencode((string) $search_birthday_dtend);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);

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

View file

@ -98,7 +98,7 @@ class mod_asset_standard extends ModeleNumRefAsset
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -137,7 +137,7 @@ class mod_asset_standard extends ModeleNumRefAsset
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -98,7 +98,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -136,7 +136,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

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

@ -99,7 +99,7 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -137,7 +137,7 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -97,7 +97,7 @@ class mod_workstation_standard extends ModeleNumRefWorkstation
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -333,7 +333,7 @@ if ($massaction == 'presend') {
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
$substitutionarray['__EMAIL__'] = empty($sendto) ? '__EMAIL__' : $sendto;
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag=undefined&securitykey='.dol_hash(getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY')."-undefined", 'md5').'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__ONLINE_PAYMENT_URL__'] = 'UrlToPayOnlineIfApplicable';
$substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = 'TextAndUrlToPayOnlineIfApplicable';

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

@ -426,7 +426,6 @@ class Export
}
break;
case 'Duree':
break;
case 'Numeric':
// if there is a signe +
if (strpos($ValueField, "+") > 0) {
@ -649,7 +648,6 @@ class Export
$szMsg = $langs->trans('ExportDateFilter');
break;
case 'Duree':
break;
case 'Numeric':
$szMsg = $langs->trans('ExportNumericFilter');
break;

View file

@ -3547,7 +3547,7 @@ class CommandeFournisseur extends CommonOrder
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
global $conf, $langs;
global $langs;
if (!dol_strlen($modele)) {
$modele = ''; // No doc template/generation by default

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

@ -5,7 +5,7 @@
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
-- Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.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
-- the Free Software Foundation; either version 3 of the License, or
@ -54,7 +54,7 @@ create table llx_facture
total_tva double(24,8) DEFAULT 0, -- amount total tva apres remise totale
localtax1 double(24,8) DEFAULT 0, -- amount total localtax1
localtax2 double(24,8) DEFAULT 0, -- amount total localtax2
localtax2 double(24,8) DEFAULT 0, -- amount total localtax2
revenuestamp double(24,8) DEFAULT 0, -- amount total revenuestamp
total_ht double(24,8) DEFAULT 0, -- amount total ht apres remise totale
total_ttc double(24,8) DEFAULT 0, -- amount total ttc apres remise totale
@ -65,7 +65,7 @@ create table llx_facture
fk_user_modif integer, -- user making last change
fk_user_valid integer, -- user validating
fk_user_closing integer, -- user closing
module_source varchar(32), -- name of module when invoice generated by a dedicated module (POS, ecommerce...)
pos_source varchar(32), -- numero of POS terminal when order is generated by a POS module, IDsession@IDwebsite when order is generated for a website basket.
fk_fac_rec_source integer, -- facture rec source
@ -75,7 +75,7 @@ create table llx_facture
fk_account integer, -- bank account
fk_currency varchar(3), -- currency code
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- payment term (30 days, end of month...)
fk_mode_reglement integer, -- payment mode (Virement, Prelevement)
date_lim_reglement date, -- due date
@ -85,6 +85,7 @@ create table llx_facture
model_pdf varchar(255),
last_main_doc varchar(255), -- relative filepath+filename of last main generated document
fk_input_reason integer DEFAULT NULL, -- id coming from c_input_reason
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
@ -103,6 +104,7 @@ create table llx_facture
import_key varchar(14),
extraparams varchar(255), -- for other parameters with json format
is_also_delivery_note tinyint DEFAULT 0 NOT NULL, -- 0=default, 1=can act also as a delivery note (for countries that accept invoices as delivery notes)
fk_multicurrency integer,
multicurrency_code varchar(3),
multicurrency_tx double(24,8) DEFAULT 1,

View file

@ -96,7 +96,7 @@ class mod_knowledgerecord_standard extends ModeleNumRefKnowledgeRecord
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -134,7 +134,7 @@ class mod_knowledgerecord_standard extends ModeleNumRefKnowledgeRecord
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -117,6 +117,7 @@ PredefinedMailContentLink=You can click on the link below to make your payment i
PredefinedMailContentGeneric=__(Hello)__\n\n\n__(Sincerely)__\n\n__SENDEREMAIL_SIGNATURE__
PredefinedMailContentSendActionComm=Event reminder "__EVENT_LABEL__" on __EVENT_DATE__ at __EVENT_TIME__<br><br>This is an automatic message, please do not reply.
DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available.
DemoDesc2=This is a restricted shared demo, you may prefer to test on your own dedicated instance with a full admin access, to do so, <a href="%s" target="_blank">go here <span class="fas fa-external-link-alt"></span></a>.
ChooseYourDemoProfil=Choose the demo profile that best suits your needs...
ChooseYourDemoProfilMore=...or build your own profile<br>(manual module selection)
DemoFundation=Manage members of a foundation

View file

@ -102,12 +102,9 @@ class ActionsMyModule extends CommonHookActions
*/
public function doActions($parameters, &$object, &$action, $hookmanager)
{
global $conf, $user, $langs;
$error = 0; // Error counter
/* print_r($parameters); print_r($object); echo "action: " . $action; */
// @phan-suppress-next-line PhanPluginEmptyStatementIf
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
// Do what you want here...
// You can for example load and use call global vars like $fieldstosearchall to overwrite them, or update the database depending on $action and GETPOST values.
@ -216,7 +213,8 @@ class ActionsMyModule extends CommonHookActions
/* print_r($parameters); print_r($object); echo "action: " . $action; */
// @phan-suppress-next-line PhanPluginEmptyStatementIf
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) {
// do something only for the context 'somecontext1' or 'somecontext2'
}
return $ret;

View file

@ -97,7 +97,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) { // @phan-suppress-current-line PhanPluginEmptyStatementIf
} elseif (!is_numeric($object->ismultientitymanaged)) { // @phan-suppress-current-line PhanPluginEmptyStatementIf
// TODO
}
@ -135,7 +135,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -97,7 +97,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -135,7 +135,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -781,7 +781,7 @@ class Product extends CommonObject
*
* @var array<string,array<int,array{0:int,1:float,2:int,3:string,4:int,5:string}>>
*/
public $sousprods;
public $sousprods = array();
/**
* @var array<int,array{id:int,id_parent:int,ref:string,nb:int,nb_total:int,stock:float,stock_alert:float,label:string,fullpath:string,type:int,desiredstick:float,level:int,incdec:int<0,1>,entity:CommonObject}> Path of subproducts. Build from ->sousprods with get_arbo_each_prod()

View file

@ -500,6 +500,7 @@ class Tasks extends DolibarrApi
* @return array
* @phan-return array{success:array{code:int,message:string}}
* @phpstan-return array{success:array{code:int,message:string}}
* @throws RestException
*/
public function delete($id)
{
@ -515,7 +516,7 @@ class Tasks extends DolibarrApi
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
if (!$this->task->delete(DolibarrApiAccess::$user)) {
if ($this->task->delete(DolibarrApiAccess::$user) <= 0) {
throw new RestException(500, 'Error when delete task : '.$this->task->error);
}

View file

@ -310,14 +310,13 @@ if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && !empty($object->usage_opp
if ($code) {
print $langs->trans("OppStatus".$code);
}
print '</td></tr>';
// Opportunity percent
print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
if (!is_null($object->opp_percent) && strcmp($object->opp_percent, '')) {
print ' <span title="'.$langs->trans("OpportunityProbability").'"> / ';
if (strcmp($object->opp_percent, '')) {
print price($object->opp_percent, 0, $langs, 1, 0).' %';
}
print '</td></tr>';
print '</span></td></tr>';
// Opportunity Amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
@ -602,7 +601,7 @@ $listofreferent = array(
'name' => "Loan",
'title' => "ListLoanAssociatedProject",
'class' => 'Loan',
'margin' => 'add',
'margin' => '',
'table' => 'loan',
'datefieldname' => 'datestart',
'disableamount' => 0,

View file

@ -965,7 +965,7 @@ if ($search_date_start_startday) {
$param .= '&search_date_start_startday='.urlencode((string) ($search_date_start_startday));
}
if ($search_date_start_start) {
$param .= '&search_date_start_start='.urlencode($search_date_start_start);
$param .= '&search_date_start_start='.urlencode((string) $search_date_start_start);
}
if ($search_date_start_endmonth) {
$param .= '&search_date_start_endmonth='.urlencode((string) ($search_date_start_endmonth));
@ -989,7 +989,7 @@ if ($search_date_end_startday) {
$param .= '&search_date_end_startday='.urlencode((string) ($search_date_end_startday));
}
if ($search_date_end_start) {
$param .= '&search_date_end_start='.urlencode($search_date_end_start);
$param .= '&search_date_end_start='.urlencode((string) $search_date_end_start);
}
if ($search_date_end_endmonth) {
$param .= '&search_date_end_endmonth='.urlencode((string) ($search_date_end_endmonth));
@ -1001,7 +1001,7 @@ if ($search_date_end_endday) {
$param .= '&search_date_end_endday='.urlencode((string) ($search_date_end_endday));
}
if ($search_date_end_end) {
$param .= '&search_date_end_end=' . urlencode($search_date_end_end);
$param .= '&search_date_end_end=' . urlencode((string) $search_date_end_end);
}
if ($search_date_creation_startmonth) {
$param .= '&search_date_creation_startmonth='.urlencode((string) ($search_date_creation_startmonth));
@ -1013,7 +1013,7 @@ if ($search_date_creation_startday) {
$param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
}
if ($search_date_creation_start) {
$param .= '&search_date_creation_start='.urlencode($search_date_creation_start);
$param .= '&search_date_creation_start='.urlencode((string) $search_date_creation_start);
}
if ($search_date_creation_endmonth) {
$param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
@ -1037,7 +1037,7 @@ if ($search_date_modif_startday) {
$param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
}
if ($search_date_modif_start) {
$param .= '&search_date_modif_start='.urlencode($search_date_modif_start);
$param .= '&search_date_modif_start='.urlencode((string) $search_date_modif_start);
}
if ($search_date_modif_endmonth) {
$param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
@ -1049,7 +1049,7 @@ if ($search_date_modif_endday) {
$param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
}
if ($search_date_modif_end) {
$param .= '&search_date_modif_end=' . urlencode($search_date_modif_end);
$param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end);
}
if (!empty($search_category_array)) {
foreach ($search_category_array as $tmpval) {

View file

@ -527,7 +527,7 @@ if ($id > 0 || !empty($ref)) {
$param .= '&search_date_start_startday='.urlencode((string) ($search_date_start_startday));
}
if ($search_date_start_start) {
$param .= '&search_date_start_start='.urlencode($search_date_start_start);
$param .= '&search_date_start_start='.urlencode((string) $search_date_start_start);
}
if ($search_date_start_endmonth) {
$param .= '&search_date_start_endmonth='.urlencode((string) ($search_date_start_endmonth));
@ -539,7 +539,7 @@ if ($id > 0 || !empty($ref)) {
$param .= '&search_date_start_endday='.urlencode((string) ($search_date_start_endday));
}
if ($search_date_start_end) {
$param .= '&search_date_start_end='.urlencode($search_date_start_end);
$param .= '&search_date_start_end='.urlencode((string) $search_date_start_end);
}
if ($search_date_end_startmonth) {
$param .= '&search_date_end_startmonth='.urlencode((string) ($search_date_end_startmonth));
@ -551,7 +551,7 @@ if ($id > 0 || !empty($ref)) {
$param .= '&search_date_end_startday='.urlencode((string) ($search_date_end_startday));
}
if ($search_date_end_start) {
$param .= '&search_date_end_start='.urlencode($search_date_end_start);
$param .= '&search_date_end_start='.urlencode((string) $search_date_end_start);
}
if ($search_date_end_endmonth) {
$param .= '&search_date_end_endmonth='.urlencode((string) ($search_date_end_endmonth));
@ -563,7 +563,7 @@ if ($id > 0 || !empty($ref)) {
$param .= '&search_date_end_endday='.urlencode((string) ($search_date_end_endday));
}
if ($search_date_end_end) {
$param .= '&search_date_end_end=' . urlencode($search_date_end_end);
$param .= '&search_date_end_end=' . urlencode((string) $search_date_end_end);
}
if ($search_planedworkload) {
$param .= '&search_planedworkload='.urlencode($search_planedworkload);

View file

@ -1926,6 +1926,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields
$selectedfields .= (is_array($arrayofmassactions) && count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
print '<!-- Liste of time spent -->'."\n";
print '<div class="div-table-responsive">';
print '<table class="tagtable nobottomiftotal liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
@ -2155,9 +2156,9 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
print '<td class="center nowraponall">';
if (($action == 'editline' || $action == 'splitline') && GETPOSTINT('lineid') == $task_time->rowid) {
print '<input type="hidden" name="lineid" value="' . GETPOSTINT('lineid') . '">';
print '<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans("Save").'">';
print '<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-save" name="save" value="'.$langs->trans("Save").'">';
print '<br>';
print '<input type="submit" class="button buttongen smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
print '<input type="submit" class="button buttongen reposition smallpaddingimp margintoponlyshort marginbottomonlyshort button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
} elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks
if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) {
print '<a class="reposition editfielda" href="'.$_SERVER["PHP_SELF"].'?'.($withproject ? 'id='.$task_time->fk_element : '').'&action=editline&token='.newToken().'&lineid='.$task_time->rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">';

View file

@ -295,8 +295,10 @@ print '</div>';
print '</div>';
print '<div class="demobantext" style="max-width: 1024px;">';
print '<div style="font-size: 20px; padding: 40px;">';
print '<div class="hideonsmartphone" style="text-align: justify;">'.$langs->trans("DemoDesc").'</div><br>';
print '<div style="font-size: 0.8em; padding: 40px;">';
print '<div class="hideonsmartphone" style="text-align: justify;">'.$langs->trans("DemoDesc").'<br>';
print $langs->trans("DemoDesc2", 'https://www.dolibarr.org/onlinedemo');
print '</div><br>';
print '<div class="titre"><span style="font-size: 20px">'.$langs->trans("ChooseYourDemoProfil").'</span></div>';
print '</div>';
print '</div>';

View file

@ -631,7 +631,7 @@ class Reception extends CommonObject
if ($qty == 0 || ($qty < 0 && !getDolGlobalInt('RECEPTION_ALLOW_NEGATIVE_QTY'))) {
continue;
}
dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid);
dol_syslog(get_class($this)."::valid movement index ".$i." ed.rowid=".$obj->rowid);
//var_dump($this->lines[$i]);
$mouvS = new MouvementStock($this->db);
@ -2038,11 +2038,7 @@ class Reception extends CommonObject
$qty = $obj->qty;
if ($qty <= 0) {
continue;
}
dol_syslog(get_class($this)."::reopen reception movement index ".$i." ed.rowid=".$obj->rowid." edb.rowid=".$obj->edbrowid);
dol_syslog(get_class($this)."::reopen reception movement index ".$i." ed.rowid=".$obj->rowid);
//var_dump($this->lines[$i]);
$mouvS = new MouvementStock($this->db);

View file

@ -97,7 +97,7 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -135,7 +135,7 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -97,7 +97,7 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}
@ -135,7 +135,7 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
if ($object->ismultientitymanaged == 1) {
$sql .= " AND entity = ".$conf->entity;
} elseif ($object->ismultientitymanaged == 2) {
} elseif (!is_numeric($object->ismultientitymanaged)) {
// TODO
}

View file

@ -363,7 +363,7 @@ class Salaries extends DolibarrApi
* @phpstan-param ?array<string,string> $request_data
* @return Object PaymentSalary object
*
* @url POST {id}/payments
* @url PUT {id}/payments
*
* @throws RestException
*/

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

@ -1117,7 +1117,7 @@ if ($search_date_creation_startday) {
$param .= '&search_date_creation_startday='.urlencode((string) ($search_date_creation_startday));
}
if ($search_date_creation_start) {
$param .= '&search_date_creation_start='.urlencode($search_date_creation_start);
$param .= '&search_date_creation_start='.urlencode((string) $search_date_creation_start);
}
if ($search_date_creation_endmonth) {
$param .= '&search_date_creation_endmonth='.urlencode((string) ($search_date_creation_endmonth));
@ -1129,7 +1129,7 @@ if ($search_date_creation_endday) {
$param .= '&search_date_creation_endday='.urlencode((string) ($search_date_creation_endday));
}
if ($search_date_creation_end) {
$param .= '&search_date_creation_end='.urlencode($search_date_creation_end);
$param .= '&search_date_creation_end='.urlencode((string) $search_date_creation_end);
}
if ($search_date_modif_startmonth) {
$param .= '&search_date_modif_startmonth='.urlencode((string) ($search_date_modif_startmonth));
@ -1141,7 +1141,7 @@ if ($search_date_modif_startday) {
$param .= '&search_date_modif_startday='.urlencode((string) ($search_date_modif_startday));
}
if ($search_date_modif_start) {
$param .= '&search_date_modif_start='.urlencode($search_date_modif_start);
$param .= '&search_date_modif_start='.urlencode((string) $search_date_modif_start);
}
if ($search_date_modif_endmonth) {
$param .= '&search_date_modif_endmonth='.urlencode((string) ($search_date_modif_endmonth));
@ -1153,7 +1153,7 @@ if ($search_date_modif_endday) {
$param .= '&search_date_modif_endday='.urlencode((string) ($search_date_modif_endday));
}
if ($search_date_modif_end) {
$param .= '&search_date_modif_end=' . urlencode($search_date_modif_end);
$param .= '&search_date_modif_end=' . urlencode((string) $search_date_modif_end);
}
// Add $param from extra fields

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

@ -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) {