<?php

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

if ( !class_exists( 'Reon' ) ) {
    return;
}

if ( !class_exists( 'Pricely_Admin_Cart_Discounts_Panel_Max' ) ) {

    class Pricely_Admin_Cart_Discounts_Panel_Max {

        public function __construct() {

            add_filter( 'pricely_admin_cart-discounts_get-panels', array( $this, 'get_panel' ), 40 );
        }

        public function get_panel( $in_fields ) {

            $in_fields[] = array(
                'id' => 'any_id',
                'type' => 'panel',
                'full_width' => true,
                'center_head' => true,
                'white_panel' => true,
                'panel_size' => 'smaller',
                'width' => '100%',
                'merge_fields' => false,
                'last' => true,
                'field_css_class' => array( 'pricely_next_panel' ),
                'css_class' => array( 'rn-round-small' ),
                'fields' => $this->get_panel_fields( array() ),
            );

            return $in_fields;
        }

        private function get_panel_fields( $in_fields ) {

            $in_fields[] = array(
                'id' => 'limit',
                'type' => 'columns-field',
                'columns' => 11,
                'merge_fields' => true,
                'fields' => $this->get_fields( array() ),
            );

            return $in_fields;
        }

        private function get_fields( $in_fields ) {

            $currency = get_woocommerce_currency_symbol( get_woocommerce_currency() );

            $in_fields[] = array(
                'id' => 'limit_type',
                'type' => 'select2',
                'column_size' => 3,
                'column_title' => esc_html__( 'Discount Limit', 'pricely-dynamic-pricing-cart-discounts' ),
                'tooltip' => esc_html__( 'Determines if this discount should be limited to a specific amount', 'pricely-dynamic-pricing-cart-discounts' ),
                'default' => 'no',
                'options' => array(
                    'no' => esc_html__( 'No discount limit', 'pricely-dynamic-pricing-cart-discounts' ),
                ),
                'width' => '100%',
            );

            return $in_fields;
        }

    }

    new Pricely_Admin_Cart_Discounts_Panel_Max();
}