diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index e03790a8995..9a044ed42c2 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-2020 Alexandre Spangaro + * Copyright (C) 2016-2021 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -30,6 +30,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; @@ -60,7 +61,7 @@ $pagenext = $page + 1; $show_subgroup = GETPOST('show_subgroup', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); - +$search_ledger_code = GETPOST('search_ledger_code', 'array'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -134,6 +135,12 @@ if (!empty($search_accountancy_code_end)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; $param .= '&search_accountancy_code_end='.$search_accountancy_code_end; } +if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]='.urlencode($code); + } +} if (empty($conf->accounting->enabled)) { accessforbidden(); @@ -157,6 +164,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_end = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; + $search_ledger_code = array(); $filter = array(); } @@ -265,6 +273,13 @@ if ($action != 'export_csv') { print ''; + print ''; + print ''; + print ''; + print ''; print '
'; + print $langs->trans('Journals'); + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + print '
'; print $langs->trans('From'); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index a93b36cf2b4..06ff8d9cb8c 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1103,7 +1103,8 @@ class BookKeeping extends CommonObject $sql = 'SELECT'; $sql .= " t.numero_compte,"; $sql .= " SUM(t.debit) as debit,"; - $sql .= " SUM(t.credit) as credit"; + $sql .= " SUM(t.credit) as credit,"; + $sql .= " t.code_journal"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -1121,6 +1122,12 @@ class BookKeeping extends CommonObject $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; } elseif ($key == 't.subledger_label') { $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + } elseif ($key == 't.code_journal' && !empty($value)) { + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; }