Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 21.85 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.                             {
  155.                                 var row = table.insertRow(counter++);
  156.                                 var cell = row.insertCell(0);
  157.                                 cell.innerHTML = "{{ $facility->name }}";
  158.                                 @if($facility->status == "Closed")
  159.                                     cell = row.insertCell(1);
  160.                                     cell.colSpan = column_count;
  161.                                     cell.innerHTML = "Facility Closed";
  162.                                     cell.style.textAlign = "center";
  163.                                     cell.style.backgroundColor = "grey";
  164.                                 @else
  165.                                     var counterv2 = 1;
  166.                                     @php
  167.                                         $start_time = $period->start;
  168.  
  169.                                         //my stuff
  170.                                         $current_time = $period->start;
  171.                                         $current_rate;
  172.                                         $slot = $current_time->format('H:i:s');
  173.                                         $cellRate;
  174.                                         //my stuff end
  175.  
  176.                                     @endphp
  177.  
  178.  
  179.  
  180.  
  181.  
  182.                                     @if(array_key_exists($facility->id, $reservations_arr))
  183.  
  184.                                         @foreach ($reservations_arr[$facility->id] as $reservation)
  185.                                             @php
  186.  
  187.                                             $reservation_start_time = DateTime::createFromFormat("Y-m-d H:i:s", $reservation->start);
  188.  
  189.                                             $difference = $period->start->diff($reservation_start_time);
  190.                                             $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($difference)->getTimeStamp();
  191.                                             $reservation_start_time = $intervalInSeconds < 0 ? $period->start : $reservation_start_time;
  192.  
  193.                                             $timeInterval = $start_time->diff($reservation_start_time);
  194.                                             $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($timeInterval)->getTimeStamp();
  195.                                             $intervalInMinutes = $intervalInSeconds/60;
  196.                                             $intervalInSpans = $intervalInMinutes/30;
  197.                                             @endphp
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.                                             @for ($i = 0; $i < $intervalInSpans; $i++)
  209.                                                 @foreach($rates_arr[$facility->id] as $key => $rate)
  210.                                                     @php
  211.                                                         $convertToDateTime = DateTime::createFromFormat('H:i:s', $rate->sort_rates);
  212.                                                         if ($current_time >= $convertToDateTime)
  213.                                                         {
  214.                                                             $cellRate = $rate->rate;
  215.                                                             echo 'alert("latest ' . $cellRate . '");';
  216.                                                             //but when to break if there's multiple past 24:00:00 rate?
  217.                                                         }
  218.                                                         else
  219.                                                         {
  220.                                                             echo 'alert("final ' . $cellRate . '");';
  221.                                                             break;
  222.                                                         }
  223.                                                     @endphp
  224.                                                 @endforeach
  225.                                                 @php
  226.                                                 @endphp
  227.                                                 cell = row.insertCell(counterv2++);
  228.                                                 cell.innerHTML = 'potato';
  229.                                                 cell.classList.add('highlight');
  230.                                                 cell.setAttribute('value', '{{ $cellRate }}' );
  231.                                                 cell.setAttribute('curtime', '{{ $slot }}' );
  232.                                                 @php
  233.                                                     $current_time->add(new DateInterval('PT30M'));
  234.                                                     $slot = $current_time->format('H:i:s');
  235.                                                     echo 'alert("then ' . $slot . '");';
  236.                                                 @endphp
  237.                                             @endfor
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.                                             @php
  253.                                             $reservation_end_time = DateTime::createFromFormat("Y-m-d H:i:s", $reservation->end);
  254.                                             $timeInterval = ($reservation_start_time->diff($reservation_end_time));
  255.                                             $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($timeInterval)->getTimeStamp();
  256.                                             $intervalInMinutes = $intervalInSeconds/60;
  257.                                             $intervalInSpans = $intervalInMinutes/30;
  258.                                             @endphp
  259.  
  260.                                             cell = row.insertCell(counterv2++);
  261.                                             cell.colSpan = "{{ $intervalInSpans }}";
  262.  
  263.  
  264.  
  265.  
  266.                                             for(var i = 0; i < '{{ $intervalInSpans }}'; i++) {
  267.                                                 @php
  268.                                                     $current_time->add(new DateInterval('PT30M'));
  269.                                                     $slot = $current_time->format('H:i:s');
  270.                                                 @endphp
  271.                                             }
  272.                                             cell.setAttribute('value', '{{ $slot }}');
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.                                             cell.innerHTML = "big potato";
  283.                                             cell.classList.add('reserved');
  284.                                             cell.style.textAlign = "center";
  285.                                             @if ($reservation->rate == $reservation->paid)
  286.                                             {
  287.                                                 cell.style.backgroundColor = "lawngreen";
  288.                                             }
  289.                                             @else
  290.                                             {
  291.                                                 cell.style.backgroundColor = "red";
  292.                                             }
  293.                                             @endif
  294.                                             @php
  295.                                                 $current_time->add(new DateInterval('PT30M'));
  296.                                                 $slot = $current_time->format('H:i:s');
  297.                                             @endphp
  298.  
  299.                                             //convert reservation->start to datetime form
  300.                                             //minus start time of booking, get diff in minutes, divide by 30 min cell
  301.                                             //create cell
  302.                                             //get end time - start time divide 30 min, create special cell for booking
  303.                                             //start_time = reservation->end
  304.  
  305.  
  306.                                             @php
  307.                                             $start_time = DateTime::createFromFormat("Y-m-d H:i:s", $reservation->end);
  308.                                             @endphp
  309.                                         @endforeach
  310.                                     @endif
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.                                     @foreach($rates_arr[$facility->id] as $key => $rate)
  318.                                         @php
  319.                                             $convertToDateTime = DateTime::createFromFormat('H:i:s', $rate->sort_rates);
  320.                                             if ($current_time >= $convertToDateTime)
  321.                                             {
  322.                                                 $cellRate = $rate->rate;
  323.                                                 echo 'alert("latest ' . $cellRate . '");';
  324.                                                 //but when to break if there's multiple past 24:00:00 rate?
  325.                                             }
  326.                                             else
  327.                                             {
  328.                                                 echo 'alert("final ' . $cellRate . '");';
  329.                                                 break;
  330.                                             }
  331.                                         @endphp
  332.                                     @endforeach
  333.  
  334.  
  335.  
  336.                                     @php
  337.                                     $timeInterval = ($start_time->diff($period->end));
  338.                                     $intervalInSeconds = (new DateTime())->setTimeStamp(0)->add($timeInterval)->getTimeStamp();
  339.                                     $intervalInMinutes = $intervalInSeconds/60;
  340.                                     $intervalInSpans = $intervalInMinutes/30;
  341.                                     @endphp
  342.                                     @for ($i = 0; $i < $intervalInSpans; $i++)
  343.                                         @foreach($rates_arr[$facility->id] as $key => $rate)
  344.                                             @php
  345.                                                 $convertToDateTime = DateTime::createFromFormat('H:i:s', $rate->sort_rates);
  346.                                                 if ($current_time >= $convertToDateTime)
  347.                                                 {
  348.                                                     $cellRate = $rate->rate;
  349.                                                     echo 'alert("latest ' . $cellRate . '");';
  350.                                                     //but when to break if there's multiple past 24:00:00 rate?
  351.                                                 }
  352.                                                 else
  353.                                                 {
  354.                                                     echo 'alert("final ' . $cellRate . '");';
  355.                                                     break;
  356.                                                 }
  357.                                             @endphp
  358.                                         @endforeach
  359.                                         cell = row.insertCell(counterv2++);
  360.                                         cell.innerHTML = "potato";
  361.                                         cell.classList.add('highlight');
  362.                                         cell.setAttribute('value', '{{ $cellRate }}');
  363.                                         cell.setAttribute('curtime', '{{ $slot }}' );
  364.                                         @php
  365.                                             $current_time->add(new DateInterval('PT30M'));
  366.                                             $slot = $current_time->format('H:i:s');
  367.                                             echo 'alert("then ' . $slot . '");';
  368.                                         @endphp
  369.                                     @endfor
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.                                 @endif
  388.                             }
  389.                             @endforeach
  390.  
  391.  
  392.                             //generate table
  393.                         }
  394.                     </script>
  395.                     @endforeach
  396.                 </div>
  397.             </div>
  398.  
  399.  
  400.  
  401.  
  402.             <div class="col-11">
  403.                 <div class="table-responsive">
  404.                     <table class="table" id="myTable">
  405.                         <thead>
  406.                             <tr>
  407.                                 <th>
  408.                                     <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>
  409.                                         <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>
  410.                                     </div>
  411.                                 </th>
  412.  
  413.                                 @foreach ($period as $dt)
  414.                                     <th>{{ $dt->format("g:i A") }}</th>
  415.                                 @endforeach
  416.                             </tr>
  417.                         </thead>
  418.                         <tbody>
  419.                         </tbody>
  420.                     </table>
  421.                 </div>
  422.             </div>
  423.         </div>
  424.     </div>
  425.     <script type="text/javascript">
  426.         button = document.getElementById("{{'category'.$categories->first()->id}}");
  427.         button.click();
  428.     </script>
  429.     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  430.     <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
  431.  
  432. @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement