What would be the best way to structure orders for a restaurant (available languages are php and javascript)? Since there are multiple tables (the ones you keep things on...), I thought of using objects in javascript. But I am quite new to javascript and absolutely new to OOP, so I'm not sure whether this is the best solution, and whether my design is actually ok. Here is what I have come up with:
var order = {
id: 0,
table: 0,
number_of_items: 0,
item: {
name: "",
quantity: 0,
unit_price: 0
},
total: 0
};
I think you can do away with some redundant elements in your structure:
How about this?
Notes:
There are multiple tables, and each table can -over the course of a service- have several orders.
I would think the basic component/object of your system would be the cover itself, consisting of something along the lines of:
order_id, the table, the course (there'll be a minimum of one course), the chosen dish and its cost, the time of ordering (this may not seem important, but it usually is to a -good- maitre d'hotel or service manager) and the drinks.
Here is one way.
Well, orders should be independent of tables. Really you'd have a table object that consisted of seat/ customer objects and an order object that consisted of one or more items (with items having name, quantity, price or whatever else belongs to an item).
As an additional complication, an order could either belong to a seat (one person) or a table (e.g., shared appetizer). Supporting that relationship would allow you to do different things when trying to compile the bill for the table (like if you had to provide split checks).
In addition to the other answers, what about special preparation directions? Do you want separate Burger items (Burger-medium rare, Burger-well done), or do you want a separate table with the cooking directions linked to that item?
Your answer really depends on your audience. Is it for the screen in the kitchen, for the waitress entering the order, the cashier, the health inspector, or all of the above?