<?php
/**
 * Calculator main settings.
 *
 * @link       https://belovdigital.agency
 * @since      1.0.0
 *
 * @package    ultimate-pregnancy-ovulation-calculator
 * @subpackage ULPC/admin/partials
 */

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

?>

<section id="main-settings" class="ulpc-settings-section active">

	<h2 class="ulpc-settings-section-title"><?php esc_html_e( 'Settings', 'ultimate-pregnancy-ovulation-calculator' ); ?></h2>

	<div id="title_settings" class="ulpc-settings-group">

		<div class="ulpc-settings-group-title">
			<h3><?php esc_html_e( 'Main Calculator Title', 'ultimate-pregnancy-ovulation-calculator' ); ?></h3>

			<?php
			$title_show = $ulpc->get_option( 'title_show' );
			?>

			<div class="ulpc-switch-wrapper">
				<div class="ulpc-switch">
					<div class="ulpc-switch-option" data-position="left">	<?php esc_html_e( 'Hide', 'ultimate-pregnancy-ovulation-calculator' ); ?></div>
					<label class="ulpc-switch-toggle">
						<input type="checkbox" name="ulpc_options[title_show]" value="show" <?php checked( 'show', $title_show ); ?>>
						<div class="ulpc-switch-toggle-circle"></div>
						<div class="ulpc-switch-toggle-background"></div>
					</label>
					<div class="ulpc-switch-option" data-position="right"><?php esc_html_e( 'Show', 'ultimate-pregnancy-ovulation-calculator' ); ?></div>
				</div>
			</div>						
		</div>

		<div id="title_show_settings" class="ulpc-settings-group-content" style="<?php echo 'show' === $title_show ? '' : 'display:none;'; ?>">

			<div class="ulpc-settings-group-content">

				<div class="ulpc-settings-row ulpc-settings-row-title">
					<?php $title_text = $ulpc->get_option( 'title_text' ); ?>

					<input type="text" name="ulpc_options[title_text]" value="<?php echo esc_attr( $title_text ); ?>">

				</div>
			</div>
		</div>
	</div>

		<div id="calculator_type_settings" class="ulpc-settings-group">
		<div class="ulpc-settings-group-title">
			<h3><?php esc_html_e( 'Calculator Type', 'ultimate-pregnancy-ovulation-calculator' ); ?></h3>
		</div>

		<?php
		$calculator_type  = $ulpc->get_option( 'calculator_type' );
		$calculator_types = $ulpc->get_calculator_types();
		?>
		<div class="ulpc-settings-group-content">
			<select id="ulpc_calculator_type_select" name="ulpc_options[calculator_type]">
				<?php
				foreach ( $calculator_types as $key => $value ) :
					?>
					<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $calculator_type, true ); ?>><?php echo esc_html( $value ); ?></option>
				<?php endforeach; ?>
			</select>
		</div>
	</div>

	<div id="calculator_method_settings" class="ulpc-settings-group" style="<?php echo 'pregnancy' === $calculator_type ? '' : 'display:none;'; ?>">
		<div class="ulpc-settings-group-title">
			<h3><?php esc_html_e( 'Default Calculator Method', 'ultimate-pregnancy-ovulation-calculator' ); ?></h3>
		</div>

		<?php
		$calculator_method  = $ulpc->get_option( 'calculator_method' );
		$calculator_methods = $ulpc->get_calculator_methods();
		?>
		<div class="ulpc-settings-group-content">
			<select id="ulpc_calculator_method_select" name="ulpc_options[calculator_method]">
				<?php
				foreach ( $calculator_methods as $key => $value ) :
					?>
					<option class="ulpc-calculator-method-option" value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $calculator_method, true ); ?>  <?php echo 'ultrasound' === $key || 'ivf_transfer' === $key || 'conception_date' === $key ? 'disabled' : ''; ?>><?php echo esc_html( $value ); ?></option>
				<?php endforeach; ?>
			</select>
		</div>
	</div>

	<div id="date_format_settings" class="ulpc-settings-group">
		<div class="ulpc-settings-group-title">
			<h3><?php esc_html_e( 'Date Format', 'ultimate-pregnancy-ovulation-calculator' ); ?></h3>
		</div>

		<?php
		$date_format  = $ulpc->get_option( 'date_format' );
		$date_formats = $ulpc->get_default_date_formats();
		?>
		<div class="ulpc-settings-group-content">
			<select id="ulpc_date_format" name="ulpc_options[date_format]">
				<?php
				foreach ( $date_formats as $key => $value ) :
					?>
					<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $date_format, true ); ?>><?php echo esc_html( $value ); ?></option>
				<?php endforeach; ?>
			</select>
		</div>
	</div>

	<div class="ulpc-settings-submit">
		<?php echo esc_html( submit_button( null, 'ulpc-submit', 'publish', true, array( 'id' => 'publish' ) ) ); ?>
	</div>

</section>
