prepare("SELECT * FROM installations WHERE id = :id");
$stmt->bindParam(':id', $installation_id, PDO::PARAM_INT);
$stmt->execute();
$installation = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$installation) {
die("Instalação não encontrada.");
}
// 4. Buscar imagens da instalação
$img_stmt = $pdo->prepare("SELECT image_path FROM installation_images WHERE installation_id = :id ORDER BY id ASC");
$img_stmt->bindParam(':id', $installation_id, PDO::PARAM_INT);
$img_stmt->execute();
$images = $img_stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
die("Erro ao acessar o banco de dados: " . $e->getMessage());
}
// 5. Gerar o nome do arquivo para download
$filename = "instalacao_" . $installation['id'] . "_" . str_replace(' ', '_', $installation['client_name']) . ".doc";
// 6. Enviar cabeçalhos para forçar o download
header("Content-Type: application/vnd.ms-word");
header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// 7. Iniciar a geração do conteúdo HTML
?>
Relatório de Instalação -
Relatório de Instalação
Detalhes do Cliente e Instalação
| ID da Instalação |
|
| Cliente |
|
| Endereço |
|
| Técnico Responsável |
|
| Data |
|
| Status |
|
Detalhes Técnicos
| Potência do Carregador (kW) |
|
| Tensão da Rede (V) |
|
| Tipo de Disjuntor |
|
| Número de Série |
|
Observações
Imagens da Instalação
';
}
?>