<?php
$rtwwpcp_basic_active = '';
$rtwwpcp_header_active = '';
$rtwwpcp_footer_active = '';
$rtwwpcp_css_active = '';
$rtwwpcp_watermark_active = '';
$rtwwpcp_pdf_format_active = '';
$rtwwpcp_custom_fonts = get_option('rtwwpcp_custom_fonts', array());

include(RTWWPCP_DIR ."includes/mpdf/autoload.php");
$rtwwpcp_mpdf = new \Mpdf\Mpdf();
$rtwwpcp_merge_font = array();
if( !empty( $rtwwpcp_custom_fonts ) ) 
{
	foreach( $rtwwpcp_custom_fonts as $key=> $value )
	{
		$rtwwpcp_merge_font[$key] = $key;
	}
}
foreach ($rtwwpcp_mpdf->fontdata as $rtwwpcp_key=> $rtwwpcp_value)
{
	$rtwwpcp_mpdf_font[$rtwwpcp_key] = $rtwwpcp_key;
}
$rtwwpcp_fonts = array_merge( $rtwwpcp_mpdf_font, $rtwwpcp_merge_font );
if (isset($_GET['rtwwpcp_tab'])) 
{
	if ($_GET['rtwwpcp_tab'] == "rtwwpcp_basic") 
	{
		$rtwwpcp_basic_active = "nav-tab-active";
	}
	if($_GET['rtwwpcp_tab'] == "rtwwpcp_header")
	{
		$rtwwpcp_header_active = "nav-tab-active";
	}
	elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_footer") 
	{
		$rtwwpcp_footer_active = "nav-tab-active";
	}
	elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_css") 
	{
		$rtwwpcp_css_active = "nav-tab-active";
	}
	elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_watermark") 
	{
		$rtwwpcp_watermark_active = "nav-tab-active";
	}
	elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_pdf_formatt") 
	{
		$rtwwpcp_pdf_format_active = "nav-tab-active";
	}
}
else
{
	$rtwwpcp_basic_active = "nav-tab-active";
} 
?>
<div class="main-wrapper">
	<div class="rtwwpcp_admin_wrapper">
		<h2 class="rtw-main-heading"><span class="dashicons dashicons-admin-generic"></span><?php esc_html_e('WooCommerce PDF Catalog Pro','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			<span style="float: right;">[rtwwpcp_catalog_shortcode]</span><br>
			<span style="float: right;">[rtwwpcp_product_shortcode]</span>
		</h2>
		<nav class="<?php echo esc_attr( 'rtw-navigation-wrapper nav-tab-wrapper' ); ?>">
			<a class="<?php echo esc_attr( 'nav-tab' ); ?> <?php echo  esc_attr($rtwwpcp_basic_active);?>" href="<?php echo esc_url(get_admin_url().'admin.php?page=rtwwpcp_pdf_settings&rtwwpcp_tab=rtwwpcp_basic');?>">
				<div class="rtwwpcp_tab_icon">
					<img src="<?php echo esc_url( RTWWPCP_URL.'assets/basic.png' ); ?>" alt="">
				</div>
				<?php esc_html_e('Basic Setting','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			</a>
			<a class="<?php echo esc_attr( 'nav-tab' ); ?> <?php echo  esc_attr($rtwwpcp_header_active);?>" href="<?php echo esc_url(get_admin_url().'admin.php?page=rtwwpcp_pdf_settings&rtwwpcp_tab=rtwwpcp_header');?>">
				<div class="rtwwpcp_tab_icon">
					<img src="<?php echo esc_url( RTWWPCP_URL.'assets/header.png' ); ?>" alt="">
				</div>
				<?php esc_html_e('Header Setting','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			</a>
			<a class="<?php echo esc_attr( 'nav-tab' ); ?> <?php echo  esc_attr($rtwwpcp_footer_active);?>" href="<?php echo esc_url(get_admin_url().'admin.php?page=rtwwpcp_pdf_settings&rtwwpcp_tab=rtwwpcp_footer');?>">
				<div class="rtwwpcp_tab_icon">
					<img src="<?php echo esc_url( RTWWPCP_URL.'assets/footer.png' ); ?>" alt="">
				</div>
				<?php esc_html_e('Footer Setting','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			</a>
			<a class="<?php echo esc_attr( 'nav-tab' ); ?> <?php echo  esc_attr($rtwwpcp_css_active);?>" href="<?php echo esc_url(get_admin_url().'admin.php?page=rtwwpcp_pdf_settings&rtwwpcp_tab=rtwwpcp_css');?>">
				<div class="rtwwpcp_tab_icon">
					<img src="<?php echo esc_url( RTWWPCP_URL.'assets/css.png' ); ?>" alt="">
				</div>
				<?php esc_html_e('CSS Setting','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			</a>
			<a class="<?php echo esc_attr( 'nav-tab' ); ?> <?php echo  esc_attr($rtwwpcp_watermark_active);?>" href="<?php echo esc_url(get_admin_url().'admin.php?page=rtwwpcp_pdf_settings&rtwwpcp_tab=rtwwpcp_watermark');?>">
				<div class="rtwwpcp_tab_icon">
					<img src="<?php echo esc_url( RTWWPCP_URL.'assets/watermark.png' ); ?>" alt="">
				</div>
				<?php esc_html_e('Watermark Setting','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			</a>
			<a class="<?php echo esc_attr( 'nav-tab' ); ?> <?php echo  esc_attr($rtwwpcp_pdf_format_active);?>" href="<?php echo esc_url(get_admin_url().'admin.php?page=rtwwpcp_pdf_settings&rtwwpcp_tab=rtwwpcp_pdf_formatt');?>">
				<div class="rtwwpcp_tab_icon">
					<img src="<?php echo esc_url( RTWWPCP_URL.'assets/watermark.png' ); ?>" alt="">
				</div>
				<?php esc_html_e('PDF Formatt Setting','rtwwpcp-woocommerce-pdf-catalog-pro');?>
			</a>
		</nav>
		<?php 
			settings_errors();
		?>
		<form enctype="multipart/form-data" action="options.php"  method="post">
			<?php
				if(isset($_GET['rtwwpcp_tab']))
				{
					if($_GET['rtwwpcp_tab'] == "rtwwpcp_basic")
					{
						include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_basic.php');
					}
					if($_GET['rtwwpcp_tab'] == "rtwwpcp_header")
					{
						include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_header.php');
					}
					elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_footer") 
					{
						include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_footer.php');
					}
					elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_css") 
					{
						include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_css.php');
					}
					elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_watermark") 
					{
						include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_watermark.php');
					}
					elseif ($_GET['rtwwpcp_tab'] == "rtwwpcp_pdf_formatt") 
					{
						include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_pdf_format.php');
					}
				}
				else
				{
					include_once(RTWWPCP_DIR.'/admin/partials/rtwwpcp_tabs/rtwwpcp_basic.php');
				}
			?>
			<p class="submit">
				<input type="submit" value="<?php esc_attr_e('Save changes','rtwwpcp-woocommerce-pdf-catalog-pro');?>" class="rtw-button" name="rtwwpcp_pdf_submit">
			</p>
		</form>
	</div>
</div>
