[% USE date %]
[%# which one is authorized? #%]
[% IF !c.check_cmd_permissions('service', c.request.parameters.service, 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 service check'
   description = 'This command is used to schedule the next check of a particular service. your Monitoring will re-queue the service 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 service regardless of both what time the scheduled check occurs and whether or not checks are enabled for the service.'
%]

[%# definition of the command send to your backend #%]
[% BLOCK action %]
    [% service_desc         = c.request.parameters.service %]
    [% 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_SVC_CHECK;[% sprintf("%s;%s;%lu",host_name,service_desc,start_time_unix) %]
    [% ELSE %]
        SCHEDULE_SVC_CHECK;[% sprintf("%s;%s;%lu",host_name,service_desc,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_service %]
  [% PROCESS cmd_form_start_time range=0 %]
  [% PROCESS cmd_form_force_check %]

[% END %]
[% END %]
