<?php
/**
 * Conditions settings page display.
 *
 * @package BricksExtras
 */

namespace BricksExtras;

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

/**
 * Conditions page class.
 */
class ConditionsPage {

	/**
	 * Prefix for settings.
	 *
	 * @var string
	 */
	public static $prefix = '';

	/**
	 * Page title.
	 *
	 * @var string
	 */
	public static $title = '';

	/**
	 * Plugin version.
	 *
	 * @var string
	 */
	public static $version = '';

	/**
	 * Display the conditions settings page.
	 *
	 * @param string $prefix Plugin prefix.
	 * @param string $title Page title.
	 * @param string $version Plugin version.
	 * @return void
	 */
	public static function init( $prefix, $title, $version ) {
		self::$prefix  = $prefix;
		self::$title   = $title;
		self::$version = $version;
		?>
		
		<h2><?php echo esc_html__( 'Conditions', 'bricksextras' ); ?></h2>

		<div class="form-plugin-links" style="display: flex;">
			<form method="post" action="options.php" style="width: 100%;">

				<?php settings_fields( self::$prefix . 'conditions_settings' ); ?>

					<div style="width: 100%; column-count: 2; gap: 2rem;">

						<table class="wp-list-table widefat plugins" style="break-inside: avoid;">
							<thead>
							<tr>
								<td id="cb" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-1">General Conditions - Toggle All</label><input id="cb-select-all-1" type="checkbox"></td><th scope="col" id="name" class="manage-column column-name column-primary"><strong>General Conditions</strong></th><td></td></tr>
							</thead>
							<tbody>
								<?php do_action( self::$prefix . 'conditions_form_options' ); ?>
							</tbody>
						</table>
						
						<table class="wp-list-table widefat plugins" style="break-inside: avoid;">
							<thead>
							<tr>
								<td id="cb2" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-2">Membership Conditions - Toggle All</label><input id="cb-select-all-2" type="checkbox"></td><th scope="col" id="name-2" class="manage-column column-name column-primary"><strong>Membership Conditions</strong></th><td></td></tr>
							</thead>
							<tbody>
								<?php do_action( self::$prefix . 'member_conditions_form_options' ); ?>
							</tbody>
						</table>
						
						
						<br>
						
						
						<table class="wp-list-table widefat plugins" style="break-inside: avoid;">
							<thead>
							<tr>
								<td id="cb3" class="manage-column column-cb check-column"><label class="screen-reader-text" for="cb-select-all-3">WooCommerce Conditions - Toggle All</label><input id="cb-select-all-3" type="checkbox"></td><th scope="col" id="name-3" class="manage-column column-name column-primary"><strong>WooCommerce Conditions</strong></th><td></td></tr>
							</thead>
							<tbody>
								<?php do_action( self::$prefix . 'wc_conditions_form_options' ); ?>
							</tbody>
						</table>

					</div>
					
					<?php submit_button( '', $type = 'primary large' ); ?>
			</form>

		</div>

		<?php
	}
}