[% 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 changes from its current state. If you want acknowledgement to disable notifications until the service recovers, check the "Sticky Acknowledgement" checkbox. 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 %][% send_notification = 1 %][% ELSE %][% send_notification = 0 %][% END %]
    [% IF c.request.parameters.sticky_ack %][% sticky_ack = 2 %][% ELSE %][% sticky_ack = 0 %][% END %]
    [% IF c.request.parameters.persistent %][% 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:%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'>Service:</td><td><b><input type='text' name='service' value='[% c.request.parameters.service %]'></b></td></tr>
<tr><td class='optBoxItem'>Sticky Acknowledgement:</td><td><b><input type='checkbox' name='sticky_ack'[% IF c.config.cmd_defaults.sticky_ack %] checked[% END %]></b></td></tr>
<tr><td class='optBoxItem'>Send Notification:</td><td><b><input type='checkbox' name='send_notification'[% IF c.config.cmd_defaults.send_notification %] checked[% END %]></b></td></tr>
<tr><td class='optBoxItem'>Persistent Comment:</td><td><b><input type='checkbox' name='persistent'[% IF c.config.cmd_defaults.persistent_ack %] checked[% END %]></b></td></tr>
[% IF has_expire_acks %]
<tr><td class='optBoxItem'>Use Expire Time:</td><td><b><input type='checkbox' name='use_expire' onchange="if(this.checked == true) {showElement('expire_row')} else { hideElement('expire_row')};"[% IF c.config.cmd_defaults.use_expire %] checked[% END %]></b></td></tr>
<tr id="expire_row"[% IF !c.config.cmd_defaults.use_expire %] style="display:none"[% END %]><td class='optBoxItem'>Expire Time:</td><td><b><input type='text' name='end_time' id="end_time" value='[% end_time %]'> <a href="javascript:show_cal('end_time')"><img src="[% url_prefix %]thruk/themes/[% theme %]/images/calendar.png" width="16" height="16" alt="pick date"></a></b></td></tr>
[% END %]
<tr><td class='optBoxRequiredItem'>Author (Your Name):</td><td><b><input type='text' name='com_author' value='[% comment_author %]'[% IF c.config.cgi_cfg.lock_author_names %] readonly disabled[% END %]></b></td></tr>
<tr><td class='optBoxRequiredItem'>Comment:</td><td><b><input type='text' name='com_data' value='' size= "40"></b></td></tr>

[% END %]
[% END %]
