CREATE PROCEDURE [dbo].[OnlineFindHotelsetupSearch] @HotelNumber INT=0  AS
SET NOCOUNT ON
/*
    Created by Troels Buch April 2005
    
    Changes:
	AHE2024-02-16: Added CheckCleanStatusAtCheckin
	SG 2023-01-23: Added SystemSMSActivated
	SG 2022-05-05: Added CleaningMainSubInteraction
	SG 2022-01-13: Added ShortMessageServicesEnabled
	SG 2022-01-10: Added CheckEarliestCheckinTimeAgainstArrivalTime
	SG 2021-12-23: Added DefaultTableBookingMinutes
	SG 2020-09-10: Added EarliestCheckinTime
	SG 2020-07-28: Added 'KeySystem'
	AHE20181219: Added EnableDigitalCheckInOut
	SG 2018-07-25: Changed so we don't need to maintain a list of "per hotel" keys. 
	TBU20170606: Added OnlineUseDominoAvailability
	TBU20170504: Added onlineuseuniversalanalytic
	TBU20170405: Added onlineusegoogletagmanager
	TBU20170405: Added onlineallowusertochooseroomnumber
	TBU20170327: Added 'OnlineRoomTypeTextPerPAX'
    TBU20161104: Added 'IsDanHostel'
    KS20160720: Added 'TimeOfArrivalForDayRoom' and 'TimeOfDepartureForDayRoom'
	TBU20151105: Added OnlineOnlyValidateCreditCard
	TBU20151005: Added PicassoOnlineMaxAgeChildren1
    TBU20150304: Added onlineusewihpscript
    TBU20150224: Added OnlineGoogleAnalytId
    SG 20140428: Added 'HallClimbingUseClimbingAvailability' 
    VD20130902: Mail addresses now situated in a separate table - KUN i 8.1+!
    TB20130814: Tilføjet SalesChannelMail
    TB20130613: Added "onlinearrivaltimemaxvalue"
    SG 20130610: Added DatabaseVersionNumber
	TB20130408: Added OR searchkey = 'PicassoOnlineHotelMail' OR searchkey = 'OnlineUrlLinkToFront')
	LJE20121221: Added 'GiftCertificateMonth'.
	LJE20110822: Added 'EniroDenmarkUsername', 'EniroDenmarkPassword'
	TB20110504: Changed spelling 'OnlineUseProductWareRelation'
	TB20110329: Changed all sql. Can read Domino settings
	
    TB20110111: Added 'OnlineUseProductWareRalation'
    TB20101218: Added 'OnlineUseDevxCalendar'	
    TB20101108: Changed 'OnlineServiceCancelType'
    TB20101012: Changed 'OnlineShowPacketContentText'
    TB20101007: Added 'OnlineUsecustomermenu'
	TB20100625: Added 'OnlineGoogleAnalytId2'
	TB20100428: Added 'OnlineServiceCancelType'
	TB20100408: Added 'OnlineWare1stSortSortnumber'
	TB20100309: Added 'OnlineUseSectorAsLocation'
	TB20100112: Added 'OnlineGoogleAnalytId'
	TB20091203: Added 'OnlineGuestsplitbill'  'OnlineCompanysplitbill'  'OnlineAgencySplitbill'
	TB20091127: Added 'OnlinePatientHotelVersion'
	TB20091124: Added 'OnlineShowPacketContentText'
	TB20091110: Added 'OnlineShowonlyarrdatescalendar'
	TB20090930: Added 'OnlineSortDeliveryTypeDescending'
	TB20090929: Added 'OnlineUseOptionalwarePerRoomtype'
	TB20090805: Added 'OnlineUseNewsOnCustomer'
	TB20090805: Changed 'OnlineShowPaxAtCalander'
	TB20090603: Added 'OnlineOnlyValidateCreditcard'
	TB20090528: Added 'OnlineShowPersonNoAdult'
	TB20090527: Added 'OnlineShowRoomsAtCalendar'
	TB20090511: Added 'OnlineSaveRestypeAltRes'
	TB20090420: Added 'OnlineUseBookParm'
	TB20090204: Added 'OnlineUsepatienthotelmode'
	TB20090129: Deleted 'OnlineMailLogoAddress'
	TB20090129: Added 'OnlineShowUserCounter'
	TB20090120: Added 'OnlineShowDatePopup'
	TB20090116: Added 'Onlinepaintarrivaldayscalendar'
	TB20081204: Added 'OnlineOptionalWareOndefault'
	TB20081125: Added 'OnlinePricesInclVat'
	TB20081121: Added 'OnlineAlwaysAllowBookingWithoutCreditcard'
	TB20081118: Added 'OnlineRoomnumberBookResource' and 'OnlineRoomtypeBookResource'
	TB20081118: Added 'OnlineShowDemandedWaresInCart'
	TB20081111: Added 'OnlineFindHouseAddressFromRoomtype'
	TB20081104 Removed 'OnlineUseBigBanner'
	TB20081015 Added 'OnlineShowPriceEUR'
             AV 20080922 added OnlineTranslationShowAll
	MFR20080918 Added 'PicassoOnlineIncludeDynamicTopTextInConfirmationMail'
	
    NOTES: 	Even fkt. GetHotelSetupKeyValue get a default value from HotelSetup_DefaultValues, not all keys are in this table. We need to maintain defaultValues in code.
*/

--DECLARE  @HotelNumber INT
--SET @HotelNumber = 0

SELECT dbo.GetHotelSetupKeyValue(searchkey, C.CustomerNumber) AS KeyValue, searchkey FROM Hotelsetup H, Customer C WITH (NOLOCK) 
WHERE C.customertypenumber = 7 AND (localhotel = 1 OR HotelNumber > 0)
AND C.hotelnumber = @HotelNumber
AND (SearchKey LIKE ('Online%')  --  LIKE is not case-sensitive: show online, Online, ...
OR
  SearchKey LIKE ('PicassoOnline%')  -- LIKE is not case-sensitive: show picassoonline, PicassoOnline, ...
OR
  searchkey IN ('Arr24HoursStarts'
    ,'EniroSearch_BaseURL'
    ,'EniroSearch_PinCode'
    ,'EniroSearchEnabled'
    ,'EniroSearchIdent_IndType'
    ,'EniroSearchIdent_Phone'
    ,'EniroSearchIdent_PinCode'
    ,'EniroDenmarkUsername'
    ,'EniroDenmarkPassword'
    ,'ForceOnContactPerson'
    ,'ForceOnPOS'
    ,'ForceOnSegment'
    ,'GuestType'
    ,'HallBookingInterval'
    ,'NumberOfDecimalsInPrices'
    ,'PurposeCode'
    ,'TimeOfArrivalForRes'
    ,'TimeOfDepartureForRes'
    ,'UseDynamicPaymentControl'
	,'GiftCertificateMonth'
	,'DatabaseVersionNumber'
	,'HallClimbingUseClimbingAvailability'
	,'TimeOfArrivalForDayRoom'
	,'TimeOfDepartureForDayRoom'
	,'IsDanHostel'
	,'EnableDigitalCheckInOut'
	,'KeySystem'
	,'EarliestCheckinTime'
	,'DefaultTableBookingMinutes'
	,'CheckEarliestCheckinTimeAgainstArrivalTime'
	,'ShortMessageServicesEnabled'
	,'CleaningMainSubInteraction'
	,'SystemSMSActivated'
	,'CheckCleanStatusAtCheckin'
))
UNION
SELECT 
  MailAddresses.MailAddress keyvalue, -- Email AS keyvalue, 
 'SalesChannelMail' AS searchkey 
FROM CUSTOMER WITH (NOLOCK)   
  LEFT JOIN MailAddresses WITH (NOLOCK) ON MailAddresses.CustomerNumber = Customer.CustomerNumber AND MailAddresses.MailAddressType = 0
WHERE CustomerTypeNumber = 7 AND hotelnumber = @HotelNumber
ORDER BY SearchKey


