<?php

namespace EverAccounting\Admin;

defined( 'ABSPATH' ) || exit;

/**
 * Notices class.
 *
 * @since 2.1.9
 * @package EverAccounting\Admin\Notices
 */
class Notices {

	/**
	 * Notices constructor.
	 *
	 * @since 1.0.0
	 */
	public function __construct() {
		add_action( 'admin_init', array( $this, 'admin_notices' ) );
	}

	/**
	 * Admin notices.
	 *
	 * @since 1.0.0
	 */
	public function admin_notices() {
		$installed_time = absint( get_option( 'eac_install_date' ) );
		$current_time   = absint( wp_date( 'U' ) );

		// TODO: Uncomment the below code when Black Friday offer is ended.
		$black_friday_end_time = strtotime( '2025-12-05 00:00:00' );
		if ( $current_time < $black_friday_end_time ) {
			EAC()->notices->add(
				array(
					'message'     => __DIR__ . '/views/notices/black-friday.php',
					'dismissible' => false,
					'notice_id'   => 'eac_black-friday_promo_2025',
					'style'       => 'border-left-color: #000000;',
					'class'       => 'notice-black-friday',
				)
			);
		}

		// Show after 5 days.
		if ( $installed_time && $current_time > ( $installed_time + ( 5 * DAY_IN_SECONDS ) ) ) {
			EAC()->notices->add(
				array(
					'message'     => __DIR__ . '/views/notices/review.php',
					'dismissible' => false,
					'notice_id'   => 'eac_review',
					'style'       => 'border-left-color: #77B82E;',
				)
			);
		}
	}
}
