dolibarr 25.0.0-alpha
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
5 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2026 Joachim Kueter <git-jk@bloxera.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
27// Load Dolibarr environment
28require '../main.inc.php';
38// Load translation files required by the page
39$langs->loadLangs(array('admin', 'bills', 'companies'));
40
41$action = '';
42
43if (!$user->admin) {
45}
46
47// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
48$hookmanager->initHooks(array('homesetup'));
49
50
51/*
52 * View
53 */
54
55$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
56llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-index');
57
58
59print load_fiche_titre($langs->trans("SetupArea"), '', 'tools');
60
61// Show
62if (getDolGlobalString('MAIN_MOTD_SETUPPAGE')) {
63 $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', getDolGlobalString('MAIN_MOTD_SETUPPAGE'));
64 if (getDolGlobalString('MAIN_MOTD_SETUPPAGE')) {
65 $i = 0;
66 $reg = array();
67 while (preg_match('/__\‍(([a-zA-Z|@]+)\‍)__/i', getDolGlobalString('MAIN_MOTD_SETUPPAGE'), $reg) && $i < 100) {
68 $tmp = explode('|', $reg[1]);
69 if (!empty($tmp[1])) {
70 $langs->load($tmp[1]);
71 }
72 $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\‍('.preg_quote($reg[1], '/').'\‍)__/i', $langs->trans($tmp[0]), getDolGlobalString('MAIN_MOTD_SETUPPAGE'));
73 $i++;
74 }
75
76 print "\n<!-- Start of welcome text for setup page -->\n";
77 print '<table class="centpercent notopnoleftnoright"><tr><td>';
78 print dol_htmlentitiesbr(getDolGlobalString('MAIN_MOTD_SETUPPAGE'));
79 print '</td></tr></table><br>';
80 print "\n<!-- End of welcome text for setup page -->\n";
81 }
82}
83
84print '<span class="opacitymedium hideonsmartphone">';
85print $langs->trans("SetupDescription1").'<br>';
86
87if (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') || !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY') || getDolGlobalString('MAIN_INFO_SOCIETE_SETUP_TODO_WARNING')) {
88 $setupcompanynotcomplete = 1;
89} else {
90 $setupcompanynotcomplete = 0;
91}
92
93if ($setupcompanynotcomplete) {
94 print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySetup"), $langs->transnoentities("Modules"));
95}
96
97print "<br><br>";
98print '</span>';
99
100
101
102// Show info depending on country if defined
103$constkey = 'MAIN_INFO_SETUP_FOR_COUNTRY_'.$mysoc->country_code;
104//$conf->global->$constkey = 'rrr';
105if (getDolGlobalString($constkey)) {
106 $langs->load("errors");
107 $warnpicto = img_warning('', 'style="padding-right: 6px;"');
108 print '<div class="warning noshadow">'.$warnpicto.$langs->trans(getDolGlobalString($constkey)).'</div>';
109}
110
111
112print '<br>';
113
114
115// Show info setup company
116
117print '<section class="setupsection setupcompany cursorpointer">';
118
119print img_picto('', 'company', 'class="paddingright valignmiddle double"');
120print ' ';
121print '<a class="nounderlineimp fontsize-1-1" href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit&token='.newToken()).'">'.$langs->transnoentities("Setup").' - '.$langs->transnoentities("MenuCompanySetup").'</a>';
122print '<br><br>';
123print $langs->trans("SetupDescription3b");
124if (!empty($setupcompanynotcomplete)) {
125 $langs->load("errors");
126 $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 10px;"');
127 print '<br><div class="warning marginrightonly"><a class="warning" href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home&action=edit&token='.newToken().'">'.$warnpicto.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
128}
129
130print '</a>';
131print '</section>';
132
133print '<br>';
134print '<br>';
135
136
137// Show info setup modules
138
139print '<section class="setupsection setupmodules cursorpointer">';
140
141// Define $nbmodulesnotautoenabled - TODO This code is at different places
142$nbmodulesnotautoenabled = count($conf->modules);
143$listofmodulesautoenabled = array('user', 'agenda', 'fckeditor', 'export', 'import'); // All modules with ->enabled_bydefault to true (so enabled during install)
144foreach ($listofmodulesautoenabled as $moduleautoenable) {
145 if (in_array($moduleautoenable, $conf->modules)) {
146 $nbmodulesnotautoenabled--;
147 }
148}
149
150// Show info setup module
151print img_picto('', 'cog', 'class="paddingright valignmiddle double"');
152print ' ';
153print '<a class="nounderlineimp fontsize-1-1" href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules").'</a>';
154print '<br><br>'.$langs->trans("SetupDescription4b");
155if ($nbmodulesnotautoenabled < getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled
156 $langs->load("errors");
157 $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 10px;"');
158 print '<br><div class="warning marginrightonly"><a class="warning" href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$warnpicto.$langs->trans("WarningEnableYourModulesApplications").'</a></div>';
159}
160
161print '</section>';
162
163print '<br>';
164print '<br>';
165
166
167// Show info setup modules
168
169// A country has one entry, or one entry per direction ('issue', 'receive'). A module is found if it is in the 'module'
170// list of the entry, or if its descriptor declares the country (and direction):
171// $this->module_parts = array('einvoice' => array('DE' => array('issue', 'receive')));
172$arrayofeinvoiceneed = array(
173 'FR' => array('module' => array('einvoice', 'pdpconnectfr'), 'search' => 'e-invoice'),
174 'ES' => array('search' => 'verifactu'),
175 'BE' => array('search' => 'peppol'),
176 'PL' => array('module' => array('ksef'), 'search' => 'ksef'),
177 'DE' => array(
178 'issue' => array('label' => 'EInvoiceIssueCustomerInvoices', 'search' => 'einvoice-issue-de'),
179 'receive' => array('label' => 'EInvoiceReceiveSupplierInvoices', 'search' => 'einvoice-receive-de')
180 )
181);
182
183$urleinvoice = '';
184
185if ($mysoc->country_code && in_array($mysoc->country_code, array_keys($arrayofeinvoiceneed))) {
186 $einvoiceneeds = $arrayofeinvoiceneed[$mysoc->country_code];
187 if (isset($einvoiceneeds['search'])) {
188 $einvoiceneeds = array($einvoiceneeds);
189 }
190 $einvoicetext = '';
191 foreach ($einvoiceneeds as $direction => $einvoiceneed) {
192 $modules = empty($einvoiceneed['module']) ? array() : $einvoiceneed['module'];
193 foreach (empty($conf->modules_parts['einvoice']) ? array() : $conf->modules_parts['einvoice'] as $module => $declared) {
194 '@phan-var-force array<string,string[]>|string $declared';
195 if (is_array($declared) && !empty($declared[$mysoc->country_code]) && (is_int($direction) || in_array($direction, (array) $declared[$mysoc->country_code]))) {
196 $modules[] = $module;
197 }
198 }
199 $modulefound = '';
200 foreach ($modules as $module) {
201 if (isModEnabled($module)) {
202 $modulefound = $module;
203 break;
204 }
205 }
206 if (!$modulefound) {
207 $url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace&search_keyword='.urlencode($einvoiceneed['search']);
208 } else {
209 $url = DOL_URL_ROOT.'/admin/modules.php?search_keyword='.urlencode($modulefound);
210 }
211 if (!$modulefound || !$urleinvoice) { // The section leads to an entry without module
212 $urleinvoice = $url;
213 }
214 $einvoicetext .= '<br><br>'.(empty($einvoiceneed['label']) ? '' : $langs->trans($einvoiceneed['label']).': ');
215 if ($modulefound || getDolGlobalString('MAIN_FAKE_EINVOICE_MODULE_FOUND')) {
216 $einvoicetext .= $langs->trans("AnEInvoiceModuleHasBeenEnabled", $mysoc->country_code);
217 } else {
218 $einvoicetext .= $langs->trans("SetupDescriptionEInvoice", $mysoc->country_code);
219 }
220 }
221
222 print '<section class="setupsection setupeinvoice cursorpointer">';
223 // Show info setup module
224 print img_picto('', 'bill', 'class="paddingright valignmiddle double"');
225 print ' ';
226 print '<a class="nounderlineimp fontsize-1-1" href="'.$urleinvoice.'">'.$langs->transnoentities("EInvoice").'</a>';
227 print $einvoicetext;
228 print '</section>';
229}
230
231
232print '<br>';
233print '<br>';
234
235
236print '<script>
237 $(document).ready(function(){
238 $(".setupcompany").click(function() {
239 event.preventDefault();
240 console.log("we click on setupcompany");
241 window.location.href = "'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'";
242 });
243 $(".setupmodules").click(function() {
244 event.preventDefault();
245 console.log("we click on setupmodules");
246 window.location.href = "'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home";
247 });
248 $(".setupeinvoice").click(function() {
249 event.preventDefault();
250 console.log("we click on setupeinvoice");
251 window.location.href = "'.$urleinvoice.'";
252 });
253 });
254</script>';
255
256// Add hook to add information
257$parameters = array();
258$object = new stdClass();
259$reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
260print $hookmanager->resPrint;
261if (empty($reshook)) {
262 // Show into other
263 //print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("SetupDescription5")."</span><br>";
264 print '<br class="hideonsmartphone">';
265
266 // Show logo
267 print '<div class="center"><div class="logo_setup"></div></div>';
268}
269
270// End of page
271llxFooter();
272$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
global $mysoc
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.