forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathobjNewReservation.pas
2041 lines (1712 loc) · 66.6 KB
/
objNewReservation.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit objNewReservation;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Contnrs, Dialogs, NativeXML
, ADODB
, Data.DB
, cmpRoomerDataSet
, cmpRoomerConnection
, uRoomerThreadedRequest
, uPriceOBJ
, objHomeCustomer
, objRoomRates
, Generics.Collections
, PrjConst
, ustringUtils
, ug
, uAlerts
, uRoomerDefinitions
, RoomerExceptionHandling
, uMarketDefinitions
, uBreakfastTypeDefinitions, uAmount
;
TYPE
EReservationCreationException = class(ERoomerException);
EReservationIDNotFoundException = class(ERoomerException);
TResMedhod = (rmNormal, rmDateRoom, rmDate, rmRoom, rmBlocked,rmAllotment,rmImport);
TYPE
TnewRoomReservationItem = class; // forward
TReservationExtra = class(TObject)
private
FRoomReservationItem: TnewRoomReservationItem;
FItemID: integer;
FItem: string;
FCount: integer;
FPrice: double;
FFromDate: TDate;
FToDate: TDate;
FDescription: string;
FID: integer;
function GetPricePerDay: double;
function GetTotalPrice: double;
function GetFromDate: TDate;
function GetToDate: TDate;
protected
procedure SetNewDepartureDate(aNewDepartureDate: TDate);
procedure SetNewArrivalDate(aNewArrivalDate: TDate);
procedure AddInvoiceInsert(aExecPlan: TRoomerExecutionPlan);
public
constructor Create(aitemID: integer; const aItem: string; const aDesc: string;
aCount: integer; aPrice: double; aFromdate, aToDate: TDate);
/// <summary> Post reservationExtra to server </summary>
procedure Post(aUseTransaction: boolean=true);
function IsAvailable: boolean;
/// <summary> Calculate the total price of this item.</summary>
property TotalPrice: double read GetTotalPrice;
/// <summary> Calculate the total price of this item per day</summary>
property PricePerDay: double read GetPricePerDay;
property RoomReservationItem: TnewRoomReservationItem read FRoomReservationItem write FRoomReservationItem;
property ID: integer read FID write FID;
property ItemID: integer read FItemID write FItemID;
property Item: string read FItem write FItem;
property Description: string read FDescription write FDescription;
property Count: integer read FCount write FCount;
property PricePerItemPerDay: double read FPrice write FPrice;
/// <summary> Startdate of use of this item, if not set (<=0) arrivaldate of roomreservation is assumed </summary>
property FromDate: TDate read GetFromDate write FFromDate;
/// <summary> Enddate of use of this item, if not set (<=0) Departuredate of roomreservation is assumed </summary>
property ToDate: TDate read GetToDate write FToDate;
end;
TReservationExtrasList = class(TObjectList<TReservationExtra>)
private
FReservationitem: TnewRoomReservationItem;
protected
procedure Notify(const Item: TReservationExtra; Action: TCollectionNotification); override;
public
constructor Create(aReservationItem: TnewRoomreservationItem); overload;
function TotalPrice: double;
/// <summary>Check if ToDate of all extras is not later then new departure date. If so correct this </summary>
procedure CorrectForNewDepartureDate(aNewDepartureDate: TDate);
/// <summary>Check if ToDate of all extras is not later then new departure date. If so correct this </summary>
procedure CorrectForNewArrivalDate(aNewArrivalDate: TDate);
/// <summary> Add reservationextras from the provided dataset </summary>
procedure LoadFromDataset(aDataset: TDataset);
/// <summary> Post all ReservationExtras to server
procedure Post(aUseTransaction: boolean=true);
procedure DeleteAllFromDatabase;
function IsAvailable(aUnavailableList: TStringlist): boolean;
end;
TnewRoomReservationItem = class
private
FRoomReservation: integer;
FRoomNumber: string;
FRoomType: string;
FPackage : string;
FArrival: TDate;
FDeparture: TDate;
FGuestCount: integer;
FAvragePrice: Double;
FAvrageDiscount : Double;
FRateCount: integer;
FChildrenCount: integer;
FInfantCount: integer;
FPriceCode : string;
FMainGuestName : string;
FNotes : string;
FRates: TRates;
FBreakfast: TBreakfastType;
FBreakfastCost: TAmount;
FExtraBedCost: Double;
FExtraBedIncluded: Boolean;
FExtraBed: Boolean;
FExtraBedCostGroupAccount: Boolean;
FManualChannelId: Integer;
FratePlanCode: String;
FExpCOT: string;
FExpTOA: string;
FExtras: TReservationExtraslist;
FReservation: integer;
function getRoomReservation: integer;
function getRoomNumber: string;
function getRoomType: string;
function getPackage: string;
function getPriceCode: string;
function getArrival: TDate;
function getDeparture: TDate;
function getGuestCount: integer;
function getAvragePrice: Double;
function getAvrageDiscount: Double;
function getRateCount: integer;
function getChildrenCount: integer;
function getInfantCount: integer;
function getMainGuestName: string;
function getNotes: string;
procedure SetRoomreservation(Value: integer);
procedure SetRoomNumber(Value: string);
procedure SetRoomType(Value: string);
procedure SetPackage(Value: string);
procedure SetPriceCode(Value: string);
procedure SetArrival(Value: TDate);
procedure SetDeparture(Value: TDate);
procedure SetGuestCount(Value: integer);
procedure SetAvragePrice(Value: Double);
procedure SetAvrageDiscount(Value: Double);
procedure setRateCount(Value: integer);
procedure setChildrenCount(Value: integer);
procedure setInfantCount(Value: integer);
procedure SetMainGuestName(Value: string);
procedure SetNotes(Value: string);
procedure SetExpCOT(const Value: string);
procedure SetExpTOA(const Value: string);
// **
public
constructor Create(aRoomReservation: integer;
aRoomNumber: string;
aRoomType: string;
aPackage : string;
aArrival: TDate;
aDeparture: TDate;
aGuestCount: integer;
aAvragePrice: Double;
aAvrageDiscount: Double;
aRateCount: integer;
aChildrenCount: integer;
aInfantCount: integer;
aPriceCode : string;
aMainGuestName : string;
notes : string
); overload;
constructor Create(const aRoomNumber: string; aArrival: TDate; aDeparture: TDate); overload;
destructor Destroy; override;
property Reservation: integer read FReservation write FReservation;
/// <summary>
/// Must be unique. If negative then it represent a temporary roomreservation number, not yet created in the database
/// If positive then this is an actual roomreservation number already defined in the database
/// </summary>
property RoomReservation: integer read getRoomReservation write SetRoomreservation ;
property RoomNumber : string read getRoomNumber write SetRoomNumber ;
property RoomType : string read getRoomType write SetRoomType ;
property Package : string read getPackage write SetPackage ;
property PriceCode : string read getPriceCode write SetPriceCode ;
property Arrival : TDate read getArrival write SetArrival ;
property Departure : TDate read getDeparture write SetDeparture ;
property GuestCount : integer read getGuestCount write SetGuestCount ;
property AvragePrice : Double read getAvragePrice write SetAvragePrice ;
property AvrageDiscount : Double read getAvrageDiscount write SetAvrageDiscount ;
property RateCount : integer read getRateCount write setRateCount ;
property ChildrenCount : integer read getChildrenCount write setChildrenCount ;
property InfantCount : integer read getInfantCount write setInfantCount ;
property MainGuestName : string read getMainGuestName write SetMainGuestName ;
property Notes : string read getNotes write SetNotes ;
property Breakfast : TBreakfastType read FBreakfast write FBreakfast;
property BreakfastCost : TAmount read FBreakfastCost write FBreakfastCost ;
property ExtraBed : Boolean read FExtraBed write FExtraBed ;
property ExtraBedIncluded : Boolean read FExtraBedIncluded write FExtraBedIncluded ;
property ExtraBedCost : Double read FExtraBedCost write FExtraBedCost ;
property ExtraBedCostGroupAccount : Boolean read FExtraBedCostGroupAccount write FExtraBedCostGroupAccount ;
property Rates : TRates read FRates write FRates ;
property ManualChannelId : Integer read FManualChannelId write FManualChannelId ;
property ratePlanCode : String read FratePlanCode write FratePlanCode ;
property ExpTOA: string read FExpTOA write SetExpTOA ;
property ExpCOT: string read FExpCOT write SetExpCOT ;
property Extras: TReservationExtraslist read FExtras;
end;
/// ///////////////////////////////////////////////////////////////////////////
// TSelectedRoomItem
//
/// ///////////////////////////////////////////////////////////////////////////
TnewRoomReservationItemsList = class(TObjectList<TnewRoomReservationItem>)
public
/// <summary>
/// Returns the lowest (negative) used roomreservationnumber - 1, which can be used as a
/// temporary roomreservationnumber for newRoomReservationItem
/// </summary>
function GetNewTempRoomResNumber: integer;
end;
/// ///////////////////////////////////////////////////////////////////////////////////
/// TSelectedRooms
///
/// //////////////////////////////////////////////////////////////////////////////////
TnewRoomReservation = class
private
FXmlFileName: string;
FRoomCount: integer;
FRoomList: TnewRoomReservationItemsList; {each room in reservation}
FHotelcode: string;
function getRoomCount: integer;
protected
FReservation: integer;
public
constructor Create(aHotelCode: string);
destructor Destroy; override;
function getReservationArrival: TDate;
function getReservationDeparture: TDate;
function TotalGuests: Integer;
function TotalPersons: integer;
property XmlFileName: string read FXmlFileName write FXmlFileName;
property Hotelcode: string read FHotelcode write FHotelcode;
function FindRoomFromRoomNumber(RoomNumber: string; StartAt: integer; caseSensitive: Boolean = false): integer;
function FindRoomFromRoomReservation(RoomReservation: integer; StartAt: integer): integer;
property RoomItemsList: TnewRoomReservationItemsList read FRoomList;
property RoomCount: integer read getRoomCount;
property ReservationArrival: TDate read getReservationArrival;
property ReservationDeparture: TDate read getReservationDeparture;
end;
/// ////////////////////////////////////////////////////////////////////////////////////////////
//
//
/// ////////////////////////////////////////////////////////////////////////////////////////////
TNewReservation = class
private
FHotelcode: string;
FnewRoomReservations: TnewRoomReservation; // i.e roomreservation
FHomeCustomer: THomeCustomer;
FShowProfile: Boolean;
FresMedhod: TResMedhod;
FIsQuick: Boolean;
// Values not available until after create
FPriceFound: Boolean;
// Hdata parameters
FConnection: TRoomerConnection;
FLoglevel: integer;
FLogPath: string;
// New 2013-01-14
FStaff: string;
FOutOfOrderBlocking: Boolean;
FSendConfirmationEmail: Boolean;
FAlertList: TAlertList;
FMarket: TReservationMarketType;
FCOnfirmationEmailSent: boolean;
procedure RemoveRemnants(ResId: Integer);
// procedure DeleteReservation(aReservation: integer);
protected
FReservationId: integer;
public
// constructor Create(aHotelCode, Staff: string); overload;
constructor Create(const aHotelCode, Staff: string; const contactAddress1: string = '';
const contactAddress2: string = '';
const contactAddress3: string = '';
const contactAddress4: string = '');
destructor Destroy; override;
Function CreateReservation(DeleteResNr : integer=-1; Transactional : Boolean = true) : Boolean;
procedure SendConfirmationEmailIfNeeded;
property Hotelcode: string read FHotelcode write FHotelcode;
property newRoomReservations: TnewRoomReservation read FnewRoomReservations
write FnewRoomReservations;
property HomeCustomer: THomeCustomer read FHomeCustomer write FHomeCustomer;
property ShowProfile: Boolean read FShowProfile write FShowProfile;
property resMedhod: TResMedhod read FresMedhod write FresMedhod;
property IsQuick: Boolean read FIsQuick write FIsQuick;
// ReservationId of newly created reservation, Values not available until after create
property ReservationId: integer read FReservationId write FReservationId;
property PriceFound: Boolean read FPriceFound write FPriceFound;
// Hdata parameters
property Connection: TRoomerConnection read FConnection write FConnection;
property loglevel: integer read FLoglevel write FLoglevel;
property logpath: string read FLogPath write FLogPath;
property Staff: string read FStaff write FStaff;
property OutOfOrderBlocking: Boolean read FOutOfOrderBlocking write FOutOfOrderBlocking;
property SendConfirmationEmail: Boolean read FSendConfirmationEmail write FSendConfirmationEmail;
property ConfirmationEmailSent: boolean read FCOnfirmationEmailSent;
property AlertList : TAlertList read FAlertList write FAlertList;
property Market: TReservationMarketType read FMarket write FMarket;
end;
implementation
uses
_glob,
hData,
ud,
uAppGlobal,
uGuestPortfolioEdit,
uActivityLogs
, uFrmBusyMessage
, uUtils
, DateUtils
, uDateUtils
, Math
, uSQLUtils, uReservationEmailingDialog, uRoomerIDList
, uInvoiceDefinitions;
const
cSTOCKITEM_IMPORTREFERENCE = 'STOCKITEM';
/// ///////////////////////////////////////////////////////////////////////////
// TSelectedRoomItem
/// ///////////////////////////////////////////////////////////////////////////
constructor TnewRoomReservationItem.Create(aRoomReservation: integer;
aRoomNumber: string;
aRoomType: string;
aPackage: string;
aArrival: TDate;
aDeparture: TDate;
aGuestCount: integer;
aAvragePrice: Double;
aAvrageDiscount: Double;
aRateCount: integer;
aChildrenCount: integer;
aInfantCount: integer;
aPriceCode : string;
aMainGuestName : string;
notes : string
);
begin
inherited Create;
FExtras := TReservationExtrasList.Create(self);
setRoomreservation(aRoomReservation);
setRoomNumber(aRoomNumber);
setRoomType(aRoomType);
setPackage(aPackage);
setArrival(aArrival);
setDeparture(aDeparture);
setGuestCount(aGuestCount);
setAvragePrice(aAvragePrice);
setAvrageDiscount(aAvrageDiscount);
setRateCount(aRateCount);
setChildrenCount(aChildrenCount);
setInfantCount(aInfantCount);
setPriceCode(aPriceCode);
setMainGuestName(aMainGuestName);
setNotes(notes);
FRates := TRates.Create('');
FBreakfast := TBreakfastType.None;
FBreakfastCost := 0.00;
FExtraBed := False;
FExtraBedIncluded := False;
FExtraBedCost := 0.00;
end;
constructor TnewRoomReservationItem.Create(const aRoomNumber: string; aArrival, aDeparture: TDate);
begin
Create(0, aRoomNumber, '', '', aArrival, aDeparture, 0, 0, 0, 0, 0, 0, '', '', '');
end;
destructor TnewRoomReservationItem.Destroy;
begin
FRates.Free;
FExtras.Free;
inherited;
end;
function TnewRoomReservationItem.getRateCount: integer;
begin
result := FRateCount;
end;
function TnewRoomReservationItem.getRoomNumber: string;
begin
result := FRoomNumber
end;
function TnewRoomReservationItem.getRoomReservation: integer;
begin
result := FRoomReservation;
end;
function TnewRoomReservationItem.getRoomType: string;
begin
result := FRoomType;
end;
function TnewRoomReservationItem.getPackage: string;
begin
result := FPackage;
end;
function TnewRoomReservationItem.getPriceCode: string;
begin
result := FPriceCode;
end;
function TnewRoomReservationItem.getMainGuestName: string;
begin
result := copy(FMainGuestName,1,100);
end;
function TnewRoomReservationItem.getNotes: string;
begin
result := FNotes;
end;
function TnewRoomReservationItem.getArrival: TDate;
begin
result := FArrival
end;
function TnewRoomReservationItem.getAvragePrice: Double;
begin
result := FAvragePrice;
end;
function TnewRoomReservationItem.getAvrageDiscount: Double;
begin
result := FAvrageDiscount;
end;
function TnewRoomReservationItem.getChildrenCount: integer;
begin
result := FChildrenCount;
end;
function TnewRoomReservationItem.getDeparture: TDate;
begin
result := FDeparture
end;
function TnewRoomReservationItem.getGuestCount: integer;
begin
result := FGuestCount;
end;
function TnewRoomReservationItem.getInfantCount: integer;
begin
result := FInfantCount;
end;
procedure TnewRoomReservationItem.SetGuestCount(Value: integer);
begin
FGuestCount := Value
end;
procedure TnewRoomReservationItem.setInfantCount(Value: integer);
begin
FInfantCount := Value;
end;
procedure TnewRoomReservationItem.setRateCount(Value: integer);
begin
FRateCount := Value;
end;
procedure TnewRoomReservationItem.SetRoomNumber(Value: string);
begin
FRoomNumber := Value
end;
procedure TnewRoomReservationItem.SetRoomreservation(Value: integer);
begin
FRoomReservation := Value;
end;
procedure TnewRoomReservationItem.SetRoomType(Value: string);
begin
FRoomType := Value;
end;
procedure TnewRoomReservationItem.SetPackage(Value: string);
begin
FPackage := Value;
end;
procedure TnewRoomReservationItem.SetPriceCode(Value: string);
begin
FPriceCode := Value;
end;
procedure TnewRoomReservationItem.SetMainGuestName(Value: string);
begin
FMainGuestName := Value;
end;
procedure TnewRoomReservationItem.SetNotes(Value: string);
begin
FNotes := Value;
end;
procedure TnewRoomReservationItem.SetArrival(Value: TDate);
begin
FArrival := Value;
FExtras.CorrectForNewArrivalDate(FArrival);
end;
procedure TnewRoomReservationItem.SetAvragePrice(Value: Double);
begin
FAvragePrice := Value;
end;
procedure TnewRoomReservationItem.SetAvrageDiscount(Value: Double);
begin
FAvrageDiscount := Value;
end;
procedure TnewRoomReservationItem.setChildrenCount(Value: integer);
begin
FChildrenCount := value;
end;
procedure TnewRoomReservationItem.SetDeparture(Value: TDate);
begin
FDeparture := Value;
FExtras.CorrectForNewDepartureDate(FArrival);
end;
procedure TnewRoomReservationItem.SetExpCOT(const Value: string);
begin
FExpCOT := Value;
end;
procedure TnewRoomReservationItem.SetExpTOA(const Value: string);
begin
FExpTOA := Value;
end;
/// ///////////////////////////////////////////////////////////////////
{ TSelectedRooms }
/// ///////////////////////////////////////////////////////////////////
constructor TnewRoomReservation.Create(aHotelCode: string);
begin
inherited Create;
FRoomList := TnewRoomReservationItemsList.Create(True);
FHotelcode := aHotelCode;
FRoomCount := 0;
end;
destructor TnewRoomReservation.Destroy;
begin
FRoomList.Free;
inherited;
end;
function TnewRoomReservation.getReservationArrival: TDate;
var
i: integer;
tmpDate: TDate;
begin
tmpDate := 0;
for i := 0 to FRoomList.Count - 1 do
begin
if i = 0 then
begin
tmpDate := FRoomList[i].FArrival;
end;
if FRoomList[i].FArrival < tmpDate then
tmpDate := FRoomList[i].FArrival;
end;
result := tmpDate;
end;
function TnewRoomReservation.getReservationDeparture: TDate;
var
i: integer;
tmpDate: TDate;
begin
tmpDate := 0;
for i := 0 to FRoomList.Count - 1 do
begin
if i = 0 then
begin
tmpDate := FRoomList[i].FDeparture;
end;
if FRoomList[i].FArrival > tmpDate then
tmpDate := FRoomList[i].FDeparture;
end;
result := tmpDate;
end;
function TnewRoomReservation.FindRoomFromRoomNumber(RoomNumber: string;
StartAt: integer; caseSensitive: Boolean): integer;
var
i: integer;
Room: string;
begin
result := -1;
if StartAt > FRoomList.Count - 1 then
exit;
if not caseSensitive then
begin
RoomNumber := ansiLowercase(RoomNumber);
end;
for i := StartAt to FRoomList.Count - 1 do
begin
Room := FRoomList[i].FRoomNumber;
if not caseSensitive then
begin
Room := ansiLowercase(Room);
end;
if RoomNumber = Room then
begin
result := i;
Break;
end;
end;
end;
function TnewRoomReservation.FindRoomFromRoomReservation(RoomReservation: integer; StartAt: integer): integer;
var
i: integer;
RoomRes : integer;
begin
result := -1;
if StartAt > FRoomList.Count - 1 then
exit;
for i := StartAt to FRoomList.Count - 1 do
begin
RoomRes := FRoomList[i].FRoomReservation;
if Roomreservation = RoomRes then
begin
result := i;
Break;
end;
end;
end;
function TnewRoomReservation.getRoomCount: integer;
begin
// Testa
result := FRoomList.Count;
end;
function TnewRoomReservation.TotalGuests: Integer;
var
lRoomRes: TnewRoomReservationItem;
begin
Result := 0;
for lRoomres in RoomItemsList do
Result := Result + lRoomRes.GuestCount;
end;
function TnewRoomReservation.TotalPersons: integer;
var
lRoomRes: TnewRoomReservationItem;
begin
Result := 0;
for lRoomres in RoomItemsList do
Result := Result + lRoomRes.GuestCount + lRoomRes.ChildrenCount + lRoomRes.InfantCount;
end;
/// /////////////////////////////////////////////////////////////////////////////
//
//
/// /////////////////////////////////////////////////////////////////////////////
{ TNewReservation }
constructor TNewReservation.Create(const aHotelCode, Staff: string;
const contactAddress1: string = '';
const contactAddress2: string = '';
const contactAddress3: string = '';
const contactAddress4: string = '');
begin
FHotelcode := Hotelcode;
FnewRoomReservations := TnewRoomReservation.Create(aHotelCode);
if contactAddress1.IsEmpty then
FHomeCustomer := THomeCustomer.Create(aHotelCode, hData.ctrlGetString('RackCustomer'))
else
FHomeCustomer := THomeCustomer.Create(aHotelCode, '',contactAddress1,contactAddress2,contactaddress3,contactAddress4);
FReservationId := -1; //hData.RV_SetNewID();
FShowProfile := false;
FresMedhod := rmNormal;
FIsQuick := true;
FStaff := Staff;
FConnection := Connection;
FLoglevel := loglevel;
FLogPath := logpath;
FPriceFound := true;
FAlertList := TAlertList.Create(0, 0, atUNKNOWN);
end;
destructor TNewReservation.Destroy;
begin
FAlertList.Free;
FHomeCustomer.Free;
FNewRoomReservations.Free;
inherited;
end;
const UPDATE_QUERY = 'INSERT INTO home100.DOORCODE_MESSAGE_SCHEDULE('
+ 'HOTEL_ID, '
+ 'BOOKING_ID, '
+ 'ROOM_RES_ID, '
+ 'FIRST_NAME, '
+ 'LAST_NAME, '
+ 'PHONENUMBER, '
+ 'EMAIL, '
+ 'HOTEL_EMAIL, '
+ 'HOTEL_ERR_EMAIL, '
+ 'DOORID, '
+ 'ARRIVAL_DATE, '
+ 'DEPARTURE_DATE, '
+ 'TIMEZONE, NAME_FOR_MAIL, '
+ 'GENDER_FOR_MAIL'
+ ') '
+ 'VALUES ('
+ ''':hotelId'', '
+ ''':bookingId'', '
+ ''':roomResId'', '
+ ''':firstName'', '
+ ''':lastName'', '
+ ''':phone'', '
+ ''':email'', '
+ ''':hotelEmail'', '
+ ''':hotelErrEmail'', '
+ ''':doorId'', '
+ ''':arrDate'', '
+ ''':depDate'', '
+ ''':tz'', '
+ ''':mailName'', '
+ ''':mailGender'''
+ ')';
procedure TNewReservation.RemoveRemnants(ResId : Integer);
var
s, s1 : String;
lPostThreadedData : TPutOrPostDataThreaded;
begin
frmBusyMessage.ChangeMessage(GetTranslatedText('shTx_Removing_Allotment_Traces'));
lPostThreadedData := TPutOrPostDataThreaded.Create;
try
s := format('resapi/booking/remove/reservation2/%d', [ResId]);
s1 := format('transactional=%s&reason=%s&request=%s&information=%s&canceltype=%d&makecopy=%s',
[BoolToString(False), 'Removing remnants after creating new reservation from allotment', '', '', 0, BoolToString(False)]);
lPostThreadedData.Post(s, s1, nil);
finally
lPostThreadedData.Free;
end;
end;
procedure TNewReservation.SendConfirmationEmailIfNeeded;
begin
if SendConfirmationEmail then
FCOnfirmationEmailSent := SendNewReservationConfirmation(ReservationId);
end;
Function TNewReservation.CreateReservation(DeleteResNr : integer=-1; Transactional : Boolean = true): Boolean;
var
rSet : TRoomerDataSet;
// iRoomReservation: integer;
iLastPerson: integer;
Customer: string;
sArrival: string;
sDeparture: string;
Arrival: TDate;
Departure: TDate;
iDayCount: integer;
sDate: string;
lDate: TDate;
RoomNumber: string;
isNoRoom: Boolean;
RoomType: string;
Package : string;
sDates: string;
ReservationArrival: TDate;
ReservationDeparture: TDate;
reservationName: string;
guestName: string;
Address1: string;
Address2: string;
Address3: string;
Address4: string;
Country: string;
Tel1: string;
Tel2: string;
Fax: string;
CustomerEmail: string;
CustomerWebSite: string;
ContactName : string;
ContactPhone : string;
ContactPhone2 : string;
ContactFax : string;
ContactEmail : string;
ContactAddress1 : string;
ContactAddress2 : string;
ContactAddress3 : string;
ContactAddress4 : string;
ContactCountry : string;
CustPID: string;
reservationDate: TDate;
Staff: String;
ReservationPaymentInfo: string;
ReservationGeneralInfo: string;
HiddenInfo: string;
MarketSegment: string;
Currency: string;
lBreakfast: TBreakfastType;
isGroupInvoice: Boolean;
RoomStatus: string;
PriceCode: string;
MainGuestName : string;
numGuests ,
numChildren ,
numInfants : integer;
Discount: Double;
RoomPMInfo: string;
RoomHiddenInfo: string;
GuestCompany: string;
GuestType: string;
GuestInformation: string;
GuestPID: string;
// Data Holders
reservationData : recReservationHolder;
invoiceHeadData : recInvoiceHeadHolder;
roomReservationData: recRoomReservationHolder;
roomsDateData : recRoomsDateHolder;
personData : recPersonHolder;
invoicelineData : recInvoiceLineHolder;
// priceNotFound : boolean;
DayCount: integer;
Processed: integer;
FirstDate: TDate;
LastDate: TDate;
useStayTax: Boolean;
useInNationalReport: Boolean;
channel: integer;
invRefrence : String;
ExecutionPlan : TRoomerExecutionPlan;
contactIsMainGuest : boolean;
lstReservationActivity : TStringlist;
lstInvoiceActivity : TStringlist;
ExpTOA: string;
ExpCOT: string;
newRoomReservationItem: TnewRoomReservationItem;
lRevenue: Double;
lNewRoomRes: TnewRoomReservationItem;
procedure init;
begin
Currency := FHomeCustomer.Currency;
Customer := FHomeCustomer.Customer;
guestName := FHomeCustomer.guestName;
invRefrence := FHomeCustomer.invRefrence;
reservationName := FHomeCustomer.reservationName;
Address1 := FHomeCustomer.Address1;
Address2 := FHomeCustomer.Address2;
Address3 := FHomeCustomer.Address3;
Address4 := FHomeCustomer.Address4;
Country := FHomeCustomer.Country;
Tel1 := FHomeCustomer.Tel1;
Tel2 := FHomeCustomer.Tel2;
Fax := FHomeCustomer.Fax;
CustomerEmail := FHomeCustomer.EmailAddress;
CustomerWebSite := FHomeCustomer.HomePage;
ContactName := copy(FHomeCustomer.ContactPerson,1,100);
ContactPhone := copy(FHomeCustomer.ContactPhone,1,30);
ContactPhone2 := copy(FHomeCustomer.ContactMobile,1,30);
ContactFax := copy(FHomeCustomer.ContactFax,1,30);
ContactEmail := copy(FHomeCustomer.ContactEmail,1,50);
CustPID := copy(FHomeCustomer.PID,1,15);
MarketSegment := copy(FHomeCustomer.MarketSegmentCode,1,5);
contactAddress1 := copy(FHomeCustomer.contactAddress1,1,100);
contactAddress2 := copy(FHomeCustomer.contactAddress2,1,100);