diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index cd2641ff6be..ab17d51de09 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2024 Alexandre Spangaro + * Copyright (C) 2016-2025 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * @@ -100,9 +100,14 @@ $formother = new FormOther($db); $form = new Form($db); if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; - $sql .= $db->plimit(1); + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } + $sql .= $db->plimit(1); $res = $db->query($sql); if ($db->num_rows($res) > 0) { diff --git a/htdocs/accountancy/bookkeeping/export.php b/htdocs/accountancy/bookkeeping/export.php index 67a6155ef7c..e866ea95980 100644 --- a/htdocs/accountancy/bookkeeping/export.php +++ b/htdocs/accountancy/bookkeeping/export.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2025 Alexandre Spangaro * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2024 Frédéric France @@ -170,9 +170,15 @@ $form = new Form($db); if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOSTINT('page') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { - $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; - $res = $db->query($query); + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } + $sql .= $db->plimit(1); + $res = $db->query($sql); if ($db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 1a39d3ec78d..67d62117ba2 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -177,9 +177,15 @@ $form = new Form($db); if (!in_array($action, array('delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'alpha') == '' && !GETPOSTINT('noreset') && $user->hasRight('accounting', 'mouvements', 'export')) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) { - $query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1"; - $res = $db->query($query); + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } + $sql .= $db->plimit(1); + $res = $db->query($sql); if ($db->num_rows($res) > 0) { $fiscalYear = $db->fetch_object($res); @@ -884,12 +890,6 @@ if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { } $moreforfilter = ''; -$moreforfilter = '
'; -$moreforfilter .= $langs->trans('FiscalYear').': '; -$moreforfilter .= '
'; -$moreforfilter .= $formfiscalyear->selectFiscalYear($fiscalYear, 'searchfiscalyear', $useempty, 0, 1); -$moreforfilter .= '
'; -$moreforfilter .= '
'; $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountingCategory').': '; $moreforfilter .= '
'; diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index ba17782a8b0..172249debb3 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Neil Orley * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2024 Alexandre Spangaro + * Copyright (C) 2013-2025 Alexandre Spangaro * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 MDW * @@ -152,8 +152,13 @@ $formaccounting = new FormAccounting($db); $form = new Form($db); if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) { - $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear "; - $sql .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."'"; + $sql = "SELECT date_start, date_end"; + $sql .=" FROM ".MAIN_DB_PREFIX."accounting_fiscalyear "; + if (getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT')) { + $sql .= " WHERE rowid = " . getDolGlobalInt('ACCOUNTANCY_FISCALYEAR_DEFAULT'); + } else { + $sql .= " WHERE date_start < '" . $db->idate(dol_now()) . "' and date_end > '" . $db->idate(dol_now()) . "'"; + } $sql .= $db->plimit(1); $res = $db->query($sql);