<?php
/**
* sibs Admin Page.
*/
require_once plugin_dir_path(realpath(__DIR__ . '/')) . '/vendor/autoload.php';

use Sibs2\sibsConstants;
use Sibs2\sibsFunctions;
use Sibs2\sibsPayments;

function sibs_admin_style_menu()
{
    add_submenu_page(
        'woocommerce',
        __('SIBS_STYLE_GENERAL', sibsConstants::SIBS_TRANSLATE),
        __('SIBS_STYLE_GENERAL', sibsConstants::SIBS_TRANSLATE),
        'manage_options',
        'sibs_style',
        'sibs_page_style_content',
        3
    );
}

//add_action('admin_menu', 'sibs_admin_style_menu');

function sibs_page_style_content()
{
    if (isset($_POST['sibs_save_style_settings'])) {
        $save = sibsPayments::saveDataStyleSettings($_POST);
    }

    wp_enqueue_style('wp-color-picker');
    wp_enqueue_script('iris', admin_url('js/iris.min.js'), [], false, 1);

    $environment_file    = sibsFunctions::get_environment();
    $environment         = $environment_file['environment'];
    $environment_default = $environment_file['default_environment'];

    $layout = [
        'default'   => __('default', sibsConstants::SIBS_TRANSLATE),
        'list'      => __('list', sibsConstants::SIBS_TRANSLATE),
        'accordion' => __('accordion', sibsConstants::SIBS_TRANSLATE),
    ];
    $style_theme = [
        'default' => __('default', sibsConstants::SIBS_TRANSLATE),
        'light'   => __('light', sibsConstants::SIBS_TRANSLATE),
        'gray'    => __('gray', sibsConstants::SIBS_TRANSLATE),
        'dark'    => __('dark', sibsConstants::SIBS_TRANSLATE),
    ];

    ?>

<style type="text/css">
.iris-picker {
	z-index: 100;
	display: none;
	position: absolute;
	border: 1px solid #ccc;
	border-radius: 3px;
	box-shadow: 0 1px 3px rgb(0 0 0 / 20%);
}
</style>

	<div class="sibs_header">
		<div>
			<img src="<?php echo esc_attr(plugins_url(sibsConstants::SIBS_TRANSLATE . '/assets/images/sibs_logo.png', )); ?>" alt="Sibs">
		</div>
		<div>
			<h1><?php esc_html_e('SIBS_STYLE_GENERAL', sibsConstants::SIBS_TRANSLATE); ?></h1>
		</div>
	</div>
	<?php if (isset($_POST['sibs_save_style_settings'])) { ?>
		<div class="sibs-notice notice notice-success"> 
			<p><strong><?php esc_html_e('Settings saved.', sibsConstants::SIBS_TRANSLATE); ?></strong></p>
		</div>
	<?php } ?>

	<div class="sibs-settings">
		<form name="sibs-settings" method="POST" action="" style="width: 90%;"> 
			<table class="form-table" role="presentation">
				<tbody>

					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout'?>"><?php esc_html_e('LAYOUT', sibsConstants::SIBS_TRANSLATE); ?></label>
						</th>
						<td>
							<select name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout'?>" style="width:25em;">
							<?php

                            foreach ($layout as $key => $value) {
                                if (get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout') == $key) {
                                    echo '<option value="' . $key . '" selected>' . $value . '</option>';
                                } else {
                                    echo '<option value="' . $key . '" >' . $value . '</option>';
                                }
                            }?>
							</select>
							
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_primary'?>">
							<?php esc_html_e('Button Color', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_primary'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_primary')); ?>" >
							</p>
						</td>
					</tr>

					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_surface'?>">
							<?php esc_html_e('Surface Color', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_surface'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_surface')); ?>" >
							</p>
						</td>
					</tr>

					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_text_color'?>">
							<?php esc_html_e('Text Color', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_text_color'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_text_color')); ?>" >
							</p>
						</td>
					</tr>

					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_header_color'?>">
							<?php esc_html_e('Header Color', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_header_color'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_layout_header_color')); ?>" >
							</p>
						</td>
					</tr>

					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme'?>"><?php esc_html_e('THEME', sibsConstants::SIBS_TRANSLATE); ?></label>
						</th>
						<td>
							<select name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme'?>" style="width:25em;">
							<?php
                            foreach ($style_theme as $key => $value) {
                                if (get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme') == $key) {
                                    echo '<option value="' . $key . '" selected>' . $value . '</option>';
                                } else {
                                    echo '<option value="' . $key . '" >' . $value . '</option>';
                                }
                            }?>
							</select>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_secondary_color'?>">
							<?php esc_html_e('Secondary', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_secondary_color'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_secondary_color')); ?>" >
							</p>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_background_color'?>">
							<?php esc_html_e('Background', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_background_color'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_background_color')); ?>" >
							</p>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_border_color'?>">
							<?php esc_html_e('Border', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_border_color'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_border_color')); ?>" >
							</p>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_header_text'?>">
							<?php esc_html_e('Header Text', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text colorpick" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_header_text'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_theme_header_text')); ?>" >
							</p>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label for="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_font'?>">
							<?php esc_html_e('Font Family', sibsConstants::SIBS_TRANSLATE); ?>
							</label>
						</th>
						<td>
							<input class="regular-text" type="text" name="<?php echo sibsConstants::SIBS_PLUGIN_PREFIX . '_style_font'?>" value="<?php echo esc_attr(get_option(sibsConstants::SIBS_PLUGIN_PREFIX . '_style_font')); ?>" >
							</p>
						</td>
					</tr>
				</tbody>
			</table>			
			<p>
				<input class="button button-primary" type="submit" name="sibs_save_style_settings" value="<?php esc_html_e('Save Changes', sibsConstants::SIBS_TRANSLATE); ?>">
			</p>
		</form>
		
	</div>
<?php
}

?>