<?php
if (!defined('ABSPATH')) exit;

add_action('admin_init', 'flexyconsent_settings_dashboardPage');
function flexyconsent_settings_dashboardPage(){
	// global $flexyconsentSettings;
	// $pageNameMain = 'dashboardPage';
	// $pageName = flexyconsent_getPageName($pageNameMain);
	// $sectionName = flexyconsent_getSectionName($pageNameMain);
}

add_action( 'current_screen', 'flexyconsent_dashboardPage_before' );
function flexyconsent_dashboardPage_before(){
	global $flexyconsent_menu_title;
	if (get_current_screen()->base == sanitize_title($flexyconsent_menu_title) . '_page_flexyconsent-dashboardPage') {
		wp_enqueue_script('moment');
    	wp_enqueue_script('daterangepicker', plugins_url('../plugins/daterangepicker/daterangepicker.min.js', __FILE__ ), array('jquery', 'moment'), '3.1', true);
		wp_enqueue_style('daterangepicker', plugins_url('../plugins/daterangepicker/daterangepicker.css', __FILE__ ), array(), '3.1');
	} 
}

function flexyconsent_dashboardPage()
{
	$pageNameMain = 'dashboardPage'; ?>
	<div class="container py-3">
		<div class="row">
			<div class="col-12 text-center">
				<?php flexyconsent_get_top_section(); ?>
			</div>
			<div id="<?php echo esc_attr($pageNameMain); ?>">
				<div class="content-wrapper">
					<div class="container-xxl flex-grow-1 container-p-y">
						<div class="row px-1 my-2">
							<div class="col-xl-4 col-lg-5 col-md-6 col-sm-7">
								<div id="date_range_picker" class="d-flex align-items-center">
									<i class="fa-regular fa-calendar me-1"></i>&nbsp;
									<span class="flex-fill"></span>
									<i class="fa-solid fa-angle-down"></i>
								</div>
							</div>
						</div>

						<div class="row">
							<div id="flexyconsent_stats" class="col-md-12">
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="col-12 mt-3">
				<div class="d-flex justify-content-center flex-wrap">
					<a href="<?php echo esc_url(flexyconsent_generateGoPage('projectSettingsPage')); ?>" class="mx-3 button button-primary"><?php esc_html_e("Website Settings", "flexyconsent"); ?></a>
					<a href="<?php echo esc_url(flexyconsent_generateGoPage('userSettingsPage')); ?>" class="mx-3 button button-primary"><?php esc_html_e("User Settings", "flexyconsent"); ?></a>
					<a href="<?php echo esc_url(flexyconsent_generateGoPage('cookieManagerPage')); ?>" class="mx-3 button button-primary"><?php esc_html_e("Cookie Manager", "flexyconsent"); ?></a>
					<a href="<?php echo esc_url(flexyconsent_generateGoPage('subscriptionPage')); ?>" class="mx-3 button button-primary"><?php esc_html_e("Subscription", "flexyconsent"); ?></a>
				</div>
			</div>
			<div class="col-12 text-center">
				<?php flexyconsent_get_bottom_section(); ?>
			</div>
		</div>
	</div>
<?php
}
