{% if wireFrame.wireFrameFile is defined and wireFrame.wireFrameFile != null %}
{% set wireFrameFile = wireFrame.wireFrameFile %}
{% else %}
{% set wireFrameFile = 'eshopLayoutFlat.html.twig' %}
{% endif %}
{% extends wireFrameFile %}
{% block title %}{{ 'eshop.search'|trans|raw }}{% endblock %}
{% block page_contents %}
<h1>{{ 'eshop.search'|trans }}</h1>
<div class="eshopHeading">{{ 'eshop.search_string'|trans }}: {{ searchString }}</div>
{% set productTemplate = 'eshopProduct_' ~ productView ~'.html.php' %}
<h4>{{ 'eshop.categories'|trans }}</h4>
<!-- category list -->
<div class="categoryContainer">
<?php
foreach($categoryList as $category) {
print($category->getCategoryName());
}
?>
</div>
<h4><?= $view['translator']->trans('eshop.products') ?></h4>
<!-- navigator -->
<div class="navigator">
<div class="paginator">
<?php
if(!empty($eshop->getCountPerPage())) {
$countPerPage = $eshop->getCountPerPage();
} else {
$countPerPage = 20;
}
$pageCount = $productCount / $countPerPage;
$pageTotal = ceil($pageCount);
if($pageTotal == 0) {
$pageTotal++;
}
/*
print('<br>qqw countPerPage: '.$countPerPage);
print('<br>qqw productCount: '.$productCount);
print('<br>qqw pageTotal: '.$pageTotal);
*/
/* we get current page */
if(!empty($app->getRequest()->get('page')) && $app->getRequest()->get('page') > 0) {
$currentPage = $app->getRequest()->get('page');
} else {
$currentPage = 1;
}
?>
<span class="smallDescription"><?= $view['translator']->trans('system.pages') ?>: <?= $currentPage ?>/<?= $pageTotal ?></span>
<?php
$scheme = $app->getRequest()->getScheme(); //This will return https
$host = $app->getRequest()->getHost(); // This will return www.yoursite.com
for ($i = 1; $i <= $pageTotal; $i++) {
if(!empty($app->getRequest()->get('page')) && $app->getRequest()->get('page') == $i) {
$cssClass = 'pageLinkCurrent';
} elseif(empty($app->getRequest()->get('page')) && $i == 1) {
$cssClass = 'pageLinkCurrent';
} else {
$cssClass = 'pageLink';
}
?>
<a href="<?= $scheme ?>://<?= $host ?><?= $app->getRequest()->getPathInfo() ?>?page=<?= $i ?>" class="<?= $cssClass ?>"><?= $i ?></a>
<?php
}
?>
</div>
<div class="clearPaginator">
</div>
</div>
<!-- product list -->
<div class="productContainer">
<?php
foreach($productList as $product) {
/* we load VAT */
$productVAT = null;
if(!empty($product) && !empty($product->getProductVAT()) && $product->getProductVAT() > 0) {
/* VAT is derived from productVAT */
$productVAT = $product->getProductVAT();
} elseif(!empty($eshop->getPreferredVAT()) && $eshop->getPreferredVAT() > 0) {
/* VAT is derived from eshop VAT */
$productVAT = $eshop->getPreferredVAT();
}
/* we get price(s) to display */
$displayPrice = null;
$displayPriceVAT = null;
foreach($productPriceList as $price) {
if($price->getProductId() == $product->getProductId()) {
//print("<br>price product id: ".$price->getProductId());
/* we get price level according to logged contact-customer */
if(!empty($view['session']->get('contact')) && !empty($view['session']->get('contact')->getPriceLevel()) && $price->getPriceLevelId()==$view['session']->get('contact')->getPriceLevel()->getPriceLevelId()) {
/* we get netto or brutto value according to e-shop configuration */
if(!empty($eshop->getDisplayNettoPrices()) && $eshop->getDisplayNettoPrices()==true) {
$displayPrice = round($price->getNettoValue(),$eshop->getRoundPrice());
} else {
$displayPrice = round($price->getBruttoValue(),$eshop->getRoundPrice());
}
if(!empty($eshop->getDisplayNettoPrices()) && $eshop->getDisplayNettoPrices()==true) {
$displayPriceVAT = $displayPrice + ($displayPrice * ($productVAT/100));
$displayPriceVATLabel = $view['translator']->trans('product.price_with_VAT');
} else {
$displayPriceVAT = $displayPrice - ($displayPrice * ($productVAT/100));
$displayPriceVATLabel = $view['translator']->trans('product.price_without_VAT');
}
} elseif($price->getPriceLevelId() == 1) {
/* we get default price level */
/* we get netto or brutto value according to e-shop configuration */
if(!empty($eshop->getDisplayNettoPrices()) && $eshop->getDisplayNettoPrices()==true) {
$displayPrice = round($price->getNettoValue(),$eshop->getRoundPrice());
} else {
$displayPrice = round($price->getBruttoValue(),$eshop->getRoundPrice());
}
if(!empty($eshop->getDisplayNettoPrices()) && $eshop->getDisplayNettoPrices()==true) {
$displayPriceVAT = $displayPrice + ($displayPrice * ($productVAT/100));
$displayPriceVATLabel = $view['translator']->trans('product.price_with_VAT');
} else {
$displayPriceVAT = $displayPrice - ($displayPrice * ($productVAT/100));
$displayPriceVATLabel = $view['translator']->trans('product.price_without_VAT');
}
//$displayPrice = round($price->getBruttoValue(),$eshop->getRoundPrice());
}
}
}
?>
<!-- product template -->
<?php
echo $view->render($productTemplate, array('product' => $product,
'eshop' => $eshop,
'displayPrice' => $displayPrice,
'displayPriceVAT' => $displayPriceVAT,
'productVAT' => $productVAT,
'productThumbs' => $productThumbs,
'user' => $user,
'app' => $app,
'searchString' => $searchString,
)
)
?>
<?php
}
?>
</div>
<!-- navigator -->
<div class="navigator">
<div class="paginator">
<?php
$pageCount = $productCount / $countPerPage;
?>
<span class="smallDescription">pages <?= $currentPage ?>/<?= $pageTotal ?></span>
<?php
$scheme = $app->getRequest()->getScheme(); //This will return https
$host = $app->getRequest()->getHost(); //This will return www.yoursite.com
for ($i = 1; $i <= $pageTotal; $i++) {
if(!empty($app->getRequest()->get('page')) && $app->getRequest()->get('page') == $i) {
$cssClass = 'pageLinkCurrent';
} elseif(empty($app->getRequest()->get('page')) && $i == 1) {
$cssClass = 'pageLinkCurrent';
} else {
$cssClass = 'pageLink';
}
?>
<a href="<?= $scheme ?>://<?= $host ?><?= $app->getRequest()->getPathInfo() ?>?page=<?= $i ?>" class="<?= $cssClass ?>"><?= $i ?></a>
<?php
}
?>
</div>
<div class="clearPaginator">
</div>
</div>
{% endblock %}