compta.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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@capnetworks.com>
  5. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2013 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 <http://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. $langs->load('admin');
  30. $langs->load('compta');
  31. if (!$user->admin)
  32. accessforbidden();
  33. $action = GETPOST('action','alpha');
  34. // Other parameters COMPTA_*
  35. $list = array(
  36. 'COMPTA_PRODUCT_BUY_ACCOUNT',
  37. 'COMPTA_PRODUCT_SOLD_ACCOUNT',
  38. 'COMPTA_SERVICE_BUY_ACCOUNT',
  39. 'COMPTA_SERVICE_SOLD_ACCOUNT',
  40. 'COMPTA_VAT_ACCOUNT',
  41. 'COMPTA_VAT_BUY_ACCOUNT',
  42. 'COMPTA_ACCOUNT_CUSTOMER',
  43. 'COMPTA_ACCOUNT_SUPPLIER'
  44. );
  45. /*
  46. * Actions
  47. */
  48. $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
  49. if ($action == 'update')
  50. {
  51. $error = 0;
  52. $compta_modes = array(
  53. 'RECETTES-DEPENSES',
  54. 'CREANCES-DETTES'
  55. );
  56. $compta_mode = GETPOST('compta_mode','alpha');
  57. if (in_array($compta_mode,$compta_modes)) {
  58. if (!dolibarr_set_const($db, 'COMPTA_MODE', $compta_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. setEventMessage($langs->trans("SetupSaved"));
  73. }
  74. else
  75. {
  76. setEventMessage($langs->trans("Error"),'errors');
  77. }
  78. }
  79. /*
  80. * View
  81. */
  82. llxHeader();
  83. $form=new Form($db);
  84. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  85. print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
  86. print '<br>';
  87. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  88. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  89. print '<input type="hidden" name="action" value="update">';
  90. print '<table class="noborder" width="100%">';
  91. // Cas du parametre COMPTA_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 '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_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 '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
  110. print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
  111. print '</form>';
  112. print "</table>\n";
  113. print "<br>\n";
  114. print '<table class="noborder" width="100%">';
  115. print '<tr class="liste_titre">';
  116. print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
  117. print "</tr>\n";
  118. foreach ($list as $key)
  119. {
  120. $var=!$var;
  121. print '<tr '.$bc[$var].' class="value">';
  122. // Param
  123. $libelle = $langs->trans($key);
  124. print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
  125. // Value
  126. print '<td>';
  127. print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
  128. print '</td></tr>';
  129. }
  130. print '</form>';
  131. print "</table>\n";
  132. print '<br /><br /><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
  133. $db->close();
  134. llxFooter();