<?php if (!empty($data['custom_css'])):?>
	<style><?php echo $data['custom_css'];?></style>
<?php endif;?>

<link href='<?php echo IHC_URL . 'assets/css/croppic.css';?>' rel='stylesheet' type='text/css' />

<script src="<?php echo IHC_URL . 'assets/js/jquery.mousewheel.min.js';?>"></script>
<script src="<?php echo IHC_URL . 'assets/js/croppic.js';?>"></script>
<script src="<?php echo IHC_URL . 'assets/js/account_page-banner.js';?>"></script>
<script>
IhcAccountPageBanner.init({
		triggerId					: 'js_ihc_edit_top_ap_banner',
		saveImageTarget		: '<?php echo IHC_URL . 'public/ajax-upload.php';?>',
		cropImageTarget   : '<?php echo IHC_URL . 'public/ajax-upload.php';?>',
		bannerClass       : 'ihc-user-page-top-ap-background'
});
</script>
<div class="ihc-account-page-wrapp" id="ihc_account_page_wrapp">

	<?php
		$top_style='';
		if (empty($this->settings['ihc_ap_edit_background']) && ($this->settings['ihc_ap_top_template'] == 'ihc-ap-top-theme-2' || $this->settings['ihc_ap_top_template'] == 'ihc-ap-top-theme-3' )){
			$top_style .='style="padding-top:75px;"';
		}
	?>

		<div class="ihc-user-page-top-ap-wrapper <?php echo (!empty($this->settings['ihc_ap_top_template']) ? $this->settings['ihc_ap_top_template'] : '');?>" <?php echo $top_style;?> >

		  	<div class="ihc-left-side">
				<div class="ihc-user-page-details">
					<?php if (!empty($data['avatar'])):?>
						<div class="ihc-user-page-avatar"><img src="<?php echo $data['avatar'];?>" class="ihc-member-photo"/></div>
					<?php endif;?>
				</div>
			</div>

			<div class="ihc-middle-side">
				<div class="ihc-account-page-top-mess">
                <?php if ($this->settings['ihc_ap_top_template'] == 'ihc-ap-top-theme-4' ){ ?>
                	<div class="iump-user-page-name"><?php echo $first_name . ' ' . $last_name;?></div>
                <?php } ?>
                   <div class="ihc-account-page-top-extra-mess">
					<?php if (!empty($data['welcome_message'])):?>
						<?php echo do_shortcode($data['welcome_message']);?>
					<?php else:?>
						<div class="iump-user-page-mess"><?php echo __('Welcome', 'ihc');?>,</div>
						<div class="iump-user-page-mess"><?php echo $first_name . ' ' . $last_name;?></div>
						<div class="iump-user-page-email"><?php echo $this->current_user->user_email;?></div>
					<?php endif;?>
                    </div>
				</div>
				<?php if (!empty($data['levels'])):?>
					<div class="ihc-top-levels">
						<?php foreach ($data['levels'] as $lid => $level):?>
							<?php
							
				    			$time_arr = ihc_get_start_expire_date_for_user_level($this->current_user->ID, $lid);
						    	$is_expired_class = '';
						    	
						    	
								if (isset($time_arr['expire_time']) && time()>strtotime( $time_arr['expire_time'] ) ){
						    		$is_expired_class = 'ihc-expired-level';
						    	}
							?>
							<?php if (!empty($data['badges_metas']['ihc_badges_on']) && !empty($level['badge_image_url'])):?>
								<div class="iump-badge-wrapper <?php echo $is_expired_class;?>"><img src="<?php echo $level['badge_image_url'];?>" class="iump-badge" title="<?php echo $level['label'];?>" /></div>
							<?php elseif (!empty($level['label'])):?>
								<div class="ihc-top-level-box <?php echo $is_expired_class;?>">
								<?php
								echo $level['label'];?></div>
							<?php endif;?>
						<?php endforeach;?>
					</div>
				<?php endif;?>
				<?php if (!empty($data['sm'])):?>
					<div class="ihc-ap-top-sm">
						<?php echo $data['sm'];?>
					</div>
				<?php endif;?>
			</div>

			<div class="ihc-clear"></div>
				<?php
					if (!empty($this->settings['ihc_ap_edit_background'])):
						$bk_style = '';
						$banner = '';
						if (!empty($this->settings['ihc_ap_top_background_image'])):
								$banner = $this->settings['ihc_ap_top_background_image'];
						endif;
						if (!empty($data ['top_banner'])):
							$banner = $data ['top_banner'];
						endif;
						if (!empty($banner)){
								$bk_style = 'style="background-image:url('.$banner.');"';
						}
			 	?>
            <div class="ihc-background-overlay"></div>
				  	<div class="ihc-user-page-top-ap-background" <?php echo $bk_style;?> data-banner="<?php echo $banner;?>" >
								
						</div>
                    <div class="ihc-edit-top-ap-banner" id="js_ihc_edit_top_ap_banner"></div>    
		  <?php endif;?>

		</div>
		<div class="ihc-user-page-content-wrapper  <?php echo @$this->settings['ihc_ap_theme'];?>">
		    
<!-- Settings for Membership Expiry Date -->

<?php
 function expire_date_function(){
 	global $wpdb;
	$table_name = $wpdb->prefix. "ihc_user_levels";
	$current_user = wp_get_current_user();
	$tbs = $wpdb->get_results("SELECT * FROM $table_name WHERE `user_id` = '$current_user->ID' ");
 	foreach($tbs as $tbp){
 	$memb_start= $tbp->start_time;
	$memb_expire = $tbp->expire_time;
    $currDate = Date("D d F Y / g i A");
	$start_time = date("D d F Y / g i A", strtotime($memb_start)); 
	$expire_time = date("D d F Y / g i A", strtotime($memb_expire)); 
	
	if(Date("Y") >= Date("Y",strtotime($memb_expire))){
	   if(Date("n") >= Date("n",strtotime($memb_expire))){
	      if(Date("j") >= Date("j",strtotime($memb_expire))){
	          $difference = Date("j") - Date("j",strtotime($memb_expire));

	         ?>
	         
	         
	          <script>
	                
	                  alert("Your Account has been expired, Please visit membership page to renew your account.");
	              </script>
	         
	         <?php
	      
	         
	          }
	      }
	   }
	}
	
	
	?>
	<script>

	 var start_date = "<?php echo $start_time; ?>";
	    var expiry_date = "<?php echo $expire_time; ?>";
	   
	  document.getElementById('memb_start_date').innerHTML = "Membership Starts On: " +  start_date;
	  document.getElementById('memb_expiry_date').innerHTML = "Membership Expires On: " +  expiry_date;
	    
	 
	</script>
	
	<?php

 }
 
 expire_date_function();