<?php if (defined('AAM_KEY')) { ?>
    <div id="extension-content" class="extension-container">
        <div class="row">
            <div class="col-xs-12">
                <p class="aam-info">
                    <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('By purchasing any of the extensions below, you obtain the license that allows you to install and use our software for life and for one physical WordPress installation only. However you will be able to download new updates for one year from the time of purchase unless you purchased the [Extended version]. Exceptions are websites where URL is either [localhost] or starts with [dev.], [staging.], [test.] or [demo.] They are considered as development websites and you can use the purchased license unlimited number of times before it is activated on a production website. [Money back guaranteed] within 10 day from the time of purchase.', 'i', 'i', 'i', 'i', 'i', 'i', 'b'), '<a href="https://aamplugin.com/development-package" target="_blank">', '</a>'); ?><br/>
                </p>
            </div>
        </div>

        <label for="extension-key"><?php echo __('Install/Update Extension', AAM_KEY); ?> <a href="#install-extension-modal" data-toggle="modal"><i class="icon-help-circled"></i></a></label>
        <div class="row">
            <div class="col-xs-8">
                <div class="form-group">
                    <input type="text" class="form-control" id="extension-key" placeholder="<?php echo __('License Key', AAM_KEY); ?>" />
                </div>
            </div>
            <div class="col-xs-4">
                <button class="btn btn-primary btn-block" id="install-extension"><i class="icon-download-cloud"></i> <?php echo __('Submit', AAM_KEY); ?></button>
            </div>
        </div>
        
        <?php $commercial = $this->getList('commercial'); ?>
        <?php $free       = $this->getList('GNU'); ?>

        <div>
            <ul class="nav nav-tabs" role="tablist">
                <?php if(count($commercial)) { ?><li role="presentation" class="active"><a href="#premium-extensions" aria-controls="premium-extensions" role="tab" data-toggle="tab"><i class='icon-basket'></i> <?php echo __('Premium', AAM_KEY); ?></a></li><?php } ?>
                <?php if(count($free)) { ?><li role="presentation" <?php echo (!count($commercial) ? 'class="active"' : ''); ?>><a href="#free-extensions" aria-controls="free-extensions" role="tab" data-toggle="tab"><i class='icon-download-cloud'></i> <?php echo __('Free', AAM_KEY); ?></a></li><?php } ?>
                <li class="aam-update-check"><a href="#" id="aam-update-check"><i class='icon-arrows-cw'></i> <?php echo __('Check for Updates', AAM_KEY); ?></a></li>
            </ul>

            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane<?php echo (count($commercial) ? ' active' : ''); ?>" id="premium-extensions">
                    <table class="table table-striped table-bordered">
                        <tbody>
                            <?php foreach ($commercial as $i => $product) { ?>
                                <tr>
                                    <td width="80%">
                                        <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['new']) ? ' <span class="badge">NEW</span> ' : ''), (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''); ?></span>
                                        <?php if (!empty($product['license']) && $this->canShowLicense()) { ?><small class="aam-license-key"><b>License:</b> <?php echo $product['license'] . (!empty($product['expire']) ? " (updates expire on {$product['expire']})" : ''); ?></small><?php } ?>
                                        <p class="aam-extension-description">
                                            <?php echo $product['description']; ?>
                                        </p>
                                    </td>
                                    <td class="text-center">
                                        <?php if ($product['status'] == AAM_Extension_Repository::STATUS_INSTALLED) { ?>
                                        <a href="#" class="btn btn-sm btn-danger btn-block aam-deactivate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-attention-circled"></i> <?php echo __('Deactivate', AAM_KEY); ?></a><small><?php echo __('extension is active', AAM_KEY); ?></small>
                                        <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_UPDATE) { ?>
                                            <a href="#" class="btn btn-sm btn-warning btn-block aam-update-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-arrows-cw"></i> <?php echo __('Update', AAM_KEY); ?></a>
                                        <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_INACTIVE) { ?>
                                            <a href="#" class="btn btn-sm btn-success btn-block aam-activate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-check"></i> <?php echo __('Activate', AAM_KEY); ?></a><small><?php echo __('extension is inactive', AAM_KEY); ?></small>
                                        <?php } else { ?>
                                            <a href="<?php echo $product['url']; ?>" target="_blank" class="btn btn-sm btn-primary btn-block"><i class="icon-link"></i> <?php echo __('Read More', AAM_KEY); ?></a>
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
                <div role="tabpanel" class="tab-pane" id="free-extensions">
                    <table class="table table-striped table-bordered">
                        <tbody>
                            <?php foreach ($free as $product) { ?>
                                <tr>
                                    <td width="80%">
                                        <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''), ' - ' . ('<span class="text-success">' . __('Free', AAM_KEY) . '</span>'); ?></span>
                                        <p class="aam-extension-description">
                                            <?php echo $product['description']; ?>
                                        </p>
                                    </td>
                                    <td class="text-center">
                                        <?php if ($product['status'] == AAM_Extension_Repository::STATUS_INSTALLED) { ?>
                                            <a href="#" class="btn btn-sm btn-danger btn-block aam-deactivate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-attention-circled"></i> <?php echo __('Deactivate', AAM_KEY); ?></a><small><?php echo __('extension is active', AAM_KEY); ?></small>
                                        <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_UPDATE) { ?>
                                            <a href="#" class="btn btn-sm btn-warning btn-block aam-update-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-arrows-cw"></i> <?php echo __('Update', AAM_KEY); ?></a>
                                        <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_INACTIVE) { ?>
                                            <a href="#" class="btn btn-sm btn-success btn-block aam-activate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-check"></i> <?php echo __('Activate', AAM_KEY); ?></a><small><?php echo __('extension is inactive', AAM_KEY); ?></small>
                                        <?php } else { ?>
                                            <a href="#" class="btn btn-sm btn-success btn-block aam-download-extension" data-license="<?php echo $product['license']; ?>"><i class="icon-download-cloud"></i> <?php echo __('Download', AAM_KEY); ?></a>
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>

        <div class="modal fade" id="extension-notification-modal" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title"><?php echo __('Notification', AAM_KEY); ?></h4>
                    </div>
                    <div class="modal-body">
                        <p class="aam-notification">
                            <strong><span id="installation-error"></span></strong> <?php echo __('Extension requires manual installation. Please follow few simple steps below.', AAM_KEY); ?>
                        </p>

                        <ul class="aam-outer-top-xs aam-numeric-list">
                            <li><?php echo AAM_Backend_View_Helper::preparePhrase('Click [Download] button below and save the zip archive on your computer', 'b'); ?>;</li>
                            <li><?php echo AAM_Backend_View_Helper::preparePhrase('Connect to your website via FTP and navigate to [wp-content] folder', 'b'); ?>;</li>
                            <li><?php echo AAM_Backend_View_Helper::preparePhrase('Create [aam/extension] folder inside [wp-content] and make sure it is writable by your server', 'b', 'b'); ?>;</li>
                            <li><?php echo AAM_Backend_View_Helper::preparePhrase('Unzip downloaded archive and upload the folder inside the [wp-content/aam/extension] folder', 'b'); ?>.</li>
                        </ul>
                        
                        <p class="aam-notification hidden" id="safari-download-notification">
                            <?php echo AAM_Backend_View_Helper::preparePhrase('[PLEASE NOTE!] Your browser may not support the latest HTML5 attribures and if downloaded file is not .ZIP archive, simply rename the file by adding .zip extension.', 'b'); ?>
                        </p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-success" id="download-extension"><?php echo __('Download', AAM_KEY); ?></button>
                        <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Cancel', AAM_KEY); ?></button>
                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="install-extension-modal" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title"><?php echo __('Install Extension', AAM_KEY); ?></h4>
                    </div>
                    <div class="modal-body aam-info-modal">
                        <p>
                            <?php echo __('Insert license key that you recieved after the payment (find the email example below). It might take up to 2 hours to process the payment. Please remember that license key is limited only to one life domain.', AAM_KEY); ?>
                            <br /> <br />
                            <img src="https://aamplugin.com/media/img/email-confirmation.jpg" class="img-responsive" />
                        </p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php }