12) { $m_next = 1; //next month is in next year $y_next = $year +1; $nr_next = date("t", mktime(12, 0, 0, $m_next, 1, $y_next)); //number of days next month previous year } else { $nr_next = date("t", mktime(12, 0, 0, $m_next, 1, $year)); //number of days next month this year } $nr = date("t", mktime(12, 0, 0, $month, 1, $year)); //nr of days of the current month $firstday = date("w", mktime(12, 0, 0, $month, $d, $year)); //what is the weekday of current date if ($firstday == 0) { $firstday = 7; } //our current day is a sunday so we need 7 an not 0 $day = $d - $firstday +1; //what is the monday, this is our first day of the first week $start_week = date("W", mktime(12, 0, 0, $month, $day, $year)); //what is first week number $week_day = date("w", mktime(12, 0, 0, $month, $d, $year)); function fill_time_slots() //fill the wording of the time slots from table { global $tpl; global $table_configuration; global $timeslots_header_color; $query = "SELECT config_value FROM $table_configuration WHERE config_key LIKE 'agenda_time%' ORDER BY config_key"; $result = mysql_query($query); $i = 1; while ($time_list = mysql_fetch_array($result)) //fill the time stamps from table { $tpl->assign("time$i", $time_list[0]); $i++; } $tpl->assign("timeslots_header_color", $timeslots_header_color); } function fill_agenda_list() { global $tpl; global $d; global $month; global $year; global $a; global $sas_lang, $userid, $table_users; global $table_agenda_name; global $bgcolor, $months_bgcolor, $week_days_bgcolor, $week_number_bgcolor, $mouse_over_color; if (IsSet ($_POST[a])) { $a = $_POST[a]; } if (IsSet ($_GET[a])) { $a = explode(",", $_GET[a]); } $query = "SELECT id, name, username FROM $table_agenda_name ORDER BY sort"; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { print "" . $sas_lang['agenda_empty_agenda_warning'] . ""; exit; } $i = 0; while ($row = mysql_fetch_array($result)) { $agenda[$i] = $row[1]; $agenda_id[$i] = $row[0]; $agenda_user[$i] = $row[2]; $i++; } //print_r($a); //print_r($agenda_id); $agenda_name = ""; $agenda_result = "
"; $agenda_result .= "" . $sas_lang['agenda_title'] . ": "; if (count($a) == 0) { //no agenda was chosen $query = "SELECT username FROM $table_users WHERE id = '$userid'"; //lets see if the user has an agenda $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $username = mysql_result($result, 0, 0); unset ($query); unset ($result); $key = array_search($username, $agenda_user); //find the key of the agenda for this user $a[$key] = $agenda_id[$key]; //use this agenda for the default for ($key = 0; $key < $i; $key++) { $agenda_edit_id .= "$a[$key],"; //create comma delimited string of agenda id's } $agenda_edit_id = substr($agenda_edit_id, 0, -1); //strip last comma } else { $agenda_edit_id = $agenda_id[0]; //no agenda was set use the first in order $a[0] = $agenda_id[0]; } } else //agenda was chosen { $agenda_edit_id = ""; for ($k = 0; $k < $i; $k++) { $agenda_edit_id .= "$a[$k],"; //create comma delimited string of agenda id's } $agenda_edit_id = substr($agenda_edit_id, 0, -1); //strip last comma } //print $agenda_edit_id ; $i = 0; for ($k = 0; $k < count($agenda); $k++) { //loop through the agenda's // print " a: $a[$k] agenda:$agenda_id[$k]"; if ($agenda_id[$k] == $a[$k]) { $checked = "checked"; } else { $checked = ""; } $a_new = str_repeat(",", $k) . $agenda_id[$k]; //make comma delimted string for the agenda link $agenda_result .= "$agenda[$k] "; if ((IsSet ($a[$k])) and ($a[$k] != "")) { $agenda_name = $agenda[$k]; $i++; } } if ($i > 1) { $agenda_name = $sas_lang['multiple_agenda']; } $tpl->assign("agenda_name", $agenda_name); $tpl->assign("agenda_list", $agenda_result); $tpl->assign("today", "agenda.php?a=" . $agenda_edit_id); $tpl->assign("button_today", $sas_lang['today']); $tpl->assign("h1", $sas_lang['week_title1']); //set week titles $tpl->assign("h2", $sas_lang['week_title2']); $tpl->assign("h3", $sas_lang['week_title3']); $tpl->assign("h4", $sas_lang['week_title4']); $tpl->assign("h5", $sas_lang['week_title5']); $tpl->assign("h6", $sas_lang['week_title6']); $tpl->assign("h7", $sas_lang['week_title7']); $tpl->assign("h8", $sas_lang['week_title8']); $tpl->assign("bgcolor", $bgcolor); //set background color $tpl->assign("months_bgcolor", $months_bgcolor); //set months background color $tpl->assign("week_days_bgcolor", $week_days_bgcolor); //set weekdays background color $tpl->assign("week_number_bgcolor", $week_number_bgcolor); //set weeknumber background color $tpl->assign("mouse_over_color", $mouse_over_color); //set mouse over color for a day cell return $agenda_edit_id; } ?>