title: Calculate, Save and Display Bookings in a Specific Table
body: <p>I am trying to calculate the best possible car booking arrangements and display them.<br>
  I have Bookings and Cars, I need to assign each booking to a car depending on its availability.</p>
  <p>The bookings are stored in a database consisting of <em><code>Date In</code></em> <em><code>Date Out</code></em> <em><code>Car Group</code></em> and possibly a <em><code>PreBooked</code></em> tag along with other information.<br>
  Where:<br>
  <em><code>Date In</code></em>  = datetime from when the car is picked up <br>
  <em><code>Date Out</code></em>  = datetime from when the car is dropped off<br>
  <em><code>Car Group</code></em> = A enum value defining each cars class (A, B, C, C1, D, D1, E, E1, D, D1, M, M1)<br>
  <em><code>PreBooked</code></em> = text (a pre booked number plate or set to <code>NO PLATE</code> )
  <br><br>
  Now I have the following HTML table that needs to be filled:<br><br>
  <a href="https://i.stack.imgur.com/1CTAL.png" rel="nofollow noreferrer">Empty HTML Table</a>
  Each of the cars &quot;Plates&quot; also has a <code>Car Group</code>so that not just any booking can be assigned to a Car, only bookings matching their <code>Car Group</code> <br>
  (In this case <code>PLATE 1234</code>&amp;<code>PLATE 5678</code> are group <strong>A</strong> and <code>PLATE 9101</code> <strong>B</strong>)<br>
  <br>
  On the right are the dates going from 1-31 (For the images february has only 10 days :)  <br>Maybe it's also possible to generate separate tables for each month? Or a 365 column wide one :p<br>
  <br>
  I am trying to think of a way to automatically assign bookings to cars  with the following bookings:<br>
  Booking 1 (<em><code>Date In</code></em>: <strong>01/02/2022</strong> <em><code>Date Out</code></em>: <strong>07/02/2022</strong> <em><code>Car Group</code></em> A
  <br>
  Booking 2 (<em><code>Date In</code></em>: <strong>04/02/2022</strong> <em><code>Date Out</code></em>: <strong>06/02/2022</strong> <em><code>Car Group</code></em> A
  <br>
  Booking 3 (<em><code>Date In</code></em>: <strong>09/02/2022</strong> <em><code>Date Out</code></em>: <strong>25/02/2022</strong> <em><code>Car Group</code></em> A
  <br>
  Booking 4 (<em><code>Date In</code></em>: <strong>01/02/2022</strong> <em><code>Date Out</code></em>: <strong>09/02/2022</strong> <em><code>Car Group</code></em> B
  <br>
  And place them according to dates and Car Groups into the table<br><br> (Booking 1 and Booking 3 are assigned to the first car since dates don't overlap and they have booked the same <code>Car Group</code>,<br> while Booking 2 is assigned to the next car with available dates and same <code>Car Group</code>.<br> As well as Booking 4 which is assigned to an available group B car)
  <br><br>
  So the Table would now should look something like this:<br><br>
  <a href="https://i.stack.imgur.com/fbcaP.png" rel="nofollow noreferrer">Booking Table w. Data</a></p>
  <p>I need a way to check for possible booking date overlaps and if there is no overlap assign the booking to a car with same <code>Car Group</code> <strong>if</strong> no <code>PreBooked</code> plate it set.<br>
  If there is a <code>PreBooked</code> plate set, force assign it first to the specific car before calculating and assigning other bookings for that car.
  <br>
  <br> And then display each booking with information nicely in-between date colums with <code>colspan=&quot;&quot;</code> and to possibly be able to save the current table and not have it re-calculate on each page refresh...</p>