export.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. /* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
  3. * Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@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 Advanced accountancy
  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. require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountancyexport.class.php';
  32. $langs->load("compta");
  33. $langs->load("bills");
  34. $langs->load("admin");
  35. $langs->load("accountancy");
  36. // Security check
  37. if (empty($user->admin) || ! empty($user->rights->accountancy->chartofaccount))
  38. {
  39. accessforbidden();
  40. }
  41. $action = GETPOST('action', 'alpha');
  42. // Parameters ACCOUNTING_EXPORT_*
  43. $main_option = array (
  44. 'ACCOUNTING_EXPORT_PREFIX_SPEC'
  45. );
  46. $model_option = array (
  47. 'ACCOUNTING_EXPORT_SEPARATORCSV',
  48. 'ACCOUNTING_EXPORT_DATE'
  49. /*
  50. 'ACCOUNTING_EXPORT_PIECE',
  51. 'ACCOUNTING_EXPORT_GLOBAL_ACCOUNT',
  52. 'ACCOUNTING_EXPORT_LABEL',
  53. 'ACCOUNTING_EXPORT_AMOUNT',
  54. 'ACCOUNTING_EXPORT_DEVISE'
  55. */
  56. );
  57. /*
  58. * Actions
  59. */
  60. if ($action == 'update') {
  61. $error = 0;
  62. $format = GETPOST('format', 'alpha');
  63. $modelcsv = GETPOST('modelcsv', 'int');
  64. if (! empty($format)) {
  65. if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', $format, 'chaine', 0, '', $conf->entity)) {
  66. $error ++;
  67. }
  68. } else {
  69. $error ++;
  70. }
  71. if (! empty($modelcsv)) {
  72. if (! dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
  73. $error ++;
  74. }
  75. if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
  76. dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
  77. }
  78. } else {
  79. $error ++;
  80. }
  81. foreach ( $main_option as $constname ) {
  82. $constvalue = GETPOST($constname, 'alpha');
  83. if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  84. $error ++;
  85. }
  86. }
  87. foreach ( $model_option as $constname ) {
  88. $constvalue = GETPOST($constname, 'alpha');
  89. if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  90. $error ++;
  91. }
  92. }
  93. if (! $error) {
  94. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  95. } else {
  96. setEventMessages($langs->trans("Error"), null, 'errors');
  97. }
  98. }
  99. /*
  100. * View
  101. */
  102. llxHeader();
  103. $form = new Form($db);
  104. $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
  105. print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'title_setup');
  106. $head = admin_accounting_prepare_head();
  107. print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">';
  108. print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
  109. print '<input type="hidden" name="action" value="update">';
  110. dol_fiche_head($head, 'export', $langs->trans("Configuration"), -1, 'cron');
  111. $var = true;
  112. /*
  113. * Main Options
  114. */
  115. print '<table class="noborder" width="100%">';
  116. print '<tr class="liste_titre">';
  117. print '<td colspan="3">' . $langs->trans('Options') . '</td>';
  118. print "</tr>\n";
  119. $var = ! $var;
  120. $num = count($main_option);
  121. if ($num) {
  122. foreach ( $main_option as $key ) {
  123. print '<tr class="oddeven value">';
  124. // Param
  125. $label = $langs->trans($key);
  126. print '<td width="50%">' . $label . '</td>';
  127. // Value
  128. print '<td>';
  129. print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
  130. print '</td></tr>';
  131. }
  132. }
  133. print "</table>\n";
  134. print "<br>\n";
  135. /*
  136. * Export model
  137. */
  138. print '<table class="noborder" width="100%">';
  139. print '<tr class="liste_titre">';
  140. print '<td colspan="2">' . $langs->trans("Modelcsv") . '</td>';
  141. print '</tr>';
  142. $var = ! $var;
  143. print '<tr class="oddeven">';
  144. print '<td width="50%">' . $langs->trans("Selectmodelcsv") . '</td>';
  145. if (! $conf->use_javascript_ajax) {
  146. print '<td class="nowrap">';
  147. print $langs->trans("NotAvailableWhenAjaxDisabled");
  148. print "</td>";
  149. } else {
  150. print '<td>';
  151. $listmodelcsv = AccountancyExport::getType();
  152. print $form->selectarray("modelcsv", $listmodelcsv, $conf->global->ACCOUNTING_EXPORT_MODELCSV, 0);
  153. print '</td>';
  154. }
  155. print "</td></tr>";
  156. print "</table>";
  157. print "<br>\n";
  158. /*
  159. * Parameters
  160. */
  161. $num2 = count($model_option);
  162. if ($num2) {
  163. print '<table class="noborder" width="100%">';
  164. print '<tr class="liste_titre">';
  165. print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
  166. print "</tr>\n";
  167. if ($conf->global->ACCOUNTING_EXPORT_MODELCSV > 1)
  168. {
  169. print '<tr><td colspan="2" bgcolor="red"><b>' . $langs->trans('OptionsDeactivatedForThisExportModel') . '</b></td></tr>';
  170. }
  171. print '<tr class="oddeven">';
  172. print '<td width="50%">' . $langs->trans("Selectformat") . '</td>';
  173. if (! $conf->use_javascript_ajax) {
  174. print '<td class="nowrap">';
  175. print $langs->trans("NotAvailableWhenAjaxDisabled");
  176. print "</td>";
  177. } else {
  178. print '<td>';
  179. $listformat = array (
  180. 'csv' => $langs->trans("csv"),
  181. 'txt' => $langs->trans("txt")
  182. );
  183. print $form->selectarray("format", $listformat, $conf->global->ACCOUNTING_EXPORT_FORMAT, 0);
  184. print '</td>';
  185. }
  186. print "</td></tr>";
  187. foreach ( $model_option as $key ) {
  188. print '<tr class="oddeven value">';
  189. // Param
  190. $label = $langs->trans($key);
  191. print '<td width="50%">' . $label . '</td>';
  192. // Value
  193. print '<td>';
  194. print '<input type="text" size="20" name="' . $key . '" value="' . $conf->global->$key . '">';
  195. print '</td></tr>';
  196. }
  197. print "</table>\n";
  198. }
  199. dol_fiche_end();
  200. print '<div class="center"><input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans('Modify')) . '" name="button"></div>';
  201. print '</form>';
  202. llxFooter();
  203. $db->close();