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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 00:22:20
Script start
Timing: Jan 19 2025 00:22:20
Module start 'layout'
Timing: Jan 19 2025 00:22:20
Module start 'content'
Timing: Jan 19 2025 00:22:21
Module end 'content'
Timing: Jan 19 2025 00:22:21
Script end

Main resources:

Total runtime0.8123 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 588.0469152.6406
Module start 'layout' 0.00740.0037 740.687539.4766
Module start 'content' 0.01110.7998 780.1641561.5781
Module end 'content' 0.81090.0014 1,341.742212.1250
Script end 0.8123  1,353.8672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4403160.0002
Check MTime0.00150.1903160.0001
Mysql Total
Database connection0.00100.125810.0010
Mysqli_queries0.744491.6317600.0124
Looping result0.00120.1492580.0000
Template Total0.769494.720.3847
Template load0.00220.276420.0011
Template processing0.767194.432920.3836
Template load and register function0.00030.039910.0003
states
state_id_array0.00140.175210.0014
state_identifier_array0.00080.094720.0004
Override
Cache load0.00190.2337450.0000
Sytem overhead
Fetch class attribute can translate value0.00140.167020.0007
Fetch class attribute name0.00210.253850.0004
XML
Image XML parsing0.00060.077720.0003
class_abstraction
Instantiating content class attribute0.00000.001650.0000
General
dbfile0.00090.1156160.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs