exec("SELECT file_path FROM pmsi.p_imports_data WHERE import_id = $import_id AND data_type = '$data_type' AND data_num = 0"); if ($result != false) { $record = $database->nextRecordInto(); if ($record != FALSE) { $file_name = trim($record[0]); $ok_import = TRUE; } } if ($ok_import == TRUE) { if ($file_name == "") { $file_name = "$data_type.txt"; } header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: text/plain"); header("Content-Disposition: attachment;filename=\"" . basename($file_name) . "\""); $result = $database->exec("SELECT data FROM pmsi.p_imports_data WHERE import_id = $import_id AND data_type IN ('$data_type', '$data_type2') ORDER by data_num "); $ok = TRUE; while ($ok == TRUE) { $ok = FALSE; $record = pg_fetch_array($result); if ($record != FALSE) { $ok = TRUE; $data = $record[0]; echo uncompress(pg_unescape_bytea($data)); } } } else { header("X-PHP-Response-Code: 404", true, 404); echo "Pas de fichier $data_type pour le rapport n° $import_id "; } ?>