feat: Tabs Aufmaß auf Auftrag + Kundenkarte [deploy]
All checks were successful
Deploy Eplan / deploy (push) Successful in 1s
All checks were successful
Deploy Eplan / deploy (push) Successful in 1s
- Tab "Aufmaß" auf Auftragskarte: PWA-Link mit Auftrags-Kontext, Grundriss-Liste (Platzhalter für Backend-Anbindung) - Tab "Aufmaß" auf Kundenkarte: Aufträge des Kunden mit Aufmaß-Button - Neue Rechte: read, write, admin - Konstanten: EPLAN_TAB_ON_ORDER, EPLAN_TAB_ON_THIRDPARTY - Standard Dolibarr Include-Pattern für Container-Kompatibilität Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0286e6c7ec
commit
b2393b0385
4 changed files with 230 additions and 45 deletions
97
aufmass_order.php
Normal file
97
aufmass_order.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?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>';
|
||||
|
||||
// TODO: Hier Aufmaß-Daten aus dem ElektroPlan-Backend laden
|
||||
// GET /api/projekte?dolibarr_auftrag_id={$object->id}
|
||||
|
||||
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();
|
||||
92
aufmass_thirdparty.php
Normal file
92
aufmass_thirdparty.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
||||
* GPL v3+
|
||||
*
|
||||
* Tab "Aufmaß" auf der Kundenkarte
|
||||
*/
|
||||
|
||||
$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.'/societe/class/societe.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
|
||||
$langs->loadLangs(array('companies', 'eplan@eplan'));
|
||||
|
||||
$socid = GETPOSTINT('socid');
|
||||
|
||||
$object = new Societe($db);
|
||||
if ($socid > 0) {
|
||||
$object->fetch($socid);
|
||||
}
|
||||
|
||||
if (!$object->id) {
|
||||
llxHeader('', 'Aufmaß');
|
||||
print '<div class="error">Kunde nicht gefunden</div>';
|
||||
llxFooter();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$user->hasRight('eplan', 'read')) accessforbidden();
|
||||
|
||||
$pwa_url = getDolGlobalString('EPLAN_PWA_URL');
|
||||
|
||||
llxHeader('', 'Aufmaß — '.$object->name, '', '', 0, 0, '', '', '', 'mod-eplan');
|
||||
|
||||
$head = societe_prepare_head($object);
|
||||
print dol_get_fiche_head($head, 'aufmass', $langs->trans("ThirdParty"), -1, 'company');
|
||||
|
||||
dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
// Aufträge des Kunden mit Aufmaß-Status
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>Auftrag</td><td>Datum</td><td>Aufmaße</td><td></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Aufträge des Kunden laden
|
||||
$sql = "SELECT c.rowid, c.ref, c.date_commande FROM ".MAIN_DB_PREFIX."commande as c";
|
||||
$sql .= " WHERE c.fk_soc = ".((int)$object->id);
|
||||
$sql .= " ORDER BY c.date_commande DESC";
|
||||
$sql .= " LIMIT 20";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
$num = 0;
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
while ($obj = $db->fetch_object($resql)) {
|
||||
print '<tr class="oddeven">';
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->rowid.'">'.dol_escape_htmltag($obj->ref).'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->date_commande), 'day').'</td>';
|
||||
print '<td class="opacitymedium">—</td>';
|
||||
print '<td class="right">';
|
||||
if (!empty($pwa_url)) {
|
||||
$link = $pwa_url.'/?auftrag='.urlencode($obj->ref).'&kunde='.urlencode($object->name).'&auftrag_id='.$obj->rowid;
|
||||
print '<a href="'.dol_escape_htmltag($link).'" target="_blank" class="butAction butActionSmall">Aufmaß</a>';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
if ($num == 0) {
|
||||
print '<tr class="oddeven"><td colspan="4" class="opacitymedium" style="text-align: center; padding: 16px;">';
|
||||
print 'Keine Aufträge für diesen Kunden.';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print dol_get_fiche_end();
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -3,11 +3,6 @@
|
|||
* GPL v3+ — siehe COPYING
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup eplan Module Eplan
|
||||
* \brief Verknüpfung zu ElektroPlan PWA — Raumaufmaß mit Bluetooth-Laser
|
||||
* \file htdocs/eplan/core/modules/modEplan.class.php
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
class modEplan extends DolibarrModules
|
||||
|
|
@ -22,34 +17,23 @@ class modEplan extends DolibarrModules
|
|||
$this->family = "other";
|
||||
$this->module_position = '91';
|
||||
$this->name = preg_replace('/^mod/i', '', get_class($this));
|
||||
$this->description = "Verknüpfung zur ElektroPlan PWA — Raumaufmaß mit Bluetooth-Laser direkt aus Dolibarr.";
|
||||
$this->descriptionlong = "Stellt einen Link zur ElektroPlan PWA im Admin-Menü bereit. Die PWA ermöglicht mobiles Raumaufmaß mit Finger-Skizze und Bosch GLM Bluetooth-Laser. Grundrisse können als PDF an Aufträge angehängt werden.";
|
||||
$this->description = "Aufmaß-Tab auf Aufträgen und Kundenkarten — Verknüpfung zur ElektroPlan PWA.";
|
||||
$this->descriptionlong = "Fügt Aufträgen und Kundenkarten einen Reiter 'Aufmaß' hinzu. Zeigt verknüpfte Grundrisse, öffnet die ElektroPlan PWA mit Auftrags-Kontext und ermöglicht PDF-Export direkt als Dolibarr-Dokument.";
|
||||
|
||||
$this->editor_name = 'Alles Watt läuft';
|
||||
$this->editor_url = '';
|
||||
$this->version = '1.0.0';
|
||||
$this->version = '1.1.0';
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
$this->picto = 'fa-drafting-compass';
|
||||
|
||||
$this->module_parts = array(
|
||||
'triggers' => 0,
|
||||
'login' => 0,
|
||||
'substitutions' => 0,
|
||||
'menus' => 0,
|
||||
'tpl' => 0,
|
||||
'barcode' => 0,
|
||||
'models' => 0,
|
||||
'printing' => 0,
|
||||
'theme' => 0,
|
||||
'css' => array(),
|
||||
'js' => array(),
|
||||
'hooks' => array(),
|
||||
'triggers' => 0, 'login' => 0, 'substitutions' => 0, 'menus' => 0,
|
||||
'tpl' => 0, 'barcode' => 0, 'models' => 0, 'printing' => 0,
|
||||
'theme' => 0, 'css' => array(), 'js' => array(), 'hooks' => array(),
|
||||
'moduleforexternal' => 0,
|
||||
);
|
||||
|
||||
$this->dirs = array();
|
||||
|
||||
// Admin-Setup-Seite
|
||||
$this->config_page_url = array("setup.php@eplan");
|
||||
|
||||
$this->hidden = false;
|
||||
|
|
@ -64,53 +48,58 @@ class modEplan extends DolibarrModules
|
|||
// Konstanten
|
||||
$this->const = array(
|
||||
0 => array('EPLAN_PWA_URL', 'chaine', '', 'URL zur ElektroPlan PWA', 0, 'current', 0),
|
||||
1 => array('EPLAN_TAB_ON_ORDER', 'chaine', '1', 'Tab Aufmaß auf Aufträgen', 0, 'current', 0),
|
||||
2 => array('EPLAN_TAB_ON_THIRDPARTY', 'chaine', '1', 'Tab Aufmaß auf Kundenkarten', 0, 'current', 0),
|
||||
);
|
||||
|
||||
// Tabs auf Auftrag + Kundenkarte
|
||||
$this->tabs = array(
|
||||
'order:+aufmass:Aufmaß:eplan@eplan:$user->hasRight("eplan","read"):/custom/eplan/aufmass_order.php?id=__ID__',
|
||||
'thirdparty:+aufmass:Aufmaß:eplan@eplan:$user->hasRight("eplan","read"):/custom/eplan/aufmass_thirdparty.php?socid=__ID__',
|
||||
);
|
||||
|
||||
// Rechte
|
||||
$this->rights = array();
|
||||
$r = 0;
|
||||
|
||||
$this->rights[$r][0] = $this->numero + 0; // 500037
|
||||
$this->rights[$r][1] = 'ElektroPlan PWA öffnen';
|
||||
$this->rights[$r][0] = $this->numero + 0;
|
||||
$this->rights[$r][1] = 'Aufmaß einsehen';
|
||||
$this->rights[$r][2] = 'r';
|
||||
$this->rights[$r][3] = 1;
|
||||
$this->rights[$r][4] = 'read';
|
||||
$r++;
|
||||
|
||||
$this->rights[$r][0] = $this->numero + 1; // 500038
|
||||
$this->rights[$r][1] = 'ElektroPlan Einstellungen verwalten';
|
||||
$this->rights[$r][0] = $this->numero + 1;
|
||||
$this->rights[$r][1] = 'Aufmaß bearbeiten';
|
||||
$this->rights[$r][2] = 'w';
|
||||
$this->rights[$r][3] = 1;
|
||||
$this->rights[$r][4] = 'write';
|
||||
$r++;
|
||||
|
||||
$this->rights[$r][0] = $this->numero + 2;
|
||||
$this->rights[$r][1] = 'Eplan Einstellungen verwalten';
|
||||
$this->rights[$r][2] = 'a';
|
||||
$this->rights[$r][3] = 0;
|
||||
$this->rights[$r][4] = 'admin';
|
||||
$r++;
|
||||
|
||||
// Menü-Einträge
|
||||
// Menü
|
||||
$this->menu = array();
|
||||
$r = 0;
|
||||
|
||||
$this->menu[$r] = array(
|
||||
'fk_menu' => 'fk_mainmenu=tools',
|
||||
'type' => 'left',
|
||||
'titre' => 'Eplan',
|
||||
'prefix' => '<i class="fas fa-drafting-compass pictofixedwidth"></i>',
|
||||
'mainmenu' => 'tools',
|
||||
'leftmenu' => 'eplan',
|
||||
'url' => '/custom/eplan/admin/setup.php',
|
||||
'langs' => 'eplan@eplan',
|
||||
'position' => 100,
|
||||
'enabled' => 'isModEnabled("eplan")',
|
||||
'perms' => '$user->hasRight("eplan","read")',
|
||||
'target' => '',
|
||||
'user' => 0,
|
||||
'fk_menu' => 'fk_mainmenu=tools', 'type' => 'left',
|
||||
'titre' => 'Eplan', 'prefix' => '<i class="fas fa-drafting-compass pictofixedwidth"></i>',
|
||||
'mainmenu' => 'tools', 'leftmenu' => 'eplan',
|
||||
'url' => '/custom/eplan/admin/setup.php', 'langs' => 'eplan@eplan',
|
||||
'position' => 100, 'enabled' => 'isModEnabled("eplan")',
|
||||
'perms' => '$user->hasRight("eplan","read")', 'target' => '', 'user' => 0,
|
||||
);
|
||||
$r++;
|
||||
}
|
||||
|
||||
public function init($options = '')
|
||||
{
|
||||
$result = $this->_load_tables('/install/mysql/', 'eplan');
|
||||
$result = $this->_init(array(), $options);
|
||||
return $result;
|
||||
$this->_load_tables('/install/mysql/', 'eplan');
|
||||
return $this->_init(array(), $options);
|
||||
}
|
||||
|
||||
public function remove($options = '')
|
||||
|
|
|
|||
|
|
@ -22,3 +22,10 @@ EplanFeature2 = Bluetooth-Laser (Bosch GLM) für exakte Maße
|
|||
EplanFeature3 = Offline-fähig — funktioniert ohne Internet
|
||||
EplanFeature4 = PDF- und DXF-Export (CAD-kompatibel)
|
||||
EplanFeature5 = Mehrere Räume pro Projekt vermessen
|
||||
|
||||
# Tabs
|
||||
Aufmaß = Aufmaß
|
||||
EplanStartAufmass = Aufmaß starten
|
||||
EplanKeinePwa = ElektroPlan PWA-URL nicht konfiguriert.
|
||||
EplanKeineAufmasse = Noch keine Aufmaße verknüpft. Starte ein neues Aufmaß über den Button oben.
|
||||
EplanKeineAuftraege = Keine Aufträge für diesen Kunden.
|
||||
|
|
|
|||
Loading…
Reference in a new issue