<?php
	include '../../autoload.php';
	
	$id=$_POST['id'];
	if(!isset($_SESSION['language']))
		$_SESSION['language']="FR";
	$language=$_SESSION['language'];
	
	$conn = get_dbconnection();
	$sql = "select quaadpoint_tag.id,procedure_needed, documents_needed, scope ,scope2 ,additional_param, where_notagid, isglobalscope,document_scope,quaadpoint_tag_name.name from quaadpoint_tag, link_quaad_tag,quaadpoint_tag_name where quaadpoint_tag.id = link_quaad_tag.id_tag and quaadpoint_tag_name.id_quaadpoint_tag=quaadpoint_tag.id and link_quaad_tag.id_quaadpoint=".$id." and language='".$language."'";
	//$sql = "select id,procedure_needed, documents_needed, scope ,scope2 ,additional_param, where_notagid, isglobalscope,document_scope from quaadpoint_tag, link_quaad_tag where quaadpoint_tag.id = link_quaad_tag.id_tag and link_quaad_tag.id_quaadpoint=".$id;
	
	$answer = "<tagslist>";
	
	$query = pg_query($conn, $sql);
	if($query)
	{
		while($row = pg_fetch_row($query))
		{
			// $answer.= "<tag id=\"".$row[0]."\" procedure_needed=\"".htmlspecialchars	( $row[1], ENT_XML1 )."\" documents_needed=\"".htmlspecialchars ( $row[2], ENT_XML1 )."\"></procedure>";
			$answer.= "<tag ";
			
			$answer.= "id=\"".$row[0]."\" ";
			$answer.= "procedure_needed=\"".htmlspecialchars($row[1], ENT_XML1)."\" ";
			$answer.= "documents_needed=\"".htmlspecialchars($row[2], ENT_XML1)."\" ";
			$answer.= "scope=\"".htmlspecialchars($row[3], ENT_XML1)."\" ";
			$answer.= "scope2=\"".htmlspecialchars($row[4], ENT_XML1)."\" ";
			$answer.= "additional_param=\"".htmlspecialchars($row[5], ENT_XML1)."\" ";
			$answer.= "where_notagid=\"".htmlspecialchars($row[6], ENT_XML1)."\" ";
			$answer.= "isglobalscope=\"".htmlspecialchars($row[7], ENT_XML1)."\" ";
			$answer.= "document_scope=\"".htmlspecialchars($row[8], ENT_XML1)."\" ";
			$answer.= "tag_name=\"".htmlspecialchars($row[9],ENT_XML1)."\" ";
			
			$answer .= "></tag>";
		}
	}
	
	$answer.="</tagslist>";
	
	header('Content-Type: text/xml');
	echo $answer;
?>