Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.94 KB | None | 0 0
  1. @extends('layouts.reservation_index')
  2.  
  3. @section('main')
  4.  
  5.  
  6.     <div class="modal fade" role="dialog" tabindex="-1" id="modal1">
  7.         <div class="modal-dialog" role="document">
  8.             <div class="modal-content">
  9.                 <div class="modal-header">
  10.                     <h4 class="modal-title">Reservation</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div>
  11.                 <div class="modal-body">
  12.                     <p>The content of your modal.</p>
  13.                     <div class="table-responsive">
  14.                         <table class="table">
  15.                             <thead>
  16.                                 <tr></tr>
  17.                             </thead>
  18.                             <tbody>
  19.                                 <tr>
  20.                                     <td>From</td>
  21.                                     <td><input type="datetime-local"></td>
  22.                                 </tr>
  23.                                 <tr>
  24.                                     <td>To</td>
  25.                                     <td><input type="datetime-local"></td>
  26.                                 </tr>
  27.                                 <tr>
  28.                                     <td>Category</td>
  29.                                     <td><select><optgroup label="This is a group"><option value="12" selected="">This is item 1</option><option value="13">This is item 2</option><option value="14">This is item 3</option></optgroup></select></td>
  30.                                 </tr>
  31.                                 <tr>
  32.                                     <td>Facility</td>
  33.                                     <td><select><optgroup label="This is a group"><option value="12" selected="">This is item 1</option><option value="13">This is item 2</option><option value="14">This is item 3</option></optgroup></select></td>
  34.                                 </tr>
  35.                                 <tr>
  36.                                     <td>Name</td>
  37.                                     <td><input type="text"></td>
  38.                                 </tr>
  39.                                 <tr>
  40.                                     <td>Contact</td>
  41.                                     <td><input type="number"></td>
  42.                                 </tr>
  43.                                 <tr>
  44.                                     <td>Price</td>
  45.                                     <td><input class="form-control-plaintext" type="text" value="Auto-generated" readonly=""></td>
  46.                                 </tr>
  47.                                 <tr>
  48.                                     <td>Paid</td>
  49.                                     <td><input type="number"></td>
  50.                                 </tr>
  51.                             </tbody>
  52.                         </table>
  53.                     </div>
  54.                 </div>
  55.                 <div class="modal-footer"><button class="btn btn-light" type="button" data-dismiss="modal">Close</button><button class="btn btn-primary" type="button" style="background-color:#563775;">Reserve</button></div>
  56.             </div>
  57.         </div>
  58.     </div>
  59.  
  60.  
  61.  
  62.     <div class="modal fade" role="dialog" tabindex="-1" id="modal2">
  63.         <div class="modal-dialog" role="document">
  64.             <div class="modal-content">
  65.                 <div class="modal-header">
  66.                     <h4 class="modal-title">Reservation</h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div>
  67.                 <div class="modal-body">
  68.                     <p>The content of your modal.</p>
  69.                     <div class="table-responsive">
  70.                         <table class="table">
  71.                             <thead>
  72.                                 <tr></tr>
  73.                             </thead>
  74.                             <tbody>
  75.                                 <tr>
  76.                                     <td>From</td>
  77.                                     <td><input type="datetime-local"></td>
  78.                                 </tr>
  79.                                 <tr>
  80.                                     <td>To</td>
  81.                                     <td><input type="datetime-local"></td>
  82.                                 </tr>
  83.                                 <tr>
  84.                                     <td>Category</td>
  85.                                     <td><select><optgroup label="This is a group"><option value="12" selected="">This is item 1</option><option value="13">This is item 2</option><option value="14">This is item 3</option></optgroup></select></td>
  86.                                 </tr>
  87.                                 <tr>
  88.                                     <td>Facility</td>
  89.                                     <td><select><optgroup label="This is a group"><option value="12" selected="">This is item 1</option><option value="13">This is item 2</option><option value="14">This is item 3</option></optgroup></select></td>
  90.                                 </tr>
  91.                                 <tr>
  92.                                     <td>Name</td>
  93.                                     <td><input type="text"></td>
  94.                                 </tr>
  95.                                 <tr>
  96.                                     <td>Contact</td>
  97.                                     <td><input type="number"></td>
  98.                                 </tr>
  99.                                 <tr>
  100.                                     <td>Price</td>
  101.                                     <td><input class="form-control-plaintext" type="text" value="Auto-generated" readonly=""></td>
  102.                                 </tr>
  103.                                 <tr>
  104.                                     <td>Paid</td>
  105.                                     <td><input type="number"></td>
  106.                                 </tr>
  107.                             </tbody>
  108.                         </table>
  109.                     </div>
  110.                 </div>
  111.                 <div class="modal-footer"><button class="btn btn-light" type="button" data-dismiss="modal">Close</button><button class="btn btn-primary" type="button" style="background-color:#ff0f00;">Cancel Booking</button><button class="btn btn-primary" type="button" style="background-color:#563775;">Update</button></div>
  112.             </div>
  113.         </div>
  114.     </div>
  115.  
  116.  
  117.  
  118.  
  119.     <div>
  120.         <div class="container">
  121.             <div class="row">
  122.                 <div class="col-md-12"><button class="btn btn-primary" type="button" style="background-color:#563775;margin:15px;">Today</button>
  123.                     <div class="btn-group" role="group" style="margin:15px;"><button class="btn btn-primary" type="button" style="background-color:#563775;">January (Delete?)</button><button class="btn btn-primary" type="button" style="background-color:#563775;">February (Delete?)</button></div><input type="datetime-local"
  124.                         style="margin:15px;"><button class="btn btn-primary" type="button" data-toggle="modal" data-target="#modal1">Release to book</button><button class="btn btn-primary" type="button" data-toggle="modal" data-target="#modal2">Tap to edit</button></div>
  125.             </div>
  126.         </div>
  127.  
  128.  
  129.  
  130.  
  131.  
  132.         <div class="row">
  133.  
  134.  
  135.             <div class="col-1">
  136.                 <div class="btn-group-vertical" role="group">
  137.                     @foreach ($categories as $category)
  138.                     <button class="btn btn-primary main_cat" type="button" style="background-color:#563775;" id = "{{'category'.$category->id}}">{{ $category->name }}</button>
  139.                     <script type="text/javascript">
  140.                         button = document.getElementById("{{'category'.$category->id}}");
  141.  
  142.                         button.onclick = function() {
  143.                             var table = document.getElementById("myTable").getElementsByTagName('tbody')[0];
  144.                             var rows = table.rows;
  145.                             var i = rows.length;
  146.                             while (i--) {
  147.                                 table.deleteRow(i);
  148.                             }
  149.  
  150.                             var counter = 0;
  151.                             var column_count = document.getElementById("myTable").getElementsByTagName('thead')[0].rows[0].cells.length - 1;
  152.  
  153.                             @foreach ($facilities_arr[$category->id] as $facility)
  154.                                 var row = table.insertRow(counter++);
  155.                                 var cell = row.insertCell(0);
  156.                                 cell.innerHTML = "{{ $facility->name }}";
  157.                                 @if($facility->status == "Closed")
  158.                                     cell = row.insertCell(1);
  159.                                     cell.colSpan = column_count;
  160.                                     cell.innerHTML = "Facility Closed";
  161.                                     cell.style.textAlign = "center";
  162.                                     cell.style.backgroundColor = "grey";
  163.                                 @else
  164.                                     var counterv2 = 1;
  165.                                     @php
  166.                                         $start_time = $period->start;
  167.  
  168.                                         //my stuff
  169.                                         $current_time = $period->start;
  170.                                         $current_rate;
  171.                                         $slot = $current_time->format('H:i:s');
  172.                                         $cellRate;
  173.                                         //my stuff end
  174.  
  175.                                     @endphp
  176.  
  177.  
  178.  
  179.  
  180.  
  181.                                     @if(array_key_exists($facility->id, $reservations_arr))
  182.  
  183.                                         @foreach ($reservations_arr[$facility->id] as $reservation)
  184.                                             @php
  185.  
  186.                                             $reservation_start_time = DateTime::createFromFormat("Y-m-d H:i:s", $reservation->start);
  187.  
  188.                                             $difference = $period->start->diff($reservation_start_time);
  189.                                             $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($difference)->getTimeStamp();
  190.                                             $reservation_start_time = $intervalInSeconds < 0 ? $period->start : $reservation_start_time;
  191.  
  192.                                             $timeInterval = $start_time->diff($reservation_start_time);
  193.                                             $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($timeInterval)->getTimeStamp();
  194.                                             $intervalInMinutes = $intervalInSeconds/60;
  195.                                             $intervalInSpans = $intervalInMinutes/30;
  196.                                             @endphp
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.                                             @for ($i = 0; $i < $intervalInSpans; $i++)
  208.                                                 @foreach($rates_arr[$facility->id] as $key => $rate)
  209.                                                     @php
  210.                                                         $convertToDateTime = DateTime::createFromFormat('H:i:s', $rate->sort_rates);
  211.                                                         if ($current_time >= $convertToDateTime)
  212.                                                         {
  213.                                                             $cellRate = $rate->rate;
  214.                                                         }
  215.                                                         else
  216.                                                         {
  217.                                                             break;
  218.                                                         }
  219.                                                     @endphp
  220.                                                 @endforeach
  221.                                                 @php
  222.                                                 @endphp
  223.                                                 cell = row.insertCell(counterv2++);
  224.                                                 cell.innerHTML = 'potato';
  225.                                                 cell.classList.add('highlight');
  226.                                                 cell.setAttribute('data-value', '{{ $cellRate }}' );
  227.                                                 cell.setAttribute('data-currentTime', '{{ $slot }}' );
  228.  
  229.                                                 @php
  230.                                                     $current_time->add(new DateInterval('PT30M'));
  231.                                                     $slot = $current_time->format('H:i:s');
  232.                                                 @endphp
  233.                                             @endfor
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.                                             @php
  249.                                             $reservation_end_time = DateTime::createFromFormat("Y-m-d H:i:s", $reservation->end);
  250.                                             $timeInterval = ($reservation_start_time->diff($reservation_end_time));
  251.                                             $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($timeInterval)->getTimeStamp();
  252.                                             $intervalInMinutes = $intervalInSeconds/60;
  253.                                             $intervalInSpans = $intervalInMinutes/30;
  254.                                             @endphp
  255.  
  256.                                             cell = row.insertCell(counterv2++);
  257.                                             cell.colSpan = "{{ $intervalInSpans }}";
  258.  
  259.  
  260.  
  261.  
  262.                                             for(var i = 0; i < '{{ $intervalInSpans }}'; i++) {
  263.                                                 @php
  264.                                                     $current_time->add(new DateInterval('PT30M'));
  265.                                                     $slot = $current_time->format('H:i:s');
  266.                                                 @endphp
  267.                                             }
  268.                                             cell.setAttribute('data-currentTime', '{{ $slot }}');
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.                                             cell.innerHTML = "big potato";
  279.                                             cell.classList.add('reserved');
  280.                                             cell.style.textAlign = "center";
  281.                                             @if ($reservation->rate == $reservation->paid)
  282.                                             {
  283.                                                 cell.style.backgroundColor = "lawngreen";
  284.                                             }
  285.                                             @else
  286.                                             {
  287.                                                 cell.style.backgroundColor = "red";
  288.                                             }
  289.                                             @endif
  290.                                             @php
  291.                                                 $current_time->add(new DateInterval('PT30M'));
  292.                                                 $slot = $current_time->format('H:i:s');
  293.                                             @endphp
  294.  
  295.                                             //convert reservation->start to datetime form
  296.                                             //minus start time of booking, get diff in minutes, divide by 30 min cell
  297.                                             //create cell
  298.                                             //get end time - start time divide 30 min, create special cell for booking
  299.                                             //start_time = reservation->end
  300.  
  301.  
  302.                                             @php
  303.                                             $start_time = DateTime::createFromFormat("Y-m-d H:i:s", $reservation->end);
  304.                                             @endphp
  305.                                         @endforeach
  306.                                     @endif
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.                                     @foreach($rates_arr[$facility->id] as $key => $rate)
  314.                                         @php
  315.                                             $convertToDateTime = DateTime::createFromFormat('H:i:s', $rate->sort_rates);
  316.                                             if ($current_time >= $convertToDateTime)
  317.                                             {
  318.                                                 $cellRate = $rate->rate;
  319.                                             }
  320.                                             else
  321.                                             {
  322.                                                 break;
  323.                                             }
  324.                                         @endphp
  325.                                     @endforeach
  326.  
  327.  
  328.  
  329.                                     @php
  330.                                     $timeInterval = ($start_time->diff($period->end));
  331.                                     $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($timeInterval)->getTimeStamp();
  332.                                     $intervalInMinutes = $intervalInSeconds/60;
  333.                                     $intervalInSpans = $intervalInMinutes/30;
  334.                                     $aaa = $timeInterval->format('%d days, %h hours, %i minutes');
  335.                                     echo 'alert("' . $aaa . '");';
  336.                                     @endphp
  337.                                     @for ($i = 0; $i < $intervalInSpans; $i++)
  338.                                         @foreach($rates_arr[$facility->id] as $key => $rate)
  339.                                             @php
  340.                                                 $convertToDateTime = DateTime::createFromFormat('H:i:s', $rate->sort_rates);
  341.                                                 if ($current_time >= $convertToDateTime)
  342.                                                 {
  343.                                                     $cellRate = $rate->rate;
  344.                                                 }
  345.                                                 else
  346.                                                 {
  347.                                                     break;
  348.                                                 }
  349.                                             @endphp
  350.                                         @endforeach
  351.                                         cell = row.insertCell(counterv2++);
  352.                                         cell.innerHTML = "potato";
  353.                                         cell.classList.add('highlight');
  354.                                         cell.setAttribute('data-value', '{{ $cellRate }}');
  355.                                         cell.setAttribute('data-currentTime', '{{ $slot }}' );
  356.                                         @php
  357.                                             $current_time->add(new DateInterval('PT30M'));
  358.                                             $slot = $current_time->format('H:i:s');
  359.                                             $cellRate = 0.00;
  360.                                         @endphp
  361.                                     @endfor
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.                                 @endif
  380.                             @endforeach
  381.                         }
  382.                     </script>
  383.                     @endforeach
  384.                 </div>
  385.             </div>
  386.  
  387.  
  388.  
  389.  
  390.             <div class="col-11">
  391.                 <div class="table-responsive">
  392.                     <table class="table" id="myTable">
  393.                         <thead>
  394.                             <tr>
  395.                                 <th>
  396.                                     <div class="dropdown"><button class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false" type="button" style="background-color:#563775;"><i class="fa fa-star"></i></button>
  397.                                         <div class="dropdown-menu" role="menu"><a class="dropdown-item" role="presentation" href="#">First Item</a><a class="dropdown-item" role="presentation" href="#">Second Item</a><a class="dropdown-item" role="presentation" href="#">Third Item</a></div>
  398.                                     </div>
  399.                                 </th>
  400.  
  401.                                 @foreach ($period as $dt)
  402.                                     <th>{{ $dt->format("g:i A") }}</th>
  403.                                 @endforeach
  404.                             </tr>
  405.                         </thead>
  406.                         <tbody>
  407.                         </tbody>
  408.                     </table>
  409.                 </div>
  410.             </div>
  411.         </div>
  412.     </div>
  413.     <script type="text/javascript">
  414.         button = document.getElementById("{{'category'.$categories->first()->id}}");
  415.         button.click();
  416.     </script>
  417.     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  418.     <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
  419.  
  420. @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement