export.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2015 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. * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
  7. * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * \file htdocs/accountancy/admin/export.php
  24. * \ingroup Accounting Expert
  25. * \brief Setup page to configure accounting expert module
  26. */
  27. require '../../main.inc.php';
  28. // Class
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
  31. $langs->load("compta");
  32. $langs->load("bills");
  33. $langs->load("admin");
  34. $langs->load("accountancy");
  35. // Security check
  36. if (!$user->admin)
  37. accessforbidden();
  38. $action = GETPOST('action', 'alpha');
  39. // Other parameters ACCOUNTING_EXPORT_*
  40. $list = array (
  41. 'ACCOUNTING_EXPORT_SEPARATORCSV',
  42. 'ACCOUNTING_EXPORT_DATE',
  43. 'ACCOUNTING_EXPORT_PIECE',
  44. 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT',
  45. 'ACCOUNTING_EXPORT_LABEL',
  46. 'ACCOUNTING_EXPORT_AMOUNT',
  47. 'ACCOUNTING_EXPORT_DEVISE'
  48. );
  49. /*
  50. * Actions
  51. */
  52. if ($action == 'update') {
  53. $error = 0;
  54. $modelcsv = GETPOST('modelcsv', 'int');
  55. if (! empty($modelcsv)) {
  56. if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
  57. $error ++;
  58. }
  59. } else {
  60. $error ++;
  61. }
  62. foreach ( $list as $constname ) {
  63. $constvalue = GETPOST($constname, 'alpha');
  64. if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  65. $error ++;
  66. }
  67. }
  68. if (! $error) {
  69. setEventMessage($langs->trans("SetupSaved"));
  70. } else {
  71. setEventMessage($langs->trans("Error"), 'errors');
  72. }
  73. }
  74. /*
  75. * View
  76. */
  77. llxHeader();
  78. $form = new Form($db);
  79. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  80. print_fiche_titre($langs->trans('ConfigAccountingExpert'),$linkback,'title_setup');
  81. $head = admin_accounting_prepare_head();
  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 width="50%">' . $langs->trans("Selectmodelcsv") . '</td>';
  94. if (! $conf->use_javascript_ajax)
  95. {
  96. print '<td class="nowrap">';
  97. print $langs->trans("NotAvailableWhenAjaxDisabled");
  98. print "</td>";
  99. }
  100. else
  101. {
  102. print '<td>';
  103. $listmodelcsv=array(
  104. '1'=>$langs->trans("Modelcsv_normal"),
  105. '2'=>$langs->trans("Modelcsv_CEGID")
  106. );
  107. print $form->selectarray("modelcsv",$listmodelcsv,$conf->global->ACCOUNTING_EXPORT_MODELCSV,0);
  108. print '</td>';
  109. }
  110. print "</td></tr>";
  111. print "</table>";
  112. print "<br>\n";
  113. /*
  114. * Parameters
  115. */
  116. $num = count($list);
  117. if ($num)
  118. {
  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. if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1) print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
  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 width="50%">' . $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 "</table>\n";
  136. }
  137. print '<br><div style="text-align:center"><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '" name="button"></div>';
  138. print '</form>';
  139. llxFooter();
  140. $db->close();