Merge pull request #6101 from atm-florian/dev_accoutnacy
fix default account selection (when cache is use)
This commit is contained in:
commit
3b193e2e22
@ -30,10 +30,10 @@
|
|||||||
*/
|
*/
|
||||||
class FormVentilation extends Form
|
class FormVentilation extends Form
|
||||||
{
|
{
|
||||||
|
|
||||||
private $options_cache = array();
|
private $options_cache = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return select filter with date of transaction
|
* Return select filter with date of transaction
|
||||||
*
|
*
|
||||||
@ -87,21 +87,22 @@ class FormVentilation extends Form
|
|||||||
if ($usecache && ! empty($this->options_cache[$usecache]))
|
if ($usecache && ! empty($this->options_cache[$usecache]))
|
||||||
{
|
{
|
||||||
$options = $this->options_cache[$usecache];
|
$options = $this->options_cache[$usecache];
|
||||||
|
$selected=$selectid;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
$trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50;
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
|
$sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version";
|
||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
|
||||||
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
|
||||||
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
$sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS;
|
||||||
$sql .= " AND aa.active = 1";
|
$sql .= " AND aa.active = 1";
|
||||||
$sql .= " ORDER BY aa.account_number";
|
$sql .= " ORDER BY aa.account_number";
|
||||||
|
|
||||||
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
dol_syslog(get_class($this) . "::select_account", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$this->error = "Error " . $this->db->lasterror();
|
$this->error = "Error " . $this->db->lasterror();
|
||||||
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
|
dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR);
|
||||||
@ -109,16 +110,16 @@ class FormVentilation extends Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
$out = ajax_combobox($htmlname, $event);
|
$out = ajax_combobox($htmlname, $event);
|
||||||
|
|
||||||
$selected = 0;
|
$selected = 0;
|
||||||
while ($obj = $this->db->fetch_object($resql))
|
while ($obj = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
$label = length_accountg($obj->account_number) . ' - ' . $obj->label;
|
||||||
$label = dol_trunc($label, $trunclength);
|
$label = dol_trunc($label, $trunclength);
|
||||||
|
|
||||||
$select_value_in = $obj->rowid;
|
$select_value_in = $obj->rowid;
|
||||||
$select_value_out = $obj->rowid;
|
$select_value_out = $obj->rowid;
|
||||||
|
|
||||||
// Try to guess if we have found default value
|
// Try to guess if we have found default value
|
||||||
if ($select_in == 1) {
|
if ($select_in == 1) {
|
||||||
$select_value_in = $obj->account_number;
|
$select_value_in = $obj->account_number;
|
||||||
@ -132,19 +133,19 @@ class FormVentilation extends Form
|
|||||||
//var_dump("Found ".$selectid." ".$select_value_in);
|
//var_dump("Found ".$selectid." ".$select_value_in);
|
||||||
$selected = $select_value_out;
|
$selected = $select_value_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
$options[$select_value_out] = $label;
|
$options[$select_value_out] = $label;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
if ($usecache)
|
if ($usecache)
|
||||||
{
|
{
|
||||||
$this->options_cache[$usecache] = $options;
|
$this->options_cache[$usecache] = $options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
|
$out .= Form::selectarray($htmlname, $options, $selected, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1);
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +304,7 @@ class FormVentilation extends Form
|
|||||||
function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
|
function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$out_array = array();
|
$out_array = array();
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
|
$sql = "SELECT DISTINCT date_format(doc_date,'%Y') as dtyear";
|
||||||
@ -342,7 +343,7 @@ class FormVentilation extends Form
|
|||||||
function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
|
function selectjournal_accountancy_bookkepping($selected = '', $htmlname = 'journalid', $useempty = 0, $output_format = 'html')
|
||||||
{
|
{
|
||||||
global $conf,$langs;
|
global $conf,$langs;
|
||||||
|
|
||||||
$out_array = array();
|
$out_array = array();
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT code_journal";
|
$sql = "SELECT DISTINCT code_journal";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user