All checks were successful
Deploy Eplan / deploy (push) Successful in 1s
require main.inc.php funktioniert nicht bei Volume-Mounts. Jetzt Standard-Pattern mit CONTEXT_DOCUMENT_ROOT + Fallbacks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
101 lines
5 KiB
PHP
101 lines
5 KiB
PHP
<?php
|
|
/* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
|
* GPL v3+
|
|
*/
|
|
|
|
$res = 0;
|
|
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
|
|
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
|
|
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; }
|
|
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
|
|
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
|
|
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
|
|
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
|
|
if (!$res) die("Include of main fails");
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
dol_include_once('/eplan/lib/eplan.lib.php');
|
|
|
|
$langs->loadLangs(array('admin', 'eplan@eplan'));
|
|
|
|
if (!$user->admin && !$user->hasRight('eplan', 'admin')) {
|
|
accessforbidden();
|
|
}
|
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
|
|
if ($action == 'save' && $user->admin) {
|
|
$pwa_url = GETPOST('EPLAN_PWA_URL', 'alpha');
|
|
$pwa_url = rtrim($pwa_url, '/');
|
|
dolibarr_set_const($db, 'EPLAN_PWA_URL', $pwa_url, 'chaine', 0, '', $conf->entity);
|
|
setEventMessages($langs->trans("EplanSettingsSaved"), null, 'mesgs');
|
|
header("Location: ".$_SERVER['PHP_SELF']);
|
|
exit;
|
|
}
|
|
|
|
$page_name = "EplanSetup";
|
|
llxHeader('', $langs->trans($page_name), '', '', 0, 0, '', '', '', 'mod-eplan page-admin-setup');
|
|
|
|
$head = eplanAdminPrepareHead();
|
|
print dol_get_fiche_head($head, 'settings', $langs->trans("EplanSetup"), -1, 'fa-drafting-compass');
|
|
|
|
$pwa_url = getDolGlobalString('EPLAN_PWA_URL');
|
|
|
|
print '<div class="div-table-responsive-no-min">';
|
|
|
|
if (!empty($pwa_url)) {
|
|
print '<div style="background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%); border-radius: 12px; padding: 30px; margin-bottom: 24px; color: #fff;">';
|
|
print '<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;">';
|
|
print '<div>';
|
|
print '<h2 style="margin: 0 0 8px; font-size: 22px; font-weight: 700;">ElektroPlan</h2>';
|
|
print '<p style="margin: 0 0 4px; opacity: 0.9; font-size: 14px;">'.$langs->trans("EplanOpenPwaDesc").'</p>';
|
|
print '<p style="margin: 0; opacity: 0.7; font-size: 12px;"><i class="fas fa-mobile-alt"></i> '.$langs->trans("EplanInstallHint").'</p>';
|
|
print '</div>';
|
|
print '<div>';
|
|
print '<a href="'.dol_escape_htmltag($pwa_url).'" target="_blank" rel="noopener" ';
|
|
print 'style="display: inline-block; background: #fff; color: #1565C0; padding: 14px 32px; border-radius: 8px; font-size: 16px; font-weight: 700; text-decoration: none;">';
|
|
print '<i class="fas fa-external-link-alt" style="margin-right: 8px;"></i>';
|
|
print $langs->trans("EplanOpenPwa");
|
|
print '</a>';
|
|
print '</div>';
|
|
print '</div>';
|
|
print '</div>';
|
|
} else {
|
|
print '<div class="warning" style="margin-bottom: 20px;">';
|
|
print '<i class="fas fa-exclamation-triangle"></i> ';
|
|
print $langs->trans("EplanNotConfigured");
|
|
print '</div>';
|
|
}
|
|
|
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
print '<input type="hidden" name="action" value="save">';
|
|
print '<table class="noborder centpercent">';
|
|
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
|
print '<tr class="oddeven"><td class="titlefield">';
|
|
print '<strong>'.$langs->trans("EplanPwaUrl").'</strong>';
|
|
print '<br><span class="opacitymedium small">'.$langs->trans("EplanPwaUrlDesc").'</span>';
|
|
print '</td><td>';
|
|
print '<input type="url" name="EPLAN_PWA_URL" value="'.dol_escape_htmltag($pwa_url).'" ';
|
|
print 'placeholder="'.$langs->trans("EplanPwaUrlPlaceholder").'" style="width: 100%; max-width: 500px;" class="flat">';
|
|
print '</td></tr>';
|
|
print '</table>';
|
|
print '<div class="center" style="margin-top: 16px;">';
|
|
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
|
print '</div>';
|
|
print '</form>';
|
|
|
|
print '<br><div class="fichecenter"><div class="underbanner clearboth"></div>';
|
|
print '<table class="border centpercent tableforfield">';
|
|
print '<tr><td class="titlefield" colspan="2"><strong>'.$langs->trans("EplanAbout").'</strong></td></tr>';
|
|
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("EplanAboutText").'</td></tr>';
|
|
print '<tr><td class="titlefield" colspan="2"><strong>'.$langs->trans("EplanFeatures").'</strong></td></tr>';
|
|
for ($i = 1; $i <= 5; $i++) {
|
|
print '<tr class="oddeven"><td colspan="2"><i class="fas fa-check" style="color: #4CAF50; margin-right: 8px;"></i>';
|
|
print $langs->trans("EplanFeature".$i).'</td></tr>';
|
|
}
|
|
print '</table></div></div>';
|
|
|
|
print dol_get_fiche_end();
|
|
llxFooter();
|
|
$db->close();
|