<?php
/**
 * Page Template
 *
 * Loaded automatically by index.php?main_page=product_info.<br />
 * Displays details of a typical product
 *
 * @package templateSystem
 * @copyright Copyright 2003-2014 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:  $
 */
//  require(DIR_WS_MODULES . '/debug_blocks/product_info_prices.php');
?>
<div class="centerColumn" id="productGeneral">

<?php echo zen_draw_form('cart_quantity', zen_href_link(zen_get_info_page($_GET['products_id']), zen_get_all_get_params(array('action')) . 'action=add_product', $request_type), 'post', 'enctype="multipart/form-data"') . "\n"; ?>

<?php if ($messageStack->size('product_info') > 0) echo $messageStack->output('product_info'); ?>

<?php if (PRODUCT_INFO_PREVIOUS_NEXT == 1 or PRODUCT_INFO_PREVIOUS_NEXT == 3) { 
require($template->get_template_dir('/tpl_products_next_previous.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_products_next_previous.php'); ?>
<?php } ?>

<div class="product-info-wrap" itemscope itemtype="http://schema.org/Product">
  <div class="row">

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

      <?php require($template->get_template_dir('/tpl_modules_additional_images.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_additional_images.php'); ?>

    </div>
   

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

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

        <?php 
        	
        if ($flag_show_product_info_reviews == 1 && $reviews->fields['count'] > 0 ) : ?>
          <?php 
            $products_rating = genesis_get_product_rating((int)$_GET['products_id']); 
            $products_rating_count = genesis_get_product_rating_count((int)$_GET['products_id']);
          ?>
          <div class="product-rating">
            <span class="the-rating" title="<?php echo genesis_get_product_rating((int)$_GET['products_id']); ?>"><?php echo genesis_get_rating_html( genesis_get_product_rating( (int)$_GET['products_id'], false ) ); ?></span>
            <span class="rating-detail">
              <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
                <meta itemprop="ratingValue" content="<?php echo genesis_get_product_rating((int)$_GET['products_id']); ?>" />
                <?php echo sprintf( TEXT_REVIEW_COUNT, $products_rating_count, zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) ); ?>
              </span>
            </span>
          </div>
        <?php else : ?>
          <!--<div class="product-rating no-review">
            <span class="rating-detail">
              <?php //echo sprintf( TEXT_REVIEW_NONE, zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) ); ?>
            </span>
          </div>       -->
        <?php endif; ?>

        <h2 id="productPrices" class="productGeneral" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
        <meta itemprop="priceCurrency" content="<?php echo $_SESSION['currency']; ?>">
        <?php echo ($products_quantity > 0 ? '<link itemprop="availability" href="http://schema.org/InStock" />' : '<link itemprop="availability" href="http://schema.org/OutOfStock" />'); ?>
        <?php
        // base price
          if ($show_onetime_charges_description == 'true') {
            $one_time = '<span>' . TEXT_ONETIME_CHARGE_SYMBOL . TEXT_ONETIME_CHARGE_DESCRIPTION . '</span>';
          } else {
            $one_time = '';
          }
          echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']) . '<meta itemprop="price" content="' . round(zen_get_products_actual_price((int)$_GET['products_id']), 2, PHP_ROUND_HALF_UP) . '">';
        ?></h2>
      </div>

      <hr>

      <?php if ($pr_attr->fields['total'] > 0) {
        require($template->get_template_dir('/tpl_modules_attributes.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_attributes.php');
      } ?>

      <!--bof free ship icon  -->
      <?php if(zen_get_product_is_always_free_shipping($products_id_current) && $flag_show_product_info_free_shipping) { ?>
      <div id="freeShippingIcon"><?php echo TEXT_PRODUCT_FREE_SHIPPING_ICON; ?></div>
      <?php } ?>
      <!--eof free ship icon  -->

      <?php if (CUSTOMERS_APPROVAL != 3 and TEXT_LOGIN_FOR_PRICE_BUTTON_REPLACE_SHOWROOM != '') {
        $display_qty = (($flag_show_product_info_in_cart_qty == 1 and $_SESSION['cart']->in_cart($_GET['products_id'])) ? '<p class="qty-in-cart">' . PRODUCTS_ORDER_QTY_TEXT_IN_CART . $_SESSION['cart']->get_quantity($_GET['products_id']) . '</p>' : '');
        if ($products_qty_box_status == 0 or $products_quantity_order_max== 1) {
          $the_button = '<input type="hidden" name="cart_quantity" value="1" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . '<button type="submit" class="button">' . BUTTON_IN_CART_ALT . '</button>';
        } else {
          $the_button = '<input type="number" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" min="1" step="1">' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . '<button type="submit" class="button">' . BUTTON_IN_CART_ALT . '</button>';
        }
        $display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);
        $backstock = "";
        // BEGIN CEON BACK IN STOCK NOTIFICATIONS 1 of 2
			if (!is_null($product_back_in_stock_notification_form_link)) {
			  $backstock = '<p>' . $product_back_in_stock_notification_form_link . '</p>';
			}
			// END CEON BACK IN STOCK NOTIFICATIONS 1 of 2

        if ($display_qty != '' or $display_button != '') {
          printf( '<div id="cartAdd">%s</div>', $display_button . $display_qty . $backstock ); 
        }  
      } ?>

      <hr>

      <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" data-toggle="genesis-tooltip" 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" data-toggle="genesis-tooltip" 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" data-toggle="genesis-tooltip" 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" data-toggle="genesis-tooltip" target="_blank"><i class="fa fa-pinterest"></i></a></li> 
          <li><a href="mailto:please_enter_your@emailaddresshere.com?subject=<?php echo $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" data-toggle="genesis-tooltip" ><i class="fa fa-envelope"></i></a></li>
        </ul>
      </div>

      <!--bof Prev/Next bottom position -->
      <?php if (PRODUCT_INFO_PREVIOUS_NEXT == 2 or PRODUCT_INFO_PREVIOUS_NEXT == 3) { ?>
      <?php
      /**
       * display the product previous/next helper
       */
       require($template->get_template_dir('/tpl_products_next_previous.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_products_next_previous.php'); ?>
      <?php } ?>
      <!--eof Prev/Next bottom position -->

    </div>

  </div>

  <?php require($template->get_template_dir('tpl_modules_also_purchased_products.php', DIR_WS_TEMPLATE, $current_page_base,'templates'). '/' . 'tpl_modules_also_purchased_products.php');?>
  <div class="product-tabs">
    <div class="tabs">
      <ul class="tabs-nav clearfix">
        <li><a href="#tab-1" class="active"><?php echo TEXT_PRODUCTS_DESCRIPTION; ?></a></li>
<!--         <li><a href="#tab-2"><?php //echo TEXT_PRODUCTS_INFORMATION; ?></a></li> -->
        <?php if ($flag_show_product_info_reviews == 1 && $reviews->fields['count'] > 0 ) : ?>
        <li><a href="#tab-3"><?php echo TEXT_PRODUCTS_REVIEW; ?></a></li>
        <?php endif; ?>
        <?php if ($zc_show_also_purchased == true) : ?>
        <li><a href="#tab-4"><?php echo TEXT_ALSO_PURCHASED; ?></a></li>
        <?php endif; ?>
      </ul>
      <div class="tabs-content">
        <div id="tab-1" class="tab-content active">
          <div id="productDescription" class="productGeneral biggerText"><?php echo stripslashes($products_description); ?></div>
       <!-- </div>
        <div id="tab-2" class="tab-content">-->
          <?php if ( (($flag_show_product_info_model == 1 and $products_model != '') or ($flag_show_product_info_weight == 1 and $products_weight !=0) or ($flag_show_product_info_quantity == 1) or ($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name))) ) : ?>
          <ul id="productDetailsList">
            <?php echo (($flag_show_product_info_model == 1 and $products_model !='') ? '<li>' . TEXT_PRODUCT_MODEL . $products_model . '</li>' : '') . "\n"; ?>
            <?php echo (($flag_show_product_info_weight == 1 and $products_weight !=0) ? '<li>' . TEXT_PRODUCT_WEIGHT .  $products_weight . TEXT_PRODUCT_WEIGHT_UNIT . '</li>'  : '') . "\n"; ?>
            <?php echo (($flag_show_product_info_quantity == 1) ? '<li>' . $products_quantity . TEXT_PRODUCT_QUANTITY . '</li>'  : '') . "\n"; ?>
            <?php echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n"; ?>
          </ul>
          <?php endif; ?>
          
          <?php if ($products_discount_type != 0) { 
           require($template->get_template_dir('/tpl_modules_products_quantity_discounts.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_products_quantity_discounts.php');
          } ?>

          <?php if ($products_date_available > date('Y-m-d H:i:s')) : ?>
            <?php if ($flag_show_product_info_date_available == 1) : ?>
              <p id="productDateAvailable" class="productGeneral"><?php echo sprintf(TEXT_DATE_AVAILABLE, zen_date_long($products_date_available)); ?></p>
            <?php endif; ?>
          <?php else : ?>
            <?php if ($flag_show_product_info_date_added == 1) : ?>
              <p id="productDateAdded" class="productGeneral"><?php echo sprintf(TEXT_DATE_ADDED, zen_date_long($products_date_added)); ?></p>
            <?php endif; ?> 
          <?php endif; ?>

          <?php if (zen_not_null($products_url) && $flag_show_product_info_url == 1) : ?>
            <p id="productInfoLink" class="productGeneral"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
          <?php endif; ?>
        </div>
      <?php if ($flag_show_product_info_reviews == 1 && $reviews->fields['count'] > 0 ) : ?>
        <div id="tab-3" class="tab-content">
          <?php if ($reviews->fields['count'] > 0 ) : ?>
            <?php $reviews_detail = genesis_get_reviews_detail((int)$_GET['products_id']); ?>

            <?php if($reviews_detail->RecordCount() > 0) : ?>
              <ul class="reviews">
              <?php while(!$reviews_detail->EOF) : ?>
                <li class="review-item clearfix">
                  <div class="review-avatar">
                    <?php echo genesis_get_gravatar( genesis_get_customer_email( $reviews_detail->fields['customers_id'] ) ); ?>
                  </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_trunc_string(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 endif; ?>
            <div class="view-all-review">
              <?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '" class="button button-inverse pull-right">' . BUTTON_REVIEWS_ALT . ' &rarr;</a>'; ?>
              <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>
      <?php endif; ?>
      <?php if ($zc_show_also_purchased == true) : ?>
        <div id="tab-4" class="tab-content">
          <div class="centerBoxWrapper" id="alsoPurchased">
          <?php require($template->get_template_dir('tpl_columnar_display.php',DIR_WS_TEMPLATE, $current_page_base,'common'). '/tpl_columnar_display.php'); ?>
          </div>
        </div>
      <?php endif; ?>
      </div>
    </div>
  </div>

</div>

<!--bof Form close-->
</form>
<!--bof Form close-->
<?php // BEGIN CEON BACK IN STOCK NOTIFICATIONS 2 of 2
if (isset($back_in_stock_notification_build_form) && $back_in_stock_notification_build_form) {
  // Build the notification request form
  
  /**
   * Load the template class
   */
  require_once(DIR_FS_CATALOG . DIR_WS_CLASSES . 'class.CeonXHTMLHiTemplate.php');
  
  // Load in and extract the template parts for Back In Stock Notification functionality
  $bisn_template_filename = $template->get_template_dir('inc.html.back_in_stock_notifications.html',
    DIR_WS_TEMPLATE, $current_page_base, 'templates') . '/' .
    'inc.html.back_in_stock_notifications.html';
  
  $bisn_template = new CeonXHTMLHiTemplate($bisn_template_filename);
  
  $bisn_template_parts = $bisn_template->extractTemplateParts();
  
  $back_in_stock_notification_form = new CeonXHTMLHiTemplate;
  
  // Load in the source for the form
  $back_in_stock_notification_form->setXHTMLSource(
    $bisn_template_parts['PRODUCT_INFO_BACK_IN_STOCK_NOTIFICATION_FORM']);
  
  // Add the form action, titles, labels and button
  $form_start_tag = zen_draw_form('back_in_stock_notification',
    zen_href_link(FILENAME_BACK_IN_STOCK_NOTIFICATION_SUBSCRIBE, zen_get_all_get_params(),
    $request_type), 'POST');
  
  $back_in_stock_notification_form->setVariable('back_in_stock_notification_form_start_tag',
    $form_start_tag);
  
  $product_back_in_stock_notification_form_title = BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_TITLE;
  
  $back_in_stock_notification_form->setVariable('title',
    $product_back_in_stock_notification_form_title);
  
  $name_label = BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_ENTRY_NAME;
  $email_label = BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_ENTRY_EMAIL;
  $email_confirmation_label = BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_ENTRY_CONFIRM_EMAIL;
  
  $back_in_stock_notification_form->setVariable('name_label', $name_label);
  $back_in_stock_notification_form->setVariable('email_label', $email_label);
  $back_in_stock_notification_form->setVariable('email_confirmation_label',
    $email_confirmation_label);
  
  $submit_button = zen_image_submit(BUTTON_IMAGE_NOTIFY_ME, BUTTON_NOTIFY_ME_ALT,
    'name="notify_me"');
  $back_in_stock_notification_form->setVariable('submit_button', $submit_button);
  
  // Add in the introductory text
  $intro_text = sprintf(BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_INTRO,
    htmlentities($products_name, ENT_COMPAT, CHARSET));
  $notice_text = BACK_IN_STOCK_NOTIFICATION_TEXT_FORM_NOTICE;
  
  $back_in_stock_notification_form->setVariable('intro', $intro_text);
  $back_in_stock_notification_form->setVariable('notice', $notice_text);
  
  // Add the customer's details to the form (empty unless logged in)
  $back_in_stock_notification_form->setVariable('name',
    $back_in_stock_notification_form_customer_name);
  $back_in_stock_notification_form->setVariable('email',
    $back_in_stock_notification_form_customer_email);
  $back_in_stock_notification_form->setVariable('cofnospam',
    $back_in_stock_notification_form_customer_email_confirmation);
  
  print $back_in_stock_notification_form->getXHTMLSource();
}
// END CEON BACK IN STOCK NOTIFICATIONS 2 of 2 ?>
</div>
