<?php
/**
 * View: Widget Settings metabox (Woo-style layout).
 *
 * @package Ilabs\Firevert\Modules\PowerWidget
 *
 * @var WP_Post $post
 * @var bool    $firevert_power_widget_visible_admin_only
 * @var string  $firevert_power_widget_display_position
 * @var string  $firevert_power_widget_display_start
 * @var string  $firevert_power_widget_display_end
 * @var bool    $firevert_power_widget_display_timer
 * @var bool    $firevert_power_widget_display_desktop
 * @var bool    $firevert_power_widget_display_mobile
 * @var bool    $firevert_power_widget_expand_mobile
 */

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

use Ilabs\Firevert\Modules\PowerWidget\Services\Type\SectionType;
use Ilabs\Firevert\Modules\PowerWidget\Services\Type\PositionType;

$positions = PositionType::get_all();
?>

<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="firevert-form">
	<?php wp_nonce_field( 'firevert_power_widget_save', 'firevert_power_widget_nonce' ); ?>
	<input type="hidden" name="action" value="firevert_save_power_widget">
	<input type="hidden" name="section" value="<?php echo esc_attr( SectionType::SETTINGS ); ?>">
	<input type="hidden" name="post_ID" value="<?php echo esc_attr( $post->ID ); ?>">

	<div class="metabox-holder woocommerce">
		<div class="postbox wc-metabox">
			<div class="postbox-header">
				<h2 class="hndle">
					<span><?php esc_html_e( 'General Display Settings', 'firevert' ); ?></span>
				</h2>
			</div>
			<div class="inside">
				<p>
					<label>
						<input type="checkbox" name="firevert_power_widget_visible_admin_only"
							value="1" <?php checked( $firevert_power_widget_visible_admin_only ); ?> />
						<?php esc_html_e( 'Visibility for admin only', 'firevert' ); ?>
					</label>
				</p>

				<p>
					<label for='firevert_power_widget_display_position'>
						<?php esc_html_e( 'Widget display position', 'firevert' ); ?>
					</label><br/>

					<select name="firevert_power_widget_display_position" id="firevert_power_widget_display_position">
						<?php foreach ( $positions as $value => $label ) : ?>
							<option value="<?php echo esc_attr( $value ); ?>"
								<?php selected( $firevert_power_widget_display_position, $value ); ?>>
								<?php echo esc_html( $label ); ?>
							</option>
						<?php endforeach; ?>
					</select>
				</p>
			</div>
		</div>

		<div class="postbox wc-metabox">
			<div class="postbox-header">
				<h2 class="hndle">
					<span><?php esc_html_e( 'Set widget display date', 'firevert' ); ?></span>
				</h2>
			</div>
			<div class="inside">
				<p>
					<label for="firevert_power_widget_display_start">
						<?php esc_html_e( 'Start date', 'firevert' ); ?>
					</label><br/>
					<input type="datetime-local" name="firevert_power_widget_display_start"
						id="firevert_power_widget_display_start"
						value="<?php echo esc_attr( $firevert_power_widget_display_start ); ?>"/>
				</p>

				<p>
					<label for="firevert_power_widget_display_end">
						<?php esc_html_e( 'End date', 'firevert' ); ?>
					</label><br/>
					<input type="datetime-local" name="firevert_power_widget_display_end"
						id="firevert_power_widget_display_end"
						value="<?php echo esc_attr( $firevert_power_widget_display_end ); ?>"/>
				</p>

				<p>
					<label>
						<input type="checkbox" name="firevert_power_widget_display_timer"
							value="1" <?php checked( $firevert_power_widget_display_timer ); ?> />
						<?php esc_html_e( 'Display timer on widget', 'firevert' ); ?>
					</label>
				</p>
			</div>
		</div>

		<div class="postbox wc-metabox">
			<div class="postbox-header">
				<h2 class="hndle">
					<span><?php esc_html_e( 'Display on', 'firevert' ); ?></span>
				</h2>
			</div>
			<div class="inside">
				<p>
					<label>
						<input type="checkbox" name="firevert_power_widget_display_desktop"
							value="1" <?php checked( $firevert_power_widget_display_desktop ); ?> />
						<?php esc_html_e( 'Desktop', 'firevert' ); ?>
					</label><br/>

					<label>
						<input type="checkbox" name="firevert_power_widget_display_mobile"
							value="1" <?php checked( $firevert_power_widget_display_mobile ); ?> />
						<?php esc_html_e( 'Mobile', 'firevert' ); ?>
					</label><br/>

					<label>
						<input type='checkbox' name='firevert_power_widget_expand_mobile'
								value='1' <?php checked( $firevert_power_widget_expand_mobile ); ?> />
						<?php esc_html_e( 'Expand widget on mobile devices', 'firevert' ); ?>
					</label>
				</p>
			</div>
		</div>
	</div>

	<?php submit_button( __( 'Save', 'firevert' ) ); ?>
</form>
