<?php
/**
 * Class VOIDEMPO_Assets
 *
 * Handles enqueuing of frontend scripts and styles.
 *
 * @package voidempo
 */
class VOIDEMPO_Assets {
	/**
	 * Constructor for the VOIDEMPO_Assets class.
	 * Initializes hooks to enqueue frontend assets.
	 */
	public function __construct() {
		
		add_action( 'wp_enqueue_scripts', array( $this, 'voidempo_enqueue_frontend_styles' ) );
	}

	/**
	 * Enqueues frontend CSS and JavaScript files.
	 *
	 * @return void
	 */
	public function voidempo_enqueue_frontend_styles() {

		// Enqueue Bootstrap CSS.
		if ( is_page('user-dashboard') ) {

			wp_enqueue_style( 'fd-font-awesome', VOIDEMPO_PLUGIN_URL . 'assets/css/font-awesome.css', array() );
			wp_enqueue_style( 'daterange_css', VOIDEMPO_PLUGIN_URL . 'assets/css/daterangepicker.css' );
			wp_enqueue_style( 'voidempo_dt_css', VOIDEMPO_PLUGIN_URL . 'assets/css/jquery.dataTables.css' );
			wp_enqueue_style( 'bootstrap-css', VOIDEMPO_PLUGIN_URL . 'assets/css/bootstrap_min.css', array(), '5.3.0' );
			wp_enqueue_style( 'fd-custom-style', VOIDEMPO_PLUGIN_URL . 'assets/css/style.css', array( 'bootstrap-css' ), null );
			wp_enqueue_style( 'voidempo_sweetalert_css', VOIDEMPO_PLUGIN_URL . 'assets/css/sweetalert.css' );
			wp_enqueue_style( 'voidempo_timepicker_addon_css', VOIDEMPO_PLUGIN_URL . 'assets/css/timepicker_addons.css' );
			wp_enqueue_style( 'voidempo_bootstrap_button_css', VOIDEMPO_PLUGIN_URL . 'assets/css/buttons.dataTables.min.css' );
			wp_enqueue_style( 'jquery-ui-css', VOIDEMPO_PLUGIN_URL . 'assets/css/jquery-ui.min.css', array(), '1.12.1' );
			wp_enqueue_style( 'select2-css', VOIDEMPO_PLUGIN_URL . 'assets/css/select2_min.css', array(), null );

			// Enqueue required JS files.

			wp_enqueue_script( 'jquery' );
			wp_enqueue_script( 'jquery-ui-datepicker' );
			wp_enqueue_script( 'moment' );
			wp_enqueue_script( 'fullcalendar-js', VOIDEMPO_PLUGIN_URL . 'assets/js/index.global.min.js', array(), '6.1.19', true );
			wp_enqueue_script( 'bootstrap-js', VOIDEMPO_PLUGIN_URL . 'assets/js/bootstrap.bundle.min.js', array( 'jquery' ), '5.3.0', true );
			wp_enqueue_script( 'voidempo_bootstrap_datatable_js', VOIDEMPO_PLUGIN_URL . 'assets/js/datatable.js', array( 'jquery' ), null, true );
			wp_enqueue_script( 'voidempo_bootstrap_buttonmin_js', VOIDEMPO_PLUGIN_URL . 'assets/js/dataTables.buttons.min.js', array( 'jquery', 'voidempo_bootstrap_datatable_js' ), '3.2.4', true );
			wp_enqueue_script( 'jszip', VOIDEMPO_PLUGIN_URL . 'assets/js/jszip.min.js', array(), '3.10.1', true );
			wp_enqueue_script( 'voidempo_bootstrap_html_js', VOIDEMPO_PLUGIN_URL . 'assets/js/buttons.html5.min.js', array( 'jquery', 'voidempo_bootstrap_buttonmin_js', 'jszip' ), true );
			wp_enqueue_script( 'select2-js', VOIDEMPO_PLUGIN_URL . 'assets/js/select2.min.js', array( 'jquery' ), null, true );
			wp_enqueue_script( 'voidempo_jquery_ui_js', VOIDEMPO_PLUGIN_URL . 'assets/js/jquery_ui.js', true );
			wp_enqueue_script( 'voidempo_timepicker_addon_js', VOIDEMPO_PLUGIN_URL . 'assets/js/timepicker_addons.js', true );
			wp_enqueue_script( 'daterange_js', VOIDEMPO_PLUGIN_URL . 'assets/js/daterangepicker-min.js', array( 'jquery' ), null, true );
			wp_enqueue_script( 'eod-script', VOIDEMPO_PLUGIN_URL . 'assets/js/eod.js', array( 'jquery', 'fullcalendar-js' ), null, true );
			wp_enqueue_script( 'voidempo_boostrap_js', VOIDEMPO_PLUGIN_URL . 'assets/js/bootstrap.min.js', true );
			wp_enqueue_script( 'voidempo_sweetalert_js', VOIDEMPO_PLUGIN_URL . 'assets/js/sweetalert.min.js', true );
			wp_enqueue_script(
				'voidempo_details_js',
				VOIDEMPO_PLUGIN_URL . 'assets/js/details.js',
				array( 'jquery' ),
				null,
				true
			);
		
			wp_enqueue_script(
				'voidempo_sidebar_toggle',
				VOIDEMPO_PLUGIN_URL . 'assets/js/sidebar-toggle.js',
				array( 'jquery' ),
				null,
				true
			);

		$localized_data = array(
			'ajaxurl'        => admin_url( 'admin-ajax.php' ),
			'VOIDEMPO_nonce' => wp_create_nonce( 'voidempo_dashboard_nonce' ),
			'dashboard_base' => get_site_url() . '/user-dashboard/',
			'login_url'      => wp_login_url(),
			'page_styles'    => array(
				'voidempo_create_task' => VOIDEMPO_PLUGIN_URL . '/assets/css/create_task.css',
				'dashboard'            => VOIDEMPO_PLUGIN_URL . '/assets/css/dashboard.css',
			),
		);

		$localized_data = apply_filters( 'voidempo_localized_js_data', $localized_data );

		wp_localize_script( 'eod-script', 'voidempo_path', $localized_data );

		if ( current_user_can( 'manage_options' )  || current_user_can( 'voidempo_manager_access' ) ||  current_user_can( 'voidempo_employee_access' )   ) {
			wp_localize_script(
				'voidempo_details_js',
				'manager_path',
				[
					'manager_ajax_nonce'   => wp_create_nonce('manager_ajax_nonce'),
					'manager_ajaxurl' => admin_url('admin-ajax.php'),
				]
			);
		}
	
	}
	}
}
