compta.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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@dolibarr.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/admin/compta.php
  21. * \ingroup compta
  22. * \brief Page to setup accountancy module
  23. */
  24. require("../main.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
  26. $langs->load('admin');
  27. $langs->load('compta');
  28. if (!$user->admin)
  29. accessforbidden();
  30. llxHeader();
  31. $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
  32. if ($_POST['action'] == 'setcomptamode')
  33. {
  34. $compta_mode = $_POST['compta_mode'];
  35. if (! dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity)) { print $db->error(); }
  36. // Note: This setup differs from TAX_MODE.
  37. // TAX_MODE is used for VAT exigibility only.
  38. }
  39. $form = new Form($db);
  40. $typeconst=array('yesno','texte','chaine');
  41. if ($_POST['action'] == 'update' || $_POST['action'] == 'add')
  42. {
  43. if (! dolibarr_set_const($db, $_POST['constname'], $_POST['constvalue'], $_POST['consttype'], 0, isset($_POST['constnote']) ? $_POST['constnote'] : '',$conf->entity));
  44. {
  45. print $db->error();
  46. }
  47. }
  48. if ($_GET['action'] == 'delete')
  49. {
  50. if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
  51. {
  52. print $db->error();
  53. }
  54. }
  55. /*
  56. * Affichage page
  57. */
  58. $html=new Form($db);
  59. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  60. print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
  61. print '<br>';
  62. print '<table class="noborder" width="100%">';
  63. // Cas du parametre COMPTA_MODE
  64. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  65. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  66. print '<input type="hidden" name="action" value="setcomptamode">';
  67. print '<tr class="liste_titre">';
  68. print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
  69. print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
  70. print "</tr>\n";
  71. 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>';
  72. print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
  73. // Write info on way to count VAT
  74. if ($conf->global->MAIN_MODULE_COMPTABILITE)
  75. {
  76. // print "<br>\n";
  77. // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
  78. }
  79. else
  80. {
  81. // print "<br>\n";
  82. // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
  83. }
  84. print "</td></tr>\n";
  85. 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>';
  86. print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
  87. print '</form>';
  88. print "</table>\n";
  89. print "<br>\n";
  90. // Cas des autres parametres COMPTA_*
  91. $list=array('COMPTA_PRODUCT_BUY_ACCOUNT','COMPTA_PRODUCT_SOLD_ACCOUNT','COMPTA_SERVICE_BUY_ACCOUNT','COMPTA_SERVICE_SOLD_ACCOUNT',
  92. 'COMPTA_VAT_ACCOUNT','COMPTA_ACCOUNT_CUSTOMER','COMPTA_ACCOUNT_SUPPLIER'
  93. );
  94. /*$sql = "SELECT rowid, name, value, type, note";
  95. $sql.= " FROM ".MAIN_DB_PREFIX."const";
  96. $sql.= " WHERE name LIKE 'COMPTA_%'";
  97. $sql.= " AND name NOT IN ('COMPTA_MODE')";
  98. $sql.= " AND entity = ".$conf->entity;
  99. $result = $db->query($sql);
  100. if ($result)
  101. {
  102. $num = $db->num_rows($result);
  103. $i = 0;
  104. while ($i < $num)
  105. {
  106. $obj = $db->fetch_object($result);
  107. $var=!$var;
  108. $list[$obj->name]=$obj->value;
  109. $i++;
  110. }
  111. }*/
  112. $num=sizeof($list);
  113. if ($num)
  114. {
  115. print '<table class="noborder" width="100%">';
  116. print '<tr class="liste_titre">';
  117. print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
  118. print "</tr>\n";
  119. }
  120. foreach ($list as $key)
  121. {
  122. $var=!$var;
  123. print '<form action="compta.php" method="POST">';
  124. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  125. print '<input type="hidden" name="action" value="update">';
  126. print '<input type="hidden" name="consttype" value="string">';
  127. print '<input type="hidden" name="constname" value="'.$key.'">';
  128. print '<tr '.$bc[$var].' class="value">';
  129. // Param
  130. $libelle = $langs->trans($key);
  131. print '<td>'.$libelle;
  132. //print ' ('.$key.')';
  133. print "</td>\n";
  134. // Value
  135. print '<td>';
  136. print '<input type="text" size="20" name="constvalue" value="'.$conf->global->$key.'">';
  137. print '</td><td>';
  138. print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
  139. print "</td></tr>\n";
  140. print '</form>';
  141. $i++;
  142. }
  143. if ($num)
  144. {
  145. print "</table>\n";
  146. }
  147. $db->close();
  148. llxFooter();
  149. ?>