144 lines
6.2 KiB
Twig
144 lines
6.2 KiB
Twig
{% extends "template.html.twig" %}
|
|
|
|
{% block content %}
|
|
<div class="table-responsive">
|
|
<table class='table table-hover'>
|
|
<tr>
|
|
<td class="align-middle font-weight-bold h3"><a class="text-warning text-decoration-none"
|
|
href="{{ path('app_star', {'productId': product.id}) }}">{% if product.starred %}★{% else %} ☆ {% endif %}</a>
|
|
</td>
|
|
<td><img src='{{ product.image }}&width=150' class='border rounded p-1' alt='{{ product.name }}'/></td>
|
|
<td>
|
|
<a href='{{ path('app_product', {'productId': product.id}) }}'
|
|
class="text-decoration-none">{{ product.name }}</a>
|
|
<span class="badge text-bg-light"><a href="{{ path('app_search', {'search': product.subTitle}) }}"
|
|
class="link-underline link-underline-opacity-0 link-dark">{{ product.subTitle }}</a></span>
|
|
{% if product.promotions is not null and product.promotions.hasPromotion %}<a
|
|
href="{{ path('app_promos', {'promo': product.promotions.slug}) }}"><span class="badge bg-info">PROMO: {{ product.promotions.tag }}</span>
|
|
</a>{% endif %}
|
|
</td>
|
|
<td>
|
|
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';">
|
|
<ol class="breadcrumb">
|
|
{% for category in product.categories %}
|
|
<li class="breadcrumb-item" aria-current="page"><a
|
|
class="breadcrumb-item text-decoration-none"
|
|
href="{{ path('app_category', {'category': category}) }}">{{ category }}</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ol>
|
|
</nav>
|
|
</td>
|
|
<td><a href='https://{{ product.country.locale }}.ryobitools.eu{{ product.url }}'>link</a></td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
<div style="width: 800px;">
|
|
<canvas id="price"></canvas>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="5">
|
|
<table class='table table-hover table-sm mb-0'>
|
|
<thead>
|
|
<tr>
|
|
<th>price</th>
|
|
<th>lowest product price in 30 days</th>
|
|
<th colspan='2'>standard price</th>
|
|
<th>Stock</th>
|
|
</tr>
|
|
</thead>
|
|
{% set stock = product.stock().get() %}
|
|
{% for price in product.price %}
|
|
<tr>
|
|
<td>{{ price.price | format_currency(product.country.currency, {}, product.country.locale) }}</td>
|
|
<td>{{ price.lowestProductPrice30Days | format_currency(product.country.currency, {}, product.country.locale) }}</td>
|
|
<td>{{ price.productStandardPrice | format_currency(product.country.currency, {}, product.country.locale) }}</td>
|
|
<td>{{ price.created_at }}</td>
|
|
<td>{{ (stock | findByCreatedAtDate(price.created_at | slice(0,10))).stock ?? '' }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
<script>
|
|
const ctx = document.getElementById('price').getContext('2d');
|
|
|
|
new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: ['{{ price_dates|raw }}'],
|
|
datasets: [
|
|
{
|
|
label: 'Price ({{ product.country.currency }})',
|
|
data: {{ price_list|raw }},
|
|
yAxisID: 'yPrice',
|
|
tension: 0.1,
|
|
borderWidth: 1
|
|
},
|
|
{
|
|
label: 'Stock (units)',
|
|
data: {{ stock_list|raw }},
|
|
yAxisID: 'yStock',
|
|
tension: 0.1,
|
|
borderWidth: 1
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
spanGaps: false,
|
|
responsive: true,
|
|
animation: false,
|
|
scales: {
|
|
x: {
|
|
title: {
|
|
display: true,
|
|
text: 'Date'
|
|
}
|
|
},
|
|
yPrice: {
|
|
type: 'linear',
|
|
position: 'left',
|
|
beginAtZero: true,
|
|
title: {
|
|
display: true,
|
|
text: 'Price ({{ product.country.currency }})'
|
|
},
|
|
grid: {
|
|
drawOnChartArea: false
|
|
}
|
|
},
|
|
yStock: {
|
|
type: 'linear',
|
|
position: 'right',
|
|
beginAtZero: true,
|
|
title: {
|
|
display: true,
|
|
text: 'Stock (units)'
|
|
},
|
|
grid: {
|
|
drawOnChartArea: false
|
|
}
|
|
}
|
|
},
|
|
plugins: {
|
|
legend: {
|
|
display: true,
|
|
position: 'top'
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: 'Price and Stock in time'
|
|
},
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|