All checks were successful
Deploy Eplan / deploy (push) Successful in 1s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
126 lines
5.3 KiB
PHP
126 lines
5.3 KiB
PHP
<?php
|
|
/* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
|
* GPL v3+
|
|
*
|
|
* Tab "Aufmaß" auf der Auftragskarte
|
|
*/
|
|
|
|
$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.'/commande/class/commande.class.php';
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
|
|
|
|
$langs->loadLangs(array('orders', 'eplan@eplan'));
|
|
|
|
$id = GETPOSTINT('id');
|
|
$ref = GETPOST('ref', 'alpha');
|
|
|
|
$object = new Commande($db);
|
|
if ($id > 0 || !empty($ref)) {
|
|
$object->fetch($id, $ref);
|
|
}
|
|
|
|
if (!$object->id) {
|
|
llxHeader('', 'Aufmaß');
|
|
print '<div class="error">Auftrag nicht gefunden</div>';
|
|
llxFooter();
|
|
exit;
|
|
}
|
|
|
|
$pwa_url = getDolGlobalString('EPLAN_PWA_URL');
|
|
|
|
// Sicherheit
|
|
if (!$user->hasRight('eplan', 'read')) accessforbidden();
|
|
|
|
llxHeader('', 'Aufmaß — '.$object->ref, '', '', 0, 0, '', '', '', 'mod-eplan');
|
|
|
|
// Auftrag-Header + Tabs
|
|
$head = commande_prepare_head($object);
|
|
print dol_get_fiche_head($head, 'aufmass', $langs->trans("Order"), -1, 'order');
|
|
|
|
// Auftrag-Info-Leiste
|
|
dol_banner_tab($object, 'ref', '', 1, 'ref', 'ref');
|
|
|
|
print '<div class="fichecenter">';
|
|
print '<div class="underbanner clearboth"></div>';
|
|
|
|
// PWA-Link mit Auftrags-Kontext
|
|
if (!empty($pwa_url)) {
|
|
$pwa_link = $pwa_url . '/?auftrag=' . urlencode($object->ref) . '&kunde=' . urlencode($object->thirdparty->name ?? '') . '&auftrag_id=' . $object->id;
|
|
|
|
print '<div style="background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%); border-radius: 10px; padding: 20px; margin: 16px 0; color: #fff; box-sizing: border-box;">';
|
|
print '<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;">';
|
|
print '<div>';
|
|
print '<strong style="font-size: 16px;">Aufmaß für ' . dol_escape_htmltag($object->ref) . '</strong>';
|
|
if (!empty($object->thirdparty->name)) {
|
|
print '<br><span style="opacity: 0.8; font-size: 13px;">' . dol_escape_htmltag($object->thirdparty->name) . '</span>';
|
|
}
|
|
print '</div>';
|
|
print '<a href="' . dol_escape_htmltag($pwa_link) . '" target="_blank" rel="noopener" ';
|
|
print 'style="display: inline-block; background: #fff; color: #1565C0; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 700; text-decoration: none;">';
|
|
print '<i class="fas fa-drafting-compass" style="margin-right: 6px;"></i>Aufmaß starten</a>';
|
|
print '</div>';
|
|
print '</div>';
|
|
} else {
|
|
print '<div class="warning" style="margin: 16px 0;">';
|
|
print '<i class="fas fa-exclamation-triangle"></i> ElektroPlan PWA-URL nicht konfiguriert. ';
|
|
print '<a href="' . dol_buildpath('/eplan/admin/setup.php', 1) . '">Einstellungen öffnen</a>';
|
|
print '</div>';
|
|
}
|
|
|
|
// Verknüpfte Aufmaß-Daten (Platzhalter für Backend-Integration)
|
|
print '<table class="noborder centpercent" style="margin-top: 16px;">';
|
|
print '<tr class="liste_titre">';
|
|
print '<td>Grundriss</td><td>Etage</td><td>Räume</td><td>Fläche</td><td>Erstellt</td><td></td>';
|
|
print '</tr>';
|
|
|
|
// Aufmaß-Daten aus dem ElektroPlan-Backend laden
|
|
$api_url = getDolGlobalString('EPLAN_PWA_URL');
|
|
$raeume = array();
|
|
if (!empty($api_url)) {
|
|
$ch = curl_init($api_url.'/api/projekte/');
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
|
|
$response = curl_exec($ch);
|
|
curl_close($ch);
|
|
if ($response) {
|
|
$projekte = json_decode($response, true);
|
|
if (is_array($projekte)) {
|
|
// TODO: Filter nach dolibarr_auftrag_id wenn Backend das unterstützt
|
|
foreach ($projekte as $p) {
|
|
print '<tr class="oddeven">';
|
|
print '<td>'.dol_escape_htmltag($p['name'] ?? '-').'</td>';
|
|
print '<td>-</td>';
|
|
print '<td>-</td>';
|
|
print '<td>-</td>';
|
|
print '<td>'.dol_print_date(strtotime($p['erstellt'] ?? ''), 'day').'</td>';
|
|
print '<td class="right">';
|
|
if (!empty($pwa_url)) {
|
|
print '<a href="'.dol_escape_htmltag($pwa_url.'/?projekt='.$p['id']).'" target="_blank" class="butAction butActionSmall">Öffnen</a>';
|
|
}
|
|
print '</td>';
|
|
print '</tr>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (empty($raeume) && empty($projekte)) {
|
|
print '<tr class="oddeven"><td colspan="6" class="opacitymedium" style="text-align: center; padding: 20px;">';
|
|
print 'Noch keine Aufmaße verknüpft. Starte ein neues Aufmaß über den Button oben.';
|
|
print '</td></tr>';
|
|
}
|
|
|
|
print '</table>';
|
|
|
|
print '</div>'; // fichecenter
|
|
print dol_get_fiche_end();
|
|
llxFooter();
|
|
$db->close();
|