From 6a66fcbff85bea8058a2609a7a4d13f990afaf71 Mon Sep 17 00:00:00 2001
From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com>
Date: Thu, 30 Sep 2021 16:51:31 +0200
Subject: [PATCH 1/6] NEW: expense report: show link to already existing
overlapping expense report
---
htdocs/expensereport/card.php | 12 ++++++++----
htdocs/expensereport/class/expensereport.class.php | 13 ++++---------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index f982b046793..7f41245b4d8 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -266,10 +266,14 @@ if (empty($reshook)) {
}
}
- if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser, $object->date_debut, $object->date_fin)) {
- $error++;
- setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors');
- $action = 'create';
+ if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) {
+ $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin, true);
+
+ if ($overlappingExpenseReportID > 0) {
+ $error++;
+ setEventMessages($langs->trans("ErrorDoubleDeclaration").' '. $langs->trans('ShowTrip').'', null, 'errors');
+ $action = 'create';
+ }
}
if (!$error) {
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 63303554c51..8df8b356090 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -2195,9 +2195,10 @@ class ExpenseReport extends CommonObject
* @param User $fuser User
* @param integer $date_debut Start date
* @param integer $date_fin End date
+ * @param bool $return_id True to return ID of existing expense report
* @return int <0 if KO, >0 if OK
*/
- public function periode_existe($fuser, $date_debut, $date_fin)
+ public function periode_existe($fuser, $date_debut, $date_fin, $return_id = false)
{
// phpcs:enable
$sql = "SELECT rowid, date_debut, date_fin";
@@ -2213,8 +2214,6 @@ class ExpenseReport extends CommonObject
$date_d_form = $date_debut;
$date_f_form = $date_fin;
- $existe = false;
-
while ($i < $num_rows) {
$objp = $this->db->fetch_object($result);
@@ -2222,17 +2221,13 @@ class ExpenseReport extends CommonObject
$date_f_req = $this->db->jdate($objp->date_fin); // 4
if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) {
- $existe = true;
+ return $return_id ? $objp->rowid : 1;
}
$i++;
}
- if ($existe) {
- return 1;
- } else {
- return 0;
- }
+ return 0;
} else {
return 0;
}
From b1eb1c1070307b3454f9bbc76aee6c8734ea537f Mon Sep 17 00:00:00 2001
From: stepanych
Date: Sun, 3 Oct 2021 01:08:22 +0200
Subject: [PATCH 2/6] fix issue #18875
added check for $$search_array_options
---
htdocs/reception/list.php | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php
index b7f3f577ce2..f32e09aa580 100644
--- a/htdocs/reception/list.php
+++ b/htdocs/reception/list.php
@@ -618,11 +618,13 @@ if ($search_ref_supplier) {
$param .= "&search_ref_supplier=".urlencode($search_ref_supplier);
}
// Add $param from extra fields
-foreach ($search_array_options as $key => $val) {
- $crit = $val;
- $tmpkey = preg_replace('/search_options_/', '', $key);
- if ($val != '') {
- $param .= '&search_options_'.$tmpkey.'='.urlencode($val);
+if ($search_array_options) {
+ foreach ($search_array_options as $key => $val) {
+ $crit = $val;
+ $tmpkey = preg_replace('/search_options_/', '', $key);
+ if ($val != '') {
+ $param .= '&search_options_' . $tmpkey . '=' . urlencode($val);
+ }
}
}
From 042d52006150fe1e7b3ac7fa374d6dc22815fb47 Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO
Date: Sun, 3 Oct 2021 05:30:49 +0200
Subject: [PATCH 3/6] Change Url
---
htdocs/core/lib/company.lib.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 0adcb967991..3271d74a4dd 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -724,7 +724,7 @@ function getFormeJuridiqueLabel($code)
function getCountriesInEEC()
{
// List of all country codes that are in europe for european vat rules
- // List found on http://ec.europa.eu/taxation_customs/common/faq/faq_1179_en.htm#9
+ // List found on https://europa.eu/european-union/about-eu/countries_en
global $conf, $db;
$country_code_in_EEC = array();
From 94166cdb7e30398ab60093d71d0479a56a825582 Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO
Date: Sun, 3 Oct 2021 05:36:53 +0200
Subject: [PATCH 4/6] FIX Remove Isle of Man of ECC's countries
---
htdocs/install/mysql/data/llx_00_c_country.sql | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql
index 4465756f00a..7217fda7d09 100644
--- a/htdocs/install/mysql/data/llx_00_c_country.sql
+++ b/htdocs/install/mysql/data/llx_00_c_country.sql
@@ -279,5 +279,5 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24
-- Set field eec
-UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IM','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI');
+UPDATE llx_c_country SET eec = 1 WHERE code IN ('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','NL','HU','IE','IT','LT','LU','LV','MC','MT','PL','PT','RO','SE','SK','SI');
From 42bb9ac6d2a8da328560f88219735aed8994fde8 Mon Sep 17 00:00:00 2001
From: Alexandre SPANGARO
Date: Sun, 3 Oct 2021 05:49:54 +0200
Subject: [PATCH 5/6] Better URL
---
htdocs/core/lib/company.lib.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index 3271d74a4dd..efea4c54b09 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -724,7 +724,7 @@ function getFormeJuridiqueLabel($code)
function getCountriesInEEC()
{
// List of all country codes that are in europe for european vat rules
- // List found on https://europa.eu/european-union/about-eu/countries_en
+ // List found on https://ec.europa.eu/taxation_customs/territorial-status-eu-countries-and-certain-territories_en
global $conf, $db;
$country_code_in_EEC = array();
From 704bae46a6672aa7a50260e6a6c0ca4df1ff745a Mon Sep 17 00:00:00 2001
From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com>
Date: Mon, 4 Oct 2021 08:51:31 +0200
Subject: [PATCH 6/6] FIX: expense report: show link to already existing
overlapping expense report without adding new parameter
---
htdocs/expensereport/class/expensereport.class.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index 8df8b356090..64034c10a3f 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -2195,10 +2195,9 @@ class ExpenseReport extends CommonObject
* @param User $fuser User
* @param integer $date_debut Start date
* @param integer $date_fin End date
- * @param bool $return_id True to return ID of existing expense report
* @return int <0 if KO, >0 if OK
*/
- public function periode_existe($fuser, $date_debut, $date_fin, $return_id = false)
+ public function periode_existe($fuser, $date_debut, $date_fin)
{
// phpcs:enable
$sql = "SELECT rowid, date_debut, date_fin";
@@ -2221,7 +2220,7 @@ class ExpenseReport extends CommonObject
$date_f_req = $this->db->jdate($objp->date_fin); // 4
if (!($date_f_form < $date_d_req || $date_d_form > $date_f_req)) {
- return $return_id ? $objp->rowid : 1;
+ return $objp->rowid;
}
$i++;