dolibarr 24.0.0-beta
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';
33require_once DOL_DOCUMENT_ROOT.'/imports/class/import.class.php';
34require_once DOL_DOCUMENT_ROOT.'/exports/class/export.class.php';
35
36// Load translation files required by the page
37$langs->loadLangs(array("exports", "other"));
38
39if (!$user->socid == 0) {
41}
42
43$export = new Export($db);
44$export->load_arrays($user);
45
46$import = new Import($db);
47$import->load_arrays($user);
48
49if (isModEnabled('import')) {
50 //$usercanimport = restrictedArea($user, 'import', 0, '', 'run');
51 $usercanimport = restrictedArea($user, 'import');
52}
53if (isModEnabled('export')) {
54 $usercanexport = restrictedArea($user, 'export');
55}
56
57
58/*
59 * View
60 */
61
62$form = new Form($db);
63
64$title = "ImportExportArea";
65if (isModEnabled('import') && !isModEnabled('export')) {
66 $title = "ImportArea";
67}
68if (!isModEnabled('import') && isModEnabled('export')) {
69 $title = "ExportsArea";
70}
71
72llxHeader('', $title, 'EN:Module_Imports_En|FR:Module_Imports|ES:M&oacute;dulo_Importaciones');
73
74print load_fiche_titre($langs->trans($title));
75
76
77// List of available import format
78if (isModEnabled('import')) {
79 $out = '';
80 $out .= '<div class="div-table-responsive-no-min">';
81 $out .= '<table class="noborder centpercent nomarginbottom">';
82 $out .= '<tr class="liste_titre">';
83 $out .= '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
84 $out .= '<td>'.$langs->trans("LibraryShort").'</td>';
85 $out .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
86 $out .= '</tr>';
87
88 include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.class.php';
89 $model = new ModeleImports();
90 $list = $model->listOfAvailableImportFormat($db);
91
92 foreach ($list as $key) {
93 $out .= '<tr class="oddeven">';
94 $out .= '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
95 $text = $model->getDriverDescForKey($key);
96 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
97 $out .= '<td>'.$form->textwithpicto($model->getDriverLabelForKey($key), $text).'</td>';
98 $out .= '<td>'.$model->getLibLabelForKey($key).'</td>';
99 $out .= '<td class="nowrap right">'.$model->getLibVersionForKey($key).'</td>';
100 $out .= '</tr>';
101 }
102
103 $out .= '</table>';
104 $out .= '</div>';
105
106 print '<div class="divsection wordwrap center">';
107 print '<br>';
108 print $form->textwithpicto($langs->trans("FormatedImportDesc1"), $out, 1, 'help', 'valignmiddle', 1, 3, 'ttimport').'<br>';
109 print '<br><br>';
110
111
112 print '<div class="center">';
113 if (count($import->array_import_code)) {
114 $params = array('forcenohideoftext' => 1);
115 print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle size4x', DOL_URL_ROOT.'/imports/import.php?leftmenu=import', '', 1, $params);
116 }
117 print '</div>';
118 print '<br>';
119
120 print '</div>';
121}
122
123
124// List of available export formats
125if (isModEnabled('export')) {
126 $out = '';
127 $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
128 $out .= '<table class="noborder centpercent nomarginbottom">';
129 $out .= '<tr class="liste_titre">';
130 $out .= '<td colspan="2">'.$langs->trans("AvailableFormats").'</td>';
131 $out .= '<td>'.$langs->trans("LibraryShort").'</td>';
132 $out .= '<td class="right">'.$langs->trans("LibraryVersion").'</td>';
133 $out .= '</tr>';
134
135 include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php';
136 $model = new ModeleExports($db);
137 $liste = $model->listOfAvailableExportFormat($db); // This is not a static method for exports because method load non static properties
138
139 foreach ($liste as $key => $val) {
140 if (preg_match('/__\‍(Disabled\‍)__/', $liste[$key])) {
141 $liste[$key] = preg_replace('/__\‍(Disabled\‍)__/', '('.$langs->transnoentitiesnoconv("Disabled").')', $liste[$key]);
142 }
143
144 $out .= '<tr class="oddeven">';
145 $out .= '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
146 $text = $model->getDriverDescForKey($key);
147 $label = $liste[$key];
148 // @phan-suppress-next-line PhanPluginSuspiciousParamPosition
149 $out .= '<td>'.$form->textwithpicto($label, $text).'</td>';
150 $out .= '<td>'.$model->getLibLabelForKey($key).'</td>';
151 $out .= '<td class="nowrap right">'.$model->getLibVersionForKey($key).'</td>';
152 $out .= '</tr>';
153 }
154
155 $out .= '</table>';
156 $out .= '</div>';
157
158
159 print '<div class="divsection wordwrap center">';
160 print '<br>';
161 print $form->textwithpicto($langs->trans("FormatedExportDesc1"), $out, 1, 'help', 'valignmiddle', 1, 3, 'ttexport').'<br>';
162 print '<br><br>';
163
164 print '<div class="center">';
165 if (count($export->array_export_code)) {
166 $params = array('forcenohideoftext' => 1);
167 print dolGetButtonTitle($langs->trans('NewExport'), '', 'fa fa-plus-circle size4x', DOL_URL_ROOT.'/exports/export.php?leftmenu=export', '', 1, $params);
168 }
169 print '</div>';
170 print '<br>';
171
172 print '</div>';
173}
174
175
176// End of page
177llxFooter();
178$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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
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.