Forum OpenACS Development: cal item new start/end date

Collapse
Posted by Iuri Sampaio on
Adding a cal-item on calendar package. It is "registered" do be displayed on the calendar in the day respective filled to its start_date.

I want to switch it to be "registered" and displayed in the calendar accordingly to its end_date.

How do i change it?

I already debug
API [calendar::item::new] as well as some plsql functions but i still haven't figured that out.
fullquery name="calendar::item::new.insert_timespan"
querytext

begin
:1 := timespan.new(
start_date => to_date(:start_date,'YYYY-MM-DD HH24:MI'),
end_date => to_date(:end_date,'YYYY-MM-DD HH24:MI')
);
end;

/querytext
/fullquery

fullquery name="calendar::item::new.cal_item_add"
querytext
select cal_item__new (
null,
:calendar_id,
:name,
null,
null,
null,
:timespan_id,
:activity_id,
null,
'cal_item',
:calendar_id,
now(),
:creation_user,
:creation_ip
)

/querytext
/fullquery

Collapse
Posted by Iuri Sampaio on
The issue is not when a cal-item is added. But when it is displayed.

Every cal-item is attached with a timespan interval (start_date and end_date). Always!

So, if we just change the filter that makes it to be displayed in the respective start_date to end_date, for example in the query "select_all_day_items"

select
to_char(start_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_start_date,
to_char(end_date, 'YYYY-MM-DD HH24:MI:SS') as ansi_end_date,
to_number(to_char(start_date,'HH24'),'90') as start_hour,
to_number(to_char(end_date,'HH24'),'90') as end_hour,
to_number(to_char(end_date,'MI'),'90') as end_minutes,
coalesce(e.name, a.name) as name,
coalesce(e.status_summary, a.status_summary) as status_summary,
coalesce(e.description, a.description) as description,
e.event_id as item_id,
(select type from cal_item_types where item_type_id= ci.item_type_id) as item_type,
cals.calendar_id,
cals.calendar_name,
cals.package_id as cal_package_id,
(select count(1) from attachments where object_id=e.event_id) as num_attachments
$additional_select_clause
from cal_items ci,
acs_events e,
timespans s,
time_intervals t,
acs_activities a,
calendars cals
where e.timespan_id = s.timespan_id
and s.interval_id = t.interval_id
and e.activity_id = a.activity_id
and end_date between $interval_limitation_clause
and ci.cal_item_id = e.event_id
and cals.calendar_id = ci.on_which_calendar
and e.event_id = ci.cal_item_id
$filter_by_clause
$additional_limitations_clause
$calendars_clause
$order_by_clause

Attention to
and start_date between $interval_limitation_clause
and switch it to
and end_date between $interval_limitation_clause

Then we solve the issue.
Very easy! ;)