2 if(!class_exists(
"radioButton") ){
3 die(
"radioButton class is not loaded ... please load it before radioButtonList");
7 public $typ =
"radioButtonList";
22 if( (isset($this->
pollID)) AND (isset($this->ID)) AND (!empty($this->
pollID)) AND (!empty($this->ID)) AND ($this->
pollID != -1) AND ($this->ID != -1) ){
26 $opt->set_default_values(
$db);
35 if(!is_array($this->
config)){
58 if($this->is_required ==
false){
62 $name =
"mit der ID {$this->ID}";
63 if( (isset($this->dispName) ) AND ( $this->dispName !=
"") ){
65 }
else if ( (isset($this->
name) ) AND ( $this->
name !=
"") ){
69 if( !isset($_POST[ $this->
name ]) ){
70 return "Das Feld <b>$name</b> ist ein Plichtfeld. Bitte dieses angeben.";
72 if( $_POST[ $this->name ] ==
"" ){
73 return "Das Feld <b>$name</b> ist ein Plichtfeld. Bitte dieses angeben.";
84 if($cnf ==
true ){ $ckd =
"checked='checked'"; }
85 echo
"<input type='checkbox' name='display_as_drop_down' value='true' id='display_as_drop_down' $ckd/>
86 <label for='display_as_drop_down'>Als Dropdown-liste anzeigen</label>";
90 if( (isset($_POST[
"display_as_drop_down"])) AND ($_POST[
"display_as_drop_down"]==
"true") ){
107 if( (
sizeof($this->option_list) == 0) OR !(isset($this->
name)) ){
112 if($this->is_required){
113 $req =
"<span class='required_asterisk'>*</span>";
115 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
118 if($dropdown ==
true ){
120 echo
"<label for='{$this->name}' style='$font_bold'>{$this->dispName} $req</label><br/>".PHP_EOL;
121 echo
"<span class='widget_indent'></span> <select id='{$this->name}' name='{$this->name}' >";
122 echo
"<option value=''></option>";
123 foreach($this->option_list as $opt){
127 echo
"</div>".PHP_EOL;
134 if( $columns ==
"columns" ){
140 echo
"<fieldset ><legend style='$font_bold' >{$this->dispName} $req</legend>".PHP_EOL;
144 $option->display(
false,$columns,$this->
name);
146 echo
"</tr></table>";
148 echo
"</div>".PHP_EOL;
154 if( (
sizeof($this->option_list) == 0) OR !(isset($this->
name)) ){
158 if($this->is_required){
159 $req =
"<span class='required_asterisk'>*</span>";
161 $font_family= $this->
get_config(
"font-family");
165 if( $font_family !=
""){ $font_family =
"font-family:".$font_family; }
166 if( $font_size !=
""){ $font_size =
"font-size:".$font_size; }
167 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
170 if($dropdown ==
true ){
171 echo
"<div class='widget_container dropDownList_widget' style='$font_family;$font_size'>";
172 echo
"<legend for='{$this->name}' style='$font_bold' ><span class='widget_question'>{$this->dispName} $req</span></legend>".PHP_EOL;
173 echo
"<span class='widget_indent'></span> <select id='{$this->name}' name='{$this->name}' >";
174 echo
"<option value=''></option>";
175 foreach($this->option_list as $opt){
176 if( (isset($this->
value)) AND ($this->
value == $opt->value) ){
180 $opt->display2($sel);
183 echo
"</div>".PHP_EOL;
189 if( $columns ==
"columns" ){
195 echo
"<div class='widget_container radioButtonList_widget' style='$font_family;$font_size'>";
196 echo
"<fieldset ><legend class='widget_question' style='$font_bold' >{$this->dispName} $req</legend>".PHP_EOL;
200 if( (isset($this->
value)) AND ($this->
value == $option->value)){
204 $option->display($sel,$columns,$this->
name);
206 echo
"</tr></table>";
208 echo
"</div>".PHP_EOL;
216 if( $this->
value !=
"" ){
223 if( (!isset($this->
name)) OR ($this->
name ==
"") ){
226 if( (!isset($this->option_list)) OR ($this->option_list ==
"") ){
227 throw new varException(
"Widget list of options not set!");
232 if ( isset($_POST[$this->
name]) ){
234 if( ($this->
value !=
"") AND ($this->
value == $_POST[$this->name]) AND ($this->option_list[
$i]->
value == $_POST[$this->name]) ){
237 }
else if ($this->option_list[
$i]->
value == $_POST[$this->name]) {
238 $max = $this->option_list[
$i]->check_max();
257 foreach( $this->option_list as $child ){
258 $child->set_data(
"count",0);
264 SELECT `{$pollID}_results`.`$name`,
268 FROM `{$pollID}_results`
270 `$pollID`.`value`=`{$pollID}_results`.`$name`
271 AND `$pollID`.`parent`='$ID'
272 GROUP BY `$pollID`.`ID`;";
273 $res =
$db->get_sql_all_assoc($sql);
276 if( is_array($res) ){
277 foreach( $res as $row ){
280 $child->set_data(
"count",intval($row[
"count"]));
294 $required_classes = array(
"pieChart",
"doughnutChart",
"radarChart",
"barChart");
295 foreach($required_classes as
$c ){
296 if( !class_exists($c) ){
297 throw new exception(
"Chart classes not loaded. Please include chart.class.php");
302 if( $type ==
"barChart" ){
305 }
else if( $type ==
"pieChart" ){
308 }
else if( $type ==
"doughnutChart" ){
311 }
else if( $type ==
"radarChart" ){
323 $data = array(
"labels" => array() ,
"datasets" => array( array() ) );
325 $data[
"labels"][] =
"Antwort".($i+1);
326 $data[
"datasets"][0][] = $this->option_list[
$i]->get_data(
"count");
337 foreach( $this->option_list as $option ){
338 $data[] = $option->get_data(
"count");
364 if( $type ==
"barChart" ){
366 }
else if( $type ==
"pieChart" ){
368 }
else if( $type ==
"doughnutChart" ){
370 }
else if( $type ==
"radarChart" ){
385 echo
"<table style='border-collapse:collapse'>";
387 echo
"<tr><th colspan='2'>Legende (v.l.n.r.)</th></tr>";
388 foreach( $this->option_list as $option ){
389 echo
"<tr style='border-bottom:1px solid #D0D0D0'>";
391 echo
"<td style='border-right:1px solid #949494;padding-right:1em'>Antwort$n</td>";
392 echo
"<td style='padding-left:1em'>{$option->dispName} <span style='color:#810000'>({$option->get_data("count")})</span></td>";
410 if( isset($this->
chart) ){
411 echo
"<table style='border-collapse:collapse'>";
413 echo
"<tr><th colspan='2'>Legende</th></tr>";
414 foreach( $this->option_list as $option ){
415 echo
"<tr style='border-bottom:1px solid #D0D0D0;'>";
418 echo
"<td style='background-color:$color;width:1em;height:1em;border: 2px solid white'> </td>";
419 echo
"<td>{$option->dispName} <span style='color:#810000'>({$option->get_data("count")})</span></td>";
436 if( isset($this->
chart) ){
455 if( !isset($this->
chart) ){
458 if( isset($this->
chart) ){
459 $this->
chart->display();
464 if( !isset($this->
chart) ){
467 if( isset($this->
chart) ){
468 echo
"<h3>{$this->dispName}</h3>";
471 $this->
chart->display();
473 echo
"<td style='padding-left:30px'>";
476 echo
"</tr></table>";