tags:

views:

41

answers:

1

hi

My form application calls for 2 chained select boxes with special conditions, and I'm using cakephp 1.3 to build this application.

The hierarchy and order of choices for the sections is this:

1 - hotel

2 - roomtype

the hotel has limits of how many visitors can be in each room

The relationships are:

customer hasOne hotel->roomtype for x weekdays AND / OR weekenddays

hotels have many roomtypes

roomtypes has limits to amount of visitors and different prices on weekdays/weekends

The user selects dates "arrival" and "departure" to the hotel and thus the list is populated with hotels that have rooms availiable and then the list with rooms. im showing the calculated price on the next "confirm" page.

anyone have any good ideas? im real stuck here.

many thx

+1  A: 

I would change your relationships and models. They don't make a ton of semantic sense -- why should a customer have one hotel roomtype? That doesn't make sense.

Instead, I'd recommend:

Room hasOne RoomType
Customer HABTM Reservation
Reservation hasOne RoomType

Is there a reason you don't want to make RoomType just a column in the Room model? Because then you could just have room, customer, reservation models that would collect all the information you need.

Travis Leleu
yes thank you! a roomtype could be a part of the room model. but there is another issue here: how to make a chained select and counting the dates and comparing this to the selected room/roomtype of the hotel. i dont know how to setup a chained select in cakephp and doing ajax functions inside this select so a price is displayed...also..should i put the amount of days (week/weekend) in the reservation?
Mikelangelo
Please clarify what you mean by "chained select". Remember, you can always use Model::query( 'Your custom SQL here' ). I'd probably just recalculate the days in a reservation in the afterFind() method of the model. Otherwise you risk having it fall out of date if the res is changed (and it's pretty easy to do date calcs in PHP, or even SQL).
Travis Leleu