templates/site/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}WINITUX|{{ 'ourProductsSite'|trans }}{% endblock %}
  3. {% block body %}
  4.     {{ app.request.getLocale() }}
  5.     <div class="container">
  6.         {#        <p>{{ session_id }}</p> #}
  7.         <input type="text" id="searchInput" class="form-control mb-3" placeholder="Nach einem Produkt suchen.." onkeyup="filterProducts()">
  8.         <div class="row">
  9.             {% for product in products %}
  10.                 <div class="col-md-6">
  11.                     <div class="card h-100">
  12.                         <div class="card-header">
  13.                             <h1 class="text-center">{{ product.productName }}</h1>
  14.                         </div>
  15.                         <div class="card-body card-btn-same-height">
  16.                             <p>{{ product.productDescriptionShort }}</p>
  17.                             {% if product.productImage is not empty %}
  18.                                 <p><img src="/images/{{ product.productImage }}" alt="{{ product.productName }}"
  19.                                         class="img-fluid"></p>
  20.                             {% endif %}
  21.                             <p>{{ product.productDescriptionLong }}</p>
  22.                             <form name="shopping{{ loop.index }}" method="post" action="{{ path('app_cart_new') }}">
  23.                                 <input type="hidden" name="product_id" id="product_id_{{ loop.index }}"
  24.                                        value="{{ product.id }}">
  25.                                 {% set amountPlans = product.id|getAmountSubscriptionPlans %}
  26.                                 <input type="hidden" id="amount_plans_{{ loop.index }}" value="{{ amountPlans }}">
  27.                                 <div id="subscription_area_{{ loop.index }}">
  28.                                     <label for="plan_{{ loop.index }}">{{ 'txtChooseSubscriptionPlan'|trans }}</label>
  29.                                     <select name="plan" id="plan_{{ loop.index }}" class="form-select mb-2"
  30.                                             onchange="calcPrice('{{ loop.index }}')">
  31.                                         {% for plan in product.subscriptionPlan %}
  32.                                             <option value="{{ plan.id }}">{{ plan.subscriptionPlanName }}</option>
  33.                                         {% endfor %}
  34.                                     </select>
  35.                                 </div>
  36.                                 <div id="output_prices{{ loop.index }}"></div>
  37.                                 <button type="submit" name="intoCard"
  38.                                         class="mt-auto btn btn-success w-100">{{ 'lang.gotoOffer'|trans }}</button>
  39.                             </form>
  40.                         </div>
  41.                     </div>
  42.                 </div>
  43.             {% endfor %}
  44.         </div>
  45.     </div>
  46. {% endblock %}
  47. {% block javascripts %}
  48.     <script>
  49.         $(document).ready(function () {
  50.             for (i = 1; i <= {{ amount }}; i++) {
  51.                 calcPrice(i);
  52.             }
  53.         });
  54.         function calcPrice(index) {
  55.             let amountPlans = parseInt($('#amount_plans_' + index).val())
  56.             let product = $('#product_id_' + index).val()
  57.             let plan = $('#plan_' + index).val()
  58.             $('#output_prices' + index).load('{{ path('app_calc_price') }}?product=' + product + '&plan=' + plan, function () {
  59.                 if (amountPlans == 1) {
  60.                     $('#subscription_area_' + index).hide()
  61.                 } else {
  62.                     $('#subscription_area_' + index).show()
  63.                 }
  64.             })
  65.         }
  66.         function filterProducts() {
  67.             let input = document.getElementById("searchInput").value.toLowerCase();
  68.             let products = document.querySelectorAll(".col-md-6");
  69.             products.forEach(product => {
  70.                 let productName = product.querySelector("h1").textContent.toLowerCase();
  71.                 if (productName.includes(input)) {
  72.                     product.style.display = "block";
  73.                 } else {
  74.                     product.style.display = "none";
  75.                 }
  76.             });
  77.         }
  78.     </script>
  79. {% endblock %}