kundenkarte/ajax/medium_types.php
data 844e6060c6 feat(pwa): Offline-fähige Progressive Web App für Elektriker
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>
2026-02-23 15:27:06 +01:00

119 lines
3.2 KiB
PHP
Executable file

<?php
/* Copyright (C) 2026 Alles Watt lauft
*
* AJAX endpoint for medium types (Kabeltypen)
*/
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/mediumtype.class.php');
header('Content-Type: application/json; charset=UTF-8');
$langs->loadLangs(array('kundenkarte@kundenkarte'));
$action = GETPOST('action', 'aZ09');
$systemId = GETPOSTINT('system_id');
$response = array('success' => false, 'error' => '');
// Security check
if (!$user->hasRight('kundenkarte', 'read')) {
$response['error'] = $langs->trans('ErrorPermissionDenied');
echo json_encode($response);
exit;
}
$mediumType = new MediumType($db);
switch ($action) {
case 'list':
// Get all medium types for a system (or all)
$types = $mediumType->fetchAllBySystem($systemId, 1);
$result = array();
foreach ($types as $t) {
$specs = $t->getAvailableSpecsArray();
$result[] = array(
'id' => $t->id,
'ref' => $t->ref,
'label' => $t->label,
'label_short' => $t->label_short,
'category' => $t->category,
'category_label' => $t->getCategoryLabel(),
'fk_system' => $t->fk_system,
'system_label' => $t->system_label,
'default_spec' => $t->default_spec,
'available_specs' => $specs,
'color' => $t->color
);
}
$response['success'] = true;
$response['types'] = $result;
break;
case 'list_grouped':
// Get types grouped by category
$grouped = $mediumType->fetchGroupedByCategory($systemId);
$result = array();
foreach ($grouped as $category => $types) {
$catTypes = array();
foreach ($types as $t) {
$catTypes[] = array(
'id' => $t->id,
'ref' => $t->ref,
'label' => $t->label,
'label_short' => $t->label_short,
'default_spec' => $t->default_spec,
'available_specs' => $t->getAvailableSpecsArray(),
'color' => $t->color
);
}
$result[] = array(
'category' => $category,
'category_label' => $types[0]->getCategoryLabel(),
'types' => $catTypes
);
}
$response['success'] = true;
$response['groups'] = $result;
break;
case 'get':
// Get single type details
$typeId = GETPOSTINT('type_id');
if ($typeId > 0 && $mediumType->fetch($typeId) > 0) {
$response['success'] = true;
$response['type'] = array(
'id' => $mediumType->id,
'ref' => $mediumType->ref,
'label' => $mediumType->label,
'label_short' => $mediumType->label_short,
'category' => $mediumType->category,
'category_label' => $mediumType->getCategoryLabel(),
'default_spec' => $mediumType->default_spec,
'available_specs' => $mediumType->getAvailableSpecsArray(),
'color' => $mediumType->color,
'description' => $mediumType->description
);
} else {
$response['error'] = $langs->trans('ErrorRecordNotFound');
}
break;
default:
$response['error'] = 'Unknown action';
}
echo json_encode($response);