<?php

require('auth-validate.php');
require('../../db.php');



$id_company = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;

if(!$id_company)
{
	http_response_code(400);
	echo 'missing parameter: id';
	return;
}


header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
header("Pragma: no-cache");
header("Expires: 0");



$f = fopen('php://temp/maxmemory:1048576', 'w');

getRowsByCompanyCSV($id_company, $f);


rewind($f);
$csv = stream_get_contents($f);
fclose($f);

echo $csv;

?>
