diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index a4fe3df4034..98cb6d61efa 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -7207,7 +7207,7 @@ class Form
print '
'.$objp->ref.' | ';
print ''.(!empty($objp->ref_client) ? $objp->ref_client : $objp->ref_supplier).' | ';
print '';
- if ($possiblelink[label] == 'LinkToContract') {
+ if ($possiblelink['label'] == 'LinkToContract') {
$form = new Form($db);
print $form->textwithpicto('', $langs->trans("InformationOnLinkToContract")).' ';
}
diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php
index 20ffa3f52b6..789a84df04d 100644
--- a/htdocs/core/lib/accounting.lib.php
+++ b/htdocs/core/lib/accounting.lib.php
@@ -1,8 +1,8 @@
- * Copyright (C) 2013-2017 Alexandre Spangaro
- * Copyright (C) 2014 Florian Henry
- * Copyright (C) 2019 Eric Seigne
+/* Copyright (C) 2013-2014 Olivier Geffroy
+ * Copyright (C) 2013-2021 Alexandre Spangaro
+ * Copyright (C) 2014 Florian Henry
+ * Copyright (C) 2019 Eric Seigne
*
* 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
@@ -257,8 +257,8 @@ function getDefaultDatesForTransfer()
$periodbydefaultontransfer = $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER;
isset($periodbydefaultontransfer) ? $periodbydefaultontransfer : 0;
if ($periodbydefaultontransfer == 2) {
- $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 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);
$res = $db->query($sql);
if ($res->num_rows > 0) {
@@ -268,6 +268,9 @@ function getDefaultDatesForTransfer()
} else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
+ if ($conf->global->SOCIETE_FISCAL_MONTH_START > dol_print_date(dol_now(), '%m')) {
+ $year_start = $year_start - 1;
+ }
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
|