<?php 
    $GLOBALS['img']='pricing';
    get_header();
    the_post();
?>

<?php if(of_get_option('show_pricing')){ ?>

<div class="container">

    <?php
         if(of_get_option('show_pricing1')){
    ?>
    
    <div class="central_title top">
          
        <h2 <?php echo colors('h2');?> ><?php echo of_get_option('pricing1_plans_title');?></h2>
            
        <span <?php echo colors('h1s');?> >~ <?php echo of_get_option('pricing1_plans_detail');?> ~</span>
            
    </div>

    <?php
        $args=array(
            'post_type' => 'plan',
            'post_status' => 'publish',
            'posts_per_page' => -1,
        );
        $my_query = null;
        $my_query = new WP_Query($args);
        $plan = array();
        
        while ($my_query->have_posts()) {
            $my_query->the_post();
            $plan[] = array(
                'title' => get_the_title(),
                'subtitle' => get_field('subtitle'),
                'price' => get_field('price'),
                'freq' => get_field('frequency'),
                'options' => get_field('options'),
                'category' => get_field('categoria'),
                'btn_title' => get_field('btn_title'),
                'btn_link' => get_field('btn_link')
            );
        }
        $c = 0;
        $planes_count = 0;
        foreach($plan as $key){
            if($key['category'] == of_get_option('price_first_plansel')){
                $planes_count++;        
            }
        }
        foreach($plan as $key){
             if($key['category'] == of_get_option('price_first_plansel')){
             $c++;
              //  if(of_get_option('price_first_plan'.$c) == 1 ){
              if($c==1){echo '<div class="row-fluid">';}
     
     ?>
        
    <div class="span3">
              
        <div class="item_table option_pricing">

            <div class="head_table">
                  
                <div class="head_title">                               
                    
                    <h1 <?php echo colors('h1');?> ><?php echo $key['title'];?></h1>
                      
                    <span <?php echo colors('h1s');?> ><?php echo $key['subtitle'];?></span>
                      
                </div>
                    
                <h2 <?php echo colors('h2');?> ><?php echo $key['price'];?><span <?php echo colors('h1s');?> > $/ <?php echo $key['freq'];?></span></h2>                        
                        
            </div>

            <ul class="items"> 
                    
                <?php foreach($key['options'] as $data){?>
                    
                <li><?php echo $data['icon'];?> <?php echo $data['descripotion'];?></li>
                    
                <?php }?>
                    
            </ul> 

            <a <?php echo colors('a');?>  href="<?php echo $key['btn_link'];?>" class="botton"><?php echo $key['btn_title'];?></a>

        </div>
        
		<!-- End Item table -->
		
    </div>
  
    <?php
                    if($c%4==0){ 
                        echo '</div>';
                    if($c+1<=$planes_count){
                        echo '<div class="row-fluid top">';
                    }
                    }elseif($c==$planes_count){
                        echo '</div>';
                    }
                //}
            }
        }
    ?>
        
    <?php
        if(of_get_option('show_pricing2')){    
    ?>
    
    <div class="central_title top">
        
        <h2 <?php echo colors('h2');?> ><?php echo of_get_option('pricing2_title');?></h2>
            
        <span <?php echo colors('h1s');?> >~ <?php echo of_get_option('pricing2_desc');?> ~</span>
            
    </div>

    <?php 
        for($i=1; $i<=of_get_option('pricing2_num'); $i++){
        if($i==1){echo '<div class="row-fluid">';}
    ?>
        
    <div class="span3">
           
        <div class="planes">
              
            <?php if(of_get_option('show_pricing2_price'.$i)){?>
              
            <div class="prices">
              
                <p <?php echo colors('p');?> >$<?php echo of_get_option('pricing2_price'.$i);?><span <?php echo colors('h1s');?> >/<?php echo of_get_option('pricing2_frec'.$i);?></span></p>
                 
            </div> 
              
            <?php }?>

            <a <?php echo colors('a');?>  href="<?php echo of_get_option('pricing2_image_link'.$i);?>">
              
                <img src="<?php echo of_get_option('pricing2_image'.$i);?>" alt=""> 
                
            </a>
              
            <div class="planes_title">   
                                           
                <h1 <?php echo colors('h1');?> ><?php echo of_get_option('pricing2_title'.$i);?></h1>
                  
                <span <?php echo colors('h1s');?> ><?php echo of_get_option('pricing2_detail'.$i);?></span>            
                  
                <p <?php echo colors('p');?> ><?php echo insert_br(of_get_option('pricing2_desc'.$i));?></p>
                   
            </div>  

            <div class="footer_table">
                
                <a <?php echo colors('a');?>  href="<?php echo insert_br(of_get_option('pricing2_btn_link'.$i));?>"><?php echo insert_br(of_get_option('pricing2_btn'.$i));?></a>                   
                  
            </div>

        </div>
            
    </div>

    <?php 
        if($i%4==0){ 
            echo '</div>';
            if($i+1<=of_get_option('pricing2_num')){
                echo '<div class="row-fluid top">';
            }
            }elseif($i==of_get_option('pricing2_num')){
                echo '</div>';
            }
        }
    ?>

    <?php }?>
    
    <?php
        if(of_get_option('show_pricing3')){
    ?>
    
    <div class="clearfix"></div>
    
    <div class="central_title top">
     
        <h2 <?php echo colors('h2');?> ><?php echo of_get_option('pricing3_title');?></h2>
        
        <span <?php echo colors('h1s');?> >~ <?php echo of_get_option('pricing3_desc');?> ~</span>
        
    </div>
    
    <?php
        $args=array(
                'post_type' => 'price',
                'post_status' => 'publish',
                'posts_per_page' => -1,
            );
            $my_query = null;
            $my_query = new WP_Query($args);
            $prices = array();
            
            while ($my_query->have_posts()) {
                $my_query->the_post();
                $prices[] = array(
                    'title' => get_the_title(),
                    'logo' => get_field('logo'),
                    'title1' => get_field('title'),
                    'subtitle' => get_field('subtitle'),
                    'description' => get_field('description'),
                    'price' => get_field('price'),
                    'left' => get_field('c_right'),
                    'right' => get_field('c_left'),
                    'btn_title' => get_field('btn_title'),
                    'btn_link' => get_field('btn_link')
                );
            }
        $c = 0;
    
	    $i = 0;
        $prices_count = 0;
        foreach($prices as $key){
		    $i++;
            if(of_get_option('price_first_price'.$i) == '1'){
                $prices_count++;        
            }
        }
		
		$i = 0;
        foreach($prices as $key){
		    $i++;
             if(of_get_option('price_first_price'.$i) == '1'){
             $c++;
                if($c==1){echo '<div class="row-fluid"><div class="table">';}
    ?>
      
    <ul class="item">

        <li class="row-fluid">
          
            <ul class="description_item">
            
                <li class="span3 title">

                    <div class="icon_items">
                
                        <?php echo $key['logo'];?>
                  
                    </div>

                    <h4 <?php echo colors('h4');?> ><?php echo $key['title'];?></h4> 
                
                                   
                    <h3 <?php echo colors('h3');?> >$<?php echo $key['price'];?></h3>
                
                
                    <a <?php echo colors('a');?>  href="<?php echo $key['btn_link'];?>" class="botton"><?php echo $key['btn_title'];?></a>
              
			    </li>

                <li class="span9 info_item">
              
                    <h4 <?php echo colors('h4');?> ><?php echo $key['title1'];?></h4> <span <?php echo colors('h1s');?> ><i><?php echo $key['subtitle'];?></i></span>
                
                    <p <?php echo colors('p');?> ><?php echo $key['description'];?></p>

                    <div class="row-fluid">

                            <div class="span6">
                  
                                <ul class="items">
                                    
                                <?php 
                                    foreach($key['right'] as $data){
                                ?>
                    
                                    <li><?php echo $data['icon'];?> <?php echo $data['description'];?></li>
                                    
                                <?php }?>
                      
                                </ul>
                    
                            </div>
                            
                            <div class="span6">
                  
                                <ul class="items">
                                    
                                <?php 
                                    foreach($key['left'] as $data){
                                ?>
                    
                                    <li><?php echo $data['icon'];?> <?php echo $data['description'];?></li>
                                    
                                <?php }?>
                      
                                </ul>
                    
                            </div>
                  
                    </div> 

                </li>
			
                <!-- info item -->
			
            </ul>
			
        </li>

    </ul>
     
    <?php 
                if($c%3==0){ 
                    echo '</div></div>';
                    if($c+1<=$prices_count){
                        echo '<div class="row-fluid"><div class="table">';
                    }
                }elseif($c==$prices_count){
                    echo '</div></div>';
                }
        
            }
        }
    ?>

</div>
  
<?php }
    }
}?>

<!-- end Main Content-->
</div>  
 <?php get_footer(); ?>