<?
?>
<link href="../../css/cssnew.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
margin-left: 5px;
}
.Estilo2 {color: #999999}
-->
</style>
<?
include("../../inc/oConn.php");
$contador=1;
if($_SESSION['rut']=="")
{
echo "<p class=titulos>Para contestar la encuesta debe estar identificado en intranet.</p>";
}
$strV="select * from encuesta_respuestas where rut_emp=".$_SESSION['rut']." and id_encuesta=$encuesta";
$rsconn=$db->Execute($strV);
if(!$rsconn->EOF)
{
echo "<p class=titulos>Usted ya ha contestado la encuesta.</p>";
}
$strSQL="select * from encuestas_cabecera where id_encuesta=".$encuesta;
$rsconn=$db->Execute($strSQL);
if($rsconn->EOF)
{
echo "La encuesta no existe o fue desactivada";
}
?>
<form action="graba_encuesta.php" method="POST" name="frmencuesta">
<table width="695" border="0" cellspacing="0" cellpadding="0" class="txt8pt">
<tr>
<td align="center"><br /><p class="txt9pt"><b><? echo $rsconn->fields[1];?></b>
<input name="encuesta" type="hidden" id="encuesta" value="<? echo $encuesta;?>" />
<input name="rut" type="hidden" id="rut" value="<? echo $_SESSION['rut'];?>" />
</p>
<p align="left"class="txt8pt"><? echo $rsconn->fields[2];?></p></td>
</tr>
<?
$seccion="";
$titulo="";
$strSQL="select a.ID_SEC,a.TITULO_SEC,a.DESC_SEC, ";
$strSQL.="b.ID_TITULO,b.NOMBRE_TITULO, ";
$strSQL.="c.ID_PREGUNTA,c.ID_PREGUNTA,c.ID_TIPO_RESP,c.ID_OPCION,C.PREGUNTA ";
$strSQL.="from encuesta_secciones a, encuesta_titulos b, encuesta_preguntas c ";
$strSQL.="where a.ID_SEC=b.ID_SEC ";
$strSQL.="and b.ID_TITULO=c.ID_TITULO ";
$strSQL.="and a.id_encuesta=".$encuesta;
$strSQL.=" order by id_sec,id_titulo";
$rsconn=$db->Execute($strSQL);
while(!$rsconn->EOF)
{
//muestro el titulo de la seccion
if($seccion!=$rsconn->fields[0])
{
echo " <tr><td> </td></tr>";
echo "<tr ><td bgcolor='E6E6E6'><p class=txt8pt><b>".$rsconn->fields[1]."</b></p></tr></td>";
echo "<tr ><td><p class=txt8pt><BR>".$rsconn->fields[2]."</p><br></tr></td>";
echo " <tr><td> </td></tr>";
$contador=1;
}
$seccion=$rsconn->fields[0];
// fin titulo seccion
//Muestro el titulo de las preguntas
if($rsconn->fields[4]!="ST" && $titulo!=$rsconn->fields[3])
{
echo "<tr ><td class='txt8pt'><br><p class='txt8pt'> <b>".$rsconn->fields[4]."</p></tr></td>";
}
$titulo=$rsconn->fields[3];
//FIN TITULO
//MUESTRO PREGUNTA
//rescarto el tipo de opciones que tiene la pregunta
$strOP="select TIPO_resp,CODIGO_RESP from ENCUENSTA_TIPO_RESP where id_tipo_resp=".$rsconn->fields[7];
$rsconn2=$db->Execute($strOP) or
die ("No existe el tipo de resp"); if(!$rsconn2->EOF)
{
if($rsconn2->fields[0]=="TEXT")
{
?>
<tr><td>
<table width="692" border="1" cellpadding="1" cellspacing="0" bordercolor="E6E6E6" class="txt8pt">
<tr>
<td width="55" class="txt8pt Estilo2"><? echo $contador;//echo $rsconn->fields[5];?></td>
<td width="627">
<?
echo " ".$rsconn->fields[9]."";
echo "<p align=center><input name='preg".$rsconn->fields[5]."' type='text' size='80' maxlength='80' class=TextoCam></p>";
?> </td>
</tr></table>
<?
}elseif($rsconn2->fields[0]=="TEXTAREA"){
?>
<tr><td>
<table width="692" border="1" cellpadding="1" cellspacing="0" bordercolor="E6E6E6" class="txt8pt">
<tr>
<td width="55" class="txt8pt Estilo2"><? echo $contador;//echo $rsconn->fields[5];?></td>
<td width="627">
<?
echo " ".$rsconn->fields[9]."";
echo "<p align=center><textarea name='preg".$rsconn->fields[5]."' cols='80' rows='4' class=TextoCam>.</textarea></p>";
?> </td>
</tr></table>
<?
}elseif($rsconn2->fields[0]=="RADIO"){
$strOP2="select * from encuesta_Desc_opciones where id_opcion=".$rsconn->fields[8]." order by id_des_op";
$rsconn3=$db->Execute($strOP2) or
die ("ERROR !"); ?>
<tr><td>
<table width="695" border="1" cellpadding="1" cellspacing="0" bordercolor="E6E6E6">
<tr>
<td width="37" class="txt8pt Estilo2"><? echo $contador;//echo $rsconn->fields[5];?></td>
<td width="453" class="txt8pt"> <? echo $rsconn->fields[9];?>:</td>
<td width="191" colspan="2"><table width="100%"><tr>
<?
while(!$rsconn3->EOF)
{
echo "<td class=txt8pt><input name='preg".$rsconn->fields[5]."' type='radio' value='".$rsconn3->fields[2]."' />".$rsconn3->fields[2]."</td>";
$rsconn3->Movenext();
}
?>
</tr></table>
</td>
</table>
</td></tr>
<?
}elseif($rsconn2->fields[0]=="LISTA"){
$strOP2="select * from encuesta_Desc_opciones where id_opcion=".$rsconn->fields[8]." order by id_des_op";
$rsconn3=$db->Execute($strOP2) or
die ("ERROR !"); ?> <tr><td>
<table width="695" border="1" cellpadding="1" cellspacing="0" bordercolor="E6E6E6">
<tr>
<td width="37" class="txt8pt Estilo2"><? echo $contador;//echo $rsconn->fields[5];?></td>
<td width='416' class="txt8pt"> <? echo $rsconn->fields[9];?></td>
<td>
<?
echo "<select name='preg".$rsconn->fields[5]."' class=TextoCam>";
echo "<option value=''>Seleccione..</option> ";
while(!$rsconn3->EOF)
{
echo "<option value='".$rsconn3->fields[2]."'>".$rsconn3->fields[2]."</option>";
$rsconn3->Movenext();
}
echo "</select>";
?>
</tr></table>
</td></tr>
<?
}else{
//fin
}
}
$contador++;
$rsconn->Movenext();
}
$db->Close();
?>
<tr>
<td align="center">
<label>
<input type="submit" name="Submit" value="Enviar Información" class="TextoCam"/>
</label></td>
</tr>
</table>
<br />
</form>