<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('memory_limit', '-1');
set_time_limit(0);
date_default_timezone_set('Europe/Madrid');
//include("conexion.php");
if(isset($_REQUEST["code"])) //Formato linux timestamp
	$code=$_REQUEST["code"]; else $code="";


$serverName = "localhost";
$connectionInfo = array( "Database"=>"ICF", "UID"=>"VAIO", "PWD"=>"VAIO");

$connNavision=false;
$retries=0;

while(!$connNavision && $retries<3){
	$connNavision = sqlsrv_connect( $serverName, $connectionInfo);
	$retries++;
}

	$sql = 'SELECT * FROM [dbo].[Ind. Campollano Ferreterķa S.L$Purchase Header]
	WHERE [No.]=\''.$code.'\'';
	$smtp=sqlsrv_query( $connNavision, $sql );
		
	if($row = sqlsrv_fetch_array( $smtp, SQLSRV_FETCH_ASSOC)){
		echo true;
	}
	else echo false;

?>
