--
-- cal_item__new/19
--
create or replace function cal_item__new(
  new__cal_item_id integer,
  new__on_which_calendar integer,
  new__name character varying,
  new__description character varying,
  new__html_p boolean,
  new__status_summary character varying,
  new__timespan_id integer,
  new__activity_id integer,
  new__recurrence_id integer,
  new__object_type character varying,
  new__context_id integer,
  new__creation_date timestamp with time zone,
  new__creation_user integer,
  new__creation_ip character varying,
  new__package_id integer,
  new__location character varying DEFAULT NULL::character varying,
  new__related_link_url character varying DEFAULT NULL::character varying,
  new__related_link_text character varying DEFAULT NULL::character varying,
  new__redirect_to_rel_link_p boolean DEFAULT NULL::boolean
) returns int4 as $$

declare
    v_cal_item_id        cal_items.cal_item_id%TYPE;
begin
    v_cal_item_id := acs_event__new(
        new__cal_item_id,    -- event_id
    	new__name,           -- name
        new__description,    -- description
        new__html_p,         -- html_p
        new__status_summary, -- status_summary
        new__timespan_id,    -- timespan_id
        new__activity_id,    -- activity_id
        new__recurrence_id,  -- recurrence_id
        new__object_type,    -- object_type
        new__creation_date,  -- creation_date
        new__creation_user,  -- creation_user
        new__creation_ip,    -- creation_ip
        new__context_id,     -- context_id
        new__package_id,     -- package_id
	new__location,        -- location
	new__related_link_url,
	new__related_link_text,
	new__redirect_to_rel_link_p
    );

    insert into cal_items (cal_item_id,   on_which_calendar)
    values                (v_cal_item_id, new__on_which_calendar);

    return v_cal_item_id;
end;
$$ language plpgsql;