[% 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[% ELSE %]SCHEDULE_HOST_CHECK[% END %];[% sprintf("%s;%lu",host_name,start_time_unix) %]
[% 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:%S'); END %]

[%# definition of the html form data #%]
<tr><td class='optBoxRequiredItem'>Host Name:</td><td><b><input type='text' name='host' value='[% c.request.parameters.host %]'></b></td></tr>
<tr><td class='optBoxRequiredItem'>Check Time:</td><td><b><input type='text' name='start_time' id="start_time" value='[% start_time %]'> <a href="javascript:show_cal('start_time')"><img src="[% url_prefix %]thruk/themes/[% theme %]/images/calendar.png" width="16" height="16" alt="pick date"></a></b></td></tr>
<tr><td class='optBoxItem'>Force Check:</td><td><b><input type='checkbox' name='force_check'[% IF c.config.cmd_defaults.force_check %] checked[% END %]></b></td></tr>

[% END %]
[% END %]
