accounting.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/admin/accounting.php
  20. * \ingroup accounting
  21. * \brief Page de configuration du module comptabilite expert
  22. */
  23. require("../main.inc.php");
  24. require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
  25. $langs->load('admin');
  26. $langs->load('compta');
  27. if (!$user->admin)
  28. accessforbidden();
  29. $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
  30. if ($_POST['action'] == 'setcomptamode')
  31. {
  32. $compta_mode = $_POST['compta_mode'];
  33. if (! dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity)) { print $db->error(); }
  34. }
  35. $form = new Form($db);
  36. $typeconst=array('yesno','texte','chaine');
  37. if ($_POST['action'] == 'update' || $_POST['action'] == 'add')
  38. {
  39. if (! dolibarr_set_const($db, $_POST['constname'], $_POST['constvalue'], $typeconst[$_POST['consttype']], 0, isset($_POST['constnote']) ? $_POST['constnote'] : '',$conf->entity));
  40. {
  41. print $db->error();
  42. }
  43. }
  44. if ($_GET['action'] == 'delete')
  45. {
  46. if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
  47. {
  48. print $db->error();
  49. }
  50. }
  51. /*
  52. * View
  53. */
  54. llxHeader();
  55. $html=new Form($db);
  56. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  57. print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
  58. print '<br>';
  59. print '<table class="noborder" width="100%">';
  60. // Cas du parametre COMPTA_MODE
  61. print '<form action="compta.php" method="post">';
  62. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  63. print '<input type="hidden" name="action" value="setcomptamode">';
  64. print '<tr class="liste_titre">';
  65. print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
  66. print '<td><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
  67. print "</tr>\n";
  68. 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>';
  69. print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'))."</td></tr>\n";
  70. 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>';
  71. print '<td colspan="2">'.$langs->trans('OptionModeVirtualDesc')."</td></tr>\n";
  72. print '</form>';
  73. print "</table>\n";
  74. print "<br>\n";
  75. // Cas des autres param�tres COMPTA_*
  76. /*
  77. $sql ="SELECT rowid, name, value, type, note";
  78. $sql.=" FROM llx_const";
  79. $sql.=" WHERE name like 'COMPTA_%' and name not in ('COMPTA_MODE')";
  80. $result = $db->query($sql);
  81. if ($result)
  82. {
  83. $num = $db->num_rows($result);
  84. $i = 0;
  85. $var=true;
  86. if ($num)
  87. {
  88. print '<table class="noborder" width="100%">';
  89. print '<tr class="liste_titre">';
  90. print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
  91. print "</tr>\n";
  92. }
  93. while ($i < $num)
  94. {
  95. $obj = $db->fetch_object($result);
  96. $var=!$var;
  97. print '<form action="compta.php" method="POST">';
  98. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  99. print '<input type="hidden" name="action" value="update">';
  100. print '<input type="hidden" name="rowid" value="'.$rowid.'">';
  101. print '<input type="hidden" name="constname" value="'.$obj->name.'">';
  102. print '<tr '.$bc[$var].' class="value">';
  103. print '<td>'.stripslashes(nl2br($obj->note))."</td>\n";
  104. print '<td>';
  105. if ($obj->type == 'yesno')
  106. {
  107. print $form->selectyesno('constvalue',$obj->value,1);
  108. }
  109. elseif ($obj->type == 'texte')
  110. {
  111. print '<textarea name="constvalue" cols="35" rows="5" wrap="soft">';
  112. print $obj->value;
  113. print "</textarea>\n";
  114. }
  115. else
  116. {
  117. print '<input type="text" size="30" name="constvalue" value="'.stripslashes($obj->value).'">';
  118. }
  119. print '</td><td>';
  120. print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
  121. print "</td></tr>\n";
  122. print '</form>';
  123. $i++;
  124. }
  125. if ($num)
  126. {
  127. print "</table>\n";
  128. }
  129. }
  130. */
  131. $db->close();
  132. llxFooter();
  133. ?>