Title Changes: - App title: "L'Oréal OMG Assistant Global" - Tab 1: "Master Global Asset Submission" - Upload button: "Approve & Upload to OMG" Preview Enhancements: - Dropdown selector to preview all 16 CSV files individually - Shows filename with ISO code (e.g., "en-GB - OMG1601654_...") - Switch between files to view complete data for each - Show ALL rows (not just first 20) Download Features: - "Download Current File" - Download the currently previewed CSV - "Download All Files (ZIP)" - Download all 16 CSVs as a ZIP archive - get-csv-preview.php: Endpoint to fetch any file for preview - download-all-csv.php: Creates ZIP with all CSVs UX Improvements: - File selector styled with brand colors - Clear labeling of which file is being previewed - Easy navigation between all regional CSVs - Test before upload with full data visibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Download All CSV Files as ZIP
|
|
*/
|
|
|
|
session_start();
|
|
|
|
// Check if processed data exists
|
|
if (!isset($_SESSION['processed_csv'])) {
|
|
http_response_code(404);
|
|
echo 'No processed data found';
|
|
exit;
|
|
}
|
|
|
|
$processedData = $_SESSION['processed_csv'];
|
|
$csvFiles = $processedData['files'];
|
|
$campaignNumber = $processedData['campaignNumber'];
|
|
$businessUnit = $processedData['businessUnit'];
|
|
|
|
// Create ZIP file
|
|
$zipFilename = "OMG{$campaignNumber}_{$businessUnit}_AllFiles_" . time() . ".zip";
|
|
$zipPath = sys_get_temp_dir() . '/' . $zipFilename;
|
|
|
|
$zip = new ZipArchive();
|
|
|
|
if ($zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== TRUE) {
|
|
http_response_code(500);
|
|
echo 'Failed to create ZIP file';
|
|
exit;
|
|
}
|
|
|
|
// Add each CSV to the ZIP
|
|
foreach ($csvFiles as $csvFile) {
|
|
$zip->addFromString($csvFile['filename'], $csvFile['content']);
|
|
}
|
|
|
|
$zip->close();
|
|
|
|
// Set headers for download
|
|
header('Content-Type: application/zip');
|
|
header('Content-Disposition: attachment; filename="' . $zipFilename . '"');
|
|
header('Content-Length: ' . filesize($zipPath));
|
|
|
|
// Output file
|
|
readfile($zipPath);
|
|
|
|
// Clean up temp file
|
|
unlink($zipPath);
|