export.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
  4. * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
  5. * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/accountancy/admin/export.php
  22. * \ingroup Accounting Expert
  23. * \brief Setup page to configure accounting expert module
  24. */
  25. // Dolibarr environment
  26. $res = @include ("../main.inc.php");
  27. if (! $res && file_exists("../main.inc.php"))
  28. $res = @include ("../main.inc.php");
  29. if (! $res && file_exists("../../main.inc.php"))
  30. $res = @include ("../../main.inc.php");
  31. if (! $res && file_exists("../../../main.inc.php"))
  32. $res = @include ("../../../main.inc.php");
  33. if (! $res)
  34. die("Include of main fails");
  35. // Class
  36. dol_include_once("/core/lib/admin.lib.php");
  37. require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  38. $langs->load("compta");
  39. $langs->load("bills");
  40. $langs->load("admin");
  41. $langs->load("accountancy");
  42. // Security check
  43. if (!$user->admin)
  44. accessforbidden();
  45. $action = GETPOST('action', 'alpha');
  46. // Other parameters ACCOUNTING_*
  47. $list = array (
  48. 'ACCOUNTING_SEPARATORCSV'
  49. );
  50. /*
  51. * Actions
  52. */
  53. if ($action == 'update') {
  54. $error = 0;
  55. $modelcsv = GETPOST('modelcsv', 'int');
  56. if (! empty($modelcsv)) {
  57. if (! dolibarr_set_const($db, 'ACCOUNTING_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
  58. $error ++;
  59. }
  60. } else {
  61. $error ++;
  62. }
  63. foreach ( $list as $constname ) {
  64. $constvalue = GETPOST($constname, 'alpha');
  65. if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  66. $error ++;
  67. }
  68. }
  69. if (! $error) {
  70. setEventMessage($langs->trans("SetupSaved"));
  71. } else {
  72. setEventMessage($langs->trans("Error"), 'errors');
  73. }
  74. }
  75. /*
  76. * View
  77. */
  78. llxHeader();
  79. $form = new Form($db);
  80. print_fiche_titre($langs->trans('ConfigAccountingExpert'));
  81. $head = admin_account_prepare_head(null);
  82. dol_fiche_head($head, 'export', $langs->trans("Configuration"), 0, 'cron');
  83. print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
  84. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  85. print '<input type="hidden" name="action" value="update">';
  86. print '<table class="noborder" width="100%">';
  87. $var = True;
  88. print '<tr class="liste_titre">';
  89. print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
  90. print '</tr>';
  91. $var = ! $var;
  92. print '<tr ' . $bc[$var] . '>';
  93. print "<td>" . $langs->trans("Selectmodelcsv") . "</td>";
  94. print "<td>";
  95. print '<select class="flat" name="modelcsv" id="modelcsv">';
  96. print '<option value="0"';
  97. if ($conf->global->ACCOUNTING_MODELCSV == 0) {
  98. print ' selected="selected"';
  99. }
  100. print '>' . $langs->trans("Modelcsv_normal") . '</option>';
  101. print '<option value="1"';
  102. if ($conf->global->ACCOUNTING_MODELCSV == 1) {
  103. print ' selected="selected"';
  104. }
  105. print '>' . $langs->trans("Modelcsv_CEGID") . '</option>';
  106. print "</select>";
  107. print "</td></tr>";
  108. print "</table>";
  109. print "<br>\n";
  110. /*
  111. * Params
  112. *
  113. */
  114. $list = array (
  115. 'ACCOUNTING_SEPARATORCSV'
  116. );
  117. $num = count($list);
  118. if ($num) {
  119. print '<table class="noborder" width="100%">';
  120. print '<tr class="liste_titre">';
  121. print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
  122. print "</tr>\n";
  123. }
  124. foreach ( $list as $key ) {
  125. $var = ! $var;
  126. print '<tr ' . $bc[$var] . ' class="value">';
  127. // Param
  128. $label = $langs->trans($key);
  129. print '<td>' . $label . '</td>';
  130. // Value
  131. print '<td>';
  132. print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
  133. print '</td></tr>';
  134. }
  135. print '</form>';
  136. print "</table>\n";
  137. print '<br /><div style="text-align:center"><input type="submit" class="button" value="' . $langs->trans('Modify') . '" name="button"></div>';
  138. llxFooter();
  139. $db->close();