<?php
include_once("_dirinfo.php");
include_once(PATH_TO_ROOT."init.php");
include_once(PATH_TO_ROOT."webcati/_class/class.webrecode.documents.php");
	
if (!$id_project) $id_project = $_REQUEST['id_project'];
if (!$proj_name) $proj_name = $_REQUEST['proj_name'];
if (!$docMode) $docMode = $_REQUEST['documents_mode'];

$docs = new webrecodeDocs($db);

if ($id_project) {
	$RecDef = $docs->getRecDef($proj_name);
	
	echo "<form method=post name=docs_list action=".$PHP_SELF.">";
	echo "<table><tr><td>Select your question: </td><td>";
	echo "<select Style=width:600px; name=rec_def>";
	foreach ($RecDef AS $k_RecDef => $i_RecDef) {
		echo  "<option value=".$k_RecDef.">".strip_tags($i_RecDef)."</option>";
	}
	echo  "</select></td><td>";
	echo  "<input type=image src=\"".PATH_TO_ROOT."_img/OK16ng.gif\">";
	echo  "</td></tr></table>";
	echo "<input type=hidden name=id_project value=\"$id_project\">";
	echo "<input type=hidden name=proj_name value=\"$proj_name\">";
	echo "<input type=hidden name=docMode value=\"$docMode\">";
	echo  "</form><hr><br>";
	
	
	if ($_POST['rec_def']) {
		$categories = $docs->getCategories($_POST['rec_def'],$proj_name);
		
		if ($categories) {
			echo "<span style=\"font-face:Arial;color:black\">";
			$var_name = explode("_",$_POST['rec_def'],2);
			
			echo "<font face=arial size=+1><b>";
			echo $var_name[1]." ".strip_tags($docs->getQuestionLab($_POST['rec_def'],$proj_name));
			echo "</b></font><br><br>";
			
			foreach ($categories['lab'] AS $k_name => $i_label) {
				echo  "<b>$k_name ".strip_tags($i_label)."</b><br>";
				
				if ($docMode){
					$catlabels = $docs->getCatlabels($_POST['rec_def'],$proj_name,$categories['id'][$k_name]);
					foreach ($catlabels AS $labid => $label) {
						echo  "&nbsp;&nbsp;$labid ".strip_tags($label)."<br>";
					}	
					
				}
			}
			echo "</span>";
		} else {
			echo "<font face=arial>no data...";
		}
	}
}

?>
