<?php
include("config.php");

$d1 = '2024-09-14'; $d2 = '2024-09-14';
$sql = "select SP_ACCESSNUMBER, HOSTORDERNUMBER, STATS from GDC_CMOD.dbo.V_DASHBOARD where 
	COLLECTIONDATE between '2024-09-14 00:00' and '2024-09-14 23:59'
	and ODR_DDATE between '2024-09-14 00:00' and '2024-09-14 23:59'
	and STATS='Comp'";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
	$ACCESSNUMBER = $row['SP_ACCESSNUMBER'];
	$HOSTNUMBER = $row['HOSTORDERNUMBER'];
	$status = $row['STATS'];
	//oru
	$file = fopen("process_oru/$ACCESSNUMBER.oru","w+");
	$date = date('Y-m-d H:i');
	fwrite($file, "$ACCESSNUMBER\r\n$HOSTNUMBER\r\n$date\r\n$status\r\n-");
	fclose($file);
}
?>