<?php
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.

// Control to reassign migrated subscriptions to different client or reseller. Consists of:
// 1) Radio selector: whether reassign is enabled or not.
// 2) Lookup field: select new customer or reseller.

?>
<div class='form-row' id='<?php echo $this->element->getId();?>-form-row'>
    <div class='field-name'>
        <?php echo $this->elementPart($this->element)->label(); ?>
    </div>
    <div class='field-value'>
        <div class="indent-box">
            <input
                type="radio"
                name="<?php echo $this->element->getId();?>[enabled]"
                value="false"
                id="<?php echo $this->element->getId();?>-do-not-change"
                class="radio"
                checked="checked"
            >
            <div class="indent-box-content">
                <label for="<?php echo $this->element->getId();?>-do-not-change">
                    <?php echo $this->labelDoNotChange; ?>
                </label>
                <span class="hint">
                    <?php echo $this->hintDoNotChange; ?>
                </span>
            </div>
        </div>
        <div class="indent-box">
            <input
                type="radio"
                name="<?php echo $this->element->getId();?>[enabled]"
                value="true"
                id="<?php echo $this->element->getId();?>-reassign"
                class="radio"
            >
            <div class="indent-box-content">
                <label for="<?php echo $this->element->getId();?>-reassign">
                    <?php echo $this->labelReassign; ?>
                </label>
                <div class="form-row">
                    <div id='<?php echo $this->element->getId();?>-reassign-container'></div>
                </div>
            </div>
        </div>
        <span class="field-errors" style="display: none;"></span>
    </div>
</div>
<?php $this->includeMigratorJavaScript('lookup-extended.js'); ?>
<?php $this->includeMigratorJavaScript('reassign-owner.js'); ?>
<script type="text/javascript">
    //<![CDATA[
    <?php
    $lookupLocale = Zend_Json::encode(
        array_merge(
            Zend_Registry::get('translate')->getSection('components.elements.lookup'),
            [
                'label' => $this->label,
            ]
        )
    );
    ?>
    Jsw.onReady(function() {
        createReassignControl(
            '<?php echo $this->element->getId();?>',
            <?php echo Zend_Json::encode($this->data); ?>,
            <?php echo $this->value ? Zend_Json::encode($this->value) : 'null'; ?>,
            <?php echo $lookupLocale; ?>
        );
    });
    //]]>
</script>
