<?php
/**
 * All Template facing functions
 */
namespace Codexpert\WC_Affiliate;

use Codexpert\Plugin\Base;

/**
 * If accessed directly, exit.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * @package Plugin
 * @subpackage Template
 * @author codexpert <hello@codexpert.io>
 */
class Template extends Base {

	public $plugin;

	public $slug;

	public $name;

	public $version;

	/**
	 * Constructor function
	 */
	public function __construct( $plugin ) {
		$this->plugin  = $plugin;
		$this->slug    = $this->plugin['TextDomain'];
		$this->name    = $this->plugin['Name'];
		$this->version = $this->plugin['Version'];
	}

	public function dashboard( $template = 'panel' ) {

		if ( $template === 'panel' ) {
			$template_path = 'views/front/shortcodes/dashboard';
		} else {
			$template_path = 'views/front/authenticate';
		}
		
		Helper::get_template( $template, $template_path, array( 'plugin' => $this->plugin ), false );
	}

	public function profile() {
		echo wp_kses_post( Helper::get_template( 'profile', 'views/front/shortcodes/dashboard', array( 'plugin' => $this->plugin ) ) );
	}

	public function navigation() {
		echo wp_kses_post( Helper::get_template( 'navigation', 'views/front/shortcodes/dashboard', array( 'plugin' => $this->plugin ) ) );
	}

	public function tab_content( $tab ) {		

		if(  $tab == 'coupons' ) {
			$tab_content = wp_kses_post( Helper::get_template( $tab, 'views/front/shortcodes/dashboard/tabs', array( 'plugin' => $this->plugin ) ) );
			echo wp_kses_post( apply_filters( 'wc-affiliate-shortcodes_dashboard_content', $tab_content, $tab ) );
			
		} else {
			Helper::get_template( $tab, 'views/front/shortcodes/dashboard/tabs', array( 'plugin' => $this->plugin ), null, false );
		}		
	}

	public function report() {
		echo wp_kses_post( Helper::get_template( 'report', 'views/admin/report', array( 'plugin' => $this->plugin ) ) );
	}

	public function review_user() {
		echo wp_kses_post( Helper::get_template( 'review-user', 'views/admin/user', array( 'plugin' => $this->plugin ) ) );
	}

	public function transaction_form() {
		echo wp_kses_post( Helper::get_template( 'transaction-form', 'views/admin/user', array( 'plugin' => $this->plugin ) ) );
	}

	public function new_affiliate_form() {
		echo wp_kses_post( Helper::get_template( 'new-affiliate-form', 'views/admin/user', array( 'plugin' => $this->plugin ) ) );
	}
}
