<?php
/* Template Name: Homepage */
get_header();
?>

<div class="container homePage">
    <div class="row align">
        <div class="col-lg-8 accroche">
            <h1><?php echo get_field('accroche');?></h1>
        </div>
        <div class="col-lg-4">
            <div class="circleTop"></div>
        </div>
    </div>
    <div class="row align intro">
        <div class="col-lg-4">
            <div class='icone-rs'>
                <a target="_blank" href="https://www.facebook.com/deligraph/ "><i class="fab fa-facebook-square"></i></a>
                <a target="_blank" href="https://www.instagram.com/deligraph/"><i class="fab fa-instagram"></i></a>
                <!-- <a target="_blank" href="https://twitter.com/deligraph"><i class="fab fa-twitter"></i></a> -->
                <a target="_blank" href="https://be.linkedin.com/company/deligraph"><i class="fab fa-linkedin"></i></a>
            </div>
        </div>
        <div class="col-lg-8">
            <div class="introduction"><?php echo get_field('phrase_dintroduction');?></div>
        </div>
    </div>
    <div class="row slider">
        <div class="col-12 sliderLarge">
            <div class="single-item">
            <?php
            // check if the repeater field has rows of data
            if( have_rows('slider') ):
                // loop through the rows of data
                while ( have_rows('slider') ) : the_row();
                    // display a sub field value
                    $image = get_sub_field('image_slider');
                    //print_r($image);
                    ?>
                    <div><img src='<?php echo $image['url']?>' alt="<?php echo $image['alt']?>"></div>
                    <?php
                endwhile;
            else :
                // no rows found
            endif;
            ?>
            </div>
        </div>
        <div class="col-12 sliderSmall">
            <div class="single-item">
            <?php
            // check if the repeater field has rows of data
            if( have_rows('slider_mobile') ):
                // loop through the rows of data
                while ( have_rows('slider_mobile') ) : the_row();
                    // display a sub field value
                    $image = get_sub_field('image_slider_mobile');
                    //print_r($image);
                    ?>
                    <div><img src='<?php echo $image['url']?>' alt="<?php echo $image['alt']?>"></div>
                    <?php
                endwhile;
            else :
                // no rows found
            endif;
            ?>
            </div>
        </div>
        <div class="col-lg-12">
            <div class="circleTop"></div>
        </div>
    </div>
        <?php
        $args = array(
            'posts_per_page' => 2,
            'cat'  => 7,
            );

            $query = new WP_Query( $args );
            $i=1;
            if ($query->have_posts()) :
                while ($query->have_posts()) : $query->the_post();
                if($i==1)
                {
                    ?>
                    <div class="row temoignages">
                    <div class="col-lg-4 contactTemoignages">
                        <div class="row">
                            <div class="col-sm-12 col-md-9 col-lg-9">
                            <p class="nom"><?php echo get_field('nom_du_client')?></p>
                            <p class="Contact"><?php echo get_field('nom_du_contact')?></p>
                            <p class="Contact"><?php echo get_field('fonction_du_contact')?></p>
                            </div>
                            <div class="col-sm-12 col-md-3 col-lg-3">
                                <div class="trait"></div>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-8 contenu"><?php the_content();?></div>
                    </div>
                    <?php
                }else
                {
                    ?>
                    <div class="row temoignages">
                    <div class="col-lg-8 contenu"><?php the_content();?></div>
                    <div class="col-lg-4 contactTemoignages">
                        <div class="row">
                            <div class="col-sm-12 col-md-3 col-lg-3">
                                <div class="trait"></div>
                            </div>
                            <div class="col-sm-12 col-md-9 col-lg-9">
                                <p class="nom"><?php echo get_field('nom_du_client')?></p>
                                <p class="Contact"><?php echo get_field('nom_du_contact')?></p>
                                <p class="Contact"><?php echo get_field('fonction_du_contact')?></p>
                            </div>
                        </div>
                    </div>
                    </div>
                    <?php
                }
                $i++;
                endwhile;
            endif;
            ?>
            <div class="row article">
                <div class="col-12">
                    <div class="circleTop"></div>
                </div>
                <?php
                $args = array (
                    'posts_per_page' => 6,
                    'cat' => -7
                );
                $query = new WP_Query( $args );
                $i=1;
                if ($query->have_posts()) :
                while ($query->have_posts()) : $query->the_post();
                $cats = get_the_category();
                $wpseo_primary_term = new WPSEO_Primary_Term( 'category', get_the_id() );
				$wpseo_primary_term = $wpseo_primary_term->get_primary_term();
				$term = get_term( $wpseo_primary_term );
				//print_r($term);
                //foreach ($cats as $cat) {
                    if($term->slug == 'web-design')
                    {
                        $classColor = 'agenceWeb';
                    }elseif($term->slug == 'graphisme')
                    {
                        $classColor = 'studioGraphique';
                    }elseif($term->slug == 'video')
                    {
                        $classColor = 'productionAudiovisuelle';
                    }elseif($term->slug == 'e-marketing')
                    {
                        $classColor = 'inboundMarketing';
                    }elseif($term->slug == 'formation')
                    {
                        $classColor = 'formationSurMesure';
                    }
                //}
                ?>
                <div class="col-lg-4 <?php  if($i<4){ }else{ echo('espacement'); }?> <?php echo $classColor; ?>">
                    <div class="articleItem">
                        <a href="<?php the_permalink()?>">
                        <h2><?php the_title();?></h2>
                        <p><?php the_excerpt();?></p>
                        </a>
                    </div>
                </div>
                <?php
                $i++;
                endwhile;
                endif;

                ?>
                <div class="col-12"><div class="circleBot"></div></div>
            </div>

</div>


<?php get_footer(); ?>
