dolibarr 20.0.2
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-2024 Alexandre Spangaro <aspangaro@easya.solutions>
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 = GETPOSTINT('ACCOUNTING_EXPORT_MODELCSV');
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$help_url = 'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilit&eacute;_en_Partie_Double#Configuration';
138$title = $langs->trans('ExportOptions');
139llxHeader('', $title, $help_url);
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("'.getDolGlobalString('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("'.getDolGlobalString('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("'.getDolGlobalString('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="2">'.$langs->trans('ExportOptions').'</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>'.dol_escape_htmltag($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 '<tr class="oddeven">';
220print '<td>'.$langs->trans("Selectmodelcsv").'</td>';
221if (!$conf->use_javascript_ajax) {
222 print '<td class="nowrap">';
223 print $langs->trans("NotAvailableWhenAjaxDisabled");
224 print "</td>";
225} else {
226 print '<td>';
227 $listofexporttemplates = $accountancyexport->getType(1);
228 print $form->selectarray("ACCOUNTING_EXPORT_MODELCSV", $listofexporttemplates, getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV'), 0, 0, 0, '', 0, 0, 0, '', '', 1);
229 print '</td>';
230}
231print "</tr>";
232
233
234$num2 = count($model_option);
235if ($num2) {
236 foreach ($model_option as $key) {
237 print '<tr class="oddeven value">';
238
239 // Param
240 $label = $key['label'];
241 print '<td>'.$langs->trans($label).'</td>';
242
243 // Value
244 print '<td>';
245 if (is_array($key['param'])) {
246 print $form->selectarray($label, $key['param'], getDolGlobalString($label), 0);
247 } else {
248 print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.getDolGlobalString($label).'">';
249 }
250
251 print '</td></tr>';
252 }
253
254 print "</table>\n";
255}
256
257print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans('Modify')).'" name="button"></div>';
258
259print '</form>';
260
261// End of page
262llxFooter();
263$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:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Manage the different format accountancy export.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.