forked from layerfsd/Roomer-PMS-1
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuFrontDeskPageButton.pas
380 lines (326 loc) · 11.7 KB
/
uFrontDeskPageButton.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
unit uFrontDeskPageButton;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, acImage, Vcl.StdCtrls, sLabel, sPanel, Vcl.ImgList, PngImageList, AdvUtil, Vcl.Grids, AdvObj, BaseGrid,
AdvGrid, cmpRoomerDataSet, uRoomerThreadedRequest
, uHotelStatistics
;
type
TFrmFrontDeskPageButton = class(TForm)
PngImageList1: TPngImageList;
pnlContainer: TsPanel;
sPanel1: TsPanel;
lblTxtArrivals: TsLabel;
sPanel2: TsPanel;
sImage1: TsImage;
lblArrivals: TsLabel;
sPanel3: TsPanel;
lbTxtlDepartures: TsLabel;
sPanel4: TsPanel;
sImage2: TsImage;
lblDepartures: TsLabel;
sPanel5: TsPanel;
lblTxtTomArrivals: TsLabel;
sPanel6: TsPanel;
sImage3: TsImage;
lblTomArrivals: TsLabel;
sPanel7: TsPanel;
lblTxlTomDepartures: TsLabel;
sPanel8: TsPanel;
sImage4: TsImage;
lblTomDepartures: TsLabel;
sPanel9: TsPanel;
lblTxtNewReservation: TsLabel;
sPanel10: TsPanel;
sImage5: TsImage;
sPanel11: TsPanel;
lblTxtInHouse: TsLabel;
sPanel12: TsPanel;
sImage6: TsImage;
lblInHouse: TsLabel;
sPanel13: TsPanel;
lblTxtCalendar: TsLabel;
sPanel14: TsPanel;
sImage7: TsImage;
sPanel15: TsPanel;
lblTxtHousekeepingStatus: TsLabel;
sPanel16: TsPanel;
sImage8: TsImage;
StatGrid: TAdvStringGrid;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
Shape7: TShape;
Shape8: TShape;
Shape1: TShape;
sLabel1: TsLabel;
sLabel2: TsLabel;
procedure sPanel1MouseEnter(Sender: TObject);
procedure sPanel1MouseLeave(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure StatGridGetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
procedure StatGridGetCellColor(Sender: TObject; ARow, ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
procedure sPanel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Shape2MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Shape5MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Shape7MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Shape6MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Shape3MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Shape4MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure sPanel15MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure panelOnPaint(Sender: TObject; Canvas: TCanvas);
private
FShowFromDate: TDate;
procedure SetShowFromDate(const Value: TDate);
{ Private declarations }
private
ThreadedDataGetter : TGetSQLDataThreaded;
function GetSenderAsPanel(Sender: TObject): TsPanel;
function GetShapeComponentOfButton(Sender: TObject): TShape;
procedure DrawDateRow;
procedure PrepareGridText;
procedure UpdateGridFromStats(aStatsList: THotelStatisticsList);
public
{ Public declarations }
procedure RefreshDisplay;
property ShowFromDate : TDate read FShowFromDate write SetShowFromDate;
end;
var
FrmFrontDeskPageButton: TFrmFrontDeskPageButton;
procedure PrepareFrontDeskPage(EmbedOn : TWinControl);
procedure FreeFrontDeskPage;
implementation
{$R *.dfm}
uses uD,
hData,
_Glob,
uAppGlobal,
uRoomerLanguage,
uUtils,
uG,
uDateUtils,
uRptArrivals,
uRptDepartures,
uRptInHouse,
uMain,
PrjConst
, uHotelStatisticsAPI
, DateUtils
, uDateTimeHelper;
const
ROW_DAY = 0;
ROW_DATE = 1;
ROW_ARRIVALS = 2;
ROW_DEPARTURES = 3;
ROW_LEFT_TO_SELL = 4;
ROW_OCCUPANCY = 5;
ROW_BAR = 6;
COL_START = 1;
procedure PrepareFrontDeskPage(EmbedOn : TWinControl);
begin
FrmFrontDeskPageButton := TFrmFrontDeskPageButton.Create(nil);
FrmFrontDeskPageButton.FShowFromDate := Trunc(Now);
FrmFrontDeskPageButton.pnlContainer.Parent := EmbedOn;
end;
procedure FreeFrontDeskPage;
begin
FrmFrontDeskPageButton.pnlContainer.Parent := FrmFrontDeskPageButton;
FrmFrontDeskPageButton.Free;
end;
{ TFrmFrontDeskPageButton }
procedure TFrmFrontDeskPageButton.RefreshDisplay;
begin
THotelStatisticsMobileAPICallerThreaded.GetHotelStatistics(ShowFromDate, TDateTime(ShowFromDate).AddDays(6), UpdateGridFromStats);
end;
procedure TFrmFrontDeskPageButton.Shape2MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowDeparturesReport(FShowFromDate, true);
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.Shape3MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowArrivalsReport(TDateTime(FShowFromDate).AddDays(1), true);
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.Shape4MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowDeparturesReport(TDateTime(FShowFromDate).AddDays(1), true);
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.Shape5MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
frmMain.CreateQuickReservation(false);
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.Shape6MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowInHouseReport(true);
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.Shape7MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
frmMain.tabsView.TabIndex := 1;
frmMain.tabsViewChange(nil);
end;
procedure TFrmFrontDeskPageButton.UpdateGridFromStats(aStatsList: THotelStatisticsList);
var
lDate: TDate;
i: integer;
lStats: TSingleDateStatistics;
begin
DrawDateRow;
for i := 0 to StatGrid.ColCount-2 do
begin
lDate := TDateTime(FShowFromDate).AddDays(i);
lStats := aStatsList.StatisticsForDate[lDate];
if assigned(lStats) then
begin
if (lDate = FSHowFromDate) then
begin
lblArrivals.Caption := lStats.Statistic['REMAINING_ARRIVALS'].FormattedValue;
lblDepartures.Caption := lStats.Statistic['REMAINING_DEPARTURES'].FormattedValue;
lblInHouse.Caption := lStats.Statistic['IN_HOUSE'].FormattedValue;
end;
if (lDate = TDateTime(FSHowFromDate).AddDays(1)) then
begin
lblTomArrivals.Caption := lStats.Statistic['REMAINING_ARRIVALS'].FormattedValue;
lblTomDepartures.Caption := lStats.Statistic['REMAINING_DEPARTURES'].FormattedValue;
end;
StatGrid.Cells[i+1, ROW_ARRIVALS] := lStats.Statistic['EXPECTED_ARRIVALS'].FormattedValue;
StatGrid.Cells[i+1, ROW_DEPARTURES] := lStats.Statistic['EXPECTED_DEPARTURES'].FormattedValue;
StatGrid.Cells[i+1, ROW_LEFT_TO_SELL] := lStats.Statistic['LEFT_TO_SELL'].FormattedValue;
StatGrid.Cells[i+1, ROW_OCCUPANCY] := lStats.Statistic['OCCUPANCY'].FormattedValue;
StatGrid.Cells[i+1, ROW_BAR] := lStats.Statistic['BAR'].FormattedValue;
end;
end;
end;
procedure TFrmFrontDeskPageButton.SetShowFromDate(const Value: TDate);
begin
FShowFromDate := Value;
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.sPanel15MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
frmMain.btnSimpleHouseKeepingClick(frmMain.btnSimpleHouseKeeping);
end;
procedure TFrmFrontDeskPageButton.sPanel1MouseEnter(Sender: TObject);
begin
GetShapeComponentOfButton(Sender).Brush.Style := bsSolid;
GetShapeComponentOfButton(Sender).Brush.Color := $00EEEEDD;
end;
procedure TFrmFrontDeskPageButton.sPanel1MouseLeave(Sender: TObject);
begin
GetShapeComponentOfButton(Sender).Brush.Style := bsClear;
end;
procedure TFrmFrontDeskPageButton.sPanel1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowArrivalsReport(FShowFromDate, True);
RefreshDisplay;
end;
procedure TFrmFrontDeskPageButton.panelOnPaint(Sender: TObject; Canvas: TCanvas);
var
lParent: TWinControl;
i: integer;
begin
lParent := Sender as TWinControl;
for i := 0 to lParent.ControlCount-1 do
if lParent.COntrols[i] is TImage then
lParent.Controls[i].Invalidate;
end;
procedure TFrmFrontDeskPageButton.StatGridGetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment);
begin
if ACol > 0 then
HAlign := taCenter
else
HAlign := taLeftJustify;
end;
procedure TFrmFrontDeskPageButton.StatGridGetCellColor(Sender: TObject; ARow, ACol: Integer; AState: TGridDrawState; ABrush: TBrush; AFont: TFont);
begin
if ARow < 1 then
ABrush.Color := $00FFBF3C
else
if (ARow < 2) OR (ACol < 1) then
ABrush.Color := $00FFDD95
else
ABrush.Color := clWhite;
AFont.Name := 'Segoe UI';
AFont.Color := clBlack;
if ARow < 2 then
AFont.Size := 14
else
if (ARow > 3) AND (ACol > 0) then
AFont.Size := 10
else
AFont.Size := 10;
if (ARow = 0) AND (StatGrid.Cells[ACol, ARow] = 'TODAY') then
AFont.Style := [fsBold];
end;
procedure TFrmFrontDeskPageButton.FormCreate(Sender: TObject);
begin
RoomerLanguage.TranslateThisForm(self);
glb.PerformAuthenticationAssertion(self);
PrepareGridText;
end;
procedure TFrmFrontDeskPageButton.FormDestroy(Sender: TObject);
begin
try
ThreadedDataGetter.Free;
except end;
end;
procedure TFrmFrontDeskPageButton.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
frmMain.FormKeyDown(Sender, Key, Shift);
end;
procedure TFrmFrontDeskPageButton.FormKeyPress(Sender: TObject; var Key: Char);
begin
frmMain.FormKeyPress(Sender, Key);
end;
procedure TFrmFrontDeskPageButton.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
frmMain.FormKeyUp(Sender, Key, Shift);
end;
///////////////////////////// HELPERS //////////////////////////////////////
procedure TFrmFrontDeskPageButton.DrawDateRow;
var
i: Integer;
begin
for i := TRUNC(ShowFromDate) to TRUNC(ShowFromDate + 6) do
begin
if i = TRUNC(Now) then
StatGrid.Cells[i - TRUNC(ShowFromDate) + 1, ROW_DAY] := 'TODAY'
else
StatGrid.Cells[i - TRUNC(ShowFromDate) + 1, ROW_DAY] := FormatDateTime('ddd', i);
StatGrid.Cells[i - TRUNC(ShowFromDate) + 1, ROW_DATE] := FormatDateTime('dd mmm', i);
end;
end;
function TFrmFrontDeskPageButton.GetSenderAsPanel(Sender: TObject) : TsPanel;
begin
if (Sender IS TsPanel) AND
((Sender AS TsPanel).Tag > 0) then
result := Sender AS TsPanel
else
if (Sender AS TControl).Parent.Tag > 0 then
result := (Sender AS TControl).Parent AS TsPanel
else
result := (Sender AS TControl).Parent.Parent AS TsPanel;
end;
function TFrmFrontDeskPageButton.GetShapeComponentOfButton(Sender: TObject) : TShape;
begin
result := FindComponent('Shape' + inttostr(GetSenderAsPanel(Sender).Tag)) AS TShape;
end;
procedure TFrmFrontDeskPageButton.PrepareGridText;
begin
StatGrid.Cells[0, ROW_ARRIVALS] := GetTranslatedText('FrontDeskPage_Arrivals');
StatGrid.Cells[0, ROW_DEPARTURES] := GetTranslatedText('FrontDeskPage_Departures');
StatGrid.Cells[0, ROW_LEFT_TO_SELL] := GetTranslatedText('FrontDeskPage_LeftToSell');
StatGrid.Cells[0, ROW_OCCUPANCY] := GetTranslatedText('FrontDeskPage_Occupancy');
StatGrid.Cells[0, ROW_BAR] := GetTranslatedText('FrontDeskPage_BAR');
end;
end.