sondage.php 3.15 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
indent  
Ayolo committed
35
36
37



Ayolo's avatar
Ayolo committed
38
39
40
41
42
$sdn = new sondage($site->db,$site->dbrw);

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

Ayolo's avatar
indent  
Ayolo committed
43
44
45
  $sdn->load_lastest();
  if ( $sdn->id > 0 && $_REQUEST["id_sondage"] == $sdn->id )
    $sdn->repondre($site->user->id,$_REQUEST["numrep"]);
Ayolo's avatar
Ayolo committed
46

Ayolo's avatar
indent  
Ayolo committed
47
48
  $res = new contents("Merci","Votre réponse a été enregistrée.");
}  
Ayolo's avatar
Ayolo committed
49
else if ( isset($_REQUEST["id_sondage"]) )
Ayolo's avatar
indent  
Ayolo committed
50
  $sdn->load_by_id($_REQUEST["id_sondage"]);
Ayolo's avatar
Ayolo committed
51

52
if ( $sdn->is_valid() )
Ayolo's avatar
Ayolo committed
53
54
{

Ayolo's avatar
indent  
Ayolo committed
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
  $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>");
  
Ayolo's avatar
Ayolo committed
100
101
  $cts->add(new reactonforum ( $site->db, $site->user, $sdn->question, array("id_sondage"=>$sdn->id), null, true ));

Ayolo's avatar
indent  
Ayolo committed
102
103
104
105
  $site->add_contents($cts);
  
  $site->end_page();
  exit();
Ayolo's avatar
Ayolo committed
106
107
108
109
110
}

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


Ayolo's avatar
indent  
Ayolo committed
111
$req = new requete($site->db, "SELECT * FROM `sdn_sondage` ORDER BY date_sondage");  
Ayolo's avatar
Ayolo committed
112
113

$site->add_contents(new sqltable(
Ayolo's avatar
indent  
Ayolo committed
114
115
116
117
118
119
120
121
122
123
124
125
  "listsondages", 
  "Archives", $req, "../sondage.php", 
  "id_sondage", 
  array(
    "question"=>"Question",
    "date_sondage"=>"Du",
    "date_fin"=>"Au"
    ), 
  array(), 
  array(),
  array( )
  ));
Ayolo's avatar
Ayolo committed
126
127
128
129

$site->end_page();

?>