60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
// Verzeichnis wechseln, damit relative Pfade in base.class.php korrekt aufgelöst werden
|
|
chdir('/var/www/vhosts/newmail.intelectra.de/httpdocs');
|
|
|
|
// base.class.php einbinden
|
|
require_once './core/base.class.php';
|
|
|
|
// Instanz der Base-Klasse erstellen
|
|
$base = new base();
|
|
|
|
// Zugriff auf die Datenbankverbindung
|
|
$db = $base->db;
|
|
|
|
// Parameter prüfen
|
|
if (!isset($_GET['offset']) || !isset($_GET['limit']) || !isset($_GET['articleId'])) {
|
|
http_response_code(400);
|
|
echo json_encode(['error' => 'Invalid parameters']);
|
|
exit;
|
|
}
|
|
|
|
$offset = (int)$_GET['offset'];
|
|
$limit = (int)$_GET['limit'];
|
|
$articleId = $db->real_escape_string($_GET['articleId']);
|
|
|
|
// Ergebnisse initialisieren
|
|
$data = [];
|
|
|
|
// SQL-Abfrage
|
|
$sql = "SELECT g.*, i.name as item_name, s2.name as parent_wg
|
|
FROM krempl_geraete_22 g
|
|
INNER JOIN krempl_artikelgeraet_22 ag ON g.id = ag.geraet
|
|
INNER JOIN krempl_passendwie pw ON ag.ersatzteil = pw.id
|
|
INNER JOIN items i ON pw.navisionid = i.krempl_id
|
|
LEFT JOIN item_structure_assign isa ON isa.item_id = i.id
|
|
LEFT JOIN structure s ON s.id = isa.structure_id
|
|
LEFT JOIN structure s2 ON s2.id = s.parent_id
|
|
WHERE i.number = '$articleId' AND s.active = 1
|
|
LIMIT $limit OFFSET $offset;";
|
|
$result = $db->query($sql);
|
|
|
|
if ($result) {
|
|
while ($row = $result->fetch_assoc()) {
|
|
$data[] = [
|
|
'bezeichnungoriginal' => $row['bezeichnungoriginal'] ?? '-',
|
|
'nr' => $row['nr'] ?? 'N/A',
|
|
'produktionsstart' => $row['produktionsstart'] ?? '',
|
|
'produktionsende' => $row['produktionsende'] ?? '',
|
|
'item_name' => $row['item_name'] ?? '',
|
|
'parent_wg' => $row['parent_wg'] ?? '',
|
|
];
|
|
}
|
|
}
|
|
|
|
// JSON-Ausgabe
|
|
header('Content-Type: application/json');
|
|
echo json_encode([
|
|
'data' => $data,
|
|
'hasMore' => count($data) === $limit,
|
|
]);
|
|
exit; |