Commit c0a44280 by Elias Sarraf

Merge remote-tracking branch 'origin/master' into cam2

parents 7005e50c bb05403e
kgOrdersClient/.vscode/
kgOrdersClient/__history/
kgOrdersClient/__recovery/
kgOrdersClient/TMSWeb
kgOrdersClient/Win32
kgOrdersClient/template/css/__history/
kgOrdersClient/TMSWeb/
kgOrdersClient/Win32/
kgOrdersClient/css/__history/
kgOrdersClient/config/__history/
kgOrdersServer/__history
kgOrdersServer/__recovery
kgOrdersServer/doc/
kgOrdersServer/Win32/
kgOrdersServer/*.log
kgOrdersServer/*.txt
kgOrdersServer/Source/__history
kgOrdersServer/doc/
kgOrdersServer/Win32/
kgOrdersServer/Source/__history/
kgOrdersServer/Source/__recovery/
*.local
*.exe
*.local
*.identcache
*.res
*.skincfg
*.tvsconfig
......@@ -45,10 +45,6 @@ procedure LoadConfig(LoadProc: TConfigLoadedProc);
if JS.toString(Obj['ApiUrl']) <> '' then
Config.ApiUrl := JS.toString(Obj['ApiUrl']);
if JS.toString(Obj['AppUrl']) <> '' then
Config.AppUrl := JS.toString(Obj['AppUrl']);
end;
finally
LoadProc(Config);
......
......@@ -2,7 +2,7 @@ object DMConnection: TDMConnection
Height = 264
Width = 395
object ApiConnection: TXDataWebConnection
URL = 'http://localhost:2004/emsys/envoy/api/'
URL = 'http://localhost:2004/emsys/kgOrders/api/'
OnError = ApiConnectionError
OnRequest = ApiConnectionRequest
OnResponse = ApiConnectionResponse
......@@ -10,7 +10,7 @@ object DMConnection: TDMConnection
Top = 80
end
object AuthConnection: TXDataWebConnection
URL = 'http://localhost:2004/emsys/envoycalls/auth/'
URL = 'http://localhost:2004/emsys/kgOrders/auth/'
OnError = AuthConnectionError
Left = 48
Top = 16
......
object FAddOrder: TFAddOrder
Width = 871
Height = 477
OnShow = WebFormShow
object WebLabel1: TWebLabel
Left = 278
Top = 44
Width = 35
Height = 15
Caption = 'Search'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel2: TWebLabel
Left = 414
Top = 44
Width = 58
Height = 15
Caption = 'Selected ID'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtSearch: TWebEdit
Left = 278
Top = 62
Width = 121
Height = 22
HeightPercent = 100.000000000000000000
Text = 'edtSearch'
WidthPercent = 100.000000000000000000
OnChange = edtSearchChange
end
object edtID: TWebEdit
Left = 414
Top = 62
Width = 69
Height = 22
ChildOrder = 1
HeightPercent = 100.000000000000000000
Text = 'WebEdit1'
WidthPercent = 100.000000000000000000
end
object TMSFNCGrid1: TTMSFNCGrid
Left = 0
Top = 166
Width = 871
Height = 303
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 2
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 4
Options.Bands.Enabled = True
Options.ColumnSize.Stretch = True
Options.Editing.CalcFormat = '%g'
Options.Grouping.CalcFormat = '%g'
Options.Grouping.GroupCountFormat = '(%d)'
Options.IO.XMLEncoding = 'ISO-8859-1'
Options.Mouse.ClickMargin = 0
Options.Mouse.ColumnSizeMargin = 6
Options.Mouse.RowSizeMargin = 6
OnSelectedCell = TMSFNCGrid1SelectedCell
Columns = <
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 70.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 250.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 100.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 432.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 90.000000000000000000
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clWindowText
DefaultFont.Height = -11
DefaultFont.Name = 'Segoe UI'
DefaultFont.Style = []
TopRow = 1
Appearance.FixedLayout.Fill.Color = 16380654
Appearance.FixedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedLayout.Font.Color = 4539717
Appearance.FixedLayout.Font.Height = -13
Appearance.FixedLayout.Font.Name = 'Segoe UI'
Appearance.FixedLayout.Font.Style = [fsBold]
Appearance.NormalLayout.Fill.Color = 16578806
Appearance.NormalLayout.Font.Charset = DEFAULT_CHARSET
Appearance.NormalLayout.Font.Color = 8026746
Appearance.NormalLayout.Font.Height = -11
Appearance.NormalLayout.Font.Name = 'Segoe UI'
Appearance.NormalLayout.Font.Style = []
Appearance.GroupLayout.Fill.Color = 12817262
Appearance.GroupLayout.Font.Charset = DEFAULT_CHARSET
Appearance.GroupLayout.Font.Color = clBlack
Appearance.GroupLayout.Font.Height = -11
Appearance.GroupLayout.Font.Name = 'Segoe UI'
Appearance.GroupLayout.Font.Style = []
Appearance.SummaryLayout.Fill.Color = 14009785
Appearance.SummaryLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SummaryLayout.Font.Color = clBlack
Appearance.SummaryLayout.Font.Height = -11
Appearance.SummaryLayout.Font.Name = 'Segoe UI'
Appearance.SummaryLayout.Font.Style = []
Appearance.SelectedLayout.Fill.Color = 16441019
Appearance.SelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SelectedLayout.Font.Color = 4539717
Appearance.SelectedLayout.Font.Height = -11
Appearance.SelectedLayout.Font.Name = 'Segoe UI'
Appearance.SelectedLayout.Font.Style = []
Appearance.FocusedLayout.Fill.Color = 16039284
Appearance.FocusedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FocusedLayout.Font.Color = 4539717
Appearance.FocusedLayout.Font.Height = -11
Appearance.FocusedLayout.Font.Name = 'Segoe UI'
Appearance.FocusedLayout.Font.Style = []
Appearance.FixedSelectedLayout.Fill.Color = clLightsteelblue
Appearance.FixedSelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedSelectedLayout.Font.Color = clBlack
Appearance.FixedSelectedLayout.Font.Height = -11
Appearance.FixedSelectedLayout.Font.Name = 'Segoe UI'
Appearance.FixedSelectedLayout.Font.Style = []
Appearance.BandLayout.Fill.Color = 16711679
Appearance.BandLayout.Font.Charset = DEFAULT_CHARSET
Appearance.BandLayout.Font.Color = 8026746
Appearance.BandLayout.Font.Height = -11
Appearance.BandLayout.Font.Name = 'Segoe UI'
Appearance.BandLayout.Font.Style = []
Appearance.ProgressLayout.Format = '%.0f%%'
LeftCol = 0
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
end
object cbCorrugatedPlate: TWebCheckBox
Left = 26
Top = 63
Width = 113
Height = 22
Caption = 'Corrugated Plate'
ChildOrder = 3
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = cbCorrugatedPlateClick
end
object cbWebPlate: TWebCheckBox
Left = 152
Top = 64
Width = 83
Height = 22
Caption = 'Web Plate'
ChildOrder = 3
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = cbWebPlateClick
end
object btnCancel: TWebButton
Left = 674
Top = 61
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 5
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object btnConfirm: TWebButton
Left = 554
Top = 61
Width = 96
Height = 25
Caption = 'Confirm'
ChildOrder = 5
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 728
Top = 109
end
object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 600
Top = 109
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
end
object xdwdsCustomersNAME: TStringField
FieldName = 'NAME'
end
object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
end
object xdwdsCustomersADDRESS: TStringField
FieldName = 'ADDRESS'
Size = 100
end
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
Left = 470
Top = 109
end
end
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>TMS Web Project</title>
<style>
</style>
</head>
<body>
</body>
</html>
\ No newline at end of file
unit View.AddOrder;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, VCL.TMSFNCTypes, VCL.TMSFNCUtils,
VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes, VCL.TMSFNCGridCell,
VCL.TMSFNCGridOptions, Vcl.Controls, VCL.TMSFNCCustomControl,
VCL.TMSFNCCustomScrollControl, VCL.TMSFNCGridData, VCL.TMSFNCCustomGrid,
VCL.TMSFNCGrid, Vcl.StdCtrls, WEBLib.StdCtrls, XData.Web.Client, Data.DB,
XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB, ConnectionModule;
type
TFAddOrder = class(TWebForm)
edtSearch: TWebEdit;
edtID: TWebEdit;
TMSFNCGrid1: TTMSFNCGrid;
cbCorrugatedPlate: TWebCheckBox;
cbWebPlate: TWebCheckBox;
btnCancel: TWebButton;
btnConfirm: TWebButton;
WebLabel1: TWebLabel;
WebLabel2: TWebLabel;
XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
wdsCustomers: TWebDataSource;
xdwdsCustomersADDRESS: TStringField;
procedure WebFormShow(Sender: TObject);
procedure TMSFNCGrid1SelectedCell(Sender: TObject; ACol, ARow: Integer);
procedure edtSearchChange(Sender: TObject);
procedure cbCorrugatedPlateClick(Sender: TObject);
procedure cbWebPlateClick(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
private
[async] procedure getCustomers;
procedure PopulateGridManually;
procedure ApplyFilter;
{ Private declarations }
public
{ Public declarations }
end;
var
FAddOrder: TFAddOrder;
implementation
{$R *.dfm}
procedure TFAddOrder.btnCancelClick(Sender: TObject);
begin
edtID.Text := '';
Close;
end;
procedure TFAddOrder.btnConfirmClick(Sender: TObject);
begin
Close;
end;
procedure TFAddOrder.WebFormShow(Sender: TObject);
begin
getCustomers();
end;
procedure TFAddOrder.cbCorrugatedPlateClick(Sender: TObject);
begin
cbWebPlate.Checked := False;
end;
procedure TFAddOrder.cbWebPlateClick(Sender: TObject);
begin
cbCorrugatedPlate.Checked := False;
end;
procedure TFAddOrder.edtSearchChange(Sender: TObject);
begin
ApplyFilter;
end;
[async] procedure TFAddOrder.getCustomers();
var
xdcResponse: TXDataClientResponse;
customerList: TJSObject;
begin
// Fetch data from XData service
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', []));
customerList := TJSObject(xdcResponse.Result);
// Load data into TXDataWebDataset
xdwdsCustomers.Close;
xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.Open;
// Manually populate the grid
PopulateGridManually;
end;
procedure TFAddOrder.PopulateGridManually;
var
RowIndex: Integer;
begin
TMSFNCGrid1.BeginUpdate;
try
TMSFNCGrid1.Clear; // Clear any existing data
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'ID';
TMSFNCGrid1.Cells[1, 0] := 'Short Name';
TMSFNCGrid1.Cells[2, 0] := 'Name';
TMSFNCGrid1.Cells[3, 0] := 'Address';
// TMSFNCGrid1.ColumnWidths[0] := 40;
// TMSFNCGrid1.ColumnWidths[1] := 80;
// TMSFNCGrid1.ColumnWidths[2] := 250;
// Populate the grid with data from the dataset
xdwdsCustomers.First;
RowIndex := 1;
while not xdwdsCustomers.EOF do
begin
TMSFNCGrid1.RowCount := RowIndex + 1;
TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString;
TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME').AsString;
TMSFNCGrid1.Cells[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('ADDRESS').AsString;
Inc(RowIndex);
xdwdsCustomers.Next;
end;
finally
TMSFNCGrid1.EndUpdate;
end;
end;
procedure TFAddOrder.TMSFNCGrid1SelectedCell(Sender: TObject; ACol,
ARow: Integer);
begin
edtID.Text := TMSFNCGrid1.Cells[0, ARow];
end;
procedure TFAddOrder.ApplyFilter;
var
fd: TTMSFNCGridFilterData;
i: Integer;
SearchText: string;
begin
SearchText := Trim(edtSearch.Text);
TMSFNCGrid1.RemoveFilter;
TMSFNCGrid1.Filter.Clear;
// match on first 3 columns
for i := 0 to 2 do
begin
fd := TMSFNCGrid1.Filter.Add;
fd.Column := i;
fd.Condition := '*' + SearchText + '*'; // Match text anywhere in the cell
fd.CaseSensitive := False; // Make the filter case-insensitive
// Use foOR for "match any column" logic
if i > 0 then
fd.Operation := foOR
else
fd.Operation := foNONE; // First filter has no logical operation
end;
// Apply the filters to the grid
TMSFNCGrid1.ApplyFilter;
end;
end.
\ No newline at end of file
object FAddOrder: TFAddOrder
Width = 894
Height = 633
Align = alClient
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
OnShow = WebFormShow
object cbWebPlate: TWebCheckBox
Left = 172
Top = 55
Width = 113
Height = 22
Caption = 'Web Plate'
ChildOrder = 5
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
OnClick = cbWebPlateClick
end
object cbCorrugatedPlate: TWebCheckBox
Left = 40
Top = 55
Width = 113
Height = 22
Caption = 'Corrugated Plate'
Checked = True
ChildOrder = 5
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
State = cbChecked
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
OnClick = cbCorrugatedPlateClick
end
object edtSearch: TWebEdit
Left = 306
Top = 55
Width = 146
Height = 22
ChildOrder = 8
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
OnChange = edtSearchChange
end
object edtID: TWebEdit
Left = 475
Top = 55
Width = 121
Height = 22
ChildOrder = 8
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
end
object btnConfirm: TWebButton
Left = 612
Top = 52
Width = 96
Height = 25
Caption = 'Confirm'
ChildOrder = 9
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object btnCancel: TWebButton
Left = 730
Top = 52
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 9
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object TMSFNCGrid1: TTMSFNCGrid
Left = 0
Top = 220
Width = 894
Height = 413
Align = alBottom
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 6
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 3
Options.Bands.Enabled = True
Options.ColumnSize.Stretch = True
Options.Editing.CalcFormat = '%g'
Options.Grouping.CalcFormat = '%g'
Options.Grouping.GroupCountFormat = '(%d)'
Options.IO.XMLEncoding = 'ISO-8859-1'
Options.Mouse.ClickMargin = 0
Options.Mouse.ColumnSizeMargin = 6
Options.Mouse.RowSizeMargin = 6
Columns = <
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 327.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 327.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = 4539717
FixedFont.Height = -11
FixedFont.Name = 'Segoe UI'
FixedFont.Style = [fsBold]
Font.Charset = DEFAULT_CHARSET
Font.Color = 8026746
Font.Height = -11
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 239.000000000000000000
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clWindowText
DefaultFont.Height = -11
DefaultFont.Name = 'Segoe UI'
DefaultFont.Style = []
TopRow = 1
Appearance.FixedLayout.Fill.Color = 16380654
Appearance.FixedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedLayout.Font.Color = 4539717
Appearance.FixedLayout.Font.Height = -13
Appearance.FixedLayout.Font.Name = 'Segoe UI'
Appearance.FixedLayout.Font.Style = [fsBold]
Appearance.NormalLayout.Fill.Color = 16578806
Appearance.NormalLayout.Font.Charset = DEFAULT_CHARSET
Appearance.NormalLayout.Font.Color = 8026746
Appearance.NormalLayout.Font.Height = -11
Appearance.NormalLayout.Font.Name = 'Segoe UI'
Appearance.NormalLayout.Font.Style = []
Appearance.GroupLayout.Fill.Color = 12817262
Appearance.GroupLayout.Font.Charset = DEFAULT_CHARSET
Appearance.GroupLayout.Font.Color = clBlack
Appearance.GroupLayout.Font.Height = -11
Appearance.GroupLayout.Font.Name = 'Segoe UI'
Appearance.GroupLayout.Font.Style = []
Appearance.SummaryLayout.Fill.Color = 14009785
Appearance.SummaryLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SummaryLayout.Font.Color = clBlack
Appearance.SummaryLayout.Font.Height = -11
Appearance.SummaryLayout.Font.Name = 'Segoe UI'
Appearance.SummaryLayout.Font.Style = []
Appearance.SelectedLayout.Fill.Color = 16441019
Appearance.SelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SelectedLayout.Font.Color = 4539717
Appearance.SelectedLayout.Font.Height = -11
Appearance.SelectedLayout.Font.Name = 'Segoe UI'
Appearance.SelectedLayout.Font.Style = []
Appearance.FocusedLayout.Fill.Color = 16039284
Appearance.FocusedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FocusedLayout.Font.Color = 4539717
Appearance.FocusedLayout.Font.Height = -11
Appearance.FocusedLayout.Font.Name = 'Segoe UI'
Appearance.FocusedLayout.Font.Style = []
Appearance.FixedSelectedLayout.Fill.Color = clLightsteelblue
Appearance.FixedSelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedSelectedLayout.Font.Color = clBlack
Appearance.FixedSelectedLayout.Font.Height = -11
Appearance.FixedSelectedLayout.Font.Name = 'Segoe UI'
Appearance.FixedSelectedLayout.Font.Style = []
Appearance.BandLayout.Fill.Color = 16711679
Appearance.BandLayout.Font.Charset = DEFAULT_CHARSET
Appearance.BandLayout.Font.Color = 8026746
Appearance.BandLayout.Font.Height = -11
Appearance.BandLayout.Font.Name = 'Segoe UI'
Appearance.BandLayout.Font.Style = []
Appearance.ProgressLayout.Format = '%.0f%%'
LeftCol = 0
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
ExplicitWidth = 982
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 370
Top = 562
end
object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 206
Top = 564
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
end
object xdwdsCustomersNAME: TStringField
FieldName = 'NAME'
end
object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
end
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
Left = 38
Top = 562
end
end
unit View.AddOrder2;
interface
uses
System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.StdCtrls, XData.Web.Client, WEBLib.ExtCtrls,
Data.DB, XData.Web.Dataset, VCL.TMSFNCTypes, VCL.TMSFNCGrid, VCL.TMSFNCGridData,
VCL.TMSFNCUtils, VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes,
VCL.TMSFNCGridCell, VCL.TMSFNCGridOptions, VCL.TMSFNCCustomComponent,
VCL.TMSFNCCustomGrid, VCL.TMSFNCGridDatabaseAdapter, VCL.TMSFNCCustomControl,
VCL.TMSFNCCustomScrollControl, WEBLib.DB, XData.Web.JsonDataset, Vcl.StdCtrls,
Vcl.Controls, ConnectionModule;
type
TFAddOrder = class(TWebForm)
edtSearch: TWebEdit;
edtID: TWebEdit;
btnCancel: TWebButton;
XDataWebClient1: TXDataWebClient;
wdsCustomers: TWebDataSource;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
btnConfirm: TWebButton;
cbCorrugatedPlate: TWebCheckBox;
cbWebPlate: TWebCheckBox;
TMSFNCGrid1: TTMSFNCGrid;
procedure WebFormShow(Sender: TObject);
procedure cbCorrugatedPlateClick(Sender: TObject);
procedure cbWebPlateClick(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
procedure edtSearchChange(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure TMSFNCGrid1SelectedCell(Sender: TObject; ACol, ARow: Integer);
private
[async] procedure getCustomers();
procedure PopulateGridManually;
procedure ApplyFilter;
public
end;
var
FAddOrder: TFAddOrder;
implementation
{$R *.dfm}
procedure TFAddOrder.WebFormShow(Sender: TObject);
begin
getCustomers(); // Fetch and populate the grid with customer data
end;
[async]
procedure TFAddOrder.getCustomers();
var
xdcResponse: TXDataClientResponse;
customerList: TJSObject;
begin
// Fetch data from XData service
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', []));
customerList := TJSObject(xdcResponse.Result);
// Load data into TXDataWebDataset
xdwdsCustomers.Close;
xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.Open;
// Manually populate the grid
PopulateGridManually;
end;
procedure TFAddOrder.PopulateGridManually;
var
RowIndex: Integer;
begin
TMSFNCGrid1.BeginUpdate;
try
TMSFNCGrid1.Clear; // Clear any existing data
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'ID';
TMSFNCGrid1.Cells[1, 0] := 'Short Name';
TMSFNCGrid1.Cells[2, 0] := 'Name';
// TMSFNCGrid1.ColumnWidths[0] := 40;
// TMSFNCGrid1.ColumnWidths[1] := 80;
// TMSFNCGrid1.ColumnWidths[2] := 250;
// Populate the grid with data from the dataset
xdwdsCustomers.First;
RowIndex := 1;
while not xdwdsCustomers.EOF do
begin
TMSFNCGrid1.RowCount := RowIndex + 1;
TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString;
TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME').AsString;
TMSFNCGrid1.Cells[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
Inc(RowIndex);
xdwdsCustomers.Next;
end;
finally
TMSFNCGrid1.EndUpdate;
end;
end;
procedure TFAddOrder.TMSFNCGrid1SelectedCell(Sender: TObject; ACol,
ARow: Integer);
begin
edtID.Text := TMSFNCGrid1.Cells[0, ARow];
end;
procedure TFAddOrder.ApplyFilter;
var
fd: TTMSFNCGridFilterData;
i: Integer;
SearchText: string;
begin
SearchText := Trim(edtSearch.Text);
TMSFNCGrid1.RemoveFilter;
TMSFNCGrid1.Filter.Clear;
// match on first 3 columns
for i := 0 to 2 do
begin
fd := TMSFNCGrid1.Filter.Add;
fd.Column := i;
fd.Condition := '*' + SearchText + '*'; // Match text anywhere in the cell
fd.CaseSensitive := False; // Make the filter case-insensitive
// Use foOR for "match any column" logic
if i > 0 then
fd.Operation := foOR
else
fd.Operation := foNONE; // First filter has no logical operation
end;
// Apply the filters to the grid
TMSFNCGrid1.ApplyFilter;
end;
procedure TFAddOrder.cbCorrugatedPlateClick(Sender: TObject);
begin
cbWebPlate.Checked := False;
end;
procedure TFAddOrder.cbWebPlateClick(Sender: TObject);
begin
cbCorrugatedPlate.Checked := False;
end;
procedure TFAddOrder.btnConfirmClick(Sender: TObject);
begin
Close;
end;
procedure TFAddOrder.btnCancelClick(Sender: TObject);
begin
edtID.Text := '';
Close;
end;
procedure TFAddOrder.edtSearchChange(Sender: TObject);
begin
ApplyFilter;
end;
end.
//unit View.AddOrder;
//
//interface
//
//uses
// System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
// WEBLib.Forms, WEBLib.Dialogs, WEBLib.StdCtrls, XData.Web.Client, WEBLib.ExtCtrls,
// Data.DB, XData.Web.Dataset, VCL.TMSFNCTypes, VCL.TMSFNCGrid, VCL.TMSFNCGridData,
// VCL.TMSFNCUtils, VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes,
// VCL.TMSFNCGridCell, VCL.TMSFNCGridOptions, VCL.TMSFNCCustomComponent,
// VCL.TMSFNCCustomGrid, VCL.TMSFNCGridDatabaseAdapter, VCL.TMSFNCCustomControl,
// VCL.TMSFNCCustomScrollControl, WEBLib.DB, XData.Web.JsonDataset, Vcl.StdCtrls,
// Vcl.Controls, ConnectionModule, WEBLib.WebCtrls;
//
//type
// TFAddOrder = class(TWebForm)
// XDataWebClient1: TXDataWebClient;
// wdsCustomers: TWebDataSource;
// xdwdsCustomers: TXDataWebDataSet;
// xdwdsCustomersID: TIntegerField;
// xdwdsCustomersNAME: TStringField;
// xdwdsCustomersSHORT_NAME: TStringField;
// xdwdsCustomersADDRESS: TStringField;
// cbWebPlate: TWebCheckBox;
// cbCorrugatedPlate: TWebCheckBox;
// edtSearch: TWebEdit;
// edtID: TWebEdit;
// btnConfirm: TWebButton;
// btnCancel: TWebButton;
// TMSFNCGrid1: TTMSFNCGrid;
// procedure cbCorrugatedPlateClick(Sender: TObject);
// procedure cbWebPlateClick(Sender: TObject);
// procedure btnConfirmClick(Sender: TObject);
// procedure btnCancelClick(Sender: TObject);
// procedure TMSFNCGrid1SelectedCell(Sender: TObject; ACol, ARow: Integer);
// procedure edtSearchChange(Sender: TObject);
// private
// [async] procedure GetCustomers();
// procedure PopulateGridManually;
// procedure ApplyFilter;
// public
// class function CreateForm(AElementID: string): TWebForm;
// end;
//
//var
// FAddOrder: TFAddOrder;
//
//implementation
//
//{$R *.dfm}
//
//
//class function TFAddOrder.CreateForm(AElementID: string): TWebForm;
//begin
// Application.CreateForm(TFAddOrder, AElementID, Result,
// procedure(AForm: TObject)
// begin
// with TFAddOrder(AForm) do
// begin
// GetCustomers();
// Console.Log('AddOrder form created and dynamic styles applied.');
// end;
// end
// );
//end;
//
//
//
//procedure TFAddOrder.edtSearchChange(Sender: TObject);
//begin
// ApplyFilter;
//end;
//
//
//[async] procedure TFAddOrder.GetCustomers();
//var
// xdcResponse: TXDataClientResponse;
// customerList: TJSObject;
//begin
// // Fetch data from XData service
// xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', []));
// customerList := TJSObject(xdcResponse.Result);
//
// // Load data into TXDataWebDataset
// xdwdsCustomers.Close;
// xdwdsCustomers.SetJsonData(customerList['data']);
// xdwdsCustomers.Open;
//
// // Manually populate the grid
// PopulateGridManually;
//end;
//
//
//procedure TFAddOrder.PopulateGridManually;
//var
// RowIndex: Integer;
//begin
// TMSFNCGrid1.BeginUpdate;
// try
// TMSFNCGrid1.Clear; // Clear any existing data
//
// // Set up column headers
// TMSFNCGrid1.ColumnCount := 3;
// TMSFNCGrid1.RowCount := 1;
// TMSFNCGrid1.Cells[0, 0] := 'ID';
// TMSFNCGrid1.Cells[1, 0] := 'Short Name';
// TMSFNCGrid1.Cells[2, 0] := 'Name';
//
//// TMSFNCGrid1.ColumnWidths[0] := 40;
//// TMSFNCGrid1.ColumnWidths[1] := 80;
//// TMSFNCGrid1.ColumnWidths[2] := 250;
//
// // Populate the grid with data from the dataset
// xdwdsCustomers.First;
// RowIndex := 1;
//
// while not xdwdsCustomers.EOF do
// begin
// TMSFNCGrid1.RowCount := RowIndex + 1;
//
// TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString;
// TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME').AsString;
// TMSFNCGrid1.Cells[2, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
//
// Inc(RowIndex);
// xdwdsCustomers.Next;
// end;
//
// finally
// TMSFNCGrid1.EndUpdate;
// end;
//end;
//
//
//procedure TFAddOrder.TMSFNCGrid1SelectedCell(Sender: TObject; ACol,
// ARow: Integer);
//begin
// edtID.Text := TMSFNCGrid1.Cells[0, ARow];
//end;
//
//
//procedure TFAddOrder.ApplyFilter;
//var
// fd: TTMSFNCGridFilterData;
// i: Integer;
// SearchText: string;
//begin
// SearchText := Trim(edtSearch.Text);
// Console.Log('Filter Applied: ' + SearchText);
//
// TMSFNCGrid1.RemoveFilter;
// TMSFNCGrid1.Filter.Clear;
//
// for i := 0 to 2 do
// begin
// fd := TMSFNCGrid1.Filter.Add;
// fd.Column := i;
// fd.Condition := '*' + SearchText + '*'; // Match text anywhere in the cell
// fd.CaseSensitive := False;
//
// if i > 0 then
// fd.Operation := foOR
// else
// fd.Operation := foNONE;
// end;
//
// TMSFNCGrid1.ApplyFilter;
//end;
//
//
//procedure TFAddOrder.cbCorrugatedPlateClick(Sender: TObject);
//begin
// cbWebPlate.Checked := False;
//end;
//
//
//procedure TFAddOrder.cbWebPlateClick(Sender: TObject);
//begin
// cbCorrugatedPlate.Checked := False;
//end;
//
//procedure TFAddOrder.btnConfirmClick(Sender: TObject);
//begin
// edtID.Text := '';
// window.location.reload(true);
//end;
//
//
//procedure TFAddOrder.btnCancelClick(Sender: TObject);
//var
// OrdersPanel: TJSHTMLElement;
//begin
// edtID.Text := '';
//
// // Get the panel element by its ID
// OrdersPanel := TJSHTMLElement(document.getElementById('pnl_orders'));
//
// // Hide the panel
// if Assigned(OrdersPanel) then
// begin
// OrdersPanel.style.setProperty('display', 'none');
//
// // Remove all child nodes of the container to clear the DOM
// while OrdersPanel.firstChild <> nil do
// OrdersPanel.removeChild(OrdersPanel.firstChild);
// end;
//
// // Free the current form instance to clean up resources
// Free;
//
// Console.Log('Panel hidden, DOM cleared, and form instance destroyed.');
//end;
//
//
//
//
//
//end.
......@@ -128,7 +128,11 @@ object FViewMain: TFViewMain
Width = 471
Height = 369
ElementID = 'main.webpanel'
HeightStyle = ssAuto
WidthStyle = ssAuto
ChildOrder = 3
ElementFont = efCSS
ElementPosition = epIgnore
TabOrder = 0
end
object WebMessageDlg1: TWebMessageDlg
......
......@@ -45,13 +45,13 @@
</div>
</nav>
<div id="page-wrapper" class="container-fluid">
<div class="container-fluid">
<div class="row">
<div id="main.webpanel" class="col-12"></div>
</div>
<div class="row">
<div class="col-12">
<div class="form-outline mb-4">
<div class="form-outline">
<textarea class="form-control" id="main.debugmemo" rows="4"></textarea>
</div>
</div>
......
object FOrderList: TFOrderList
Width = 1016
Height = 683
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
OnShow = WebFormShow
object lblEntries: TWebLabel
Left = 0
Top = 336
Width = 77
Height = 14
Caption = 'Showing 0 of ...'
ElementID = 'lblentries'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblEntries2: TWebLabel
Left = 8
Top = 358
Width = 49
Height = 14
Caption = 'lblEntries2'
ElementID = 'lblentries2'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtSearch: TWebEdit
Left = 8
Top = 384
Width = 121
Height = 22
HelpType = htKeyword
ChildOrder = 8
ElementClassName = 'form-control'
ElementID = 'edtsearch'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
HideSelection = False
WidthPercent = 100.000000000000000000
end
object pnlMessage: TWebPanel
Left = 24
Top = 57
Width = 121
Height = 33
ElementClassName = 'card'
ElementID = 'pnl_message'
ChildOrder = 5
ElementBodyClassName = 'card-body'
ElementFont = efCSS
ElementPosition = epRelative
Role = 'alert'
TabOrder = 1
object lblMessage: TWebLabel
Left = 28
Top = 9
Width = 44
Height = 14
Caption = 'Message'
ElementID = 'pnl_message'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnCloseNotification: TWebButton
Left = 96
Top = 3
Width = 22
Height = 25
ChildOrder = 1
ElementClassName = 'btn btn-light'
ElementID = 'view.login.message.button'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Role = 'button'
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
end
end
object WebDBTableControl: TWebDBTableControl
Left = 172
Top = 287
Width = 530
Height = 265
ElementClassName = 'table-responsive'
ElementId = 'customer_list'
BorderColor = clSilver
ChildOrder = 5
ColHeader = False
ElementTableClassName = 'table table-striped table-bordered table-hover dataTable'
Options.ResizeColumns = True
Columns = <
item
DataField = 'ID'
Title = 'ID'
Width = 24
end
item
DataField = 'NAME'
Title = 'NAME'
Width = 100
end
item
DataField = 'SHORT_NAME'
Title = 'SHORT_NAME'
end
item
DataField = 'ADDRESS'
Title = 'ADDRESS'
end>
DataSource = wdsCustomers
end
object cbCorrugatedPlate: TWebCheckBox
Left = 172
Top = 210
Width = 113
Height = 22
Caption = 'Corrugated Plate'
Checked = True
ChildOrder = 5
HeightPercent = 100.000000000000000000
State = cbChecked
WidthPercent = 100.000000000000000000
OnClick = cbCorrugatedPlateClick
end
object cbWebPlate: TWebCheckBox
Left = 304
Top = 210
Width = 113
Height = 22
Caption = 'Web Plate'
ChildOrder = 5
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = cbWebPlateClick
end
object edtCompanyName: TWebEdit
Left = 302
Top = 252
Width = 121
Height = 22
ChildOrder = 7
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtID: TWebEdit
Left = 172
Top = 252
Width = 121
Height = 22
ChildOrder = 8
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnConfirm: TWebButton
Left = 564
Top = 251
Width = 96
Height = 25
Caption = 'Confirm'
ChildOrder = 9
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 88
Top = 434
end
object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 84
Top = 490
object xdwdsCustomersID: TIntegerField
FieldName = 'ID'
end
object xdwdsCustomersNAME: TStringField
FieldName = 'NAME'
end
object xdwdsCustomersSHORT_NAME: TStringField
FieldName = 'SHORT_NAME'
end
object xdwdsCustomersADDRESS: TStringField
FieldName = 'ADDRESS'
end
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
Left = 38
Top = 562
end
end
<div class="row">
<div class="col-12">
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-12 col-md-8">
<div class="row">
<div class="col-sm">
<div id="pnl_message" class="alert alert-danger">
<button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button>
<span id="view.login.message.label"></span>
</div>
</div>
</div>
<div class="row">
<label id="lblentries"></label>
</div>
<label id="lblentries2"></label>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="pagination">
<!-- Pagination items will be added dynamically via Delphi code -->
</ul>
</nav>
</div>
</div>
</div>
</div>
unit View.OrderList;
interface
uses
System.SysUtils, System.Generics.Collections, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
Data.DB, XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB, WEBLib.Grids,
Vcl.Grids;
type
TFOrderList = class(TWebForm)
lblEntries: TWebLabel;
lblEntries2: TWebLabel;
edtSearch: TWebEdit;
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
btnCloseNotification: TWebButton;
XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet;
wdsCustomers: TWebDataSource;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersADDRESS: TStringField;
WebDBTableControl: TWebDBTableControl;
cbCorrugatedPlate: TWebCheckBox;
cbWebPlate: TWebCheckBox;
edtCompanyName: TWebEdit;
edtID: TWebEdit;
btnConfirm: TWebButton;
procedure WebFormShow(Sender: TObject);
procedure WebDBTableControlGetCellChildren(Sender: TObject; ACol,
ARow: Integer; AField: TField; AValue: string;
AElement: TJSHTMLElementRecord);
procedure cbCorrugatedPlateClick(Sender: TObject);
procedure cbWebPlateClick(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
private
//FJSONProc: TJSONProc;
procedure AddRowToTable();
procedure ClearTable();
[async] procedure getCustomers();
public
class function CreateForm(AElementID: string): TWebForm;
end;
var
FOrderList: TFOrderList;
implementation
{$R *.dfm}
class function TFOrderList.CreateForm(AElementID: string): TWebForm;
begin
Application.CreateForm(TFOrderList, AElementID, Result,
procedure(AForm: TObject)
begin
with TFOrderList(AForm) do
begin
end;
end
);
end;
procedure TFOrderList.WebDBTableControlGetCellChildren(Sender: TObject; ACol,
ARow: Integer; AField: TField; AValue: string;
AElement: TJSHTMLElementRecord);
begin
//WebDBTableControl.WidthStyle := TSizeStyle.ssAuto;
console.log(AValue);
WebDBTableControl.ColWidths[ACol] := AValue.Length * 12;
end;
procedure TFOrderList.WebFormShow(Sender: TObject);
begin
getCustomers();
end;
procedure TFOrderList.btnConfirmClick(Sender: TObject);
begin
Close;
end;
procedure TFOrderList.cbCorrugatedPlateClick(Sender: TObject);
begin
cbWebPlate.Checked := false;
end;
procedure TFOrderList.cbWebPlateClick(Sender: TObject);
begin
cbCorrugatedPlate.Checked := false;
end;
procedure TFOrderList.ClearTable();
// clears the table
var
tbody: TJSHTMLElement;
begin
tbody := TJSHTMLElement(document.getElementById('tblCustomerGrid').getElementsByTagName('tbody')[0]);
tbody.innerHTML := '';
end;
procedure TFOrderList.getCustomers();
var
xdcResponse: TXDataClientResponse;
customerList: TJSObject;
data: TJSArray;
i, count: integer;
temp: TJSONObject;
customer: TJSObject;
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers',
[]));
customerList := TJSObject(xdcResponse.Result);
data := TJSArray(customerList['data']);
count := integer(customerList['count']);
xdwdsCustomers.Close;
xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.Open;
end;
procedure TFOrderList.AddRowToTable();
var
NewRow, Cell, P, Button, Audio: TJSHTMLElement;
ClickHandler: TJSFunction;
//strColorList: string;
id: integer;
begin
NewRow := TJSHTMLElement(document.createElement('tr'));
//NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value;
NewRow.addEventListener('click', procedure
begin
//orderEntry(NewRow.Attrs['id'], 'EDIT');
end);
// Company ID Cell
NewRow.Attrs['id'] := xdwdsCustomersID.AsString;
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order ID');
if xdwdsCustomersID.AsString = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersID.AsString;
NewRow.appendChild(Cell);
// Company Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Company Name');
if xdwdsCustomersNAME.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersNAME.Value;
NewRow.appendChild(Cell);
// Short Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Job Name');
if xdwdsCustomersSHORT_NAME.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersSHORT_NAME.Value;
NewRow.appendChild(Cell);
// Address Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order Date');
if xdwdsCustomersADDRESS.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersADDRESS.Value;
NewRow.appendChild(Cell);
// Appends new rows to the table body
TJSHTMLElement(document.getElementById('tblCustomerGrid').getElementsByTagName('tbody')[0]).appendChild(NewRow);
end;
end.
......@@ -12,8 +12,8 @@ object FViewOrders: TFViewOrders
OnCreate = WebFormCreate
OnShow = WebFormShow
object lblEntries: TWebLabel
Left = 0
Top = 336
Left = 68
Top = 333
Width = 77
Height = 13
Caption = 'Showing 0 of ...'
......@@ -23,46 +23,17 @@ object FViewOrders: TFViewOrders
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblEntries2: TWebLabel
Left = 8
Top = 358
Width = 49
Height = 13
Caption = 'lblEntries2'
ElementID = 'lblentries2'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wcbPageSize: TWebComboBox
Left = -4
Top = 52
Width = 145
Height = 21
ElementClassName = 'custom-select'
ElementID = 'wcbpagesize'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = '10'
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'10'
'25'
'50')
end
object wcbSortBy: TWebComboBox
Left = 0
Top = 18
Left = 368
Top = 16
Width = 145
Height = 21
ElementClassName = 'custom-select'
ElementID = 'wcbsortby'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 4
TabStop = False
Text = 'PROOF DONE'
WidthPercent = 100.000000000000000000
ItemIndex = -1
......@@ -85,20 +56,22 @@ object FViewOrders: TFViewOrders
Height = 25
Caption = 'Apply'
ChildOrder = 7
ElementClassName = 'btn btn-light'
ElementID = 'btnapply'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 5
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnApplyClick
end
object edtSearch: TWebEdit
Left = 48
Top = 382
Left = 35
Top = 16
Width = 121
Height = 22
HelpType = htKeyword
TabStop = False
ChildOrder = 8
ElementClassName = 'form-control'
ElementID = 'edtsearch'
......@@ -106,44 +79,46 @@ object FViewOrders: TFViewOrders
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
HideSelection = False
TabOrder = 1
WidthPercent = 100.000000000000000000
end
object btnaddOrder: TWebButton
Left = 0
object btnAddOrder: TWebButton
Left = 59
Top = 79
Width = 96
Height = 25
Caption = 'Add Order'
ChildOrder = 5
ElementClassName = 'btn btn-light'
ElementID = 'btnaddorder'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 6
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnaddOrderClick
OnClick = btnAddOrderClick
end
object btnFilters: TWebButton
Left = 542
Top = 50
Left = 462
Top = 79
Width = 96
Height = 25
Caption = 'Show Filters'
ChildOrder = 6
ElementClassName = 'btn btn-light'
ElementID = 'btnfilters'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 9
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnFiltersClick
end
object dtpStartDate: TWebDateTimePicker
Left = 168
Top = 16
Width = 170
Width = 85
Height = 22
ElementClassName = 'form-control'
ElementID = 'dtpstartdate'
HeightStyle = ssAuto
BorderStyle = bsSingle
......@@ -152,14 +127,15 @@ object FViewOrders: TFViewOrders
Date = 45553.505972858790000000
ElementFont = efCSS
Role = ''
TabOrder = 2
TabStop = False
Text = ''
end
object dtpEndDate: TWebDateTimePicker
Left = 356
Left = 266
Top = 16
Width = 170
Width = 87
Height = 22
ElementClassName = 'form-control'
ElementID = 'dtpenddate'
HeightStyle = ssAuto
BorderStyle = bsSingle
......@@ -168,12 +144,14 @@ object FViewOrders: TFViewOrders
Date = 45553.505972858790000000
ElementFont = efCSS
Role = ''
TabOrder = 3
TabStop = False
Text = ''
end
object pnlMessage: TWebPanel
Left = 220
Top = 429
Width = 121
Left = 82
Top = 352
Width = 125
Height = 33
ElementClassName = 'card'
ElementID = 'pnl_message'
......@@ -182,10 +160,10 @@ object FViewOrders: TFViewOrders
ElementFont = efCSS
ElementPosition = epRelative
Role = 'alert'
TabOrder = 8
TabOrder = 7
object lblMessage: TWebLabel
Left = 28
Top = 9
Left = 32
Top = 11
Width = 42
Height = 13
Caption = 'Message'
......@@ -215,74 +193,44 @@ object FViewOrders: TFViewOrders
end
end
object WebButton1: TWebButton
Left = 174
Left = 188
Top = 79
Width = 96
Height = 25
Caption = 'Set Status'
ChildOrder = 11
ElementClassName = 'btn btn-light'
ElementID = 'btnsetstatus'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 7
TabStop = False
WidthPercent = 100.000000000000000000
end
object WebButton2: TWebButton
Left = 344
Left = 328
Top = 79
Width = 96
Height = 25
Caption = 'PDF'
ChildOrder = 12
ElementClassName = 'btn btn-light'
ElementID = 'btngeneratepdf'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 8
TabStop = False
WidthPercent = 100.000000000000000000
end
object btnConfirm: TWebButton
Left = 566
Top = 317
Width = 96
Height = 25
Caption = 'Confirm'
ChildOrder = 13
ElementClassName = 'btn btn-light'
ElementID = 'btn_confirm_order'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object wcbCustomers: TWebDBLookupComboBox
Left = 550
Top = 286
Width = 145
Height = 22
ElementClassName = 'custom-select'
ElementID = 'wcbcustomer'
ElementFont = efCSS
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = wcbCustomersChange
DataField = 'CURR_ID'
DataSource = wdsSave
KeyField = 'ID'
ListField = 'NAME'
ListSource = wdsCustomers
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 8
Top = 430
Left = 28
Top = 410
end
object XDataWebDataSet1: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 58
Top = 432
Left = 70
Top = 410
object XDataWebDataSet1ID: TStringField
FieldName = 'ID'
end
......@@ -340,18 +288,18 @@ object FViewOrders: TFViewOrders
end
object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1
Left = 94
Top = 430
Left = 120
Top = 410
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
Left = 598
Top = 406
Left = 518
Top = 414
end
object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 596
Top = 354
Left = 422
Top = 412
object xdwdsCustomersNAME: TStringField
FieldName = 'NAME'
end
......@@ -364,15 +312,15 @@ object FViewOrders: TFViewOrders
end
object xdwdsSave: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 498
Top = 352
Left = 188
Top = 408
object xdwdsSaveCURR_ID: TIntegerField
FieldName = 'CURR_ID'
end
end
object wdsSave: TWebDataSource
DataSet = xdwdsSave
Left = 490
Top = 408
Left = 346
Top = 412
end
end
<div class="row">
<div class="col-12">
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-12 col-md-8">
<div class="row">
<div class="col-sm">
<div id="pnl_message" class="alert alert-danger">
<button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button>
<span id="view.login.message.label"></span>
</div>
</div>
</div>
<div class="mb-3" id="filter_info" style="display: none;">
<div class="row">
<!-- Search Input Field -->
<div class="col-auto">
<label class='pe-2' style="font-weight: 700;">Search:</label>
<input class="form-control input-sm" id="edtsearch">
</div>
<!-- Start Date Input Field -->
<div class="col-auto">
<label class='pe-2' style="font-weight: 700;">Start Date:</label>
<input class="form-control input-sm" id="dtpstartdate" type="date">
</div>
<!-- End Date Input Field -->
<div class="col-auto">
<label class='pe-2' style="font-weight: 700;">End Date:</label>
<input class="form-control input-sm" id="dtpenddate" type="date">
</div>
<!-- Status Type Dropdown -->
<div class="col-auto">
<label style="font-weight: 700;">Status Type:</label>
<div>
<select class="form-control input-sm" id="wcbsortby" style="font-size: 1.00rem; height: calc(2.25rem + 2px); padding-top: 0.375rem; padding-bottom: 0.375rem;"></select>
</div>
<div class="container vh-100 d-flex flex-column pb-5" style="max-width: 80%;">
<!-- Alert Section -->
<div class="row">
<div class="col-sm">
<div id="pnl_message" class="alert alert-danger">
<button id="view.login.message.button" type="button" class="btn-close" aria-label="Close"></button>
<span id="view.login.message.label"></span>
</div>
</div>
</div>
</div>
<!-- Button (Align this with the inputs) -->
<div class="col-auto d-flex align-items-end">
<label style="font-weight: 700;"> </label>
<button class="btn btn-primary btn-sm" id="btnapply">Apply</button>
</div>
</div>
</div>
<form class="form-inline">
<div class= "row">
<div class="col-sm-3">
<label class="py-2" style="font-weight: 700;">Show <select class="custom-select" id="wcbpagesize" style="font-size: 1.00rem;"></select> entries</label>
</div>
<div class="col-sm-2">
<button class= "ps-3" id="btnaddorder"></button>
</div>
<div class="col-sm-2">
<button class= "ps-3" id="btnsetstatus"></button>
</div>
<div class="col-sm-2">
<button class= "ps-3" id="btngeneratepdf"></button>
</div>
<div class="col-sm-2">
<button class= "ps-3" id="btnfilters"></button>
</div>
</div>
</form>
</div>
<div class="row">
<label id="lblentries"></label>
</div>
<table class="table table-responsive table-striped table-bordered" id="tblPhoneGrid">
<thead class="thead-dark">
<tr>
<th scope="col">Order ID</th>
<th scope="col">Company Name</th>
<th scope="col">Job Name</th>
<th scope="col">Order Date</th>
<th scope="col">Proof Due</th>
<th scope="col">Proof Date</th>
<th scope="col">Art Due</th>
<th scope="col">Art Done</th>
<th scope="col">Plate Due</th>
<th scope="col">Plate Done</th>
<th scope="col">Mount Due</th>
<th scope="col">Mount Done</th>
<th scope="col">Ship Due</th>
<th scope="col">Ship Done</th>
<th scope="col">Price</th>
<th scope="col">Quickbooks Reference Number</th>
<th scope="col">Colors</th>
</tr>
</thead>
<tbody>
<!-- Rows will be added dynamically via Delphi code -->
</tbody>
</table>
<label id="lblentries2"></label>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="pagination">
<!-- Pagination items will be added dynamically via Delphi code -->
</ul>
</nav>
<!-- Filters Section -->
<div class="container mb-3">
<!-- Filters Row (Hidden Initially) -->
<div id="filter_info" style="display: none;">
<div class="row justify-content-center">
<div class="col-auto">
<label for="edtsearch" class="fw-bold">Search:</label>
<input type="text" id="edtsearch" class="form-control">
</div>
<div class="col-auto">
<label for="dtpstartdate" class="fw-bold">Start Date:</label>
<input type="date" id="dtpstartdate" class="form-control">
</div>
<div class="col-auto">
<label for="dtpenddate" class="fw-bold">End Date:</label>
<input type="date" id="dtpenddate" class="form-control">
</div>
<div class="col-auto">
<label for="wcbsortby" class="fw-bold">Property Type*</label>
<select class="form-select" id="wcbsortby"></select>
</div>
<div class="col-auto d-flex align-items-end">
<button id="btnapply" class="btn btn-primary">Apply</button>
</div>
</div>
</div>
<!-- Actions Row -->
<div class="row mt-3 justify-content-center">
<div class="col-auto">
<button id="btnaddorder" class="btn btn-secondary mt-3">Add Order</button>
</div>
<div class="col-auto">
<button id="btnsetstatus" class="btn btn-secondary mt-3">Set Status</button>
</div>
<div class="col-auto">
<button id="btngeneratepdf" class="btn btn-secondary mt-3">Generate PDF</button>
</div>
<div class="col-auto">
<button id="btnfilters" class="btn btn-secondary mt-3">Filters</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="confirmation_modal" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmation_modal_label">Select Customer</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<select class="form-control input-sm" id="wcbcustomer"></select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="btn_confirm_order">Confirm</button>
</div>
<!-- Entries Label Section -->
<div class="container mt-2">
<div class="row">
<div class="col">
<label id="lblentries"></label>
</div>
</div>
</div>
<!-- Table Section -->
<div id="order_table_section" class="overflow-auto mt-2 flex-grow-1">
<table id="tblPhoneGrid" class="table table-striped table-bordered">
<thead style="position: sticky; top: 0; z-index: 1; background-color: white; border-bottom: 2px solid #dee2e6;">
<tr>
<th>Order ID</th>
<th>Company Name</th>
<th>Job Name</th>
<th>Order Date</th>
<th>Proof Due</th>
<th>Proof Date</th>
<th>Art Due</th>
<th>Art Done</th>
<th>Plate Due</th>
<th>Plate Done</th>
<th>Mount Due</th>
<th>Mount Done</th>
<th>Ship Due</th>
<th>Ship Done</th>
<th>Price</th>
<th>QuickBooks Ref Number</th>
<th>Colors</th>
</tr>
</thead>
<tbody>
<!-- Rows will be dynamically added -->
</tbody>
</table>
</div>
<!-- Pagination Section -->
<div class="container mt-4">
<div class="row justify-content-center">
<nav aria-label="Page navigation">
<ul id="pagination" class="pagination">
<!-- Pagination items added dynamically -->
</ul>
</nav>
</div>
</div>
</div>
</div>
<!-- Confirmation Modal -->
<div id="confirmation_modal" class="modal fade" tabindex="-1" aria-labelledby="confirmation_modal_label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 id="confirmation_modal_label" class="modal-title">Select Customer</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<select id="wcbcustomer" class="form-control input-sm"></select>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" id="btn_confirm_order">Confirm</button>
</div>
</div>
</div>
</div>
......@@ -13,14 +13,13 @@ uses
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
Data.DB, XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB;
XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset, View.AddOrder;
type
TFViewOrders = class(TWebForm)
XDataWebClient1: TXDataWebClient;
XDataWebDataSet1: TXDataWebDataSet;
lblEntries: TWebLabel;
wcbPageSize: TWebComboBox;
wcbSortBy: TWebComboBox;
btnApply: TWebButton;
edtSearch: TWebEdit;
......@@ -40,11 +39,10 @@ type
XDataWebDataSet1ID: TStringField;
XDataWebDataSet1qbRefNum: TStringField;
XDataWebDataSet1colors: TStringField;
btnaddOrder: TWebButton;
btnAddOrder: TWebButton;
btnFilters: TWebButton;
dtpStartDate: TWebDateTimePicker;
dtpEndDate: TWebDateTimePicker;
lblEntries2: TWebLabel;
XDataWebDataSet1plateDue: TStringField;
XDataWebDataSet1plateDone: TStringField;
XDataWebDataSet1orderType: TStringField;
......@@ -53,9 +51,7 @@ type
btnCloseNotification: TWebButton;
WebButton1: TWebButton;
WebButton2: TWebButton;
btnConfirm: TWebButton;
wdsCustomers: TWebDataSource;
wcbCustomers: TWebDBLookupComboBox;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersID: TIntegerField;
......@@ -66,12 +62,11 @@ type
procedure WebFormCreate(Sender: TObject);
procedure btnApplyClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
procedure btnaddOrderClick(Sender: TObject);
procedure btnAddOrderClick(Sender: TObject);
procedure btnFiltersClick(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject);
procedure WebFormShow(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
procedure wcbCustomersChange(Sender: TObject);
private
FChildForm: TWebForm;
procedure AddRowToTable(temp: string);
......@@ -106,7 +101,7 @@ var
implementation
uses
XData.Model.Classes, View.Main, View.OrderList;
XData.Model.Classes, View.Main;
{$R *.dfm}
......@@ -121,7 +116,6 @@ begin
DMConnection.ApiConnection.Connected := True;
PageNumber := 1;
TotalPages := 1; // Initial total pages
wcbPageSize.Text := '10';
wcbSortBy.Text := 'PROOF';
//today := TDateTime.Today;
dtpStartDate.Date := 0;
......@@ -167,19 +161,14 @@ begin
);
end;
procedure TFViewOrders.ShowOrderListForm();
var
newform: TFOrderList;
formattedBkNum: string;
newform: TFAddOrder;
begin
newform := TFOrderList.CreateNew;
{newform.FUserInfo := AUserInfo;
newform.FBKNum := ABKNum;
newform.FSource := ASource;
newform.FViewImages := AViewImages;}
newform := TFAddOrder.CreateNew;
newform.Caption := 'Select Company an Order Type';
newform.Caption := 'Select Customer and Order Type';
newForm.Popup := True;
newForm.Border := fbDialog;
console.log(newForm.GetElementHandle);
......@@ -190,12 +179,13 @@ begin
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newForm.edtID.Text <> '' then
if newform.edtID.Text <> '' then
orderEntry('', newForm.edtID.Text, 'ADD');
end
);
end;
procedure TFViewOrders.AddRowToTable(temp: string);
// Adds rows to the table
// PhoneNumber: phone number of the location
......@@ -622,33 +612,25 @@ begin
if callListLength = 0 then
begin
lblEntries.Caption := 'No entries found';
lblEntries2.Caption := 'No entries found';
end
else if (PageNumber * PageSize) < callListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' of ' + IntToStr(callListLength);
lblEntries2.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(PageNumber * PageSize) +
' of ' + IntToStr(callListLength);
end
else if (PageNumber * PageSize) >= callListLength then
begin
lblEntries.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(callListLength) +
' of ' + IntToStr(callListLength);
lblEntries2.Caption := 'Showing entries ' + IntToStr((PageNumber - 1) * PageSize + 1) +
' - ' + IntToStr(callListLength) +
' of ' + IntToStr(callListLength);
end;
GeneratePagination(TotalPages);
end;
end;
procedure TFViewOrders.btnaddOrderClick(Sender: TObject);
procedure TFViewOrders.btnAddOrderClick(Sender: TObject);
begin
//getCustomers();
ShowOrderListForm();
end;
......@@ -663,7 +645,7 @@ var
searchOptions: string;
begin
PageNumber := 1;
PageSize := StrToInt(wcbPageSize.Text);
PageSize := 50;
OrderBy := wcbSortBy.Text;
searchOptions := '&pagenumber=' + IntToStr(PageNumber) +
'&pagesize=' + IntToStr(PageSize) +
......@@ -755,7 +737,7 @@ var
searchOptions: string;
begin
//PageNumber := 1;
PageSize := StrToInt(wcbPageSize.Text);
PageSize := 50;
OrderBy := wcbSortBy.Text;
searchOptions := '&pagenumber=' + IntToStr(PageNumber) +
'&pagesize=' + IntToStr(PageSize) +
......@@ -786,10 +768,5 @@ begin
end;
end;
procedure TFViewOrders.wcbCustomersChange(Sender: TObject);
begin
console.log(wcbCustomers.Value);
end;
end.
{
"AuthUrl": "hhttp://localhost:2004/emsys/envoy/auth/",
"ApiUrl": "http://localhost:2004/emsys/envoy/api/",
"AppUrl": "http://localhost:2004/emsys/envoy/app/"
}
\ No newline at end of file
{
"AuthUrl" : "http://144.71.200.57:2004/emsys/envoy/auth/",
"ApiUrl" : "http://144.71.200.57:2004/emsys/envoy/api/",
"AppUrl" : "http://144.71.200.57:2004/emsys/envoy/app/"
}
\ No newline at end of file
"AuthUrl" : "http://localhost:2004/emsys/kgOrders/auth/",
"ApiUrl" : "http://localhost:2004/emsys/kgOrders/api/"
}
......@@ -280,5 +280,42 @@ input[type="text"] {
}
.grid-container {
position: relative; /* Ensure the container is the reference for child positioning */
height: 400px; /* Set the height for the grid */
width: 100%; /* Full width of the parent container */
overflow: hidden; /* Prevent unintended overflow */
}
#TFAddOrder_TMSFNCGrid2 {
top: 0px !important; /* Reset the top offset */
left: 0px !important; /* Reset the left offset */
position: absolute !important; /* Use relative positioning to align with the grid container */
}
#TFAddOrder_TMSFNCGrid2_Canvas {
position: relative !important; /* Ensure absolute positioning within the parent */
width: 100% !important; /* Make the canvas fill the container width */
height: 100% !important; /* Make the canvas fill the container height */
left: 0px !important; /* Align canvas to the left */
}
#TFAddOrder_ScrollBar5 {
top: 0px !important; /* Align scrollbar to the top */
right: 0px !important; /* Align scrollbar to the right edge */
position: absolute !important; /* Position within the grid container */
height: 400px !important; /* Match the height of the grid container */
box-sizing: border-box !important; /* Prevent borders from affecting dimensions */
}
......@@ -4,7 +4,7 @@
<noscript>Your browser does not support JavaScript!</noscript>
<link rel="icon" href="data:;base64,=">
<title>TMS Web Project</title>
<link href="template/css/app.css" rel="stylesheet" type="text/css">
<link href="css/app.css" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/2.3.1/css/flag-icon.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.0/css/all.min.css" rel="stylesheet">
......@@ -25,7 +25,7 @@
</script>
<title>EM Systems webCharms App</title>
<title>EM Systems webKGOrders App</title>
<script type="text/javascript" src="$(ProjectName).js"></script>
<style>
/*-----svg loader styles-------*/
......
......@@ -18,7 +18,7 @@ uses
View.EditUser in 'View.EditUser.pas' {FViewEditUser: TWebForm} {*.html},
View.Orders in 'View.Orders.pas' {FViewOrders: TWebForm} {*.html},
View.OrderEntryCorrugated in 'View.OrderEntryCorrugated.pas' {FOrderEntry: TWebForm} {*.html},
View.OrderList in 'View.OrderList.pas' {FOrderList: TWebForm} {*.html};
View.AddOrder in 'View.AddOrder.pas' {FAddOrder: TWebForm} {*.html};
{$R *.res}
......@@ -66,6 +66,6 @@ begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TDMConnection, DMConnection);
Application.Run;
DMConnection.InitApp(@StartApplication, @UnauthorizedAccessProc);
//Application.Run;
end.
......@@ -90,11 +90,11 @@
<DCC_RemoteDebug>false</DCC_RemoteDebug>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.3.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;LastCompiledTime=2018/08/27 15:18:29</VerInfo_Keys>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=;LastCompiledTime=2018/08/27 15:18:29</VerInfo_Keys>
<AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode>
<VerInfo_MinorVer>3</VerInfo_MinorVer>
<TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebSingleInstance>1</TMSWebSingleInstance>
<TMSWebBrowser>5</TMSWebBrowser>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
......@@ -171,13 +171,14 @@
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<DCCReference Include="View.OrderList.pas">
<Form>FOrderList</Form>
<DCCReference Include="View.AddOrder.pas">
<Form>FAddOrder</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/>
<None Include="template\css\app.css"/>
<None Include="css\app.css"/>
<None Include="config\config.json"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
......@@ -213,22 +214,28 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile">
<DeployFile LocalName="config\config.json" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="template\bootstrap\bootstrap.min.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\bootstrap\bootstrap.min.js" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\bootstrap\dataTables.bootstrap.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\css\app.css" Configuration="Debug" Class="ProjectFile">
<DeployFile LocalName="css\app.css" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile">
<Platform Name="Win32">
<RemoteDir>.\</RemoteDir>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="template\bootstrap\bootstrap.min.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\bootstrap\bootstrap.min.js" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\bootstrap\dataTables.bootstrap.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\css\emsys.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\css\metisMenu.min.css" Configuration="Debug" Class="ProjectFile"/>
<DeployFile LocalName="template\css\morris.css" Configuration="Debug" Class="ProjectFile"/>
......
......@@ -3,20 +3,21 @@ object ApiServerModule: TApiServerModule
Width = 230
object SparkleHttpSysDispatcher: TSparkleHttpSysDispatcher
Active = True
Left = 84
Left = 86
Top = 30
end
object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/envoy/api/'
BaseUrl = 'http://localhost:2004/emsys/kgOrders/api/'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Api'
EntitySetPermissions = <>
SwaggerOptions.Enabled = True
SwaggerOptions.AuthMode = Jwt
SwaggerUIOptions.Enabled = True
SwaggerUIOptions.ShowFilter = True
SwaggerUIOptions.TryItOutEnabled = True
Left = 85
Top = 110
Left = 89
Top = 112
object XDataServerLogging: TSparkleGenericMiddleware
OnMiddlewareCreate = XDataServerLoggingMiddlewareCreate
end
......
......@@ -32,7 +32,7 @@ type
{ Private declarations }
public
{ Public declarations }
procedure StartApiServer(ABaseUrl: string);
procedure StartApiServer(ABaseUrl: string; AModelName: string);
end;
const
......@@ -67,7 +67,7 @@ begin
Result := (User <> nil) and User.Claims.Exists('admin') and User.Claims['admin'].AsBoolean;
end;
procedure TApiServerModule.StartApiServer(ABaseUrl: string);
procedure TApiServerModule.StartApiServer(ABaseUrl: string; AModelName: string);
var
Url: string;
begin
......@@ -79,9 +79,10 @@ begin
Url := Url + SERVER_PATH_SEGMENT;
XDataServer.BaseUrl := Url;
XDataServer.ModelName := AModelName;
SparkleHttpSysDispatcher.Start;
Logger.Log(1, Format('Api server module listening at "%s"', [Url]));
Logger.Log(1, Format('Api server module listening at "%s"', [XDataServer.BaseUrl]));
end;
procedure TApiServerModule.XDataServerLoggingMiddlewareCreate(Sender: TObject;
......
......@@ -19,11 +19,7 @@ object AuthDatabase: TAuthDatabase
object ucKG: TUniConnection
ProviderName = 'MySQL'
Database = 'kg_order_entry'
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
Username = 'root'
Server = '192.168.159.132'
Connected = True
LoginPrompt = False
Left = 67
Top = 131
......
......@@ -20,7 +20,6 @@ type
{ Private declarations }
public
{ Public declarations }
procedure SetLoginAuditEntry( userStr: string );
end;
var
......@@ -40,46 +39,61 @@ uses
procedure TAuthDatabase.DataModuleCreate(Sender: TObject);
var
IniFile: TIniFile;
iniFile: TIniFile;
iniStr: string;
begin
IniFile := TIniFile.Create( ChangeFileExt(Application.ExeName, '.ini') );
Logger.Log( 5, 'TAuthDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
iniStr := IniFile.ReadString( 'Database', 'Server', '' );
Logger.Log( 5, '--iniFile entries:' );
iniStr := iniFile.ReadString('Database', 'Server', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Database->Server: Entry not found' )
Logger.Log( 5, '----Database->Server: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Database->Server: ' + iniStr );
Logger.Log( 5, '----Database->Server: ' + iniStr );
ucKG.Server := iniStr;
end;
iniStr := IniFile.ReadString( 'Twilio', 'AccountSID', '' );
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AccountSID: Entry not found' )
Logger.Log( 5, '----Database->Database: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AccountSID: ' + iniStr );
//accountSID := iniStr;
Logger.Log( 5, '----Database->Database: ' + iniStr );
ucKG.Database := iniStr;
end;
iniStr := IniFile.ReadString( 'Twilio', 'AuthHeader', '' );
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AuthHeader: Entry not found' )
Logger.Log( 5, '----Database->Username: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AuthHeader: ' + iniStr );
//authHeader := iniStr;
Logger.Log( 5, '----Database->Username: ' + iniStr );
ucKG.Username := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Password: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Password: xxxxxxxx' );
ucKG.Password := iniStr;
end;
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(3, '--TAuthDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
IniFile.Free;
iniFile.Free;
end;
end;
......@@ -88,34 +102,5 @@ begin
ucKG.Connected := false;
end;
procedure TAuthDatabase.SetLoginAuditEntry( userStr: string );
var
auditMasterId: string;
userInfo: TStringList;
entry: string;
username: string;
fullname: string;
agency: string;
userid: string;
personnelid: string;
admin: boolean;
i: Integer;
begin
Logger.Log( 3, 'TAuthDatabase.SetLoginAuditEntry - start' );
userInfo := TStringList.Create;
try
userInfo.Delimiter := '&';
userInfo.StrictDelimiter := True;
userInfo.DelimitedText := userStr;
username := userInfo.Values['username'];
fullname := userInfo.Values['fullname'];
userid := userInfo.Values['userId'];
personnelid := userInfo.Values['personnelid'];
finally
userInfo.Free;
end;
end;
end.
......@@ -6,7 +6,7 @@ object AuthServerModule: TAuthServerModule
Top = 16
end
object XDataServer: TXDataServer
BaseUrl = 'http://localhost:2004/emsys/envoy/auth/'
BaseUrl = 'http://localhost:2004/emsys/kgOrders/auth/'
Dispatcher = SparkleHttpSysDispatcher
ModelName = 'Auth'
EntitySetPermissions = <>
......
......@@ -67,7 +67,7 @@ begin
XDataServer.ModelName := AModelName;
SparkleHttpSysDispatcher.Start;
Logger.Log(1, Format('Auth server module listening at "%s"', [Url]));
Logger.Log(1, Format('Auth server module listening at "%s"', [XDataServer.BaseUrl]));
end;
procedure TAuthServerModule.XDataServerLoggingMiddlewareCreate(Sender: TObject;
......
......@@ -6,7 +6,7 @@ unit Common.Config;
interface
const
defaultServerUrl = 'http://localhost:2004/emsys/envoycalls/';
defaultServerUrl = 'http://localhost:2004/emsys/kgOrders/';
type
TServerConfig = class
......@@ -15,16 +15,12 @@ type
FJWTTokenSecret: string;
FAdminPassword: string;
FWebAppFolder: string;
FMemoLogLevel: Integer;
FFileLogLevel: Integer;
public
constructor Create;
property url: string read FUrl write FUrl;
property jwtTokenSecret: string read FJWTTokenSecret write FJWTTokenSecret;
property adminPassword: string read FAdminPassword write FAdminPassword;
property webAppFolder: string read FWebAppFolder write FWebAppFolder;
property memoLogLevel: Integer read FMemoLogLevel write FMemoLogLevel;
property fileLogLevel: Integer read FFileLogLevel write FFileLogLevel;
end;
procedure LoadServerConfig;
......@@ -65,8 +61,6 @@ begin
Logger.Log( 1, '-- serverConfig.adminPassword: ' + serverConfig.adminPassword );
Logger.Log( 1, '-- serverConfig.jwtTokenSecret: ' + serverConfig.jwtTokenSecret );
Logger.Log( 1, '-- serverConfig.webAppFolder: ' + serverConfig.webAppFolder );
Logger.Log( 1, '-- serverConfig.memoLogLevel: ' + IntToStr(serverConfig.memoLogLevel) );
Logger.Log( 1, '-- serverConfig.fileLogLevel: ' + IntToStr(serverConfig.fileLogLevel) );
Logger.Log( 1, '--LoadServerConfig - end' );
end;
......@@ -82,8 +76,6 @@ begin
adminPassword := 'whatisthisusedfor';
jwtTokenSecret := 'super_secret0123super_secret4567';
webAppFolder := 'static';
memoLogLevel := 3;
fileLogLevel := 4;
// ServerConfigStr := Bcl.Json.TJson.Serialize( ServerConfig );
// ConfigFile := 'serverconfig.json';
// TFile.WriteAllText( ConfigFile, ServerConfigStr );
......
......@@ -172,7 +172,7 @@ object FData: TFData
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '2.8.3.1'
Version = '2.8.3.2'
AutoCreateColumns = True
AutoRemoveColumns = True
Columns = <
......@@ -753,7 +753,7 @@ object FData: TFData
SortSettings.HeaderColorTo = clWhite
SortSettings.HeaderMirrorColor = clWhite
SortSettings.HeaderMirrorColorTo = clWhite
Version = '2.8.3.1'
Version = '2.8.3.2'
AutoCreateColumns = True
AutoRemoveColumns = True
Columns = <
......@@ -1505,7 +1505,6 @@ object FData: TFData
Top = 472
end
object uqUsers: TUniQuery
Connection = FDatabaseModule.ucKG
SQL.Strings = (
'select * from users')
Left = 669
......
......@@ -51,11 +51,11 @@ implementation
{$R *.dfm}
uses Database, uLibrary;
uses KGOrders.Database, uLibrary;
procedure TFData.FormCreate(Sender: TObject);
begin
FDatabaseModule := TFDatabaseModule.Create(Self);
KGOrdersDatabase := TKGOrdersDatabase.Create(Self);
end;
procedure TFData.btnFindClick(Sender: TObject);
......
object FDatabaseModule: TFDatabaseModule
object KGOrdersDatabase: TKGOrdersDatabase
OnCreate = DataModuleCreate
Height = 480
Width = 640
Height = 358
Width = 519
object ucKG: TUniConnection
ProviderName = 'MySQL'
Database = 'kg_order_entry'
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
Username = 'root'
Server = '192.168.159.132'
Connected = True
LoginPrompt = False
Left = 75
Top = 139
Top = 65
EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
end
object UniQuery1: TUniQuery
Connection = ucKG
SQL.Strings = (
'')
Left = 363
Top = 138
Left = 73
Top = 148
end
object MySQLUniProvider1: TMySQLUniProvider
Left = 220
Top = 134
Left = 162
Top = 66
end
object UniQuery2: TUniQuery
Connection = ucKG
SQL.Strings = (
'')
Left = 433
Top = 144
Left = 179
Top = 148
end
object uqOrders: TUniQuery
Connection = ucKG
SQL.Strings = (
'select * from corrugated_plate_orders')
Left = 527
Top = 120
Left = 263
Top = 156
object uqOrdersORDER_ID: TIntegerField
FieldName = 'ORDER_ID'
end
......
// Where the database is kept. Only used by Lookup.ServiceImpl to retrieve info
// from the data base and send it to the client.
// Author: ???
unit Database;
unit KGOrders.Database;
interface
......@@ -11,7 +11,7 @@ uses
Common.Logging, Vcl.Forms, MySQLUniProvider;
type
TFDatabaseModule = class(TDataModule)
TKGOrdersDatabase = class(TDataModule)
ucKG: TUniConnection;
UniQuery1: TUniQuery;
MySQLUniProvider1: TMySQLUniProvider;
......@@ -113,7 +113,7 @@ type
end;
var
FDatabaseModule: TFDatabaseModule;
KGOrdersDatabase: TKGOrdersDatabase;
implementation
......@@ -121,58 +121,71 @@ implementation
{$R *.dfm}
procedure TFDatabaseModule.DataModuleCreate(Sender: TObject);
// Sets the database connection to the ini file IP
// TODO: clean up unnecessary reads from the ini file
procedure TKGOrdersDatabase.DataModuleCreate(Sender: TObject);
var
IniFile: TIniFile;
iniFile: TIniFile;
iniStr: string;
begin
IniFile := TIniFile.Create( ChangeFileExt(Application.ExeName, '.ini') );
Logger.Log( 5, 'TKGOrdersDatabase.DataModuleCreate' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
iniStr := IniFile.ReadString( 'Database', 'Server', '' );
Logger.Log( 5, '--iniFile entries:' );
iniStr := iniFile.ReadString('Database', 'Server', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Database->Server: Entry not found' )
Logger.Log( 5, '----Database->Server: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Database->Server: ' + iniStr );
Logger.Log( 5, '----Database->Server: ' + iniStr );
ucKG.Server := iniStr;
end;
iniStr := IniFile.ReadString( 'Twilio', 'AccountSID', '' );
iniStr := iniFile.ReadString('Database', 'Database', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AccountSID: Entry not found' )
Logger.Log( 5, '----Database->Database: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AccountSID: ' + iniStr );
//accountSID := iniStr;
Logger.Log( 5, '----Database->Database: ' + iniStr );
ucKG.Database := iniStr;
end;
iniStr := IniFile.ReadString( 'Twilio', 'AuthHeader', '' );
iniStr := iniFile.ReadString('Database', 'Username', '');
if iniStr.IsEmpty then
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AuthHeader: Entry not found' )
Logger.Log( 5, '----Database->Username: Entry not found' )
else
begin
Logger.Log( 1, 'iniFile: ' + ChangeFileExt(Application.ExeName, '.ini') +
' Twilio->AuthHeader: ' + iniStr );
//authHeader := iniStr;
Logger.Log( 5, '----Database->Username: ' + iniStr );
ucKG.Username := iniStr;
end;
iniStr := iniFile.ReadString('Database', 'Password', '');
if iniStr.IsEmpty then
Logger.Log( 5, '----Database->Password: Entry not found' )
else
begin
Logger.Log( 5, '----Database->Password: xxxxxxxx' );
ucKG.Password := iniStr;
end;
try
ucKG.Connect;
except
on E: Exception do
begin
Logger.Log(3, '--TKGOrdersDatabase.DataModuleCreate -Error connecting to database: ' + E.Message);
end;
end;
Logger.Log(1, '');
finally
IniFile.Free;
iniFile.Free;
end;
end;
class procedure TFDatabaseModule.ExecSQL(const SQL: string);
class procedure TKGOrdersDatabase.ExecSQL(const SQL: string);
var
DB: TFDatabaseModule;
DB: TKGOrdersDatabase;
begin
DB := TFDatabaseModule.Create(nil);
DB := TKGOrdersDatabase.Create(nil);
try
DB.UniQuery1.SQL.Text := SQL;
DB.UniQuery1.ExecSQL;
......
......@@ -141,7 +141,6 @@ type
supplied_by_customer_existing_: string;
supplied_by_customer_ref_art_p: string;
supplied_by_customer_ref_art_a: string;
supplied_by_customer_order_date: string;
// Layout
layout_rsc_l: string;
......@@ -200,7 +199,7 @@ type
type
[ServiceContract]
[ServiceContract, Model(API_MODEL)]
ILookupService = interface(IInvokable)
['{F24E1468-5279-401F-A877-CD48B44F4416}']
[HttpGet] function Search(phoneNum: string): TOrderList;
......
......@@ -11,7 +11,7 @@ interface
uses
XData.Server.Module,
XData.Service.Common,
Database, Data.DB,
KGOrders.Database, Data.DB,
Lookup.Service, System.Hash, System.Classes, System.JSON;
......@@ -19,7 +19,7 @@ type
[ServiceImplementation]
TLookupService = class(TInterfacedObject, ILookupService)
strict private
ordersDB: TFDatabaseModule;
ordersDB: TKGOrdersDatabase;
private
function GetItems(searchOptions: string): TItemList;
function GetUsers(searchOptions: string): TUserList;
......@@ -51,7 +51,7 @@ uses
procedure TLookupService.AfterConstruction;
begin
inherited;
ordersDB := TFDatabaseModule.Create(nil);
ordersDB := TKGOrdersDatabase.Create(nil);
end;
......@@ -383,7 +383,6 @@ begin
result.staff_fields_mount_due := ordersDB.UniQuery1.FieldByName('staff_fields_mount_due').AsString;
result.staff_fields_art_location := ordersDB.UniQuery1.FieldByName('staff_fields_art_location').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('staff_fields_invoice_to').AsString;
result.staff_fields_order_date := ordersDB.UniQuery1.FieldByName('staff_fields_order_date').AsString;
// Supplied by Customer
if ordersDB.UniQuery1.FieldByName('supplied_by_customer_b_w_copy').AsString = 'T' then
......
......@@ -3,7 +3,7 @@ object FMain: TFMain
Top = 0
Caption = 'KG Orders Server'
ClientHeight = 597
ClientWidth = 764
ClientWidth = 773
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
......@@ -12,15 +12,21 @@ object FMain: TFMain
Font.Style = []
OnClose = FormClose
DesignSize = (
764
773
597)
TextHeight = 13
object memoInfo: TMemo
Left = 8
Top = 40
Width = 744
Top = 44
Width = 753
Height = 549
Anchors = [akLeft, akTop, akRight, akBottom]
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Lucida Console'
Font.Style = []
ParentFont = False
ReadOnly = True
TabOrder = 0
end
......@@ -60,13 +66,6 @@ object FMain: TFMain
TabOrder = 4
OnClick = btnAuthSwaggerUIClick
end
object tmrTwilio: TTimer
Enabled = False
Interval = 300000
OnTimer = tmrTwilioTimer
Left = 167
Top = 399
end
object initTimer: TTimer
OnTimer = initTimerTimer
Left = 58
......
......@@ -9,7 +9,7 @@ uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, Winapi.ShellApi,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, Vcl.ExtCtrls, System.Generics.Collections, System.IniFiles,
Auth.Service, Auth.Server.Module, Api.Server.Module, App.Server.Module;
Auth.Service, Auth.Server.Module, Lookup.Service, Api.Server.Module, App.Server.Module;
type
TFMain = class(TForm)
......@@ -17,21 +17,17 @@ type
btnApiSwaggerUI: TButton;
btnData: TButton;
btnExit: TButton;
tmrTwilio: TTimer;
initTimer: TTimer;
btnAuthSwaggerUI: TButton;
procedure btnApiSwaggerUIClick(Sender: TObject);
procedure btnDataClick(Sender: TObject);
procedure btnExitClick(Sender: TObject);
procedure tmrTwilioTimer(Sender: TObject);
procedure ContactFormData(AText: String);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure initTimerTimer(Sender: TObject);
procedure btnAuthSwaggerUIClick(Sender: TObject);
strict private
phoneDict: TDictionary<string, string>;
procedure StartServers;
procedure UpdateGUI;
end;
......@@ -45,7 +41,8 @@ uses
Common.Logging,
Common.Config,
Sparkle.Utils,
Database, Data;
KGOrders.Database,
Data;
{$R *.dfm}
......@@ -99,29 +96,39 @@ procedure TFMain.StartServers;
// Reads from the ini file to figure out what IP the database is located at and
// whether or not Twilio automatic updates should be enabled
var
iniFilename: string;
iniFile: TIniFile;
iniStr: string;
begin
// this looks ok in the log file but not in the memo on the form
Logger.Log(1, '*******************************************************');
Logger.Log(1, '* kgOrders Server - beta ver. *');
Logger.Log(1, '* Developed by EM Systems, Inc. *');
Logger.Log(1, '*******************************************************');
Logger.Log(1, '');
Logger.Log(1, 'TMemoLogAppender - logLevel: ' + IntToStr(serverConfig.memoLogLevel));
Logger.Log(1, 'TFileLogAppender - logLevel: ' + IntToStr(serverConfig.fileLogLevel));
Logger.Log(1, '');
iniFilename := ChangeFileExt(Application.ExeName, '.ini');
Logger.Log( 1, 'iniFilename: ' + iniFileName);
iniFile := TIniFile.Create( iniFilename );
Logger.Log( 1, '*******************************************************' );
Logger.Log( 1, '* kgOrdersServer - ver 1.1.0 *' );
Logger.Log( 1, '* Developed by EM Systems, Inc. *' );
Logger.Log( 1, '*******************************************************' );
Logger.Log( 1, '' );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
iniStr := iniFile.ReadString( 'Options', 'LogFileNum', '' );
Logger.Log( 1, 'iniFile: ' + ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
Logger.Log( 1, 'LogLevels are displayed here. They were set in kgOrders.dpr, it executes first' );
iniStr := iniFile.ReadString( 'Settings', 'MemoLogLevel', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->memoLogLevel: Entry not found - default: 3' )
else
Logger.Log( 1, '--Settings->memoLogLevel: ' + iniStr );
iniStr := iniFile.ReadString( 'Settings', 'FileLogLevel', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Settings->fileLogLevel: Entry not found - default: 4' )
else
Logger.Log( 1, '--Settings->fileLogLevel: ' + iniStr );
Logger.Log( 1, '' );
iniStr := iniFile.ReadString( 'Settings', 'LogFileNum', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Options->LogFileNum: Entry not found' )
Logger.Log( 1, '--Settings->LogFileNum: Entry not found' )
else
Logger.Log( 1, '--Options->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) );
Logger.Log( 1, '--Settings->LogFileNum: ' + IntToStr(StrToInt(iniStr) - 1) );
iniStr := IniFile.ReadString( 'Database', 'Server', '' );
if iniStr.IsEmpty then
......@@ -129,28 +136,7 @@ begin
else
Logger.Log( 1, '--Database->Server: ' + iniStr );
iniStr := IniFile.ReadString( 'Options', 'TwilioUpdateTime', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Options->TwilioUpdateTime: Entry not found' )
else
begin
Logger.Log( 1, '--Options->TwilioUpdateTime: ' + iniStr );
if iniStr = '0' then
begin
Logger.Log( 1, '--Twilio Update Timer not enabled due to timer length of ' +
'0. Edit the ini file to enable auto updates.');
tmrTwilio.Enabled := False;
end
else
begin
Logger.Log( 1, '--Twilio Update Timer enabled and set to update every '+ iniStr + ' minutes.');
tmrTwilio.Interval := StrToInt(IniStr) * 60000;
tmrTwilio.Enabled := True;
end;
end;
Logger.Log(1, '');
Logger.Log( 1, '' );
finally
IniFile.Free;
end;
......@@ -159,26 +145,14 @@ begin
AuthServerModule.StartAuthServer(serverConfig.url, AUTH_MODEL);
ApiServerModule := TApiServerModule.Create( Self );
ApiServerModule.StartApiServer(serverConfig.url);
ApiServerModule.StartApiServer(serverConfig.url, API_MODEL);
AppServerModule := TAppServerModule.Create(Self);
AppServerModule.StartAppServer( serverConfig.url );
end;
procedure TFMain.tmrTwilioTimer(Sender: TObject);
var
key: string;
phoneNum: string;
begin
memoInfo.Lines.Add('Timer set off');
tmrTwilio.Enabled := False;
tmrTwilio.Enabled := True;
end;
procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
phoneDict.Free;
ServerConfig.Free;
AuthServerModule.Free;
ApiServerModule.Free;
......
......@@ -9,7 +9,7 @@ uses
Api.Server.Module in 'Source\Api.Server.Module.pas' {ApiServerModule: TDataModule},
Main in 'Source\Main.pas' {FMain},
Common.Logging in 'Source\Common.Logging.pas',
Database in 'Source\Database.pas' {FDatabaseModule: TDataModule},
KGOrders.Database in 'Source\KGOrders.Database.pas' {KGOrdersDatabase: TDataModule},
Common.Middleware.Logging in 'Source\Common.Middleware.Logging.pas',
Common.Config in 'Source\Common.Config.pas',
Auth.Server.Module in 'Source\Auth.Server.Module.pas' {AuthServerModule: TDataModule},
......@@ -92,12 +92,12 @@ var
begin
FLogLevel := ALogLevel;
FCriticalSection := TCriticalSection.Create;
IniFile := TIniFile.Create( ChangeFileExt( Application.ExeName, '.ini' ) );
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
fileNum := IniFile.ReadInteger( 'Options', 'LogFileNum', 0 );
fileNum := iniFile.ReadInteger( 'Settings', 'LogFileNum', 0 );
// FFilename := AFilename + Format('%.*d',[4, fileNum]);
FFilename := AFilename + Format('%.4d',[fileNum]);
iniFile.WriteInteger( 'Options', 'LogFileNum', fileNum + 1 );
iniFile.WriteInteger( 'Settings', 'LogFileNum', fileNum + 1 );
finally
iniFile.Free;
end;
......@@ -132,14 +132,12 @@ begin
try
AssignFile( FLogFile, LogFile );
if FileExists(LogFile) then
Append( FLogFile )
else
ReWrite( FLogFile );
if logLevel <= FLogLevel then
begin
if FileExists(LogFile) then
Append( FLogFile )
else
ReWrite( FLogFile );
WriteLn( FLogFile, FormattedMessage );
end;
finally
CloseFile(FLogFile);
end;
......@@ -150,12 +148,24 @@ end;
{$R *.res}
var
iniFile: TIniFile;
memoLogLevel: Integer;
fileLogLevel: Integer;
begin
ReportMemoryLeaksOnShutdown := True;
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFMain, FMain);
Logger.AddAppender(TMemoLogAppender.Create( 5, FMain.memoinfo ));
Logger.AddAppender(TFileLogAppender.Create( 5, 'kgOrdersServer' ));
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
try
memoLogLevel := iniFile.ReadInteger( 'Settings', 'memoLogLevel', 3 );
fileLogLevel := iniFile.ReadInteger( 'Settings', 'memoLogLevel', 4 );
finally
iniFile.Free;
end;
Logger.AddAppender(TMemoLogAppender.Create( memoLogLevel, FMain.memoinfo ));
Logger.AddAppender(TFileLogAppender.Create( fileLogLevel, 'kgOrdersServer' ));
Application.Run;
end.
......@@ -133,8 +133,8 @@
<Form>FMain</Form>
</DCCReference>
<DCCReference Include="Source\Common.Logging.pas"/>
<DCCReference Include="Source\Database.pas">
<Form>FDatabaseModule</Form>
<DCCReference Include="Source\KGOrders.Database.pas">
<Form>KGOrdersDatabase</Form>
<FormType>dfm</FormType>
<DesignClass>TDataModule</DesignClass>
</DCCReference>
......
[Options]
LogFileNum=234
UpdateTimerLength=0
[Settings]
MemoLogLevel=5
FileLogLevel=5
LogFileNum=23
webClientVersion=1.0.0
[Database]
Server=192.168.159.132
--Server=192.168.102.129
[Twilio]
AccountSID=AC37aeef9c36a2cccbaecbadafc172b2ff
AuthHeader=Basic QUMzN2FlZWY5YzM2YTJjY2NiYWVjYmFkYWZjMTcyYjJmZjo5NzM5OTAwYTgyZmRlNjVlMzI2ODFmZjVmMmI5ZGZjZgo=
--Server=192.168.159.132
Server=192.168.198.131
--Server=192.168.75.133
--Database=
--Username=
--Password=
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment