<?php
global $redux_demo;
$planOneC = $redux_demo['plan-one-color'];
$planTwoC = $redux_demo['plan-two-color'];
$planThreeC = $redux_demo['plan-three-color'];
global $paged, $wp_query, $wp;
$args = wp_parse_args($wp->matched_query);
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('post_type=price_plan&posts_per_page=-1');
$current = -1;
$current2 = 0;
$Myh1= "";
?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); $current++; $current2++; ?>
<?php $popular_plan = get_post_meta($post->ID, 'popular_plan', true); ?>
<div class="large-4 medium-6 large-uncentered medium-centered columns priceTable <?php if($popular_plan == 'true'){echo 'popular-plan'; } ?>">

<?php if($current < 3){?>
	<div class="pricePlan">
<style scoped>
	#pricingPlan .priceTable:nth-of-type(<?php echo $current+1; ?>) .pricePlan{
		border-top: 2px solid <?php if($current == 0){echo $planOneC;}elseif($current == 1){echo $planTwoC;}elseif($current == 2){echo $planThreeC;} ?>;		
	}
	#pricingPlan .priceTable:nth-of-type(<?php echo $current+1; ?>) .pricePlan .price p:nth-of-type(1){
		color:<?php if($current == 0){echo $planOneC;}elseif($current == 1){echo $planTwoC;}elseif($current == 2){echo $planThreeC;} ?>;
	}
	#pricingPlan .priceTable:nth-of-type(<?php echo $current+1; ?>) .pricePlan ul.description li i{
		color:<?php if($current == 0){echo $planOneC;}elseif($current == 1){echo $planTwoC;}elseif($current == 2){echo $planThreeC;} ?>;
	}
	#pricingPlan .priceTable:nth-of-type(<?php echo $current+1; ?>) .pricePlan > form button:hover{
		background:<?php if($current == 0){echo $planOneC;}elseif($current == 1){echo $planTwoC;}elseif($current == 2){echo $planThreeC;} ?> !important;
	}
	#pricingPlan .priceTable:nth-of-type(<?php echo $current+1; ?>):hover .pricePlan{
		border: 2px solid <?php if($current == 0){echo $planOneC;}elseif($current == 1){echo $planTwoC;}elseif($current == 2){echo $planThreeC;} ?>;
		border-bottom: 5px solid <?php if($current == 0){echo $planOneC;}elseif($current == 1){echo $planTwoC;}elseif($current == 2){echo $planThreeC;} ?>;
	}
</style>
	<!--End Featured Plans Title -->
		<div class="title">
			<?php 
				$Myh1= $current+1;
			?>
			<h1>0<?php echo $Myh1; ?></h1>
			<h3><?php the_title(); ?></h3>
		</div><!--End Title Div-->
		<div class="price">
			<?php /* Get Price Data*/
			$post_price = get_post_meta($post->ID, 'plan_price', true);
			$plan_text = get_post_meta($post->ID, 'plan_text', true);
			$plan_days = get_post_meta($post->ID, 'plan_time', true);
			$planFeaturedTXT = get_post_meta($post->ID, 'plan_free_text', true);
			$planSecureTXT = get_post_meta($post->ID, 'plan_secure_text', true);
			global $redux_demo;
			$currency_code = $redux_demo['currency_code']; 
				if($currency_code == "USD") {
						$currCode = "$";
					} elseif($currency_code == "AUD") {
						$currCode = "A$";
					} elseif($currency_code == "CAD") {
						$currCode = "$";
					} elseif($currency_code == "CZK") {
						$currCode = "Kč";
					} elseif($currency_code == "DKK") {
						$currCode = "kr";
					} elseif($currency_code == "EUR") {
						$currCode = "€";
					} elseif($currency_code == "HKD") {
						$currCode = "$";
					} elseif($currency_code == "HUF") {
						$currCode = "Ft";
					} elseif($currency_code == "JPY") {
						$currCode = "¥";
					} elseif($currency_code == "NOK") {
						$currCode = "kr";
					} elseif($currency_code == "NZD") {
						$currCode = "$";
					} elseif($currency_code == "PLN") {
						$currCode = "zł";
					} elseif($currency_code == "GBP") {
						$currCode = "£";
					} elseif($currency_code == "SEK") {
						$currCode = "kr";
					} elseif($currency_code == "SGD") {
						$currCode = "S$";
					} elseif($currency_code == "CHF") {
						$currCode = "CHF";
					}elseif($currency_code == "BRL") {
						$currCode = "R$";
					}elseif($currency_code == "ILS") {
						$currCode = "ILS";
					}elseif($currency_code == "MYR") {
						$currCode = "RM";
					}elseif($currency_code == "MXN") {
						$currCode = "$";
					}elseif($currency_code == "PHP") {
						$currCode = "₱";
					}elseif($currency_code == "TWD") {
						$currCode = "NT$";
					}elseif($currency_code == "THB") {
						$currCode = "฿";
					}elseif($currency_code == "TRY") {
						$currCode = "TRY";
					}
				
			?>
			<p><?php echo $currCode.$post_price; ?> <span>/<?php echo $plan_days; ?><?php esc_html_e('D', 'classiera') ?></span></p>
			<p><?php echo $plan_text; ?></p>
		</div><!--End Price Div-->
		<ul class="description">
		<?php $plan_featured_ads = get_post_meta($post->ID, 'featured_ads', true); ?>
		<?php if(!empty($planFeaturedTXT)){?>
			<li><i class="fa fa-check-square"></i><?php echo $planFeaturedTXT; ?></li>
		<?php } ?>	
			<li><i class="fa fa-check-square"></i><?php echo $plan_featured_ads ?>&nbsp;<?php esc_html_e( 'Featured ads availability', 'classiera' ); ?></li>
			<li><i class="fa fa-check-square"></i><?php esc_html_e( 'For', 'classiera' ); ?>&nbsp;<?php echo $plan_days ?>&nbsp;<?php esc_html_e( 'days', 'classiera' ); ?></li>
		<?php if(!empty($planSecureTXT)){?>	
			<li><i class="fa fa-check-square"></i><?php echo $planSecureTXT; ?></li>
		<?php } ?>		
		</ul>


<?php
if ( !is_user_logged_in() ) { 
	global $redux_demo;
	$login = $redux_demo['login'];
	$redirect =	$login;
}else{
	$redirect = get_template_directory_uri().'/paypal/form-handler.php?func=addrow';									}
?>
	<form method="post" action="<?php echo $redirect; ?>">
		<input type="hidden" name="AMT" value="<?php echo $post_price; ?>" />
		<input type="hidden" name="PAYMENTREQUEST_0_DESC" value="<?php the_title(); ?>" />
		<?php global $redux_demo; $currency_code = $redux_demo['currency_code']; ?>
		<input type="hidden" name="CURRENCYCODE" value="<?php echo $currency_code; ?>">

		<?php $planID = uniqid(); ?>
		<input type="hidden" name="PAYMENTREQUEST_0_CUSTOM" value="<?php echo $planID; ?>">

		<input type="hidden" name="user_ID" value="<?php echo $user_ID; ?>">

		<input type="hidden" name="plan_name" value="<?php the_title(); ?>">

		<?php $plan_ads = get_post_meta($post->ID, 'featured_ads', true); ?>
		<input type="hidden" name="plan_ads" value="<?php echo $plan_ads; ?>">

		<input type="hidden" name="plan_price" value="<?php echo $post_price; ?>">

		<?php $plan_time = get_post_meta($post->ID, 'plan_time', true); ?>
		<input type="hidden" name="plan_time" value="<?php echo $plan_time; ?>">

		<?php $date = date('d/m/Y H:i:s'); ?>
		<input type="hidden" name="date" value="<?php echo $date; ?>">

		<input type="hidden" name="url" value="<?php echo get_template_directory_uri(); ?>">

		<?php global $redux_demo; $paypal_success = $redux_demo['paypal_success']; $paypal_fail = $redux_demo['paypal_fail']; ?>
													  
		<?php if ( isset($paypal_success) ) { ?>
		<input type="hidden" name="RETURN_URL" value="<?php echo $paypal_success; ?>" />
		<?php } ?>
													  
		<?php if ( isset($paypal_fail) ) { ?>
		<input type="hidden" name="CANCEL_URL" value="<?php echo $paypal_fail; ?>" />
		<?php } ?>
													  
		<input type="hidden" name="func" value="start" />
		<?php if($current < 3){?>
		<button class="form-submit button round" name="op" value="Purchase Now" type="submit"><?php printf( __( 'Buy Now', 'classiera' )); ?></button>
		<?php }?>								
	</form>
	</div>
<?php }?>	
</div><!--End Main Col Div -->

<?php endwhile; ?>
<?php $wp_query = null; $wp_query = $temp;
?>
