{% extends 'layout.html.twig' %}
{% block title %}{{ 'service.marketplace'|trans }}{% endblock %}
{% block page_contents %}
<div class="marketplaceWrapper">
<!-- department path -->
<div class="departmentPath">
{% set depCount = 0 %}
{% for dep in departmentPath %}
{% if depCount == 0 %}
<a href="{{ path('root') }}marketplace" class="pathLink">{{ 'eshop.home'|trans }}</a>
{% endif %}
{% set depCount = depCount + 1 %}
{% if depCount == departmentPath|length %}
<span class="pathSeparator">|</span> <a href="{{ path('root') }}marketplace/department/{{ dep.departmentId }}" class="pathLinkCurrent">{{ dep.departmentName }}</a>
{% else %}
<span class="pathSeparator">|</span> <a href="{{ path('root') }}marketplace/department/{{ dep.departmentId }}" class="pathLink">{{ dep.departmentName }}</a>
{% endif %}
{% endfor %}
</div>
<table width="100%">
<tr>
<td><h1>{{ department.departmentName }}</h1></td>
<td> </td>
<td>
<a href="{{ path('root') }}addproducts" class="newButtonLink">{{ 'module.eshopLink_add'|trans }}</a>
</td>
<td>
<!-- Search form -->
{% set smallPanel = true %}
{{ include('searchForm.html.twig') }}
</td>
</tr>
</table>
<div class="departmentsContainer">
{% for dep in childDepartments %}
{% set departmentId = dep.departmentId %}
<a href="{{ path('root') }}marketplace/department/{{ dep.departmentId }}" class="departmentLink">
<div class="departmentBox2">
{% if dep.image1 is defined and dep.image1 != "" %}
<div class="departmentImage">
{% set imagePath = 'images/' ~ dep.image1 %}
<!-- we display department image -->
<img src="{{ asset(imagePath) }}" alt="Department Image" border="0">
</div>
{% endif %}
<div class="departmentTitle">{{ dep.departmentName }}</div>
<div class="subDepartments">
{% set subDepCount = 0 %}
{% set subDeps = subDepartments[departmentId] %}
{% for subDep in subDeps %}
{% set subDepId = subDep.departmentId %}
{% if subDepCount < 3 %}
<div class="subDepartmentBox">
<a href="{{ path('root') }}marketplace/department/{{ subDepId }}" class="subDepartmentLink">{{ subDep.departmentName }}</a>
</div>
{% endif %}
{% set subDepCount = subDepCount + 1 %}
{% endfor %}
</div>
</div>
</a>
{% endfor %}
</div>
<!-- product list -->
<div class="productContainer">
<div class="products"><h3>{{ 'eshop.products'|trans }}</h3></div>
<!-- navigator -->
<div class="navigator">
<div class="paginator">
{% set countPerPage = 20 %}
{% set pageCount = productCount / countPerPage %}
{% set pageTotal = pageCount|round(0, 'ceil') %}
{% if pageTotal == 0 %}
{% set pageTotal = pageTotal + 1 %}
{% endif %}
{% if app.request.get('page') is defined and app.request.get('page') > 0 %}
{% set currentPage = app.request.get('page') %}
{% else %}
{% set currentPage = 1 %}
{% endif %}
<span class="smallDescription">{{ 'system.pages'|trans }}: {{ currentPage }}/{{ pageTotal }}</span>
{% set scheme = app.request.scheme %}
{% set host = app.request.host %}
{% set port = app.request.port %}
{% set startPage = 1 %}
{% if pageTotal > 12 %}
{% set pagesDisplayed = 12 %}
{% set endPage = startPage + 11 %}
{% else %}
{% set pagesDisplayed = pageTotal %}
{% set endPage = pageTotal %}
{% endif %}
{% if app.request.get('page') is defined and app.request.get('page') != '' and app.request.get('page') > endPage %}
{# <br>---- is request page#}
{% set startPage = app.request.get('page') - 5 %}
{% set endPage = startPage + 11 %}
{% endif %}
{% if startPage > 1 %}
<span class="smallMenu">
{# prev page link #}
<a href="{{ scheme }}://{{ host }}{{ app.request.pathinfo }}?page={{ (startPage - 5) }}" class="pageLink"><</a>
</span>
{% endif %}
{# <br>qqw page: {{ dump(app.request.get('page')) }}#}
{% for i in startPage..endPage %}
{% if app.request.get('page') is defined and app.request.get('page') == i %}
{% set cssClass = 'pageLinkCurrent' %}
{% elseif app.request.get('page') == null and i == 1 %}
{% set cssClass = 'pageLinkCurrent' %}
{% else %}
{% set cssClass = 'pageLink' %}
{% endif %}
<a href="{{ scheme }}://{{ host }}{{ app.request.pathinfo }}?page={{ i }}" class="{{ cssClass }}">{{ i }}</a>
{% endfor %}
{% if pageTotal > 12 %}
<span class="smallMenu">
{# next page link #}
<a href="{{ scheme }}://{{ host }}{{ app.request.pathinfo }}?page={{ (endPage + 1) }}" class="pageLink">></a>
</span>
<span class="smallMenu">
{# first page link #}
<a href="{{ scheme }}://{{ host }}{{ app.request.pathinfo }}?page=1" class="pageLink"><<</a>
{# last page link #}
<a href="{{ scheme }}://{{ host }}{{ app.request.pathinfo }}?page={{ pageTotal }}" class="pageLink">>></a>
</span>
{% endif %}
</div>
<div class="clearPaginator">
</div>
</div>
{% for product in productList %}
{# {% for price in product.prices %}#}
{# {% set displayPrice = price.nettoValue|round(2, 'ceil') %}#}
{# {% endfor %}#}
{# we get price(s) to display #}
{% set displayPrice = null %}
{% set displayPriceVAT = null %}
{% for price in productPriceList %}
{% if price.productId == product.productId %}
{# we get default price level #}
{% if price.priceLevelId == 1 %}
{% set displayPrice = price.nettoValue|round(2, 'ceil') %}
{# {% set displayPrice = price.bruttoValue|round(2, 'ceil') %}#}
{% endif %}
{% endif %}
{% endfor %}
<div class="productPanel">
<div class="productImage">
{% if product.image1 is defined %}
<a href="{{ path('root') }}marketplace/product/{{ product.productId }}">
<img src="{{ product.image1 }}" class="marketplaceProductImage" alt="Product Image" border="0">
</a>
{% endif %}
</div>
<div class="productDetail">
<a href="{{ path('root') }}marketplace/product/{{ product.productId }}" class="productLink">{{ product.productName }}</a>
<div class="productDescription">
{% if product.productDescription|length > 200 %}
{% set productDescription = product.productDescription|slice(0, 200) ~ "..." %}
{% else %}
{% set productDescription = product.productDescription %}
{% endif %}
{{ productDescription|striptags }}
</div>
</div>
<div class="productBasket">
<div class="productPrice">{{ displayPrice }} CZK</div>
<div class="productToBasket">
<a href="{{ path('root') }}marketplace/product/{{ product.productId }}" class="viewProductLink">{{ 'system.view'|trans }}</a>
</div>
<div class="productToBasket">
<a href="{{ path('root') }}marketplace/product/{{ product.productId }}?redirect_to_eshop={{ product.productLink }}" target="_blank" class="viewProductLink">{{ 'service.eshop'|trans }}</a>
</div>
</div>
</div>
{% endfor %}
<!-- navigator -->
<div class="navigator">
<div class="paginator">
<span class="smallDescription">pages {{ currentPage }}/{{ pageTotal }}</span>
{% for i in startPage..endPage %}
{% if app.request.get('page') is defined and app.request.get('page') == i %}
{% set cssClass = 'pageLinkCurrent' %}
{% elseif app.request.get('page') == null and i == 1 %}
{% set cssClass = 'pageLinkCurrent' %}
{% else %}
{% set cssClass = 'pageLink' %}
{% endif %}
<a href="{{ scheme }}://{{ host }}{{ app.request.pathinfo }}?page={{ i }}" class="{{ cssClass }}">{{ i }}</a>
{% endfor %}
</div>
<div class="clearPaginator">
</div>
</div>
{% if productCount == 0 %}
<br><br>
{% set actionBannerPath = 'images/banners/VirtualRealityCommerceCZ-ActionBanner001.jpg' %}
{# we display Action banner image#}
<div class="banner">
<a href="{{ path('root') }}addproducts">
<img src="{{ asset(actionBannerPath) }}" alt="Action banner" border="0" class="bannerImage">
</a>
</div>
{% endif %}
</div>
<div class="eshopLinkList">
<div class="eshopLinks"><h3>{{ 'module.eshopLinks'|trans }}</h3></div>
{% for eshopLink in eshopLinkList %}
<div class="eshopLinkPanel">
{% if eshopLink.logoUrl is defined and eshopLink.logoUrl != '' %}
<div class="eshopLinkLogo">
<a href="{{ path('root') }}marketplace/eshop/{{ eshopLink.eshopLinkId }}?redirect_to_eshop={{ eshopLink.eshopLinkUrl }}" target="_blank">
<img src="{{ eshopLink.logoUrl }}" width="150" alt="E-shop Logo">
</a>
</div>
{% endif %}
<div class="eshopLinkDetail">
<a href="{{ path('root') }}marketplace/eshop/{{ eshopLink.eshopLinkId }}?redirect_to_eshop={{ eshopLink.eshopLinkUrl }}" target="_blank" class="eshopLink">{{ eshopLink.eshopLinkName }}</a>
<div class="eshopLinkDescription">{{ eshopLink.eshopLinkDescription }}</div>
</div>
</div>
{% endfor %}
</div>
<br>
</div>
{% endblock %}