[% 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 acknowledge a host problem'
   description = 'This command is used to acknowledge a host problem. When a host problem is acknowledged, future notifications about problems are temporarily disabled until the host recovers. This is the behaviour when the &quot;Sticky Acknowledgement&quot; checkbox is checked, as it is by default. Acknowledgment with &quot;Sticky Acknowledgement&quot; disabled will cause notifications to be re-enabled when the host state next changes, no matter what the new state is. Contacts for this host 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 host. 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 host comment to remain once the acknowledgement is removed, check the &quot;Persistent Comment&quot; checkbox. If you do not want an acknowledgement notification sent out to the appropriate contacts, uncheck the &quot;Send Notification&quot; checkbox.'
%]

[%# definition of the command send to your backend #%]
[% BLOCK action %]
    [% IF c.request.parameters.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 %]
    [% 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_HOST_PROBLEM_EXPIRE;[% sprintf("%s;%d;%d;%d;%d;%s;%s",host_name,sticky_ack,send_notification,persistent_comment,end_time_unix,comment_author,comment_data) %]
    [% ELSE %]
    ACKNOWLEDGE_HOST_PROBLEM;[% sprintf("%s;%d;%d;%d;%s;%s",host_name,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_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 %]
