<?php
 
 /**
 * =============================================================================
 * @package			    Blue Raven (Free Version)
 * @Plugin URI			https://enterrahost.com/plugins/blue-raven
 * 
 * @Author			    EnterraHost
 * @Author URI			https://enterrahost.com
 * @License		    	GPL-2.0-or-later
 *  
 * @Copyright			(c) 2025 EnterraHost
 * @File Description	Loads the HTML for the New Product Page
 * 
 * =============================================================================
 * 
 * || INDEX:
 * ||   - BLUE RAVEN ADMIN NEW PRODUCT
 * || 
 * =============================================================================
 */
 
if ( ! defined( 'ABSPATH' ) ) exit; 

/*
============================================================
    BLUE RAVEN ADMIN NEW PRODUCT
============================================================
*/

class Blue_Raven_Admin_New_Product {

    /**
     * Render the new product admin interface.
     */
    public function render() {
        if (class_exists('WooCommerce')) {
            self::load_new_product_template();
        } else {
            echo '<div class="parent-container"><p class="enterra-highlight" style="padding: 1rem 0rem;">WooCommerce is not active. Please install and activate WooCommerce to use the Product Creation.</p></div>';
       }
    }
    
    /**
     * Load the new product admin template.
     *
     * Includes the HTML markup for the new product creation form.
     *
     * @access private
     */
    private static function load_new_product_template() {
        ?>
            <div class='parent-container'>
                <div class='flex-sb border-bottom-white'>
                    <div>
                        <h2><?php esc_html_e('Create a new product', 'blue-raven'); ?></h2>
                        <p class='enterra-highlight'><?php esc_html_e('Create a new WooCommerce product', 'blue-raven'); ?></p>
                    </div>
                    <div style='text-align: right; align-content: end;'>
                        <h4>
                            <?php esc_html_e( 'Need Help', 'blue-raven' ); ?>
                            <a href="https://portal.enterrahost.com/knowledgebase/11/" target="_noopeing" style="margin-left: 8px;" title="Learn more">
                                <i class="fas fa-question-circle"></i>
                            </a>
                        </h4>
                        <button class='enterra-button' id='view-brand-option'><?php esc_html_e('Brand Options', 'blue-raven'); ?></button>
                        <button class='enterra-button' id='view-new-product' style='display: none;'><?php esc_html_e('Return to New Product', 'blue-raven'); ?></button>
                    </div>
                </div>
                <section id='product-block'>
                    <form id='create-new-product' style='width: 100%;'>
                        <h4><?php esc_html_e('Describe your New Product', 'blue-raven'); ?></h4>
                        <div class='flex-sb spacing-bottom' style='width: 100%;'>
                            <div style="margin: 0; width: 100%;">
                                <label class='text-center'><p class='no-margin-padding spacing-right-small text-center'><?php esc_html_e('Description', 'blue-raven'); ?></p></label>
                                <textarea class='br-text-area' id='product-description' style="width: 100%; height: 200px;" name='description'></textarea>
                            </div> 
                        </div>
                        <p id='new-product-form-error-message'></p>
                        <div style='text-align: right; margin: 4rem auto'>
                            <button class='enterra-button' data-tool='create-product' id='post-create-product'><?php esc_html_e('Create Product', 'blue-raven'); ?></button>
                        </div>
                    </form>
                </section>
                <section id='creating-product-block' style='display:none;'>
                    <h4 style='text-align: center; margin: 2rem 0rem;'><?php esc_html_e('Working ... Please wait', 'blue-raven'); ?></h4>
                </section>
                <section id='product-block-nol' style='display:none; margin-top: 5rem;'>
                    <div style="margin: auto; width: 90%; max-width: 800px;">
                         <p class='enterra-highlight'><?php esc_html_e('Create WooCommerce Products must faster and with only a description.', 'blue-raven'); ?></p>
                        <h4 class='no-margin-padding text-center' style='margin-bottom: 1.5rem;'><?php esc_html_e('It looks like you don\'t have a License yet ?', 'blue-raven'); ?></h4>
                        <div class='flex-center' style='margin: 1.5rem 0rem;'>
                            <a href='https://portal.enterrahost.com/store/blue-raven-wordpress-plugin' target='_blank' class='enterra-button'><?php esc_attr_e('Get a License', 'blue-raven'); ?></a>
                        </div>
                    </div>
                </section>
            </div>
        <?php
    }
}