diff --git a/ChangeLog b/ChangeLog index aa82859a5b8..9653e4577cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ Following changes may create regressions for some external modules, but were nec * Rename property $paiementid in API api_supplier_invoices into $payment_mode_id * The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you still use old syntax in your email templates. +* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom + days of holiday. ***** ChangeLog for 12.0.2 compared to 12.0.1 ***** FIX: computation of the bottom margin of returns NaN because body is not loaded yet diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index ebdc1f7ed59..840cf4d2681 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -35,13 +35,11 @@ $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); if (!$user->admin) accessforbidden(); -//Init error -$error = false; -$message = false; +$error = 0; $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); -$offset = GETPOST('offset', 'int'); +$ikoffset = GETPOST('ikoffset', 'int'); $coef = GETPOST('coef', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); @@ -59,10 +57,13 @@ if ($action == 'updateik') $expIk->setValues($_POST); $result = $expIk->create($user); - if ($result > 0) setEventMessages('SetupSaved', null, 'mesgs'); - - header('Location: '.$_SERVER['PHP_SELF']); - exit; + if ($result > 0) { + setEventMessages('SetupSaved', null, 'mesgs'); + header('Location: '.$_SERVER['PHP_SELF']); + exit; + } else { + setEventMessages($expIk->error, $expIk->errors, 'errors'); + } } elseif ($action == 'delete') // TODO add confirm { $expIk = new ExpenseReportIk($db); @@ -81,6 +82,7 @@ if ($action == 'updateik') $rangesbycateg = ExpenseReportIk::getAllRanges(); + /* * View */ @@ -90,12 +92,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ExpenseReportsIkSetup"), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenseik', $langs->trans("ExpenseReportsIk"), -1, 'trip'); -echo $langs->trans('ExpenseReportIkDesc'); +echo ''.$langs->trans('ExpenseReportIkDesc').''; +print '

'; echo '
'; @@ -136,21 +139,23 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; // Label - echo '['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; + echo '['.$langs->trans('RangeNum', $tranche++).'] - '.$label.''; // Offset - echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; - else echo $range->ik->offset; + echo ''; + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; + else { + echo $range->ik->ikoffset; + } echo ''; // Coef - echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; + echo ''; + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); echo ''; // Total for one - echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->offset + 5 * $range->ik->coef)).''; + echo ''.$langs->trans('expenseReportPrintExample', price($range->ik->ikoffset + 5 * $range->ik->coef)).''; // Action echo ''; @@ -161,8 +166,8 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; echo ''; } else { - echo ''.img_edit().''; - if (!empty($range->ik->id)) echo ''.img_delete().''; + echo ''.img_edit().''; + if (!empty($range->ik->id)) echo ''.img_delete().''; // TODO add delete link } } diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 337311b85e7..28d5b3341b1 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -138,6 +138,7 @@ $rules = ExpenseReportRule::getAllRule(); $tab_apply = array('A' => $langs->trans('All'), 'G' => $langs->trans('Group'), 'U' => $langs->trans('User')); $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->trans('Month'), 'EX_YEA' => $langs->trans('Year'), 'EX_EXP' => $langs->trans('OnExpense')); + /* * View */ @@ -147,12 +148,13 @@ llxHeader('', $langs->trans("ExpenseReportsSetup")); $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup'); +print load_fiche_titre($langs->trans("ExpenseReportsSetup"), $linkback, 'title_setup'); $head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip'); -echo $langs->trans('ExpenseReportRulesDesc'); +echo ''.$langs->trans('ExpenseReportRulesDesc').''; +print '

'; if ($action != 'edit') { @@ -164,7 +166,7 @@ if ($action != 'edit') echo ''; echo ''.$langs->trans('ExpenseReportApplyTo').''; - echo ''.$langs->trans('ExpenseReportDomain').''; + echo ''.$langs->trans('Type').''; echo ''.$langs->trans('ExpenseReportLimitOn').''; echo ''.$langs->trans('ExpenseReportDateStart').''; echo ''.$langs->trans('ExpenseReportDateEnd').''; @@ -184,7 +186,7 @@ if ($action != 'edit') echo ''.$form->selectarray('code_expense_rules_type', $tab_rules_type, '', 0).''; echo ''.$form->selectDate(strtotime(date('Y-m-01', dol_now())), 'start', '', '', 0, '', 1, 0).''; echo ''.$form->selectDate(strtotime(date('Y-m-t', dol_now())), 'end', '', '', 0, '', 1, 0).''; - echo ''.$conf->currency.''; + echo ' '.$conf->currency.''; echo ''.$form->selectyesno('restrictive', 0, 1).''; echo ''; echo ''; @@ -207,7 +209,7 @@ echo ''; echo ''; echo ''; -echo ''; +echo ''; echo ''; echo ''; echo ''; @@ -300,11 +302,11 @@ foreach ($rules as $rule) echo ''; - echo ''; } - 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 ''; print ''; if (!empty($conf->projet->enabled)) print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; print ''; print ''; print ''; @@ -2080,6 +2080,13 @@ if ($action == 'create') } print ''; } + + // Type of fee + 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 ''; + // Comment print ''; // VAT rate @@ -2285,6 +2288,11 @@ if ($action == 'create') print ''; } + // Select type + print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; } - // Select type - print ''; - // Add comments print ''; print ''; print ''; - if (!empty($conf->projet->enabled)) print ''; - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; + if (!empty($conf->projet->enabled)) { + print ''; + } print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { + print ''; + } print ''; print ''; print ''; @@ -2440,19 +2447,19 @@ if ($action == 'create') print ''; } - if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) - { - print ''; - } - // Select type print ''; + if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) + { + print ''; + } + // Add comments print '
'.$langs->trans('ExpenseReportApplyTo').''.$langs->trans('ExpenseReportDomain').''.$langs->trans('Type').''.$langs->trans('ExpenseReportLimitOn').''.$langs->trans('ExpenseReportDateStart').''.$langs->trans('ExpenseReportDateEnd').''; + 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 .= ''; } $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 '
'.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''; + $labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code)); + print $labeltype; + 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 ''.dol_nl2br($line->comments).''; + select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); + print ''; @@ -2293,11 +2301,6 @@ if ($action == 'create') print ''; - select_type_fees_id($line->fk_c_type_fees, 'fk_c_type_fees'); - 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 '
'.$langs->trans('Date').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('CarCategory').''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).''.$langs->trans('Type').''.$langs->trans('CarCategory').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''; - $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_fees_id($fk_c_type_fees, 'fk_c_type_fees', 1); 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 ''; 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) } /**