<?php
/**
 * Created by PhpStorm.
 * User: Villatheme-Thanh
 * Date: 13-06-19
 * Time: 9:55 AM
 */

namespace WACVP\Inc\Settings;

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

class Email_Popup_Settings extends Admin_Settings {

	protected static $instance = null;

	public function __construct() {

	}

	public static function get_instance() {

		if ( null == self::$instance ) {
			self::$instance = new self;
		}

		return self::$instance;
	}

	public function setting_page() {
		$redirect_option   = array(
			'no_redirect'      => esc_html__( 'No redirect', "woo-abandoned-cart-recovery" ),
			'to_cart_page'     => esc_html__( 'Cart page', "woo-abandoned-cart-recovery" ),
			'to_checkout_page' => esc_html__( 'Checkout page', "woo-abandoned-cart-recovery" ),
		);
		$unsub_type_option = array(
			'cart'  => esc_html__( 'Current abandoned cart', "woo-abandoned-cart-recovery" ),
			'email' => esc_html__( "Customer's email", "woo-abandoned-cart-recovery" ),
		);
		$country_codes = include WC()->plugin_path() . '/i18n/phone.php';
		ksort( $country_codes );
		$captcha_type = array(
            'ver2' => 'reCAPTCHA v2',
            'ver3' => 'reCAPTCHA v3',
        )
		?>
        <div class="vi-ui bottom attached tab segment tab-admin" data-tab="popup">
            <h4><?php esc_html_e( 'Get email popup', 'woo-abandoned-cart-recovery' ) ?></h4>
            <table class="wacv-table">
				<?php $this->checkbox_option( 'front_page', esc_html__( "Appear on", 'woo-abandoned-cart-recovery' ), esc_html__( 'Choose which pages where you want the request email pop-up appear', 'woo-abandoned-cart-recovery' ), esc_html__( 'Home page', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'single_page', '', '', esc_html__( 'Single product pages', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'shop_page', '', '', esc_html__( 'Shop page', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'cart_page', '', '', esc_html__( 'Cart page', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'category_page', '', '', esc_html__( 'Category page', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->text_option( 'popup_page_id', '', esc_html__( 'page_id, e.g: 123,456', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->text_option( 'popup_post_type', '', esc_html__( 'post_type, e.g: adb_cart,abd_block', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->text_option( 'exclude_class_popup', esc_html__( 'Exclude button with class', 'woo-abandoned-cart-recovery' ), 'eg: add-to-cart-loop,add-to-cart-archive' ); ?>
				<?php $this->checkbox_option( 'immediate_cart_popup', esc_html__( "Immediate display on the cart page", 'woo-abandoned-cart-recovery' ), '', '' ); ?>
				<?php $this->checkbox_option( 'email_field', esc_html__( "Fields display", 'woo-abandoned-cart-recovery' ), '', esc_html__( 'Email', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'phone_field', '', '', esc_html__( 'Phone number (Only appear in template 1 popup)', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'enable_captcha', '', '', esc_html__( 'Google reCAPTCHA', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'enable_gdpr', '', '', esc_html__( 'GDPR', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->select_option( 'def_phone_country', $country_codes, esc_html__( "Default phone country", 'woo-abandoned-cart-recovery' ), '' ); ?>
				<?php $this->select_option( 'recaptcha_version', $captcha_type, esc_html__( "Captcha version", 'woo-abandoned-cart-recovery' ), '' ); ?>
				<?php $this->text_option( 'recaptcha_site_key', esc_html__( 'Captcha site key', 'woo-abandoned-cart-recovery' ), '' ); ?>
				<?php $this->text_option( 'recaptcha_secret_key', esc_html__( 'Captcha secret key', 'woo-abandoned-cart-recovery' ), '' ); ?>
				<?php $this->guide_option( 'recaptcha_guide', esc_html__( 'Captcha guide', 'woo-abandoned-cart-recovery' ), 'captcha' ); ?>
				<?php $this->editor_option( 'gdpr_content', esc_html__( 'GDPR content', 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->checkbox_option( 'info_require', esc_html__( "Email required", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->checkbox_option( 'phone_require', esc_html__( "Phone number required", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->number_option( 'dismiss_delay', esc_html__( "Dismiss time", 'woo-abandoned-cart-recovery' ), esc_html__( 'Set a time for the get email pop-up to reappear', 'woo-abandoned-cart-recovery' ), esc_html__('minutes', 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->select_option( 'redirect_after_atc', $redirect_option, esc_html__( "Redirect after Add to cart", 'woo-abandoned-cart-recovery' ), '' ); ?>
				<?php $this->template_popup( 'template_popup', esc_html__( "Template", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->text_option( 'title_popup', esc_html__( "Title", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'sub_title_popup', esc_html__( "Sub title", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'add_to_cart_btn', esc_html__( "Add to cart", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'popup_close_text', esc_html__( 'Popup close text', 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'invalid_email', esc_html__( "Invalid email notice", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'invalid_phone', esc_html__( "Invalid phone number notice", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->checkbox_option( 'enable_email_immediate', esc_html__( "Send email immediately after close popup", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->text_option( 'email_immediate_subject', esc_html__( "Email immediately subject", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->editor_option( 'email_immediate_content', esc_html__( 'Email immediately content', 'woo-abandoned-cart-recovery' ), '', '', true ); ?>

            </table>
            <hr>
            <h4><?php esc_html_e( 'Unsubscribe popup', 'woo-abandoned-cart-recovery' ) ?></h4>
            <table class="wacv-table">
				<?php $this->text_option( 'unsub_title', esc_html__( "Title", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'unsub_content', esc_html__( "Content", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'unsub_button', esc_html__( "Button label", 'woo-abandoned-cart-recovery' ), '', '', true ); ?>
				<?php $this->text_option( 'unsub_redirect', esc_html__( "Redirect URL", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->select_option( 'unsub_type', $unsub_type_option, esc_html__( "Unsubscribe type", 'woo-abandoned-cart-recovery' ),
					esc_html__( 'If choose "Current abandoned cart" not send the following abandoned emails for the current abandoned cart, but do still send if any then; Or choose "Customer\'s email" never send abandoned emails if customers unsubscribe.', 'woo-abandoned-cart-recovery' ) ); ?>
            </table>
            <hr>
            <h4><?php esc_html_e( 'Design', 'woo-abandoned-cart-recovery' ) ?></h4>
            <table class="wacv-table">
				<?php $this->color_field( 'popup_bg_color', esc_html__( "Background color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_title_color', esc_html__( "Title color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_sub_title_color', esc_html__( "Sub title color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_btn_color', esc_html__( "Button color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_btn_bg_color', esc_html__( "Button background color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_input_border_color', esc_html__( "Input border color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_input_text_color', esc_html__( "Input text color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_input_bg_color', esc_html__( "Input background color", 'woo-abandoned-cart-recovery' ) ); ?>
				<?php $this->color_field( 'popup_notice_color', esc_html__( "Notice color", 'woo-abandoned-cart-recovery' ) ); ?>
            </table>
        </div>
		<?php
	}


}
