<?php get_header('insidepages'); ?>

    <?php
    if (have_posts()){
        the_post();
            $solutionPageId = get_ID_by_slug('pars-patent-solutions');
            $solutionPage = get_post($solutionPageId);

            if(get_field('icon_page', $solutionPageId)) $icon = get_field('icon_page', $solutionPageId);
            $title = $solutionPage->post_title;
            if(get_field('introduction_txt', $solutionPageId)) $intro = get_field('introduction_txt', $solutionPageId);

    }
    ?>

    <!-- Banner : Begin -->
    <div class="row no-margin slider">
        <div class="rounded">
            <div class="bannercontainer">
                <div class="banner" style="visibility:hidden">
                    <ul>
                        <!-- Slides : Begin -->
                        <?php
                        /*
                        *  Loop through Slider Repeater fields (From another $post ID)
                        */

                        if(get_field('sliders', $solutionPageId) )
                        {
                            
                            while(has_sub_field('sliders', $solutionPageId) )
                            {
                                if(get_sub_field('image_banner')) $image = get_sub_field('image_banner');

                        ?>
                                
                        <li data-transition="fade">
                            <img src="<?php echo $image; ?>" alt="" />
                            <div class="all-container row no-margin clr-0">
                                    <div class="container">
                                        <span class="caption sfl" data-speed="600" data-start="500" data-easing="easeIn"><img  src="<?php echo $icon; ?>" alt=""/></span>
                                        <h3 class="caption fade sfr" data-speed="600" data-start="600" data-easing="easeIn"><?php echo $title; ?></h3>
                                    </div>
                            </div>
                        </li>
                        
                        <?php
                            }
                        }
                        ?>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <!--  Banner : End -->



    <!-- Intro -->
    <div class="row no-margin">
        <div class="container margin_T_80 theme-padding"> 
            <p class="txt_al_j">
            <?php echo $intro; ?><br /><br />
            </p>
        </div>
    </div>
    <!-- /Intro -->

    <!-- Services : Begin -->
    <div class="row no-margin"> 
        <div class="container theme-padding">

        <?php

            $args = array(
                'category_name' =>'solutions',
                'post_type' =>  'post',
                'posts_per_page' => 10,
                'orderby' => 'post_date',
                'order' => 'ASC'
            );
            $solutions = get_posts( $args );

            //var_dump($solutions);

            for($i=0; $i<count($solutions); $i++){
                if(get_field('excerpt_txt', $solutions[$i]->ID)) $excerpt = get_field('excerpt_txt', $solutions[$i]->ID);
                if(get_field('colorid_txt', $solutions[$i]->ID)) $colorID = get_field('colorid_txt', $solutions[$i]->ID);
                if(get_field('icon_solutions', $solutions[$i]->ID)) $icon = get_field('icon_solutions', $solutions[$i]->ID);

                //Break The title to 2 lines
                $title = $solutions[$i]->post_title;
                $word_array = explode(" ", $title);
                $first_part = $word_array[0];
                $second_part = substr($title, strlen($first_part) + 1);                        
        ?>

            <div class="service-item clr-<?php echo $colorID; ?>">
                <div class="image-div col-sm-5 no-padding">
                        <a href="<?php echo post_permalink($solutions[$i]->ID); ?>"><img class="img-responsive center-block" alt="<?php echo $solutions[$i]->post_title; ?>" src="<?php the_img_url('large' , $solutions[$i]->ID); ?>"/></a>
                        <span><img src="<?php echo $icon; ?>" alt="<?php echo $solutions[$i]->post_title; ?>"/></span>
                        <div>
                            <a href="<?php echo post_permalink($solutions[$i]->ID); ?>">
                                EXPLORE DEPARTMENT <span></span>
                            </a>
                        </div>
                </div>
                <div class="text-div col-sm-7">
                    <h3><a href="<?php echo post_permalink($solutions[$i]->ID); ?>"><?php echo $first_part . '<br />' . $second_part; ?></a></h3>
                    <p><?php echo $excerpt?></p>
                    <a href="department.html">Learn More</a>
                </div>
            </div>
        <?php } ?>

        </div>  
    </div>
    <!-- Services : End -->


                    
<?php get_footer('insidepages'); ?>