false, 'error' => 'Missing parameters']); exit; } $tables = DocumentTypeHelper::getTableNames($docType); if (!$tables) { echo json_encode(['exists' => false, 'error' => 'Invalid document type']); exit; } // Prüfe ob Subtotal in Manager-Tabelle existiert $sql = "SELECT rowid, ".$tables['fk_line']." as detail_id, in_facturedet FROM ".MAIN_DB_PREFIX."facture_lines_manager"; $sql .= " WHERE parent_section = ".(int)$section_id; $sql .= " AND line_type = 'subtotal'"; $sql .= " AND document_type = '".$db->escape($docType)."'"; $resql = $db->query($sql); $exists = false; $subtotal_id = null; $detail_id = null; $in_facturedet = false; if ($resql && $db->num_rows($resql) > 0) { $obj = $db->fetch_object($resql); $exists = true; $subtotal_id = $obj->rowid; $detail_id = $obj->detail_id; $in_facturedet = $obj->in_facturedet ? true : false; } echo json_encode([ 'exists' => $exists, 'subtotal_id' => $subtotal_id, 'detail_id' => $detail_id, 'in_facturedet' => $in_facturedet ]);