<?php
/**
 * Page Template
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: tpl_product_reviews_default.php 4852 2006-10-28 06:47:45Z drbyte $
 */

$limit = MAX_DISPLAY_NEW_REVIEWS;
if( !isset($_GET['page']) ){
  $offset = 0;
}else{
  if($_GET['page'] < 2){
    $offset = 0;
  }else{
    $offset = ($_GET['page']-1)*$limit; 
  }
}

?>
<div class="centerColumn" id="reviewsDefault">

  <div class="product-info-wrap">
    <div class="row">

      <?php if (zen_not_null($products_image)) : ?>
      <div class="product-images col-md-6" itemtype="http://schema.org/ImageGallery">
        <div id="productReviewsDefaultProductImage"><?php require($template->get_template_dir('/tpl_modules_main_product_image.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_main_product_image.php'); ?></div>
      </div>
      <?php endif; ?>

      <div class="product-details col-md-6">

        <div class="product-header">
          <h1 id="productName" class="productGeneral"><?php echo $products_name; ?></h1>

          <h2 id="productPrices" class="productGeneral"><?php echo $products_price; ?></h2>

          <?php echo '<a class="button" href="' . zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('reviews_id'))) . '">' . BUTTON_GOTO_PROD_DETAILS_ALT . '</a>'; ?>

          <div class="product-share">
            <ul>
              <li><a href="https://www.facebook.com/sharer.php?u=<?php echo urlencode(htmlspecialchars_decode(zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id((int)$_GET['products_id'])) . '&products_id=' . (int)$_GET['products_id'] . '&amp;p[images][0]=' . (($request_type == 'SSL') ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ) . $products_image_large, $request_type, false))); ?>" class="facebook-share" title="Share on Facebook" target="_blank"><i class="fa fa-facebook"></i></a></li> 
              <li><a href="http://www.twitter.com/share?url=<?php echo urlencode(htmlspecialchars_decode(zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id((int)$_GET['products_id'])) . '&products_id=' . (int)$_GET['products_id'], $request_type, false))); ?>" class="twitter-share" title="Share on Twitter" target="_blank"><i class="fa fa-twitter"></i></a></li> 
              <li><a href="https://plus.google.com/share?url=<?php echo urlencode(htmlspecialchars_decode(zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id((int)$_GET['products_id'])) . '&products_id=' . (int)$_GET['products_id'], $request_type, false))); ?>" class="google-plus-share" title="Share on Google Plus" target="_blank"><i class="fa fa-google-plus"></i></a></li> 
              <li><a href="https://pinterest.com/pin/create/button/?url=<?php echo urlencode(htmlspecialchars_decode(zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id((int)$_GET['products_id'])) . '&products_id=' . (int)$_GET['products_id'], $request_type, false))); ?>&amp;media=<?php echo (($request_type == 'SSL') ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ) . $products_image_large; ?>&amp;description=" class="pinterest-share" title="Share on Pinterest" target="_blank"><i class="fa fa-pinterest"></i></a></li> 
              <li><a href="mailto:please_enter_your@emailaddresshere.com?subject=<?php echo urlencode($products_name); ?>&amp;body=<?php echo urlencode(htmlspecialchars_decode(zen_href_link(zen_get_info_page((int)$_GET['products_id']), 'cPath=' . zen_get_generated_category_path_rev(zen_get_products_category_id((int)$_GET['products_id'])) . '&products_id=' . (int)$_GET['products_id'], $request_type, false))); ?>" title="Email a Friend"><i class="fa fa-envelope"></i></a></li>
            </ul>
          </div>
        </div>

      </div>

    </div>

    <div class="reviews-wrap">
      <?php $reviews_detail = genesis_get_reviews_detail((int)$_GET['products_id'], $offset, $limit); ?>
      <?php if($reviews_detail->RecordCount() > 0) : ?>
        <h3 class="section-title"><?php echo TEXT_PRODUCTS_REVIEW; ?></h3>

        <?php if ( $reviews_split->number_of_rows > 0 && (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) : ?>
          <div id="productReviewsDefaultListingTopNumber" class="navSplitPagesResult"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
          <div id="productReviewsDefaultListingTopLinks" class="navSplitPagesLinks"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page'))); ?></div>
        <?php endif; ?>

        <ul class="reviews">
        <?php while(!$reviews_detail->EOF) : ?>
          <li class="review-item clearfix">
            <div class="review-avatar">
              <?php echo genesis_get_gravatar( $reviews_detail->fields['customers_email_address'] ); ?>
            </div>
            <h3 class="review-by">
              <?php echo $reviews_detail->fields['customers_name']; ?>
              <span class="review-date"><em> - <?php echo date( 'd M Y', strtotime( $reviews_detail->fields['date_added'] ) ); ?></em></span>
            </h3>
            <p class="review-text"><?php echo zen_clean_html(stripslashes($reviews_detail->fields['reviews_text'])); ?></p>
            <span class="the-rating" title="<?php echo $reviews_detail->fields['reviews_rating']; ?>"><?php echo genesis_get_rating_html( $reviews_detail->fields['reviews_rating'] ); ?></span>                 
          </li>
          <?php $reviews_detail->MoveNext(); ?>
        <?php endwhile; ?>
        </ul>

        <?php if (($reviews_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) : ?>
          <div id="productReviewsDefaultListingBottomNumber" class="navSplitPagesResult"><?php echo $reviews_split->display_count(TEXT_DISPLAY_NUMBER_OF_REVIEWS); ?></div>
          <div id="productReviewsDefaultListingBottomLinks" class="navSplitPagesLinks"><?php echo TEXT_RESULT_PAGE . ' ' . $reviews_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'main_page'))); ?></div>
        <?php endif; ?>

        <div class="view-all-review">
          <a class="button pull-right" href="<?php echo zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())); ?>"><?php echo TEXT_REVIEW_WRITE; ?></a>
        </div>

      <?php endif; ?> 
    </div>

  </div>

</div>
