templates/tennis_court_availability/index.html.twig line 1

Open in your IDE?
  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>
  184.     <br>
  185.     <br>
  186.     <br>
  187. {% endblock %}
  188. {% block datatable %}
  189.     <script>
  190.         $(document).ready(function () {
  191.             $('.table').DataTable({
  192.                 'pageLength': 50,
  193.                 "order": [[0, 'asc']],
  194.                 "paging": false,
  195.                 "searching": false,
  196.                 "bInfo": false,
  197.                 "responsive": false,
  198.                 "sort": false
  199.             });
  200.         });
  201.     </script>
  202.     <script>
  203.         {% if app.user %}
  204.         function checkAccountBalance(id) {
  205.             var bidPrice = $("#bid-input-reserve" + id).val();
  206.             var balance = {{ (Payments.TotalPaymentsMade(ActiveAceifyClient.findClient(app.user)) -
  207.             Payments.TotalBookingsCost(ActiveAceifyClient.findClient(app.user))) }};
  208.             if (balance < parseInt(bidPrice)) {
  209.                 $(".close").click();
  210.                 $(".top-up-dialog").css('display', 'block');
  211.                 return false;
  212.             } else {
  213.                 return true;
  214.             }
  215.         }
  216.         function returnAccountBalance(id) {
  217.             var balance = {{ (Payments.TotalPaymentsMade(ActiveAceifyClient.findClient(app.user)) -
  218.             Payments.TotalBookingsCost(ActiveAceifyClient.findClient(app.user))) }};
  219.             return balance;
  220.         }
  221.         function checkAccountBalanceConfirm(price) {
  222.             {% if is_granted('ROLE_ACEIFY') %}
  223.             {% else %}
  224.             var balance = {{ (Payments.TotalPaymentsMade(ActiveAceifyClient.findClient(app.user)) -
  225.             Payments.TotalBookingsCost(ActiveAceifyClient.findClient(app.user))) }};
  226.             if (balance < price) {
  227.                 $(".close").click();
  228.                 $(".top-up-dialog").css('display', 'block');
  229.                 return false;
  230.             } else {
  231.                 return true;
  232.             }
  233.         }
  234.         {% endif %}
  235.         $('.close-pop-up').click(function () {
  236.             $(".top-up-dialog").css('display', 'none');
  237.         });
  238.         var date = '';
  239.         var hour = '';
  240.         var venue = '';
  241.         {% endif %}
  242.         function bid(date, hour, venue) {
  243.             date = date;
  244.             hour = hour;
  245.             venue = venue;
  246.             $(".bid-dialog").css('display', 'block');
  247.             $(".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>");
  248.             $(".submit-bid-button").click(function (e) {
  249.                 e.preventDefault();
  250.                 var bid = $('.bid-input').val();
  251.                 {# var href = "/tennis/bookings/advanceReservation/" + date + "/" + hour + "/" + venue + "/{{ app.user.id }}/" + bid + ""; #}
  252.                 $(".bid-dialog").css("display", "none");
  253.                 window.location.href = href;
  254.             });
  255.             $(".close-bid-button").click(function (e) {
  256.                 e.preventDefault();
  257.                 $(".bid-dialog").css("display", "none");
  258.             })
  259.             return false;
  260.         }
  261.     </script>
  262.     <script>
  263.         ///   $("table").removeClass('table-responsive');
  264.     </script>
  265. {% endblock datatable %}
  266. {% block additionaljs %}
  267.     <script>
  268.         $(document).ready(function () {
  269.             var height = $('.table-data thead tr th').height();
  270.             $('.table-hour thead tr th').height(height);
  271.             $(window).resize(function () {
  272.                 var height = $('.table-data thead tr th').height();
  273.                 $('.table-hour thead tr th').height(height);
  274.             })
  275.             var dateRange = "{{ dateRange }}";
  276.             if (dateRange !== "") {
  277.                 $('a:contains("' + dateRange + '")').removeClass('btn-primary');
  278.                 $('a:contains("' + dateRange + '")').addClass('btn-success');
  279.             }
  280.             $('.main-container').each(function () {
  281.                 var parent = $(this);
  282.                 $(this).find('.table-data-container tbody tr').each(function (index) {
  283.                     var height = $(this).height();
  284.                     $(parent).find('.table-hour-container table tbody tr').eq(index).css("height", height);
  285.                 });
  286.             })
  287.         })
  288.     </script>
  289. {% endblock %}