$templates.shared.doctype
{=
include "templates.shared.util.encode_js";
# ------------------------
# check number of profiles
# ------------------------
# If no profile exist then don't allow to open the scheduler!
int number_of_profiles = num_subnodes("profiles");
# ----------------------------
# Check scheduler default view
# ----------------------------
bool view_by_tasks = true;
if (node_exists("preferences.miscellaneous.scheduler_view_by_tasks")) then (
view_by_tasks = node_value("preferences.miscellaneous.scheduler_view_by_tasks");
);
# --------------------------
# Subroutine build_view_node
# --------------------------
subroutine(build_view_node(bool view_by_tasks), (
if (node_exists("volatile.temp.primary_fields")) then (
delete_node("volatile.temp.primary_fields");
);
node item;
string action_name;
string action_label;
string profile_name;
string profile_label;
string profile_position;
string schedule_id;
int field_id; # is equal number of subnodes in secondary_fields node
string volatile_path;
foreach item "schedule" (
action_name = node_value(subnode_by_name(item, "action"));
# For backward compatibility check for generate_all_report_files nodes!
# generate_all_report_files become generate_report_files!
if (action_name eq "generate_all_report_files") then (
action_name = "generate_report_files";
);
action_label = node_value("lang_options.command_line." . action_name . ".label");
profile_name = node_value(subnode_by_name(item, "profile"));
schedule_id = node_name(item);
if (profile_name eq "*") then (
profile_name = "esc_all_profiles";
profile_label = lang_admin.scheduler.all_profiles_label;
profile_position = "0";
)
else (
if (node_exists("profiles." . profile_name)) then (
profile_label = node_value("profiles." . profile_name . ".label");
if (contains(profile_label, "$")) then (profile_label = replace_all(profile_label, "$", "$"));
)
else (
profile_label = profile_name;
profile_name = "esc_no_profile_" . profile_name;
);
profile_position = profile_label;
);
if (view_by_tasks) then (
# ----------------
# if view by tasks
# ----------------
if (!node_exists("volatile.temp.primary_fields." . action_name . "label")) then (
"volatile.temp.primary_fields." . action_name . ".label" = action_label;
"volatile.temp.primary_fields." . action_name . ".position" = action_label;
);
if (!node_exists("volatile.temp.primary_fields." . action_name . ".secondary_fields")) then (
field_id = 0;
)
else (
field_id = num_subnodes("volatile.temp.primary_fields." . action_name . ".secondary_fields");
);
volatile_path = "volatile.temp.primary_fields." . action_name . ".secondary_fields." . field_id;
volatile_path . ".schedule_id" = schedule_id;
volatile_path . ".label" = profile_label;
volatile_path . ".position" = profile_position;
)
else (
# -------------------
# if view by profiles
# -------------------
if (!node_exists("volatile.temp.primary_fields." . profile_name . "label")) then (
"volatile.temp.primary_fields." . profile_name . ".label" = profile_label;
"volatile.temp.primary_fields." . profile_name . ".position" = profile_position;
);
if (!node_exists("volatile.temp.primary_fields." . profile_name . ".secondary_fields")) then (
field_id = 0;
)
else (
field_id = num_subnodes("volatile.temp.primary_fields." . profile_name . ".secondary_fields");
);
volatile_path = "volatile.temp.primary_fields." . profile_name . ".secondary_fields." . field_id;
volatile_path . ".schedule_id" = schedule_id;
volatile_path . ".label" = action_label;
volatile_path . ".position" = action_label;
);
); # foreach item
# debug_message("NEW TEMP TASK NODE SORTED\n" . node_as_string("volatile.temp.primary_fields") . "\n");
));
# ------------------------------
# Subroutine get_schedule_string
# ------------------------------
subroutine(get_schedule_string(string schedule_id), (
node schedule = "schedule." . schedule_id;
string month = node_value(subnode_by_name(schedule, "month"));
string day;
string day_of_month = node_value(subnode_by_name(schedule, "day_of_month"));
string day_of_week = node_value(subnode_by_name(schedule, "day_of_week"));
string hour = node_value(subnode_by_name(schedule, "hour"));
string minute = node_value(subnode_by_name(schedule, "minute"));
if (month eq "*") then (
month = lang_admin.scheduler.any_month;
)
else (
month = node_value("lang_stats.months." . month);
);
day = lang_admin.scheduler.any_day;
if (day_of_month ne "*") then (
day = lang_admin.scheduler.day . " " . day_of_month;
);
if (day_of_week ne "*") then (
day = node_value("lang_stats.weekdays." . day_of_week);
);
if (hour ne "*") then (
if (length(hour) == 1) then (
hour = "0" . hour;
);
)
else (
hour = lang_admin.scheduler.any_hour;
);
if (minute ne "*") then (
if (length(minute) == 1) then (
minute = "0" . minute;
);
)
else (
minute = lang_admin.scheduler.any_minute;
);
month . ", " . day . ", " . hour . ":" . minute;
));
# ---------------------------
# Subroutine build_view_table
# ---------------------------
subroutine(build_view_table(bool view_by_tasks), (
sort("volatile.temp.primary_fields", "field:position,alphabetical,ascending");
# debug_message("NEW TEMP TASK NODE SORTED\n" . node_as_string("volatile.temp.primary_fields") . "\n");
'
{=
bool tasks_exists = false;
if (node_exists("schedule")) then (
if (num_subnodes("schedule") >= 1) then (
tasks_exists = true;
);
);
if (tasks_exists) then (
# ---------------------
# Scheduler view switch
# ---------------------
'
\n';
'\n';
'';
'' . lang_admin.scheduler.actions_profiles_label . '';
'' . lang_admin.scheduler.profiles_actions_label . '';
' | \n';
'\n';
'\n';
' | \n';
'
\n';
'
\n';
# --------------------
# Tasks/Profiles table
# --------------------
'
\n';
build_view_node(true);
build_view_table(true);
'
\n';
# --------------------
# Profiles/Tasks table
# --------------------
'
\n';
build_view_node(false);
build_view_table(false);
'
\n';
)
else (
# -------------------
# No task in schedule
# -------------------
'
' . lang_admin.scheduler.no_actions_defined_info . '
\n';
);
expand(templates.shared.copyright);
'
\n';
=}