{% extends 'base.html.twig' %}{% set menuMode = 'catalog' %}{% set title = product.name %}{% set optimalAvailability = priceCalculator.getOptimalAvailability(product) %}{% block main %} <div class="container-fluid"> <div class="row"> <div class="col-md-6"> <div class="card"> <div class="card-header">Общие сведения</div> <div class="card-body"> <table class="table table-sm table-bordered"> <thead> <tr> <th>Параметр</th> <th>Значение</th> </tr> </thead> <tbody> <tr> <td>ID</td> <td>{{ product.id }}</td> </tr> <tr> <td>Название</td> <td>{{ product.name }}</td> </tr> <tr> <td>Кол-во поставщиков</td> <td>{{ product.availabilities|length }}</td> </tr> <tr> <td>Дата привязки к сайту</td> {% if product.connection is not null %} <td>{{ product.connection.dateConnected|date('d.m.Y H:i:s') }}</td> {% else %} <td>-</td> {% endif %} </tr> </tbody> </table> </div> </div> </div> <div class="col-md-6"> <div class="card"> <div class="card-header">Привязка к сайту</div> <div class="card-body"> {% if product.connection is null %} <div class="alert alert-warning" role="alert"> Привязка товара к сайту отсутствует </div> {% endif %} <form method="POST" action="{{ path('product_connect', {id: product.id}) }}"> <div class="row"> <div class="col-md-12"> <div class="mb-3"> <label for="insales_product_id" class="form-label">ID товара на сайте</label> <input type="number" name="insales_product_id" class="form-control" id="insales_product_id" required value="{{ product.connection.insalesProductId|default('') }}"> </div> </div> <div class="col-md-6"> <div class="mb-3"> <label for="insales_variant_id" class="form-label">ID варианта</label> <input type="number" disabled name="insales_variant_id" class="form-control" id="insales_variant_id" value="{{ product.connection.insalesVariantId|default('') }}"> </div> </div> <div class="col-md-6"> <div class="mb-3"> <label for="insales_sku" class="form-label">SKU</label> <input type="number" disabled name="insales_sku" class="form-control" id="insales_sku" value="{{ product.connection.insalesSku|default('') }}"> </div> </div> {% if product.connection is not null %} <div class="col-md-8"> <div class="d-grid gap-2"> <button class="btn btn-primary" type="submit">Перепривязать</button> </div> </div> <div class="col-md-4"> <div class="d-grid gap-2"> <a class="btn btn-danger" href="{{ path('product_connect', {id: product.id}) }}">Удалить привязку</a> </div> </div> {% else %} <div class="col-md-12"> <div class="d-grid gap-2"> <button class="btn btn-primary" type="submit">Привязать</button> </div> </div> {% endif %} </div> </form> </div> </div> </div> <div class="col-md-12"> <div class="card mt-3"> <div class="card-header">Наличие у поставщиков</div> <div class="card-body"> <table class="table table-sm table-bordered"> <thead> <tr> <th>ID</th> <th>Артикул</th> <th>Наименование</th> <th>Партномер</th> <th>Цена закупки</th> <th>Цена продажи</th> <th>Финальная цена</th> <th>Остаток</th> <th>Управление</th> </tr> </thead> <tbody> {% for availability in product.availabilities %} {% set calculatedPrice = priceCalculator.calculatePriceForAvailability(availability) %} <tr class="{% if availability == optimalAvailability %}table-success{% endif %} {% if availability.stock == 0 %}table-secondary{% endif %}"> <td>{{ availability.provider.name }}</td> <td>{{ availability.providerArticle }}</td> <td>{{ availability.providerName }}</td> <td>{{ availability.providerPartnumber }}</td> <td>{{ availability.priceRub }}</td> <td>{{ availability.priceSale }}</td> <td>{{ calculatedPrice }}</td> <td>{{ availability.stock }}</td> <td> <a href="#" class="js-move-availability" data-url="{{ path('product_move_availability', {id: availability.id}) }}">Перенести</a> <br/> <a href="{{ path('product_remove_availability', {id: availability.id}) }}" onclick="return confirm('Вы точно хотите отвязать?');">Отвязать</a> </td> </tr> {% endfor %} </tbody> </table> </div> </div> </div> </div> </div>{% endblock %}{% block javascripts %} {{ parent() }} <script> (function() { const $btnMoveAvailability = $('.js-move-availability'); $btnMoveAvailability.on('click', function() { let $el = $(this); let url = $el.attr('data-url'); let id = prompt('Введите ID товара куда нужно перенести'); if (id) { url += `?to=${id}`; window.open(url, '_blank').focus(); } }); })(); </script>{% endblock %}