CREATE PROCEDURE dbo.OnlineAddLog @AReferenceNumber INT, @AGuestNumber INT, @ANote VARCHAR(1000), @APage VARCHAR(32), @AUserIdNumber INT = 0  AS
SET NOCOUNT ON
/*
  Created by Kent Johansen August 2016.
  Add followup for reservation

  Changes:
  KJ 20200623: Bug: Fix for "Log made with user techotel".
*/

DECLARE @FollowupNumber INT
DECLARE @CurDT DATETIME

SET @AUserIdNumber = ISNULL(@AUserIdNumber, 1)
IF @AUserIdNumber <= 0
  SET @AUserIdNumber = 1

EXEC SystemDateTime '', @CurDT OUTPUT

INSERT INTO FollowUp ([Date], Type, Priority, State, Note, CreatedDate, CreatedBy, Tag)
VALUES (@CurDT, 5, 17, 3, @ANote, @CurDT, @AUserIdNumber, @APage)

SET @FollowupNumber = @@IDENTITY

INSERT INTO ReservationFollowUpXTab (ReferenceNumber, GuestNumber, FollowUpNumber)
VALUES (@AReferenceNumber, @AGuestNumber, @FollowupNumber)