<?php

use Magento\Framework\App\Action\Action;
?>
<?php
$enable_bestseller = $this->getData('bestseller_title');
$enable_hotdeals = $this->getData('enable_hotdeals');
$enable_featured = $this->getData('enable_featured');

$bestseller_order = $this->getData('bestseller_order');
$hotdeals_order = $this->getData('hotdeals_order');
$featured_order = $this->getData('featured_order');

$_imagehelper = $this->helper('Magento\Catalog\Helper\Image');
$cpanel_helper = $this->helper('Solwin\Cpanel\Helper\Data');
$isNewLabel = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/newlabel');
$isSaleLabel = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/salelabel');
$Enable_aspect_ratio = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/image_aspect_ratio');
$img_width = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/image_ratio_width');
$img_height = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/image_ratio_height');
$show_alternative_image = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_alternative_image');
$show_rating_star = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_rating_star');
$show_product_price = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_product_price');
$show_actions = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_actions');
$show_addtocompare = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_addtocompare');
$show_addtowishlist = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_addtowishlist');
$show_productview = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/show_productview');
$list_blocks = $cpanel_helper->getCpanelConfigValue('cpanelsection/listpagegroup/list_product_blocks');
?>

<?php if ($enable_bestseller || $enable_hotdeals || $enable_featured) { ?>
    <div class="ht-wrapper pad-main">
        <div class="ht-main">
            <ul class="ht-main-ul">
                <?php if ($enable_bestseller) { ?>
                    <li id="htab_<?php echo $bestseller_order; ?>" class="ht-tab">
                        <label style="display: none;"><?php echo $bestseller_order; ?></label>
                        <?php echo $this->getData('bestseller_title'); ?>
                    </li>
                <?php } ?>
                <?php if ($enable_hotdeals) { ?>
                    <li id="htab_<?php echo $hotdeals_order; ?>" class="ht-tab">
                        <label style="display: none;"><?php echo $hotdeals_order; ?></label>
                        <?php echo $this->getData('hotdeals_title'); ?>
                    </li>
                <?php } ?>
                <?php if ($enable_featured) { ?>
                    <li id="htab_<?php echo $featured_order; ?>" class="ht-tab">
                        <label style="display: none;"><?php echo $featured_order; ?></label>
                        <?php echo $this->getData('featured_title'); ?>
                    </li>
                <?php } ?>
            </ul>
        </div>
        <div class="ht-tab-content">
            <?php if ($enable_bestseller) { ?>
                <div id="hcontent_<?php echo $bestseller_order; ?>" class="ht-inner owl-btn-top">
                    <label style="display: none;"><?php echo $bestseller_order; ?></label>
                    <?php
                    $_productCollection = $block->getBeastsellerLoadedProductCollection();
                    $_helper = $this->helper('Magento\Catalog\Helper\Output');
                    $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\Image');
                    ?>
                    <?php if (!$_productCollection->count()): ?>
                        <div class="message info empty"><div><?php echo __('We can\'t find products matching the selection.') ?></div></div>
                    <?php else: ?>
                        <?php
                        if ($block->getMode() == 'grid') {
                            $viewMode = 'grid';
                            $image = 'category_page_grid';
                            $hover_img = 'category_page_grid_hover';
                            $showDescription = false;
                            $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
                        } else {
                            $viewMode = 'list';
                            $image = 'category_page_list';
                            $hover_img = 'category_page_list_hover';
                            $showDescription = true;
                            $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
                        }
                        $pos = $block->getPositioned();
                        $position = '';
                        if ($pos != null) {
                            $position = ' style="left:' . $block->getVar("{$image}:width") . 'px;'
                                    . 'top:' . $block->getVar("{$image}:height") . 'px;"';
                        }
                        ?>
                        <div class="block-content">
                            <div class="wrapper <?php echo $viewMode; ?> products-<?php echo $viewMode; ?>">
                                <?php $iterator = 1; ?>
                                <div class="row">
                                    <ol class="list items product-items porduct-slider">
                                        <?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
                                        <?php foreach ($_productCollection as $_product): ?>
                                            <?php echo($iterator++ == 1) ? '<li style="margin-bottom:2px;" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-item">' : '</li><li style="margin-bottom:2px;" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-item">' ?>
                                            <div class="product-item-info" data-container="product-grid">
                                                <?php // Product Image         ?>
                                                <a href="<?php echo $_product->getProductUrl() ?>" tabindex="-1">
                                                    <?php
                                                    if ($Enable_aspect_ratio) {
                                                        $productImage = $_imagehelper->init($_product, $image)
                                                                ->constrainOnly(FALSE)
                                                                ->keepAspectRatio(TRUE)
                                                                ->keepFrame(FALSE)
                                                                ->resize($img_width);
                                                    } else {
                                                        $productImage = $_imagehelper->init($_product, $image)
                                                                ->resize($img_width, $img_height);
                                                    }
                                                    $productImageUrl = $productImage->getUrl();
                                                    ?>
                                                    <img class="product-image-photo pd-img" src="<?php echo $productImageUrl; ?>" alt="<?php echo $productImage->getLabel(); ?>"/>
                                                    <?php if ($show_alternative_image) { ?>
                                                        <?php
                                                        if ($Enable_aspect_ratio) {
                                                            $productHoverImage = $_imagehelper->init($_product, $hover_img)
                                                                    ->constrainOnly(FALSE)
                                                                    ->keepAspectRatio(TRUE)
                                                                    ->keepFrame(FALSE)
                                                                    ->resize($img_width);
                                                        } else {
                                                            $productHoverImage = $_imagehelper->init($_product, $hover_img)
                                                                    ->resize($img_width, $img_height);
                                                        }
                                                        $productHoverImageUrl = $productHoverImage->getUrl();
                                                        ?>
                                                        <img class="product-image-photo ph_img" src="<?php echo $productHoverImageUrl; ?>" alt="<?php echo $productHoverImage->getLabel(); ?>"/>
                                                    <?php } ?>
                                                    <?php
                                                    /**
                                                     * Check if "new" label is enabled and if product has from new date & to new date
                                                     */
                                                    if ($isNewLabel) {
                                                        $fromDate = $_product->getNewsFromDate();
                                                        $toDate = $_product->getNewsToDate();
                                                        if (isset($fromDate) && isset($toDate)) {
                                                            $fromDate = strtotime($fromDate);
                                                            $toDate = strtotime($toDate);
                                                            $now = strtotime(date("Y-m-d h:m:s"));

                                                            if ($fromDate <= $now && $now <= $toDate) {
                                                                ?>
                                                                <span class="new-lbl">New</span>
                                                                <?php
                                                            }
                                                        }
                                                    }
                                                    ?>
                                                    <?php
                                                    /**
                                                     * Check if "sale" label is enabled and if product has special price with from & to special price
                                                     */
                                                    if ($isSaleLabel) {
                                                        $special_price = number_format($_product->getSpecialPrice(), 2);
                                                        $regular_price = number_format($_product->getPrice(), 2);
                                                        if (isset($special_price) && $special_price > 0) {
                                                            if ($special_price < $regular_price) {
                                                                $fromSpecialDate = $_product->getSpecialFromDate();
                                                                $toSpecialDate = $_product->getSpecialToDate();

                                                                if (isset($fromSpecialDate) && isset($toSpecialDate)) {
                                                                    $fromSpecialDate = strtotime($fromSpecialDate);
                                                                    $toSpecialDate = strtotime($toSpecialDate);
                                                                    $now = strtotime(date("Y-m-d h:m:s"));

                                                                    if ($fromSpecialDate <= $now && $now <= $toSpecialDate) {
                                                                        ?>
                                                                        <span class="sale-lbl">Sale</span>
                                                                        <?php
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    ?>
                                                </a>
                                                <div class="product details product-item-details">
                                                    <?php
                                                    $_productNameStripped = $block->stripTags($_product->getName(), null, true);
                                                    ?>
                                                    <strong class="product name product-item-name">
                                                        <a class="product-item-link"
                                                           href="<?php echo $_product->getProductUrl() ?>">
                                                               <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                                                        </a>
                                                    </strong>
                                                    <?php if ($show_rating_star) { ?>
                                                        <?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
                                                    <?php } ?>
                                                    <?php if ($show_product_price) { ?>
                                                        <?php echo $block->getProductPrice($_product) ?>
                                                    <?php } ?>
                                                    <?php echo $block->getProductDetailsHtml($_product); ?>
                                                    <?php if ($show_actions) { ?>
                                                        <div class="product-item-inner">
                                                            <div class="product actions product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
                                                                <div class="actions-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
                                                                    <?php if ($_product->isSaleable()): ?>
                                                                        <?php $postParams = $block->getAddToCartPostParams($_product); ?>
                                                                        <form data-role="tocart-form" action="<?php echo $postParams['action']; ?>" method="post">
                                                                            <input type="hidden" name="product" value="<?php echo $postParams['data']['product']; ?>">
                                                                            <input type="hidden" name="<?php echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                                                            <?php echo $block->getBlockHtml('formkey') ?>
                                                                            <button type="submit"
                                                                                    title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
                                                                                    class="action tocart primary">
                                                                                <span><?php echo __('Add to Cart') ?></span>
                                                                            </button>
                                                                        </form>
                                                                    <?php else: ?>
                                                                        <?php if ($_product->getIsSalable()): ?>
                                                                            <div class="stock available"><span><?php echo __('In stock') ?></span></div>
                                                                        <?php else: ?>
                                                                            <div class="stock unavailable"><span><?php echo __('Out of stock') ?></span></div>
                                                                        <?php endif; ?>
                                                                    <?php endif; ?>
                                                                </div>
                                                                <div data-role="add-to-links" class="actions-secondary"<?php echo strpos($pos, $viewMode . '-secondary') ? $position : ''; ?>>
                                                                    <?php if ($show_addtowishlist) { ?>
                                                                        <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
                                                                            <a href="#"
                                                                               class="action towishlist"
                                                                               title="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
                                                                               aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
                                                                               data-post='<?php echo $block->getAddToWishlistParams($_product); ?>'
                                                                               data-action="add-to-wishlist"
                                                                               role="button">
                                                                                <span><?php echo __('Add to Wish List') ?></span>
                                                                            </a>
                                                                        <?php endif; ?>
                                                                    <?php } ?>
                                                                    <?php if ($show_addtocompare) { ?>
                                                                        <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare'); ?>
                                                                        <a href="#"
                                                                           class="action tocompare"
                                                                           title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
                                                                           aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
                                                                           data-post='<?php echo $compareHelper->getPostDataParams($_product); ?>'
                                                                           role="button">
                                                                            <span><?php echo __('Add to Compare') ?></span>
                                                                        </a>
                                                                    <?php } ?>
                                                                    <?php if ($show_productview) { ?>
                                                                        <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"
                                                                           class="action cus-addto toview"
                                                                           title="<?php echo $block->escapeHtml(__('View')); ?>"
                                                                           aria-label="<?php echo $block->escapeHtml(__('View')); ?>"
                                                                           role="button">
                                                                            <span><?php /* @escapeNotVerified */ echo __('View') ?></span>
                                                                            <div class="span-hov"></div>
                                                                        </a>
                                                                    <?php } ?>
                                                                </div>
                                                            </div>
                                                            <?php if ($showDescription): ?>
                                                                <div class="product description product-item-description">
                                                                    <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                                                                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>"
                                                                       class="action more"><?php echo __('Learn More') ?></a>
                                                                </div>
                                                            <?php endif; ?>
                                                        </div>
                                                    <?php } ?>
                                                </div>
                                            </div>
                                            <?php echo($iterator == count($_productCollection) + 1) ? '</li>' : '' ?>
                                        <?php endforeach; ?>
                                    </ol>
                                </div>
                            </div>
                        </div>
                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                            <script type="text/x-magento-init">
                                {
                                "[data-role=tocart-form], .form.map.checkout": {
                                "catalogAddToCart": {}
                                }
                                }
                            </script>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>
            <?php } ?>
            <?php if ($enable_hotdeals) { ?>
                <div id="hcontent_<?php echo $hotdeals_order; ?>" class="ht-inner owl-btn-top">
                    <label style="display: none;"><?php echo $hotdeals_order; ?></label>
                    <?php
                    $_productCollection = $block->getHotDealsLoadedProductCollection();
                    $_helper = $this->helper('Magento\Catalog\Helper\Output');
                    $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\Image');
                    ?>
                    <?php if (!$_productCollection->count()): ?>
                        <div class="message info empty"><div><?php echo __('We can\'t find products matching the selection.') ?></div></div>
                    <?php else: ?>
                        <?php
                        if ($block->getMode() == 'grid') {
                            $viewMode = 'grid';
                            $image = 'category_page_grid';
                            $hover_img = 'category_page_grid_hover';
                            $showDescription = false;
                            $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
                        } else {
                            $viewMode = 'list';
                            $image = 'category_page_list';
                            $hover_img = 'category_page_list_hover';
                            $showDescription = true;
                            $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
                        }
                        $pos = $block->getPositioned();
                        $position = '';
                        if ($pos != null) {
                            $position = ' style="left:' . $block->getVar("{$image}:width") . 'px;'
                                    . 'top:' . $block->getVar("{$image}:height") . 'px;"';
                        }
                        ?>
                        <div class="block-content">
                            <div class="wrapper <?php echo $viewMode; ?> products-<?php echo $viewMode; ?>">
                                <?php $iterator = 1; ?>
                                <?php $procount = 1; ?>
                                <div class="row">
                                    <ol class="list items product-items porduct-slider">
                                        <?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
                                        <?php foreach ($_productCollection as $_product): ?>

                                            <?php
                                            $todaydate = strtotime(date('Y-m-d'));
                                            $start_date = strtotime($_product['special_from_date']);
                                            $end_date = strtotime($_product['special_to_date']);
                                            $price = $_product['price'];
                                            $sp_price = $_product['special_price'];
                                            ?>
                                            <?php if (($sp_price < $price) && ($todaydate >= $start_date) && ($todaydate <= $end_date)) { ?>
                                                <?php //if ($procount <= $ProductLimit) { ?>
                                                <?php echo($iterator++ == 1) ? '<li style="margin-bottom:2px;" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-item">' : '</li><li style="margin-bottom:2px;" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-item">' ?>
                                                <div class="product-item-info" data-container="product-grid">
                                                    <?php // Product Image         ?>
                                                    <a href="<?php echo $_product->getProductUrl(); ?>" tabindex="-1">
                                                        <?php
                                                        if ($Enable_aspect_ratio) {
                                                            $productImage = $_imagehelper->init($_product, $image)
                                                                    ->constrainOnly(FALSE)
                                                                    ->keepAspectRatio(TRUE)
                                                                    ->keepFrame(FALSE)
                                                                    ->resize($img_width);
                                                        } else {
                                                            $productImage = $_imagehelper->init($_product, $image)
                                                                    ->resize($img_width, $img_height);
                                                        }
                                                        $productImageUrl = $productImage->getUrl();
                                                        ?>
                                                        <img class="product-image-photo pd-img" src="<?php echo $productImageUrl; ?>" alt="<?php echo $productImage->getLabel(); ?>"/>
                                                        <?php if ($show_alternative_image) { ?>
                                                            <?php
                                                            if ($Enable_aspect_ratio) {
                                                                $productHoverImage = $_imagehelper->init($_product, $hover_img)
                                                                        ->constrainOnly(FALSE)
                                                                        ->keepAspectRatio(TRUE)
                                                                        ->keepFrame(FALSE)
                                                                        ->resize($img_width);
                                                            } else {
                                                                $productHoverImage = $_imagehelper->init($_product, $hover_img)
                                                                        ->resize($img_width, $img_height);
                                                            }
                                                            $productHoverImageUrl = $productHoverImage->getUrl();
                                                            ?>
                                                            <img class="product-image-photo ph_img" src="<?php echo $productHoverImageUrl; ?>" alt="<?php echo $productHoverImage->getLabel(); ?>"/>
                                                        <?php } ?>
                                                        <?php
                                                        /**
                                                         * Check if "new" label is enabled and if product has from new date & to new date
                                                         */
                                                        if ($isNewLabel) {
                                                            $fromDate = $_product->getNewsFromDate();
                                                            $toDate = $_product->getNewsToDate();
                                                            if (isset($fromDate) && isset($toDate)) {
                                                                $fromDate = strtotime($fromDate);
                                                                $toDate = strtotime($toDate);
                                                                $now = strtotime(date("Y-m-d h:m:s"));

                                                                if ($fromDate <= $now && $now <= $toDate) {
                                                                    ?>
                                                                    <span class="new-lbl">New</span>
                                                                    <?php
                                                                }
                                                            }
                                                        }
                                                        ?>
                                                        <?php
                                                        /**
                                                         * Check if "sale" label is enabled and if product has special price with from & to special price
                                                         */
                                                        if ($isSaleLabel) {
                                                            $special_price = number_format($_product->getSpecialPrice(), 2);
                                                            $regular_price = number_format($_product->getPrice(), 2);
                                                            if (isset($special_price) && $special_price > 0) {
                                                                if ($special_price < $regular_price) {
                                                                    $fromSpecialDate = $_product->getSpecialFromDate();
                                                                    $toSpecialDate = $_product->getSpecialToDate();

                                                                    if (isset($fromSpecialDate) && isset($toSpecialDate)) {
                                                                        $fromSpecialDate = strtotime($fromSpecialDate);
                                                                        $toSpecialDate = strtotime($toSpecialDate);
                                                                        $now = strtotime(date("Y-m-d h:m:s"));

                                                                        if ($fromSpecialDate <= $now && $now <= $toSpecialDate) {
                                                                            ?>
                                                                            <span class="sale-lbl">Sale</span>
                                                                            <?php
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        ?>
                                                    </a>
                                                    <div class="product details product-item-details">
                                                        <?php
                                                        $_productNameStripped = $block->stripTags($_product->getName(), null, true);
                                                        ?>
                                                        <strong class="product name product-item-name">
                                                            <a class="product-item-link"
                                                               href="<?php echo $_product->getProductUrl() ?>">
                                                                   <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                                                            </a>
                                                        </strong>

                                                        <div data-countdown="<?php echo date('Y/m/d', strtotime($_product->getSpecialToDate())); ?>" class="timer"></div>
                                                        <script>
                                                            require(['jquery', 'cpplugin', 'cpcountdown'], function () {
                                                                jQuery(document).ready(function () {
                                                                    jQuery('[data-countdown]').each(function () {
                                                                        var $this = jQuery(this), finaldate = jQuery(this).data('countdown');
                                                                        finaldate = new Date(finaldate);
                                                                        jQuery(this).countdown({until: finaldate, padZeroes: true});
                                                                    });
                                                                });
                                                            });
                                                        </script>
                                                        <?php if ($show_rating_star) { ?>
                                                            <?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
                                                        <?php } ?>
                                                        <?php if ($show_product_price) { ?>
                                                            <?php echo $block->getProductPrice($_product) ?>
                                                        <?php } ?>
                                                        <?php echo $block->getProductDetailsHtml($_product); ?>

                                                        <?php if ($show_actions) { ?>
                                                            <div class="product-item-inner">
                                                                <div class="product actions product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
                                                                    <div class="actions-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
                                                                        <?php if ($_product->isSaleable()): ?>
                                                                            <?php $postParams = $block->getAddToCartPostParams($_product); ?>
                                                                            <form data-role="tocart-form" action="<?php echo $postParams['action']; ?>" method="post">
                                                                                <input type="hidden" name="product" value="<?php echo $postParams['data']['product']; ?>">
                                                                                <input type="hidden" name="<?php echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                                                                <?php echo $block->getBlockHtml('formkey') ?>
                                                                                <button type="submit"
                                                                                        title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
                                                                                        class="action tocart primary">
                                                                                    <span><?php echo __('Add to Cart') ?></span>
                                                                                </button>
                                                                            </form>
                                                                        <?php else: ?>
                                                                            <?php if ($_product->getIsSalable()): ?>
                                                                                <div class="stock available"><span><?php echo __('In stock') ?></span></div>
                                                                            <?php else: ?>
                                                                                <div class="stock unavailable"><span><?php echo __('Out of stock') ?></span></div>
                                                                            <?php endif; ?>
                                                                        <?php endif; ?>
                                                                    </div>
                                                                    <div data-role="add-to-links" class="actions-secondary"<?php echo strpos($pos, $viewMode . '-secondary') ? $position : ''; ?>>
                                                                        <?php if ($show_addtowishlist) { ?>
                                                                            <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
                                                                                <a href="#"
                                                                                   class="action towishlist"
                                                                                   title="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
                                                                                   aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
                                                                                   data-post='<?php echo $block->getAddToWishlistParams($_product); ?>'
                                                                                   data-action="add-to-wishlist"
                                                                                   role="button">
                                                                                    <span><?php echo __('Add to Wish List') ?></span>
                                                                                </a>
                                                                            <?php endif; ?>
                                                                        <?php } ?>
                                                                        <?php if ($show_addtocompare) { ?>
                                                                            <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare'); ?>
                                                                            <a href="#"
                                                                               class="action tocompare"
                                                                               title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
                                                                               aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
                                                                               data-post='<?php echo $compareHelper->getPostDataParams($_product); ?>'
                                                                               role="button">
                                                                                <span><?php echo __('Add to Compare') ?></span>
                                                                            </a>
                                                                        <?php } ?>
                                                                        <?php if ($show_productview) { ?>
                                                                            <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"
                                                                               class="action cus-addto toview"
                                                                               title="<?php echo $block->escapeHtml(__('View')); ?>"
                                                                               aria-label="<?php echo $block->escapeHtml(__('View')); ?>"
                                                                               role="button">
                                                                                <span><?php /* @escapeNotVerified */ echo __('View') ?></span>
                                                                                <div class="span-hov"></div>
                                                                            </a>
                                                                        <?php } ?>
                                                                    </div>
                                                                </div>
                                                                <?php if ($showDescription): ?>
                                                                    <div class="product description product-item-description">
                                                                        <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                                                                        <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>"
                                                                           class="action more"><?php echo __('Learn More') ?></a>
                                                                    </div>
                                                                <?php endif; ?>
                                                            </div>
                                                        <?php } ?>
                                                    </div>
                                                </div>
                                                <?php echo($iterator == count($_productCollection) + 1) ? '</li>' : '' ?>
                                                <?php //} ?>
                                                <?php //$procount++; ?>
                                            <?php } ?>
                                        <?php endforeach; ?>
                                    </ol>
                                </div>
                            </div>
                        </div>
                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                            <script type="text/x-magento-init">
                                {
                                "[data-role=tocart-form], .form.map.checkout": {
                                "catalogAddToCart": {}
                                }
                                }
                            </script>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>
            <?php } ?>
            <?php if ($enable_featured) { ?>
                <div id="hcontent_<?php echo $featured_order; ?>" class="ht-inner owl-btn-top">
                    <label style="display: none;"><?php echo $featured_order; ?></label>
                    <?php
                    $_productCollection = $block->getFeaturedLoadedProductCollection();
                    $_helper = $this->helper('Magento\Catalog\Helper\Output');
                    $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\Image');
                    ?>
                    <?php if (!$_productCollection->count()): ?>
                        <div class="message info empty"><div><?php echo __('We can\'t find products matching the selection.') ?></div></div>
                    <?php else: ?>
                        <?php
                        if ($block->getMode() == 'grid') {
                            $viewMode = 'grid';
                            $image = 'category_page_grid';
                            $hover_img = 'category_page_grid_hover';
                            $showDescription = false;
                            $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW;
                        } else {
                            $viewMode = 'list';
                            $image = 'category_page_list';
                            $hover_img = 'category_page_list_hover';
                            $showDescription = true;
                            $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::FULL_VIEW;
                        }
                        $pos = $block->getPositioned();
                        $position = '';
                        if ($pos != null) {
                            $position = ' style="left:' . $block->getVar("{$image}:width") . 'px;'
                                    . 'top:' . $block->getVar("{$image}:height") . 'px;"';
                        }
                        ?>
                        <div class="block-content">
                            <div class="wrapper <?php echo $viewMode; ?> products-<?php echo $viewMode; ?>">
                                <?php $iterator = 1; ?>
                                <div class="row">
                                    <ol class="list items product-items porduct-slider">
                                        <?php /** @var $_product \Magento\Catalog\Model\Product */ ?>
                                        <?php foreach ($_productCollection as $_product): ?>
                                            <?php echo($iterator++ == 1) ? '<li style="margin-bottom:2px;" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-item">' : '</li><li style="margin-bottom:2px;" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 product-item">' ?>
                                            <div class="product-item-info" data-container="product-grid">
                                                <?php // Product Image         ?>
                                                <a href="<?php echo $_product->getProductUrl(); ?>" tabindex="-1">
                                                    <?php
                                                    if ($Enable_aspect_ratio) {
                                                        $productImage = $_imagehelper->init($_product, $image)
                                                                ->constrainOnly(FALSE)
                                                                ->keepAspectRatio(TRUE)
                                                                ->keepFrame(FALSE)
                                                                ->resize($img_width);
                                                    } else {
                                                        $productImage = $_imagehelper->init($_product, $image)
                                                                ->resize($img_width, $img_height);
                                                    }
                                                    $productImageUrl = $productImage->getUrl();
                                                    ?>
                                                    <img class="product-image-photo pd-img" src="<?php echo $productImageUrl; ?>" alt="<?php echo $productImage->getLabel(); ?>"/>
                                                    <?php if ($show_alternative_image) { ?>
                                                        <?php
                                                        if ($Enable_aspect_ratio) {
                                                            $productHoverImage = $_imagehelper->init($_product, $hover_img)
                                                                    ->constrainOnly(FALSE)
                                                                    ->keepAspectRatio(TRUE)
                                                                    ->keepFrame(FALSE)
                                                                    ->resize($img_width);
                                                        } else {
                                                            $productHoverImage = $_imagehelper->init($_product, $hover_img)
                                                                    ->resize($img_width, $img_height);
                                                        }
                                                        $productHoverImageUrl = $productHoverImage->getUrl();
                                                        ?>
                                                        <img class="product-image-photo ph_img" src="<?php echo $productHoverImageUrl; ?>" alt="<?php echo $productHoverImage->getLabel(); ?>"/>
                                                    <?php } ?>
                                                    <?php
                                                    /**
                                                     * Check if "new" label is enabled and if product has from new date & to new date
                                                     */
                                                    if ($isNewLabel) {
                                                        $fromDate = $_product->getNewsFromDate();
                                                        $toDate = $_product->getNewsToDate();
                                                        if (isset($fromDate) && isset($toDate)) {
                                                            $fromDate = strtotime($fromDate);
                                                            $toDate = strtotime($toDate);
                                                            $now = strtotime(date("Y-m-d h:m:s"));

                                                            if ($fromDate <= $now && $now <= $toDate) {
                                                                ?>
                                                                <span class="new-lbl">New</span>
                                                                <?php
                                                            }
                                                        }
                                                    }
                                                    ?>
                                                    <?php
                                                    /**
                                                     * Check if "sale" label is enabled and if product has special price with from & to special price
                                                     */
                                                    if ($isSaleLabel) {
                                                        $special_price = number_format($_product->getSpecialPrice(), 2);
                                                        $regular_price = number_format($_product->getPrice(), 2);
                                                        if (isset($special_price) && $special_price > 0) {
                                                            if ($special_price < $regular_price) {
                                                                $fromSpecialDate = $_product->getSpecialFromDate();
                                                                $toSpecialDate = $_product->getSpecialToDate();

                                                                if (isset($fromSpecialDate) && isset($toSpecialDate)) {
                                                                    $fromSpecialDate = strtotime($fromSpecialDate);
                                                                    $toSpecialDate = strtotime($toSpecialDate);
                                                                    $now = strtotime(date("Y-m-d h:m:s"));

                                                                    if ($fromSpecialDate <= $now && $now <= $toSpecialDate) {
                                                                        ?>
                                                                        <span class="sale-lbl">Sale</span>
                                                                        <?php
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                    ?>
                                                </a>
                                                <div class="product details product-item-details">
                                                    <?php
                                                    $_productNameStripped = $block->stripTags($_product->getName(), null, true);
                                                    ?>
                                                    <strong class="product name product-item-name">
                                                        <a class="product-item-link"
                                                           href="<?php echo $_product->getProductUrl() ?>">
                                                               <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                                                        </a>
                                                    </strong>
                                                    <?php if ($show_rating_star) { ?>
                                                        <?php echo $block->getReviewsSummaryHtml($_product, $templateType); ?>
                                                    <?php } ?>
                                                    <?php if ($show_product_price) { ?>
                                                        <?php echo $block->getProductPrice($_product) ?>
                                                    <?php } ?>
                                                    <?php echo $block->getProductDetailsHtml($_product); ?>

                                                    <?php if ($show_actions) { ?>
                                                        <div class="product-item-inner">
                                                            <div class="product actions product-item-actions"<?php echo strpos($pos, $viewMode . '-actions') ? $position : ''; ?>>
                                                                <div class="actions-primary"<?php echo strpos($pos, $viewMode . '-primary') ? $position : ''; ?>>
                                                                    <?php if ($_product->isSaleable()): ?>
                                                                        <?php $postParams = $block->getAddToCartPostParams($_product); ?>
                                                                        <form data-role="tocart-form" action="<?php echo $postParams['action']; ?>" method="post">
                                                                            <input type="hidden" name="product" value="<?php echo $postParams['data']['product']; ?>">
                                                                            <input type="hidden" name="<?php echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                                                            <?php echo $block->getBlockHtml('formkey') ?>
                                                                            <button type="submit"
                                                                                    title="<?php echo $block->escapeHtml(__('Add to Cart')); ?>"
                                                                                    class="action tocart primary">
                                                                                <span><?php echo __('Add to Cart') ?></span>
                                                                            </button>
                                                                        </form>
                                                                    <?php else: ?>
                                                                        <?php if ($_product->getIsSalable()): ?>
                                                                            <div class="stock available"><span><?php echo __('In stock') ?></span></div>
                                                                        <?php else: ?>
                                                                            <div class="stock unavailable"><span><?php echo __('Out of stock') ?></span></div>
                                                                        <?php endif; ?>
                                                                    <?php endif; ?>
                                                                </div>
                                                                <div data-role="add-to-links" class="actions-secondary"<?php echo strpos($pos, $viewMode . '-secondary') ? $position : ''; ?>>
                                                                    <?php if ($show_addtowishlist) { ?>
                                                                        <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow()): ?>
                                                                            <a href="#"
                                                                               class="action towishlist"
                                                                               title="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
                                                                               aria-label="<?php echo $block->escapeHtml(__('Add to Wish List')); ?>"
                                                                               data-post='<?php echo $block->getAddToWishlistParams($_product); ?>'
                                                                               data-action="add-to-wishlist"
                                                                               role="button">
                                                                                <span><?php echo __('Add to Wish List') ?></span>
                                                                            </a>
                                                                        <?php endif; ?>
                                                                    <?php } ?>
                                                                    <?php if ($show_addtocompare) { ?>
                                                                        <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare'); ?>
                                                                        <a href="#"
                                                                           class="action tocompare"
                                                                           title="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
                                                                           aria-label="<?php echo $block->escapeHtml(__('Add to Compare')); ?>"
                                                                           data-post='<?php echo $compareHelper->getPostDataParams($_product); ?>'
                                                                           role="button">
                                                                            <span><?php echo __('Add to Compare') ?></span>
                                                                        </a>
                                                                    <?php } ?>
                                                                    <?php if ($show_productview) { ?>
                                                                        <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>"
                                                                           class="action cus-addto toview"
                                                                           title="<?php echo $block->escapeHtml(__('View')); ?>"
                                                                           aria-label="<?php echo $block->escapeHtml(__('View')); ?>"
                                                                           role="button">
                                                                            <span><?php /* @escapeNotVerified */ echo __('View') ?></span>
                                                                            <div class="span-hov"></div>
                                                                        </a>
                                                                    <?php } ?>
                                                                </div>
                                                            </div>
                                                            <?php if ($showDescription): ?>
                                                                <div class="product description product-item-description">
                                                                    <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
                                                                    <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>"
                                                                       class="action more"><?php echo __('Learn More') ?></a>
                                                                </div>
                                                            <?php endif; ?>
                                                        </div>
                                                    <?php } ?>
                                                </div>
                                            </div>
                                            <?php echo($iterator == count($_productCollection) + 1) ? '</li>' : '' ?>
                                        <?php endforeach; ?>
                                    </ol>
                                </div>
                            </div>
                        </div>
                        <?php if (!$block->isRedirectToCartEnabled()) : ?>
                            <script type="text/x-magento-init">
                                {
                                "[data-role=tocart-form], .form.map.checkout": {
                                "catalogAddToCart": {}
                                }
                                }
                            </script>
                        <?php endif; ?>
                    <?php endif; ?>
                </div>
            <?php } ?>
        </div>
        <script type="text/javascript">
            require([
                'jquery'
            ], function () {
                jQuery(document).ready(function () {

                    var divs = jQuery(".ht-tab-content div.ht-inner");
                    var numericallyOrderedDivs = divs.sort(function (a, b) {
                        return jQuery(a).find("label").text() > jQuery(b).find("label").text();
                    });
                    jQuery(".ht-tab-content").html(numericallyOrderedDivs);

                    var divs = jQuery(".ht-main-ul li.ht-tab");
                    var numericallyOrderedLis = divs.sort(function (a, b) {
                        return jQuery(a).find("label").text() > jQuery(b).find("label").text();
                    });
                    jQuery(".ht-main-ul").html(numericallyOrderedLis);

                    jQuery('.ht-tab-content #hcontent_1').addClass('htc-active');
                    jQuery('.ht-tab-content #hcontent_2').addClass('htc-active');
                    jQuery('.ht-tab-content #hcontent_3').addClass('htc-active');
                    jQuery('.ht-tab-content .ht-inner').removeClass('htc-active');
                    jQuery('.ht-tab-content .ht-inner:first-child').addClass('htc-active');
                    jQuery('.ht-main .ht-tab:first-child').addClass('ht-active');
                    jQuery('[id^=htab_]').click(function () {
                        var temp_id = jQuery(this).attr('id');
                        var id_num = temp_id.split('_');
                        var fin_id = id_num[1];
                        jQuery('.ht-main .ht-tab').removeClass('ht-active');
                        jQuery('.ht-tab-content .ht-inner').removeClass('htc-active');
                        jQuery('.ht-main #htab_' + fin_id).addClass('ht-active');
                        jQuery('.ht-tab-content #hcontent_' + fin_id).addClass('htc-active');
                    });
                });
            });
        </script>
        <style>
            .ht-wrapper .owl-item {
                transition-duration: 0s;
                transition-delay: 0s;
            }
        </style>
        <script>
            require(['jquery', 'cpowlcarousel'], function () {
                jQuery(document).ready(function () {
                    jQuery(".porduct-slider").owlCarousel({
                        items: <?php echo $list_blocks; ?>,
                        itemsDesktop: [1198, 4],
                        itemsDesktopSmall: [1023, 3],
                        itemsTablet: [768, 3],
                        itemsTabletSmall: [767, 2],
                        itemsMobile: [479, 1],
                        pagination: false,
                        navigationText: ["<div class='lft-btn'><i class='fa fa-angle-left'></i></div>", "<div class='rgt-btn'><i class='fa fa-angle-right'></div>"],
                        navigation: true,
                    });
                });
            });
        </script>
    </div>
<?php } ?>