File: /home/reachcon/www/wp-content/themes/reach-connects/single-omada_client.php
<?php
// The Template for displaying all single posts
global $omada,$omadaLayout,$omadaClient;
get_header();
$cats = $omadaClient->get_category_images();
$packages = $omadaClient->get_package_details();
echo '<main>';
if ( have_posts() ) :
while ( have_posts() ) : the_post();
$category = get_field('listing_category');
$permalink = get_the_permalink(get_the_ID());
// Collect Package
$package = get_field('package');
if(isset($packages[$package])){ $pkg=$packages[$package]; }
else{ if(isset($packages[0])){ $pkg = $packages[0]; }else{ $pkg = false; } }
if($pkg){
/*
[label] => Featured
[features] => Array (
[0] => Listing Details
[1] => Location
[2] => Logo
[3] => Google Map
[4] => Description
[5] => Reviews
[6] => Contact Form
[7] => Images
[8] => Videos
[9] => Hours
)
*/
// Location
echo '<div class="busSection">';
echo '<div class="grid-container">';
echo '<div class="grid-x align-center">';
echo '<div class="cell large-10 medium-11">';
echo '<div class="grid-container">';
echo '<div class="contactDetails">';
echo '<div class="grid-x">';
echo '<div class="cell xlarge-3 large-4 medium-5">';
echo '<div class="contactDetailsLeft">';
// echo '<h5 class="busCategory">'.$cats[get_field('listing_category')]['name'].'</h5>';
if($pkg['label']){echo '<h5 class="busFeatured">'.$pkg['label'].'</h5>'; }
///echo $cats[$category]['url'];
if(in_array('Logo',$pkg['features'])){
$img = get_field('company_logo',get_the_ID());
if(!empty($img)){
echo '<img src="'.$img['url'].'" alt="" class="profileImg">';
echo '<div class="smspc"></div>';
}elseif(isset($cats[$category]['url'])){
echo '<img src="'.$cats[$category]['url'].'" alt="" class="profileImg">';
echo '<div class="smspc"></div>';
}
}
echo '<h3>'.get_the_title(get_the_ID()).'</h3>';
$address = get_field('address');
$address2 = get_field('address_line_2');
$add='';
if($address){$add=$add.$address;}
if($address2){$add=$add.'<br>'.$address2;}
$add=$add.'<br>'.get_field('city').', '.get_field('state').' '.get_field('zip');
echo '<p>'.$add.'</p>';
// Website
$web = get_field('website');
if($web){echo '<strong><i class="fa fa-globe fa-fw"></i></strong> <a href="'.$web.'" target="_blank">Visit Us Online</a>';}
// Phone
$phone=get_field('phone');
$phone_alt=get_field('phone_alt');
if($phone){echo '<br><strong><i class="fa fa-phone fa-fw"></i></strong> <a>'.$phone.'</a>';}
if($phone_alt){echo '<br><strong><i class="fa fa-phone fa-fw"></i></strong> <a>'.$phone_alt.'</a>';}
echo '</div>';
echo '</div>';
echo '<div class="cell xlarge-9 large-8 medium-7">';
echo '<h1>'.get_the_title(get_the_ID()).'</h1>';
// CATEGORY
echo '<div class="archiveCategory"><small>';
echo $cats[get_field('listing_category')]['name'];
if(get_field('listing_category2')){ echo ', '.$cats[get_field('listing_category2')]['name'];}
if(get_field('listing_category3')){ echo ', '.$cats[get_field('listing_category3')]['name'];}
echo '</small></div>';
if(get_field('about')){
echo '<h2 class="busHead">Company Description</h2>';
echo get_field('about');
}
$args=array(
'posts_per_page' => -1,
'post_type' => 'receipts',
'meta_key' => 'customer',
'meta_value' => get_field('user'),
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
$count = $the_query->post_count;
$d = ($count==1) ? 'donation' : 'donations';
echo '<h2>'.get_the_title(get_the_ID()).' has '.$the_query->post_count.' verified '.$d.'.</h2>';
echo '<table>';
echo '<thead>';
echo '<tr>';
echo '<th>Date</th>';
echo '<th>Category</th>';
echo '<th class="text-right">Amount</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
while ( $the_query->have_posts() ) : $the_query->the_post();
$symbol = '&#'.get_field('currency_symbol').';';
echo '<tr>';
echo '<td>'.get_field('date_of_donation').'</td>';
$term = get_term(get_field('donation_category'),'donation_category');
echo '<td>'.$term->name.'</td>';
echo '<td class="text-right">'.$symbol.get_field('amount_donated').'</td>';
echo '</tr>';
endwhile;
echo '</tbody>';
echo '</table>';
else:
echo '<h2>'.get_the_title(get_the_ID()).' has 0 verified donations.</h2>';
endif;
// Reset Post Data
wp_reset_postdata();
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
// GOOGLE MAP WILL COME LATER
if(in_array('Google Map',$pkg['features'])){
// IGNORE FOR NOW - API CANNOT BE TESTED AT THIS TIME.
}
// GOOGLE MAP WILL COME LATER
if(in_array('Hours',$pkg['features'])){
// I will be creating a function to handle this display
// displayClientHours(get_the_ID());
}
if(in_array('Images',$pkg['features'])){
echo '<div class="busSection">';
echo '<h2 class="busHead">Gallery</h2>';
if( have_rows('client_images') ){
$i=0;
$images=array();
$id='5465';
echo '<div class="paginatedGallery omadaGallery" data-gallery="'.$id.'"><div class="tabs-panel is-active" id="panel'.$id.'"><div class="grid-x grid-padding-x small-up-2 medium-up-4 large-up-6 align-center" data-equalizer>';
// loop through the rows of data
while ( have_rows('client_images') ){ the_row();
$image = get_sub_field('image');
if(!empty($image)){
$title = get_sub_field('title');
$images[$i]=array( 'url'=>$image['sizes']['thumbnail'], 'title'=>$title );
echo '<div class="cell">';
echo '<img src="'.$image['sizes']['thumbnail'].'" class="fw thumbnail galleriesImage'.$id.'" alt="'.$title.'" data-ref="'.$i.'" data-equalizer-watch />';
echo '</div>';
$i++;
}
}
echo '</div>';
echo '</div>';
echo '</div>';
if(!empty($images)){
echo '<div class="reveal large text-center gallerySys" id="galleriesReveal'.$id.'" data-reveal>';
echo '<div id="slides'.$id.'" class="swiper-container">';
echo '<div class="swiper-wrapper">';
$i=0;
foreach( $images as $image){
echo '<div class="swiper-slide">';
echo '<div class="galleryImage"><img src="'.$image['url'].'" alt="'.$image['title'].'"></div>';
if($image['title']!=''){
echo '<div class="slideDetails">';
echo '<h2 class="galleryTitle">'.$image['title'].'</h2>';
echo '</div>';
}
echo '</div>';
}
echo '</div>';
echo '</div>';
echo '<button class="close-button" data-close aria-label="Close reveal" type="button"><span aria-hidden="true"><i class="fa fa-window-close" aria-hidden="true"></i></span></button>';
echo '</div>';
}
}
echo '</div>';
}
// Videos
if(in_array('Videos',$pkg['features'])){
if( have_rows('videos') ){
echo '<div class="busSection">';
echo '<h2 class="busHead">Videos</h2>';
echo '<div class="grid-x grid-padding-x medium-up-2 align-center" >';
while ( have_rows('videos') ){ the_row();
echo '<div class="cell">';
echo '<div class="embed-container">'.get_sub_field('client_video').'</div>';
echo '</div>';
}
echo '</div>';
echo '</div>';
}
}
// ADD REVEWS SYSTEM
comments_template( '', true );
}else{
// This user did not pay for their package and there is no free package available to downgrade to.
// We have to decide on what to display if the account has been "disabled"
}
endwhile;
else:
// The post no longer exists. Please try searching again.
// Maybe a back button or include the search form.
endif;
?>
<div class="spc"></div>
</main>
<?php get_footer(); ?>