30require 
'../../main.inc.php';
 
   33require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
 
   34require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
 
   35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
 
   38$langs->loadLangs(array(
"compta", 
"bills", 
"admin", 
"accountancy", 
"salaries", 
"loan"));
 
   41if (!$user->hasRight(
'accounting', 
'chartofaccount')) {
 
   45$action = 
GETPOST(
'action', 
'aZ09');
 
   48$list_account_main = array(
 
   49  'ACCOUNTING_ACCOUNT_CUSTOMER',
 
   50  'ACCOUNTING_ACCOUNT_SUPPLIER',
 
   51  'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
 
   54$list_account = array();
 
   56$list_account[] = 
'---Product---';
 
   57$list_account[] = 
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT';
 
   58if ($mysoc->isInEEC()) {
 
   59  $list_account[] = 
'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT';
 
   61$list_account[] = 
'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT';
 
   62$list_account[] = 
'ACCOUNTING_PRODUCT_BUY_ACCOUNT';
 
   63if ($mysoc->isInEEC()) {
 
   64  $list_account[] = 
'ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT';
 
   66$list_account[] = 
'ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT';
 
   68$list_account[] = 
'---Service---';
 
   69$list_account[] = 
'ACCOUNTING_SERVICE_SOLD_ACCOUNT';
 
   70if ($mysoc->isInEEC()) {
 
   71  $list_account[] = 
'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT';
 
   73$list_account[] = 
'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT';
 
   74$list_account[] = 
'ACCOUNTING_SERVICE_BUY_ACCOUNT';
 
   75if ($mysoc->isInEEC()) {
 
   76  $list_account[] = 
'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT';
 
   78$list_account[] = 
'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT';
 
   80$list_account[] = 
'---Others---';
 
   81$list_account[] = 
'ACCOUNTING_VAT_SOLD_ACCOUNT';
 
   82$list_account[] = 
'ACCOUNTING_VAT_BUY_ACCOUNT';
 
   89$list_account[] = 
'ACCOUNTING_VAT_PAY_ACCOUNT';
 
   91if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
 
   92  $list_account[] = 
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT';
 
   93  $list_account[] = 
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT';
 
   95if (isModEnabled(
'banque')) {
 
   96  $list_account[] = 
'ACCOUNTING_ACCOUNT_TRANSFER_CASH';
 
   98if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) {
 
   99  $list_account[] = 
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY';
 
  101if (isModEnabled(
'don')) {
 
  102  $list_account[] = 
'DONATION_ACCOUNTINGACCOUNT';
 
  104if (isModEnabled(
'adherent')) {
 
  105  $list_account[] = 
'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT';
 
  107if (isModEnabled(
'loan')) {
 
  108  $list_account[] = 
'LOAN_ACCOUNTING_ACCOUNT_CAPITAL';
 
  109  $list_account[] = 
'LOAN_ACCOUNTING_ACCOUNT_INTEREST';
 
  110  $list_account[] = 
'LOAN_ACCOUNTING_ACCOUNT_INSURANCE';
 
  112$list_account[] = 
'ACCOUNTING_ACCOUNT_SUSPENSE';
 
  113if (isModEnabled(
'societe')) {
 
  114  $list_account[] = 
'---Deposits---';
 
  121if ($action == 
'update') {
 
  124  foreach ($list_account_main as $constname) {
 
  125    $constvalue = 
GETPOST($constname, 
'alpha');
 
  127    if (!
dolibarr_set_const($db, $constname, $constvalue, 
'chaine', 0, 
'', $conf->entity)) {
 
  132  foreach ($list_account as $constname) {
 
  134    if (preg_match(
'/---(.*)---/', $constname, $reg)) { 
 
  138    $constvalue = 
GETPOST($constname, 
'alpha');
 
  140    if (!
dolibarr_set_const($db, $constname, $constvalue, 
'chaine', 0, 
'', $conf->entity)) {
 
  145  $constname = 
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT';
 
  146  $constvalue = 
GETPOST($constname, 
'int');
 
  147  if (!
dolibarr_set_const($db, $constname, $constvalue, 
'chaine', 0, 
'', $conf->entity)) {
 
  151  $constname = 
'ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT';
 
  152  $constvalue = 
GETPOST($constname, 
'int');
 
  153  if (!
dolibarr_set_const($db, $constname, $constvalue, 
'chaine', 0, 
'', $conf->entity)) {
 
  165if ($action == 
'setACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT') {
 
  166  $setDisableAuxiliaryAccountOnCustomerDeposit = 
GETPOST(
'value', 
'int');
 
  167  $res = 
dolibarr_set_const($db, 
"ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT", $setDisableAuxiliaryAccountOnCustomerDeposit, 
'yesno', 0, 
'', $conf->entity);
 
  179if ($action == 
'setACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT') {
 
  180  $setDisableAuxiliaryAccountOnSupplierDeposit = 
GETPOST(
'value', 
'int');
 
  181  $res = 
dolibarr_set_const($db, 
"ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT", $setDisableAuxiliaryAccountOnSupplierDeposit, 
'yesno', 0, 
'', $conf->entity);
 
  198$form = 
new Form($db);
 
  204print 
load_fiche_titre($langs->trans(
'MenuDefaultAccounts'), $linkback, 
'title_accountancy');
 
  206print 
'<span class="opacitymedium">'.$langs->trans(
"DefaultBindingDesc").
'</span><br>';
 
  209print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
 
  210print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  211print 
'<input type="hidden" name="action" value="update">';
 
  216print 
'<div class="div-table-responsive-no-min">';
 
  217print 
'<table class="noborder centpercent">';
 
  218print 
'<tr class="liste_titre"><td>'.$langs->trans(
"ThirdParties").
' | '.$langs->trans(
"Users").
'</td><td></td></tr>';
 
  220foreach ($list_account_main as $key) {
 
  221  print 
'<tr class="oddeven value">';
 
  223  $label = $langs->trans($key);
 
  224  $keydesc = $key.
'_Desc';
 
  226  $htmltext = $langs->trans($keydesc);
 
  227  print 
'<td class="fieldrequired">';
 
  228  if ($key == 
'ACCOUNTING_ACCOUNT_CUSTOMER') {
 
  229    print 
img_picto(
'', 
'company', 
'class="pictofixedwidth"');
 
  230  } elseif ($key == 
'ACCOUNTING_ACCOUNT_SUPPLIER') {
 
  231    print 
img_picto(
'', 
'company', 
'class="pictofixedwidth"');
 
  233    print 
img_picto(
'', 
'user', 
'class="pictofixedwidth"');
 
  235  print $form->textwithpicto($label, $htmltext);
 
  238  print 
'<td class="right">'; 
 
  240  print $formaccounting->select_account($key_value, $key, 1, 
'', 1, 1, 
'minwidth100 maxwidth300 maxwidthonsmartphone', 
'accountsmain');
 
  248print 
'<div class="div-table-responsive-no-min">';
 
  249print 
'<table class="noborder centpercent">';
 
  251foreach ($list_account as $key) {
 
  253  if (preg_match(
'/---(.*)---/', $key, $reg)) {
 
  254    print 
'<tr class="liste_titre"><td>'.$langs->trans($reg[1]).
'</td><td></td></tr>';
 
  256    print 
'<tr class="oddeven value">';
 
  258    $label = $langs->trans($key);
 
  260    if (preg_match(
'/^ACCOUNTING_PRODUCT/', $key)) {
 
  261      print 
img_picto(
'', 
'product', 
'class="pictofixedwidth"');
 
  262    } elseif (preg_match(
'/^ACCOUNTING_SERVICE/', $key)) {
 
  263      print 
img_picto(
'', 
'service', 
'class="pictofixedwidth"');
 
  264    } elseif (preg_match(
'/^ACCOUNTING_VAT_PAY_ACCOUNT/', $key)) {
 
  265      print 
img_picto(
'', 
'payment_vat', 
'class="pictofixedwidth"');
 
  266    } elseif (preg_match(
'/^ACCOUNTING_VAT/', $key)) {
 
  267      print 
img_picto(
'', 
'vat', 
'class="pictofixedwidth"');
 
  270    } elseif (preg_match(
'/^ACCOUNTING_ACCOUNT_CUSTOMER/', $key)) {
 
  271      print 
img_picto(
'', 
'bill', 
'class="pictofixedwidth"');
 
  272    } elseif (preg_match(
'/^LOAN_ACCOUNTING_ACCOUNT/', $key)) {
 
  273      print 
img_picto(
'', 
'loan', 
'class="pictofixedwidth"');
 
  274    } elseif (preg_match(
'/^DONATION_ACCOUNTING/', $key)) {
 
  275      print 
img_picto(
'', 
'donation', 
'class="pictofixedwidth"');
 
  276    } elseif (preg_match(
'/^ADHERENT_SUBSCRIPTION/', $key)) {
 
  277      print 
img_picto(
'', 
'member', 
'class="pictofixedwidth"');
 
  278    } elseif (preg_match(
'/^ACCOUNTING_ACCOUNT_TRANSFER/', $key)) {
 
  279      print 
img_picto(
'', 
'bank_account', 
'class="pictofixedwidth"');
 
  280    } elseif (preg_match(
'/^ACCOUNTING_ACCOUNT_SUSPENSE/', $key)) {
 
  281      print 
img_picto(
'', 
'question', 
'class="pictofixedwidth"');
 
  286    print 
'<td class="right">'; 
 
  287    print $formaccounting->select_account(
getDolGlobalString($key), $key, 1, 
'', 1, 1, 
'minwidth100 maxwidth300 maxwidthonsmartphone', 
'accounts');
 
  295print 
'<tr class="oddeven value">';
 
  298print 
img_picto(
'', 
'bill', 
'class="pictofixedwidth"') . $langs->trans(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT');
 
  301print 
'<td class="right">'; 
 
  302print $formaccounting->select_account(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'), 
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT', 1, 
'', 1, 1, 
'minwidth100 maxwidth300 maxwidthonsmartphone', 
'accounts');
 
  307  print 
'<tr class="oddeven">';
 
  308  print 
'<td>' . 
img_picto(
'', 
'bill', 
'class="pictofixedwidth"') . $langs->trans(
"UseAuxiliaryAccountOnCustomerDeposit") . 
'</td>';
 
  309  if (
getDolGlobalInt(
'ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT')) {
 
  310    print 
'<td class="right"><a class="reposition" href="' . $_SERVER[
'PHP_SELF'] . 
'?token=' . newToken() . 
'&action=setACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT&value=0">';
 
  311    print 
img_picto($langs->trans(
"Activated"), 
'switch_on', 
'', 
false, 0, 0, 
'', 
'warning');
 
  314    print 
'<td class="right"><a class="reposition" href="' . $_SERVER[
'PHP_SELF'] . 
'?token=' . newToken() . 
'&action=setACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT&value=1">';
 
  315    print 
img_picto($langs->trans(
"Disabled"), 
'switch_off');
 
  322print 
'<tr class="oddeven value">';
 
  325print 
img_picto(
'', 
'supplier_invoice', 
'class="pictofixedwidth"') . $langs->trans(
'ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT');
 
  328print 
'<td class="right">'; 
 
  329print $formaccounting->select_account(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT'), 
'ACCOUNTING_ACCOUNT_SUPPLIER_DEPOSIT', 1, 
'', 1, 1, 
'minwidth100 maxwidth300 maxwidthonsmartphone', 
'accounts');
 
  334  print 
'<tr class="oddeven">';
 
  335  print 
'<td>' . 
img_picto(
'', 
'supplier_invoice', 
'class="pictofixedwidth"') . $langs->trans(
"UseAuxiliaryAccountOnSupplierDeposit") . 
'</td>';
 
  336  if (
getDolGlobalInt(
'ACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT')) {
 
  337    print 
'<td class="right"><a class="reposition" href="' . $_SERVER[
'PHP_SELF'] . 
'?token=' . newToken() . 
'&action=setACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT&value=0">';
 
  338    print 
img_picto($langs->trans(
"Activated"), 
'switch_on', 
'', 
false, 0, 0, 
'', 
'warning');
 
  341    print 
'<td class="right"><a class="reposition" href="' . $_SERVER[
'PHP_SELF'] . 
'?token=' . newToken() . 
'&action=setACCOUNTING_ACCOUNT_SUPPLIER_USE_AUXILIARY_ON_DEPOSIT&value=1">';
 
  342    print 
img_picto($langs->trans(
"Disabled"), 
'switch_off');
 
  351print 
'<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans(
'Save').
'"></div>';
 
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.