USP_DATAFORMTEMPLATE_EDIT_COPYITINERARY
The save procedure used by the edit dataform template "Copy Itinerary Edit Data Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter indicating the ID of the record being edited. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@RESERVATIONID | uniqueidentifier | IN | Reservation |
@COPYITINERARYID | uniqueidentifier | IN | Itinerary |
@IGNORECONFLICTS | bit | IN | Ignore itinerary resource conflicts when saving |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_COPYITINERARY
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@RESERVATIONID uniqueidentifier,
@COPYITINERARYID uniqueidentifier,
@IGNORECONFLICTS bit
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
declare @STATUSCODE tinyint;
select @STATUSCODE = SALESORDER.STATUSCODE
from dbo.SALESORDER
inner join dbo.ITINERARY on ITINERARY.RESERVATIONID = SALESORDER.ID
where ITINERARY.ID = @ID
if @STATUSCODE = 1 or @STATUSCODE = 5
raiserror('BBERR_INVALIDSTATUS', 13, 1);
exec dbo.USP_ITINERARY_COPYFROMEXISTING @ID, @COPYITINERARYID, @CHANGEAGENTID, @IGNORECONFLICTS;
update dbo.ITINERARY set
TRACKID = null,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where ID = @ID
if @IGNORECONFLICTS = 0
begin
if exists(select 1 from dbo.ITINERARYITEM where ITINERARYID = @ID)
begin
declare @START datetime;
declare @END datetime;
select
@START = ITINERARY.STARTDATETIME,
@END = ITINERARY.ENDDATETIME
from dbo.ITINERARY
where ID = @ID
declare @RESOURCES xml;
set @RESOURCES = dbo.UFN_ITINERARYRESOURCE_GETRESOURCES_TOITEMLISTXML(@ID);
declare @STAFFRESOURCES xml;
set @STAFFRESOURCES = dbo.UFN_ITINERARY_GETSTAFFRESOURCES_TOITEMLISTXML(@ID);
if dbo.UFN_CONFLICTCHECK_CONFLICTSEXIST
(@START, @END, null, @RESOURCES, @STAFFRESOURCES, null, @ID, null, 0, 1, 0, 0) = 1
begin
raiserror('BBERR_CONFLICTSEXIST', 13, 1);
return 1;
end
end
end
-- if this uses a flat rate with per-ticket pricing, we need to update that price
exec dbo.USP_RESERVATION_UPDATEFLATRATEPERTICKETPRICE @RESERVATIONID, null, @CHANGEAGENTID, @CURRENTDATE;
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;