Merge pull request #15328 from FHenry/dev_multifilter_jounal_on_bookeping

Dev multifilter jounal on bookeping
This commit is contained in:
Laurent Destailleur 2020-12-30 13:19:27 +01:00 committed by GitHub
commit 92a88441ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 94 additions and 7 deletions

View File

@ -48,6 +48,7 @@ $action = GETPOST('action', 'aZ09');
$list = array(
'ACCOUNTING_LENGTH_GACCOUNT',
'ACCOUNTING_LENGTH_AACCOUNT',
// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated.
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
);

View File

@ -85,7 +85,7 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
$search_direction = GETPOST('search_direction', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'array');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
@ -192,7 +192,7 @@ if (empty($reshook))
$search_accountancy_aux_code_end = '';
$search_mvt_label = '';
$search_direction = '';
$search_ledger_code = '';
$search_ledger_code = array();
$search_date_start = '';
$search_date_end = '';
$search_date_creation_start = '';
@ -267,7 +267,9 @@ if (empty($reshook))
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
foreach ($search_ledger_code as $code) {
$param .= '&search_ledger_code[]='.urlencode($code);
}
}
if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
@ -447,6 +449,8 @@ if (count($filter) > 0) {
$sqlwhere[] = natural_search($key, $value, 1, 1);
} elseif ($key == 't.reconciled_option') {
$sqlwhere[] = 't.lettering_code IS NULL';
} elseif ($key == 't.code_journal' && !empty($value)) {
$sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
} else {
$sqlwhere[] = natural_search($key, $value, 0, 1);
}
@ -780,7 +784,9 @@ if (!empty($arrayfields['t.lettering_code']['checked']))
// Code journal
if (!empty($arrayfields['t.code_journal']['checked']))
{
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.$search_ledger_code.'"></td>';
print '<td class="liste_titre center">';
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
print '</td>';
}
// Fields from hook

View File

@ -59,7 +59,7 @@ class FormAccounting extends Form
/**
* Return list of journals with label by nature
*
* @param string $selectid Preselected pcg_type
* @param string $selectid Preselected journal code
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
@ -136,6 +136,86 @@ class FormAccounting extends Form
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of journals with label by nature
*
* @param array $selectedIds Preselected journal code array
* @param string $htmlname Name of field in html form
* @param int $nature Limit the list to a particular type of journals (1:various operations / 2:sale / 3:purchase / 4:bank / 9: has-new)
* @param int $showempty Add an empty field
* @param int $select_in 0=selectid value is the journal rowid (default) or 1=selectid is journal code
* @param int $select_out Set value returned by select. 0=rowid (default), 1=code
* @param string $morecss More css non HTML object
* @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache.
* @param int $disabledajaxcombo Disable ajax combo box.
* @return string String with HTML select
*/
public function multi_select_journal($selectedIds = array(), $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = '', $usecache = '', $disabledajaxcombo = 0)
{
// phpcs:enable
global $conf, $langs;
$out = '';
$options = array();
if ($usecache && !empty($this->options_cache[$usecache]))
{
$options = $this->options_cache[$usecache];
$selected = $selectedIds;
} else {
$sql = "SELECT rowid, code, label, nature, entity, active";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_journal";
$sql .= " WHERE active = 1";
$sql .= " AND entity = ".$conf->entity;
if ($nature && is_numeric($nature)) $sql .= " AND nature = ".$nature;
$sql .= " ORDER BY code";
dol_syslog(get_class($this)."::multi_select_journal", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::multi_select_journal ".$this->error, LOG_ERR);
return -1;
}
$selected = array();
$langs->load('accountancy');
while ($obj = $this->db->fetch_object($resql))
{
$label = $langs->trans($obj->label);
$select_value_in = $obj->rowid;
$select_value_out = $obj->rowid;
// Try to guess if we have found default value
if ($select_in == 1) {
$select_value_in = $obj->code;
}
if ($select_out == 1) {
$select_value_out = $obj->code;
}
// Remember guy's we store in database llx_accounting_bookkeeping the code of accounting_journal and not the rowid
if (!empty($selectedIds) && in_array($select_value_in, $selectedIds)) {
//var_dump("Found ".$selectid." ".$select_value_in);
$selected[] = $select_value_out;
}
$options[$select_value_out] = $label;
}
$this->db->free($resql);
if ($usecache)
{
$this->options_cache[$usecache] = $options;
}
}
$out .= Form::multiselectarray($htmlname, $options, $selected, $showempty, 0, $morecss, 0, 0, 0, 'code_journal', '', ($disabledajaxcombo ? 0 : 1));
return $out;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of accounting category.

View File

@ -145,7 +145,7 @@ NotVentilatedinAccount=Not bound to the accounting account
XLineSuccessfullyBinded=%s products/services successfully bound to an accounting account
XLineFailedToBeBinded=%s products/services were not bound to any accounting account
ACCOUNTING_LIMIT_LIST_VENTILATION=Number of elements to bind shown by page (maximum recommended: 50)
ACCOUNTING_LIMIT_LIST_VENTILATION=Maximum number of lines on list and bind page (recommended: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Begin the sorting of the page "Binding to do" by the most recent elements
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Begin the sorting of the page "Binding done" by the most recent elements

View File

@ -144,7 +144,7 @@ NotVentilatedinAccount=Non lié au compte comptable
XLineSuccessfullyBinded=%s produits/service correctement liés à un compte comptable
XLineFailedToBeBinded=%s produits/services n'ont pu être liés à un compte comptable
ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre d'éléments à lier représentés par page (maximum recommandé: 50)
ACCOUNTING_LIMIT_LIST_VENTILATION=Nombre de ligne des listes et d'éléments à lier représentés par page (maximum recommandé: 50)
ACCOUNTING_LIST_SORT_VENTILATION_TODO=Commencez le tri de la page "Lien à réaliser" par les éléments les plus récents
ACCOUNTING_LIST_SORT_VENTILATION_DONE=Commencez le tri de la page "Liens réalisés" par les éléments les plus récents