<?php
defined('ABSPATH') or die('No script kiddies please!!');
$button_status = (!empty($ciws_main_settings['woocommerce']['button_status'])) ? 1 : 0;
$button_position = (!empty($ciws_main_settings['woocommerce']['button_position'])) ? $ciws_main_settings['woocommerce']['button_position'] : 'ciws-before-title';
$selected_account = (!empty($ciws_main_settings['woocommerce']['woo_button_account'])) ? $ciws_main_settings['woocommerce']['woo_button_account'] : '';

?>
<div class="ciws-settings-section" data-settings-ref="woocommerce" style="display:none;">
    <div class="ciws-field-wrap">
        <label>
            <?php esc_html_e('Button Status', 'chat-in-website'); ?>
        </label>
        <div class="ciws-field ciws-checkbox-toggle">
            <input type="checkbox" class="ciws-customize-status" name="ciws_main_settings[woocommerce][button_status]"
                value="1" <?php checked($button_status, '1'); ?> />
            <label></label>
        </div>
    </div>


    <div class="ciws-field-wrap">
        <label>
            <?php esc_html_e('WooCommerce Button Position', 'chat-in-website'); ?>
        </label>
        <div class="ciws-field">
            <select name="ciws_main_settings[woocommerce][button_position]"
                class="ciws-buton-position-dropdown ciws-display-none">
                <option value="<?php esc_html_e('ciws-before-title', 'chat-in-website'); ?>"
                    <?php echo selected($button_position, 'ciws-before-title'); ?>>
                    <?php esc_html_e('Before Title', 'chat-in-website'); ?>

                </option>
                <option value="<?php esc_html_e('ciws-after-title', 'chat-in-website'); ?>"
                    <?php echo selected($button_position, 'ciws-after-title') ?>>
                    <?php esc_html_e('After Title', 'chat-in-website'); ?>

                </option>
                <option value="<?php esc_html_e('ciws-before-cart', 'chat-in-website'); ?>"
                    <?php echo selected($button_position, 'ciws-before-cart') ?>>
                    <?php esc_html_e('Before Cart', 'chat-in-website'); ?>

                </option>
                <option value="<?php esc_html_e('ciws-after-cart', 'chat-in-website'); ?>"
                    <?php echo selected($button_position, 'ciws-after-cart') ?>>
                    <?php esc_html_e('After Cart', 'chat-in-website'); ?>

                </option>
                <option value="<?php esc_html_e('ciws-after-description', 'chat-in-website'); ?>"
                    <?php echo selected($button_position, 'ciws-after-description') ?>>
                    <?php esc_html_e('After Long Description', 'chat-in-website'); ?>

                </option>



            </select>
            <div class="ciws-field ciws-high-width">
                <div class="position-image-flex">
                    <div class="ciws-position-image">
                        <label>
                            <div
                                class="ciws-position-image-wrap ciws-position-select <?php echo ($button_position == 'ciws-before-title')?"ciws-selected":''; ?>">
                                <img src="<?php echo esc_url(CIWS_IMG_DIR . '/positions/ciws-bfr-title.png'); ?>"
                                    data-position="ciws-before-title">
                            </div>
                            <span> <?php esc_html_e('Before Title', 'chat-in-website'); ?></span>
                        </label>
                    </div>
                    <div class="ciws-position-image">
                        <label>
                            <div
                                class="ciws-position-image-wrap ciws-position-select <?php echo ($button_position == 'ciws-after-title')?"ciws-selected":''; ?>">
                                <img src="<?php echo esc_url(CIWS_IMG_DIR . '/positions/ciws-aftr-title.png'); ?>"
                                    data-position="ciws-after-title">
                            </div>
                            <span> <?php esc_html_e('After Title', 'chat-in-website'); ?></span>
                        </label>
                    </div>
                    <div class="ciws-position-image ">
                        <label>
                            <div
                                class="ciws-position-image-wrap ciws-position-select <?php echo ($button_position == 'ciws-before-cart')?"ciws-selected":''; ?>">
                                <img src="<?php echo esc_url(CIWS_IMG_DIR . '/positions/ciws-bfr-cart.png'); ?>"
                                    data-position="ciws-before-cart">
                            </div>
                            <span> <?php esc_html_e('Before Cart', 'chat-in-website'); ?></span>
                        </label>
                    </div>
                    <div class="ciws-position-image">
                        <label>
                            <div
                                class="ciws-position-image-wrap ciws-position-select <?php echo ($button_position == 'ciws-after-cart')?"ciws-selected":''; ?>">
                                <img src="<?php echo esc_url(CIWS_IMG_DIR . '/positions/ciws-aftr-cart.png'); ?>"
                                    data-position="ciws-after-cart">
                            </div>
                            <span> <?php esc_html_e('After Cart', 'chat-in-website'); ?></span>
                        </label>
                    </div>
                    <div class="ciws-position-image">
                        <label>
                            <div
                                class="ciws-position-image-wrap ciws-position-select <?php echo ($button_position == 'ciws-after-description')?"ciws-selected":''; ?>">
                                <img src="<?php echo esc_url(CIWS_IMG_DIR . '/positions/ciws-aftr-desc.png'); ?>"
                                    data-position="ciws-after-description">
                            </div>
                            <span> <?php esc_html_e('After Long Description', 'chat-in-website'); ?></span>
                        </label>
                    </div>
                </div>

            </div>

        </div>
    </div>

    <div class="ciws-field-wrap">
        <label>
            <?php esc_html_e('Select WooCommerce Button Account', 'chat-in-website'); ?>
        </label>
        <div class="ciws-field ciws-checkbox-toggle">
            <select name="ciws_main_settings[woocommerce][woo_button_account]" class="ciws-template-dropdown">

                <?php
                global $wpdb;

                $account_rows = $wpdb->get_results($wpdb->prepare("select * from %i order by account_id desc", CIWS_TABLE));
                if (!empty($account_rows)) {
                    foreach ($account_rows as $account_row) {
                        $ciws_account_details = maybe_unserialize($account_row->ciws_account_details);
                ?>
                <option value="<?php echo esc_attr($account_row->account_id); ?>"
                    <?php echo selected($selected_account, $account_row->account_id); ?>>
                    <?php echo esc_html($account_row->account_name); ?>
                </option>
                <?php }
                } ?>
            </select>

        </div>
    </div>



</div>