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

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

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

SET @FollowupNumber = @@IDENTITY

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