<?php defined('ABSPATH') or die("No script kiddies please!"); ?>  
<!--☆Display Business Badge Details START☆-->  
<div class="egpr-badge-outer-new-wrapper egpr-<?php echo $badge_animation; ?>">
  <div class="egpr-business-badge egpr-business-header egpr-badge-<?php echo esc_attr($badge_template); ?>">
    
    <div class="egpr-business-badge-inner-wrap <?php echo $badge_animation_type;?>" <?php if($badge_animation_type != '') echo 'data-wow-duration="2s" data-wow-delay="0.2s"'; else echo '';?>> 
      <?php if ($show_header == 'true') { ?>
        <div class="egpr-show-header egpr-ribbon-banner <?php echo 'egpr-ribbon-' . $header_template; ?>">
          <div class="egpr-google-wrap">
            <?php
            $ribbon_template_number = intval(preg_replace('/[^0-9]+/', '', $header_template), 10);
            ?>
            <?php
            if($ribbon_template_number == 2){
              if($badge_template == "template1" || $badge_template == "template2" || $badge_template == "template5"){
                $bnum = $ribbon_template_number;
              }else if($badge_template == "template4" || $badge_template == "template7" || $badge_template == "template10"){
                $bnum = '-right-2';
              }else{
                $bnum = '-left-2';
              }
            }else if($ribbon_template_number == 3){
              if($badge_template == "template1" || $badge_template == "template2" || $badge_template == "template5"){
                $bnum = $ribbon_template_number;
              }else if($badge_template == "template4" || $badge_template == "template7" || $badge_template == "template10"){
                $bnum = '-right-3';
              }else{
                $bnum = '-left-3';
              }
            }else if($ribbon_template_number == 9){
              if($badge_template == "template1" || $badge_template == "template2" || $badge_template == "template5"){
                $bnum = $ribbon_template_number;
              }else if($badge_template == "template4" || $badge_template == "template7" || $badge_template == "template10"){
                $bnum = '-right-9';
              }else{
                $bnum = '-left-9';
              }
              
            }else{
              $bnum = $ribbon_template_number;
            }
            ?>
            <img src="<?php echo EGPR_FRONTEND_IMG_DIR . 'headers/header' . $bnum  . '.png' ?>"/>
          </div>           
        </div>
      <?php } ?>
      <div class="egpr-business-wrapper egpr-clearfix">       
        <?php if ($badge_template == "template1" || $badge_template == "template5") { ?>   
          <div class="egpr-business-avatar">
            <?php if ($photo_avatar != '') { ?>
              <a class="egpr-avatar-img-wrap" <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                <img src="https://maps.googleapis.com/maps/api/place/photo?photoreference=<?php echo esc_attr($photo_avatar); ?>&maxwidth=1300&maxheight=500&key=<?php echo $nverified_api_key; ?>">
              </a>
            <?php } else { ?>
              <a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                <img src="<?php echo EGPR_FRONTEND_IMG_DIR; ?>nopreview.png">
              </a>
            <?php } ?>
          </div>
          <div class="egpr-business-banner-info">
            <div class="egpr-header-title">
              <?php if ($business_name != '') { ?>
                <h2><a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>><?php echo esc_attr($business_name); ?></a></h2>
              <?php } ?>
            </div>
            <div class="egpr-ratings-wrap clearfix">
              <div class="egpr-star-rating">
                <?php
                $rating = $avg_star;
                      $whole = floor($avg_star);      // 1
                      $fraction = $rating - $whole; // .25
                      $next = $whole + 1;
                      $fraction_percent = round($fraction, 1) * 100;
                      for ($n = 1; $n <= 5; $n++) {
                        $full = ($n <= $whole) ? 'full' : '';
                        $half = ($fraction != '' && $n == $next) ? 'half egpr-fraction-' . $fraction_percent : '';
                        if($full == '' && $half == ''){
                          $new_class = "empty";
                        }else{
                          $new_class = $full . $half;
                        }
                        ?>
                        
                        <span class="egpr-star-icon <?php echo $new_class; ?>">
                          <i class="fa fa-star-o"></i>
                        </span>
                        <?php if ($half != '') { ?>
                          <style>
                            .egpr-star-rating .half.egpr-fraction-<?php echo $fraction_percent; ?>:before {
                              width:<?php echo $fraction_percent; ?>%;
                            }
                          </style>
                          <?php
                        }
                      }
                      ?>
                    </div>
                    <?php if ($hide_avg_rating != "1" && $avg_star != '') { ?>
                      <div class="egpr-average-star">
                        <?php if ($badge_template == "template5") { ?>
                          <span><?php echo $avg_star; ?></span>
                          <span class="egpr-text-stars">stars</span>
                        <?php } else { ?>
                          <span><?php echo $avg_star; ?>/5</span>
                        <?php } ?>

                      </div>
                    <?php } ?>
                  </div>
                </div>
              <?php } else if ($badge_template == "template2" || $badge_template == "template3" || $badge_template == "template6") { ?>
                <div class="egpr-business-avatar">
                  <?php if ($photo_avatar != '') { ?>
                    <a class="egpr-avatar-img-wrap" <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                      <img src="https://maps.googleapis.com/maps/api/place/photo?photoreference=<?php echo esc_attr($photo_avatar); ?>&maxwidth=1300&maxheight=500&key=<?php echo $nverified_api_key; ?>">
                    </a>
                  <?php } else { ?>
                    <a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                      <img src="<?php echo EGPR_FRONTEND_IMG_DIR; ?>nopreview.png">
                    </a>
                  <?php } ?>
                  <div class="egpr-header-title">
                    <?php if ($business_name != '') { ?>
                      <h2><a itemprop="name" <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>><?php echo esc_attr($business_name); ?></a></h2>
                    <?php } ?>
                  </div>
                </div>
                <div class="egpr-business-banner-info">
                  <?php if ($hide_avg_rating != "1" && $avg_star != '') { ?>
                    <div class="egpr-average-star">
                      <div class="egpr-average-star-wrap">
                        <span><?php echo $avg_star; ?></span><span>Ratings</span>
                      </div>
                    </div>
                  <?php } ?>
                  <div class="egpr-star-rating">
                    <?php
                    $rating = $avg_star;
                    $whole = floor($avg_star);      // 1
                    $fraction = $rating - $whole; // .25
                    $next = $whole + 1;
                    $fraction_percent = round($fraction, 1) * 100;
                    for ($n = 1; $n <= 5; $n++) {
                      $full = ($n <= $whole) ? 'full' : '';
                      $half = ($fraction != '' && $n == $next) ? 'half egpr-fraction-' . $fraction_percent : '';
                      if($full == '' && $half == ''){
                        $new_class = "empty";
                      }else{
                        $new_class = $full . $half;
                      }
                      ?>

                      <?php if ($badge_template == "template2") { ?>
                        <span class="egpr-heart-icon <?php echo $new_class; ?>">
                          <i class="fa fa-heart-o" aria-hidden="true"></i>  </span>
                        <?php } else if ($badge_template == "template3") {
                          ?>
                          <span class="egpr-circle-icon <?php echo $new_class; ?>">        
                            <i class="fa fa-circle-o" aria-hidden="true"></i>  </span>
                            <?php
                          } else {
                            //6
                            ?>
                            <span class="egpr-star-icon <?php echo $new_class; ?>">
                              <i class="fa fa-star-o" aria-hidden="true"></i>
                            </span>
                          <?php }
                          ?>

                          <?php if ($half != '') { ?>
                            <style>
                              .egpr-star-rating .half.egpr-fraction-<?php echo $fraction_percent; ?>:before {
                                width:<?php echo $fraction_percent; ?>%;
                              }
                            </style>
                            <?php
                          }
                        }
                        ?>
                      </div>
                    </div>

                  <?php } else if ($badge_template == "template4") { ?>
                    <div class="egpr-business-banner-info">
                      <?php if ($hide_avg_rating != "1" && $avg_star != '') { ?>
                        <div class="egpr-average-star">
                          <div class="egpr-average-star-wrap">
                            <span><?php echo $avg_star; ?></span><span><?php _e('Ratings','everest-google-places-reviews');?></span>
                          </div>
                        </div>
                      <?php } ?>
                      <div class="egpr-star-rating">
                        <?php
                        $rating = $avg_star;
                    $whole = floor($avg_star);      // 1
                    $fraction = $rating - $whole; // .25
                    $next = $whole + 1;
                    $fraction_percent = round($fraction, 1) * 100;
                    for ($n = 1; $n <= 5; $n++) {
                      $full = ($n <= $whole) ? 'full' : '';
                      $half = ($fraction != '' && $n == $next) ? 'half egpr-fraction-' . $fraction_percent : '';
                      if($full == '' && $half == ''){
                        $new_class = "empty";
                      }else{
                        $new_class = $full . $half;
                      }
                      ?>
                      <span class="egpr-thumbs-icon <?php echo $new_class; ?>"> 
                        <i class="fa fa-thumbs-o-up" aria-hidden="true"></i>
                      </span>
                      <?php if ($half != '') { ?>
                        <style>
                          .egpr-fraction-<?php echo $fraction_percent; ?>:before {
                            width:<?php echo $fraction_percent; ?>%;
                          }
                        </style>
                        <?php
                      }
                    }
                    ?>
                  </div>
                </div>
                <div class="egpr-business-avatar">
                  <?php if ($photo_avatar != '') { ?>
                    <a class="egpr-avatar-img-wrap" <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                      <img src="https://maps.googleapis.com/maps/api/place/photo?photoreference=<?php echo esc_attr($photo_avatar); ?>&maxwidth=1300&maxheight=500&key=<?php echo $nverified_api_key; ?>">
                    </a>
                  <?php } else { ?>
                    <a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                      <img src="<?php echo EGPR_FRONTEND_IMG_DIR; ?>nopreview.png">
                    </a>
                  <?php } ?>
                  <div class="egpr-header-title">
                    <?php if ($business_name != '') { ?>
                      <h2><a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>><?php echo esc_attr($business_name); ?></a></h2>
                    <?php } ?>
                  </div>
                </div>

              <?php } else if ($badge_template == "template7" || $badge_template == "template8" || $badge_template == "template9") { ?>
                <div class="egpr-business-inner-wrapper">
                  <div class="egpr-business-avatar">
                    <?php if ($photo_avatar != '') { ?>
                      <a class="egpr-avatar-img-wrap" <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                        <img src="https://maps.googleapis.com/maps/api/place/photo?photoreference=<?php echo esc_attr($photo_avatar); ?>&maxwidth=1300&maxheight=500&key=<?php echo $nverified_api_key; ?>">
                      </a>
                    <?php } else { ?>
                      <a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                        <img src="<?php echo EGPR_FRONTEND_IMG_DIR; ?>nopreview.png">
                      </a>
                    <?php } ?>    
                  </div>
                  <div class="egpr-header-title">
                    <?php if ($business_name != '') { ?>
                      <h2><a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>><?php echo esc_attr($business_name); ?></a></h2>
                    <?php } ?>
                  </div>
                  <div class="egpr-business-banner-info egpr-clearfix">
                    <div class="egpr-star-rating">
                      <?php
                      $rating = $avg_star;
                      $whole = floor($avg_star);      // 1
                      $fraction = $rating - $whole; // .25
                      $next = $whole + 1;
                      $fraction_percent = round($fraction, 1) * 100;
                      for ($n = 1; $n <= 5; $n++) {
                        $full = ($n <= $whole) ? 'full' : '';
                        $half = ($fraction != '' && $n == $next) ? 'half egpr-fraction-' . $fraction_percent : '';
                        if($full == '' && $half == ''){
                          $new_class = "empty";
                        }else{
                          $new_class = $full . $half;
                        }
                        ?>

                        <?php if ($badge_template == "template7") { ?>
                          <span class="egpr-circle-icon <?php echo $new_class; ?>">       
                            <i class="fa fa-circle-o" aria-hidden="true"></i>
                          </span>
                        <?php } else if ($badge_template == "template8") {
                          ?>
                          <span class="egpr-heart-icon <?php echo $new_class; ?>">
                            <i class="fa fa-heart-o" aria-hidden="true"></i>
                          </span>
                          <?php
                        } else {
                              //9
                          ?>
                          <span class="egpr-thumbs-icon <?php echo $new_class; ?>">       
                            <i class="fa fa-thumbs-o-up" aria-hidden="true"></i>
                          </span>
                        <?php }
                        ?>

                        <?php if ($half != '') { ?>
                          <style>
                            .egpr-fraction-<?php echo $fraction_percent; ?>:before {
                              width:<?php echo $fraction_percent; ?>%;
                            }
                          </style>
                          <?php
                        }
                      }
                      ?>
                    </div>
                    <?php if ($hide_avg_rating != "1" && $avg_star != '') { ?>
                      <div class="egpr-average-star">
                        <div class="egpr-average-star-wrap">
                          <span><?php echo $avg_star; ?></span><span>Ratings</span>
                        </div>
                      </div>
                    <?php } ?>
                  </div>
                </div>


              <?php } else if ($badge_template == "template10") { ?>
                <div class="egpr-business-banner-info">
                  <?php if ($hide_avg_rating != "1" && $avg_star != '') { ?>
                    <div class="egpr-average-star">
                      <span><?php echo $avg_star; ?></span><span>Ratings</span>
                    </div>
                  <?php } ?>
                  <div class="egpr-star-rating">
                    <?php
                    $rating = $avg_star;
                    $whole = floor($avg_star);      // 1
                    $fraction = $rating - $whole; // .25
                    $next = $whole + 1;
                    $fraction_percent = round($fraction, 1) * 100;
                    for ($n = 1; $n <= 5; $n++) {
                      $full = ($n <= $whole) ? 'full' : '';
                      $half = ($fraction != '' && $n == $next) ? 'half egpr-fraction-' . $fraction_percent : '';
                      if($full == '' && $half == ''){
                        $new_class = "empty";
                      }else{
                        $new_class = $full . $half;
                      }
                      ?>
                      <span class="egpr-star-icon <?php echo $new_class; ?>">
                        <i class="fa fa-star-o"></i>
                      </span>
                      <?php if ($half != '') { ?>
                        <style>
                          .egpr-fraction-<?php echo $fraction_percent; ?>:before {
                            width:<?php echo $fraction_percent; ?>%;
                          }
                        </style>
                        <?php
                      }
                    }
                    ?>
                  </div>
                </div>
                <div class="egpr-business-avatar">
                  <?php if ($photo_avatar != '') { ?>
                    <a class="egpr-avatar-img-wrap" <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                      <img src="https://maps.googleapis.com/maps/api/place/photo?photoreference=<?php echo esc_attr($photo_avatar); ?>&maxwidth=1300&maxheight=500&key=<?php echo $nverified_api_key; ?>">
                    </a>
                  <?php } else { ?>
                    <a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>>
                      <img src="<?php echo EGPR_FRONTEND_IMG_DIR; ?>nopreview.png">
                    </a>
                  <?php } ?>
                  <div class="egpr-header-title">
                    <?php if ($business_name != '') { ?>
                      <h2><a <?php if($badge_link != 1) echo 'href="'.$url.'" target="_blank"';?>><?php echo esc_attr($business_name); ?></a></h2>
                    <?php } ?>
                  </div>
                </div>



              <?php } ?>
            </div>
          </div>
        </div>
      </div>
      <!--Display Business Badge Details END--> 