dolibarr 18.0.6
export.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
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 * Copyright (C) 2017-2018 Frédéric France <frederic.france@netlogic.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
29require '../../main.inc.php';
30
31require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
34
35// Load translation files required by the page
36$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
37
38// Security access
39if (!$user->hasRight('accounting', 'chartofaccount')) {
41}
42
43$action = GETPOST('action', 'aZ09');
44
45// Parameters ACCOUNTING_EXPORT_*
46$main_option = array(
47 'ACCOUNTING_EXPORT_PREFIX_SPEC',
48);
49
50$accountancyexport = new AccountancyExport($db);
51$configuration = $accountancyexport->getTypeConfig();
52
53$listparam = $configuration['param'];
54
55$listformat = $configuration['format'];
56
57$listcr = $configuration['cr'];
58
59
60$model_option = array(
61 '1' => array(
62 'label' => 'ACCOUNTING_EXPORT_FORMAT',
63 'param' => $listformat,
64 ),
65 '2' => array(
66 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV',
67 'param' => '',
68 ),
69 '3' => array(
70 'label' => 'ACCOUNTING_EXPORT_ENDLINE',
71 'param' => $listcr,
72 ),
73 '4' => array(
74 'label' => 'ACCOUNTING_EXPORT_DATE',
75 'param' => '',
76 ),
77);
78
79
80/*
81 * Actions
82 */
83
84if ($action == 'update') {
85 $error = 0;
86
87 $modelcsv = GETPOST('ACCOUNTING_EXPORT_MODELCSV', 'int');
88
89 if (!empty($modelcsv)) {
90 if (!dolibarr_set_const($db, 'ACCOUNTING_EXPORT_MODELCSV', $modelcsv, 'chaine', 0, '', $conf->entity)) {
91 $error++;
92 }
93 //if ($modelcsv==AccountancyExport::$EXPORT_TYPE_QUADRATUS || $modelcsv==AccountancyExport::$EXPORT_TYPE_CIEL) {
94 // dolibarr_set_const($db, 'ACCOUNTING_EXPORT_FORMAT', 'txt', 'chaine', 0, '', $conf->entity);
95 //}
96 } else {
97 $error++;
98 }
99
100 foreach ($main_option as $constname) {
101 $constvalue = GETPOST($constname, 'alpha');
102
103 if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
104 $error++;
105 }
106 }
107
108 foreach ($listparam[$modelcsv] as $key => $value) {
109 $constante = $key;
110
111 if (strpos($constante, 'ACCOUNTING') !== false) {
112 $constvalue = GETPOST($key, 'alpha');
113 if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
114 $error++;
115 }
116 }
117 }
118
119 if (!$error) {
120 // reload
121 $configuration = $accountancyexport->getTypeConfig();
122 $listparam = $configuration['param'];
123 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
124 } else {
125 setEventMessages($langs->trans("Error"), null, 'errors');
126 }
127}
128
129
130
131/*
132 * View
133 */
134
135$form = new Form($db);
136
137$title = $langs->trans('ExportOptions');
138llxHeader('', $title);
139
140
141$linkback = '';
142// $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1">' . $langs->trans("BackToModuleList") . '</a>';
143print load_fiche_titre($langs->trans('ExportOptions'), $linkback, 'accountancy');
144
145
146print "\n".'<script type="text/javascript">'."\n";
147print 'jQuery(document).ready(function () {'."\n";
148print ' function initfields()'."\n";
149print ' {'."\n";
150foreach ($listparam as $key => $param) {
151 print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
152 print ' {'."\n";
153 print ' //console.log("'.$param['label'].'");'."\n";
154 if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
155 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n";
156 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
157 } else {
158 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
159 print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
160 }
161 if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
162 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
163 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
164 } else {
165 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n";
166 print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
167 }
168 if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
169 print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
170 } else {
171 print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
172 }
173 if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
174 print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
175 print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
176 } else {
177 print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n";
178 print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
179 }
180 print ' }'."\n";
181}
182print ' }'."\n";
183print ' initfields();'."\n";
184print ' jQuery("#ACCOUNTING_EXPORT_MODELCSV").change(function() {'."\n";
185print ' initfields();'."\n";
186print ' });'."\n";
187print '})'."\n";
188print '</script>'."\n";
189
190print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
191print '<input type="hidden" name="token" value="'.newToken().'">';
192print '<input type="hidden" name="action" value="update">';
193
194/*
195 * Main Options
196 */
197
198print '<table class="noborder centpercent">';
199print '<tr class="liste_titre">';
200print '<td colspan="3">'.$langs->trans('Options').'</td>';
201print "</tr>\n";
202
203$num = count($main_option);
204if ($num) {
205 foreach ($main_option as $key) {
206 print '<tr class="oddeven value">';
207
208 // Param
209 $label = $langs->trans($key);
210 print '<td width="50%">'.$label.'</td>';
211
212 // Value
213 print '<td>';
214 print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
215 print '</td></tr>';
216 }
217}
218
219print "</table>\n";
220
221print "<br>\n";
222
223/*
224 * Export model
225 */
226print '<table class="noborder centpercent">';
227
228print '<tr class="liste_titre">';
229print '<td colspan="2">'.$langs->trans("Modelcsv").'</td>';
230print '</tr>';
231
232
233print '<tr class="oddeven">';
234print '<td width="50%">'.$langs->trans("Selectmodelcsv").'</td>';
235if (!$conf->use_javascript_ajax) {
236 print '<td class="nowrap">';
237 print $langs->trans("NotAvailableWhenAjaxDisabled");
238 print "</td>";
239} else {
240 print '<td>';
241 $listmodelcsv = $accountancyexport->getType();
242 print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listmodelcsv, getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'), 0, 0, 0, '', 0, 0, 0, '', '', 1);
243
244 print '</td>';
245}
246print "</td></tr>";
247print "</table>";
248
249print "<br>\n";
250
251/*
252 * Parameters
253 */
254
255$num2 = count($model_option);
256if ($num2) {
257 print '<table class="noborder centpercent">';
258 print '<tr class="liste_titre">';
259 print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
260 print "</tr>\n";
261
262 foreach ($model_option as $key) {
263 print '<tr class="oddeven value">';
264
265 // Param
266 $label = $key['label'];
267 print '<td width="50%">'.$langs->trans($label).'</td>';
268
269 // Value
270 print '<td>';
271 if (is_array($key['param'])) {
272 print $form->selectarray($label, $key['param'], getDolGlobalString($label), 0);
273 } else {
274 print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.getDolGlobalString($label).'">';
275 }
276
277 print '</td></tr>';
278 }
279
280 print "</table>\n";
281}
282
283print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Modify')).'" name="button"></div>';
284
285print '</form>';
286
287// End of page
288llxFooter();
289$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
Manage the different format accountancy export.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.