<div class="page-headline">
    <img src="<?php echo $this->imagePath; ?>/icons/settings.svg" alt="">
    <h3><?php _ex('License', 'Headline right of icon', 'borlabs-cookie'); ?></h3>
</div>
<div class="content">

    <div class="messages">
    <?php echo \BorlabsCookie\Cookie\Backend\Backend::getInstance()->getMessages(); ?>
    </div>

    <?php
    if (!empty($licenseUnlinkData)) {
    ?>
        <form action="" method="post">
            <fieldset>
                <legend><?php _ex('Unlink website from license', 'Headline of a fieldset', 'borlabs-cookie'); ?></legend>

                <div class="form-group">
                    <div class="form-title">
                        <label for="licensePurchaseCode"><?php _ex('Select a website to unlink', 'Setting title', 'borlabs-cookie'); ?></label>
                    </div>
                    <div class="form-field">
                        <table>
                            <thead>
                                <tr>
                                    <th class="align-left"><?php _ex('Website', 'Table headline', 'borlabs-cookie'); ?></th>
                                    <th class="align-center"><?php _ex('Status', 'Table headline', 'borlabs-cookie'); ?></th>
                                    <th class="align-center"><?php _ex('Unlink', 'License option', 'borlabs-cookie'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php
                            foreach ($licenseUnlinkData->unlink as $siteData) {
                                ?>
                                <tr>
                                    <td><?php echo $siteData->url; ?></td>
                                    <td class="align-center"><?php
                                        if ($siteData->status == 'active') {
                                            ?>
                                            <span class="dashicons dashicons-yes"></span>
                                            <?php
                                        } else {
                                            ?>
                                            <span class="dashicons dashicons-no"></span>
                                            <?php
                                        }
                                    ?>
                                    </td>
                                    <td class="align-center"><input type="radio" name="hash" value="<?php echo $siteData->hash; ?>"></td>
                                </tr>
                                <?php
                            }
                            ?>
                            </tbody>
                        </table>
                        <span class="description">
                            <?php _ex('You can unlink a website of your license by just selecting the radio-button in the row of the website.', 'License notice', 'borlabs-cookie'); ?>
                            <br>
                            <?php _ex('After a website is unlinked, you are able to enter your license key again and register your new website.', 'License notice', 'borlabs-cookie'); ?>
                        </span>
                    </div>
                </div>

                <?php wp_nonce_field('borlabs_cookie_unlink_routine'); ?>
                <input type="hidden" name="formSend" value="1">
                <input type="hidden" name="licenseKey" value="<?php echo esc_attr($licenseUnlinkData->licenseKey); ?>">
                <input type="hidden" name="unlinkWebsite" value="1">
                <input class="button-primary" type="submit" value="<?php _ex('Unlink selected website', 'Button title', 'borlabs-cookie'); ?>">
            </fieldset>
        </form>
        <?php
    }

    if (!empty($licenseData->licenseKey)) {
    ?>
        <h4><?php _ex('Your license status', 'Headline', 'borlabs-cookie'); ?></h4>
        <table>
            <tr>
                <th><?php _ex('License status', 'Table headline', 'borlabs-cookie'); ?></th>
                <td class="<?php echo $licenseStatus; ?>"><?php echo $licenseStatusMessage; ?></td>
            </tr>
            <tr>
                <th><?php _ex('License type', 'Table headline', 'borlabs-cookie'); ?></th>
                <td><?php echo $licenseTitle; ?></td>
            </tr>
            <tr>
                <th><?php _ex('Updates until', 'Table headline', 'borlabs-cookie'); ?></th>
                <td><?php echo $licenseValidUntil; ?></td>
            </tr>
            <tr>
                <th><?php _ex('Support until', 'Table headline', 'borlabs-cookie'); ?></th>
                <td><?php echo $licenseSupportUntil; ?></td>
            </tr>
            <tr>
                <th><?php _ex('Max Websites', 'Table headline', 'borlabs-cookie'); ?></th>
                <td><?php echo $licenseMaxSites === 99 ? '&infin;' : $licenseMaxSites; ?></td>
            </tr>
        </table>
        <?php
    }
    ?>

    <form action="" method="post">
        <fieldset>
            <legend><?php _ex('Manage your license', 'Headline of a fieldset', 'borlabs-cookie'); ?></legend>

            <div class="form-group">
                <div class="form-title">
                    <label for="license-key">
                        <?php
                            _ex('Your license key', 'Setting title', 'borlabs-cookie');
                        ?>
                    </label>
                </div>
                <div class="form-field">
                    <input type="text" name="licenseKey" id="license-key" placeholder="<?php echo $licenseKey; ?>" class="large-text">
                </div>
            </div>

            <?php wp_nonce_field('borlabs_cookie_manage_license'); ?>
            <input type="hidden" name="formSend" value="1">
            <input type="hidden" name="registerLicense" value="1">
            <input class="button-primary" type="submit" value="<?php _ex('Save license key', 'Button title', 'borlabs-cookie'); ?>">
        </fieldset>
    </form>

    <form action="" method="post">
        <fieldset>
            <legend><?php _ex('Test environment', 'Headline of a fieldset', 'borlabs-cookie'); ?></legend>

            <div class="form-group">
                <div class="form-title"><?php _ex('Status', 'Setting title', 'borlabs-cookie'); ?></div>
                <div class="form-field">
                    <label for="testEnvironment">
                        <input<?php echo $checkboxTestEnvironment; ?> type="checkbox" name="testEnvironment" id="testEnvironment" value="1"> <span class="option-title"><?php _ex('Activate', 'Setting checkbox', 'borlabs-cookie'); ?></span>
                    </label>
                    <span class="description"><?php _ex('Mark this installation as a test environment to continue using Borlabs Cookie without a license.', 'Setting description', 'borlabs-cookie'); ?></span>
                </div>
            </div>

            <?php wp_nonce_field('borlabs_cookie_test_environment'); ?>
            <input type="hidden" name="formSend" value="1">
            <input type="hidden" name="enableTestEnvironment" value="1">
            <input class="button-primary" type="submit" value="<?php _ex('Save', 'Button title', 'borlabs-cookie'); ?>">
        </fieldset>
    </form>

    <?php
    if (!empty($licenseData) && empty($licenseData->noLicense)) {
    ?>
    <form action="" method="post">
        <fieldset>
            <legend><?php _ex('Remove license', 'Headline of a fieldset', 'borlabs-cookie'); ?></legend>

            <div class="form-group">
                <div class="form-title"><?php _ex('Confirmation', 'License - Setting title', 'borlabs-cookie'); ?></div>
                <div class="form-field">
                    <label for="licenseRemovalConfirmation">
                        <input type="checkbox" name="licenseRemovalConfirmation" id="licenseRemovalConfirmation" value="yes"> <span class="option-title"><?php _ex('Confirmed', 'Setting checkbox', 'borlabs-cookie'); ?></span>
                    </label>
                    <span class="description"><?php _ex('Please confirm that you want to remove your license data from this website.', 'License - Setting description', 'borlabs-cookie'); ?></span>
                    <span class="description"><?php _ex('After the license data is removed you are able to enter your new license key.', 'License - Setting description', 'borlabs-cookie'); ?></span>
                </div>
            </div>
            <?php wp_nonce_field('borlabs_cookie_remove_license'); ?>
            <input type="hidden" name="formSend" value="1">
            <input type="hidden" name="removeLicense" value="1">
            <input disabled id="executeLicenseRemoval" class="button-primary red-button" type="submit" value="<?php _ex('Remove license data', 'Button title', 'borlabs-cookie'); ?>">
        </fieldset>
    </form>
    <?php
    }
    ?>
</div>