dolibarr/htdocs/admin/index.php

249 lines
8.8 KiB
PHP
Raw Normal View History

<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
2003-01-18 17:15:23 +00:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2003-01-18 17:15:23 +00:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 19:55:30 +00:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2003-01-18 17:15:23 +00:00
*/
/**
* \file htdocs/admin/index.php
2013-08-05 08:10:44 +00:00
* \brief Home page of setup area
*/
2022-09-07 18:08:59 +00:00
// Load Dolibarr environment
require '../main.inc.php';
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
2025-06-10 12:39:49 +00:00
* @var Societe $mysoc
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 22:53:20 +00:00
*/
2018-05-26 16:41:16 +00:00
// Load translation files required by the page
$langs->loadLangs(array('admin', 'companies'));
2022-09-12 09:06:55 +00:00
$action = '';
2021-02-26 21:04:03 +00:00
if (!$user->admin) {
accessforbidden();
}
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
2013-08-05 08:10:44 +00:00
$hookmanager->initHooks(array('homesetup'));
/*
2009-01-21 13:20:26 +00:00
* View
*/
$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-index');
2019-09-27 09:51:34 +00:00
print load_fiche_titre($langs->trans("SetupArea"), '', 'tools');
// Show
if (getDolGlobalString('MAIN_MOTD_SETUPPAGE')) {
2024-12-12 13:47:48 +00:00
$conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', getDolGlobalString('MAIN_MOTD_SETUPPAGE'));
if (getDolGlobalString('MAIN_MOTD_SETUPPAGE')) {
$i = 0;
2021-07-04 16:30:20 +00:00
$reg = array();
2024-12-12 13:47:48 +00:00
while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', getDolGlobalString('MAIN_MOTD_SETUPPAGE'), $reg) && $i < 100) {
$tmp = explode('|', $reg[1]);
2021-02-26 21:04:03 +00:00
if (!empty($tmp[1])) {
$langs->load($tmp[1]);
}
2025-10-25 20:53:09 +00:00
$conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/i', $langs->trans($tmp[0]), getDolGlobalString('MAIN_MOTD_SETUPPAGE'));
$i++;
}
print "\n<!-- Start of welcome text for setup page -->\n";
print '<table class="centpercent notopnoleftnoright"><tr><td>';
print dol_htmlentitiesbr(getDolGlobalString('MAIN_MOTD_SETUPPAGE'));
print '</td></tr></table><br>';
print "\n<!-- End of welcome text for setup page -->\n";
}
}
2020-05-10 22:35:05 +00:00
print '<span class="opacitymedium hideonsmartphone">';
2025-10-09 13:18:23 +00:00
print $langs->trans("SetupDescription1").'<br>';
2025-11-20 15:45:58 +00:00
if (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') || !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY') || getDolGlobalString('MAIN_INFO_SOCIETE_SETUP_TODO_WARNING')) {
$setupcompanynotcomplete = 1;
} else {
$setupcompanynotcomplete = 0;
}
if ($setupcompanynotcomplete) {
print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySetup"), $langs->transnoentities("Modules"));
}
2019-11-28 11:50:38 +00:00
print "<br><br>";
2020-05-10 22:35:05 +00:00
print '</span>';
2025-11-20 15:45:58 +00:00
// Show info depending on country if defined
$constkey = 'MAIN_INFO_SETUP_FOR_COUNTRY_'.$mysoc->country_code;
//$conf->global->$constkey = 'rrr';
if (getDolGlobalString($constkey)) {
$langs->load("errors");
$warnpicto = img_warning('', 'style="padding-right: 6px;"');
print '<div class="warning noshadow">'.$warnpicto.$langs->trans(getDolGlobalString($constkey)).'</div>';
}
2022-01-28 18:28:37 +00:00
print '<br>';
2013-08-05 08:10:44 +00:00
2013-08-05 08:10:44 +00:00
// Show info setup company
2025-02-24 12:03:45 +00:00
print '<section class="setupsection setupcompany cursorpointer">';
2022-01-28 18:28:37 +00:00
2025-06-10 16:12:07 +00:00
print img_picto('', 'company', 'class="paddingright valignmiddle double"');
print ' ';
2025-12-07 15:16:50 +00:00
print '<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>';
2021-10-19 17:52:18 +00:00
print '<br><br>';
print $langs->trans("SetupDescription3b");
2021-02-26 21:04:03 +00:00
if (!empty($setupcompanynotcomplete)) {
2012-10-18 08:36:53 +00:00
$langs->load("errors");
2026-03-12 00:54:19 +00:00
$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 10px;"');
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>';
}
2022-01-28 18:28:37 +00:00
2025-02-24 12:03:45 +00:00
print '</a>';
2022-01-28 18:28:37 +00:00
print '</section>';
print '<br>';
print '<br>';
2022-01-28 18:28:37 +00:00
// Show info setup modules
2025-02-24 12:03:45 +00:00
print '<section class="setupsection setupmodules cursorpointer">';
2013-08-05 08:10:44 +00:00
2024-06-19 16:21:19 +00:00
// Define $nbmodulesnotautoenabled - TODO This code is at different places
$nbmodulesnotautoenabled = count($conf->modules);
$listofmodulesautoenabled = array('user', 'agenda', 'fckeditor', 'export', 'import'); // All modules with ->enabled_bydefault to true (so enabled during install)
2024-06-19 16:21:19 +00:00
foreach ($listofmodulesautoenabled as $moduleautoenable) {
if (in_array($moduleautoenable, $conf->modules)) {
$nbmodulesnotautoenabled--;
}
2023-12-04 10:41:14 +00:00
}
2013-08-05 08:10:44 +00:00
// Show info setup module
2025-06-10 16:12:07 +00:00
print img_picto('', 'cog', 'class="paddingright valignmiddle double"');
print ' ';
2025-12-07 15:16:50 +00:00
print '<a class="nounderlineimp fontsize-1-1" href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules").'</a>';
2021-08-10 09:40:25 +00:00
print '<br><br>'.$langs->trans("SetupDescription4b");
if ($nbmodulesnotautoenabled < getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled
$langs->load("errors");
2026-03-12 00:54:19 +00:00
$warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 10px;"');
print '<br><div class="warning marginrightonly"><a class="warning" href="'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home">'.$warnpicto.$langs->trans("WarningEnableYourModulesApplications").'</a></div>';
}
2022-01-28 18:28:37 +00:00
print '</section>';
print '<br>';
print '<br>';
// Show info setup modules
$arrayofeinvoiceneed = array(
'FR' => array('module' => array('einvoice', 'pdpconnectfr'), 'search' => 'e-invoice'),
'ES' => array('search' => 'verifactu'),
'BE' => array('search' => 'peppol'),
'PL' => array('module' => array('ksef'), 'search' => 'ksef')
);
2026-05-21 20:40:04 +00:00
$urleinvoice = '';
if ($mysoc->country_code && in_array($mysoc->country_code, array_keys($arrayofeinvoiceneed))) {
$einvoiceneed = $arrayofeinvoiceneed[$mysoc->country_code];
$modulefound = '';
if (!empty($einvoiceneed['module'])) {
foreach ($einvoiceneed['module'] as $module) {
if (isModEnabled($module)) {
$modulefound = $module;
break;
}
}
}
if (!$modulefound) {
$urleinvoice = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace&search_keyword='.urlencode($einvoiceneed['search']);
} else {
$urleinvoice = DOL_URL_ROOT.'/admin/modules.php?search_keyword='.urlencode($modulefound);
}
print '<section class="setupsection setupeinvoice cursorpointer">';
// Show info setup module
print img_picto('', 'bill', 'class="paddingright valignmiddle double"');
print ' ';
print '<a class="nounderlineimp fontsize-1-1" href="'.$urleinvoice.'">'.$langs->transnoentities("EInvoice").'</a>';
2026-07-20 12:58:04 +00:00
if ($modulefound || getDolGlobalString('MAIN_FAKE_EINVOICE_MODULE_FOUND')) {
print '<br><br>'.$langs->trans("AnEInvoiceModuleHasBeenEnabled", $mysoc->country_code);
} else {
print '<br><br>'.$langs->trans("SetupDescriptionEInvoice", $mysoc->country_code);
}
print '</section>';
}
2009-08-20 01:39:54 +00:00
print '<br>';
2014-02-02 18:00:56 +00:00
print '<br>';
2025-02-24 12:03:45 +00:00
print '<script>
$(document).ready(function(){
$(".setupcompany").click(function() {
event.preventDefault();
console.log("we click on setupcompany");
window.location.href = "'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'";
});
$(".setupmodules").click(function() {
event.preventDefault();
console.log("we click on setupmodules");
window.location.href = "'.DOL_URL_ROOT.'/admin/modules.php?mainmenu=home";
});
$(".setupeinvoice").click(function() {
event.preventDefault();
console.log("we click on setupeinvoice");
window.location.href = "'.$urleinvoice.'";
});
2025-02-24 12:03:45 +00:00
});
</script>';
2013-08-05 08:10:44 +00:00
// Add hook to add information
$parameters = array();
2022-09-12 09:06:55 +00:00
$object = new stdClass();
$reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2013-08-05 08:10:44 +00:00
print $hookmanager->resPrint;
2021-02-26 21:04:03 +00:00
if (empty($reshook)) {
2013-08-05 08:10:44 +00:00
// Show into other
2022-09-12 09:06:55 +00:00
//print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("SetupDescription5")."</span><br>";
2021-10-05 06:55:57 +00:00
print '<br class="hideonsmartphone">';
2013-08-05 08:10:44 +00:00
// Show logo
2014-11-25 19:13:43 +00:00
print '<div class="center"><div class="logo_setup"></div></div>';
2013-08-05 08:10:44 +00:00
}
2003-01-18 17:15:23 +00:00
2018-07-28 16:03:14 +00:00
// End of page
llxFooter();
2013-01-10 17:50:07 +00:00
$db->close();