* Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2013-2017 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ /** * \file htdocs/accountancy/admin/defaultaccounts.php * \ingroup Advanced accountancy * \brief Setup page to configure accounting expert module */ require '../../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $langs->load("compta"); $langs->load("bills"); $langs->load("admin"); $langs->load("accountancy"); $langs->load("salaries"); $langs->load("loan"); // Security check if (empty($user->rights->accounting->chartofaccount)) { accessforbidden(); } $action = GETPOST('action', 'alpha'); $list_account_main = array ( 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); $list_account = array ( 'ACCOUNTING_PRODUCT_BUY_ACCOUNT', 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT', 'ACCOUNTING_SERVICE_BUY_ACCOUNT', 'ACCOUNTING_SERVICE_SOLD_ACCOUNT', 'ACCOUNTING_VAT_BUY_ACCOUNT', 'ACCOUNTING_VAT_SOLD_ACCOUNT', 'ACCOUNTING_VAT_PAY_ACCOUNT', 'ACCOUNTING_ACCOUNT_SUSPENSE', 'ACCOUNTING_ACCOUNT_TRANSFER_CASH', 'DONATION_ACCOUNTINGACCOUNT', 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL', 'LOAN_ACCOUNTING_ACCOUNT_INTEREST', 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE' ); /* * Actions */ $accounting_mode = defined('ACCOUNTING_MODE') ? ACCOUNTING_MODE : 'RECETTES-DEPENSES'; if (GETPOST('change_chart')) { $chartofaccounts = GETPOST('chartofaccounts', 'int'); if (! empty($chartofaccounts)) { if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error ++; } } else { $error ++; } } if ($action == 'update') { $error = 0; foreach ( $list_account_main as $constname ) { $constvalue = GETPOST($constname, 'alpha'); if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error ++; } } foreach ( $list_account as $constname ) { $constvalue = GETPOST($constname, 'alpha'); if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { $error ++; } } if (! $error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } } /* * View */ $form = new Form($db); $formaccounting = new FormAccounting($db); llxHeader(); $linkback = ''; print load_fiche_titre($langs->trans('MenuDefaultAccounts'), $linkback, 'title_accountancy'); print $langs->trans("DefaultBindingDesc").'
'; print '
'; print '
'; print ''; print ''; // Define main accounts for thirdparty print ''; foreach ($list_account_main as $key) { print ''; // Param $label = $langs->trans($key); $keydesc=$key.'_Desc'; $htmltext = $langs->trans($keydesc); print ''; // Value print ''; print ''; } print "
'; print $form->textwithpicto($label, $htmltext); print ''; // Do not force align=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
\n"; print '
'; // Define default accounts print ''; foreach ($list_account as $key) { print ''; // Param $label = $langs->trans($key); print ''; // Value print ''; print ''; } print "
' . $label . ''; // Do not force align=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
\n"; print '
'; print '
'; llxFooter(); $db->close();