Forums / Developer / Multiple object creation from single edit form

Multiple object creation from single edit form

Author Message

Roberto Cespa

Tuesday 17 October 2006 2:15:39 am

Good morning to everybody!
After a quite long pause using eZpublish, I'm back on it.
I'm developing a travel web site, almost like lastminute.com or EDreams.

I have an object (travel_offer) with some attributes (name, publish_start, publish_end, tour_operator, ecc. ecc.).
This object is also a container for the prices (object: price).
Object price has these attributes:

sell_mode: selection (how do we sell this package? on request or on a free sales basis?)
price_list: object relation with pricelists (net, gross, discounts, etc.)
treatment: object relation with treatments (full board, half board, etc.)
room_type: object relation with room_types (single, double, twin, etc)
departure_id: object relation with departure_cities (Rome, Milan, Venice, etc)
start_date: date object (first departure)
end_date: date object (last departure)
weekdays: selection (Mon, Tue, ..., Sun)
prices: matrix (base price + several fees like airport taxes)

Suppose I've a travel offer, departing from Rome and Milan every Tuesday and every Saturday from 1st Nov to 31st Dec.
I need to create one price object per each date, city: if I would write the code from scratch it would look like:

$oneday = 60 * 60 * 24; //Number of seconds in one day
foreach ( $departure_cities as $dep) {
    for ( $i=$start_date; $i<$end_date; $i+=$oneday ) {
       foreach ( $weekdays as $day ) {
          if ( date ("D", $i ) == $day ) {
             $object->setday = $day;
             $object->setdate = $i;
             $object->setcity = $dep;
             $object->store();
          }
       }
    }
}

In this way I could get in the "database" one row per date/day per departure city.
Why do I need this?
Because I need to store with prices also informations related to allottments (how many seats on the plane and/or how many rooms we bought in advance) and I need the ability to change the prices for single departure city or date.

I was thinking about using the workflows, but I'd like to know if someone can point me to some kind of solution.
In the meanwhile, I'm reading the eZpublish book, but it'd based on the older eZp 3.2 and I'm not sure that the solution I'll study will be working on 3.8.4 (the one I'm using now).

Ciao,
Roberto

Roberto Cespa

Wednesday 18 October 2006 4:37:14 am

Gulp!
no answer to this question...?
Did I find the problem of the new century?

I'll keep going on reading the book....

Nabil Alimi

Wednesday 18 October 2006 5:05:24 am

Hi Roberto,

I think Ezpublish 3.8 new feature might help you achieve what you want.

Take a look to Lukasz Blog : http://serwatka.net/index.php/en/blog/ez_publish_3_8_new_custom_edit_handler

There's an example of something similar to your case.

(Didn't try it yet ;)

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Roberto Cespa

Wednesday 18 October 2006 6:04:29 am

I read the blog article and it seems to be the solution to my problem!
Thank you very much for pointing me to that site!

Ciao,
Roberto