<?php

// http://127.0.0.1/hsintungyang-energy/action/schedule/man_export_report_month.php?start_date=2024-01&end_date=2024-05
set_time_limit(0);
if(isset($_GET['start_date']) && isset($_GET['end_date']))
{
	$start_date = new DateTime($_GET['start_date']);
	$end_date = new DateTime($_GET['end_date']);

	for ($dt=$start_date; $dt <= $end_date; $dt->modify('+1 months')) 
	{ 
		$path = substr($_SERVER['PHP_SELF'],1,strrpos($_SERVER['PHP_SELF'],'/'));
		$date = $dt->format('Y-m');
		$url = "http://127.0.0.1:{$_SERVER['SERVER_PORT']}/{$path}excel_export_report_month.php?report_date={$date}";
		// echo $url.'<br>';
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$res = curl_exec($ch);
		echo $dt->format('Y-m-d').': '.$res.'<br>';
		curl_close($ch);
		sleep(1);
	}
	
}
else
{
	echo 'no param: start_date,end_date';
}

?>
