prepare(); fill_time_slots(); //fill the timeslots text $agenda_edit = fill_agenda_list(); //get the different agenda's //$tpl->assign( "year_prev", $y_prev ); $tpl->assign("year_next", $y_next); $tpl->assign("month", $month); $tpl->assign("year", $year); $tpl->assign("cur_date", $edit_date[2] . " " . $lang_month[$edit_date[1]] . " " . $edit_date[0]); for ($i = 1; $i < 13; $i++) { //fill the month's link bar $k = $i + $month -1; //set current month as first entry if ($k > 12) { //if larger as 12 start counting at 1 $k = $i + $month -13; $year_link = $y_next; } else { $year_link = $year; } $m = substr($lang_month[$k], 0, 3); //get the first three letters of month $tpl->assign("m$i", "$m"); } $tpl->assign("year_next", "$y_next >>"); $tpl->assign("year_prev", "<< $y_prev"); if ($d +7 > $nr) { //fill the week forward link $tpl->assign("day_forward", $d +7 - $nr); $tpl->assign("month_forward", $m_next); if (($m_next == 1) and ($m_next < $month)) //next month is in next year { $tpl->assign("year_forward", $year +1); } else { $tpl->assign("year_forward", $year); } } else { $tpl->assign("day_forward", $d +7); $tpl->assign("month_forward", $month); $tpl->assign("year_forward", $year); } if ($d -7 < 1) { //fill the week backward link $tpl->assign("day_back", $nr_prev + $d -7); $tpl->assign("month_back", $m_prev); if (($m_prev == 12) and ($m_next > $month)) //next month is in previous year { $tpl->assign("year_back", $year -1); } else { $tpl->assign("year_back", $year); } } else { $tpl->assign("day_back", $d -7); $tpl->assign("month_back", $month); $tpl->assign("year_back", $year); } for ($i = 1; $i < 6; $i++) //fill the week numbers { if ($start_week + $i -2 == 52) { $start_week = 2 - $i; } //reset to week 1 if larger than 52 $tpl->assign("w$i", $start_week + $i -1); } for ($i = 1; $i < 36; $i++) //fill the day numbers and set colors { if (($i == 6) or ($i == 7) or ($i == 13) or ($i == 14) or ($i == 20) or ($i == 21) or ($i == 27) or ($i == 28) or ($i == 34) or ($i == 35)) { $tpl->assign("color$i", $weekend_color); } else { $tpl->assign("color$i", $day_color); } //set color for the day if ($i + $day -1 < 1) { //days of previous month $day_number = $nr_prev -abs($day) + $i -1; if ($i == 1) { if ($m_prev == 12) { //previous month is dec so we need previous year $query_date_first = "$y_prev-$m_prev-$day_number"; //this is the first date of the 5 weeks period } else { $query_date_first = "$year-$m_prev-$day_number"; } } //this is the first date of the 5 weeks period $tpl->assign("$i", "$day_number"); $tpl->assign("curdate$i", "document.getElementById('date').innerHTML='$day_number $lang_month[$m_prev] $y_prev';"); if (($day_number == date("j")) and ($m_prev == date("n")) and ($y_prev == date("Y"))) { $tpl->assign("color$i", $active_day_color); } } if (($i + $day -1 < $nr +1) and ($i + $day -1 > 0)) { //days of this month $day_number = $day + $i -1; if ($i == 1) { $query_date_first = "$day_number-$month-$year"; } //this is the first date of the 5 weeks period if ($i == 35) { $query_date_last = "$day_number-$month-$year"; } //this is the last date of the 5 weeks period $tpl->assign("$i", "$day_number"); $tpl->assign("curdate$i", "document.getElementById('date').innerHTML='$day_number $lang_month[$month] $year';"); if (($day_number == date("j")) and ($month == date("n")) and ($year == date("Y"))) { $tpl->assign("color$i", $active_day_color); } } if ($i + $day -1 > $nr) { //days of next month $day_number = $i - $nr + $day -1; if (($m_next == 1) and ($m_next < $month)) //next month is in next year { $y_next = $year +1; } else { $y_next = $year; } if ($i == 35) { $query_date_last = "$day_number-$m_next-$y_next"; } //this is the last date of the 5 weeks period $tpl->assign("$i", "$day_number"); $tpl->assign("curdate$i", "document.getElementById('date').innerHTML='$day_number $lang_month[$m_next] $y_next';"); if (($day_number == date("j")) and ($m_next == date("n")) and ($y_next == date("Y"))) { $tpl->assign("color$i", $active_day_color); } } } //fill the timeslots from the mysql table $num = 0; $where_clause = ""; for ($k = 0; $k < count($a); $k++) { if ($a[$k] != "") { //get the agenda numbers for the where clause $where_clause .= " OR agenda = $a[$k]"; $num++; } //create where clause of agenda id's } $where_clause = substr($where_clause, 3); $query = "SELECT adate, timeslot, descr, agenda FROM $table_agenda_events WHERE adate = '$_GET[date_edit]' AND ($where_clause) ORDER BY timeslot, agenda"; $result = mysql_query($query); //print $query; $i = 0; while ($time_list = mysql_fetch_array($result)) //fill the description from table { $slot[$i] = $time_list[1]; $descr[$i] = $time_list[2]; $i++; } $i = 0; if ($num == 1) //we have one agenda to edit { for ($k = 1; $k < 46; $k++) //loop trough the time slots and fill the data { if ($k == $slot[$i]) //slotnumber is equal { $value = $descr[$i]; $i++; } else { $value = ""; } if ($k == 45) //remarks field needs a bigger input field { $tpl->assign("app$k", ""); // $tpl->assign( "app$k", ""); } else { $tpl->assign("app$k", ""); } } } else //we have multiple agenda's { for ($k = 1; $k < 46; $k++) { //loop trough the time slots and fill the data $tpl->assign("app$k", ""); } if (count($slot) > 0) { foreach ($slot as $key => $value) { $tpl->assign("app$value", "