<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Provide a admin area view for the plugin
 *
 * This file is used to markup the admin-facing aspects of the plugin.
 *
 * @link       https://webequipe.com
 * @since      1.0.0
 *
 * @package    Webequipe_Spin_Win_Wheel
 * @subpackage Webequipe_Spin_Win_Wheel/admin/partials
 */
?>

<!-- This file should primarily consist of HTML with a little bit of PHP. -->

<div class="wrap wsww-spin-view">
    <h1 class="wp-heading-inline"><?php echo esc_html( $spin->spin_title ); ?></h1>
    <hr class="wp-header-end">

    <form action="" method="post">
        <div id="poststuff">
            <div id="post-body" class="metabox-holder columns-2">
                <div id="post-body-content">

                    <?php $webequipe_sww_spins_items = json_decode( $spin->spins, true ); ?>

                    <div class="postbox">
                        <h2>
                            <span>Spin</span> Shortcode:
                            <input type="text" class="shortcode-clipboard"
                                   value='[wsww-spin id="<?php echo esc_attr( $spin->id ); ?>"]' readonly />
                        </h2>

                        <div class="inside">
                            <table class="wsww-spin-table table table-striped">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th><?php esc_html_e( 'Win?', 'webequipe-spin-win-wheel' ); ?></th>
                                        <th><?php esc_html_e( 'Winning Probability', 'webequipe-spin-win-wheel' ); ?></th>
                                        <th><?php esc_html_e( 'Label', 'webequipe-spin-win-wheel' ); ?></th>
                                        <th><?php esc_html_e( 'Value', 'webequipe-spin-win-wheel' ); ?></th>
                                        <th><?php esc_html_e( 'Background Color', 'webequipe-spin-win-wheel' ); ?></th>
                                        <th><?php esc_html_e( 'Text Color', 'webequipe-spin-win-wheel' ); ?></th>
                                    </tr>
                                </thead>

                                <tbody>
                                    <?php
                                    $webequipe_sww_i = 1;
                                    foreach ( $webequipe_sww_spins_items as $webequipe_sww_key => $webequipe_sww_data ) :
                                    ?>
                                    <tr class="wsww-fields-row" data-group="spins">
                                        <td><?php echo esc_html( $webequipe_sww_i ); ?></td>
                                        <td><div class="wsww-"><?php echo esc_html( $webequipe_sww_data['is_win'] ?? '' ); ?></div></td>
                                        <td><div class="wsww-"><?php echo esc_html( $webequipe_sww_data['spin_probability'] ?? '' ); ?></div></td>
                                        <td><div class="wsww-"><?php echo esc_html( $webequipe_sww_data['spin_label'] ?? '' ); ?></div></td>
                                        <td><div class="wsww-"><?php echo esc_html( $webequipe_sww_data['spin_value'] ?? '' ); ?></div></td>
                                        <td>
                                            <div class="wsww-" style="width:30px; height:30px; border:1px solid #ccc; background-color: <?php echo esc_attr( $webequipe_sww_data['spin_bgcolor'] ?? '#fff' ); ?>;"></div>
                                        </td>
                                        <td>
                                            <div class="wsww-" style="width:30px; height:30px; border:1px solid #ccc; background-color: <?php echo esc_attr( $webequipe_sww_data['spin_textcolor'] ?? '#000' ); ?>;"></div>
                                        </td>
                                    </tr>
                                    <?php
                                    $webequipe_sww_i++;
                                    endforeach;
                                    ?>
                                </tbody>
                            </table>
                        </div> <!-- inside -->
                    </div> <!-- postbox -->

                    <div class="clear">
                        <div class="textright">
                            <a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=wsww-spin&action=edit&id=' . $spin->id ), 'wsww_spin_action' ) ); ?>"
                               class="page-title-action right">
                                <?php esc_html_e( 'Edit', 'webequipe-spin-win-wheel' ); ?>
                            </a>

                            <a href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=wsww-spin&action=new' ), 'wsww_spin_action' ) ); ?>"
                               class="page-title-action right">
                                <?php esc_html_e( 'Add New', 'webequipe-spin-win-wheel' ); ?>
                            </a>
                        </div>
                    </div>

                </div> <!-- post-body-content -->
                <div id="postbox-container-1" class="postbox-container">
                    <div id="side-sortables" class="meta-box-sortables ui-sortable"></div>
                </div>
            </div>
            <br class="clear">
        </div>
    </form>
</div>
