2 if(!class_exists(
"checkBox") ){
3 die(
"CheckBox class is not loaded ... please load it before checkBoxList");
6 public $typ =
"checkBoxList";
19 if(!is_array($this->
config)){
40 if($this->is_required ==
false){
44 $name =
"mit der ID {$this->ID}";
45 if( (isset($this->dispName) ) AND ( $this->dispName !=
"") ){
47 }
else if ( (isset($this->
name) ) AND ( $this->
name !=
"") ){
52 $keys = array_keys($_POST);
53 foreach($this->option_list as $opt){
54 if( in_array($opt->ID,
$keys) ){
55 if( $_POST[$opt->ID] !=
""){
63 return "Das Feld <b>$name</b> ist ein Plichtfeld. Bitte dieses angeben.";
72 if( (isset($this->
pollID)) AND (isset($this->ID)) AND (!empty($this->
pollID)) AND (!empty($this->ID)) AND ($this->
pollID != -1) AND ($this->ID != -1) ){
76 $opt->set_default_values(
$db);
85 if( (
sizeof($this->option_list) == 0) OR !(isset($this->
name)) ){
88 if($this->is_required){
89 $req =
"<span class='required_asterisk'>*</span>";
92 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
97 if( $columns ==
"columns" ){
105 echo
"<fieldset ><legend style='$font_bold' >{$this->dispName} $req</legend>".PHP_EOL;
106 $values = explode(
",",$this->
value);
109 if( (isset($this->
value)) AND ($this->
value == $option->value)){
113 $option->display($sel,$columns);
115 echo
"</tr></table>";
117 echo
"</div>".PHP_EOL;
123 if( (
sizeof($this->option_list) == 0) OR !(isset($this->
name)) ){
126 if($this->is_required){
127 $req =
"<span class='required_asterisk'>*</span>";
129 $font_family= $this->
get_config(
"font-family");
132 if( $font_family !=
""){ $font_family =
"font-family:".$font_family; }
133 if( $font_size !=
""){ $font_size =
"font-size:".$font_size; }
134 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
139 if( $columns ==
"columns" ){
145 echo
"<div class='widget_container checkBoxList_widget' style='$font_family;$font_size'>";
146 echo
"<fieldset ><legend style='$font_bold' class='widget_question' >{$this->dispName} $req</legend>".PHP_EOL;
147 $values = explode(
",",$this->
value);
152 if( in_array($option->value,$values) ){
156 $option->display($sel,$columns);
159 echo
"</tr></table>";
161 echo
"</div>".PHP_EOL;
171 if( (!isset($this->
name)) OR ($this->
name ==
"") ){
174 if( (!isset($this->option_list)) OR ($this->option_list ==
"") ){
175 throw new varException(
"Widget list of options not set!");
178 $values_old = explode(
",",$this->
value);
181 foreach($this->option_list as $option){
182 $max = $option->check_max();
184 if ( (isset($_POST[ $option->ID ])) AND ($_POST[ $option->ID ] == $option->value) ){
186 if( ($max !==
true) AND (!in_array($_POST[ $option->ID ],$values_old)) ){
189 $values[] = $option->value;
194 if (
sizeof($values) != 0){
195 $this->
value = implode(
",",$values);
203 foreach( $this->option_list as $child ){
204 $child->set_data(
"count",0);
210 `{$this->name}` AS 'values',
211 COUNT(`{$this->name}`) AS count
212 FROM `umfragen`.`{$this->pollID}_results`
214 $res =
$db->get_sql_all_assoc($sql);
217 if( is_array($res) ){
219 foreach( $res as $row ){
220 $vals = explode(
",",$row[
"values" ]);
222 foreach($vals as $val){
224 foreach( $this->option_list as $child){
225 if( $child->value == $val){
231 if( isset($child_set) ){
232 $actual = $child_set->get_data(
"count");
233 $child_set->set_data(
"count", $actual+intval($row[
"count"]) );
249 $required_classes = array(
"pieChart",
"doughnutChart",
"radarChart",
"barChart");
250 foreach($required_classes as
$c ){
251 if( !class_exists($c) ){
252 throw new exception(
"Chart classes not loaded. Please include chart.class.php");
257 if( $type ==
"barChart" ){
260 }
else if( $type ==
"pieChart" ){
263 }
else if( $type ==
"doughnutChart" ){
266 }
else if( $type ==
"radarChart" ){
278 $data = array(
"labels" => array() ,
"datasets" => array( array() ) );
280 $data[
"labels"][] =
"Antwort".($i+1);
281 $data[
"datasets"][0][] = $this->option_list[
$i]->get_data(
"count");
292 foreach( $this->option_list as $option ){
293 $data[] = $option->get_data(
"count");
319 if( $type ==
"barChart" ){
321 }
else if( $type ==
"pieChart" ){
323 }
else if( $type ==
"doughnutChart" ){
325 }
else if( $type ==
"radarChart" ){
340 echo
"<table style='border-collapse:collapse'>";
342 echo
"<tr><th colspan='2'>Legende (v.l.n.r.)</th></tr>";
343 foreach( $this->option_list as $option ){
344 echo
"<tr style='border-bottom:1px solid #D0D0D0'>";
346 echo
"<td style='border-right:1px solid #949494;padding-right:1em'>Antwort$n</td>";
347 echo
"<td style='padding-left:1em'>{$option->dispName} <span style='color:#810000'>({$option->get_data("count")})</span></td>";
365 if( isset($this->
chart) ){
366 echo
"<table style='border-collapse:collapse'>";
368 echo
"<tr><th colspan='2'>Legende</th></tr>";
369 foreach( $this->option_list as $option ){
370 echo
"<tr style='border-bottom:1px solid #D0D0D0;'>";
373 echo
"<td style='background-color:$color;width:1em;height:1em;border: 2px solid white'> </td>";
374 echo
"<td>{$option->dispName} <span style='color:#810000'>({$option->get_data("count")})</span></td>";
391 if( isset($this->
chart) ){
410 if( !isset($this->
chart) ){
413 if( isset($this->
chart) ){
414 $this->
chart->display();
419 if( !isset($this->
chart) ){
422 if( isset($this->
chart) ){
423 echo
"<h3>{$this->dispName}</h3>";
426 $this->
chart->display();
428 echo
"<td style='padding-left:30px'>";
431 echo
"</tr></table>";