<?php
include "../dbconection.php";
include "../funciones.php";

//header ("Location: ".$strUrl."track/1.gif");
$sJSON = "";

$intDocumento = $_REQUEST["c"];
$intUsuario = $_REQUEST["id"];

$query = "SELECT * FROM tblactividad WHERE intDocumento = ". $intDocumento . " and intUsuario = ". $intUsuario;

$queryResult = mysql_query($query);	
$totalRows = mysql_num_rows($queryResult);

if($totalRows == 0){

	$query = "INSERT INTO tblactividad (intDocumento, intUsuario) VALUES(". $intDocumento .",". $intUsuario .")";
	$queryResult = mysql_query($query);
	
	if($queryResult){
		$sJSON .= "exito";
	}else{
		$sJSON .= "error";
	}

}else{
	$query = "UPDATE tblactividad SET datFechaApertura = CURRENT_TIMESTAMP WHERE intDocumento = ". $intDocumento ." and intUsuario = ". $intUsuario ." ";
	$queryResult = mysql_query($query);
	
	if($queryResult){
		$sJSON .= "exito";
	}else{
		$sJSON .= "error";
	}
}

//mysql_free_result ( $queryResult );

print($query);
?>