{= #debug_message('- calendar.cfv start the calendar template'); query_db_calendar("volatile.query_result"); node query_result = "volatile.query_result"; debug_message("\ncalendar query result: " . node_as_string(query_result) . "\n"); # variables required to get the start_date and end_date of the log data int start_year = 0; int start_month = 0; int start_month_js = 0; int start_day = 0; int end_year = 0; int end_month = 0; int end_month_js = 0; int end_day = 0; int count_year = 0; int count_month = 0; int count_day = 0; int count = 0; node year_node; # js array which contains all months in the calendar string log_months = "["; foreach year_node query_result ( int year = node_name(year_node); if (count_year == 0) then (start_year = year); end_year = year; node month_node; foreach month_node year_node ( int month = node_name(month_node); int month_js = month - 1; # required for javascript where the months start with 0 if (count_month == 0) then (start_month = month); end_month = month; # write month to internal node for later use "internal.date_time.query_result." . year . "." . month = true; string log_days = "_log_days['" . year . "_" . month_js . "'] = ["; log_months .= "'" . year . "_" . month_js . "',"; node day_node; foreach day_node month_node ( int day = node_name(day_node); if (count_day == 0) then (start_day = day); end_day = day; # write days to internal node for later use "internal.date_time.query_result." . year . "." . month . ".days." . day = true; log_days .= day . ","; count_day++; ); log_days = replace_last(log_days,",","];"); ("internal.date_time.js_array_log_days." . count) = log_days; # "internal.date_time.js_array_log_days." . count = print("$log_days"); count_month++; count++; ); count_year++; ); #debug_message("internal.date_time.js_array_log_days: " . node_as_string("internal.date_time.js_array_log_days") . "\n"); start_month_js = start_month - 1; end_month_js = end_month -1; log_months = replace_last(log_months, ",", "]"); internal.date_time.js_var_log_start_date = print("new Date ($start_year, $start_month_js, $start_day);"); internal.date_time.js_var_log_end_date = print("new Date ($end_year, $end_month_js, $end_day);"); internal.date_time.js_log_months = log_months; save_session_changes(); =}