From 290a6c3d58c4080a438c1bdcf406e9b144eeb46c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Nov 2021 03:34:50 +0100 Subject: [PATCH] Prepare code to allow to filter autolink on month/year --- htdocs/accountancy/customer/index.php | 6 ++++++ htdocs/accountancy/expensereport/index.php | 9 +++++++++ htdocs/accountancy/supplier/index.php | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index d0d0a29bbef..f54c81477aa 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -36,6 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "accountancy")); +$validatemonth = GETPOST('validatemonth', 'int'); +$validateyear = GETPOST('validateyear', 'int'); + // Security check if (empty($conf->accounting->enabled)) { accessforbidden(); @@ -174,6 +177,9 @@ if ($action == 'validatehistory') { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } + if ($validatemonth && $validateyear) { + $sql .= dolSqlDateFilter('f.datef', 0, $validatemonth, $validateyear); + } dol_syslog('htdocs/accountancy/customer/index.php'); diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 13582474716..e9efb5f23b3 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -32,6 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "accountancy")); +$validatemonth = GETPOST('validatemonth', 'int'); +$validateyear = GETPOST('validateyear', 'int'); + $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1); if (GETPOST("year", 'int')) { $year_start = GETPOST("year", 'int'); @@ -106,12 +109,18 @@ if ($action == 'validatehistory') { $sql1 .= " WHERE ".MAIN_DB_PREFIX."expensereport_det.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); $sql1 .= " AND accnt.active = 1 AND t.accountancy_code = accnt.account_number"; $sql1 .= " AND ".MAIN_DB_PREFIX."expensereport_det.fk_code_ventilation = 0"; + if ($validatemonth && $validateyear) { + $sql1 .= dolSqlDateFilter('date', 0, $validatemonth, $validateyear); + } } else { $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd, ".MAIN_DB_PREFIX."c_type_fees as t, ".MAIN_DB_PREFIX."accounting_account as accnt , ".MAIN_DB_PREFIX."accounting_system as syst"; $sql1 .= " SET erd.fk_code_ventilation = accnt.rowid"; $sql1 .= " WHERE erd.fk_c_type_fees = t.id AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); $sql1 .= " AND accnt.active = 1 AND t.accountancy_code=accnt.account_number"; $sql1 .= " AND erd.fk_code_ventilation = 0"; + if ($validatemonth && $validateyear) { + $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear); + } } dol_syslog('htdocs/accountancy/expensereport/index.php'); diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 7212568f42a..55dcec12989 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -34,6 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "other", "accountancy")); +$validatemonth = GETPOST('validatemonth', 'int'); +$validateyear = GETPOST('validateyear', 'int'); + // Security check if (empty($conf->accounting->enabled)) { accessforbidden(); @@ -172,6 +175,9 @@ if ($action == 'validatehistory') { if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND f.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'"; } + if ($validatemonth && $validateyear) { + $sql .= dolSqlDateFilter('f.datef', 0, $validatemonth, $validateyear); + } dol_syslog('htdocs/accountancy/supplier/index.php');