4 public $typ =
"schedule";
13 if( (isset($this->
pollID)) AND (isset($this->ID)) AND (!empty($this->
pollID)) AND (!empty($this->ID)) AND ($this->
pollID != -1) AND ($this->ID != -1) ){
18 $nick->set_dispName(
"Termin planen Name");
25 $date->set_default_values(
$db);
40 if(
$name ==
"users" ){
42 $this->data[
"users"] = $val;
55 if(
$name ==
"users" ){
56 if( isset($this->data[
"users"]) ){
57 return $this->data[
"users"];
60 foreach( $this->widget_list as $child ){
61 $tmp[ $child->ID ] = array();
72 if(!is_array($this->
config)){
77 if( is_array($this->
config) ){
78 if(
$name ==
"displayOtherUsers" ){
79 if( isset($this->
config[
"displayOtherUsers"]) ){
80 return $this->
config[
"displayOtherUsers"];
85 }
else if(
$name ==
"displayOtherUsersStatistics" ){
86 if( isset($this->
config[
"displayOtherUsersStatistics"]) ){
87 return $this->
config[
"displayOtherUsersStatistics"];
91 }
else if(
$name ==
"usernameRestriction" ){
92 if( isset($this->
config[
"usernameRestriction"]) ){
93 return $this->
config[
"usernameRestriction"];
97 }
else if(
$name ==
"yesValue" ){
98 if( isset($this->
config[
"yesValue"]) ){
99 return $this->
config[
"yesValue"];
103 }
else if(
$name ==
"noValue" ){
104 if( isset($this->
config[
"noValue"]) ){
105 return $this->
config[
"noValue"];
109 }
else if(
$name ==
"maybeValue" ){
110 if( isset($this->
config[
"maybeValue"]) ){
111 return $this->
config[
"maybeValue"];
125 if( (isset($this->
config)) AND (is_string($this->
config)) AND ($this->
config !=
"") ){
129 if(
$name ==
"displayOtherUsers" ){
131 $this->
config[
"displayOtherUsers"] =
true;
133 $this->
config[
"displayOtherUsers"] =
false;
135 }
else if(
$name ==
"displayOtherUsersStatistics" ){
137 $this->
config[
"displayOtherUsersStatistics"] =
true;
139 $this->
config[
"displayOtherUsersStatistics"] =
false;
141 }
else if(
$name ==
"usernameRestriction" ){
142 $list = array(
"free",
"force",
"none");
143 if( in_array($val,$list) ){
144 $this->
config[
"usernameRestriction"] = $val;
146 return "Wert für usernameRestriction ungültig";
148 }
else if(
$name ==
"yesValue" ){
149 $value_clean = htmlspecialchars($val , ENT_QUOTES ,
"UTF-8",
true);
150 if( (strlen($value_clean) > 25) ){
151 return "Wert für die Antwort \"Ja\" enthält mehr als 25 Zeichen";
153 $this->
config[
"yesValue"] = $value_clean;
155 }
else if(
$name ==
"noValue" ){
156 $value_clean = htmlspecialchars($val , ENT_QUOTES ,
"UTF-8",
true);
157 if( (strlen($value_clean) > 25) ){
158 return "Wert für die Antwort \"Nein\" enthält mehr als 25 Zeichen";
160 $this->
config[
"noValue"] = $value_clean;
162 }
else if(
$name ==
"maybeValue" ){
163 $value_clean = htmlspecialchars($val , ENT_QUOTES ,
"UTF-8",
true);
164 if( (strlen($value_clean) > 25) ){
165 return "Wert für die Antwort \"Vielleicht\" enthält mehr als 25 Zeichen";
167 $this->
config[
"maybeValue"] = $value_clean;
181 foreach( $this->widget_list as $child){
196 $sel =
"checked='checked'";
199 echo
"<input type='checkbox' name='display_other_participants' id='display_other_participants' value='true' $sel/>";
200 echo
"<label for='display_other_participants'>Andere Teilnehmer und ihre Antworten anzeigen</label>";
204 if( (isset($_POST[
"display_other_participants"])) AND ($_POST[
"display_other_participants"] ==
"true") ){
214 if( $this->
get_config(
"displayOtherUsersStatistics") ){
215 $sel =
"checked='checked'";
218 echo
"<input type='checkbox' name='display_other_participants_stats' id='display_other_participants_stats' value='true' $sel/>";
219 echo
"<label for='display_other_participants_stats'>Zahlen über die anderen Antworten anzeigen</label>";
223 if( (isset($_POST[
"display_other_participants_stats"])) AND ($_POST[
"display_other_participants_stats"] ==
"true") ){
224 $r = $this->
set_config(
"displayOtherUsersStatistics",
true);
226 $r = $this->
set_config(
"displayOtherUsersStatistics",
false);
235 $val_list = array(
"free" =>
"Frei wählbar" ,
"force" =>
"Namen erzwingen" ,
"none" =>
"Nicht danch fragen");
237 echo
"Name: <select name='username_restriction'>";
238 foreach( array_keys($val_list) as $val ){
240 echo
"<option value='$val' selected='selected'>{$val_list[$val]}</option>";
242 echo
"<option value='$val'>{$val_list[$val]}</option>";
249 $val_list = array(
"free",
"force",
"none");
251 if( (isset($_POST[
"username_restriction"])) AND (in_array($_POST[
"username_restriction"],$val_list )) ){
252 return $this->
set_config(
"usernameRestriction",$_POST[
"username_restriction"]);
254 return "Kein gültiger Wert";
262 $maybeValue = $this->
get_config(
"maybeValue");
265 echo
"<td style='text-align:right;color:#9AC74D'><label for='yesValue'>Wert \"Ja\"</label>: </td>";
266 echo
"<td><input type='text' name='yesValue' id='yesValue' value='$yesValue'/></td>";
267 echo
"<td style='font-size:80%;color:#3C0200;font-style:italic'>Maximal 25 Zeichen</td>";
270 echo
"<td style='text-align:right;color:#C7A24D'><label for='maybeValue'>Wert \"Vielleicht\"</label>: </td>";
271 echo
"<td><input type='text' name='maybeValue' id='maybeValue' value='$maybeValue'/></td>";
272 echo
"<td style='font-size:80%;color:#3C0200;font-style:italic'>Maximal 25 Zeichen</td>";
275 echo
"<td style='text-align:right;color:#C74D5D'><label for='noValue'>Wert \"Nein\"</label>: </td>";
276 echo
"<td><input type='text' name='noValue' id='noValue' value='$noValue'/></td>";
277 echo
"<td style='font-size:80%;color:#3C0200;font-style:italic'>Maximal 25 Zeichen</td>";
284 if( (isset($_POST[
"yesValue"])) AND ($_POST[
"yesValue"] !=
"") ){
288 $all_err .=
"<br/>".$err;
290 if( (isset($_POST[
"maybeValue"])) AND ($_POST[
"maybeValue"] !=
"") ){
294 $all_err .=
"<br/>".$err;
296 if( (isset($_POST[
"noValue"])) AND ($_POST[
"noValue"] !=
"") ){
300 $all_err .=
"<br/>".$err;
302 if( $all_err !=
"" ){
309 echo
"<table class='edit_schedule_table' > ";
310 $rows = array(
"edit",
"from date",
"from time",
"separator",
"to date",
"to time");
311 $rows_desc = array(
"",
"Von / Am",
312 "<span style='font-style:italic;font-size:70%'>Uhrzeit</span><span style='color:#E25C57'> * </span>",
314 "Bis<span style='color:#E25C57'> * </span>" ,
315 "<span style='font-style:italic;font-size:70%'>Uhrzeit</span><span style='color:#E25C57'> * </span>");
317 if( (
sizeof($this->widget_list) > 1) ){
319 foreach(
$rows as $code ){
321 if( $code ==
"separator" ){
324 echo
"<tr class='$cl'>";
325 $code_arr = explode(
" ",$code);
326 echo
"<th class='{$code_arr[0]}_td'>{$rows_desc[$r]}</th>";
328 foreach($this->widget_list as $child ){
331 if( (isset($_SESSION[
"last_option_edit"])) AND ( $_SESSION[
"last_option_edit"] == $child->ID ) ){
332 $edited =
"option_last_edit_schedule";
335 if( $code ==
"edit" ){
336 echo
"<td class='schedule_edit_td'>
337 <input type='submit' name='rmq_option_ID{$child->ID}' title='Frage Löschen' value='' tabindex='-1' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT.
"/icons/22/edit-delete.png );background-repeat:no-repeat;width:26px;height:26px;' />
339 }
else if($code ==
"separator"){
342 echo
"<td class='{$code_arr[0]}_td $edited'>";
343 $child->display_date_input($code_arr[0],$code_arr[1]);
349 $s =
sizeof(
$rows)-1;
350 echo
"<td class='schedule_edit_td'><input type='submit' name='addq_option_ID{$child->ID}' title='Frage Einfügen' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT.
"/icons/22/list-add.png );background-repeat:no-repeat;width:26px;height:26px;' /></td>";
352 if($code !=
"separator"){
353 echo
"<td class='schedule_edit_td'></td>";
360 echo
"<tr><td><input type='submit' name='addq_option_ID{$this->ID}' title='Option Einfügen' value='' style='padding:0px;margin:0px;background-color:transparent;background-image:url( ".APP_ROOT.
"/icons/22/list-add.png );background-repeat:no-repeat;width:26px;height:26px;' /></td></tr>";
363 unset($_SESSION[
"last_option_edit"] );
370 $options_seen = array();
371 $code_wl = array(
"from",
"to");
372 $type_wl = array(
"datepicker",
"time",
"day",
"month",
"year");
374 $post_keys = array_keys($_POST);
375 foreach($post_keys as $post){
376 $tmp = explode(
"_",$post);
377 if(
sizeof(
$tmp) == 4 ){
378 if( is_numeric(
$tmp[1]) ){
379 $id = intval(
$tmp[1]);
383 if( (!in_array(intval($id),$options_seen)) AND (in_array($code,$code_wl)) AND (in_array($type,$type_wl)) ){
391 $options_seen[] = $id;
397 if($all_errs !==
""){
406 $month_names = array(
"" ,
"Jan." ,
"Feb." ,
"Mrz." ,
"Apr." ,
"Mai" ,
"Jun." ,
"Jul." ,
"Aug" ,
"Sep." ,
"Oct.",
"Nov." ,
"Dez.");
407 $fmt = array(
"year",
"mon",
"day",
"hour",
"min",
"time");
408 foreach( array_keys($date) as $key ){
409 if( $key ==
"tm_year" ){
410 $fmt[
"year"] = (string) $date[$key];
411 }
else if( $key ==
"tm_mon" ){
412 $fmt[
"mon"] = $month_names[ $date[$key] ];
413 }
else if( $key ==
"tm_mday" ){
414 if( $date[$key] < 10 ){
415 $fmt[
"day"] =
"0{$date[$key]}.";
417 $fmt[
"day"] =
"{$date[$key]}.";
419 }
else if( $key ==
"tm_hour" ){
420 if( $date[$key] < 10 ){
421 $fmt[
"hour"] =
"0{$date[$key]}";
423 $fmt[
"hour"] =
"{$date[$key]}";
425 }
else if( $key ==
"tm_min" ){
426 if( $date[$key] < 10 ){
427 $fmt[
"min"] =
"0{$date[$key]}";
429 $fmt[
"min"] =
"{$date[$key]}";
433 $fmt[
"time"] =
"{$fmt["hour
"]}:{$fmt["min
"]}";
438 $date_str_common = $date_str_from= $date_str_to =
"";
440 foreach( $this->widget_list as $child ){
442 $from = $child->get_date(
"from");
443 $to = $child->get_date(
"to");
444 $from_arr = $child->get_date_array($from);
445 $to_arr = $child->get_date_array($to);
447 if( (!empty($from_arr)) AND (!empty($to_arr)) ){
449 $year_same = $month_same = $day_same =
false;
453 if( $from_arr[
"tm_year"] === $to_arr[
"tm_year"] ){
456 if( $from_arr[
"tm_mon"] === $to_arr[
"tm_mon"] ){
459 if( $from_arr[
"tm_mday"] === $to_arr[
"tm_mday"] ){
463 if( $year_same AND $month_same AND $day_same ){
464 $date_str_common .=
"<th class='head_date_th date_common'>{$fromf["day
"]} {$fromf["mon
"]} {$fromf["year
"]} </th>";
465 if( $fromf[
"time"] !=
"00:00" ){
466 $date_str_from .=
"<th class='head_date_th date_from'>{$fromf["time
"]}</th>";
468 if( $tof[
"time"] !=
"00:00" ){
469 $date_str_to .=
"<th class='head_date_th date_to'>{$tof["time
"]}</th>";
471 }
else if( ($year_same) OR ($year_same AND $month_same) ){
472 $date_str_common .=
"<th class='head_date_th date_common'>{$fromf["year
"]}</th>";
473 $date_str_from .=
"<th class='head_date_th date_from'><span style='display:block;font-weight:bold'>{$fromf["day
"]} {$fromf["mon
"]}</span>";
474 if( $fromf[
"time"] !=
"00:00" ){
475 $date_str_from .=
"<span style='display:block'>{$fromf["time
"]}</span></th>";
477 $date_str_to .=
"<th class='head_date_th date_to'><span style='display:block;font-weight:bold'>{$tof["day
"]} {$tof["mon
"]}</span>";
478 if( $tof[
"time"] !=
"00:00" ){
479 $date_str_to .=
"<span style='display:block'>{$tof["time
"]}</span></th>";
482 $date_str_common .=
"<th class='head_date_th date_common'></th>";
483 $date_str_from .=
"<th class='head_date_th date_from'><span style='display:block'><span style='font-weight:bold'>{$fromf["day
"]} {$fromf["mon
"]}</span> {$fromf["year
"]}</span>";
484 if( $fromf[
"time"] !=
"00:00" ){
485 $date_str_from .=
"<span class='head_date_span date_from' style='display:block'>{$fromf["time
"]}</span></th>";
487 if( $to !==
"0000-00-00 00:00" ){
488 $date_str_to .=
"<th class='head_date_th date_to'><span style='display:block'><span style='display:block'><span style='font-weight:bold'>{$tof["day
"]} {$tof["mon
"]}</span> {$tof["year
"]}</span>";
489 if( $tof[
"time"] !=
"00:00" ){
490 $date_str_to .=
"<span style='display:block'>{$tof["time
"]}</span></th>";
493 $date_str_to .=
"<th class='head_date_th date_to'></th>";
501 return array(
"common" => $date_str_common,
"from" => $date_str_from,
"to" => $date_str_to );
506 $font_family= $this->
get_config(
"font-family");
509 if( $font_family !=
""){ $font_family =
"font-family:".$font_family; }
510 if( $font_size !=
""){ $font_size =
"font-size:".$font_size; }
511 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
513 $month_names = array(
"" ,
"Jan." ,
"Feb." ,
"Mrz." ,
"Apr." ,
"Mai" ,
"Jun." ,
"Jul." ,
"Aug" ,
"Sep." ,
"Oct.",
"Nov." ,
"Dez.");
521 $maybeValue = $this->
get_config(
"maybeValue");
522 $options_map = array(
"" =>
"" ,
"yes" => $yesValue ,
"maybe" => $maybeValue ,
"no" => $noValue );
527 foreach( $this->widget_list as $child ){
531 if( $child->get_date(
"to") ==
"0000-00-00 00:00" ){ ++$c_no_to; }
534 $count[ $child->ID] = array(
"yes"=>0 ,
"maybe"=>0 ,
"no" =>0);
536 if( $c_no_to == $c_dates ){
541 echo
"<table class='schedule_table'>";
544 $date_str_common =
$tmp[
"common"];
545 $date_str_from =
$tmp[
"from"];
546 $date_str_to =
$tmp[
"to"];
547 echo
"<tr><th></th>$date_str_common</tr>";
548 if( $no_to ===
false){
549 echo
"<tr><th style='text-align:right;padding-right:1em''>von/am</th>$date_str_from</tr>";
550 echo
"<tr><th style='text-align:right;padding-right:1em'>bis</th>$date_str_to</tr>";
552 echo
"<tr><th style='text-align:right;padding-right:1em''>am</th>$date_str_from</tr>";
556 $cells = str_repeat(
"<td></td>",
sizeof($this->widget_list));
557 echo
"<tr class='spacer_tr'>$cells</tr>";
558 echo
"<tr><th style='text-align:right;padding-right:1em;' class='schedule_response_td_name'>Max Muster</th>";
559 foreach( $this->widget_list as $child ){
561 echo
"<td class='schedule_response_td schedule_response_td_yes'>{$yesValue}</td>";
569 if( $this->
get_config(
"displayOtherUsersStatistics") ){
570 $cells = str_repeat(
"<td></td>",
sizeof($this->widget_list));
571 echo
"<tr class='spacer_tr'>$cells</tr>";
572 echo
"<tr style='text-align:center' class='schedule_count_tr'><td></td>";
573 foreach( $this->widget_list as $child ){
576 foreach( array(
"yes",
"maybe",
"no") as $val){
578 echo
"<span class='schedule_count_span_$val $m'>{$count[$child->ID][$val]}</span>";
586 $cells = str_repeat(
"<td></td>",
sizeof($this->widget_list));
587 echo
"<tr class='spacer_tr'>$cells</tr>";
588 echo
"<tr class='participate_tr'>";
589 $name_restriction = $this->
get_config(
"usernameRestriction");
590 if( $name_restriction ==
"free" ){
591 $name = $_SESSION[
"user"]->fullName;
592 echo
"<td><input type='text' value='{$name}' size='10' name='{$this->name}_name'/></td>";
593 }
else if($name_restriction ==
"force"){
594 $name = $_SESSION[
"user"]->fullName;
595 echo
"<td>{$name}</td>";
596 }
else if( $name_restriction ==
"none" ){
600 foreach( $this->widget_list as $child ){
602 echo
"<td> <select name='{$child->name}'>";
603 foreach( array_keys($options_map) as $op ){
604 echo
"<option value='{$op}'>{$options_map[$op]}</option>";
606 echo
" </select> </td>";
618 $font_family= $this->
get_config(
"font-family");
621 if( $font_family !=
""){ $font_family =
"font-family:".$font_family; }
622 if( $font_size !=
""){ $font_size =
"font-size:".$font_size; }
623 if( $font_bold ==
true){ $font_bold =
"font-weight:bold"; }
else{ $font_bold=
""; }
625 $month_names = array(
"" ,
"Jan." ,
"Feb." ,
"Mrz." ,
"Apr." ,
"Mai" ,
"Jun." ,
"Jul." ,
"Aug" ,
"Sep." ,
"Oct.",
"Nov." ,
"Dez.");
633 $maybeValue = $this->
get_config(
"maybeValue");
634 $options_map = array(
"" =>
"" ,
"yes" => $yesValue ,
"maybe" => $maybeValue ,
"no" => $noValue );
639 foreach( $this->widget_list as $child ){
643 if( $child->get_date(
"to") ==
"0000-00-00 00:00" ){ ++$c_no_to; }
646 $count[ $child->ID] = array(
"yes"=>0 ,
"maybe"=>0 ,
"no" =>0);
648 if( $c_no_to == $c_dates ){
652 echo
"<div class='widget_container schedule_widget' style='$font_family;$font_size'>";
653 echo
"<table class='schedule_table'>";
656 $date_str_common =
$tmp[
"common"];
657 $date_str_from =
$tmp[
"from"];
658 $date_str_to =
$tmp[
"to"];
659 echo
"<tr><th></th>$date_str_common</tr>";
660 echo
"<tr><th style='text-align:right;padding-right:1em''>von/am</th>$date_str_from</tr>";
661 if( $no_to ===
false ){
662 echo
"<tr><th style='text-align:right;padding-right:1em'>bis</th>$date_str_to</tr>";
666 $cells = str_repeat(
"<td></td>",
sizeof($this->widget_list));
667 echo
"<tr class='spacer_tr'>$cells</tr>";
668 if( isset($name_wid) ){
670 for(
$i=0 ;
$i<
sizeof(
$data[$name_wid->ID]) ; ++
$i ){
671 echo
"<tr><th style='text-align:right;padding-right:1em;' class='schedule_response_td_name'>{$data[$name_wid->ID][$i]}</th>";
672 foreach( $this->widget_list as $child ){
674 if( (isset(
$data[$child->ID])) AND (isset(
$data[$child->ID][
$i])) ){
676 if(
$data[$child->ID][$i] == $yesValue ){ ++
$count[$child->ID][
"yes"];$css=
"yes";}
677 else if(
$data[$child->ID][$i] == $maybeValue ){++
$count[$child->ID][
"maybe"];$css=
"maybe";}
678 else if(
$data[$child->ID][$i] == $noValue ){++
$count[$child->ID][
"no"];$css=
"no";}
679 echo
"<td class='schedule_response_td schedule_response_td_{$css}'>{$data[$child->ID][$i]}</td>";
693 if( $this->
get_config(
"displayOtherUsersStatistics") ){
694 $cells = str_repeat(
"<td></td>",
sizeof($this->widget_list));
695 echo
"<tr class='spacer_tr'>$cells</tr>";
696 echo
"<tr style='text-align:center' class='schedule_count_tr'><td></td>";
697 foreach( $this->widget_list as $child ){
700 foreach( array(
"yes",
"maybe",
"no") as $val){
702 if( max(
$count[$child->ID]) ==
$count[$child->ID][$val] ){
703 $m=
"schedule_count_max";
705 echo
"<span class='schedule_count_span_$val $m'>{$count[$child->ID][$val]}</span>";
713 $cells = str_repeat(
"<td></td>",
sizeof($this->widget_list));
714 echo
"<tr class='spacer_tr'>$cells</tr>";
715 echo
"<tr class='participate_tr'>";
716 $name_restriction = $this->
get_config(
"usernameRestriction");
717 if( $name_restriction ==
"free" ){
719 if( isset($_SESSION[
"user"]) ){
720 $name = $_SESSION[
"user"]->fullName;
722 if( $name_wid->value !=
"" ){
723 $name = $name_wid->value;
725 echo
"<td><input type='text' value='{$name}' size='10' name='{$this->name}_name'/></td>";
726 }
else if($name_restriction ==
"force"){
728 if( isset($_SESSION[
"user"]) ){
729 $name = $_SESSION[
"user"]->fullName;
731 echo
"<td>{$name}</td>";
732 }
else if( $name_restriction ==
"none" ){
736 foreach( $this->widget_list as $child ){
738 echo
"<td> <select name='{$child->name}'>";
740 foreach( array_keys($options_map) as $key ){
742 if( $child->value === $options_map[$key] ){
743 echo
"<option value='{$key}' selected='selected'>{$options_map[$key]}</option>";
745 echo
"<option value='{$key}'>{$options_map[$key]}</option>";
748 echo
" </select> </td>";
764 $maybeValue = $this->
get_config(
"maybeValue");
765 $options_map = array(
"yes" => $yesValue ,
"maybe" => $maybeValue ,
"no" => $noValue );
769 foreach( $this->widget_list as $child ){
771 if( (isset($_POST[$child->name])) AND ($_POST[$child->name] !=
"") ){
772 foreach( array_keys($options_map) as $key ){
773 if( $_POST[$child->name] === $key ){
774 $child->value = $options_map[$key];
779 $req = $child->check_required();
780 if( ($child->value ==
"") AND ($req !==
true) ){
785 $name_widget = $child;
790 $name_restriction = $this->
get_config(
"usernameRestriction");
791 if( $name_restriction ==
"free" ){
792 if( (isset($name_widget)) AND ($name_widget instanceof
scheduleName) ){
793 if( (isset($_POST[
"{$this->name}_name"])) ){
794 $r = $name_widget->set_value($_POST[
"{$this->name}_name"]);
800 $err[] =
"Interner Fehler. Konnte scheduleName nicht in der Widgetliste finden";
802 }
else if($name_restriction ==
"force"){
803 $r = $name_widget->set_value( $_SESSION[
"user"]->fullName );
804 }
else if($name_restriction ==
"none"){
805 $name_widget->set_value(
"");
808 if(
sizeof(
$err) == 0){