diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
index dfe3fa53994..e6bcc7ad12e 100644
--- a/.php-cs-fixer.dist.php
+++ b/.php-cs-fixer.dist.php
@@ -8,6 +8,8 @@ $finder = (new PhpCsFixer\Finder())
'custom',
'documents',
'doctemplates',
+ 'vendor',
+ 'install/doctemplates',
'htdocs/custom',
'htdocs/includes',
'htdocs/install/doctemplates',
@@ -41,6 +43,8 @@ return (new PhpCsFixer\Config())
// So we use target PHP70 for the moment.
'@PHP70Migration' => true,
//'@PHP71Migration' => true,
+ // Avoid adding public to const (incompatible with PHP 7.0):
+ 'visibility_required' => ['elements'=>['property', 'method']],
//'strict_param' => true,
//'array_syntax' => ['syntax' => 'short'],
diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
new file mode 100644
index 00000000000..a98cf177eca
--- /dev/null
+++ b/.phpcs.xml.dist
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/COPYRIGHT b/COPYRIGHT
index 31b7f47434e..0bb5937497d 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -26,9 +26,9 @@ PHP libraries:
EvalMath 1.0 BSD Yes Safe math expressions evaluation. Used by dynamic price only. TODO Replace with dol_eval ?
Escpos-php 3.0 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers
GeoIP2 0.2.0 Apache License 2.0 Yes Lib to make geoip convert
-MathPHP 2.8.1 MIT License Yes Modern math library for PHP
+MathPHP 2.8.1 MIT License Yes Modern math library for PHP (only few files)
Mobiledetect 2.8.41 MIT License Yes Detect mobile devices browsers
-NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
+NuSoap 0.9.16 LGPL 2.1+ Yes Library to develop SOAP Web services. From https://github.com/f00b4r/nusoap/tree/v0.9.16
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.7.4 MIT License Yes Markdown parser
PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files
diff --git a/ChangeLog b/ChangeLog
index a5d8b7c967e..0458780eeab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -254,6 +254,44 @@ The following changes may create regressions for some external modules, but were
* A very high number of class properties (with old name in french) are now deprecated in favor of the property name in english.
+***** ChangeLog for 18.0.4 compared to 18.0.3 *****
+FIX: $this->newref already exists and could have been modified by trigger but we still use a local variable for the filesystem-based renaming
+FIX: 16.0 only, backport fix for SQL error on global search product
+FIX: #25399 (#26694)
+FIX: #25458 intervention localizations (backport v17) (#26757)
+FIX: #26518
+FIX: #26536 Accountancy - Balance - Not divided lines by label & account, only by account (#26547)
+FIX: #26553 Supplier invoice - Do not display the delete button for reconciled payment (#26554)
+FIX: #26735
+FIX: #26994
+FIX: Accountancy - Possibility to write in bookkeeping expense report operation with some line not bound (#26545)
+FIX: add display of an error when attempting to delete a committed transaction (#26573)
+FIX: avoid warning : Cannot use a scalar value as an array (#26437)
+FIX: backport SQL error on global search product
+FIX: # Bug Estimated Stock at date value in V14 (#26479)
+FIX: commande context (#26497)
+FIX: delivery note disappear after generation
+FIX: double hook and paging search param in product list (#26767)
+FIX: Email reminder template must not be visible when option is off
+FIX: escape HTML tags in return value of getFullName() (#26735)
+FIX: Fix set private note (#26610)
+FIX: Fix when options FAC_FORCE_DATE_VALIDATION and INVOICE_CHECK_POSTERIOR_DATE enabled. The date is forced after the test and not before
+FIX: menu auguria
+FIX: pagination parameters on save and cancel buttons (#26605)
+FIX: pdf cornas page head multicell width (backport v17)
+FIX: php8 fatal on edit supplier order when multicurrency is activated (#26758)
+FIX: possible inconsistency between llx_ecm_files and file system when BILL_SUPPLIER_VALIDATES changes ref
+FIX: regression on planned bank entries (#26556)
+FIX: Social contribution - Payment list - Wrong information in type column (#26561)
+FIX: special_code update line keep old value. (#26819)
+FIX: substitute project variables in invoice documents (#26445)
+FIX: Test on permission for holiday tooltips
+FIX: v17: Param $notrigger in $societe->create() causes method to return true regardless of actual result of database functions (#26499)
+FIX: v18 SQL error in llx_c_forme_juridique.sql when installing
+FIX: Warehouse Global Amounts not displayed (#26478)
+FIX: warning param $lineID getSpecialCode is negatif (#26826)
+FIX: warning php8.2 undefined_array_key (#26830)
+
***** ChangeLog for 18.0.3 compared to 18.0.2 *****
FIX: #25793 Cannot add time spent (#26405)
FIX: #26100 Ticket - On edit, list of closed project must be excluded (#26223)
diff --git a/SECURITY.md b/SECURITY.md
index 953059e625f..f004cea7c86 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -82,18 +82,17 @@ Scope is the web application (backoffice) and the APIs.
## Examples of vulnerabilities that are Non-qualified for reporting.
* "Self" XSS
-* SSL/TLS best practices
-* Denial of Service attacks
* Clickjacking/UI redressing
-* Physical or social engineering attempts or issues that require physical access to a victim’s computer/device
* Presence of autocomplete attribute on web forms
-* Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself.
* Logout and other instances of low-severity Cross-Site Request Forgery
-* Missing security-related HTTP headers which do not lead directly to a vulnerability
* Reports from automated web vulnerability scanners (Acunetix, Vega, etc.) that have not been validated
-* Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC)
-* Reports on features flagged as "experimental" or "development"
-* Software version or private IP disclosure when logged-in user is admin
+* Reports on features on modules flagged as "deprecated", "experimental" or "development" if the module needs to be enabled for that (this is not the case on production).
+* Software or libraries versions or private IP disclosure when logged-in user is admin
* Stack traces or path disclosure when logged-in user is admin
* Any vulnerabilities due to a configuration different than the one defined in chapter "Scope for qualified vulnerabilities".
-* Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the fail2ban recommended fail2ban rules were not installed.
+* Vulnerabilities affecting outdated browsers or platforms, or vulnerabilities inside browsers themself.
+* Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the recommended fail2ban rules were not installed.
+* SSL/TLS best practices
+* Denial of Service attacks
+* Invalid or missing SPF (Sender Policy Framework) records (Incomplete or missing SPF/DKIM/DMARC)
+* Physical or social engineering attempts or issues that require physical access to a victim’s computer/device
diff --git a/build/exe/doliwamp/UsedPort.cpp b/build/exe/doliwamp/UsedPort.cpp
index e2724b831a1..a63938c5038 100644
--- a/build/exe/doliwamp/UsedPort.cpp
+++ b/build/exe/doliwamp/UsedPort.cpp
@@ -253,6 +253,7 @@ int main(int argc, char **argv)
//----------------
int noarg,curseurarg,help=0,invalide=0;
char option;
+char *endptr;
for (noarg=1;noarg INT_MAX) {
+ // Handle error: Port number out of range
+ printf("Port number out of range\n");
+ exit(-1);
+}
+
help=!(Port > 0);
// Show usage
diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt
index 8305dbefbd9..e8af4cd420d 100644
--- a/dev/dolibarr_changes.txt
+++ b/dev/dolibarr_changes.txt
@@ -44,23 +44,22 @@ With
NUSOAP:
-------
-* In file nusoap.php, to avoid a warning,
-Replace
- if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
-By
- if (! is_array($this->methodreturn) && isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
+* Line 1257 of file nusoap.php. Add:
-* In file nusoap.php, to avoid a warning,
-Replace call to serialize_val with no bugged value
+ libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only for libxml < 2.
+
+
+* Line 4346 of file nusoap.php
-* In all files, replace constructor names into __construct. Replace also parent::constructor_name with parent::__construct
+ $rev = array();
+ preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
+ $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
-* Line 4222 of file nusoap.php
-
- $rev = array();
- preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
- $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
+* Line 6566 of file nusoap.php, replace
+ if (count($attrs) > 0) {
+ with
+ if (is_array($attrs) && count($attrs) > 0) {
diff --git a/dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt b/dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt
new file mode 100644
index 00000000000..d85bedd9528
--- /dev/null
+++ b/dev/examples/stripe/webhook_ipn_paymentintent_failed_sepa.txt
@@ -0,0 +1,124 @@
+{
+ "id": "evt_123456789",
+ "object": "event",
+ "api_version": "2023-10-16",
+ "created": 1702053463,
+ "data": {
+ "object": {
+ "id": "pi_123456789",
+ "object": "payment_intent",
+ "amount": 60,
+ "amount_capturable": 0,
+ "amount_details": {
+ "tip": {
+ }
+ },
+ "amount_received": 0,
+ "application": null,
+ "application_fee_amount": null,
+ "automatic_payment_methods": null,
+ "canceled_at": null,
+ "cancellation_reason": null,
+ "capture_method": "automatic",
+ "client_secret": "pi_123456789_secret_123456789",
+ "confirmation_method": "automatic",
+ "created": 1702053448,
+ "currency": "eur",
+ "customer": "cus_123456789",
+ "description": "Stripe payment from makeStripeSepaRequest: DID=31262-INV=123-CUS=123 did=123 ref=FA2312-123",
+ "invoice": null,
+ "last_payment_error": {
+ "code": "",
+ "decline_code": "generic_decline",
+ "message": "The transaction can't be processed because your customer's account information is missing or incorrect. Collect a new mandate and ask your customer to provide their name and address exactly as it appears on their bank account. After this, you can attempt the transaction again.",
+ "payment_method": {
+ "id": "pm_123456789",
+ "object": "payment_method",
+ "billing_details": {
+ "address": {
+ "city": null,
+ "country": "FR",
+ "line1": null,
+ "line2": null,
+ "postal_code": null,
+ "state": null
+ },
+ "email": "email@example.com",
+ "name": "Test example",
+ "phone": null
+ },
+ "created": 1692688898,
+ "customer": "cus_123456789",
+ "livemode": false,
+ "metadata": {
+ "dol_version": "19.0.0-dev",
+ "dol_thirdparty_id": "123",
+ "ipaddress": "1.2.3.4",
+ "dol_id": "123",
+ "dol_type": "companypaymentmode",
+ "dol_entity": "1"
+ },
+ "sepa_debit": {
+ "bank_code": "123",
+ "branch_code": "",
+ "country": "AT",
+ "fingerprint": "123456789",
+ "generated_from": {
+ "charge": null,
+ "setup_attempt": null
+ },
+ "last4": "3202"
+ },
+ "type": "sepa_debit"
+ },
+ "type": "card_error"
+ },
+ "latest_charge": "py_123456789",
+ "livemode": false,
+ "metadata": {
+ "dol_version": "19.0.0-beta",
+ "dol_thirdparty_id": "123",
+ "ipaddress": "1.2.3.4",
+ "dol_id": "123",
+ "dol_type": "facture",
+ "dol_entity": "1"
+ },
+ "next_action": null,
+ "on_behalf_of": null,
+ "payment_method": null,
+ "payment_method_configuration_details": null,
+ "payment_method_options": {
+ "card": {
+ "installments": null,
+ "mandate_options": null,
+ "network": null,
+ "request_three_d_secure": "automatic"
+ },
+ "sepa_debit": {
+ }
+ },
+ "payment_method_types": [
+ "card",
+ "sepa_debit"
+ ],
+ "processing": null,
+ "receipt_email": null,
+ "review": null,
+ "setup_future_usage": null,
+ "shipping": null,
+ "source": null,
+ "statement_descriptor": "DID=123-",
+ "statement_descriptor_suffix": "DID=123-",
+ "status": "requires_payment_method",
+ "transfer_data": null,
+ "transfer_group": null
+ }
+ },
+ "livemode": false,
+ "pending_webhooks": 1,
+ "request": {
+ "id": null,
+ "idempotency_key": null
+ },
+ "type": "payment_intent.payment_failed"
+}
diff --git a/dev/initdata/purge-data.php b/dev/initdata/purge-data.php
index d75c9fae8b2..442d991a453 100755
--- a/dev/initdata/purge-data.php
+++ b/dev/initdata/purge-data.php
@@ -148,8 +148,8 @@ $sqls=array(
"DELETE FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'",
),
'project'=>array(
- // TODO set fk_project to null on object that refer to project
- "DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
+ // TODO set fk_project to null on all objects/tables that refer to project
+ "DELETE FROM ".MAIN_DB_PREFIX."element_time WHERE elementtype = 'task' AND fk_element IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
"DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')",
"DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'",
),
diff --git a/dev/tools/apstats.php b/dev/tools/apstats.php
index e15c8b5ace2..80e026bb600 100755
--- a/dev/tools/apstats.php
+++ b/dev/tools/apstats.php
@@ -38,6 +38,8 @@ error_reporting(E_ALL & ~E_DEPRECATED);
define('PRODUCT', "apstats");
define('VERSION', "1.0");
+$phpstanlevel = 2;
+
print '***** '.constant('PRODUCT').' - '.constant('VERSION').' *****'."\n";
if (empty($argv[1])) {
@@ -71,6 +73,7 @@ while ($i < $argc) {
$i++;
}
+$timestart = time();
// Count lines of code of Dolibarr itself
/*
@@ -86,7 +89,7 @@ $resexec = (int) (empty($resexec) ? 0 : trim($resexec));
*/
// Count lines of code of application
-$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc . --exclude-dir=includes,custom';
+$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc . --exclude-dir=htdocs/includes,htdocs/custom,htdocs/theme/common/fontawesome-5,htdocs/theme/common/octicons';
print 'Execute SCC to count lines of code in project: '.$commandcheck."\n";
$output_arrproj = array();
$resexecproj = 0;
@@ -94,7 +97,7 @@ exec($commandcheck, $output_arrproj, $resexecproj);
// Count lines of code of dependencies
-$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc htdocs/includes';
+$commandcheck = ($dirscc ? $dirscc.'/' : '').'scc htdocs/includes htdocs/theme/common/fontawesome-5 htdocs/theme/common/octicons';
print 'Execute SCC to count lines of code in dependencies: '.$commandcheck."\n";
$output_arrdep = array();
$resexecdep = 0;
@@ -102,7 +105,7 @@ exec($commandcheck, $output_arrdep, $resexecdep);
// Get technical debt
-$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
+$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$phpstanlevel.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n";
$output_arrtd = array();
$resexectd = 0;
@@ -169,6 +172,8 @@ foreach (array('proj', 'dep') as $source) {
}
}
+$timeend = time();
+
/*
* View
@@ -224,7 +229,7 @@ th,td {
.nowrap {
white-space: nowrap;
}
-.opacity {
+.opacitymedium {
opacity: 0.5;
}
.centpercent {
@@ -238,6 +243,7 @@ th,td {
}
.seedetail {
color: #000088;
+ cursor: pointer;
}
.box {
padding: 20px;
@@ -293,7 +299,7 @@ $html .= ''."\n";
$html .= ''."\n";
$html .= '
\n";
// Create an external user login for each new member subscription validated
-$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.$conf->entity : '');
+$linkofpubliclist = DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.((isModEnabled('multicompany')) ? '?entity='.((int) $conf->entity) : '');
print '
\n";
// Show the table of all available membership types. If not, show a form (as the default was for Dolibarr <=16.0)
- $skiptable = (getDolGlobalString('MEMBER_SKIP_TABLE') ? $conf->global->MEMBER_SKIP_TABLE : 0);
+ $skiptable = getDolGlobalInt('MEMBER_SKIP_TABLE');
print '
';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 7c991630275..6b0e29a207f 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -68,9 +68,9 @@ $origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
// PDF
-$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
-$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
-$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
+$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0));
+$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DESC') ? 1 : 0));
+$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF') ? 1 : 0));
$datecontrat = '';
diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php
index 6a86b31bf73..523eb59ea03 100644
--- a/htdocs/contrat/class/api_contracts.class.php
+++ b/htdocs/contrat/class/api_contracts.class.php
@@ -202,6 +202,12 @@ class Contracts extends DolibarrApi
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->contract->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->contract->$field = $value;
}
/*if (isset($request_data["lines"])) {
@@ -509,6 +515,12 @@ class Contracts extends DolibarrApi
if ($field == 'id') {
continue;
}
+ if ($field === 'caller') {
+ // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller
+ $this->contract->context['caller'] = $request_data['caller'];
+ continue;
+ }
+
$this->contract->$field = $value;
}
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 08bb4caa932..d524c6973a1 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -2943,7 +2943,7 @@ class Contrat extends CommonObject
$return .= ' '.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat, 'day').'';
}
if (method_exists($this, 'getLibStatut')) {
- $return .= '
'.$this->getLibStatut(7).'
';
+ $return .= '
'.$this->getLibStatut(7).'
';
}
$return .= '';
$return .= '';
@@ -3413,7 +3413,7 @@ class ContratLigne extends CommonObjectLine
*/
public function update($user, $notrigger = 0)
{
- global $conf, $langs, $mysoc;
+ global $mysoc;
$error = 0;
@@ -3615,10 +3615,10 @@ class ContratLigne extends CommonObjectLine
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Mise a jour en base des champs total_xxx de ligne
- * Used by migration process
+ * Update in database the fields total_xxx of lines
+ * Used by migration process
*
- * @return int Return integer <0 if KO, >0 if OK
+ * @return int Return integer <0 if KO, >0 if OK
*/
public function update_total()
{
@@ -3656,7 +3656,7 @@ class ContratLigne extends CommonObjectLine
*/
public function insert($notrigger = 0)
{
- global $conf, $user;
+ global $user;
$error = 0;
@@ -3753,8 +3753,6 @@ class ContratLigne extends CommonObjectLine
public function active_line($user, $date, $date_end = '', $comment = '')
{
// phpcs:enable
- global $langs, $conf;
-
$error = 0;
$this->db->begin();
@@ -3813,9 +3811,6 @@ class ContratLigne extends CommonObjectLine
public function close_line($user, $date_end_real, $comment = '', $notrigger = 0)
{
// phpcs:enable
- global $langs, $conf;
-
- // Update object
$this->date_cloture = $date_end_real;
$this->date_end_real = $date_end_real;
$this->user_closing_id = $user->id;
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 6e375c363bd..c7de54e22e0 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -410,7 +410,7 @@ if (!$error && $massaction == 'confirm_presend') {
$tmp = explode(',', $user->email_aliases);
$from = trim($tmp[($reg[1] - 1)]);
} elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
- $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
+ $tmp = explode(',', getDolGlobalString('MAIN_INFO_SOCIETE_MAIL_ALIASES'));
$from = trim($tmp[($reg[1] - 1)]);
} elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
$sql = "SELECT rowid, label, email FROM ".MAIN_DB_PREFIX."c_email_senderprofile WHERE rowid = ".(int) $reg[1];
@@ -751,7 +751,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto
$result = $objecttmp->fetch($toselectid);
if ($result > 0) {
$listofobjectid[$toselectid] = $toselectid;
- $thirdpartyid = $objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid;
+ $thirdpartyid = !empty($objecttmp->fk_soc) ? $objecttmp->fk_soc : $objecttmp->socid;
$listofobjectthirdparties[$thirdpartyid] = $thirdpartyid;
$listofobjectref[$toselectid] = $objecttmp->ref;
}
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index b05e13d76eb..6fbe2440fb3 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -286,7 +286,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
$tmp = explode(',', $user->email_aliases);
$from = trim($tmp[($reg[1] - 1)]);
} elseif (preg_match('/global_aliases_(\d+)/', $fromtype, $reg)) {
- $tmp = explode(',', $conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES);
+ $tmp = explode(',', getDolGlobalString('MAIN_INFO_SOCIETE_MAIL_ALIASES'));
$from = trim($tmp[($reg[1] - 1)]);
} elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
@@ -328,7 +328,7 @@ if (($action == 'send' || $action == 'relance') && !GETPOST('addfile') && !GETPO
$deliveryreceipt = GETPOST('deliveryreceipt');
if ($action == 'send' || $action == 'relance') {
- $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
+ $actionmsg2 = $langs->transnoentities('MailSentByTo', CMailFile::getValidAddress($from, 4, 0, 1), CMailFile::getValidAddress($sendto, 4, 0, 1));
/*if ($message) {
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php
index 301b9ef1d6e..129658ef8fd 100644
--- a/htdocs/core/ajax/ajaxtooltip.php
+++ b/htdocs/core/ajax/ajaxtooltip.php
@@ -38,7 +38,6 @@ include '../../main.inc.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-
$id = GETPOST('id', 'aZ09');
$objecttype = GETPOST('objecttype', 'aZ09arobase'); // 'module' or 'myobject@mymodule', 'mymodule_myobject'
diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php
index 177154cee3a..fc89b77c56b 100644
--- a/htdocs/core/ajax/fileupload.php
+++ b/htdocs/core/ajax/fileupload.php
@@ -18,7 +18,7 @@
/**
* \file htdocs/core/ajax/fileupload.php
- * \brief File to return Ajax response on file upload
+ * \brief File to return Ajax response on common file upload. For large files, see flowjs-server.php
*/
if (!defined('NOREQUIREMENU')) {
@@ -36,7 +36,7 @@ if (!defined('NOREQUIRESOC')) {
// Load Dolibarr environment
require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php'; // Class to upload common files
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
$id = GETPOST('fk_element', 'int');
diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php
index 1ef36091082..49afbcc0953 100644
--- a/htdocs/core/ajax/onlineSign.php
+++ b/htdocs/core/ajax/onlineSign.php
@@ -70,6 +70,12 @@ $type = $mode;
$securekeyseed = '';
if ($type == 'proposal') {
$securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
+} elseif ($type == 'contract') {
+ $securekeyseed = getDolGlobalString('CONTRACT_ONLINE_SIGNATURE_SECURITY_TOKEN');
+} elseif ($type == 'fichinter') {
+ $securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN');
+} else {
+ $securekeyseed = getDolGlobalString(strtoupper($type).'_ONLINE_SIGNATURE_SECURITY_TOKEN');
}
if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed . $type . $ref . (!isModEnabled('multicompany') ? '' : $entity), $SECUREKEY, '0')) {
@@ -152,6 +158,10 @@ if ($action == "importSignature") {
//$pdf->Open();
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
+ $param = array();
+ $param['online_sign_name'] = $online_sign_name;
+ $param['pathtoimage'] = $upload_dir . $filename;
+
$s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297);
for ($i = 1; $i < ($pagecount + 1); $i++) {
try {
@@ -159,6 +169,17 @@ if ($action == "importSignature") {
$s = $pdf->getTemplatesize($tppl);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tppl);
+
+ if (getDolGlobalString("PROPAL_SIGNATURE_ON_ALL_PAGES")) {
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
+
+ $param['xforimgstart'] = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
+ $param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 60);
+ $param['wforimg'] = $s['w'] - 20 - $param['xforimgstart'];
+
+ dolPrintSignatureImage($pdf, $langs, $param);
+ }
} catch (Exception $e) {
dol_syslog("Error when manipulating the PDF " . $sourcefile . " by onlineSign: " . $e->getMessage(), LOG_ERR);
$response = $e->getMessage();
@@ -166,19 +187,16 @@ if ($action == "importSignature") {
}
}
- // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
- // TODO Get position of box from PDF template
- $xforimgstart = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
- $yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 60);
- $wforimg = $s['w'] - 20 - $xforimgstart;
+ if (!getDolGlobalString("PROPAL_SIGNATURE_ON_ALL_PAGES")) {
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
- $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4) - 4);
- $pdf->SetFont($default_font, '', $default_font_size - 1);
- $pdf->MultiCell($wforimg, 4, $langs->trans("DateSigning") . ': ' . dol_print_date(dol_now(), "daytext", false, $langs, true), 0, 'L');
- $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4));
- $pdf->MultiCell($wforimg, 4, $langs->trans("Lastname") . ': ' . $online_sign_name, 0, 'L');
+ $param['xforimgstart'] = (empty($s['w']) ? 120 : round($s['w'] / 2) + 15);
+ $param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 60);
+ $param['wforimg'] = $s['w'] - 20 - $param['xforimgstart'];
- $pdf->Image($upload_dir . $filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
+ dolPrintSignatureImage($pdf, $langs, $param);
+ }
//$pdf->Close();
$pdf->Output($newpdffilename, "F");
@@ -294,9 +312,13 @@ if ($action == "importSignature") {
$pdf->SetCompression(false);
}
-
//$pdf->Open();
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
+
+ $param = array();
+ $param['online_sign_name'] = $online_sign_name;
+ $param['pathtoimage'] = $upload_dir . $filename;
+
$s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297);
for ($i = 1; $i < ($pagecount + 1); $i++) {
try {
@@ -304,6 +326,17 @@ if ($action == "importSignature") {
$s = $pdf->getTemplatesize($tppl);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tppl);
+
+ if (getDolGlobalString("CONTRACT_SIGNATURE_ON_ALL_PAGES")) {
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
+
+ $param['xforimgstart'] = 10;
+ $param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 65);
+ $param['wforimg'] = $s['w'] / 2 - $param['xforimgstart'];
+
+ dolPrintSignatureImage($pdf, $langs, $param);
+ }
} catch (Exception $e) {
dol_syslog("Error when manipulating some PDF by onlineSign: " . $e->getMessage(), LOG_ERR);
$response = $e->getMessage();
@@ -311,13 +344,17 @@ if ($action == "importSignature") {
}
}
- // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
- // TODO Get position of box from PDF template
- $xforimgstart = 5;
- $yforimgstart = (empty($s['h']) ? 240 : $s['h'] - 65);
- $wforimg = $s['w'] / 2 - $xforimgstart;
+ if (!getDolGlobalString("CONTRACT_SIGNATURE_ON_ALL_PAGES")) {
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
+
+ $param['xforimgstart'] = 10;
+ $param['yforimgstart'] = (empty($s['h']) ? 240 : $s['h'] - 65);
+ $param['wforimg'] = $s['w'] / 2 - $param['xforimgstart'];
+
+ dolPrintSignatureImage($pdf, $langs, $param);
+ }
- $pdf->Image($upload_dir . $filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
//$pdf->Close();
$pdf->Output($newpdffilename, "F");
@@ -388,9 +425,13 @@ if ($action == "importSignature") {
$pdf->SetCompression(false);
}
-
//$pdf->Open();
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
+
+ $param = array();
+ $param['online_sign_name'] = $online_sign_name;
+ $param['pathtoimage'] = $upload_dir . $filename;
+
$s = array(); // Array with size of each page. Exemple array(w'=>210, 'h'=>297);
for ($i = 1; $i < ($pagecount + 1); $i++) {
try {
@@ -398,6 +439,17 @@ if ($action == "importSignature") {
$s = $pdf->getTemplatesize($tppl);
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
$pdf->useTemplate($tppl);
+
+ if (getDolGlobalString("FICHINTER_SIGNATURE_ON_ALL_PAGES")) {
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
+
+ $param['xforimgstart'] = 111;
+ $param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
+ $param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);
+
+ dolPrintSignatureImage($pdf, $langs, $param);
+ }
} catch (Exception $e) {
dol_syslog("Error when manipulating some PDF by onlineSign: " . $e->getMessage(), LOG_ERR);
$response = $e->getMessage();
@@ -405,23 +457,17 @@ if ($action == "importSignature") {
}
}
- // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ if (!getDolGlobalString("FICHINTER_SIGNATURE_ON_ALL_PAGES")) {
+ // A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
+ // TODO Get position of box from PDF template
+ $param['xforimgstart'] = 111;
+ $param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
+ $param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);
+ dolPrintSignatureImage($pdf, $langs, $param);
+ }
- // TODO Get position of box from PDF template
- $xforimgstart = 105;
- $yforimgstart = (empty($s['h']) ? 250 : $s['h'] - 57);
-
- $wforimg = $s['w'] / 1 - ($xforimgstart + 16);
-
- $pdf->SetXY(111, 235 +25);
- $pdf->SetFont($default_font, '', $default_font_size - 1);
- $pdf->MultiCell($wforimg, 4, $langs->trans("DateSigning").': '.dol_print_date(dol_now(), "daytext", false, $langs, true), 0, 'L');
- $pdf->SetXY(111, $pdf->GetY());
- $pdf->MultiCell($wforimg, 4, $langs->trans("Lastname").': '.$online_sign_name, 0, 'L');
-
- $pdf->Image($upload_dir.$filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
//$pdf->Close();
$pdf->Output($newpdffilename, "F");
@@ -450,8 +496,7 @@ if ($action == "importSignature") {
$object->fetch_thirdparty();
- $upload_dir = $conf->societe->multidir_output[$object->thirdparty->entity] . '/'
- . dol_sanitizeFileName($object->thirdparty->id) . '/';
+ $upload_dir = $conf->societe->multidir_output[$object->thirdparty->entity] . '/' . dol_sanitizeFileName($object->thirdparty->id) . '/';
$default_font_size = pdf_getPDFFontSize($langs); // Must be after pdf_getInstance
$default_font = pdf_getPDFFont($langs); // Must be after pdf_getInstance
@@ -563,11 +608,18 @@ if ($action == "importSignature") {
$yforimgstart = $yForDate - 5;
$wforimg = $s['w'] - 20 - $xforimgstart;
- $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4));
- $pdf->MultiCell($wforimg, 4, $langs->trans("Lastname") . ': ' . $online_sign_name, 0, 'L');
+ $param = array();
+ $param['online_sign_name'] = $online_sign_name;
+ $param['pathtoimage'] = $upload_dir . $filename;
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
- $pdf->Image($upload_dir . $filename, $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
+ // TODO Get position of box from PDF template
+
+ $param['xforimgstart'] = $xforimgstart;
+ $param['yforimgstart'] = $yforimgstart;
+ $param['wforimg'] = $wforimg;
+
+ dolPrintSignatureImage($pdf, $langs, $param);
}
//$pdf->Close();
$pdf->Output($newpdffilename, "F");
@@ -639,3 +691,32 @@ if ($error) {
}
echo $response;
+
+
+/**
+ * Output the signature file
+ *
+ * @param TCPDF $pdf PDF handler
+ * @param Translate $langs Language
+ * @param array $params Array of params
+ * @return void
+ */
+function dolPrintSignatureImage(TCPDF $pdf, $langs, $params)
+{
+ $default_font_size = pdf_getPDFFontSize($langs); // Must be after pdf_getInstance
+ $default_font = pdf_getPDFFont($langs); // Must be
+ $xforimgstart = $params['xforimgstart'];
+ $yforimgstart = $params['yforimgstart'];
+ $wforimg = $params['wforimg'];
+
+ $pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4) - 4);
+ $pdf->SetFont($default_font, '', $default_font_size - 1);
+ $pdf->SetTextColor(80, 80, 80);
+ $pdf->MultiCell($wforimg, 4, $langs->trans("Signature") . ': ' . dol_print_date(dol_now(), "day", false, $langs, true). ' - '.$params['online_sign_name'], 0, 'L');
+ //$pdf->SetXY($xforimgstart, $yforimgstart + round($wforimg / 4));
+ //$pdf->MultiCell($wforimg, 4, $langs->trans("Lastname") . ': ' . $online_sign_name, 0, 'L');
+
+ $pdf->Image($params['pathtoimage'], $xforimgstart, $yforimgstart, $wforimg, round($wforimg / 4));
+
+ return;
+}
diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php
index 854188f7d6e..96700b261da 100644
--- a/htdocs/core/ajax/pingresult.php
+++ b/htdocs/core/ajax/pingresult.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2019-2023 Laurent Destailleur
*
* 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
@@ -16,9 +16,10 @@
*/
/**
- * \file htdocs/core/ajax/pingresult.php
- * \brief Page called after a ping was done in js to the official dolibarr ping service.
- * This ajax URL is called with parameter 'firstpingok' or 'firstpingko' depending on the result of the ping.
+ * \file htdocs/core/ajax/pingresult.php
+ * \brief Page called after a ping was done in js to the official dolibarr ping service.
+ * This ajax URL is called with parameter 'firstpingok' or 'firstpingko' depending on the result of the ping.
+ * You can use &forceping=1 in parameters to force the ping if the ping was already sent.
*/
if (!defined('NOTOKENRENEWAL')) {
diff --git a/htdocs/core/ajax/selectobject.php b/htdocs/core/ajax/selectobject.php
index 14372a405b4..edc5eb32998 100644
--- a/htdocs/core/ajax/selectobject.php
+++ b/htdocs/core/ajax/selectobject.php
@@ -39,34 +39,92 @@ if (!defined('NOREQUIRESOC')) {
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-$objectdesc = GETPOST('objectdesc', 'alpha');
+$extrafields = new ExtraFields($db);
+
+$objectdesc = GETPOST('objectdesc', 'alphanohtml', 0, null, null, 1);
$htmlname = GETPOST('htmlname', 'aZ09');
$outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
-$id = GETPOST('id', 'int');
-$filter = GETPOST('filter', 'alphanohtml'); // Universal Syntax filter
+$id = GETPOSTINT('id');
+$objectfield = GETPOST('objectfield', 'alpha'); // 'MyObject:field' or 'MyModule_MyObject:field' or 'MyObject:option_field' or 'MyModule_MyObject:option_field'
if (empty($htmlname)) {
httponly_accessforbidden('Bad value for param htmlname');
}
-$InfoFieldList = explode(":", $objectdesc);
-$classname = $InfoFieldList[0];
-$classpath = $InfoFieldList[1];
-if (!empty($classpath)) {
- dol_include_once($classpath);
- if ($classname && class_exists($classname)) {
- $objecttmp = new $classname($db);
+if (!empty($objectfield)) {
+ // Recommended method to call selectobject.
+ // $objectfield is Object:Field that contains the definition (in table $fields or extrafield). Example: 'Societe:t.ddd' or 'Societe:options_xxx'
+
+ $tmparray = explode(':', $objectfield);
+ $objectdesc = '';
+
+ // Load object according to $id and $element
+ $objectforfieldstmp = fetchObjectByElement(0, strtolower($tmparray[0]));
+
+ $reg = array();
+ if (preg_match('/^options_(.*)$/', $tmparray[1], $reg)) {
+ // For a property in extrafields
+ $key = $reg[1];
+ // fetch optionals attributes and labels
+ $extrafields->fetch_name_optionals_label($objectforfieldstmp->table_element);
+
+ if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key]) && $extrafields->attributes[$objectforfieldstmp->table_element]['type'][$key] == 'link') {
+ if (!empty($extrafields->attributes[$objectforfieldstmp->table_element]['param'][$key]['options'])) {
+ $tmpextrafields = array_keys($extrafields->attributes[$objectforfieldstmp->table_element]['param'][$key]['options']);
+ $objectdesc = $tmpextrafields[0];
+ }
+ }
+ } else {
+ // For a property in ->fields
+ $objectdesc = $objectforfieldstmp->fields[$tmparray[1]]['type'];
+ $objectdesc = preg_replace('/^integer[^:]*:/', '', $objectdesc);
}
}
-if (!is_object($objecttmp)) {
- httponly_accessforbidden('Bad value for param objectdesc');
+
+if ($objectdesc) {
+ // Example of value for $objectdesc:
+ // Bom:bom/class/bom.class.php:0:t.status=1
+ // Bom:bom/class/bom.class.php:0:t.status=1:ref
+ // Bom:bom/class/bom.class.php:0:(t.status:=:1) OR (t.field2:=:2):ref
+ $InfoFieldList = explode(":", $objectdesc, 4);
+ $vartmp = (empty($InfoFieldList[3]) ? '' : $InfoFieldList[3]);
+ $reg = array();
+ if (preg_match('/^.*:(\w*)$/', $vartmp, $reg)) {
+ $InfoFieldList[4] = $reg[1]; // take the sort field
+ }
+ $InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field
+
+ $classname = $InfoFieldList[0];
+ $classpath = $InfoFieldList[1];
+ //$addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2];
+ $filter = empty($InfoFieldList[3]) ? '' : $InfoFieldList[3];
+ $sortfield = empty($InfoFieldList[4]) ? '' : $InfoFieldList[4];
+
+ // Load object according to $id and $element
+ $objecttmp = fetchObjectByElement(0, strtolower($InfoFieldList[0]));
+
+ // Fallback to another solution to get $objecttmp
+ if (empty($objecttmp) && !empty($classpath)) {
+ dol_include_once($classpath);
+
+ if ($classname && class_exists($classname)) {
+ $objecttmp = new $classname($db);
+ }
+ }
}
-/*
-// Load object according to $id and $element
-$object = fetchObjectByElement($id, $element);
+// Make some replacement
+$sharedentities = getEntity(strtolower($objecttmp->element));
+$filter = str_replace(
+ array('__ENTITY__', '__SHARED_ENTITIES__', '__USER_ID__', '$ID$'),
+ array($conf->entity, $sharedentities, $user->id, $id),
+ $filter
+);
+
+/*
$module = $object->module;
$element = $object->element;
$usesublevelpermission = ($module != $element ? $element : '');
@@ -86,15 +144,13 @@ restrictedArea($user, $objecttmp->element, $id);
* View
*/
-//print ''."\n";
-//print_r($_GET);
-
-//$langs->load("companies");
-
$form = new Form($db);
top_httphead($outjson ? 'application/json' : 'text/html');
+//print ''."\n";
+//print_r($_GET);
+
$arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1, 0, '', $filter);
$db->close();
diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php
index 295a14159cf..c8f683a86ec 100644
--- a/htdocs/core/boxes/box_comptes.php
+++ b/htdocs/core/boxes/box_comptes.php
@@ -63,7 +63,7 @@ class box_comptes extends ModeleBoxes
$this->db = $db;
// disable module for such cases
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
if (!in_array('banque', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php
index 257f351cfca..b2cc183fc2a 100644
--- a/htdocs/core/boxes/box_funnel_of_prospection.php
+++ b/htdocs/core/boxes/box_funnel_of_prospection.php
@@ -26,6 +26,7 @@
*/
include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
+
/**
* Class to manage the box to show funnel of prospections
*/
@@ -56,7 +57,7 @@ class box_funnel_of_prospection extends ModeleBoxes
*/
public function __construct($db, $param = '')
{
- global $user, $langs, $conf;
+ global $user, $langs;
// Load translation files required by the page
$langs->loadLangs(array('boxes', 'projects'));
@@ -64,6 +65,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$this->db = $db;
$this->enabled = (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0); // Not enabled by default, still need some work
+ //$this->enabled = 1;
$this->hidden = empty($user->rights->projet->lire);
}
@@ -102,6 +104,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$sql .= " FROM ".MAIN_DB_PREFIX."c_lead_status as cls";
$sql .= " WHERE active=1";
$sql .= " AND cls.code <> 'LOST'";
+ $sql .= " AND cls.code <> 'WON'";
$sql .= $this->db->order('cls.rowid', 'ASC');
$resql = $this->db->query($sql);
if ($resql) {
@@ -126,9 +129,6 @@ class box_funnel_of_prospection extends ModeleBoxes
case 'NEGO':
$colorseriesstat[$objp->rowid] = $badgeStatus4;
break;
- case 'WON':
- $colorseriesstat[$objp->rowid] = $badgeStatus6;
- break;
default:
break;
}
@@ -143,6 +143,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$this->info_box_head = array(
'text' => $langs->trans("Statistics").' - '.$langs->trans("BoxTitleFunnelOfProspection"),
+ 'nbcol' => '2',
'graph' => '1'
);
@@ -152,7 +153,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$sql .= " WHERE p.entity IN (".getEntity('project').")";
$sql .= " AND p.fk_opp_status = cls.rowid";
$sql .= " AND p.fk_statut = 1"; // Opend projects only
- $sql .= " AND cls.code NOT IN ('LOST')";
+ $sql .= " AND cls.code NOT IN ('LOST', 'WON')";
$sql .= " GROUP BY p.fk_opp_status, cls.code";
$resql = $this->db->query($sql);
@@ -236,6 +237,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$dolgraph->setShowPercent(1);
$dolgraph->setMirrorGraphValues(true);
$dolgraph->setBorderWidth(2);
+ $dolgraph->setBorderSkip('false');
$dolgraph->SetType(array('horizontalbars'));
$dolgraph->SetHeight('200');
$dolgraph->SetWidth('600');
@@ -248,7 +250,7 @@ class box_funnel_of_prospection extends ModeleBoxes
$stringtoprint .= '';
$line = 0;
- $this->info_box_contents[$line][] = array(
+ /*$this->info_box_contents[$line][] = array(
'tr' => 'class="nohover left "',
'text' => ''
);
@@ -256,7 +258,7 @@ class box_funnel_of_prospection extends ModeleBoxes
'tr' => 'class="nohover left "',
'text' => ''
);
- $line++;
+ $line++;*/
$this->info_box_contents[$line][] = array(
'tr' => '',
'td' => 'class="center nopaddingleftimp nopaddingrightimp" colspan="2"',
diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php
index df8192c2055..45404727d96 100644
--- a/htdocs/core/boxes/box_members_by_tags.php
+++ b/htdocs/core/boxes/box_members_by_tags.php
@@ -63,7 +63,7 @@ class box_members_by_tags extends ModeleBoxes
$this->db = $db;
// disable module for such cases
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php
index 9bcb20b2826..4a684011139 100644
--- a/htdocs/core/boxes/box_members_by_type.php
+++ b/htdocs/core/boxes/box_members_by_type.php
@@ -63,7 +63,7 @@ class box_members_by_type extends ModeleBoxes
$this->db = $db;
// disable module for such cases
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php
index a961a478385..2d9d580f8b8 100644
--- a/htdocs/core/boxes/box_members_last_modified.php
+++ b/htdocs/core/boxes/box_members_last_modified.php
@@ -62,7 +62,7 @@ class box_members_last_modified extends ModeleBoxes
$this->db = $db;
// disable module for such cases
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php
index 3d1e88627f2..b7eaad8cd13 100644
--- a/htdocs/core/boxes/box_members_last_subscriptions.php
+++ b/htdocs/core/boxes/box_members_last_subscriptions.php
@@ -62,7 +62,7 @@ class box_members_last_subscriptions extends ModeleBoxes
$this->db = $db;
// disable module for such cases
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php
index 999640c3ae4..9a94f6f071b 100644
--- a/htdocs/core/boxes/box_members_subscriptions_by_year.php
+++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php
@@ -62,7 +62,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes
$this->db = $db;
// disable module for such cases
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php
index ff01ceb810d..748c58f2381 100644
--- a/htdocs/core/boxes/box_produits_alerte_stock.php
+++ b/htdocs/core/boxes/box_produits_alerte_stock.php
@@ -63,7 +63,7 @@ class box_produits_alerte_stock extends ModeleBoxes
$this->db = $db;
- $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
+ $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
$tmpentry = array('enabled'=>((isModEnabled("product") || isModEnabled("service")) && isModEnabled('stock')), 'perms'=>!empty($user->rights->stock->lire), 'module'=>'product|service|stock');
$showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal);
$this->hidden = ($showmode != 1);
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 260baa718ea..941f12cba82 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -223,7 +223,10 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) {
$out .= '
';
$out .= '
0) {
+ if (!empty($head['nbcol'])) {
+ $nbcol = $head['nbcol'];
+ }
+ if ($nbcol > 1) {
$out .= ' colspan="'.$nbcol.'"';
}
$out .= '>';
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index ceb65e8cfa9..5f053ae6e18 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -311,7 +311,7 @@ class CMailFile
// Add auto copy to if not already in $to (Note: Adding bcc for specific modules are also done from pages)
// For example MAIN_MAIL_AUTOCOPY_TO can be 'email@example.com, __USER_EMAIL__, ...'
if (getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO')) {
- $listofemailstoadd = explode(',', $conf->global->MAIN_MAIL_AUTOCOPY_TO);
+ $listofemailstoadd = explode(',', getDolGlobalString('MAIN_MAIL_AUTOCOPY_TO'));
foreach ($listofemailstoadd as $key => $val) {
$emailtoadd = $listofemailstoadd[$key];
if (trim($emailtoadd) == '__USER_EMAIL__') {
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index 0f3b8628122..83f38d2a70f 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -49,6 +49,12 @@ abstract class CommonInvoice extends CommonObject
*/
public $subtype;
+ /**
+ * @var int Thirdparty ID
+ * @deprecated
+ * @see $socid
+ */
+ public $fk_soc;
/**
* @var int Thirdparty ID
*/
@@ -63,6 +69,8 @@ abstract class CommonInvoice extends CommonObject
*/
public $date;
+ public $date_lim_reglement;
+
public $cond_reglement_id; // Id in llx_c_paiement
public $cond_reglement_code; // Code in llx_c_paiement
public $cond_reglement_label;
@@ -1131,14 +1139,18 @@ abstract class CommonInvoice extends CommonObject
}
// Load the pending payment request to process (with rowid=$did)
- $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_prelevement_bons";
+ $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn, fk_salary, fk_prelevement_bons";
$sql .= " FROM ".$this->db->prefix()."prelevement_demande";
$sql .= " WHERE rowid = ".((int) $did);
if ($type != 'bank-transfer' && $type != 'credit-transfer') {
- $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one
+ $sql .= " AND fk_facture = ".((int) $this->id); // Add a protection to not pay another invoice than current one
}
if ($type != 'direct-debit') {
- $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one
+ if ($$sourcetype == 'salary') {
+ $sql .= " AND fk_salary = ".((int) $this->id); // Add a protection to not pay another salary than current one
+ } else {
+ $sql .= " AND fk_facture_fourn = ".((int) $this->id); // Add a protection to not pay another invoice than current one
+ }
}
$sql .= " AND traite = 0"; // To not process payment request that were already converted into a direct debit or credit transfer order (Note: fk_prelevement_bons is also empty when traite = 0)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index fdc1fc4bf6a..140b7a92d26 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -93,7 +93,7 @@ abstract class CommonObject
public $element;
/**
- * @var int The related element
+ * @var string Fieldname with ID of parent key if this field has a parent
*/
public $fk_element;
@@ -167,8 +167,9 @@ abstract class CommonObject
* @var CommonObject To store a cloned copy of object before to edit it and keep track of old properties
*/
public $oldcopy;
+
/**
- * @var CommonObject To store old value of a modified ref
+ * @var string To store old value of a modified ref
*/
public $oldref;
@@ -675,9 +676,14 @@ abstract class CommonObject
public $sendtoid;
/**
- * @var float Amount already paid (used to show correct status)
+ * @var float Amount already paid from getSommePaiement() (used to show correct status)
+ * @deprecated Duplicate of $totalpaid
*/
public $alreadypaid;
+ /**
+ * @var float Amount already paid from getSommePaiement() (used to show correct status)
+ */
+ public $totalpaid;
/**
* @var array Array with label of status
@@ -854,6 +860,7 @@ abstract class CommonObject
// Add extrafields
if (!empty($extrafields->attributes[$this->table_element]['label'])) {
+ $datas['opendivextra'] = '
';
foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) {
if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') {
continue;
@@ -894,6 +901,7 @@ abstract class CommonObject
$count++;
}
}
+ $datas['closedivextra'] = '
';
}
$hookmanager->initHooks(array($this->element . 'dao'));
@@ -1730,8 +1738,6 @@ abstract class CommonObject
public function fetch_thirdparty($force_thirdparty_id = 0)
{
// phpcs:enable
- global $conf;
-
if (empty($this->socid) && empty($this->fk_soc) && empty($force_thirdparty_id)) {
return 0;
}
@@ -3654,7 +3660,7 @@ abstract class CommonObject
if (!empty($MODULE)) {
if (!empty($conf->global->$MODULE)) {
- $modsactivated = explode(',', $conf->global->$MODULE);
+ $modsactivated = explode(',', getDolGlobalString($MODULE));
foreach ($modsactivated as $mod) {
if (isModEnabled($mod)) {
return 1; // update was disabled by specific setup
@@ -4533,6 +4539,9 @@ abstract class CommonObject
if ($elementTable == 'commande_fournisseur_dispatch') {
$fieldstatus = "status";
}
+ if ($elementTable == 'prelevement_bons') {
+ $fieldstatus = "statut";
+ }
if (isset($this->fields) && is_array($this->fields) && array_key_exists('status', $this->fields)) {
$fieldstatus = 'status';
}
@@ -5617,7 +5626,9 @@ abstract class CommonObject
$file = $prefix."_".$modele.".modules.php";
}
- // On verifie l'emplacement du modele
+ $file = dol_sanitizeFileName($file);
+
+ // We chack if file exists
$file = dol_buildpath($reldir.$modelspath.$file, 0);
if (file_exists($file)) {
$filefound = $file;
@@ -5637,10 +5648,13 @@ abstract class CommonObject
return -1;
}
- // If generator was found
- global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
+ // Sanitize $filefound
+ $filefound = dol_sanitizePathName($filefound);
- require_once $file;
+ // If generator was found
+ global $db; // Required to solve a conception default making an include of some code that uses $db instead of $this->db just after.
+
+ require_once $filefound;
$obj = new $classname($this->db);
@@ -6818,15 +6832,23 @@ abstract class CommonObject
}
}
+ // $new_array_options will be used for direct update, so must contains formated data for the UPDATE.
+ $new_array_options = $this->array_options;
+
//dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG);
//dol_syslog("attributeType=".$attributeType, LOG_DEBUG);
if (!empty($attrfieldcomputed)) {
if (getDolGlobalString('MAIN_STORE_COMPUTED_EXTRAFIELDS')) {
$value = dol_eval($attrfieldcomputed, 1, 0, '2');
dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG);
- $this->array_options["options_".$key] = $value;
+
+ $new_array_options["options_".$key] = $value;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
} else {
- $this->array_options["options_".$key] = null;
+ $new_array_options["options_".$key] = null;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
}
}
@@ -6836,7 +6858,9 @@ abstract class CommonObject
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
} elseif ($value === '') {
- $this->array_options["options_".$key] = null;
+ $new_array_options["options_".$key] = null;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
}
break;
case 'double':
@@ -6849,19 +6873,24 @@ abstract class CommonObject
$value = null;
}
//dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG);
- $this->array_options["options_".$key] = $value;
+ $new_array_options["options_".$key] = $value;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
break;
/*case 'select': // Not required, we chosed value='0' for undefined values
if ($value=='-1')
{
- $this->array_options[$key] = null;
+ $new_array_options["options_".$key] = $value;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
}
break;*/
case 'price':
- $this->array_options["options_".$key] = price2num($this->array_options["options_".$key]);
+ $new_array_options["options_".$key] = price2num($this->array_options["options_".$key]);
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
break;
case 'password':
- $new_array_options = array();
$algo = '';
if ($this->array_options["options_".$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) {
// If there is an encryption choice, we use it to crypt data before insert
@@ -6915,26 +6944,34 @@ abstract class CommonObject
case 'date':
case 'datetime':
if (empty($this->array_options["options_".$key])) {
- $this->array_options["options_".$key] = null;
+ $new_array_options["options_".$key] = null;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
} else {
- $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]);
+ $new_array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]);
}
break;
case 'datetimegmt':
if (empty($this->array_options["options_".$key])) {
- $this->array_options["options_".$key] = null;
+ $new_array_options["options_".$key] = null;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
} else {
- $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key], 'gmt');
+ $new_array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key], 'gmt');
}
break;
case 'boolean':
if (empty($this->array_options["options_".$key])) {
- $this->array_options["options_".$key] = null;
+ $new_array_options["options_".$key] = null;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
}
break;
case 'link':
if ($this->array_options["options_".$key] === '') {
- $this->array_options["options_".$key] = null;
+ $new_array_options["options_".$key] = null;
+
+ $this->array_options["options_".$key] = $new_array_options["options_".$key];
}
break;
/*
@@ -6993,12 +7030,12 @@ abstract class CommonObject
}
}
- //var_dump('linealreadyfound='.$linealreadyfound.' sql='.$sql);
+ //var_dump('linealreadyfound='.$linealreadyfound.' sql='.$sql); exit;
if ($linealreadyfound) {
if ($this->array_options["options_".$key] === null) {
$sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = null";
} else {
- $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'";
+ $sql = "UPDATE ".$this->db->prefix().$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($new_array_options["options_".$key])."'";
}
$sql .= " WHERE fk_object = ".((int) $this->id);
@@ -7674,7 +7711,8 @@ abstract class CommonObject
}
}
- $out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, empty($val['disabled']) ? 0 : 1);
+ //$out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, (empty($val['disabled']) ? 0 : 1), '');
+ $out = $form->selectForForms($param_list_array[0], $keyprefix.$key.$keysuffix, $value, $showempty, '', '', $morecss, $moreparam, 0, (empty($val['disabled']) ? 0 : 1), '', $this->element.':'.$key.$keysuffix);
if (!empty($param_list_array[2])) { // If the entry into $fields is set, we must add a create button
if ((!GETPOSTISSET('backtopage') || strpos(GETPOST('backtopage'), $_SERVER['PHP_SELF']) === 0) // // To avoid to open several times the 'Plus' button (we accept only one level)
diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php
index e5f92cf14d2..dc5de2b9863 100644
--- a/htdocs/core/class/commonorder.class.php
+++ b/htdocs/core/class/commonorder.class.php
@@ -63,7 +63,7 @@ abstract class CommonOrder extends CommonObject
$return .= '