<?php

$currentPageID = CONST_ABOUT_PAGE_ID;

$profileAboutPriceHeading = get_field('profile_about_price_heading',$currentPageID);

$profileAboutPricingFeatured = array();
$profileAboutPricingTitle = array();
$profileAboutPricingPrice = array();
$profileAboutPricingMonth = array();
$profileAboutPricingType = array();
$profileAboutPricingContent = array();
$profileAboutPricingButtonType = array();

if(have_rows('profile_about_pricing',$currentPageID)){
    while(have_rows('profile_about_pricing',$currentPageID)){
        the_row();      

        $tempValue = '';
        $tempClass = 'btn-secondary';
        if(get_sub_field('profile_about_pricing_featured',$currentPageID)){
            $tempValue = 'highlight-col';
            $tempClass = 'btn-primary';
        }

        $profileAboutPricingFeatured[] = $tempValue;
        $profileAboutPricingButtonType[] = $tempClass;
        $profileAboutPricingTitle[] = get_sub_field('profile_about_pricing_title',$currentPageID);
        $profileAboutPricingPrice[] = get_sub_field('profile_about_pricing_price',$currentPageID);
        $profileAboutPricingMonth[] = get_sub_field('profile_about_pricing_month',$currentPageID);
        $profileAboutPricingType[] = get_sub_field('profile_about_pricing_type',$currentPageID);        
        $profileAboutPricingContent[] = get_sub_field('profile_about_pricing_content',$currentPageID);

    }
}

?>

<?php
    if(sizeof($profileAboutPricingTitle) > 0 ){
?>
    <div class="white-space-50"></div>

    <!-- Pricing -->
    <div class="row">
        <div class="col-xs-12 col-sm-12">

            <div class="block-title">
                <?php 
                    $tempArray = explode(",",$profileAboutPriceHeading);
                    if(sizeof($tempArray) > 1 ){
                ?>
                        <h3><?php echo($tempArray[0]); ?> <span><?php echo($tempArray[1]); ?></span></h3>
                <?php
                    }
                    else{
                ?>
                        <h3><?php echo($tempArray[0]); ?></h3>
                <?php
                    }
                ?>
            </div>
        </div>
    </div>

    <div class="row">
        <div class=" col-xs-12 col-sm-12 ">
            <div class="fw-pricing clearfix row">
                <?php
                        
                    for($counter=0; $counter < sizeof($profileAboutPricingTitle); $counter++ ){
                ?>
                        <div class="fw-package-wrap col-md-6 <?php echo($profileAboutPricingFeatured[$counter])?>">
                            <div class="fw-package">
                                <div class="fw-heading-row">
                                    <span><?php echo($profileAboutPricingTitle[$counter]);?></span>
                                </div>

                                <div class="fw-pricing-row">
                                    <span><?php echo($profileAboutPricingPrice[$counter]);?></span>
                                    <small><?php echo($profileAboutPricingMonth[$counter]);?></small>
                                </div>

                                <div class="fw-button-row">
                                    <a href="#" target="_self" class="btn <?php echo($profileAboutPricingButtonType[$counter]); ?>">
                                        <?php echo($profileAboutPricingType[$counter]);?>
                                    </a>
                                </div>
                                <?php 
                                    $tempArray = explode("<br>",$profileAboutPricingContent[$counter]);
                                    if(sizeof($tempArray) > 1 ){
                                        for($inner=0; $inner < sizeof($tempArray); $inner++ ){
                                ?>
                                <div class="fw-default-row"><?php echo($tempArray[$inner]); ?></div>
                                <?php
                                        }
                                    }
                                    else{
                                ?>
                                <div class="fw-default-row"><?php echo($tempArray[0]); ?></div>
                                <?php
                                    }
                                ?>
                            </div>
                        </div>
                <?php
                    }
                ?>
            </div>
        </div>
    </div>
    <!-- End of Pricing -->

<?php
    }
?>