PWA Mobile App für Schaltschrank-Dokumentation vor Ort: - Token-basierte Authentifizierung (15 Tage gültig) - Kundensuche mit Offline-Cache - Anlagen-Auswahl und Offline-Laden - Felder/Hutschienen/Automaten erfassen - Automatische Synchronisierung wenn wieder online - Installierbar auf dem Smartphone Home Screen - Touch-optimiertes Dark Mode Design - Quick-Select für Automaten-Werte (B16, C32, etc.) Schaltplan-Editor Verbesserungen: - Block Hover-Tooltip mit show_in_hover Feldern - Produktinfo mit Icon im Tooltip - Position und Breite in TE Neue Dateien: - pwa.php, pwa_auth.php - PWA Einstieg & Auth - ajax/pwa_api.php - PWA AJAX API - js/pwa.js, css/pwa.css - PWA App & Styles - sw.js, manifest.json - Service Worker & Manifest - img/pwa-icon-192.png, img/pwa-icon-512.png Version: 5.2.0 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
121 lines
3.3 KiB
PHP
Executable file
121 lines
3.3 KiB
PHP
Executable file
<?php
|
|
/* Copyright (C) 2026 Alles Watt lauft
|
|
*
|
|
* AJAX endpoint for building types (Gebäudetypen)
|
|
*/
|
|
|
|
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
|
|
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
|
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
|
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
|
|
|
$res = 0;
|
|
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");
|
|
|
|
dol_include_once('/kundenkarte/class/buildingtype.class.php');
|
|
|
|
header('Content-Type: application/json; charset=UTF-8');
|
|
|
|
$langs->loadLangs(array('kundenkarte@kundenkarte'));
|
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
$levelType = GETPOST('level_type', 'alpha');
|
|
|
|
$response = array('success' => false, 'error' => '');
|
|
|
|
// Security check
|
|
if (!$user->hasRight('kundenkarte', 'read')) {
|
|
$response['error'] = $langs->trans('ErrorPermissionDenied');
|
|
echo json_encode($response);
|
|
exit;
|
|
}
|
|
|
|
$buildingType = new BuildingType($db);
|
|
|
|
switch ($action) {
|
|
case 'list':
|
|
// Get all building types
|
|
$types = $buildingType->fetchAll(1, $levelType);
|
|
|
|
$result = array();
|
|
foreach ($types as $t) {
|
|
$result[] = array(
|
|
'id' => $t->id,
|
|
'ref' => $t->ref,
|
|
'label' => $t->label,
|
|
'label_short' => $t->label_short,
|
|
'level_type' => $t->level_type,
|
|
'level_type_label' => $t->getLevelTypeLabel(),
|
|
'icon' => $t->icon,
|
|
'color' => $t->color,
|
|
'can_have_children' => $t->can_have_children,
|
|
'is_system' => $t->is_system
|
|
);
|
|
}
|
|
|
|
$response['success'] = true;
|
|
$response['types'] = $result;
|
|
break;
|
|
|
|
case 'list_grouped':
|
|
// Get types grouped by level
|
|
$grouped = $buildingType->fetchGroupedByLevel(1);
|
|
|
|
$result = array();
|
|
$levelTypes = BuildingType::getLevelTypes();
|
|
|
|
foreach ($grouped as $level => $types) {
|
|
$levelLabel = isset($levelTypes[$level]) ? $levelTypes[$level] : $level;
|
|
$levelTypes_data = array();
|
|
foreach ($types as $t) {
|
|
$levelTypes_data[] = array(
|
|
'id' => $t->id,
|
|
'ref' => $t->ref,
|
|
'label' => $t->label,
|
|
'label_short' => $t->label_short,
|
|
'icon' => $t->icon,
|
|
'color' => $t->color,
|
|
'can_have_children' => $t->can_have_children
|
|
);
|
|
}
|
|
$result[] = array(
|
|
'level_type' => $level,
|
|
'level_type_label' => $levelLabel,
|
|
'types' => $levelTypes_data
|
|
);
|
|
}
|
|
|
|
$response['success'] = true;
|
|
$response['groups'] = $result;
|
|
break;
|
|
|
|
case 'get':
|
|
// Get single type details
|
|
$typeId = GETPOSTINT('type_id');
|
|
if ($typeId > 0 && $buildingType->fetch($typeId) > 0) {
|
|
$response['success'] = true;
|
|
$response['type'] = array(
|
|
'id' => $buildingType->id,
|
|
'ref' => $buildingType->ref,
|
|
'label' => $buildingType->label,
|
|
'label_short' => $buildingType->label_short,
|
|
'description' => $buildingType->description,
|
|
'level_type' => $buildingType->level_type,
|
|
'level_type_label' => $buildingType->getLevelTypeLabel(),
|
|
'icon' => $buildingType->icon,
|
|
'color' => $buildingType->color,
|
|
'can_have_children' => $buildingType->can_have_children,
|
|
'is_system' => $buildingType->is_system
|
|
);
|
|
} else {
|
|
$response['error'] = $langs->trans('ErrorRecordNotFound');
|
|
}
|
|
break;
|
|
|
|
default:
|
|
$response['error'] = 'Unknown action';
|
|
}
|
|
|
|
echo json_encode($response);
|