templates/tennis_court_availability/index.html.twig line 1

  1. {% extends 'base.html.twig' %}
  2. {% block title %}Court Availability: {{ dateRange }}{% endblock %}
  3. {% block body %}
  4.     <style>
  5.         /*.table-data th {*/
  6.         /*    height: 70px;*/
  7.         /*    width: 120px;*/
  8.         /*    padding: 0px 10px*/
  9.         /*}*/
  10.         .table-data td {
  11.             padding: 4px !important;
  12.             vertical-align: middle;
  13.         }
  14.         /*.table-hour th {*/
  15.         /*    height: 66px;*/
  16.         /*    padding: 0px 10px*/
  17.         /*}*/
  18.         .table-hour td {
  19.             padding: 4px !important;
  20.             vertical-align: middle;
  21.         }
  22.     </style>
  23.     {% for message in app.flashes('failed') %}
  24.         <div class="alert alert-danger">
  25.             {{ message }}
  26.         </div>
  27.     {% endfor %}
  28.     <div class="top-up-dialog col-md-3 shadow p-2 text-center">
  29.         <p><strong>Your account balance is too low to book this court. Top-up?</strong></p>
  30.         <div class="d-flex justify-content-center">
  31.             <button class="btn btn-warning w-50 close-pop-up"> Ignore</button>
  32.             <a class="btn btn-primary ml-2 w-50" href="{{ path('payments_new', {type: 'In-coming cash'}) }}">TopUp</a>
  33.         </div>
  34.     </div>
  35.     <div class="bid-dialog col-md-3 shadow-lg text-dark rounded px-0 pb-2">
  36.         <div class="py-2 text-center text-light" style="background-color: #e7e7e7"><h4 style="color:#898989"><strong>Bid
  37.                     Your Price</strong></h4></div>
  38.         <div class="">
  39.             <form class="bid-form px-5 pt-3 py-2" method="post">
  40.                 <div class="form-group">
  41.                     <div class="label-bid"></div>
  42.                     <input type="number" class="bid-input form-control mt-1" name="bid">
  43.                 </div>
  44.                 <div class="form-group d-flex">
  45.                     <input type="submit" name="submit" class="w-50 submit-bid-button btn btn-success d-inline ml-1"
  46.                            value="Submit">
  47.                     <input type="submit" name="cancel-submit"
  48.                            class="w-50 close-bid-button btn btn-danger d-inline" value="Cancel">
  49.                 </div>
  50.             </form>
  51.         </div>
  52.     </div>
  53.     <h1 style="color: red;">Court Availability: {{ dateRange }}</h1>
  54.     <div class="row">
  55.         {% include 'tennis_court_availability/parts/date_ranges.html.twig' %}
  56.         {% if app.user %}
  57.             {% include 'tennis_court_availability/parts/client_court_times_provisional.html.twig' %}
  58.             {% include 'tennis_court_availability/parts/postcodes.html.twig' %}
  59.             {% include 'tennis_court_availability/parts/postcodes_sub_routine2.html.twig' %}
  60.         {% endif %}
  61.         {% include 'tennis_court_availability/parts/date_ranges2.html.twig' %}
  62.     </div>
  63.     {% if is_granted('ROLE_ACEIFY') %}
  64.         <div class="row">
  65.             <div class="col-8"></div>
  66.             <div class="col-3">
  67.                 {#                Admin: {% include 'tennis_court_availability/parts/admin_buttons.html.twig' %} #}
  68.             </div>
  69.         </div>
  70.     {% endif %}
  71.     <hr>
  72.     {% for date in dates %}
  73.         <h3 style="color: blue;">{{ date|date('D d-M-Y') }}</h3>
  74.         <div class="row">
  75.             <div class="main-container d-flex w-100">
  76.                 <div class="table-hour-container">
  77.                     <table class="table table-hour">
  78.                         <thead>
  79.                         <tr>
  80.                             <th>Hour
  81.                                 {% include 'tennis_court_availability/parts/scrape_all_venues_that_day.html.twig' %}
  82.                             </th>
  83.                             {% if is_granted('ROLE_ACEIFY') and app.user.id != ActiveAceifyClient.findClient(app.user).id %}
  84.                                 <th>
  85.                                     Email
  86.                                 </th>
  87.                             {% endif %}
  88.                         </tr>
  89.                         </thead>
  90.                         <tbody>
  91.                         {% for hour in hours %}
  92.                             <tr>
  93.                                 <td style="text-align: center" data-sort="{{ hour.sort }}"><b>{{ hour.hour }}</b></td>
  94.                                 {% if is_granted('ROLE_ACEIFY') and app.user.id != ActiveAceifyClient.findClient(app.user).id %}
  95.                                     <td style="text-align: center">
  96.                                         {% set client_court_flag = 0 %}
  97.                                         {% for client_court_time in client_court_times %}
  98.                                             {% if client_court_time.date == date and client_court_time.hour == hour.sort %}
  99.                                                 {% set client_court_flag =1 %}
  100.                                                 <form method="post"
  101.                                                       action="{{ path('client_court_times_delete', {'id': client_court_time.id}) }}">
  102.                                                     <input type="hidden" name="_token"
  103.                                                            value="{{ csrf_token('delete' ~ client_court_time.id) }}">
  104.                                                     <button style="background-color: white;border:none"><i
  105.                                                                 style="color: green" class="fa fa-calendar-check"></i>
  106.                                                     </button>
  107.                                                 </form>
  108.                                             {% endif %}
  109.                                         {% endfor %}
  110.                                         {% if client_court_flag ==0 %}
  111.                                             <a href="{{ path('client_court_times_new', {date: date|date('Y-m-d'), hour: hour.sort}) }}">
  112.                                                 <i style="color: grey" class="fa fa-circle"></i>
  113.                                             </a>
  114.                                         {% endif %}
  115.                                     </td>
  116.                                 {% endif %}
  117.                             </tr>
  118.                         {% endfor %}
  119.                         </tbody>
  120.                     </table>
  121.                 </div>
  122.                 <div class="table-data-container overflow-auto">
  123.                     <table class="table table-responsive table-data">
  124.                         <thead>
  125.                         <tr>
  126.                             {% for tennis_venue in tennis_venues %}
  127.                                 <th style="text-align: left">
  128.                                     {% include 'tennis_court_availability/parts/venue_header.html.twig' %}
  129.                                 </th>
  130.                             {% endfor %}
  131.                             {% include 'tennis_court_availability/parts/weather_headers.html.twig' %}
  132.                         </tr>
  133.                         </thead>
  134.                         <tbody>
  135.                         {% for hour in hours %}
  136.                             {% set past_or_future = "default" %}
  137.                             {% if date|date('Y-m-d') < today|date('Y-m-d') or hour.sort < todayHour and date|date('Y-m-d') == today|date('Y-m-d') %}
  138.                                 <tr style="background-color: whitesmoke">
  139.                                 {% set past_or_future = "Past" %}
  140.                             {% else %}
  141.                                 {% if hour.sort == todayHour and date|date('Y-m-d') == today|date('Y-m-d') %}
  142.                                     {% set past_or_future = "Future" %}
  143.                                     <tr style="background-color: lightyellow">
  144.                                 {% else %}
  145.                                     <tr>
  146.                                     {% set past_or_future = "Future" %}
  147.                                 {% endif %}
  148.                             {% endif %}
  149.                             {% for tennis_venue in tennis_venues %}
  150.                                 {% set availability = "-" %}
  151.                                 {% set id = '' %}
  152.                                 {% set court_cost='' %}
  153.                                 <td style="text-align: center">
  154.                                     {% include 'template_parts/login_or_register_popup.html.twig' %}
  155. {#                                    {% include 'tennis_court_availability/parts/bookings_made.html.twig' %}#}
  156.                                     {#                                    {% if is_granted('ROLE_SUPER_ADMIN') %} #}
  157.                                     {#                                        <span style="color: red">{{ CourtAvailabilities.summaryAcrossCourt(hour.sort,tennis_venue,date) }}</span> #}
  158.                                     {#                                    {% endif %} #}
  159.                                     {% if CourtAvailabilities.summaryAcrossCourt(tennis_venue,date, hour.sort)  == 1 %}
  160.                                         {% include 'tennis_court_availability/parts/court_not_released_yet.html.twig' %}
  161.                                     {% endif %}
  162.                                     {% if  CourtAvailabilities.summaryAcrossCourt(tennis_venue,date, hour.sort) == 2 %}
  163.                                         {% include 'tennis_court_availability/parts/court_available.html.twig' %}
  164.                                     {% endif %}
  165.                                     {% if CourtAvailabilities.summaryAcrossCourt(tennis_venue,date, hour.sort)  == 3 %}
  166.                                         {% include 'tennis_court_availability/parts/court_fully_booked.html.twig' %}
  167.                                     {% endif %}
  168.                                     {% if CourtAvailabilities.summaryAcrossCourt(tennis_venue,date, hour.sort)  == 4 %}
  169.                                         {% include 'tennis_court_availability/parts/court_closed.html.twig' %}
  170.                                     {% endif %}
  171.                                 </td>
  172.                             {% endfor %}
  173.                             {% include 'tennis_court_availability/parts/weather.html.twig' %}
  174.                             </tr>
  175.                         {% endfor %}
  176.                         </tbody>
  177.                     </table>
  178.                 </div>
  179.             </div>
  180.         </div>
  181.         <hr>
  182.     {% endfor %}
  183.     <br>    <br>    <br>    <br>
  184. {% endblock %}
  185. {% block datatable %}
  186.     <script>
  187.         $(document).ready(function () {
  188.             $('.table').DataTable({
  189.                 'pageLength': 50,
  190.                 "order": [[0, 'asc']],
  191.                 "paging": false,
  192.                 "searching": false,
  193.                 "bInfo": false,
  194.                 "responsive": false,
  195.                 "sort": false
  196.             });
  197.         });
  198.     </script>
  199.     <script>
  200.         {% if app.user %}
  201.         function checkAccountBalance(id) {
  202.             var bidPrice = $("#bid-input-reserve" + id).val();
  203.             var balance = {{ (Payments.TotalPaymentsMade(ActiveAceifyClient.findClient(app.user)) -
  204.             Payments.TotalBookingsCost(ActiveAceifyClient.findClient(app.user))) }};
  205.             if (balance < parseInt(bidPrice)) {
  206.                 $(".close").click();
  207.                 $(".top-up-dialog").css('display', 'block');
  208.                 return false;
  209.             } else {
  210.                 return true;
  211.             }
  212.         }
  213.         function returnAccountBalance(id) {
  214.             var balance = {{ (Payments.TotalPaymentsMade(ActiveAceifyClient.findClient(app.user)) -
  215.             Payments.TotalBookingsCost(ActiveAceifyClient.findClient(app.user))) }};
  216.             return balance;
  217.         }
  218.         function checkAccountBalanceConfirm(price) {
  219.             {% if is_granted('ROLE_ACEIFY') %}
  220.             {% else %}
  221.             var balance = {{ (Payments.TotalPaymentsMade(ActiveAceifyClient.findClient(app.user)) -
  222.             Payments.TotalBookingsCost(ActiveAceifyClient.findClient(app.user))) }};
  223.             if (balance < price) {
  224.                 $(".close").click();
  225.                 $(".top-up-dialog").css('display', 'block');
  226.                 return false;
  227.             } else {
  228.                 return true;
  229.             }
  230.         }
  231.         {% endif %}
  232.         $('.close-pop-up').click(function () {
  233.             $(".top-up-dialog").css('display', 'none');
  234.         });
  235.         var date = '';
  236.         var hour = '';
  237.         var venue = '';
  238.         {% endif %}
  239.         function bid(date, hour, venue) {
  240.             date = date;
  241.             hour = hour;
  242.             venue = venue;
  243.             $(".bid-dialog").css('display', 'block');
  244.             $(".label-bid").html("<p class='mb-0' style='font-size: 20.5px;color:#878787'><strong>Please enter your bid for the court on " + date + " at " + hour + "h at " + venue + "</strong></p>");
  245.             $(".submit-bid-button").click(function (e) {
  246.                 e.preventDefault();
  247.                 var bid = $('.bid-input').val();
  248.                 {# var href = "/tennis/bookings/advanceReservation/" + date + "/" + hour + "/" + venue + "/{{ app.user.id }}/" + bid + ""; #}
  249.                 $(".bid-dialog").css("display", "none");
  250.                 window.location.href = href;
  251.             });
  252.             $(".close-bid-button").click(function (e) {
  253.                 e.preventDefault();
  254.                 $(".bid-dialog").css("display", "none");
  255.             })
  256.             return false;
  257.         }
  258.     </script>
  259.     <script>
  260.         ///   $("table").removeClass('table-responsive');
  261.     </script>
  262. {% endblock datatable %}
  263. {% block additionaljs %}
  264.     <script>
  265.         $(document).ready(function () {
  266.             var height = $('.table-data thead tr th').height();
  267.             $('.table-hour thead tr th').height(height);
  268.             $(window).resize(function () {
  269.                 var height = $('.table-data thead tr th').height();
  270.                 $('.table-hour thead tr th').height(height);
  271.             })
  272.             var dateRange = "{{ dateRange }}";
  273.             if (dateRange !== "") {
  274.                 $('a:contains("' + dateRange + '")').removeClass('btn-primary');
  275.                 $('a:contains("' + dateRange + '")').addClass('btn-success');
  276.             }
  277.             $('.main-container').each(function () {
  278.                 var parent = $(this);
  279.                 $(this).find('.table-data-container tbody tr').each(function (index) {
  280.                     var height = $(this).height();
  281.                     $(parent).find('.table-hour-container table tbody tr').eq(index).css("height", height);
  282.                 });
  283.             })
  284.         })
  285.     </script>
  286. {% endblock %}