';
echo ''.$langs->trans('ExpenseReportApplyTo').' ';
-echo ''.$langs->trans('ExpenseReportDomain').' ';
+echo ''.$langs->trans('Type').' ';
echo ''.$langs->trans('ExpenseReportLimitOn').' ';
echo ''.$langs->trans('ExpenseReportDateStart').' ';
echo ''.$langs->trans('ExpenseReportDateEnd').' ';
@@ -300,11 +302,11 @@ foreach ($rules as $rule)
echo '';
- echo '';
+ echo ' ';
if ($object->id != $rule->id)
{
- echo ''.img_edit().' ';
- echo ''.img_delete().' ';
+ echo ''.img_edit().' ';
+ echo ''.img_delete().' ';
} else {
echo ' ';
echo ''.$langs->trans('Cancel').' ';
diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php
index caaeb706c32..42691f14307 100644
--- a/htdocs/core/class/coreobject.class.php
+++ b/htdocs/core/class/coreobject.class.php
@@ -269,10 +269,10 @@ class CoreObject extends CommonObject
/**
* Function to create object in database
*
- * @param User $user user object
+ * @param User $user User object
* @return int < 0 if KO, > 0 if OK
*/
- public function create(User &$user)
+ public function create(User $user)
{
if ($this->id > 0) return $this->update($user);
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index c6ebb7511bb..80752a2090a 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7606,9 +7606,10 @@ class Form
* @param string $target htmlname of target select to bind event
* @param int $default_selected default category to select if fk_c_type_fees change = EX_KME
* @param array $params param to give
+ * @param int $info_admin Show the tooltip help picto to setup list
* @return string
*/
- public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array())
+ public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array(), $info_admin = 1)
{
global $db, $conf, $langs, $user;
@@ -7629,7 +7630,9 @@ class Form
$out .= 'rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.$langs->trans($obj->label).' ';
}
$out .= '';
- if (!empty($htmlname) && $user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
+ $out .= ajax_combobox('select_'.$htmlname);
+
+ if (!empty($htmlname) && $user->admin && $info_admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if (!empty($target))
{
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 1c7ff2cf20e..30fd6d29a1d 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -615,23 +615,6 @@ function num_public_holiday($timestampStart, $timestampEnd, $country_code = '',
$mois = date("m", $timestampStart);
$annee = date("Y", $timestampStart);
- // Check into var $conf->global->HOLIDAY_MORE_DAYS MM-DD,YYYY-MM-DD, ...
- // Do not use this anymore, use instead the dictionary of public holidays.
- if (!empty($conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS))
- {
- $arrayofdaystring = explode(',', $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS);
- foreach ($arrayofdaystring as $daystring)
- {
- $tmp = explode('-', $daystring);
- if ($tmp[2])
- {
- if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) $ferie = true;
- } else {
- if ($tmp[0] == $mois && $tmp[1] == $jour) $ferie = true;
- }
- }
- }
-
$country_id = dol_getIdFromCode($db, $country_code, 'c_country', 'code', 'rowid');
// Loop on public holiday defined into hrm_public_holiday
diff --git a/htdocs/core/lib/expensereport.lib.php b/htdocs/core/lib/expensereport.lib.php
index 4c54ca09e31..c4e68356349 100644
--- a/htdocs/core/lib/expensereport.lib.php
+++ b/htdocs/core/lib/expensereport.lib.php
@@ -133,14 +133,6 @@ function expensereport_admin_prepare_head()
$head[$h][2] = 'expensereport';
$h++;
- if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
- {
- $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
- $head[$h][1] = $langs->trans("ExpenseReportsIk");
- $head[$h][2] = 'expenseik';
- $h++;
- }
-
if (!empty($conf->global->MAIN_USE_EXPENSE_RULE))
{
$head[$h][0] = DOL_URL_ROOT."/admin/expensereport_rules.php";
@@ -149,6 +141,14 @@ function expensereport_admin_prepare_head()
$h++;
}
+ if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
+ {
+ $head[$h][0] = DOL_URL_ROOT."/admin/expensereport_ik.php";
+ $head[$h][1] = $langs->trans("ExpenseReportsIk");
+ $head[$h][2] = 'expenseik';
+ $h++;
+ }
+
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index d4f09f793bc..59584562dff 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2019 Laurent Destailleur
+ * Copyright (C) 2004-2020 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2015-2017 Alexandre Spangaro
* Copyright (C) 2017 Ferran Marcet
@@ -1835,7 +1835,7 @@ if ($action == 'create')
print ' ';
}
- if ($object->fk_statut == 6)
+ if ($object->fk_statut == $object::STATUS_CLOSED)
{
/* TODO this fields are not yet filled
print '';
@@ -2029,8 +2029,8 @@ if ($action == 'create')
//print ''.$langs->trans('Piece').' ';
print ''.$langs->trans('Date').' ';
if (!empty($conf->projet->enabled)) print ''.$langs->trans('Project').' ';
- if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''.$langs->trans('CarCategory').' ';
print ''.$langs->trans('Type').' ';
+ if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''.$langs->trans('CarCategory').' ';
print ''.$langs->trans('Description').' ';
print ''.$langs->trans('VAT').' ';
print ''.$langs->trans('PriceUHT').' ';
@@ -2080,6 +2080,13 @@ if ($action == 'create')
}
print '';
}
+
+ // Type of fee
+ print '';
+ $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
+ print $labeltype;
+ print ' ';
+
// IK
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
{
@@ -2087,11 +2094,7 @@ if ($action == 'create')
print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
print '';
}
- // Type of fee
- print '';
- $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
- print $labeltype;
- print ' ';
+
// Comment
print ''.dol_nl2br($line->comments).' ';
// VAT rate
@@ -2285,6 +2288,11 @@ if ($action == 'create')
print '';
}
+ // Select type
+ print '';
+ select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees');
+ print ' ';
+
if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
{
print '';
@@ -2293,11 +2301,6 @@ if ($action == 'create')
print ' ';
}
- // Select type
- print '';
- select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees');
- print ' ';
-
// Add comments
print '';
print '';
@@ -2344,7 +2347,7 @@ if ($action == 'create')
}
}
- // Add a line
+ // Add a new line
if (($object->fk_statut == ExpenseReport::STATUS_DRAFT || $object->fk_statut == ExpenseReport::STATUS_REFUSED)
&& $action != 'editline'
&& $user->rights->expensereport->creer)
@@ -2408,9 +2411,13 @@ if ($action == 'create')
print ' ';
print ' ';
print ''.$langs->trans('Date').' ';
- if (!empty($conf->projet->enabled)) print ''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).' ';
- if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''.$langs->trans('CarCategory').' ';
+ if (!empty($conf->projet->enabled)) {
+ print ''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).' ';
+ }
print ''.$langs->trans('Type').' ';
+ if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
+ print ''.$langs->trans('CarCategory').' ';
+ }
print ''.$langs->trans('Description').' ';
print ''.$langs->trans('VAT').' ';
print ''.$langs->trans('PriceUHT').' ';
@@ -2440,19 +2447,19 @@ if ($action == 'create')
print '';
}
- if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
- {
- print '';
- $params = array('fk_expense' => $object->id);
- print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params);
- print ' ';
- }
-
// Select type
print '';
select_type_fees_id($fk_c_type_fees, 'fk_c_type_fees', 1);
print ' ';
+ if (!empty($conf->global->MAIN_USE_EXPENSE_IK))
+ {
+ print '';
+ $params = array('fk_expense' => $object->id);
+ print $form->selectExpenseCategories('', 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params, 0);
+ print ' ';
+ }
+
// Add comments
print '';
print '';
diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
index a3c0b78510c..defe5736aa8 100644
--- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
+++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql
@@ -318,3 +318,5 @@ ALTER TABLE llx_facturedet ADD COLUMN ref_ext varchar(255) AFTER multicurrency_t
ALTER TABLE llx_c_ticket_category ADD COLUMN fk_parent integer DEFAULT 0 NOT NULL;
ALTER TABLE llx_c_ticket_category ADD COLUMN force_severity varchar(32) NULL;
+ALTER TABLE llx_expensereport_ik ADD COLUMN ikoffset double DEFAULT 0 NOT NULL;
+
diff --git a/htdocs/install/mysql/tables/llx_expensereport_ik.sql b/htdocs/install/mysql/tables/llx_expensereport_ik.sql
index 3e767a8c396..ddc7fa4d3c7 100644
--- a/htdocs/install/mysql/tables/llx_expensereport_ik.sql
+++ b/htdocs/install/mysql/tables/llx_expensereport_ik.sql
@@ -25,6 +25,6 @@ CREATE TABLE IF NOT EXISTS llx_expensereport_ik (
fk_c_exp_tax_cat integer DEFAULT 0 NOT NULL,
fk_range integer DEFAULT 0 NOT NULL,
coef double DEFAULT 0 NOT NULL,
- ikoffset double DEFAULT 0 NOT NULL,
+ ikoffset double DEFAULT 0 NOT NULL,
active integer DEFAULT 1
)ENGINE=innodb;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 15627a7e88b..0a91a481ac3 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1794,7 +1794,6 @@ TypePaymentDesc=0:Customer payment type, 1:Vendor payment type, 2:Both customers
IncludePath=Include path (defined into variable %s)
ExpenseReportsSetup=Setup of module Expense Reports
TemplatePDFExpenseReports=Document templates to generate expense report document
-ExpenseReportsIkSetup=Setup of module Expense Reports - Milles index
ExpenseReportsRulesSetup=Setup of module Expense Reports - Rules
ExpenseReportNumberingModules=Expense reports numbering module
NoModueToManageStockIncrease=No module able to manage automatic stock increase has been activated. Stock increase will be done on manual input only.
diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang
index 654f14d6bf7..d0fc0126f2c 100644
--- a/htdocs/langs/en_US/trips.lang
+++ b/htdocs/langs/en_US/trips.lang
@@ -110,7 +110,7 @@ ExpenseReportPayment=Expense report payment
ExpenseReportsToApprove=Expense reports to approve
ExpenseReportsToPay=Expense reports to pay
ConfirmCloneExpenseReport=Are you sure you want to clone this expense report ?
-ExpenseReportsIk=Expense report milles index
+ExpenseReportsIk=Configuration of mileage charges
ExpenseReportsRules=Expense report rules
ExpenseReportIkDesc=You can modify the calculation of kilometers expense by category and range who they are previously defined. d is the distance in kilometers
ExpenseReportRulesDesc=You can create or update any rules of calculation. This part will be used when user will create a new expense report
diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php
index 062bdb6dd11..2d5598f49b3 100644
--- a/test/phpunit/DateLibTest.php
+++ b/test/phpunit/DateLibTest.php
@@ -242,29 +242,6 @@ class DateLibTest extends PHPUnit\Framework\TestCase
$result=num_public_holiday($date1, $date2, 'XX', 1);
print __METHOD__." result=".$result."\n";
$this->assertEquals(2, $result, 'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown)
-
-
-
- // Add more holiday with constant HOLIDAY_MORE_PUBLIC_HOLIDAYS
- $conf->global->HOLIDAY_MORE_PUBLIC_HOLIDAYS='12-13,2019-12-14';
-
- $date1=dol_mktime(0, 0, 0, 12, 13, 2018);
- $date2=dol_mktime(0, 0, 0, 12, 13, 2018);
- $result=num_public_holiday($date1, $date2, 'YY', 1);
- print __METHOD__." result=".$result."\n";
- $this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2018-12-13'); // 0 opened day, 1 closed days (even if country unknown)
-
- $date1=dol_mktime(0, 0, 0, 12, 14, 2018);
- $date2=dol_mktime(0, 0, 0, 12, 14, 2018);
- $result=num_public_holiday($date1, $date2, 'YY', 1);
- print __METHOD__." result=".$result."\n";
- $this->assertEquals(0, $result, 'NumPublicHoliday for YY the 2018-12-14'); // 1 opened day, 0 closed days (even if country unknown)
-
- $date1=dol_mktime(0, 0, 0, 12, 14, 2019);
- $date2=dol_mktime(0, 0, 0, 12, 14, 2019);
- $result=num_public_holiday($date1, $date2, 'YY', 1);
- print __METHOD__." result=".$result."\n";
- $this->assertEquals(1, $result, 'NumPublicHoliday for YY the 2019-12-14'); // 0 opened day, 1 closed days (even if country unknown)
}
/**