index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <?php
  2. /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
  4. * Copyright (C) 2013-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
  5. * Copyright (C) 2014-2015 Ari Elbaz (elarifr) <github@accedinfo.com>
  6. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  7. * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  9. * Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/accountancy/admin/index.php
  26. * \ingroup Advanced accountancy
  27. * \brief Setup page to configure accounting expert module
  28. */
  29. require '../../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  31. require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
  32. // Load translation files required by the page
  33. $langs->loadLangs(array("compta","bills","admin","accountancy"));
  34. // Security access
  35. if (empty($user->rights->accounting->chartofaccount))
  36. {
  37. accessforbidden();
  38. }
  39. $action = GETPOST('action', 'aZ09');
  40. // Parameters ACCOUNTING_* and others
  41. $list = array (
  42. 'ACCOUNTING_LENGTH_GACCOUNT',
  43. 'ACCOUNTING_LENGTH_AACCOUNT' ,
  44. // 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
  45. // 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
  46. );
  47. /*
  48. * Actions
  49. */
  50. $accounting_mode = empty($conf->global->ACCOUNTING_MODE) ? 'RECETTES-DEPENSES' : $conf->global->ACCOUNTING_MODE;
  51. if ($action == 'update') {
  52. $error = 0;
  53. if (! $error)
  54. {
  55. foreach ($list as $constname)
  56. {
  57. $constvalue = GETPOST($constname, 'alpha');
  58. if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  59. $error++;
  60. }
  61. }
  62. if ($error) {
  63. setEventMessages($langs->trans("Error"), null, 'errors');
  64. }
  65. }
  66. if (! $error) {
  67. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  68. }
  69. }
  70. // TO DO Mutualize code for yes/no constants
  71. if ($action == 'setlistsorttodo') {
  72. $setlistsorttodo = GETPOST('value', 'int');
  73. $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
  74. if (! $res > 0)
  75. $error ++;
  76. if (! $error) {
  77. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  78. } else {
  79. setEventMessages($langs->trans("Error"), null, 'mesgs');
  80. }
  81. }
  82. if ($action == 'setlistsortdone') {
  83. $setlistsortdone = GETPOST('value', 'int');
  84. $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
  85. if (! $res > 0)
  86. $error ++;
  87. if (! $error) {
  88. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  89. } else {
  90. setEventMessages($langs->trans("Error"), null, 'mesgs');
  91. }
  92. }
  93. if ($action == 'setmanagezero') {
  94. $setmanagezero = GETPOST('value', 'int');
  95. $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
  96. if (! $res > 0)
  97. $error ++;
  98. if (! $error) {
  99. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  100. } else {
  101. setEventMessages($langs->trans("Error"), null, 'mesgs');
  102. }
  103. }
  104. if ($action == 'setdisabledirectinput') {
  105. $setdisabledirectinput = GETPOST('value', 'int');
  106. $res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
  107. if (! $res > 0)
  108. $error ++;
  109. if (! $error) {
  110. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  111. } else {
  112. setEventMessages($langs->trans("Error"), null, 'mesgs');
  113. }
  114. }
  115. if ($action == 'setenabledraftexport') {
  116. $setenabledraftexport = GETPOST('value', 'int');
  117. $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
  118. if (! $res > 0)
  119. $error ++;
  120. if (! $error) {
  121. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  122. } else {
  123. setEventMessages($langs->trans("Error"), null, 'mesgs');
  124. }
  125. }
  126. /*
  127. * View
  128. */
  129. llxHeader();
  130. $form = new Form($db);
  131. //$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
  132. print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
  133. print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
  134. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  135. print '<input type="hidden" name="action" value="update">';
  136. // Default mode for calculating turnover (parameter ACCOUNTING_MODE)
  137. /*
  138. print '<table class="noborder" width="100%">';
  139. print '<tr class="liste_titre">';
  140. print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
  141. print "</tr>\n";
  142. print '<tr ' . $bc[false] . '><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"' . ($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '') . '> ' . $langs->trans('OptionModeTrue') . '</td>';
  143. print '<td colspan="2">' . nl2br($langs->trans('OptionModeTrueDesc'));
  144. // Write info on way to count VAT
  145. // if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
  146. // {
  147. // // print "<br>\n";
  148. // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
  149. // }
  150. // else
  151. // {
  152. // // print "<br>\n";
  153. // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
  154. // }
  155. print "</td></tr>\n";
  156. print '<tr ' . $bc[true] . '><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"' . ($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '') . '> ' . $langs->trans('OptionModeVirtual') . '</td>';
  157. print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td></tr>\n";
  158. print "</table>\n";
  159. print '<br>';
  160. */
  161. // Others params
  162. print '<table class="noborder" width="100%">';
  163. print '<tr class="liste_titre">';
  164. print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
  165. print "</tr>\n";
  166. if (! empty($user->admin))
  167. {
  168. // TO DO Mutualize code for yes/no constants
  169. print '<tr class="oddeven">';
  170. print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
  171. if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
  172. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
  173. print img_picto($langs->trans("Activated"), 'switch_on');
  174. print '</a></td>';
  175. } else {
  176. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
  177. print img_picto($langs->trans("Disabled"), 'switch_off');
  178. print '</a></td>';
  179. }
  180. print '</tr>';
  181. print '<tr class="oddeven">';
  182. print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
  183. if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
  184. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
  185. print img_picto($langs->trans("Activated"), 'switch_on');
  186. print '</a></td>';
  187. } else {
  188. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
  189. print img_picto($langs->trans("Disabled"), 'switch_off');
  190. print '</a></td>';
  191. }
  192. print '</tr>';
  193. print '<tr class="oddeven">';
  194. print '<td>' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . '</td>';
  195. if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
  196. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=0">';
  197. print img_picto($langs->trans("Activated"), 'switch_on');
  198. print '</a></td>';
  199. } else {
  200. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=1">';
  201. print img_picto($langs->trans("Disabled"), 'switch_off');
  202. print '</a></td>';
  203. }
  204. print '</tr>';
  205. print '<tr class="oddeven">';
  206. print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
  207. if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
  208. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
  209. print img_picto($langs->trans("Activated"), 'switch_on');
  210. print '</a></td>';
  211. } else {
  212. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
  213. print img_picto($langs->trans("Disabled"), 'switch_off');
  214. print '</a></td>';
  215. }
  216. print '</tr>';
  217. print '<tr class="oddeven">';
  218. print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
  219. if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
  220. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
  221. print img_picto($langs->trans("Activated"), 'switch_on');
  222. print '</a></td>';
  223. } else {
  224. print '<td class="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
  225. print img_picto($langs->trans("Disabled"), 'switch_off');
  226. print '</a></td>';
  227. }
  228. print '</tr>';
  229. }
  230. // Param a user $user->rights->accounting->chartofaccount can access
  231. foreach ($list as $key)
  232. {
  233. print '<tr class="oddeven value">';
  234. if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
  235. // Param
  236. $label = $langs->trans($key);
  237. print '<td>'.$label.'</td>';
  238. // Value
  239. print '<td class="right">';
  240. print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
  241. print '</td>';
  242. print '</tr>';
  243. }
  244. print '</table>';
  245. print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
  246. print '<br>';
  247. print '<br>';
  248. print '<br>';
  249. print '</form>';
  250. // End of page
  251. llxFooter();
  252. $db->close();