[% 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 acknowledge a service problem'
   description = 'This command is used to acknowledge a service problem. When a service problem is acknowledged, future notifications about problems are temporarily disabled until the service recovers. This is the behaviour when the "Sticky Acknowledgement" checkbox is checked, as it is by default. Acknowledgment with "Sticky Acknowledgement" disabled will cause notifications to be re-enabled when the service state next changes, no matter what the new state is.  Contacts for this service will receive a notification about the acknowledgement, so they are aware that someone is working on the problem. Additionally, a comment will also be added to the service. Make sure to enter your name and fill in a brief description of what you are doing in the comment field. If you would like the service comment to remain once the acknowledgement is removed, check the "Persistent Comment" checkbox. If you do not want an acknowledgement notification sent out to the appropriate contacts, uncheck the "Send Notification" checkbox.'
%]

[%# definition of the command send to your backend #%]
[% BLOCK action %]
    [% IF c.request.parameters.send_notification || force_send_notification %][% send_notification = 1 %][% ELSE %][% send_notification = 0 %][% END %]
    [% IF c.request.parameters.sticky_ack || force_sticky_ack %][% sticky_ack = 2 %][% ELSE %][% sticky_ack = 0 %][% END %]
    [% IF c.request.parameters.persistent || force_persistent_ack %][% persistent_comment = 1 %][% ELSE %][% persistent_comment = 0 %][% END %]
    [% comment_data         = c.request.parameters.com_data %]
    [% service_desc         = c.request.parameters.service %]
    [% host_name            = c.request.parameters.host %]
    [% comment_author       = c.request.parameters.com_author %]

    [% IF has_expire_acks && end_time_unix > 0 && c.request.parameters.use_expire %]
    ACKNOWLEDGE_SVC_PROBLEM_EXPIRE;[% sprintf("%s;%s;%d;%d;%d;%d;%s;%s",host_name,service_desc,sticky_ack,send_notification,persistent_comment,end_time_unix,comment_author,comment_data) %]
    [% ELSE %]
    ACKNOWLEDGE_SVC_PROBLEM;[% sprintf("%s;%s;%d;%d;%d;%s;%s",host_name,service_desc,sticky_ack,send_notification,persistent_comment,comment_author,comment_data) %]
    [% END %]
[% END %]

[% IF c.request.parameters.end_time;   SET end_time   = c.request.parameters.end_time;   ELSE; SET end_time   = format_date(date.now+expire_ack_duration, '%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_sticky_ack %]
  [% PROCESS cmd_form_send_notification %]
  [% PROCESS cmd_form_persistent_acks %]
  [% PROCESS cmd_form_expire_acks %]
  [% PROCESS cmd_form_author %]
  [% PROCESS cmd_form_comment %]

[% END %]
[% END %]
