dolibarr 22.0.5
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25require_once '../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.'/imports/class/import.class.php';
27require_once DOL_DOCUMENT_ROOT.'/exports/class/export.class.php';
28
37// Load translation files required by the page
38$langs->load("exports");
39
40if (!$user->socid == 0) {
42}
43
44$export = new Export($db);
45$export->load_arrays($user);
46
47$import = new Import($db);
48$import->load_arrays($user);
49
50if (isModEnabled('import')) {
51 //$usercanimport = restrictedArea($user, 'import', 0, '', 'run');
52 $usercanimport = restrictedArea($user, 'import');
53}
54if (isModEnabled('export')) {
55 $usercanexport = restrictedArea($user, 'export');
56}
57
58
59/*
60 * View
61 */
62
63$form = new Form($db);
64
65$title = "ImportExportArea";
66if (isModEnabled('import') && !isModEnabled('export')) {
67 $title = "ImportArea";
68}
69if (!isModEnabled('import') && isModEnabled('export')) {
70 $title = "ExportsArea";
71}
72
73llxHeader('', $title, 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones');
74
75print load_fiche_titre($langs->trans($title));
76
77
78// List of available import format
79if (isModEnabled('import')) {
80 $out = '';
81 $out .= '<div class="div-table-responsive-no-min">';
82 $out .= '<table class="noborder centpercent nomarginbottom">';
83 $out .= '<tr class="liste_titre">';
84 $out .= '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
85 $out .= '<td>'.$langs->trans("LibraryShort").'</td>';
86 $out .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
87 $out .= '</tr>';
88
89 include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php';
90 $model = new ModeleImports();
91 $list = $model->listOfAvailableImportFormat($db);
92
93 foreach ($list as $key) {
94 $out .= '<tr class="oddeven">';
95 $out .= '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
96 $text = $model->getDriverDescForKey($key);
97 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
98 $out .= '<td>'.$form->textwithpicto($model->getDriverLabelForKey($key), $text).'</td>';
99 $out .= '<td>'.$model->getLibLabelForKey($key).'</td>';
100 $out .= '<td class="nowrap right">'.$model->getLibVersionForKey($key).'</td>';
101 $out .= '</tr>';
102 }
103
104 $out .= '</table>';
105 $out .= '</div>';
106
107 print '<div class="divsection wordwrap center">';
108 print '<br>';
109 print $form->textwithpicto($langs->trans("FormatedImportDesc1"), $out, 1, 'help', 'valignmiddle', 1, 3, 'ttimport').'<br>';
110 print '<br><br>';
111
112
113 print '<div class="center">';
114 if (count($import->array_import_code)) {
115 $params = array('forcenohideoftext' => 1);
116 print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle size4x', DOL_URL_ROOT.'/imports/import.php?leftmenu=import', '', 1, $params);
117 }
118 print '</div>';
119 print '<br>';
120
121 print '</div>';
122}
123
124
125// List of available export formats
126if (isModEnabled('export')) {
127 $out = '';
128 $out .= '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
129 $out .= '<table class="noborder centpercent nomarginbottom">';
130 $out .= '<tr class="liste_titre">';
131 $out .= '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
132 $out .= '<td>'.$langs->trans("LibraryShort").'</td>';
133 $out .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
134 $out .= '</tr>';
135
136 include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
137 $model = new ModeleExports($db);
138 $liste = $model->listOfAvailableExportFormat($db); // This is not a static method for exports because method load non static properties
139
140 foreach ($liste as $key => $val) {
141 if (preg_match('/__\‍(Disabled\‍)__/', $liste[$key])) {
142 $liste[$key] = preg_replace('/__\‍(Disabled\‍)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
143 }
144
145 $out .= '<tr class="oddeven">';
146 $out .= '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
147 $text = $model->getDriverDescForKey($key);
148 $label = $liste[$key];
149 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
150 $out .= '<td>'.$form->textwithpicto($label, $text).'</td>';
151 $out .= '<td>'.$model->getLibLabelForKey($key).'</td>';
152 $out .= '<td class="nowrap right">'.$model->getLibVersionForKey($key).'</td>';
153 $out .= '</tr>';
154 }
155
156 $out .= '</table>';
157 $out .= '</div>';
158
159
160 print '<div class="divsection wordwrap center">';
161 print '<br>';
162 print $form->textwithpicto($langs->trans("FormatedExportDesc1"), $out, 1, 'help', 'valignmiddle', 1, 3, 'ttexport').'<br>';
163 print '<br><br>';
164
165 print '<div class="center">';
166 if (count($export->array_export_code)) {
167 $params = array('forcenohideoftext' => 1);
168 print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle size4x', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', 1, $params);
169 }
170 print '</div>';
171 print '<br>';
172
173 print '</div>';
174}
175
176
177// End of page
178llxFooter();
179$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage exports.
Class to manage generation of HTML components Only common components must be here.
Class to manage imports.
Parent class for export modules.
Parent class for import file readers.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.