<?php
require_once('includes/load.php');

$mrpData = array(); // Replace this with your data retrieval code

// Generate CSV content
$csvContent = "Child BOM,Child Name,Level,Quantity,Quantity Order,Total Requirement,UoM,Total Requirement (KG)\n";
foreach ($mrpData as $data) {
    $csvContent .= "{$data['child_bom']},{$data['child_name']},{$data['level']},{$data['quantity']},{$data['quantity_order']},{$data['total_requirement']},{$data['uom']},{$data['total_requirement_kg']}\n";
}

// Set the response headers
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=mrp_export.csv");

// Output the CSV content
echo $csvContent;
exit();
?>
