<?php
/**
 * Download Sample CSV for Menu Import
 */

// Include CMSB
require_once '../../lib/init.php';

// Check if user has access
if (!defined('IS_CMS_ADMIN') || !$CURRENT_USER['isAdmin']) {
    die("Access denied");
}

// Set headers for CSV download
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="sample_menu_import.csv"');
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');

// Create CSV content
$csvContent = "name,category,price,ingredients,listingsNum,enable_order,delivery_type,option_name,option_type,option_category,option_price,is_required,min_selection,max_selection,option_sort_order,choice_name,choice_description,choice_price,choice_sort_order\n";

// Sample data
$sampleData = [
    ["Beef Burrito", 2, 12.99, "Beef, rice, beans, cheese, lettuce, sour cream", 10, 1, "delivery,pickup", "Select Size", "required", "Size", 0.00, 1, 1, 1, 1, "Regular", "", 0.00, 1],
    ["Beef Burrito", 2, 12.99, "Beef, rice, beans, cheese, lettuce, sour cream", 10, 1, "delivery,pickup", "Select Size", "required", "Size", 0.00, 1, 1, 1, 1, "Large", "", 4.00, 2],
    ["Beef Burrito", 2, 12.99, "Beef, rice, beans, cheese, lettuce, sour cream", 10, 1, "delivery,pickup", "Add Sides", "optional", "Sides", 0.00, 0, 0, 3, 2, "Chips & Salsa", "Fresh tortilla chips with salsa", 2.50, 1],
    ["Chicken Tacos", 2, 9.99, "Chicken, corn tortillas, onions, cilantro, lime", 10, 1, "delivery,pickup", "Select Number", "required", "Quantity", 0.00, 1, 1, 1, 1, "1 Taco", "", 0.00, 1],
    ["Chicken Tacos", 2, 9.99, "Chicken, corn tortillas, onions, cilantro, lime", 10, 1, "delivery,pickup", "Select Number", "required", "Quantity", 0.00, 1, 1, 1, 1, "2 Tacos", "", 8.00, 2],
    ["Margherita Pizza", 1, 16.99, "Fresh mozzarella, tomato sauce, basil, olive oil", 10, 1, "delivery,pickup", "Select Size", "required", "Size", 0.00, 1, 1, 1, 1, "Small (10 inch)", "", 0.00, 1],
    ["Margherita Pizza", 1, 16.99, "Fresh mozzarella, tomato sauce, basil, olive oil", 10, 1, "delivery,pickup", "Select Size", "required", "Size", 0.00, 1, 1, 1, 1, "Medium (12 inch)", "", 4.00, 2]
];

// Add sample data to CSV
foreach ($sampleData as $row) {
    $csvContent .= '"' . implode('","', $row) . '"' . "\n";
}

// Output CSV content
echo $csvContent;
exit;
?>