[% USE date %]
[%# which one is authorized? #%]
[% IF !c.check_cmd_permissions('host', c.request.parameters.host) %]
  [% WRAPPER error.tt errorMessage = "you are not authorized for this command" errorDescription = "check your configuration if you believe this is an error" %][% END %]
[% ELSE %]

[%# description used by the commands page #%]
[% WRAPPER $cmd_tt
   request     = 'You are requesting to schedule a host check'
   description = 'This command is used to schedule the next check of a particular host. your Monitoring will re-queue the host to be checked at the time you specify. If you select the <i>force check</i> option, your Monitoring will force a check of the host regardless of both what time the scheduled check occurs and whether or not checks are enabled for the host.'
%]

[%# definition of the command send to your backend #%]
[% BLOCK action %]
    [% host_name            = c.request.parameters.host %]
    [%# rescheduling with date in the past breaks latency #%]
    [% IF start_time_unix < date.now %][% start_time_unix = date.now %][% END %]

    [% IF c.request.parameters.force_check %]
        SCHEDULE_FORCED_HOST_CHECK;[% sprintf("%s;%lu",host_name,start_time_unix) %]
    [% ELSE %]
        SCHEDULE_HOST_CHECK;[% sprintf("%s;%lu",host_name,start_time_unix) %]
    [% END %]
[% END %]

[% IF c.request.parameters.start_time; SET start_time = c.request.parameters.start_time; ELSE; SET start_time = format_date(date.now,      '%Y-%m-%d %H:%M:00'); END %]

[%# definition of the html form data #%]
[% PROCESS _cmd_parts.tt %]
  [% PROCESS cmd_form_host %]
  [% PROCESS cmd_form_start_time range=0 %]
  [% PROCESS cmd_form_force_check %]

[% END %]
[% END %]
