diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 882c51f40c0..bef8ece1d39 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -110,7 +110,7 @@ $form = new Form($db);
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
{
- if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
+ if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start'))
{
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 44097c84f49..c871304905f 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3596,7 +3596,7 @@ if ($action == 'create')
if (is_array($objectsrc->linkedObjects['facture']) && count($objectsrc->linkedObjects['facture']) >= 1)
{
setEventMessages('WarningBillExist', null, 'warnings');
- echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['facture'])->getNomUrl(1).')';
+ echo ' ('.$langs->trans('LatestRelatedBill').' '.end($objectsrc->linkedObjects['facture'])->getNomUrl(1).')';
}
echo '';
print '
| '.$langs->trans('AmountHT').' | '.price($objectsrc->total_ht).' |
';
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index f88560159b0..6bc9133c553 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -831,7 +831,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '| '.$langs->trans("ContactByDefaultFor").' | ';
print '';
$contactType = $object->listeTypeContacts('external', '', 1);
- print $form->multiselectarray('roles', $contactType);
+ print $form->multiselectarray('roles', $contactType, array(), 0, 0, 'minwidth500');
print ' |
';
}
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index b1b03e8de97..6b6d5854a1d 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -3,7 +3,7 @@
* Copyright (C) 2018 Nicolas ZABOURI
* Copyright (C) 2018 Juanjo Menent
* Copyright (C) 2019 Ferran Marcet
- * Copyright (C) 2019 Frédéric France
+ * Copyright (C) 2019-2021 Frédéric France
*
* 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
@@ -1111,18 +1111,47 @@ if (!$error && $massaction == 'validate' && $permissiontoadd)
if ($result > 0)
{
$result = $objecttmp->validate($user);
- if ($result == 0)
- {
+ if ($result == 0) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorObjectMustHaveStatusDraftToBeValidated", $objecttmp->ref), null, 'errors');
$error++;
break;
- } elseif ($result < 0)
- {
+ } elseif ($result < 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
- } else $nbok++;
+ } else {
+ // validate() rename pdf but do not regenerate
+ // Define output language
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
+ $newlang = GETPOST('lang_id', 'aZ09');
+ }
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
+ $newlang = $objecttmp->thirdparty->default_lang;
+ }
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ $outputlangs->load('products');
+ }
+ $model = $objecttmp->model_pdf;
+ $ret = $objecttmp->fetch($objecttmp->id); // Reload to get new records
+ // To be sure vars is defined
+ $hidedetails = !empty($hidedetails) ? $hidedetails : 0;
+ $hidedesc = !empty($hidedesc) ? $hidedesc : 0;
+ $hideref = !empty($hideref) ? $hideref : 0;
+ $moreparams = !empty($moreparams) ? $moreparams : null;
+
+ $result = $objecttmp->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ if ($result < 0) {
+ setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
+ }
+ }
+ $nbok++;
+ }
} else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 9e6204bd364..0b4565ab08f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1399,6 +1399,8 @@ abstract class CommonObject
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num > 0) {
+ $langs->loadLangs(array("propal", "orders", "bills", "suppliers", "contracts", "supplier_proposal"));
+
while ($obj = $this->db->fetch_object($resql)) {
$modulename = $obj->element;
if (strpos($obj->element, 'project') !== false) {
@@ -1414,11 +1416,15 @@ abstract class CommonObject
}
if ($conf->{$modulename}->enabled) {
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
- $transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code;
+ $tmpelement = $obj->element;
+ $transkey = "TypeContact_".$tmpelement."_".$source."_".$obj->code;
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
- if (empty($option))
+ if (empty($option)) {
$tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
- else $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
+ }
+ else {
+ $tab[$obj->rowid] = $libelle_element.' - '.$libelle_type;
+ }
}
}
}
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index 391a5359846..f40f84c7b2c 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -520,9 +520,9 @@ function hideMessage(fieldId,message) {
* Used by button to set on/off.
* Call url then make complementary action (like show/hide, enable/disable or set another option).
*
- * @param string url Url
+ * @param string url Url (warning: as any url called in ajax mode, the url called here must not renew the token)
* @param string code Code
- * @param string intput Input
+ * @param string intput Array of complementary actions to do if success
* @param int entity Entity
* @param int strict Strict
* @param int forcereload Force reload
@@ -536,7 +536,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
entity: entity,
token: token
},
- function() {
+ function() { /* handler for success of post */
console.log("url request success forcereload="+forcereload);
$("#set_" + code).hide();
$("#del_" + code).show();
@@ -574,11 +574,12 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
$.each(data, function(key, value) {
$("#set_" + key).hide();
$("#del_" + key).show();
- $.get( url, {
+ $.post( url, {
action: "set",
name: key,
value: value,
- entity: entity
+ entity: entity,
+ token: token
});
});
}
@@ -593,9 +594,9 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
* Used by button to set on/off
* Call url then make complementary action (like show/hide, enable/disable or set another option).
*
- * @param string url Url
+ * @param string url Url (warning: as any url called in ajax mode, the url called here must not renew the token)
* @param string code Code
- * @param string intput Input
+ * @param string intput Array of complementary actions to do if success
* @param int entity Entity
* @param int strict Strict
* @param int forcereload Force reload
@@ -644,10 +645,11 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
$.each(data, function(key, value) {
$("#del_" + value).hide();
$("#set_" + value).show();
- $.get( url, {
+ $.post( url, {
action: "del",
name: value,
- entity: entity
+ entity: entity,
+ token: token
});
});
}
@@ -659,12 +661,13 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
}
/*
- * Used by button to set on/off
+ * Call the setConstant or delConstant but with a confirmation before.
+ * Used by button to set on/off.
*
* @param string action Action
* @param string url Url
* @param string code Code
- * @param string intput Input
+ * @param string intput Array of complementary actions to do if success
* @param string box Box
* @param int entity Entity
* @param int yesButton yesButton
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 8a364359e9d..c9f64129e65 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -491,13 +491,13 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
* On/off button for constant
*
* @param string $code Name of constant
- * @param array $input Array of options. ("disabled"|"enabled'|'set'|'del') => CSS element to switch, 'alert' => message to show, ... Example: array('disabled'=>array(0=>'cssid'))
- * @param int $entity Entity to set. Use current entity if null.
+ * @param array $input Array of complementary actions to do if success ("disabled"|"enabled'|'set'|'del') => CSS element to switch, 'alert' => message to show, ... Example: array('disabled'=>array(0=>'cssid'))
+ * @param int $entity Entity. Current entity is used if null.
* @param int $revertonoff Revert on/off
* @param int $strict Use only "disabled" with delConstant and "enabled" with setConstant
* @param int $forcereload Force to reload page if we click/change value (this is supported only when there is no 'alert' option in input)
* @param string $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left margin on picto, 0 = No left margin. Works for fontawesome picto only.
- * @param int $forcenoajax 1=Force to use a ahref link instead of ajax code.
+ * @param int $forcenoajax 1 = Force to use a ahref link instead of ajax code.
* @return string
*/
function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0, $marginleftonlyshort = 2, $forcenoajax = 0)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 92c519c5a66..e2889c4d6d3 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5833,6 +5833,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
$allowed_tags_string = join("><", $allowed_tags);
$allowed_tags_string = '<'.$allowed_tags_string.'>';
+ $stringtoclean = str_replace('', '__!DOCTYPE_HTML__', $stringtoclean); // Replace DOCTYPE to avoid to have it removed by the strip_tags
+
$stringtoclean = dol_string_nounprintableascii($stringtoclean, 0);
$stringtoclean = preg_replace('/:/i', ':', $stringtoclean);
@@ -5855,6 +5857,8 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1,
$temp = preg_replace('/javascript\s*:/i', '', $temp);
}
+ $temp = str_replace('__!DOCTYPE_HTML__', '', $temp); // Restore the DOCTYPE
+
return $temp;
}
diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang
index ca75eddb7df..a68319fb2df 100644
--- a/htdocs/langs/en_US/supplier_proposal.lang
+++ b/htdocs/langs/en_US/supplier_proposal.lang
@@ -53,3 +53,6 @@ SupplierProposalsToClose=Vendor proposals to close
SupplierProposalsToProcess=Vendor proposals to process
LastSupplierProposals=Latest %s price requests
AllPriceRequests=All requests
+TypeContact_supplier_proposal_external_SHIPPING=Vendor contact for delivery
+TypeContact_supplier_proposal_external_BILLING=Vendor contact for billing
+TypeContact_supplier_proposal_external_SERVICE=Representative following-up proposal
diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php
index 78fdb0b1419..bca1aace56a 100644
--- a/test/phpunit/SecurityTest.php
+++ b/test/phpunit/SecurityTest.php
@@ -300,6 +300,7 @@ class SecurityTest extends PHPUnit\Framework\TestCase
$_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
$_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
$_POST["param11"]=' Name ';
+ $_POST["param12"]='aaa';
$result=GETPOST('id', 'int'); // Must return nothing
print __METHOD__." result=".$result."\n";
@@ -397,6 +398,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase
print __METHOD__." result=".$result."\n";
$this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt');
+ $result=GETPOST("param12", 'restricthtml');
+ print __METHOD__." result=".$result."\n";
+ $this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml');
+
return $result;
}