    <?php
    $this->Form->create(null, ['id' => 'cancel_service']);
    ?>
        <div class="modal-header">
            <h5 class="global_modal_title"><?php $this->_('ClientServices.cancel.heading_cancel');?></h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
        </div>
        <div class="modal-body">
            <?php
            foreach ((array)(isset($confirm_cancel_messages) ? $confirm_cancel_messages : []) as $type => $message) {
            ?>
                <div class="cancel_message <?php (print (isset($type) ? $this->Html->safe($type) : null));?>"><?php echo (isset($message) ? $message : null);?></div>
            <?php
            }
            ?>
            <div class="form-group">
                <?php
                if (empty($invoices)) {
                    if ($clients_cancel_options == 'both' || $clients_cancel_options == 'end_of_term') {
                    ?>
                        <div class="radio">
                            <label>
                                <?php
                                $this->Form->fieldRadio('cancel', 'term', ((isset($vars->cancel) ? $vars->cancel : null) == 'term'));

                                // Show language based on whether or not a renew date exists
                                if ((isset($service->date_renews) ? $service->date_renews : false)) {
                                    $this->_('ClientServices.cancel.field_term_date', false, $this->Date->cast((isset($service->date_renews) ? $service->date_renews : null), 'date'));
                                } else {
                                    $this->_('ClientServices.cancel.field_term');
                                }
                                ?>
                            </label>
                        </div>
                    <?php
                    }
                    ?>
                    <?php
                    if ($clients_cancel_options == 'both' || $clients_cancel_options == 'now') {
                    ?>
                        <div class="radio">
                            <label>
                                <?php
                                $this->Form->fieldRadio('cancel', 'now', ((isset($vars->cancel) ? $vars->cancel : null) == 'now'));
                                $this->_('ClientServices.cancel.field_now');
                                ?>
                            </label>
                        </div>
                    <?php
                    }
                }
                ?>
                <div class="radio">
                    <label>
                        <?php
                        $this->Form->fieldRadio('cancel', '', ((isset($vars->cancel) ? $vars->cancel : null) == ''));
                        $this->_('ClientServices.cancel.field_do_not');
                        ?>
                    </label>
                </div>
            </div>
            <div class="form-group">
                <?php
                $this->Form->label($this->_('ClientServices.cancel.field_cancellation_reason', true), 'cancellation_reason');
                $this->Form->fieldTextarea('cancellation_reason', (isset($vars->cancellation_reason) ? $vars->cancellation_reason : null), ['id' => 'cancellation_reason', 'class' => 'form-control']);
                ?>
            </div>
            <div class="form-group">
                <?php
                $this->Form->label($this->_('ClientServices.cancel.field_password', true), 'password');
                $this->Form->fieldPassword('password', ['id' => 'password', 'class' => 'form-control']);
                ?>
            </div>
        </div>
        <div class="modal-footer">
            <?php
            $this->Form->fieldButton('cancel', $this->_('ClientServices.cancel.field_cancel_cancel', true), ['class' => 'btn btn-light', 'data-dismiss' => 'modal']);
            $this->Form->fieldButton('submit', $this->_('ClientServices.cancel.field_cancel_submit', true), ['class' => 'btn btn-primary', 'type' => 'submit']);
            ?>
        </div>
    <?php
    $this->Form->end();
    ?>

<script type="text/javascript">
    $(document).ready(function() {
        setCancelMessage();

        $("#cancel_service input[name='cancel']").change(function() {
            setCancelMessage();
        });

        function setCancelMessage() {
            $("div.cancel_message").hide();
            var message_type = $("#cancel_service input[name='cancel']:checked").val();
            if (message_type)
                $("div.cancel_message" + "." + message_type).show();
        }
    });
</script>
