diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php
index f9b5b37ec4d..8ef984f1e81 100644
--- a/htdocs/admin/oauthlogintokens.php
+++ b/htdocs/admin/oauthlogintokens.php
@@ -218,7 +218,6 @@ if ($mode == 'setup' && $user->admin) {
$tokenobj = null;
// Token
require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
- require_once DOL_DOCUMENT_ROOT.'/includes/OAuth/bootstrap.php';
// Dolibarr storage
$storage = new DoliStorage($db, $conf);
try {
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 249a4e2a66d..888c09124ad 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -883,8 +883,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//Default language
if (!empty($conf->global->MAIN_MULTILANGS)) {
print '
| '.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' | '."\n";
- print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone', 0, 0, 0, null, 1);
-
+ print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
print ' | ';
print '
';
}
@@ -1171,8 +1170,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//Default language
if (!empty($conf->global->MAIN_MULTILANGS)) {
print '| '.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).' | '."\n";
- print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1);
-
+ print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
print ' | ';
print '
';
}
@@ -1403,7 +1401,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
//$s=picto_from_langcode($object->default_lang);
//print ($s?$s.' ':'');
$langs->load("languages");
- $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang.'_'.strtoupper($object->default_lang)) : '');
+ $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
+ print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
print $labellang;
print '';
}
diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php
index 8c7d8b7106d..0f4d274cc0d 100644
--- a/htdocs/core/ajax/onlineSign.php
+++ b/htdocs/core/ajax/onlineSign.php
@@ -73,7 +73,7 @@ if ($type == 'proposal') {
$securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
-if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
+if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $entity), $SECUREKEY, '0')) {
http_response_code(403);
print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref);
exit(-1);
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 4067636e676..a68c268f8bd 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1552,10 +1552,10 @@ function complete_elementList_with_modules(&$elementList)
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
- if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && !$conf->global->$const_name) {
+ if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && getDolGlobalString($const_name)) {
$modulequalified = 0;
}
- if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && !$conf->global->$const_name) {
+ if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && getDolGlobalString($const_name)) {
$modulequalified = 0;
}
//If module is not activated disqualified
diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php
index d76120ab3de..1dbefb5719a 100644
--- a/htdocs/core/lib/signature.lib.php
+++ b/htdocs/core/lib/signature.lib.php
@@ -90,7 +90,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
if ($mode == 1) {
$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
} else {
- $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref, '0');
+ $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $object->entity), '0');
}
/*
if ($mode == 1) {
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index 6e9e73c8d27..832e93ff026 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -199,7 +199,7 @@ if (empty($reshook)) {
if ($result <= 0) {
dol_print_error($db);
}
- $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(1));
+ $multicurrency_amountsresttopay[$cursorfacid] = price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
if ($multicurrency_amounts[$cursorfacid]) {
// Check amount
if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) {
diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php
index 3f68c444fd2..18ec0d67738 100644
--- a/htdocs/knowledgemanagement/knowledgerecord_list.php
+++ b/htdocs/knowledgemanagement/knowledgerecord_list.php
@@ -99,13 +99,12 @@ if (!$sortorder) {
$search_all = GETPOST('search_all', 'alphanohtml');
$search = array();
foreach ($object->fields as $key => $val) {
- if (GETPOST('search_'.$key, 'alpha') !== '') {
- if ($key == "lang") {
- $search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : '';
- } else {
- $search[$key] = GETPOST('search_'.$key, 'alpha');
- }
+ if ($key == "lang") {
+ $search[$key] = GETPOST('search_'.$key, 'alpha')!='0' ? GETPOST('search_'.$key, 'alpha') : '';
+ } else {
+ $search[$key] = GETPOST('search_'.$key, 'alpha');
}
+
if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) {
$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int'));
$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int'));
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 3bac43e1374..ed43e792d87 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -4801,9 +4801,10 @@ class Product extends CommonObject
* @param int $id Id of product to search childs of
* @param int $firstlevelonly Return only direct child
* @param int $level Level of recursing call (start to 1)
+ * @param array $parents Array of all parents of $id
* @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=>product type, 3=>label, 4=>incdec, 5=>product ref)
*/
- public function getChildsArbo($id, $firstlevelonly = 0, $level = 1)
+ public function getChildsArbo($id, $firstlevelonly = 0, $level = 1, $parents = array())
{
global $alreadyfound;
@@ -4821,7 +4822,7 @@ class Product extends CommonObject
$sql .= " AND pa.fk_product_fils <> ".((int) $id); // This should not happens, it is to avoid infinite loop if it happens
$sql.= " ORDER BY pa.rang";
- dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level, LOG_DEBUG);
+ dol_syslog(get_class($this).'::getChildsArbo id='.$id.' level='.$level. ' parents='.$parents, LOG_DEBUG);
if ($level == 1) {
$alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly
@@ -4837,7 +4838,9 @@ class Product extends CommonObject
while ($rec = $this->db->fetch_array($res)) {
if (!empty($alreadyfound[$rec['rowid']])) {
dol_syslog(get_class($this).'::getChildsArbo the product id='.$rec['rowid'].' was already found at a higher level in tree. We discard to avoid infinite loop', LOG_WARNING);
- continue;
+ if (in_array($rec['id'], $parents)) {
+ continue; // We discard this child if it is already found at a higher level in tree in the same branch.
+ }
}
$alreadyfound[$rec['rowid']] = 1;
$prods[$rec['rowid']] = array(
@@ -4853,7 +4856,7 @@ class Product extends CommonObject
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty'],2=>$rec['fk_product_type']);
//$prods[$this->db->escape($rec['label'])]= array(0=>$rec['id'],1=>$rec['qty']);
if (empty($firstlevelonly)) {
- $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1);
+ $listofchilds = $this->getChildsArbo($rec['rowid'], 0, $level + 1, array_push($parents, $rec['rowid']));
foreach ($listofchilds as $keyChild => $valueChild) {
$prods[$rec['rowid']]['childs'][$keyChild] = $valueChild;
}
diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php
index 459d4176094..e698c20c4f0 100644
--- a/htdocs/public/onlinesign/newonlinesign.php
+++ b/htdocs/public/onlinesign/newonlinesign.php
@@ -139,7 +139,7 @@ if ($source == 'proposal') {
$securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
-if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
+if (!dol_verifyHash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $entity), $SECUREKEY, '0')) {
http_response_code(403);
print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref);
exit(-1);
@@ -293,7 +293,6 @@ if ($source == 'proposal') {
$result = $object->fetch_thirdparty($object->socid);
// Creditor
-
print '| '.$langs->trans("Designation");
print ' | '.$text;
diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php
index 20c5d45dd3b..3427d377703 100755
--- a/htdocs/ticket/card.php
+++ b/htdocs/ticket/card.php
@@ -4,6 +4,7 @@
* Copyright (C) 2018 Laurent Destailleur
* Copyright (C) 2021 Frédéric France
* Copyright (C) 2021 Alexandre Spangaro
+ * Copyright (C) 2022 Charlene Benke
*
* 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
@@ -218,7 +219,7 @@ if (empty($reshook)) {
$fk_user_assign = GETPOST("fk_user_assign", 'int');
if ($fk_user_assign > 0) {
$object->fk_user_assign = $fk_user_assign;
- $object->fk_status = $object::STATUS_ASSIGNED;
+ $object->status = $object::STATUS_ASSIGNED;
}
$object->fk_project = $projectid;
@@ -298,7 +299,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'update' && $user->rights->ticket->write && $object->fk_status < Ticket::STATUS_CLOSED) {
+ if ($action == 'update' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) {
$error = 0;
$ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha'));
@@ -560,7 +561,7 @@ if (empty($reshook)) {
if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
// prevent browser refresh from reopening ticket several times
- if ($object->fk_status == Ticket::STATUS_CLOSED || $object->fk_status == Ticket::STATUS_CANCELED) {
+ if ($object->status == Ticket::STATUS_CLOSED || $object->status == Ticket::STATUS_CANCELED) {
$res = $object->setStatut(Ticket::STATUS_ASSIGNED);
if ($res) {
// Log action in ticket logs table
@@ -619,7 +620,7 @@ if (empty($reshook)) {
// Reopen ticket
if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$new_status = GETPOST('new_status', 'int');
- $old_status = $object->fk_status;
+ $old_status = $object->status;
$res = $object->setStatut($new_status);
if ($res) {
// Log action in ticket logs table
@@ -738,7 +739,7 @@ if ($action == 'create' || $action == 'presend') {
$formticket->withcancel = 1;
$formticket->showForm(1, 'create', 0);
- /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_status < Ticket::STATUS_CLOSED) {
+ /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) {
$formticket = new FormTicket($db);
$head = ticket_prepare_head($object);
@@ -953,7 +954,7 @@ if ($action == 'create' || $action == 'presend') {
// Thirdparty
if (!empty($conf->societe->enabled)) {
$morehtmlref .= ' '.$langs->trans('ThirdParty').' ';
- if ($action != 'editcustomer' && $object->fk_status < 8 && !$user->socid && $user->rights->ticket->write) {
+ if ($action != 'editcustomer' && $object->status < 8 && !$user->socid && $user->rights->ticket->write) {
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('Edit'), 0).' : ';
}
if ($action == 'editcustomer') {
@@ -1070,7 +1071,7 @@ if ($action == 'create' || $action == 'presend') {
print '';
print '| ';
print $langs->trans("AssignedTo");
- if (isset($object->fk_status) && $object->fk_status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) {
+ if (isset($object->status) && $object->status < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) {
print ' | '.img_edit($langs->trans('Modify'), '').'';
}
print ' | ';
@@ -1081,7 +1082,7 @@ if ($action == 'create' || $action == 'presend') {
}
// Show user list to assignate one if status is "read"
- if (GETPOST('set', 'alpha') == "assign_ticket" && $object->fk_status < 8 && !$user->socid && $user->rights->ticket->write) {
+ if (GETPOST('set', 'alpha') == "assign_ticket" && $object->status < 8 && !$user->socid && $user->rights->ticket->write) {
print ' | |