<?php
// Copyright 1999-2026. WebPros International GmbH. All rights reserved.
?>
Admin.Views.Subscription.changePreSubmitHandler = function(form) {
    var notConfiguredMailPlans = <?php echo Zend_Json::encode($this->notConfiguredMailPlans); ?>;
    if (
        document.getElementById('<?php echo $this->formId; ?>-removeMailConfirm') &&
        document.getElementById('<?php echo $this->formId; ?>-removeMailConfirm').value !== 'true' &&
        notConfiguredMailPlans.indexOf(+document.getElementById('<?php echo $this->formId; ?>-servicePlan').value) !== -1
    ) {
        Jsw.messageBox.show({
            type: Jsw.messageBox.TYPE_YESNO,
            buttonTitles: {
                yes: <?php echo $this->jsLmsg('admin.controllers.subscription.change-current.confirmationYes'); ?>,
                no: <?php echo $this->jsLmsg('admin.controllers.subscription.change-current.confirmationNo'); ?>,
            },
            text: <?php echo $this->jsLmsg('admin.controllers.subscription.change-current.removeMailConfirmText'); ?>,
            subtype: 'toggle',
            onYesClick: function () {
                document.getElementById('<?php echo $this->formId; ?>-removeMailConfirm').value = 'true';
                Jsw.submit(document.getElementById(form._applyTargetId));
            }
        });
        return false;
    }
    return true;
};
