<?php
/*
 * The template for displaying the Season Cards
 *
 * This is the template that displays the Season Card.
 * This template over-rides index.php.
 *
 * @package IRIS WebPortal Seasonal cards Version 2.0
 *
 */
?>
<?php check_card_status()  ?>
<?php

global $season_name;
global $dec_month;
global $iris_db;
global $wpdb;
//if ( !has_card() ) {
//		wp_update_post( array( 'post_title' => 'Card', 'post_status' => 'draft' ) );
//	}
$irisdefault=$iris_db->get_row( "select * from seasoncards where active='1'" );
        if(isset($irisdefault->start_date)){$sdate = strtotime($irisdefault->start_date);
        if(isset($irisdefault->end_date)){$edate = strtotime($irisdefault->end_date);
        $currtime = strtotime("now");
        if( $currtime >= $sdate && $currtime <= $edate ){
$mysite=$wpdb->get_row( "select * from ow_card_2022 where season='".$irisdefault->season."'" );
if(isset($mysite->card_image_name)){$image=site_url().'/wp-content/uploads/'.$mysite->card_image_name;}else{$image='https://seasoncards.irisopenwebsite.co.uk/seasoncards/'.$irisdefault->card_image_name;}
if(isset($mysite->season_wish)){$season_wish=$mysite->season_wish;}else{$season_wish=$irisdefault->season_wish;}
if(isset($mysite->greetings)){$greeting=$mysite->greetings;}else{$greeting=$irisdefault->greetings;}
if(isset($mysite->border_color)){$border=$mysite->border_color;}else{$border=$irisdefault->border_color;}
if(isset($mysite->swish_color)){$wishcolor=$mysite->swish_color;}else{$wishcolor=$irisdefault->swish_color;}
if(isset($mysite->sgreet_color)){$greetcolor=$mysite->sgreet_color;}else{$greetcolor=$irisdefault->sgreet_color;}
if(isset($mysite->logo_bgcolor)){$logobg=$mysite->logo_bgcolor;}else{$logobg=$irisdefault->logo_bgcolor;}
if(isset($mysite->footbg_color)){$footbg=$mysite->footbg_color;}else{$footbg=$irisdefault->footbg_color;}
if(isset($mysite->cedit_color)){$ceditcolor=$mysite->cedit_color;}else{$ceditcolor=$irisdefault->cedit_color;}
if(isset($mysite->cardbg_color)){$cardbgcolor=$mysite->cardbg_color;}else{$cardbgcolor=$irisdefault->cardbg_color;}
if(isset($mysite->client_content)){$clientcontent=$mysite->season_wish;}else{$clientcontent='';}

?>
<?php
$template=$iris_db->get_row( "SELECT * FROM seasoncards_template" );
echo $template->part1;
echo $border;
echo '; background-color:'.$cardbgcolor;
echo $template->part2;
echo $image;
echo $template->part3;
echo $wishcolor;
echo $template->part4;
echo $season_wish;
echo $template->part5;
echo $greetcolor;
echo $template->part6;
echo $greeting;
echo $template->part7;
echo $logobg;
echo $template->part8;
echo the_logo( 'logo.png', array( 'id' => 'cardlogo', 'class' => '' )); 
echo $template->part9;
echo $ceditcolor;
echo $template->part10;
echo $clientcontent;
echo $template->part11;
echo $template->part12;
echo $footbg;
echo $template->part13;
echo date('Y').'. '.ow_global_var('accountant_name');
echo $template->part14;
echo $template->part15;
echo get_address(', ');
echo $template->part16;
echo ow_global_var('accountant_name').' is a trading name of '.ow_global_var('accountant_full_name');

if ( ow_global_var( 'accountant_reg' ) != NULL ) {
	echo '<p style="padding: 0;margin: 0 0 5px 0;">' . ow_global_var( 'accountant_reg' ) . ', Registered in England and Wales' . '</p>';
} 
echo $template->part17;
			
?>
<?php }elseif($currtime > $edate ){?>
<style>body{padding:0px;margin:0px;}</style>
<title>IRIS WebPortal Seasonal Card</title>
<div class="unavailable" style="background: #1c2b39; width: 100%; margin: 0 auto; text-align: center; padding:0px;height:100vh;">
	<img src="../wp-content/plugins/ow-plugin/img/iris-webportal-logo-white.svg" alt="IRIS WHITE LOGO" id="iris-white-logo" style=" display: block;margin: 0 auto; height: 150px;"/>
	<img width="auto" height="300"  src="../wp-content/plugins/ow-plugin/img/season-card-icon.svg" alt="Season Card Cross Icon" id="card-icon"/>
	<h2 style="font-size: 66px;    color: #52b8e8;    font-weight: 500;    margin: 0 0 5px 0;">Oops, sorry!</h2><h4 style="font-size: 36px;    font-weight: 400;    color: #fff;">The Season Card is currently unavailable.</h4>
	<a href="<?php echo site_url(); ?>" style="text-align:center;padding:0 0 10px 0;text-decoration:underline; font-size:16px; display:inline-block;color: #b3c4ff;font-weight:500;">Back to home</a>
</div>  
			<?php }}}else{?>
<style>body{padding:0px;margin:0px;}</style>
<title>IRIS WebPortal Seasonal Card</title>
<div class="unavailable" style="background: #1c2b39; width: 100%; margin: 0 auto; text-align: center; padding:0px;height:100vh;">
	<img src="../wp-content/plugins/ow-plugin/img/iris-webportal-logo-white.svg" alt="IRIS WHITE LOGO" id="iris-white-logo" style=" display: block;margin: 0 auto; height: 150px;"/>
	<img width="auto" height="300"  src="../wp-content/plugins/ow-plugin/img/season-card-icon.svg" alt="Season Card Cross Icon" id="card-icon"/>
	<h2 style="font-size: 66px;    color: #52b8e8;    font-weight: 500;    margin: 0 0 5px 0;">Oops, sorry!</h2><h4 style="font-size: 36px;    font-weight: 400;    color: #fff;">The Season Card is currently unavailable.</h4>
	<a href="<?php echo site_url(); ?>" style="text-align:center;padding:0 0 10px 0;text-decoration:underline; font-size:16px; display:inline-block;color: #b3c4ff;font-weight:500;">Back to home</a>
</div>  
			<?php } ?>
</body>
</html>    

       