<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$current_page = 'woofunnels';
// Exit if accessed directly
?>
<div class="woofunnels_plugins_wrap">
    <h1><?php esc_html_e( 'Manage Licenses', 'woofunnels' ) ?></h1>
	<?php
	if ( is_object( $model ) ) {
		?>
        <div class="wp-filter">
            <ul class="filter-links woofunnels_plugins_license_links">
				<?php $licenses = WooFunnels_licenses::get_instance();
				$licenses->get_plugins_list();
				if ( ! empty( $licenses->plugins_list ) ) { ?>
                    <li class="plugin-install-featured <?php echo ( isset( $model->current_tab ) && $model->current_tab === "licenses" ) ? "current" : "" ?>">
                        <a href="<?php echo admin_url( 'admin.php?page=' . $current_page . "&tab=licenses" ); ?>"><?php esc_html_e( 'Licenses', 'woofunnels' ); ?></a>
                    </li>
				<?php } ?>
                <li class="plugin-install-popular <?php echo ( isset( $model->current_tab ) && $model->current_tab === "services" ) ? "current" : "" ?>">
                    <a href="<?php echo admin_url( 'admin.php?page=' . $current_page . "&tab=support" ); ?>" class=""><?php esc_html_e( 'Support', 'woofunnels' ); ?></a>
                </li>
				<?php
				if ( isset( $model->additional_tabs ) && is_array( $model->additional_tabs ) && count( $model->additional_tabs ) > 0 ): ?>
					<?php foreach ( $model->additional_tabs as $tab ): ?>
                        <li class="<?php echo ( isset( $model->current_tab ) && $model->current_tab === $tab['slug'] ) ? "current" : "" ?>">
                            <a href="<?php echo admin_url( 'admin.php?page=' . $current_page . '&tab=' . $tab['slug'] ); ?>"><?php echo esc_html( $tab['label'] ); ?></a>
                        </li>
					<?php endforeach; ?>
				<?php endif; ?>
            </ul>
        </div>
        <br class="clear"/>
        <div id="col-container" class="about-wrap">
            <div class="col-wrap woofunnels_dashboard_license_content" style="width:100%">
                <form id="woofunnels_activate-products" method="post" action="" class="validate">
                    <input type="hidden" name="action" value="woofunnels_activate-products"/>
					<?php
					require_once( WooFunnels_dashboard::$loader_url . 'includes/class-woofunnels-updater-licenses-table.php' );
					$table       = new WooFunnels_Updater_Licenses_Table();
					$table->data = $model->licenses;

					$table->prepare_items();
					$table->display();
					?>
                    <p class="submit woothemes-helper-submit-wrapper">
						<?php
						submit_button( __( 'Activate License', 'woofunnels' ), 'button-primary', null, false );
						?>
                    </p><!--/.submit-->
					<?php wp_nonce_field( 'woofunnels-activate-license' ); ?>
                </form>

                <div class="col-wrap">
					<?php
					$notice_text_raw = __( 'Note: You need to have valid licenses to receive updates and support for these plugins.', 'woofunnels' );
					$notice_text_raw .= ' <a target="_blank" href="https://myaccount.funnelkit.com/">';
					$notice_text_raw .= __( 'Click Here', 'woofunnels' );
					$notice_text_raw .= '</a> ' . __( 'to get your license key(s).', 'woofunnels' );
					$notice_text     = apply_filters( 'woofunnels_after_license_table_notice', $notice_text_raw );
					?>
                    <p style="font-size: 12px;"><?php echo $notice_text; ?></p>
                </div>
				<?php do_action( 'woofunnels_license_after_notice_wrap' ); ?>
            </div><!--/.col-wrap-->
            <div class="woofunnels-area-right">  <?php do_action( 'woofunnels_licenses_right_content' ); ?> </div>
        </div><!--/#col-container-->
		<?php do_action( 'woofunnels_licenses_after_area' ); ?>
	<?php } else { ?>
        <div class="woofunnels_cannot_connect"> <?php echo apply_filters( 'woofunnels_no_data_license', esc_html__( 'Could not connect to server.', 'woofunnels' ) ); ?></div>
	<?php } ?>
</div>
