<?php
	require_once '../../../autoload.php';

	error_log ( "### delete_nrd " );

	$nrd_id		 		= -1;
		
	if ( isset ( $_POST['nrd_id'] ) 			)	$nrd_id			 	= $_POST['nrd_id'];
		
	$pdo = getPDO ();
	
	$response = -1;
	
	if ( $pdo )
	{
		$sql = '';

		if ( $nrd_id != -1 )
		{
			$sql = 'delete from  link_nrd where type = 2 and nrd_id = :nrd_id;';

			$stmt = $pdo->prepare ( $sql );
			$stmt->bindParam ( ':nrd_id', $nrd_id );

			if ( $stmt->execute () == true )
			{
				$sql = 'delete from nrd where nrd_id = :nrd_id;';

				$stmt1 = $pdo->prepare ( $sql );
				$stmt1->bindParam ( ':nrd_id', $nrd_id );

				if ( $stmt1->execute () == true )
					$response = $nrd_id;
			}
		}
	}
	
	header ('Content-type: text/xml' );
	
	echo $response;
?>