diff --git a/export_html.php b/export_html.php index 8be546b..b0de847 100644 --- a/export_html.php +++ b/export_html.php @@ -33,141 +33,104 @@ try { die("Erro ao acessar o banco de dados: " . $e->getMessage()); } -// 5. Gerar o nome do arquivo para download +// --- Início da Geração MHTML --- + +$boundary = "----=" . md5(uniqid(time())); $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"); +// Cabeçalhos principais para MHTML +header("Content-Type: multipart/related; boundary=\"$boundary\""); 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 -?> +// Parte 1: Conteúdo HTML +$html_content = <<
- -| ID da Instalação | -- |
| Cliente | -- |
| Endereço | -- |
| Técnico Responsável | -- |
| Data | -- |
| Status | -- |
| ID da Instalação | {htmlspecialchars($installation['id'])} |
| Cliente | {htmlspecialchars($installation['client_name'])} |
| Endereço | {htmlspecialchars($installation['address'])} |
| Técnico Responsável | {htmlspecialchars($installation['technician_name'])} |
| Data | {date("d/m/Y H:i", strtotime($installation['created_at']))} |
| Status | {ucfirst(htmlspecialchars($installation['status']))} |
| Tensão (V) | -- |
| Fase-Neutro-Terra | -- |
| Saída do Disjuntor | -- |
| Tensão (V) | {htmlspecialchars($installation['voltage'] ?? 'N/A')} |
| Fase-Neutro-Terra | {htmlspecialchars($installation['phase_neutral_ground'] ?? 'N/A')} |
| Saída do Disjuntor | {htmlspecialchars($installation['breaker_output'] ?? 'N/A')} |
{nl2br(htmlspecialchars($installation['observations'] ?? 'Nenhuma observação.'))}
+HTML; - -Imagem não encontrada no caminho: ' . htmlspecialchars($image['image_path']) . '
'; - } - ?> -