diff --git a/SECURITY.md b/SECURITY.md index f63f9c3f277..7d65b7e98e4 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,7 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM ## Reporting a Vulnerability -To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (or alternatively send an email to security@dolibarr.org) +To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) ## Hunting vulnerabilities on Dolibarr @@ -55,7 +55,7 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us * $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. * The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be set to 1 soon by default) -* The module DebugBar and ModuleBuilder must NOT be enabled (by default, this module is not enabled. This is a developer tool) +* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly. @@ -65,12 +65,12 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us Scope is the web application (back office) and the APIs. -## Qualifying vulnerabilities for Bug bounty programs +## Qualifying vulnerabilities for reporting * Remote code execution (RCE) * Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA) * Code injections (HTML, JS, SQL, PHP, ...) -* Cross-Site Scripting (XSS) +* Cross-Site Scripting (XSS), except from setup page of module "External web site" (allowing any content here, editable by admin user only, is accepted on purpose or into module "Web site" when permission to edit website content is allowed). * Cross-Site Requests Forgery (CSRF) with real security impact (when using GET URLs, CSRF are qualified only for creating, updating or deleting data from pages restricted to admin users) * Open redirect * Broken authentication & session management @@ -82,7 +82,7 @@ Scope is the web application (back office) and the APIs. * Stack traces or path disclosure (for non admin users only) -## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting +## Non-qualifying vulnerabilities for reporting * "Self" XSS * SSL/TLS best practices diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 8982376ded6..cf2bd2065a2 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -582,6 +582,10 @@ if ($resql) { $i++; } + if ($num == 0) { + print '
| '.dol_print_date($db->jdate($obj->dm), 'day').' | '."\n"; - print "".$obj->label." | \n"; + $tva_static->id = $obj->id_tva; + $tva_static->ref = $obj->label; + print "".$tva_static->getNomUrl(1)." | \n"; - print ''.price($obj->amount)." | "; + print ''.price($obj->amount_tva)." | "; // Ref payment - $tva_static->id = $obj->rowid; - $tva_static->ref = $obj->rowid; - print ''.$tva_static->getNomUrl(1)." | \n"; + $ptva_static->id = $obj->rowid; + $ptva_static->ref = $obj->rowid; + print ''.$ptva_static->getNomUrl(1)." | \n"; // Date - print ''.dol_print_date($db->jdate($obj->dm), 'day')." | \n"; + print ''.dol_print_date($db->jdate($obj->date_payment), 'day')." | \n"; // Type payment print ''; @@ -360,7 +365,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $i++; } print ' | ||
| '.$langs->trans("Total").' | '; - print ''.price($total).' | '; + print ''; print ' | '; print ' | '; print ' | '; @@ -440,9 +445,9 @@ while ($j < $numlt) { print ' | '.price($obj->amount)." | "; // Ref payment - $tva_static->id = $obj->rowid; - $tva_static->ref = $obj->rowid; - print ''.$tva_static->getNomUrl(1)." | \n"; + $ptva_static->id = $obj->rowid; + $ptva_static->ref = $obj->rowid; + print ''.$ptva_static->getNomUrl(1)." | \n"; print ''.dol_print_date($db->jdate($obj->dp), 'day')." | \n"; print ''.price($obj->amount)." | "; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1afa9347f67..c3544ba214e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5367,9 +5367,11 @@ class FactureLigne extends CommonInvoiceLine return -1; } - // if buy price not defined, define buyprice as configured in margin admin + // if buy price not provided, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { + // We call defineBuyPrice only if data was not provided (if input was '0', we will not go here and value will remaine '0') + $result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product); + if ($result < 0) { return $result; } else { $this->pa_ht = $result; @@ -5410,7 +5412,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); - $sql .= ", buy_price_ht='".price2num($this->pa_ht)."'"; + $sql .= ", buy_price_ht=".(($this->pa_ht || $this->pa_ht === 0 || $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); if (!empty($this->rang)) { $sql .= ", rang=".$this->rang; diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index d4091a6df90..451007932d7 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -33,6 +33,8 @@ $langs->loadLangs(array('compta', 'banks', 'bills')); $id = GETPOST("id", 'int'); $action = GETPOST("action", "alpha"); +$cancel = GETPOST('cancel'); + $refund = GETPOST("refund", "int"); if (empty($refund)) { $refund = 0; @@ -57,18 +59,18 @@ $hookmanager->initHooks(array('localtaxvatcard', 'globalcard')); * Actions */ -if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) { +if ($cancel && !$id) { header("Location: list.php?localTaxType=".$lttype); exit; } -if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { +if ($action == 'add' && $cancel) { $db->begin(); - $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); - $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); + $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); - $object->accountid = GETPOST("accountid"); + $object->accountid = GETPOST("accountid", 'int'); $object->paymenttype = GETPOST("paiementtype"); $object->datev = $datev; $object->datep = $datep; @@ -165,14 +167,14 @@ if ($action == 'create') { print '|
| '.$langs->trans("Label").' | transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'"> | ||||||||||
| '.$langs->trans("Label").' | transcountry(($lttype == 2 ? "LT2Payment" : "LT1Payment"), $mysoc->country_code)).'"> | ||||||||||
| '.$langs->trans("Amount").' | |||||||||||
| '.$langs->trans("Account").' | '; - $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 2); // Affiche liste des comptes courant + $form->select_comptes(GETPOST("accountid", "int"), "accountid", 0, "courant=1", 2); // Affiche liste des comptes courant print ' | ||||||||||
| '.$langs->trans("PaymentMode").' | ';
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 847dae1bc29..86153e4b38d 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -117,9 +117,9 @@ if ($action == 'setref' && $user->rights->banque->cheque) {
}
}
-if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->cheque) {
+if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->rights->banque->cheque) {
if (is_array($_POST['toRemise'])) {
- $result = $object->create($user, $_POST["accountid"], 0, $_POST['toRemise']);
+ $result = $object->create($user, GETPOST("accountid", "int"), 0, GETPOST('toRemise'));
if ($result > 0) {
if ($object->statut == 1) { // If statut is validated, we build doc
$object->fetch($object->id); // To force to reload all properties in correct property name
@@ -134,7 +134,7 @@ if ($action == 'create' && $_POST["accountid"] > 0 && $user->rights->banque->che
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $result = $object->generatePdf($_POST["model"], $outputlangs);
+ $result = $object->generatePdf(GETPOST("model"), $outputlangs);
}
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id);
@@ -227,7 +227,7 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
- $result = $object->generatePdf($_POST["model"], $outputlangs);
+ $result = $object->generatePdf(GETPOST("model"), $outputlangs);
if ($result <= 0) {
dol_print_error($db, $object->error);
exit;
diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php
index 139188c7c1b..ba8c9b2a82f 100644
--- a/htdocs/compta/paiement/rapport.php
+++ b/htdocs/compta/paiement/rapport.php
@@ -70,14 +70,14 @@ if ($action == 'builddoc') {
// We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8.
$sav_charset_output = $outputlangs->charset_output;
- if ($rap->write_file($dir, $_POST["remonth"], $_POST["reyear"], $outputlangs) > 0) {
+ if ($rap->write_file($dir, GETPOST("remonth", "int"), GETPOST("reyear", "int"), $outputlangs) > 0) {
$outputlangs->charset_output = $sav_charset_output;
} else {
$outputlangs->charset_output = $sav_charset_output;
dol_print_error($db, $obj->error);
}
- $year = $_POST["reyear"];
+ $year = GETPOST("reyear", "int");
}
diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php
index bc79ff07d47..e796f039f80 100644
--- a/htdocs/compta/paiement_charge.php
+++ b/htdocs/compta/paiement_charge.php
@@ -32,6 +32,8 @@ $langs->load("bills");
$chid = GETPOST("id", 'int');
$action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel');
+
$amounts = array();
// Security check
@@ -50,15 +52,15 @@ $charge = new ChargeSociales($db);
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) {
$error = 0;
- if ($_POST["cancel"]) {
+ if ($cancel) {
$loc = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$chid;
header("Location: ".$loc);
exit;
}
- $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+ $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", "int"), GETPOST("reday", "int"), GETPOST("reyear", "int"));
- if (!$_POST["paiementtype"] > 0) {
+ if (!(GETPOST("paiementtype") > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
$action = 'create';
@@ -68,7 +70,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
$error++;
$action = 'create';
}
- if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) {
+ if (!empty($conf->banque->enabled) && !(GETPOST("accountid") > 0)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
$action = 'create';
diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php
index c05e11c554c..7fc81e5ac27 100644
--- a/htdocs/compta/paiement_vat.php
+++ b/htdocs/compta/paiement_vat.php
@@ -33,6 +33,8 @@ $langs->loadLangs(array("banks", "bills"));
$chid = GETPOST("id", 'int');
$action = GETPOST('action', 'alpha');
+$cancel = GETPOST('cancel');
+
$amounts = array();
// Security check
@@ -49,7 +51,7 @@ if ($user->socid > 0) {
if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) {
$error = 0;
- if ($_POST["cancel"]) {
+ if ($cancel) {
$loc = DOL_URL_ROOT.'/compta/tva/card.php?id='.$chid;
header("Location: ".$loc);
exit;
@@ -73,23 +75,23 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y
$action = 'create';
}
+ // Read possible payments
+ foreach ($_POST as $key => $value) {
+ if (substr($key, 0, 7) == 'amount_') {
+ $other_chid = substr($key, 7);
+ $amounts[$other_chid] = price2num(GETPOST($key));
+ }
+ }
+
+ if ($amounts[key($amounts)] <= 0) {
+ $error++;
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors');
+ $action = 'create';
+ }
+
if (!$error) {
$paymentid = 0;
- // Read possible payments
- foreach ($_POST as $key => $value) {
- if (substr($key, 0, 7) == 'amount_') {
- $other_chid = substr($key, 7);
- $amounts[$other_chid] = price2num(GETPOST($key));
- }
- }
-
- if (count($amounts) <= 0) {
- $error++;
- setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors');
- $action = 'create';
- }
-
if (!$error) {
$db->begin();
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index 83a6a8f3b3a..c26c62fb7ed 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -180,7 +180,7 @@ if ($action == 'add' && $user->rights->tax->charges->creer) {
}
-if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) {
+if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) {
$amount = price2num(GETPOST('amount'), 'MT');
if (!$dateech) {
diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php
index c4daeb801c6..fdb1e3336df 100755
--- a/htdocs/compta/tva/card.php
+++ b/htdocs/compta/tva/card.php
@@ -41,6 +41,7 @@ $langs->loadLangs(array('compta', 'banks', 'bills'));
$id = GETPOST("id", 'int');
$action = GETPOST("action", "alpha");
+$cancel = GETPOST('cancel');
$confirm = GETPOST('confirm');
$refund = GETPOST("refund", "int");
if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
@@ -74,7 +75,7 @@ $hookmanager->initHooks(array('taxvatcard', 'globalcard'));
* Actions
*/
-if ($_POST["cancel"] == $langs->trans("Cancel") && !$id) {
+if ($cancel && !$id) {
header("Location: list.php");
exit;
}
@@ -135,7 +136,7 @@ if ($action == 'reopen' && $user->rights->tax->charges->creer) {
}
}
-if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) {
+if ($action == 'add' && $cancel) {
$error = 0;
$object->fk_account = GETPOST("accountid", 'int');
@@ -260,7 +261,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') {
}
}
-if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) {
+if ($action == 'update' && !GETPOST("cancel") && $user->rights->tax->charges->creer) {
$amount = price2num(GETPOST('amount'));
if (empty($amount)) {
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index a32263cd65e..332b7dd36c6 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -283,28 +283,28 @@ abstract class ActionsContactCardCommon
// phpcs:enable
global $langs, $mysoc;
- $this->object->old_name = $_POST["old_name"];
- $this->object->old_firstname = $_POST["old_firstname"];
+ $this->object->old_name = GETPOST("old_name");
+ $this->object->old_firstname = GETPOST("old_firstname");
- $this->object->socid = $_POST["socid"];
- $this->object->lastname = $_POST["name"];
- $this->object->firstname = $_POST["firstname"];
- $this->object->civility_id = $_POST["civility_id"];
- $this->object->poste = $_POST["poste"];
- $this->object->address = $_POST["address"];
- $this->object->zip = $_POST["zipcode"];
- $this->object->town = $_POST["town"];
- $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
- $this->object->state_id = $_POST["state_id"];
- $this->object->phone_pro = $_POST["phone_pro"];
- $this->object->phone_perso = $_POST["phone_perso"];
- $this->object->phone_mobile = $_POST["phone_mobile"];
- $this->object->fax = $_POST["fax"];
- $this->object->email = $_POST["email"];
- $this->object->jabberid = $_POST["jabberid"];
- $this->object->priv = $_POST["priv"];
- $this->object->note = $_POST["note"];
- $this->object->canvas = $_POST["canvas"];
+ $this->object->socid = GETPOST("socid");
+ $this->object->lastname = GETPOST("name");
+ $this->object->firstname = GETPOST("firstname");
+ $this->object->civility_id = GETPOST("civility_id");
+ $this->object->poste = GETPOST("poste");
+ $this->object->address = GETPOST("address");
+ $this->object->zip = GETPOST("zipcode");
+ $this->object->town = GETPOST("town");
+ $this->object->country_id = GETPOST("country_id") ? GETPOST("country_id") : $mysoc->country_id;
+ $this->object->state_id = GETPOST("state_id");
+ $this->object->phone_pro = GETPOST("phone_pro");
+ $this->object->phone_perso = GETPOST("phone_perso");
+ $this->object->phone_mobile = GETPOST("phone_mobile");
+ $this->object->fax = GETPOST("fax");
+ $this->object->email = GETPOST("email");
+ $this->object->jabberid = GETPOST("jabberid");
+ $this->object->priv = GETPOST("priv");
+ $this->object->note = GETPOST("note", "restricthtml");
+ $this->object->canvas = GETPOST("canvas");
// We set country_id, and country_code label of the chosen country
if ($this->object->country_id) {
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 421b88ea6b8..b337f0980e6 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -561,7 +561,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$object->state_id = GETPOST("state_id");
// We set country_id, country_code and label for the selected country
- $object->country_id = $_POST["country_id"] ?GETPOST("country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
+ $object->country_id = GETPOST("country_id") ? GETPOST("country_id", "int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
if ($object->country_id) {
$tmparray = getCountry($object->country_id, 'all');
$object->country_code = $tmparray['code'];
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index 8d2969a1370..628c73b0afc 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -45,12 +45,12 @@ $object = new Contact($db);
* Action
*/
-if ($action == 'update' && !$_POST["cancel"] && $user->rights->societe->contact->creer) {
+if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact->creer) {
$ret = $object->fetch($id);
// Note: Correct date should be completed with location to have exact GM time of birth.
- $object->birthday = dol_mktime(0, 0, 0, $_POST["birthdaymonth"], $_POST["birthdayday"], $_POST["birthdayyear"]);
- $object->birthday_alert = $_POST["birthday_alert"];
+ $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth"), GETPOST("birthdayday"), GETPOST("birthdayyear"));
+ $object->birthday_alert = GETPOST("birthday_alert");
if (GETPOST('deletephoto')) {
$object->photo = '';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 217414aa30c..88627ca0698 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -2008,7 +2008,7 @@ if ($action == 'create') {
if (empty($user->socid)) {
if ($object->statut == 1) {
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->contrat->creer)) {
- print '';
+ print '';
} else {
print '';
}
@@ -2017,14 +2017,14 @@ if ($action == 'create') {
if ($object->statut == 0 && $nbofservices) {
if ($user->rights->contrat->creer) {
- print '';
+ print '';
} else {
print '';
}
}
if ($object->statut == 1) {
if ($user->rights->contrat->creer) {
- print '';
+ print '';
} else {
print '';
}
@@ -2050,14 +2050,14 @@ if ($action == 'create') {
if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0) {
if ($user->rights->contrat->activer) {
- print '';
+ print '';
} else {
print '';
}
}
if ($object->nbofservicesclosed < $nbofservices) {
if ($user->rights->contrat->desactiver) {
- print '';
+ print '';
} else {
print '';
}
@@ -2081,7 +2081,7 @@ if ($action == 'create') {
// Clone
if ($user->rights->contrat->creer) {
- print '';
+ print '';
}
// On peut supprimer entite si
diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php
index d61ac357a40..bd96eac7b0d 100644
--- a/htdocs/contrat/note.php
+++ b/htdocs/contrat/note.php
@@ -180,6 +180,7 @@ if ($id > 0 || !empty($ref)) {
//print ' '; + $cssclass='fieldtitle'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print dol_get_fiche_end(); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 7f3d7d4cc3a..4662c3a1406 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -95,7 +95,7 @@ if (GETPOST('roworder', 'alpha', 2) && GETPOST('table_element_line', 'aZ09', 2) } else { $tmparray = explode('_', $table_element_line); $tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]); - if (!empty($tmpmodule) && !empty($tmpobject) && !empty($conf->$tmpmodule->enabled) && !empty($user->rights->$tmpobject->read)) { + if (!empty($tmpmodule) && !empty($tmpobject) && !empty($conf->$tmpmodule->enabled) && !empty($user->rights->$tmpobject->write)) { $perm = 1; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e36e96f0833..8fa0ad9c8a5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1072,9 +1072,9 @@ abstract class CommonObject // Insert into database $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql .= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; - $sql .= " VALUES (".$this->id.", ".$fk_socpeople." , "; + $sql .= " VALUES (".$this->id.", ".((int) $fk_socpeople)." , "; $sql .= "'".$this->db->idate($datecreate)."'"; - $sql .= ", 4, ".$id_type_contact; + $sql .= ", 4, ".((int) $id_type_contact); $sql .= ")"; $resql = $this->db->query($sql); @@ -7688,7 +7688,8 @@ abstract class CommonObject $buyPrice = 0; - if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { // In most cases, test here is false + if (($unitPrice > 0) && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull > 0)) { + // When ForceBuyingPriceIfNull is set $buyPrice = $unitPrice * (1 - $discountPercent / 100); } else { // Get cost price for margin calculation diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 061332c2e8b..4afcf295d40 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -144,13 +144,13 @@ class DiscountAbsolute $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid"; $sql .= " WHERE sr.entity IN (".getEntity('invoice').")"; if ($rowid) { - $sql .= " AND sr.rowid=".$rowid; + $sql .= " AND sr.rowid=".((int) $rowid); } if ($fk_facture_source) { - $sql .= " AND sr.fk_facture_source=".$fk_facture_source; + $sql .= " AND sr.fk_facture_source = ".((int) $fk_facture_source); } if ($fk_invoice_supplier_source) { - $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source; + $sql .= " AND sr.fk_invoice_supplier_source = ".((int) $fk_invoice_supplier_source); } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ac56180d3a8..779e89c1f9f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2008,7 +2008,9 @@ class Form if (!$obj->entity) { $moreinfo .= ($moreinfo ? ' - ' : ' (').$langs->trans("AllEntities"); } else { - $moreinfo .= ($moreinfo ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined")); + if ($obj->entity != $conf->entity) { + $moreinfo .= ($moreinfo ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined")); + } } } $moreinfo .= ($moreinfo ? ')' : ''); diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 53852955094..e6ada4d67c7 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -364,7 +364,7 @@ class FormAccounting extends Form $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.labelshort, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; - $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; + $sql .= " AND asy.rowid = ".((int) $conf->global->CHARTOFACCOUNTS); $sql .= " AND aa.active = 1"; $sql .= " AND aa.entity=".$conf->entity; $sql .= " ORDER BY aa.account_number"; @@ -380,7 +380,7 @@ class FormAccounting extends Form $num_rows = $this->db->num_rows($resql); - if ($num_rows == 0) { + if ($num_rows == 0 && (empty($conf->global->CHARTOFACCOUNTS) || $conf->global->CHARTOFACCOUNTS < 0)) { $langs->load("errors"); $showempty = $langs->trans("ErrorYouMustFirstSetupYourChartOfAccount"); } else { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 8f8f8e665f7..f56b9f6070e 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -912,8 +912,8 @@ class FormMail extends Form } } - if (GETPOSTISSET("message") && !$_POST['modelselected']) { - $defaultmessage = $_POST["message"]; + if (GETPOSTISSET("message") && !GETPOST('modelselected')) { + $defaultmessage = GETPOST("message", "restricthtml"); } else { $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index c58b0a4036a..f951a3dc198 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -90,8 +90,10 @@ class FormMargin $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); } } - // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente - if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { + + // If buy price is not defined (null), we will use the sell price. If defined to 0 (it means it was forced to 0 during insert, for example for a free to get product), we must still use 0. + //if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull > 0)) { + if ((!isset($line->pa_ht)) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull > 0)) { $line->pa_ht = $line->subprice * (1 - ($line->remise_percent / 100)); } diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 445686340e8..c5c3b38b29b 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -126,9 +126,10 @@ class FormTicket * * @param int $withdolfichehead With dol_get_fiche_head() and dol_get_fiche_end() * @param string $mode Mode ('create' or 'edit') + * @param int $public 1=If we show the form for the public interface * @return void */ - public function showForm($withdolfichehead = 0, $mode = 'edit') + public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0) { global $conf, $langs, $user, $hookmanager; @@ -182,6 +183,7 @@ class FormTicket if (isset($this->param['origin']) && $this->param['originid'] > 0) { // Parse element/subelement (ex: project_task) $element = $subelement = $this->param['origin']; + $regs = array(); if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) { $element = $regs[1]; $subelement = $regs[2]; @@ -208,7 +210,11 @@ class FormTicket // Group print ' | ||||||||||
| '; - $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', 2, 0, 0, 0, 'minwidth200'); + $filter = ''; + if ($public) { + $filter = 'public=1'; + } + $this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 0, 0, 0, 'minwidth200'); print ' | |||||||||||