<?
/*
,´¯`. Federico Larsen
: (` ; Linux Registered User #304032.
`. `´ Mar del Plata. Argentina!
`· ICQ: 39334744
*/
include_once ("encuesta.inc.php");
class controler_encuestas { //manipulator of the class
var $enc;
var $op;
function controler_encuestas (){
$this->enc = new appt_encuestas; //create the instance of a survey
$this->op = new appt_opciones_x_encuesta; //create the instance of a option per survey
}
function ver_encuestas (){ //show all avaliable surveys
$q = "select * from appt_encuestas where fecha_ini <= \"".date("Y-m-d")."\" and fecha_fin >= \"".date("Y-m-d")."\"";
$result = mysql_query ($q);
echo '<table border="1">';
while ($row = mysql_fetch_array ($result) ){
$this->enc->get_data ($row["id_enc"]);
$this->enc->mostrar_link ();
}
echo '</table>';
}
function ver_res_encuesta ( $id_enc){ //show the selected survey
$this->enc->get_data ($id_enc);
$this->enc->ver_resultados ();
}
function votar_1_encuesta ( $id_enc){ //vote on a survey
$this->enc->get_data ($id_enc);
$this->enc->mostrar ();
}
function elige_opcion ( $id_enc ,$id_op){ //make te vote if did not already vote
$this->enc->get_data ($id_enc);
if ( $this->enc->votar ($id_op) ){
echo "su voto ha sido computado <br>\n";
}
else {
echo "ud. ya ha votado <br>\n";
}
$this->enc->mostrar ();
}
function agregar_encuesta ($pregunta , $fecha_ini , $fecha_fin , $orden){
$this->enc->pregunta = $pregunta;
$this->enc->fecha_ini = $fecha_ini;
$this->enc->fecha_fin = $fecha_fin;
$this->enc->orden = $orden;
$this->enc->insert_data ();
}
function elegir_encuesta ($id_enc){
$this->enc->get_data ($id_enc);
}
function modificar_encuesta (){
$this->enc->update_data ();
}
function eliminar_encuesta (){
$this->enc->delete_data ();
}
function agregar_opcion ($opcion , $orden){
$this->enc->add_opcion ($opcion , $orden);
}
function elegir_opcion ($id_op){
$this->op->get_data ($id_op);
}
function eliminar_opcion (){
$this->op->delete_data ();
}
function modificar_opcion (){
$this->op->update_data ();
}
}
?>