index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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-2019 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 <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/accountancy/admin/index.php
  26. * \ingroup Accountancy (Double entries)
  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. if ($action == 'setenablesubsidiarylist') {
  127. $setenablesubsidiarylist = GETPOST('value', 'int');
  128. $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
  129. if (! $res > 0)
  130. $error ++;
  131. if (! $error) {
  132. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  133. } else {
  134. setEventMessages($langs->trans("Error"), null, 'mesgs');
  135. }
  136. }
  137. /*
  138. * View
  139. */
  140. llxHeader();
  141. $form = new Form($db);
  142. //$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
  143. print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
  144. print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
  145. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  146. print '<input type="hidden" name="action" value="update">';
  147. // Default mode for calculating turnover (parameter ACCOUNTING_MODE)
  148. /*
  149. print '<table class="noborder" width="100%">';
  150. print '<tr class="liste_titre">';
  151. print '<td>' . $langs->trans('OptionMode') . '</td><td>' . $langs->trans('Description') . '</td>';
  152. print "</tr>\n";
  153. 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>';
  154. print '<td colspan="2">' . nl2br($langs->trans('OptionModeTrueDesc'));
  155. // Write info on way to count VAT
  156. // if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
  157. // {
  158. // // print "<br>\n";
  159. // // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
  160. // }
  161. // else
  162. // {
  163. // // print "<br>\n";
  164. // // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
  165. // }
  166. print "</td></tr>\n";
  167. 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>';
  168. print '<td colspan="2">' . nl2br($langs->trans('OptionModeVirtualDesc')) . "</td></tr>\n";
  169. print "</table>\n";
  170. print '<br>';
  171. */
  172. // Others params
  173. print '<table class="noborder" width="100%">';
  174. print '<tr class="liste_titre">';
  175. print '<td colspan="2">' . $langs->trans('OtherOptions') . '</td>';
  176. print "</tr>\n";
  177. if (! empty($user->admin))
  178. {
  179. // TO DO Mutualize code for yes/no constants
  180. print '<tr class="oddeven">';
  181. print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO") . '</td>';
  182. if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
  183. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=0">';
  184. print img_picto($langs->trans("Activated"), 'switch_on');
  185. print '</a></td>';
  186. } else {
  187. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsorttodo&value=1">';
  188. print img_picto($langs->trans("Disabled"), 'switch_off');
  189. print '</a></td>';
  190. }
  191. print '</tr>';
  192. print '<tr class="oddeven">';
  193. print '<td>' . $langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE") . '</td>';
  194. if (! empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
  195. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=0">';
  196. print img_picto($langs->trans("Activated"), 'switch_on');
  197. print '</a></td>';
  198. } else {
  199. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setlistsortdone&value=1">';
  200. print img_picto($langs->trans("Disabled"), 'switch_off');
  201. print '</a></td>';
  202. }
  203. print '</tr>';
  204. print '<tr class="oddeven">';
  205. print '<td>' . $langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL") . '</td>';
  206. if (! empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) {
  207. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=0">';
  208. print img_picto($langs->trans("Activated"), 'switch_on');
  209. print '</a></td>';
  210. } else {
  211. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenabledraftexport&value=1">';
  212. print img_picto($langs->trans("Disabled"), 'switch_off');
  213. print '</a></td>';
  214. }
  215. print '</tr>';
  216. print '<tr class="oddeven">';
  217. print '<td>' . $langs->trans("BANK_DISABLE_DIRECT_INPUT") . '</td>';
  218. if (! empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
  219. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=0">';
  220. print img_picto($langs->trans("Activated"), 'switch_on');
  221. print '</a></td>';
  222. } else {
  223. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setdisabledirectinput&value=1">';
  224. print img_picto($langs->trans("Disabled"), 'switch_off');
  225. print '</a></td>';
  226. }
  227. print '</tr>';
  228. print '<tr class="oddeven">';
  229. print '<td>' . $langs->trans("ACCOUNTANCY_COMBO_FOR_AUX") . '</td>';
  230. if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
  231. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenablesubsidiarylist&value=0">';
  232. print img_picto($langs->trans("Activated"), 'switch_on');
  233. print '</a></td>';
  234. } else {
  235. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setenablesubsidiarylist&value=1">';
  236. print img_picto($langs->trans("Disabled"), 'switch_off');
  237. print '</a></td>';
  238. }
  239. print '</tr>';
  240. print '<tr class="oddeven">';
  241. print '<td>' . $langs->trans("ACCOUNTING_MANAGE_ZERO") . '</td>';
  242. if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
  243. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=0">';
  244. print img_picto($langs->trans("Activated"), 'switch_on');
  245. print '</a></td>';
  246. } else {
  247. print '<td class="right"><a class="reposition" href="' . $_SERVER['PHP_SELF'] . '?action=setmanagezero&value=1">';
  248. print img_picto($langs->trans("Disabled"), 'switch_off');
  249. print '</a></td>';
  250. }
  251. print '</tr>';
  252. }
  253. // Param a user $user->rights->accounting->chartofaccount can access
  254. foreach ($list as $key)
  255. {
  256. print '<tr class="oddeven value">';
  257. if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
  258. // Param
  259. $label = $langs->trans($key);
  260. print '<td>'.$label.'</td>';
  261. // Value
  262. print '<td class="right">';
  263. print '<input type="text" class="maxwidth100" id="' . $key . '" name="' . $key . '" value="' . $conf->global->$key . '">';
  264. print '</td>';
  265. print '</tr>';
  266. }
  267. print '</table>';
  268. print '<div class="center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
  269. print '<br>';
  270. print '<br>';
  271. print '<br>';
  272. print '</form>';
  273. // End of page
  274. llxFooter();
  275. $db->close();