<?php
/**
 * Abstract online solution settings model for webshop/catering.
 *
 * @package northmill-online-shared
 */

declare( strict_types = 1 );

namespace Northmill_Online_Shared\Modules\Admin\Pages\Page\Admin_Sync_Settings\Models;

use Northmill_Online_Shared\Modules\Admin\Pages\Page\Admin_Sync_Settings\Models\Properties\Settings_Color_Model;

defined( 'ABSPATH' ) || exit;

/**
 * Class Abstract_Online_Solution_Webshop_Settings_Model
 *
 * @used Northmill Webshop Theme
 * @used Northmill Catering Theme
 */
abstract class Abstract_Online_Solution_Webshop_Settings_Model extends Abstract_Online_Solution_Settings_Model {
	/**
	 * Whether the webshop is public.
	 *
	 * @var bool
	 */
	public bool $SitePublic;
	/**
	 * Enable account creation.
	 *
	 * @var bool
	 */
	public bool $EnableAccountCreation;

	/**
	 * Color settings for general background of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorGeneralBackground;

	/**
	 * Color settings for the general header background of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorHeaderBackground;

	/**
	 * Color settings for the general header text of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorHeaderText;

	/**
	 * Color settings for the general header link of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorHeaderLink;
	/**
	 * Color settings for the footer background of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorFooterBackground;

	/**
	 * Color settings for the footer heading of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorFooterHeading;

	/**
	 * Color settings for the footer text of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorFooterText;

	/**
	 * Color settings for the footer link of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorFooterLink;
	/**
	 * Color settings for the typography heading of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorTypographyHeading;

	/**
	 * Color settings for the typography text of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorTypographyText;

	/**
	 * Color settings for the typography link of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorTypographyLink;
	/**
	 * Color settings for the button background of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorButtonBackground;

	/**
	 * Color settings for the button text of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorButtonText;

	/**
	 * Color settings for the button alt background of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorButtonAltBackground;

	/**
	 * Color settings for the button alt text of the webshop theme.
	 *
	 * @var Settings_Color_Model|null
	 */
	public ?Settings_Color_Model $ColorButtonAltText;

	/**
	 * Content for the about us page.
	 *
	 * @var string
	 */
	public string $ContentAboutUs;
	/**
	 * Content for the contact us page.
	 *
	 * @var string
	 */
	public string $ContentContactUs;
	/**
	 * Content for the terms of purchase page.
	 *
	 * @var string
	 */
	public string $ContentTermsOfPurchase;
	/**
	 * Content for the privacy policy page.
	 *
	 * @var string
	 */
	public string $ContentPrivacyPolicy;

	/**
	 * {@inheritDoc}
	 */
	public function is_enabled(): bool {
		if ( ! parent::is_enabled() ) {
			return false;
		}

		return ! empty( $this->CompanyName ) && ! empty( $this->ColorHeaderBackground );
	}

	/**
	 * {@inheritDoc}
	 */
	public function get_preview_site_section(
		array $additional_fields_before = array(),
		array $additional_fields_after = array()
	): array {
		return parent::get_preview_site_section(
			array_merge(
				array(
					array(
						'name'  => 'SitePublic',
						'label' => __( 'Site public', 'northmill-online-shared' ),
						'value' => $this->SitePublic
							? __( 'Yes', 'northmill-online-shared' )
							: __( 'No', 'northmill-online-shared' ),
						'mark'  => $this->SitePublic
							? 'yes'
							: 'no',
					),
				),
				$additional_fields_before,
			),
			array_merge(
				array(
					array(
						'name'  => 'EnableAccountCreation',
						'label' => __( 'Enable account creation', 'northmill-online-shared' ),
						'value' => $this->EnableAccountCreation
							? __( 'Yes', 'northmill-online-shared' )
							: __( 'No', 'northmill-online-shared' ),
						'mark'  => $this->EnableAccountCreation
							? 'yes'
							: 'no',
					),
				),
				$additional_fields_after,
			)
		);
	}

	/**
	 * Get the section payment methods for the preview.
	 *
	 * @return array
	 *
	 * @used Northmill Webshop Theme
	 * @used Northmill Catering Theme
	 */
	public function get_preview_theme_section(): array {
		return array(
			'label'  => __( 'Theme', 'northmill-online-shared' ),
			'values' => array(
				array(
					'name'  => 'ColorGeneralBackground',
					'label' => __( 'General - Background', 'northmill-online-shared' ),
					'value' => $this->ColorGeneralBackground,
				),
				array(
					'name'  => 'ColorHeaderBackground',
					'label' => __( 'Header - Background', 'northmill-online-shared' ),
					'value' => $this->ColorHeaderBackground,
				),
				array(
					'name'  => 'ColorHeaderText',
					'label' => __( 'Header - Text', 'northmill-online-shared' ),
					'value' => $this->ColorHeaderText,
				),
				array(
					'name'  => 'ColorHeaderLink',
					'label' => __( 'Header - Link', 'northmill-online-shared' ),
					'value' => $this->ColorHeaderLink,
				),
				array(
					'name'  => 'ColorFooterBackground',
					'label' => __( 'Footer - Background', 'northmill-online-shared' ),
					'value' => $this->ColorFooterBackground,
				),
				array(
					'name'  => 'ColorFooterHeading',
					'label' => __( 'Footer - Heading', 'northmill-online-shared' ),
					'value' => $this->ColorFooterHeading,
				),
				array(
					'name'  => 'ColorFooterText',
					'label' => __( 'Footer - Text', 'northmill-online-shared' ),
					'value' => $this->ColorFooterText,
				),
				array(
					'name'  => 'ColorFooterLink',
					'label' => __( 'Footer - Link', 'northmill-online-shared' ),
					'value' => $this->ColorFooterLink,
				),
				array(
					'name'  => 'ColorTypographyHeading',
					'label' => __( 'Typography - Heading', 'northmill-online-shared' ),
					'value' => $this->ColorTypographyHeading,
				),
				array(
					'name'  => 'ColorTypographyText',
					'label' => __( 'Typography - Text', 'northmill-online-shared' ),
					'value' => $this->ColorTypographyText,
				),
				array(
					'name'  => 'ColorTypographyLink',
					'label' => __( 'Typography - Link', 'northmill-online-shared' ),
					'value' => $this->ColorTypographyLink,
				),
				array(
					'name'  => 'ColorButtonBackground',
					'label' => __( 'Button - Background', 'northmill-online-shared' ),
					'value' => $this->ColorButtonBackground,
				),
				array(
					'name'  => 'ColorButtonText',
					'label' => __( 'Button - Text', 'northmill-online-shared' ),
					'value' => $this->ColorButtonText,
				),
				array(
					'name'  => 'ColorButtonAltBackground',
					'label' => __( 'Button - Alternative Background', 'northmill-online-shared' ),
					'value' => $this->ColorButtonAltBackground,
				),
				array(
					'name'  => 'ColorButtonAltText',
					'label' => __( 'Button - Alternative Text', 'northmill-online-shared' ),
					'value' => $this->ColorButtonAltText,
				),
			),
		);
	}

	/**
	 * Get the section payment methods for the preview.
	 *
	 * @return array
	 *
	 * @used Northmill Webshop Theme
	 * @used Northmill Catering Theme
	 */
	public function get_preview_page_content_section(): array {
		return array(
			'label'  => __( 'Pages content', 'northmill-online-shared' ),
			'values' => array(
				array(
					'name'  => 'ContentAboutUs',
					'label' => __( 'About us', 'northmill-online-shared' ),
					'value' => $this->ContentAboutUs,
				),
				array(
					'name'  => 'ContentContactUs',
					'label' => __( 'Contact us', 'northmill-online-shared' ),
					'value' => $this->ContentContactUs,
				),
				array(
					'name'  => 'ContentTermsOfPurchase',
					'label' => __( 'Terms of purchase', 'northmill-online-shared' ),
					'value' => $this->ContentTermsOfPurchase,
				),
				array(
					'name'  => 'ContentPrivacyPolicy',
					'label' => __( 'Privacy policy', 'northmill-online-shared' ),
					'value' => $this->ContentPrivacyPolicy,
				),
			),
		);
	}
}
