templates/Components/Destination/Detail/Tabs/priceTable.html.twig line 1

  1. {% if(showStyle is defined) %}
  2.     <style>
  3.         .table {
  4.             width: 100%;
  5.             border-collapse: collapse;
  6.             font-size: 0.7rem; /* Zmenšení velikosti textu */
  7.         }
  8.         .table-smaller td,
  9.         .table-smaller th {
  10.             padding: 4px; /* Menší padding uvnitř buněk */
  11.             text-align: center;
  12.             vertical-align: middle;
  13.             border: 1px solid #ccc;
  14.         }
  15.         thead tr {
  16.             background-color: #f2f2f2;
  17.         }
  18.         thead td {
  19.             font-weight: bold;
  20.             padding: 6px; /* Menší padding v záhlaví */
  21.             text-align: center;
  22.             border: 1px solid #ddd;
  23.         }
  24.         .field-title {
  25.             font-weight: bold;
  26.             text-align: left;
  27.             padding-left: 6px; /* Menší zarovnání */
  28.             white-space: nowrap; /* Zabránění zalomení textu */
  29.         }
  30.         .bg-reserved {
  31.             background-color: #eccb0b;
  32.             color: white;
  33.             font-weight: bold;
  34.             text-align: center;
  35.         }
  36.         .bg-full {
  37.             background-color: #d2494c;
  38.             color: white;
  39.             font-weight: bold;
  40.             text-align: center;
  41.         }
  42.         .bg-only-bus {
  43.             background-color: #4fbe1b;
  44.             color: white;
  45.             font-weight: bold;
  46.             text-align: center;
  47.         }
  48.         .bg-only-car {
  49.             background-color: #6FA5D2;
  50.             color: white;
  51.             font-weight: bold;
  52.             text-align: center;
  53.         }
  54.         tbody tr:nth-child(even) {
  55.             background-color: #f9f9f9;
  56.         }
  57.         tbody tr:hover {
  58.             background-color: #f1f1f1;
  59.         }
  60.         td {
  61.             padding: 4px; /* Menší padding */
  62.             border: 1px solid #ddd;
  63.             font-size: 0.7rem; /* Zmenšení textu pro obsah buněk */
  64.         }
  65.         td.bg-reserved {
  66.             background-color: #eccb0b;
  67.             color: #fff;
  68.             font-weight: bold;
  69.         }
  70.         td.bg-full {
  71.             background-color: #d2494c;
  72.             color: #fff;
  73.             font-weight: bold;
  74.         }
  75.         td.bg-only-bus {
  76.             background-color: #4fbe1b;
  77.             color: #fff;
  78.             font-weight: bold;
  79.         }
  80.         td.bg-only-car {
  81.             background-color: #6FA5D2;
  82.             color: #fff;
  83.             font-weight: bold;
  84.         }
  85.         .bg-price-text {
  86.             background-color: #9b59b6;
  87.             color: #fff;
  88.             font-weight: bold;
  89.             text-align: center;
  90.         }
  91.         td.bg-price-text {
  92.             background-color: #9b59b6;
  93.             color: #fff;
  94.             font-weight: bold;
  95.         }
  96.         td.pdf-bg-only-bus {
  97.             background-color: #4fbe1b;
  98.             color: #fff;
  99.             font-weight: bold;
  100.         }
  101.         td.pdf-bg-only-car {
  102.             background-color: #6FA5D2;
  103.             color: #fff;
  104.             font-weight: bold;
  105.         }
  106.         /* Přidání automatického zmenšení tabulky */
  107.         .table {
  108.             table-layout: fixed; /* Nastavení pevného layoutu tabulky */
  109.         }
  110.         td {
  111.             word-wrap: break-word; /* Rozdělení dlouhých slov */
  112.         }
  113.     </style>
  114. {% endif %}
  115. {% if(destination.generatePriceTable) %}
  116.     <table class="table table-smaller">
  117.         <thead>
  118.         <tr>
  119.             <td></td>
  120.             <td><strong>Termín</strong></td>
  121.             <td><strong>Počet dní pob./záj.</strong></td>
  122.             <td><strong>Den odjezdu</strong></td>
  123.             {% for accommodation in destination.accommodations %}
  124.                 <td><strong>{{ accommodation.name }}</strong></td>
  125.             {% endfor %}
  126.         </tr>
  127.         </thead>
  128.         <tbody>
  129.         {% for term in destination.activeTerms %}
  130.             <tr class="{% if(term.onlyBus) %}bus pdf-bg-only-bus{% endif %}{% if(term.onlyCar) %}car pdf-bg-only-car{% endif %}">
  131.                 <td class="field-title{% if(term.onlyBus) %} pdf-bg-only-bus{% endif %}{% if(term.onlyCar) %} pdf-bg-only-car{% endif %}">{{ term.number }}</td>
  132.                 <td>{{ term.start|date('d.m.') }} - {{ term.end|date('d.m.') }}</td>
  133.                 <td>{{ term.numberOfDays }}</td>
  134.                 <td>{{ term.departureDay }}</td>
  135.                 {% for accommodation in destination.accommodations %}
  136.                     {% set termPrice = term.getAccommodationTermPrice(accommodation) %}
  137.                     {% set price = termPrice ? termPrice.price : null %}
  138.                     {% set bgClass = term.getAccommodationBgClass(accommodation) %}
  139.                     <td class="{{ bgClass }}">
  140.                         {% if termPrice and termPrice.priceText is not empty %}
  141.                             {{ termPrice.priceText }}
  142.                         {% elseif(price) %}
  143.                             {{ price|format_currency('CZK') }}
  144.                             {% if bgClass in ['bg-full', 'bg-reserved'] and termPrice %}
  145.                                 <br>
  146.                                 <button class="btn btn-sm btn-warning watchdog-btn" 
  147.                                         data-term-price-id="{{ termPrice.id }}"
  148.                                         data-destination="{{ destination.name }}"
  149.                                         data-term="{{ term.start|date('d.m.') }} - {{ term.end|date('d.m.') }}"
  150.                                         data-accommodation="{{ accommodation.name }}"
  151.                                         data-price="{{ price }}"
  152.                                         style="font-size: 0.65rem; padding: 2px 6px; margin-top: 2px;">
  153.                                     🔔 Hlídat
  154.                                 </button>
  155.                             {% endif %}
  156.                         {% else %}
  157.                             -
  158.                         {% endif %}
  159.                     </td>
  160.                 {% endfor %}
  161.             </tr>
  162.         {% endfor %}
  163.         </tbody>
  164.     </table>
  165.     <span class="bg-reserved">Rezervováno</span>
  166.     <span class="bg-full">Prodáno</span>
  167.     <span class="bg-only-car">Pouze vlastní doprava</span>
  168.     <span class="bg-only-bus">Pouze autobusová doprava</span>
  169.     <span class="bg-price-text">Text místo ceny</span>
  170.     <!-- Modal pro watchdog -->
  171.     <div class="modal fade" id="watchdogModal" tabindex="-1" role="dialog" aria-labelledby="watchdogModalLabel">
  172.         <div class="modal-dialog" role="document">
  173.             <div class="modal-content">
  174.                 <div class="modal-header">
  175.                     <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  176.                         <span aria-hidden="true">&times;</span>
  177.                     </button>
  178.                     <h4 class="modal-title" id="watchdogModalLabel">🔔 Hlídat dostupnost</h4>
  179.                 </div>
  180.                 <div class="modal-body">
  181.                     <div id="watchdog-info" style="margin-bottom: 15px; padding: 10px; background-color: #f5f5f5; border-radius: 4px;">
  182.                         <strong>Destinace:</strong> <span id="modal-destination"></span><br>
  183.                         <strong>Termín:</strong> <span id="modal-term"></span><br>
  184.                         <strong>Ubytování:</strong> <span id="modal-accommodation"></span><br>
  185.                         <strong>Cena:</strong> <span id="modal-price"></span>
  186.                     </div>
  187.                     <div class="form-group">
  188.                         <label for="watchdog-email">Váš e-mail:</label>
  189.                         <input type="email" class="form-control" id="watchdog-email" placeholder="vas@email.cz" required>
  190.                         <small class="form-text text-muted">
  191.                             Pošleme vám e-mail, jakmile bude termín dostupný k objednání.
  192.                         </small>
  193.                     </div>
  194.                     
  195.                     <div class="form-group">
  196.                         <div class="checkbox">
  197.                             <label>
  198.                                 <input type="checkbox" id="watchdog-gdpr-consent" required>
  199.                                 Souhlasím se zpracováním mého e-mailu za účelem zasílání upozornění na dostupnost vybraného termínu.
  200.                             </label>
  201.                         </div>
  202.                         <small class="form-text text-muted" style="margin-top: 5px;">
  203.                             <a href="#gdpr-details" data-toggle="collapse" aria-expanded="false" aria-controls="gdpr-details" style="color: #337ab7;">
  204.                                 Informace o zpracování osobních údajů
  205.                             </a>
  206.                         </small>
  207.                         <div class="collapse" id="gdpr-details" style="margin-top: 10px;">
  208.                             <div class="well well-sm" style="margin-bottom: 0; font-size: 12px;">
  209.                                 <strong>Informace o zpracování osobních údajů:</strong><br>
  210.                                 Správcem vašich osobních údajů je Iveria Travel. Váš e-mail bude použit výhradně pro zaslání upozornění 
  211.                                 na dostupnost vybraného termínu. Po odeslání upozornění nebo na základě vašeho odvolání souhlasu 
  212.                                 budou údaje vymazány. Máte právo na přístup k údajům, jejich opravu, výmaz a přenositelnost.
  213.                                 <br><br>
  214.                                 Svůj souhlas mohu kdykoli odvolat kliknutím na odkaz v zaslaném e-mailu.
  215.                             </div>
  216.                         </div>
  217.                     </div>
  218.                     
  219.                     <div id="watchdog-message" style="display: none; margin-top: 10px;"></div>
  220.                 </div>
  221.                 <div class="modal-footer">
  222.                     <button type="button" class="btn btn-default" data-dismiss="modal">Zrušit</button>
  223.                     <button type="button" class="btn btn-primary" id="watchdog-submit">Hlídat dostupnost</button>
  224.                 </div>
  225.             </div>
  226.         </div>
  227.     </div>
  228.     <script>
  229.     (function() {
  230.         let currentTermPriceId = null;
  231.         // Otevření modalu při kliknutí na tlačítko
  232.         document.addEventListener('click', function(e) {
  233.             if (e.target && e.target.classList.contains('watchdog-btn')) {
  234.                 currentTermPriceId = e.target.getAttribute('data-term-price-id');
  235.                 document.getElementById('modal-destination').textContent = e.target.getAttribute('data-destination');
  236.                 document.getElementById('modal-term').textContent = e.target.getAttribute('data-term');
  237.                 document.getElementById('modal-accommodation').textContent = e.target.getAttribute('data-accommodation');
  238.                 
  239.                 // Formátování ceny
  240.                 const price = e.target.getAttribute('data-price');
  241.                 if (price) {
  242.                     const formattedPrice = new Intl.NumberFormat('cs-CZ', {
  243.                         style: 'currency',
  244.                         currency: 'CZK'
  245.                     }).format(price);
  246.                     document.getElementById('modal-price').textContent = formattedPrice;
  247.                 } else {
  248.                     document.getElementById('modal-price').textContent = '-';
  249.                 }
  250.                 
  251.                 document.getElementById('watchdog-email').value = '';
  252.                 document.getElementById('watchdog-gdpr-consent').checked = false;
  253.                 document.getElementById('watchdog-message').style.display = 'none';
  254.                 
  255.                 // Zavřít GDPR details collapse
  256.                 if (typeof jQuery !== 'undefined') {
  257.                     jQuery('#gdpr-details').collapse('hide');
  258.                 }
  259.                 
  260.                 // Otevřít modal (Bootstrap 3)
  261.                 if (typeof jQuery !== 'undefined') {
  262.                     jQuery('#watchdogModal').modal('show');
  263.                 }
  264.             }
  265.         });
  266.         // Odeslání formuláře
  267.         document.getElementById('watchdog-submit').addEventListener('click', function() {
  268.             const email = document.getElementById('watchdog-email').value.trim();
  269.             const gdprConsent = document.getElementById('watchdog-gdpr-consent').checked;
  270.             const messageDiv = document.getElementById('watchdog-message');
  271.             
  272.             if (!email) {
  273.                 showMessage('Prosím, vyplňte e-mailovou adresu.', 'danger');
  274.                 return;
  275.             }
  276.             if (!validateEmail(email)) {
  277.                 showMessage('Prosím, zadejte platnou e-mailovou adresu.', 'danger');
  278.                 return;
  279.             }
  280.             if (!gdprConsent) {
  281.                 showMessage('Prosím, potvrďte souhlas se zpracováním osobních údajů.', 'danger');
  282.                 return;
  283.             }
  284.             // Disable tlačítko během odesílání
  285.             const submitBtn = document.getElementById('watchdog-submit');
  286.             submitBtn.disabled = true;
  287.             submitBtn.textContent = 'Odesílám...';
  288.             // AJAX požadavek
  289.             fetch('/term-price-watchdog', {
  290.                 method: 'POST',
  291.                 headers: {
  292.                     'Content-Type': 'application/json',
  293.                 },
  294.                 body: JSON.stringify({
  295.                     termPriceId: currentTermPriceId,
  296.                     email: email,
  297.                     gdprConsent: gdprConsent
  298.                 })
  299.             })
  300.             .then(response => response.json())
  301.             .then(data => {
  302.                 if (data.ok) {
  303.                     showMessage(data.message || 'Hlídání bylo úspěšně nastaveno!', 'success');
  304.                     setTimeout(function() {
  305.                         if (typeof jQuery !== 'undefined') {
  306.                             jQuery('#watchdogModal').modal('hide');
  307.                         }
  308.                     }, 2000);
  309.                 } else {
  310.                     showMessage(data.message || 'Došlo k chybě. Zkuste to prosím znovu.', 'danger');
  311.                 }
  312.             })
  313.             .catch(error => {
  314.                 console.error('Error:', error);
  315.                 showMessage('Došlo k chybě při komunikaci se serverem.', 'danger');
  316.             })
  317.             .finally(() => {
  318.                 submitBtn.disabled = false;
  319.                 submitBtn.textContent = 'Hlídat dostupnost';
  320.             });
  321.         });
  322.         function showMessage(message, type) {
  323.             const messageDiv = document.getElementById('watchdog-message');
  324.             messageDiv.className = 'alert alert-' + type;
  325.             messageDiv.textContent = message;
  326.             messageDiv.style.display = 'block';
  327.         }
  328.         function validateEmail(email) {
  329.             const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
  330.             return re.test(email);
  331.         }
  332.     })();
  333.     </script>
  334. {% endif %}
  335. {{ destination.priceTable | raw }}