<pre>
<?php
include("../config.php");
$req = $_GET['req'];
//$sql = "select r.EXTERNALORDERNUMBER from glendb.dbo.REQUESTS r where r.ACCESSNUMBER='$req'";
$sql = "select r.HOSTORDERNUMBER from glendb.dbo.SP_REQUESTS r where r.SP_ACCESSNUMBER='$req'";
$stmt = sqlsrv_query( $conn1, $sql );
if( $stmt == false) { die( print_r( sqlsrv_errors(), true) ); }
$row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC);
$hon = $row[0];

$conn=odbc_connect('GLENEAGLES','','');
$sql="UPDATE TDL_ORDER SET ODR_NRECEIVED=NULL , ODR_DTRECEIVE=NULL WHERE ODR_CNOLAB='$hon'";
$rs=odbc_exec($conn,$sql);
if (!$rs) {exit("Error in SQL");}
$sql="UPDATE TDL_ORDERDT SET ODD_NRECEIVED=NULL , ODD_DTRECEIVE=NULL WHERE ODR_CNOLAB='$hon'";
$rs=odbc_exec($conn,$sql);
if (!$rs) {exit("Error in SQL");}

//logging to audit
$sql = "INSERT INTO GDC_CMOD.dbo.AUDIT_REQUESTS(ACCESSNUMBER, STEPDATE, STEPTYPE) 
	VALUES('$req', GETDATE(), 'UNRECV')";
sqlsrv_query( $conn1, $sql ) or die( print_r( sqlsrv_errors(), true) );
// update sp_tubes
$sql = "update SP_TUBES set TUBESTATUS=0 where SP_ACCESSNUMBER='$req'";
echo "<br/>$sql";
sqlsrv_query( $conn1, $sql ) or die( print_r( sqlsrv_errors(), true) );
// update sp_tests
$sql = "update SP_TESTS set SP_TESTSTATUS=NULL where SP_ACCESSNUMBER='$req' ";
sqlsrv_query( $conn1, $sql ) or die( print_r( sqlsrv_errors(), true) );
// update sp_tests
$sql = "update GDC_CMOD.dbo.REQUESTS_RECEIVE set RECEIVESTATUS=NULL where ACCESSNUMBER='$req' ";
sqlsrv_query( $conn1, $sql ) or die( print_r( sqlsrv_errors(), true) );

?>
</pre>