<?php defined('ABSPATH') or die('No Script Cuddies');
/*
Template Name: Página Inicial
*/
get_header();
$sobre=get_field('pagina');
$pagina_trabalhos=get_field('pagina_trabalhos');
$pagina_onde_trabalhei=get_field('pagina_onde_trabalhei');
$pagina_skills=get_field('pagina_habilidades');
?>
<div class="coloured-madness-cast">
	<div class="container">
		<div class="spacer-85"></div>
		<div class="cast-container">
			<div class="cast-tabs row">
				<div class="col-xs-12 col-md-6 col-lg-4 profile_img_container">
					<img src="<?=get_field('imagem_de_perfil',$sobre)['sizes']['thumbnail'];?>">
				</div>
				<div class="col-xs-12 col-md-6 col-lg-4">
					<strong><?=__('Name','portfolio_madness');?>:</strong> <?=get_field('nome_completo',$sobre);?>
				</div>
				<div class="col-xs-12 col-md-6 col-lg-4">
					<strong><?=__('Age / Birtday','portfolio_madness');?>:</strong>
					<?php 
					$aniversario=get_field('aniversario',$sobre);
					$na=explode('/',$aniversario);
					$_age = floor((time() - strtotime($na[2].'/'.$na[1].'/'.$na[0])) / 31556926);
					?> 
					<p><?=$_age;?> / <?=$aniversario;?></p>
				</div>
				<div class="col-xs-12 col-md-6 col-lg-4">
					<strong><?=__('Naturalness','portfolio_madness');?>: </strong> <?=get_field('naturalidade',$sobre)?>
				</div>
				<div class="col-xs-12 col-md-6 col-lg-4">
					<strong><?=__('Current Ocupation','portfolio_madness');?>:</strong> <?=get_field('ocupação',$sobre)?>
				</div>
				<div class="col-xs-12 col-md-6 col-lg-4">
					<strong><?=__('Civil Status','portfolio_madness');?>:</strong> <?=get_field('estado_civil',$sobre)?>
				</div>
			</div>
			<div class="cast-tabs row">
				<div class="col-xs-12">
					<h3 align="center"><?=__('Some of My Skills','portfolio_madness');?></h3>
				</div>
				<?php 
					$skills=get_posts(array(
						'post_type'=>'skill',
						'numberposts' => 3,
						'meta_query'=>array(
							array(
								'key'     => 'skill_level',
								'value'   => '70',
								'compare' => '>=',
								'type'    => 'NUMERIC',
							),
						),
						'order'=>'asc',
						'orderby'=>'rand',
						'suppress_filters' => false
					));
					if(!empty($skills)){
						foreach($skills as $skill){
								$style=get_field('cor_icone_css',$skill->ID)?'color:'.get_field('cor_icone_css',$skill->ID).';':'';
								$title=(get_field('nome_icone_css',$skill->ID)!='')?'<i class="'.get_field('nome_icone_css',$skill->ID).'"></i> - '.get_the_title($skill->ID):get_the_title($skill->ID);
								$skill_level=intval(get_field('skill_level',$skill->ID));
								if(($skill_level>0) && ($skill_level<=20)){
									$skill_name=__('Very Poor','portfolio_madness');
								}
								elseif(($skill_level>20) && ($skill_level<50)){
									$skill_name=__('Poor','portfolio_madness');
								}
								elseif(($skill_level>=50) && ($skill_level<70)){
									$skill_name=__('OK','portfolio_madness');
								}
								elseif(($skill_level>=70) && ($skill_level<90)){
									$skill_name=__('Good','portfolio_madness');
								}
								elseif(($skill_level>=90) && ($skill_level<100)){
									$skill_name=__('Very Good','portfolio_madness');
								}
								elseif(($skill_level=100)){
									$skill_name=__('Excelent','portfolio_madness');
								}
								?>
					<div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
						<div class="fac3-title-container" style="<?=$style;?>"><?=$title;?></div>
						<div class="fac3-slider-container">
							<div class="slide_value" style="width:<?=$skill_level;?>%;<?=($style!='')?'background-'.$style:'background-color:#353c48;';?>"></div>
							<div class="slide_upper_text">
								<?=$skill_name;?>
							</div>
						</div>
					</div><?php	}
					}
				?>
				<div class="col-xs-12 col-md-6 col-md-offset-3 col-lg-4 col-lg-offset-4">
					<?php 
					$the_pmlink=get_the_permalink($pagina_skills);
					ob_start();?>
					<a href="{the_pmlink}" class="button" homebutton="{the_pmlink}">
						<?=__('All My Skills','portfolio_madness')?>
					</a>
					<?php
					$menu=ob_get_clean();
					$the_surl=site_url();
					$the_link=str_replace($the_surl,'',$the_pmlink);
					$menu=str_replace('{the_pmlink}',$the_link,$menu);
					$menu=str_replace('href="/', 'href="', $menu);
					$menu=str_replace('/"', '"', $menu);
					$menu=str_replace('homebutton="/', 'homebutton="', $menu);
					$menu=str_replace('/"', '"', $menu);
					echo $menu;
					?>
				</div>
			</div>
			<div class="row">
				<!-- Start - Last Job -->
				<div class="col-xs-12 col-md-6">
					<?php
				$args=array('post_type'=>'job','posts_per_page'=>1);
				$wpq=new WP_Query($args); 
				if($wpq->have_posts()):
					while($wpq->have_posts()):
						$wpq->the_post();
						?>
						<div class="cast-tabs row no-margin-removal" data-cast-tab="<?=$t['term']['slug']?>" id="<?=$t['term']['slug']?>_cast" class="row">
							<div class="col-xs-12">
								<h3 align="center"><?=__('Last Job I\'ve Done','portfolio_madness');?></h3>
							</div>
							<div class="col-xs-12 col-md-6 profile_img_container">
								<img src="<?php the_post_thumbnail_url();?>" width="100%;">
								<?php if( is_user_logged_in()) {
									
									    edit_post_link(__('edit','portfolio_madness'), '', '');
									
									}?>
							</div>
							<div class="col-xs-12 col-md-6">
								<h4><?php the_title();?></h4>
								<hr>
								<?php the_content();?>
								<hr>
								<div class="">
									<a class="button" href="<?=get_field('link')['url']?>" target="_BLANK">
										<?=__('Go To','portfolio_madness');?>
									</a>
								</div>
							</div>
							<div class="col-xs-12">
								<div class="row">
									<?php 
									$the_pmlink=get_the_permalink($pagina_trabalhos);
									ob_start();?>
									<a href="{the_pmlink}" class="button" homebutton="{the_pmlink}">
										<?=__('View all','portfolio_madness')?>
									</a>
									<?php
									$menu=ob_get_clean();
									$the_surl=site_url();
									$the_link=str_replace($the_surl,'',$the_pmlink);
									$menu=str_replace('{the_pmlink}',$the_link,$menu);
									$menu=str_replace('href="/', 'href="', $menu);
									$menu=str_replace('/"', '"', $menu);
									$menu=str_replace('homebutton="/', 'homebutton="', $menu);
									$menu=str_replace('/"', '"', $menu);
									echo $menu;
									?>
								</div>
							</div>
						</div>
						<?php
					endwhile;
				endif;
				?>
				</div>
				<!-- END - Last Job -->
				<!-- Start - Last Place -->
				<div class="col-xs-12 col-md-6">
					<?php 
					$piw=new WP_Query(array('post_type'=>'place-i-worked','posts_per_page'=>1));
					if($piw->have_posts()){
						?>
					<div class="cast-tabs row no-margin-removal">
						<?php
						while($piw->have_posts()){
							$piw->the_post();
							?>
						<div class="col-xs-12">
							<h3 align="center"><?=__('Last Place I\'ve Worked','portfolio_madness');?></h3>
						</div>
						<div class="col-xs-12">
							<div class="row">
								<h3><?php the_title();?></h3>
								<p><?=get_field('cargo');?> - <?=get_field('tipo_de_trabalho');?></p>
								<p><?=__('From','portfolio_madness');?>: <?=get_field('data_de_inicio');?> <?=__('To','portfolio_madness');?>: <?=get_field('data_de_fim');?></p>
							</div>
						</div>
							<?php
						}
						?>
						<div class="col-xs-12">
							<div class="row">
									<?php 
									$the_pmlink=get_the_permalink($pagina_onde_trabalhei);
									ob_start();?>
									<a href="{the_pmlink}" class="button" homebutton="{the_pmlink}">
										<?=__('View all','portfolio_madness')?>
									</a>
									<?php
									$menu=ob_get_clean();
									$the_surl=site_url();
									$the_link=str_replace($the_surl,'',$the_pmlink);
									$menu=str_replace('{the_pmlink}',$the_link,$menu);
									$menu=str_replace('href="/', 'href="', $menu);
									$menu=str_replace('/"', '"', $menu);
									$menu=str_replace('homebutton="/', 'homebutton="', $menu);
									$menu=str_replace('/"', '"', $menu);
									echo $menu;
									?>
							</div>
						</div>
					</div><?php
					}
					?>
				</div>
				<!-- END - Last Place -->
			</div>
		</div>
	</div>
</div>
<?php
get_footer();

