Skip to content

Commit

Permalink
NEW Chart of account is loaded when selected into accounting setup
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 23, 2017
1 parent e0c9c00 commit 28ae602
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions htdocs/accountancy/admin/account.php
Expand Up @@ -105,14 +105,32 @@
$search_array_options=array();
}

if (GETPOST('change_chart'))
if (GETPOST('change_chart','alpha'))
{
$chartofaccounts = GETPOST('chartofaccounts', 'int');

if (! empty($chartofaccounts)) {
if ($chartofaccounts > 0)
{
// Get language code for this $chartofaccounts
$sql ='SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
$sql.=' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
$country_code = $obj->code;
}
else dol_print_error($db);

// Try to load sql file
if ($country_code)
{
$sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql';
$result = run_sql($sqlfile, 1, 0, 1);
}

if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error ++;
$error++;
}
} else {
$error ++;
Expand Down

0 comments on commit 28ae602

Please sign in to comment.