diff --git a/aufmass_order.php b/aufmass_order.php new file mode 100644 index 0000000..b3a32f7 --- /dev/null +++ b/aufmass_order.php @@ -0,0 +1,97 @@ + + * 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 '
Auftrag nicht gefunden
'; + 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 '
'; +print '
'; + +// 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 '
'; + print '
'; + print '
'; + print 'Aufmaß für ' . dol_escape_htmltag($object->ref) . ''; + if (!empty($object->thirdparty->name)) { + print '
' . dol_escape_htmltag($object->thirdparty->name) . ''; + } + print '
'; + print ''; + print 'Aufmaß starten'; + print '
'; + print '
'; +} else { + print '
'; + print ' ElektroPlan PWA-URL nicht konfiguriert. '; + print 'Einstellungen öffnen'; + print '
'; +} + +// Verknüpfte Aufmaß-Daten (Platzhalter für Backend-Integration) +print ''; +print ''; +print ''; +print ''; + +// TODO: Hier Aufmaß-Daten aus dem ElektroPlan-Backend laden +// GET /api/projekte?dolibarr_auftrag_id={$object->id} + +print ''; + +print '
GrundrissEtageRäumeFlächeErstellt
'; +print 'Noch keine Aufmaße verknüpft. Starte ein neues Aufmaß über den Button oben.'; +print '
'; + +print '
'; // fichecenter +print dol_get_fiche_end(); +llxFooter(); +$db->close(); diff --git a/aufmass_thirdparty.php b/aufmass_thirdparty.php new file mode 100644 index 0000000..2930a1c --- /dev/null +++ b/aufmass_thirdparty.php @@ -0,0 +1,92 @@ + + * 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 '
Kunde nicht gefunden
'; + 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 '
'; +print '
'; + +// Aufträge des Kunden mit Aufmaß-Status +print ''; +print ''; +print ''; +print ''; + +// 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 ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } +} +if ($num == 0) { + print ''; +} + +print '
AuftragDatumAufmaße
'.dol_escape_htmltag($obj->ref).''.dol_print_date($db->jdate($obj->date_commande), 'day').''; + if (!empty($pwa_url)) { + $link = $pwa_url.'/?auftrag='.urlencode($obj->ref).'&kunde='.urlencode($object->name).'&auftrag_id='.$obj->rowid; + print 'Aufmaß'; + } + print '
'; + print 'Keine Aufträge für diesen Kunden.'; + print '
'; + +print '
'; +print dol_get_fiche_end(); +llxFooter(); +$db->close(); diff --git a/core/modules/modEplan.class.php b/core/modules/modEplan.class.php index 7a22f93..f9b76d7 100644 --- a/core/modules/modEplan.class.php +++ b/core/modules/modEplan.class.php @@ -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' => '', - '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' => '', + '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 = '') diff --git a/langs/de_DE/eplan.lang b/langs/de_DE/eplan.lang index 942f355..bf91f4a 100644 --- a/langs/de_DE/eplan.lang +++ b/langs/de_DE/eplan.lang @@ -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.