compta.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013-2017 Philippe Grand <philippe.grand@atoo-net.com>
  7. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/admin/compta.php
  24. * \ingroup compta
  25. * \brief Page to setup accountancy module
  26. */
  27. require '../main.inc.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array('admin', 'compta', 'accountancy'));
  31. if (!$user->admin)
  32. accessforbidden();
  33. $action = GETPOST('action', 'alpha');
  34. // Other parameters ACCOUNTING_*
  35. $list = array(
  36. 'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
  37. 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
  38. 'ACCOUNTING_SERVICE_BUY_ACCOUNT',
  39. 'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
  40. 'ACCOUNTING_VAT_SOLD_ACCOUNT',
  41. 'ACCOUNTING_VAT_BUY_ACCOUNT',
  42. 'ACCOUNTING_ACCOUNT_CUSTOMER',
  43. 'ACCOUNTING_ACCOUNT_SUPPLIER'
  44. );
  45. /*
  46. * Actions
  47. */
  48. $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
  49. if ($action == 'update')
  50. {
  51. $error = 0;
  52. $accounting_modes = array(
  53. 'RECETTES-DEPENSES',
  54. 'CREANCES-DETTES'
  55. );
  56. $accounting_mode = GETPOST('accounting_mode', 'alpha');
  57. if (in_array($accounting_mode, $accounting_modes)) {
  58. if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
  59. $error++;
  60. }
  61. } else {
  62. $error++;
  63. }
  64. foreach ($list as $constname) {
  65. $constvalue = GETPOST($constname, 'alpha');
  66. if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  67. $error++;
  68. }
  69. }
  70. if (!$error)
  71. {
  72. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  73. }
  74. else
  75. {
  76. setEventMessages($langs->trans("Error"), null, 'errors');
  77. }
  78. }
  79. /*
  80. * View
  81. */
  82. llxHeader();
  83. $form = new Form($db);
  84. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  85. print load_fiche_titre($langs->trans('ComptaSetup'), $linkback, 'title_setup');
  86. print '<br>';
  87. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  88. print '<input type="hidden" name="token" value="'.newToken().'">';
  89. print '<input type="hidden" name="action" value="update">';
  90. print '<table class="noborder centpercent">';
  91. // case of the parameter ACCOUNTING_MODE
  92. print '<tr class="liste_titre">';
  93. print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
  94. print "</tr>\n";
  95. print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
  96. print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
  97. // Write info on way to count VAT
  98. //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
  99. //{
  100. // // print "<br>\n";
  101. // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
  102. //}
  103. //else
  104. //{
  105. // // print "<br>\n";
  106. // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
  107. //}
  108. print "</td></tr>\n";
  109. print '<tr class="oddeven"><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
  110. print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
  111. print "</table>\n";
  112. print "<br>\n";
  113. print '<table class="noborder centpercent">';
  114. print '<tr class="liste_titre">';
  115. print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
  116. print "</tr>\n";
  117. foreach ($list as $key)
  118. {
  119. print '<tr class="oddeven value">';
  120. // Param
  121. $libelle = $langs->trans($key);
  122. print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
  123. // Value
  124. print '<td>';
  125. print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
  126. print '</td></tr>';
  127. }
  128. print "</table>\n";
  129. print '<br><br><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
  130. print '</form>';
  131. // End of page
  132. llxFooter();
  133. $db->close();