<div class="content-area colum-two-wrper">
    <div class="container">
        <div class="sidenav-left">
            <?php echo $this->publicproductheader($this->user); ?>
        </div>
        <div class="content-right">
            <?php
                if ($this->package['productType'] == PACKAGE_TYPE_HOSTING) {
                    echo $this->partial('productspublic/partials/hosting.phtml', [
                        'package' => $this->package,
                        'showAutomaticRenewal' => $this->showAutomaticRenewal,
                        'automaticRenewalChecked' => $this->automaticRenewalChecked
                    ]);
                } else if ($this->package['productType'] == PACKAGE_TYPE_DOMAIN) {
                    echo $this->partial('productspublic/partials/domain.phtml', [
                        'package' => $this->package,
                        'showAutomaticRenewal' => $this->showAutomaticRenewal,
                        'automaticRenewalChecked' => $this->automaticRenewalChecked
                    ]);
                } else if ($this->package['productType'] == PACKAGE_TYPE_GENERAL) {
                    echo $this->partial('productspublic/partials/general.phtml', [
                        'package' => $this->package,
                        'showAutomaticRenewal' => $this->showAutomaticRenewal,
                        'automaticRenewalChecked' => $this->automaticRenewalChecked
                    ]);
                } else if ($this->package['productType'] == PACKAGE_TYPE_SSL) {
                    echo $this->partial('productspublic/partials/ssl.phtml', [
                        'package' => $this->package,
                        'cert' => $this->cert,
                        'showAutomaticRenewal' => $this->showAutomaticRenewal,
                        'automaticRenewalChecked' => $this->automaticRenewalChecked
                    ]);
                }
            ?>
        </div>
    </div>
</div>


<script>

var productId = <?php echo $this->product_id; ?>;

<?php if ($this->showAutomaticRenewal) { ?>
$('#toogle-automatic-cc-charge').on('click', function() {
    $.post('index.php?fuse=clients&controller=products&action=toogleautomaticcccharge', {
        id: productId
    },
    function(data) {
        clientexec.parseResponse(data);
    });
});
<?php } ?>


<?php if ($this->registrarLock != '' && $this->status['statusRaw'] == 'Active') { ?>
$('#toogle-registrar-lock').on('click', function() {
    var regLockValue = 0;
    if ($(this).is(':checked')) {
        regLockValue = 1;
    }
    $.post('index.php?fuse=clients&controller=products&action=updateregistrarlock', {
        value: regLockValue,
        id: productId
    },
    function(data) {
        clientexec.parseResponse(data);
    });
});
<?php } ?>

$('#passwordChange').on('click', function(e) {
    e.preventDefault();

    $.confirm({
        title: clientexec.lang('Password Change'),
        content: '' +
        '<form action="">' +
        '<div class="form-group">' +
        '<label>' + clientexec.lang('Please enter a new password') + '</label>' +
        '<input type="password" class="password form-control" />' +
        '</div>' +
        '</form>',
        buttons: {
            formSubmit: {
                text: 'Save',
                btnClass: 'btn btn-primary',
                action: function () {
                    var password = this.$content.find('.password').val();
                    if( $.trim(password) !== "" ) {
                        $.post('index.php?fuse=clients&controller=products&action=updatehostingpassword', {
                            id: productId,
                            password: password
                        }, function( data ) {
                            clientexec.parseResponse(data);
                        });
                    }
                }
            },
            cancel: function () {
            },
        },
        onContentReady: function () {
            var jc = this;
            this.$content.find('form').on('submit', function (e) {
                // if the user submits the form by pressing enter in the field.
                e.preventDefault();
                jc.$$formSubmit.trigger('click');
            });
        }
    });
});

$('.customFieldModal').on('click', function(e){

    var content = $(this).data('content');
    if (content.length > 50) {
        columnClass = 'medium';
    } else if (content.length > 25) {
        columnClass = 'small';
    } else {
        columnClass = 'xsmall';
    }

    $.dialog({
        title: $(this).data('name'),
        content: content,
        columnClass: columnClass,
        containerFluid: true,
    });
});


$('.customFieldChange').on('click', function(e){
    e.preventDefault();
    var fieldName = $(this).data('name');
    var value = $(this).data('value');
    if (value.length > 50) {
        columnClass = 'medium';
    } else if (value.length > 25) {
        columnClass = 'small';
    } else {
        columnClass = 'xsmall';
    }

    $.confirm({
        columnClass: columnClass,
        containerFluid: true,
        title: '',
        content: '' +
        '<form action="">' +
        '<div class="form-group">' +
        '<label>' + clientexec.lang('Please enter a new value') + '</label>' +
        '<input type="text" class="value form-control" value="' + value + '" />' +
        '</div>' +
        '</form>',
        buttons: {
            formSubmit: {
                text: 'Save',
                btnClass: 'btn btn-primary',
                action: function () {
                    var value = this.$content.find('.value').val();
                    $.post('index.php?fuse=clients&controller=products&action=updatecustomfield', {
                        id: productId,
                        fieldName: fieldName,
                        value: value
                    }, function( data ) {
                        response = clientexec.parseResponse(data);
                        if (response.success === true) {
                            location.reload();
                        }
                    });
                }
            },
            cancel: function () {
            },
        },
        onContentReady: function () {
            var jc = this;
            this.$content.find('form').on('submit', function (e) {
                // if the user submits the form by pressing enter in the field.
                e.preventDefault();
                jc.$$formSubmit.trigger('click');
            });
        }
    });
});

</script>

<style>
    .jconfirm-content {
        overflow-wrap: break-word;
    }
</style>