loreal-global-kickoff/download-csv.php
DJP 5c6cf687a8 Update Global to Local to create 16 separate CSV files and fix PHP compatibility
Key Changes:
- Fixed CSV transformation to create 16 separate files (one per ISO code)
- Each CSV has all input rows with Language/Country replaced
- Handles Excel Sep=, prefix correctly
- Parses date format "24 Mar 2025 00:00" from sample CSV
- Skip OMG API for testing (use business unit "TESTING")
- Upload all 16 CSVs to Box folder
- Show list of all files in preview
- Download preview functionality

PHP Compatibility:
- Downgraded nesbot/carbon to ^2.0 (supports PHP 7.1+)
- Downgraded league/csv to 9.8.0 (supports PHP 7.4+)
- Now compatible with PHP 7.4-8.0 servers

Preview Enhancements:
- Shows all 16 filenames with ISO codes
- Preview table shows first file as sample
- Summary shows file count and total rows

Testing:
- Added sample CSV: Project_1601654_mediaBookings.csv
- OMG API lookup commented out (ready to enable later)
- Using "TESTING" as business unit

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 17:03:51 -05:00

34 lines
846 B
PHP

<?php
/**
* Download CSV Preview
* Allows downloading processed CSV files before Box upload
*/
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'];
$fileIndex = isset($_GET['file']) ? (int)$_GET['file'] : 0;
// Check if file index is valid
if (!isset($processedData['files'][$fileIndex])) {
http_response_code(404);
echo 'File not found';
exit;
}
$csvFile = $processedData['files'][$fileIndex];
// Set headers for download
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="' . $csvFile['filename'] . '"');
header('Content-Length: ' . strlen($csvFile['content']));
// Output CSV content
echo $csvFile['content'];