sondage.php 3.06 KB
Newer Older
Ayolo's avatar
Ayolo committed
1
2
3
<?php

/* Copyright 2006
4
 * - Julien Etelain <julien CHEZ pmad POINT net>
Ayolo's avatar
Ayolo committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 * 
 * Ce fichier fait partie du site de l'Association des Étudiants de
 * l'UTBM, http://ae.utbm.fr.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

$topdir = "./";

require_once($topdir. "include/site.inc.php");
require_once($topdir. "include/cts/newsflow.inc.php");
require_once($topdir. "include/cts/sqltable.inc.php");
require_once($topdir."include/cts/react.inc.php");

$site = new site ();

34
$site->allow_only_logged_users("accueil");
Ayolo's avatar
Ayolo committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	
$sdn = new sondage($site->db,$site->dbrw);

if (  isset($_REQUEST["answord"]) )
{

	$sdn->load_lastest();
	if ( $sdn->id > 0 && $_REQUEST["id_sondage"] == $sdn->id )
		$sdn->repondre($site->user->id,$_REQUEST["numrep"]);

	$res = new contents("Merci","Votre réponse a été enregistrée.");
}	
else if ( isset($_REQUEST["id_sondage"]) )
	$sdn->load_by_id($_REQUEST["id_sondage"]);

50
if ( $sdn->is_valid() )
Ayolo's avatar
Ayolo committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{

	$site->start_page("accueil","Sondage");	
		
	$cts = new contents("Sondage");
		
	if ( $res )
		$cts->add($res);
	

	$cts->add_title(2,"Resultats");
	
	$cts->add_paragraph($sdn->question);
	
	$cts->puts("<p>");

	$res = $sdn->get_results();
	
	foreach ( $res as $re )
	{
		$cumul+=$re[1];
		$pc = $re[1]*100/$sdn->total;
		
		$cts->puts($re[0]."<br/>");
		
		$wpx = floor($pc);
		if ( $wpx != 0 )
			$cts->puts("<div class=\"activebar\" style=\"width: ".$wpx."px\"></div>");
		if ( $wpx != 100 )
			$cts->puts("<div class=\"inactivebar\" style=\"width: ".(100-$wpx)."px\"></div>");
		
		$cts->puts("<div class=\"percentbar\">".round($pc,1)."%</div>");
		$cts->puts("<div class=\"clearboth\"></div>\n");
		
	}
	
	if ( $cumul < $sdn->total )
	{
		$pc = ( $sdn->total-$cumul)*100/$sdn->total;
		$cts->puts("<br/>Blanc ou nul : ".round($pc,1)."%");
	}
	
	$cts->puts("</p>");

	$cts->add_title(2,"Voir aussi");
	$cts->add_paragraph("<a href=\"sondage.php\">Archives</a>");
	
  $cts->add(new reactonforum ( $site->db, $site->user, $sdn->question, array("id_sondage"=>$sdn->id), null, true ));

	$site->add_contents($cts);
	
	$site->end_page();
	exit();
}

$site->start_page("accueil","Sondage");


$req = new requete($site->db, "SELECT * FROM `sdn_sondage` ORDER BY date_sondage");	

$site->add_contents(new sqltable(
	"listsondages", 
	"Archives", $req, "../sondage.php", 
	"id_sondage", 
	array(
		"question"=>"Question",
		"date_sondage"=>"Du",
		"date_fin"=>"Au"
		), 
	array(), 
	array(),
	array( )
	));

$site->end_page();

?>