<?php
/**
 * Created by PhpStorm.
 * User: marco
 * Date: 25/06/18
 * Time: 16.07
 */
$site_title = get_bloginfo('name');
//$site_url = network_site_url( '/' );
$site_description = get_bloginfo('description');
$footer_home = '';
$footer_home_png = '';
$field_image_suffix = '';
if (is_front_page()) {
    $footer_home = ' home-footer ';
    $footer_home_png = 'home-footer-';
    $field_image_suffix = '_home';
}

?>
<?php       if (have_rows('sezione_con_testo')) : ?>

    <div class="blok columns-home-container">
        <div class="container">
            <div class="row">

                <?php
                $acf_string = '';
                if (have_rows('sezione_con_testo')) : ?>
                    <?php while (have_rows('sezione_con_testo')) : the_row(); ?>
                        <?php
                        $banner_image = '<img src="' . get_sub_field('immagine')['sizes']['quad'] . '" alt="' . get_sub_field('titolo') . '" class ="img-responsive"/>';
                        $banner_title = get_sub_field('titolo');
                        $banner_title_content = '';
                        $banner_text = '<div class="blok banner_text">' . get_sub_field('testo') . '</div>';
                        $banner_link = get_sub_field('link')['url'];
                        $banner_bottone_testo = get_sub_field('titolo');
                        if (!empty($banner_bottone_testo)) {
                            $button_html_text = $banner_bottone_testo;
                        } else {
                            $button_html_text = get_label('Per saperne di più');
                        };
                        $banner_button = '<div class="button_container button_columns"><a href="' . $banner_link . '">' . $button_html_text . '</a></div>';
                        if (!empty($banner_title)) {
                            $banner_title_content = html5_div('<h3>' . get_sub_field('titolo') . '</h3>', null, 'banner_title');
                        }
                        $return_content = $banner_image . $banner_title_content;
                        if (!empty($banner_link)) {
                            $return_content = '<a href="' . $banner_link . '">' . $banner_image . $banner_title_content . '</a>';
                        }
                        $acf_string .= html5_div('<div class="col-md-4"><div class="content"><div class="banner">' . $return_content . '</div></div>' . $banner_text . $banner_button . '</div>', null, 'banner');
                    endwhile;
                endif;
                echo $acf_string;
                ?>

            </div>
        </div>
    </div>
<?php endif;
global $is_testimonial;
if (empty($is_testimonial)) :?>
<div class="blok testimonials">
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="blok titolo-testimonials">
                    <h1><?php the_field( 'testimonials', 'option' ); ?></h1>
                </div>

            </div>
        </div>
        <div class="row">
            <?php     $subs_args = array(
        'post_type' => 'testimonial_post',
        'posts_per_page' => 3,
                'orderby'        => 'rand'
    );
    $the_query = new WP_Query($subs_args);
            if ($the_query->have_posts()) :


            while ($the_query->have_posts()) : $the_query->the_post();


    ?>            <div class="col-md-12">
                    <div class="blok testimonial-content">
                      <?php the_content();?>
                    </div>
                </div>
            <?php endwhile;endif;?>
        </div>
    </div>
</div>
<?php endif;?>
<div class="footer-wrapper <?php echo $footer_home; ?>">
    <section id="pre-footer" class="pre-footer " style="display: none">
        <div class="container">
            <div class="row">
                <?php if (have_rows('sezione_cerchio')) : ?>
                    <?php while (have_rows('sezione_cerchio')) : the_row(); ?>
                        <?php $link = get_sub_field('link'); ?>
                        <?php $immagine = get_sub_field('immagine');
                        //var_dump($immagine);
                        ?>

                        <div class="col-md-3 col-sm-6">
                            <div class="blok pre-footer-content">
                                <a href="<?php echo $link['url']; ?>">

                                    <?php if ($immagine) { ?>
                                        <img src="<?php echo $immagine['sizes']['quad']; ?>"
                                             alt="<?php echo $immagine['alt']; ?>"/>
                                    <?php } ?>
                                    <h3>  <?php the_sub_field('titolo'); ?></h3>
                                </a>
                            </div>
                        </div>

                    <?php endwhile; ?>
                <?php else : ?>
                    <?php // no rows found ?>
                <?php endif; ?>


            </div>
        </div>
    </section>



    <footer id="site-footer" class="site-footer <?php echo $footer_home; ?>">
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
                    <div class="site-footer-content">
                        <div class="site-footer-content-left">
                            <?php echo get_field('prima_colonna_footer', 'option'); ?>
                        </div>
                         <div class="site-footer-content-right">
                            <?php echo get_field('seconda_colonna_footer', 'option'); ?>
                            <div class="social-footer" style="margin-top: 45px">

                                <?php if ( have_rows( 'social', 'option' ) ) : ?>
                                    <?php while ( have_rows( 'social', 'option' ) ) : the_row(); ?>
                                        <span class="span_social"><a href="<?php the_sub_field( 'url' ); ?>"><i class="fa <?php the_sub_field( 'font_awesome_class_name' ); ?>"
                                                style="font-size: 24px;margin-left: 10px"></i></a>
                                </span>
                                    <?php endwhile; ?>
                                <?php else : ?>
                                    <?php // no rows found ?>
                                <?php endif; ?>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </footer>
</div>