We run is an afternoon tea service for customers of the shop, www.beasofbloomsbury.com.
I need two PHP scripts to be written that do the following. We run a Shopify ecommerce store. Shopify will pass (via JSON or AJAX) a request that contains:
- size of party
- time of party
- date of party
- name of shop for reservation
We have a limited number of seats in the shop as described by the CSV file, which should be put into mysql.
When the request comes in, we want to make a booking. We always want to get to 100% and never turn down a customer unless there is no possible table for that sized party (after the readjusting):
When a request comes in:
- The customer must be queried to find an available table for the party in the store so that the smallest possible table combination that can seat everyone is reserved. Every single possible table combination is described in the CSV file attached and is a separate row, so there is no special logic needed except to round robin and find the table combination that works.
- If customers have to be shifted around to maximize capacity, customers must be shifted around. So if a second request comes in, it may make sense to move a previous customer.
- This is an NP-complete problem, so it is okay to try every single possible combination to find the best seating arrangement.
- In the event of no tables, a message is passed back saying no slot available.
- A unique ID is also passed back that serves as a reservation confirmation number.
A second PHP script will do the following:
- Take in the reservation confirmation number
- Open a connection to Google Calendar (see https://developers.google.com/google-apps/calendar/v1/developers_guide_php). We will create a separate Google Calendar for each shop.
- Write out the entire calendar for the day to Google Calendar for that shop (it has to write out the entire calendar because tables may have moved around and the reservation number is only for the one reservation, so there is no way to pass around state).
The CSV file attached has the following format:
Shop name, table combination, capacity, ignore, ignore
It would be great if our developer was familiar with Shopify and jQuery so we can then implement integrate this with Shopify.