<?php
/**
 * Rewards Configuration template class
 *
 * @package MultiPOS - Point of Sale for WooCommerce
 * @version 1.0.0
 */

namespace DDWCMultiPOS\Templates\Admin\Configuration;

use DevDiggers\Framework\Includes\DDFW_Layout;

defined( 'ABSPATH' ) || exit();

if ( ! class_exists( 'DDWCPOS_Rewards_Configuration_Template' ) ) {
	/**
	 * Rewards Configuration template class
	 *
	 * POS rewards (LoyaltyX integration) are a Pro-only feature; the integration code
	 * is not shipped in the free build. The fields below are disabled, non-functional
	 * previews (no register_setting, never saved) shown only so users can see what the
	 * Pro version provides.
	 */
	class DDWCPOS_Rewards_Configuration_Template {
		/**
		 * Construct
		 *
		 * @param array $ddwcpos_configuration Configuration data.
		 */
		public function __construct( $ddwcpos_configuration ) {
			$pro_field = [
				'field_class'       => [ 'ddfw-upgrade-to-pro-tag-wrapper' ],
				'custom_attributes' => [ 'disabled' => 'disabled' ],
			];

			$args = [
				[
					'header' => [
						'heading'     => esc_html__( 'Rewards', 'devdiggers-multipos-for-woocommerce' ),
						'description' => esc_html__( 'Use LoyaltyX rules, balances, and reward coupons inside the POS checkout flow. Available in Pro.', 'devdiggers-multipos-for-woocommerce' ),
					],
					'fields' => [
						array_merge(
							[
								'type'           => 'checkbox',
								'label'          => esc_html__( 'LoyaltyX Status', 'devdiggers-multipos-for-woocommerce' ),
								'checkbox_label' => esc_html__( 'Enable LoyaltyX in POS', 'devdiggers-multipos-for-woocommerce' ),
								'description'    => esc_html__( 'Show LoyaltyX points and rewards to cashiers and sync POS orders with LoyaltyX.', 'devdiggers-multipos-for-woocommerce' ),
								'id'             => 'ddwcpos-loyaltyx-rewards-enabled',
								'value'          => '',
							],
							$pro_field
						),
						array_merge(
							[
								'type'           => 'checkbox',
								'label'          => esc_html__( 'Earning Rules', 'devdiggers-multipos-for-woocommerce' ),
								'checkbox_label' => esc_html__( 'Award points for POS orders', 'devdiggers-multipos-for-woocommerce' ),
								'description'    => esc_html__( 'Calculate earned points from active LoyaltyX purchase rules when POS orders reach the configured order status.', 'devdiggers-multipos-for-woocommerce' ),
								'id'             => 'ddwcpos-loyaltyx-earning-enabled',
								'value'          => '',
							],
							$pro_field
						),
						array_merge(
							[
								'type'           => 'checkbox',
								'label'          => esc_html__( 'Redeeming Rules', 'devdiggers-multipos-for-woocommerce' ),
								'checkbox_label' => esc_html__( 'Let cashiers create LoyaltyX reward coupons in POS', 'devdiggers-multipos-for-woocommerce' ),
								'description'    => esc_html__( 'Customers can convert points or redeem active LoyaltyX reward rules from the POS cart.', 'devdiggers-multipos-for-woocommerce' ),
								'id'             => 'ddwcpos-loyaltyx-redeeming-enabled',
								'value'          => '',
							],
							$pro_field
						),
						array_merge(
							[
								'type'           => 'checkbox',
								'label'          => esc_html__( 'Existing Rewards', 'devdiggers-multipos-for-woocommerce' ),
								'checkbox_label' => esc_html__( 'Show customer LoyaltyX coupons in POS', 'devdiggers-multipos-for-woocommerce' ),
								'description'    => esc_html__( 'Active LoyaltyX-generated coupons appear in the reward picker and can be applied like normal POS coupons.', 'devdiggers-multipos-for-woocommerce' ),
								'id'             => 'ddwcpos-loyaltyx-reward-coupons-enabled',
								'value'          => '',
							],
							$pro_field
						),
						array_merge(
							[
								'type'        => 'select',
								'label'       => esc_html__( 'Allowed Earning Rules', 'devdiggers-multipos-for-woocommerce' ),
								'description' => esc_html__( 'Choose earning rules available to POS orders. Leave empty to allow every active LoyaltyX earning rule.', 'devdiggers-multipos-for-woocommerce' ),
								'id'          => 'ddwcpos-loyaltyx-allowed-earning-rules',
								'value'       => '',
								'options'     => [],
								'input_class' => [ 'ddwcpos-select2' ],
							],
							$pro_field
						),
						array_merge(
							[
								'type'        => 'select',
								'label'       => esc_html__( 'Allowed Redeeming Rules', 'devdiggers-multipos-for-woocommerce' ),
								'description' => esc_html__( 'Choose reward rules cashiers can redeem in POS. Leave empty to allow every active LoyaltyX redeeming rule.', 'devdiggers-multipos-for-woocommerce' ),
								'id'          => 'ddwcpos-loyaltyx-allowed-redeeming-rules',
								'value'       => '',
								'options'     => [],
								'input_class' => [ 'ddwcpos-select2' ],
							],
							$pro_field
						),
					],
				],
			];

			$layout = new DDFW_Layout();
			$layout->get_form_section_layout( $args, 'ddwcpos-rewards-configuration-fields' );
		}
	}
}
