<?php
/*
* Plugin-Name: Product Designer App
* Plugin-URI: https://productdesignerapp.com
* Author: productdesignerapp
* Page: Requires
*/

if (!defined('ABSPATH'))
{
    exit;
}

$pdappDevScript = PDAPP_DEV_MODE ? '' : 'min.';
$pdappDevStr = PDAPP_DEV_MODE ? '' : '-min';
wp_enqueue_style('pdapp-material-style', PDAPP_PLUGIN_URL . 'assets/plugins/material/css/material.min.css', array(), PDAPP_VERSION, 'all');
wp_enqueue_style('pdapp-main-style'. $pdappDevStr, PDAPP_PLUGIN_URL . 'admin/assets/css/pdapp-style.'. $pdappDevScript .'css', array(), PDAPP_VERSION, 'all');
?>

<?php
    global $wp_version;
    $pdappCheckPHP = version_compare(PHP_VERSION, PDAPP_PHP_VERSION, '<') ? false : true;
    $pdappCheckWp = version_compare($wp_version, PDAPP_WP_VERSION, '<') ? false : true;
    $pdappCheckWoo = !in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) ? false : true;
?>

<div id="productdesignerapp-wrapper">
    <div id="productdesignerapp-app" style="display: none;">
        <div class="container-fluid">
            <div class="card mt-3">
                <div class="card-body">
                    <h4 class="header-title mb-1">System requirements</h4>
                    <table class="table table-borderless table-centered mb-0">
                        <thead class="table-light">
                            <tr>
                                <th>Status</th>
                                <th>Name</th>
                                <th>Requirement</th>
                                <th>Current</th>
                                <th>Guide</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td>
                                    <?php
                                        if($pdappCheckPHP) echo '<i class="material-icons material-symbols-outlined text-success">check</i>';
                                        else echo '<i class="material-icons material-symbols-outlined text-danger">block</i>';
                                    ?>
                                </td>
                                <td>PHP Version</td>
                                <td><?php echo esc_html(PDAPP_PHP_VERSION); ?>+</td>
                                <td><?php echo esc_html(PHP_VERSION); ?></td>
                                <td>
                                    <?php
                                        if(!$pdappCheckPHP)
                                        {
                                            echo '<span>Update to PHP version '. esc_html(PDAPP_PHP_VERSION) .'+.</span>';
                                            echo '<a v-if="requires.php_version != undefined" target="_blank" :href="requires.php_version" class="ms-1">Read More</a>';
                                        }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <?php
                                        if($pdappCheckWp) echo '<i class="material-icons material-symbols-outlined text-success">check</i>';
                                        else echo '<i class="material-icons material-symbols-outlined text-danger">block</i>';
                                    ?>
                                </td>
                                <td>Wordpress Version</td>
                                <td><?php echo esc_html(PDAPP_WP_VERSION); ?>+</td>
                                <td><?php echo esc_html($wp_version); ?></td>
                                <td>
                                    <?php
                                        if(!$pdappCheckWp)
                                        {
                                            echo '<span>Update to Wordpress version '. esc_html(PDAPP_WP_VERSION) .'+.</span>';
                                            echo '<a v-if="requires.php_version != undefined" target="_blank" :href="requires.wp_version" class="ms-1">Read More</a>';
                                        }
                                    ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <?php
                                        if($pdappCheckWoo) echo '<i class="material-icons material-symbols-outlined text-success">check</i>';
                                        else echo '<i class="material-icons material-symbols-outlined text-danger">block</i>';
                                    ?>
                                </td>
                                <td>Woocommerce Plugin</td>
                                <td>Install</td>
                                <td><?php echo $pdappCheckWoo ? 'Installed' : 'Not Install'; ?></td>
                                <td>
                                    <?php
                                        if(!$pdappCheckWp)
                                        {
                                            echo '<span>Install Woocommerce version '. esc_html(PDAPP_WOO_VERSION) .'+.</span>';
                                            echo '<a v-if="requires.php_version != undefined" target="_blank" :href="requires.woo_version" class="ms-1">Read More</a>';
                                        }
                                    ?>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php
    wp_enqueue_script('pdapp-vue-script', PDAPP_PLUGIN_URL . 'assets/plugins/vue/js/vue.min.js', ['jquery'], PDAPP_VERSION, true);
    wp_enqueue_script('pdapp-api-script'. $pdappDevStr, PDAPP_PLUGIN_URL . 'admin/assets/js/requires/pdapp-api.'. $pdappDevScript. 'js', ['jquery'], PDAPP_VERSION, true);
    wp_enqueue_script('pdapp-main-script'. $pdappDevStr, PDAPP_PLUGIN_URL . 'admin/assets/js/requires/pdapp-main.'. $pdappDevScript. 'js', ['jquery'], PDAPP_VERSION, true);
?>