Commit 7f19b291 by Elias Sarraf

Merge remote-tracking branch 'origin/cam'

parents e3cf4538 bfd278e3
...@@ -51,7 +51,7 @@ type ...@@ -51,7 +51,7 @@ type
procedure ShowForm( AFormClass: TWebFormClass ); procedure ShowForm( AFormClass: TWebFormClass );
procedure EditUser( Mode, Username, Password, Name, Status, Email, procedure EditUser( Mode, Username, Password, Name, Status, Email,
Access, Rights, Perspective, QB: string); Access, Rights, Perspective, QB: string);
procedure ViewOrderEntry(orderInfo, mode: string); procedure ViewOrderEntry(orderInfo, customerInfo, mode: string);
procedure ViewOrders(info: string); procedure ViewOrders(info: string);
procedure ShowUserForm(Info: string); procedure ShowUserForm(Info: string);
end; end;
...@@ -227,12 +227,12 @@ begin ...@@ -227,12 +227,12 @@ begin
end; end;
procedure TFViewMain.ViewOrderEntry(orderInfo, mode: string); procedure TFViewMain.ViewOrderEntry(orderInfo, customerInfo, mode: string);
begin begin
lblAppTitle.Caption := 'Koehler-Gibson Order Entry'; lblAppTitle.Caption := 'Koehler-Gibson Order Entry';
if Assigned(FChildForm) then if Assigned(FChildForm) then
FChildForm.Free; FChildForm.Free;
FChildForm := TFOrderEntry.CreateForm(WebPanel1.ElementID, orderInfo, mode); FChildForm := TFOrderEntry.CreateForm(WebPanel1.ElementID, orderInfo, customerInfo, mode);
end; end;
procedure TFViewMain.ShowUserForm(Info: string); procedure TFViewMain.ShowUserForm(Info: string);
......
...@@ -239,13 +239,14 @@ object FOrderEntry: TFOrderEntry ...@@ -239,13 +239,14 @@ object FOrderEntry: TFOrderEntry
object edtCompanyName: TWebDBEdit object edtCompanyName: TWebDBEdit
Left = 24 Left = 24
Top = 92 Top = 92
Width = 121 Width = 260
Height = 22 Height = 22
AutoSize = True AutoSize = True
ChildOrder = 79 ChildOrder = 79
ElementID = 'edtcompanyname' ElementID = 'edtcompanyname'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
MaxLength = 90 MaxLength = 90
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
DataField = 'NAME' DataField = 'NAME'
DataSource = WebDataSource1 DataSource = WebDataSource1
...@@ -327,19 +328,6 @@ object FOrderEntry: TFOrderEntry ...@@ -327,19 +328,6 @@ object FOrderEntry: TFOrderEntry
DataField = 'staff_fields_invoice_to' DataField = 'staff_fields_invoice_to'
DataSource = WebDataSource1 DataSource = WebDataSource1
end end
object edtShipTo: TWebDBEdit
Left = 26
Top = 430
Width = 121
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtshipto'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
DataField = 'staff_fields_ship_to'
DataSource = WebDataSource1
end
object edtPONumber: TWebDBEdit object edtPONumber: TWebDBEdit
Left = 26 Left = 26
Top = 458 Top = 458
...@@ -965,6 +953,20 @@ object FOrderEntry: TFOrderEntry ...@@ -965,6 +953,20 @@ object FOrderEntry: TFOrderEntry
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebDBComboBox1: TWebDBComboBox
Left = 26
Top = 430
Width = 145
Height = 22
ElementID = 'wcbshipto'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
ItemIndex = -1
DataField = 'staff_fields_ship_to'
DataSource = WebDataSource1
ListField = 'ADDRESS'
ListSource = wdsShipTo
end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 244 Left = 244
...@@ -1247,10 +1249,25 @@ object FOrderEntry: TFOrderEntry ...@@ -1247,10 +1249,25 @@ object FOrderEntry: TFOrderEntry
object XDataWebDataSet1staff_fields_mount_due: TStringField object XDataWebDataSet1staff_fields_mount_due: TStringField
FieldName = 'staff_fields_mount_due' FieldName = 'staff_fields_mount_due'
end end
object XDataWebDataSet1ADDRESS_LIST: TStringField
FieldName = 'ADDRESS_LIST'
end
end end
object WebDataSource1: TWebDataSource object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1 DataSet = XDataWebDataSet1
Left = 216 Left = 216
Top = 104 Top = 104
end end
object wdsShipTo: TWebDataSource
DataSet = xdwdsShipTo
Left = 212
Top = 436
end
object xdwdsShipTo: TXDataWebDataSet
Left = 192
Top = 486
object xdwdsShipToADDRESS: TStringField
FieldName = 'ADDRESS'
end
end
end end
...@@ -38,7 +38,6 @@ type ...@@ -38,7 +38,6 @@ type
edtQuantity: TWebDBEdit; edtQuantity: TWebDBEdit;
edtPrice: TWebDBEdit; edtPrice: TWebDBEdit;
edtInvoiceTo: TWebDBEdit; edtInvoiceTo: TWebDBEdit;
edtShipTo: TWebDBEdit;
edtPONumber: TWebDBEdit; edtPONumber: TWebDBEdit;
edtJobName: TWebDBEdit; edtJobName: TWebDBEdit;
edtQuickBooksItem: TWebDBEdit; edtQuickBooksItem: TWebDBEdit;
...@@ -182,11 +181,17 @@ type ...@@ -182,11 +181,17 @@ type
cbStickyBak: TWebCheckBox; cbStickyBak: TWebCheckBox;
cbLoose: TWebCheckBox; cbLoose: TWebCheckBox;
cbExcaliburDie: TWebCheckBox; cbExcaliburDie: TWebCheckBox;
XDataWebDataSet1ADDRESS_LIST: TStringField;
wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet;
xdwdsShipToADDRESS: TStringField;
WebDBComboBox1: TWebDBComboBox;
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
procedure WebFormShow(Sender: TObject); procedure WebFormShow(Sender: TObject);
[async] procedure getOrder(Order_ID: string); [async] procedure getOrder(Order_ID: string);
[async] procedure getCustomer(customerID: string);
procedure tmrScrollTopTimer(Sender: TObject); procedure tmrScrollTopTimer(Sender: TObject);
procedure WebButton1Click(Sender: TObject); procedure WebButton1Click(Sender: TObject);
procedure addColorRow(num, Color, LPI, Size: string); procedure addColorRow(num, Color, LPI, Size: string);
...@@ -197,10 +202,11 @@ type ...@@ -197,10 +202,11 @@ type
FCurrentReportType: string; FCurrentReportType: string;
FSelectProc: TSelectProc; FSelectProc: TSelectProc;
orderID: string; orderID: string;
customerID: string;
mode: string; mode: string;
//FJSONProc1: TJSONProc1; //FJSONProc1: TJSONProc1;
public public
class function CreateForm(AElementID, orderInfo, mode: string): TWebForm; class function CreateForm(AElementID, orderInfo, customerInfo, mode: string): TWebForm;
end; end;
var var
...@@ -333,7 +339,7 @@ begin ...@@ -333,7 +339,7 @@ begin
[orderJSON.ToString])); [orderJSON.ToString]));
end; end;
class function TFOrderEntry.CreateForm(AElementID, orderInfo, mode: string): TWebForm; class function TFOrderEntry.CreateForm(AElementID, orderInfo, customerInfo, mode: string): TWebForm;
var var
localMode: string; localMode: string;
begin begin
...@@ -344,6 +350,7 @@ begin ...@@ -344,6 +350,7 @@ begin
with TFOrderEntry(AForm) do with TFOrderEntry(AForm) do
begin begin
HideNotification; HideNotification;
TFOrderEntry(AForm).customerID := customerInfo;
TFOrderEntry(AForm).orderID := orderInfo; TFOrderEntry(AForm).orderID := orderInfo;
TFOrderEntry(AForm).mode := localMode; TFOrderEntry(AForm).mode := localMode;
console.log(TFOrderEntry(AForm).mode); console.log(TFOrderEntry(AForm).mode);
...@@ -362,7 +369,6 @@ begin ...@@ -362,7 +369,6 @@ begin
const newRow = document.createElement('div'); const newRow = document.createElement('div');
newRow.className = 'row mb-2'; newRow.className = 'row mb-2';
// Labels and inputs
const labels = ['#', 'Color', 'LPI', 'Size']; const labels = ['#', 'Color', 'LPI', 'Size'];
const values = [num, Color, LPI, Size]; const values = [num, Color, LPI, Size];
labels.forEach((label, index) => { labels.forEach((label, index) => {
...@@ -400,7 +406,6 @@ begin ...@@ -400,7 +406,6 @@ begin
removeButtonCol.appendChild(removeButton); removeButtonCol.appendChild(removeButton);
newRow.appendChild(removeButtonCol); newRow.appendChild(removeButtonCol);
// Add the new row to the container
container.appendChild(newRow); container.appendChild(newRow);
end; end;
end; end;
...@@ -513,9 +518,34 @@ begin ...@@ -513,9 +518,34 @@ begin
end; end;
procedure TFOrderEntry.getCustomer(customerID: string);
var
xdcResponse: TXDataClientResponse;
customer : TJSObject;
address: string;
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomer',
[customerID]));
customer := TJSObject(xdcResponse.Result);
XDataWebDataSet1.Close;
XDataWebDataSet1.SetJsonData(customer);
XDataWebDataSet1.Open;
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(customer['ADDRESS_LIST']);
xdwdsShipTo.Open;
console.log(xdwdsShipToADDRESS.AsString);
console.log(customer['ADDRESS_LIST']);
end;
procedure TFOrderEntry.WebFormShow(Sender: TObject); procedure TFOrderEntry.WebFormShow(Sender: TObject);
begin begin
getOrder(orderID); if mode <> 'ADD' then
getOrder(orderID)
else
getCustomer(customerID);
console.log(customerID);
HideNotification(); HideNotification();
end; end;
......
...@@ -31,21 +31,6 @@ object FOrderList: TFOrderList ...@@ -31,21 +31,6 @@ object FOrderList: TFOrderList
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end 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 object pnlMessage: TWebPanel
Left = 370 Left = 370
Top = 558 Top = 558
...@@ -58,7 +43,7 @@ object FOrderList: TFOrderList ...@@ -58,7 +43,7 @@ object FOrderList: TFOrderList
ElementFont = efCSS ElementFont = efCSS
ElementPosition = epRelative ElementPosition = epRelative
Role = 'alert' Role = 'alert'
TabOrder = 1 TabOrder = 0
object lblMessage: TWebLabel object lblMessage: TWebLabel
Left = 28 Left = 28
Top = 9 Top = 9
...@@ -89,40 +74,6 @@ object FOrderList: TFOrderList ...@@ -89,40 +74,6 @@ object FOrderList: TFOrderList
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
end end
object tblOrders: TWebDBTableControl
Left = 0
Top = 142
Width = 1016
Height = 289
ElementClassName = 'table'
ElementId = 'tbl_orders'
BorderColor = clSilver
ChildOrder = 5
ColHeader = False
ElementTableClassName = 'table table-striped table-hover table-bordered'
Options.ResizeColumns = True
OnClickCell = tblOrdersClickCell
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 object cbCorrugatedPlate: TWebCheckBox
Left = 190 Left = 190
Top = 26 Top = 26
...@@ -180,7 +131,211 @@ object FOrderList: TFOrderList ...@@ -180,7 +131,211 @@ object FOrderList: TFOrderList
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
Text = 'edtID' Text = 'edtID'
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = edtIDChange OnClick = btnConfirmClick
end
object btnFilter: TWebButton
Left = 564
Top = 195
Width = 96
Height = 25
Caption = 'Filter'
ChildOrder = 9
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnFilterClick
end
object TMSFNCGrid1: TTMSFNCGrid
Left = 228
Top = 308
Width = 588
Height = 353
AdaptToStyle = True
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 7
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 0
RowCount = 1
Options.Bands.Enabled = True
Options.Editing.CalcFormat = '%g'
Options.Filtering.MultiColumn = True
Options.Grouping.CalcFormat = '%g'
Options.Grouping.GroupCountFormat = '(%d)'
Options.IO.XMLEncoding = 'ISO-8859-1'
Options.Mouse.ColumnSizing = True
Options.Mouse.ClickMargin = 0
Options.Mouse.ColumnSizeMargin = 6
Options.Mouse.RowSizing = True
Options.Mouse.RowSizeMargin = 6
Options.Mouse.FixedColumnSizing = True
Options.Mouse.FixedRowSizing = True
Columns = <
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = clWindowText
FixedFont.Height = -11
FixedFont.Name = 'Tahoma'
FixedFont.Style = []
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ID = ''
Width = 68.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = clWindowText
FixedFont.Height = -11
FixedFont.Name = 'Tahoma'
FixedFont.Style = []
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ID = ''
Width = 68.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = clWindowText
FixedFont.Height = -11
FixedFont.Name = 'Tahoma'
FixedFont.Style = []
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ID = ''
Width = 68.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = clWindowText
FixedFont.Height = -11
FixedFont.Name = 'Tahoma'
FixedFont.Style = []
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ID = ''
Width = 68.000000000000000000
end
item
BorderWidth = 1
FixedFont.Charset = DEFAULT_CHARSET
FixedFont.Color = clWindowText
FixedFont.Height = -11
FixedFont.Name = 'Tahoma'
FixedFont.Style = []
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ID = ''
Width = 68.000000000000000000
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clBlack
DefaultFont.Height = -11
DefaultFont.Name = 'Segoe UI'
DefaultFont.Style = []
Stroke.Color = 15987699
TopRow = 1
Appearance.FixedLayout.Fill.Kind = gfkGradient
Appearance.FixedLayout.Fill.Color = 16382457
Appearance.FixedLayout.Fill.ColorTo = 16382457
Appearance.FixedLayout.Stroke.Color = 15987699
Appearance.FixedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedLayout.Font.Color = clBlack
Appearance.FixedLayout.Font.Height = -11
Appearance.FixedLayout.Font.Name = 'Tahoma'
Appearance.FixedLayout.Font.Style = [fsBold]
Appearance.NormalLayout.Fill.Color = -1
Appearance.NormalLayout.Stroke.Color = 15987699
Appearance.NormalLayout.Font.Charset = DEFAULT_CHARSET
Appearance.NormalLayout.Font.Color = clBlack
Appearance.NormalLayout.Font.Height = -11
Appearance.NormalLayout.Font.Name = 'Tahoma'
Appearance.NormalLayout.Font.Style = []
Appearance.GroupLayout.Fill.Kind = gfkGradient
Appearance.GroupLayout.Fill.Color = 15385233
Appearance.GroupLayout.Fill.ColorTo = 15385233
Appearance.GroupLayout.Stroke.Color = 15987699
Appearance.GroupLayout.Font.Charset = DEFAULT_CHARSET
Appearance.GroupLayout.Font.Color = clBlack
Appearance.GroupLayout.Font.Height = -11
Appearance.GroupLayout.Font.Name = 'Tahoma'
Appearance.GroupLayout.Font.Style = []
Appearance.SummaryLayout.Fill.Kind = gfkGradient
Appearance.SummaryLayout.Fill.Color = 15385233
Appearance.SummaryLayout.Fill.ColorTo = 15385233
Appearance.SummaryLayout.Stroke.Color = 15987699
Appearance.SummaryLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SummaryLayout.Font.Color = clBlack
Appearance.SummaryLayout.Font.Height = -11
Appearance.SummaryLayout.Font.Name = 'Tahoma'
Appearance.SummaryLayout.Font.Style = []
Appearance.SelectedLayout.Fill.Kind = gfkGradient
Appearance.SelectedLayout.Fill.Color = 15385233
Appearance.SelectedLayout.Fill.ColorTo = 15385233
Appearance.SelectedLayout.Stroke.Color = 15987699
Appearance.SelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.SelectedLayout.Font.Color = clBlack
Appearance.SelectedLayout.Font.Height = -11
Appearance.SelectedLayout.Font.Name = 'Tahoma'
Appearance.SelectedLayout.Font.Style = []
Appearance.FocusedLayout.Fill.Kind = gfkGradient
Appearance.FocusedLayout.Fill.Color = 15385233
Appearance.FocusedLayout.Fill.ColorTo = 15385233
Appearance.FocusedLayout.Stroke.Color = 15987699
Appearance.FocusedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FocusedLayout.Font.Color = clBlack
Appearance.FocusedLayout.Font.Height = -11
Appearance.FocusedLayout.Font.Name = 'Tahoma'
Appearance.FocusedLayout.Font.Style = []
Appearance.FixedSelectedLayout.Fill.Kind = gfkGradient
Appearance.FixedSelectedLayout.Fill.Color = 15385233
Appearance.FixedSelectedLayout.Fill.ColorTo = 15385233
Appearance.FixedSelectedLayout.Stroke.Color = 15987699
Appearance.FixedSelectedLayout.Font.Charset = DEFAULT_CHARSET
Appearance.FixedSelectedLayout.Font.Color = clBlack
Appearance.FixedSelectedLayout.Font.Height = -11
Appearance.FixedSelectedLayout.Font.Name = 'Tahoma'
Appearance.FixedSelectedLayout.Font.Style = []
Appearance.BandLayout.Fill.Color = clLightyellow
Appearance.BandLayout.Stroke.Color = 15987699
Appearance.BandLayout.Font.Charset = DEFAULT_CHARSET
Appearance.BandLayout.Font.Color = clWindowText
Appearance.BandLayout.Font.Height = -11
Appearance.BandLayout.Font.Name = 'Tahoma'
Appearance.BandLayout.Font.Style = []
Appearance.ProgressLayout.Color = 15385233
Appearance.ProgressLayout.Format = '%.0f%%'
LeftCol = 0
ScrollMode = scmItemScrolling
DesignTimeSampleData = True
end
object edtSearch: TWebEdit
Left = 437
Top = 198
Width = 121
Height = 22
ChildOrder = 8
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtSearchChange
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
......
...@@ -3,42 +3,48 @@ unit View.OrderList; ...@@ -3,42 +3,48 @@ unit View.OrderList;
interface interface
uses uses
System.SysUtils, System.Generics.Collections, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls, System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls, WEBLib.Forms, WEBLib.Dialogs, WEBLib.StdCtrls, XData.Web.Client, WEBLib.ExtCtrls,
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage, Data.DB, XData.Web.Dataset, VCL.TMSFNCTypes, VCL.TMSFNCGrid, VCL.TMSFNCGridData,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls, VCL.TMSFNCUtils, VCL.TMSFNCGraphics, VCL.TMSFNCGraphicsTypes,
Data.DB, XData.Web.JsonDataset, XData.Web.Dataset, WEBLib.DB, WEBLib.Grids, VCL.TMSFNCGridCell, VCL.TMSFNCGridOptions, VCL.TMSFNCCustomComponent,
Vcl.Grids; VCL.TMSFNCCustomGrid, VCL.TMSFNCGridDatabaseAdapter, VCL.TMSFNCCustomControl,
VCL.TMSFNCCustomScrollControl, WEBLib.DB, XData.Web.JsonDataset, Vcl.StdCtrls,
Vcl.Controls, ConnectionModule;
type type
TFOrderList = class(TWebForm) TFOrderList = class(TWebForm)
lblEntries: TWebLabel; lblEntries: TWebLabel;
lblEntries2: TWebLabel; lblEntries2: TWebLabel;
edtSearch: TWebEdit; edtSearch: TWebEdit;
edtCompanyName: TWebEdit;
edtID: TWebEdit;
pnlMessage: TWebPanel; pnlMessage: TWebPanel;
lblMessage: TWebLabel; lblMessage: TWebLabel;
btnCloseNotification: TWebButton; btnCloseNotification: TWebButton;
btnFilter: TWebButton;
XDataWebClient1: TXDataWebClient; XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet;
wdsCustomers: TWebDataSource; wdsCustomers: TWebDataSource;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField; xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField; xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField; xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersADDRESS: TStringField; xdwdsCustomersADDRESS: TStringField;
tblOrders: TWebDBTableControl; TMSFNCGrid1: TTMSFNCGrid;
btnConfirm: TWebButton;
cbCorrugatedPlate: TWebCheckBox; cbCorrugatedPlate: TWebCheckBox;
cbWebPlate: TWebCheckBox; cbWebPlate: TWebCheckBox;
btnConfirm: TWebButton; procedure WebFormShow(Sender: TObject);
edtCompanyName: TWebEdit; procedure btnFilterClick(Sender: TObject);
edtID: TWebEdit; procedure cbCorrugatedPlateClick(Sender: TObject);
procedure edtIDChange(Sender: TObject); procedure cbWebPlateClick(Sender: TObject);
procedure edtCompanyNameChange(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
procedure tblOrdersClickCell(Sender: TObject; ACol, ARow: Integer); procedure edtSearchChange(Sender: TObject);
private private
[async] procedure GetCustomers; [async] procedure getCustomers();
procedure FilterDataset; procedure PopulateGridManually;
procedure ApplyFilter;
public public
class function CreateForm(AElementID: string): TWebForm;
end; end;
var var
...@@ -48,142 +54,128 @@ implementation ...@@ -48,142 +54,128 @@ implementation
{$R *.dfm} {$R *.dfm}
{ TFOrderList } procedure TFOrderList.WebFormShow(Sender: TObject);
class function TFOrderList.CreateForm(AElementID: string): TWebForm;
begin
Application.CreateForm(TFOrderList, AElementID, Result,
procedure(AForm: TObject)
begin
with TFOrderList(AForm) do
begin
// Initialize or configure form properties as needed
console.log('TFOrderList created and bound to ElementID:', AElementID);
GetCustomers;
end;
end
);
end;
procedure TFOrderList.edtCompanyNameChange(Sender: TObject);
begin begin
// FilterDataset; getCustomers(); // Fetch and populate the grid with customer data
console.log('Filtering data logic WIP');
end; end;
procedure TFOrderList.edtIDChange(Sender: TObject); [async]
begin procedure TFOrderList.getCustomers();
// FilterDataset;
console.log('Filtering data logic WIP');
end;
procedure TFOrderList.GetCustomers;
var var
xdcResponse: TXDataClientResponse; xdcResponse: TXDataClientResponse;
ResponseObject: TJSObject; customerList: TJSObject;
DataArray: TJSArray;
begin begin
try // Fetch data from XData service
asm
startSpinner();
end;
// Fetch data from the server
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', [])); xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', []));
customerList := TJSObject(xdcResponse.Result);
// Log the raw JSON response to verify its structure // Load data into TXDataWebDataset
console.log('Raw JSON Response:' + TJSJSON.stringify(xdcResponse.Result));
// Extract the "data" array from the JSON response
ResponseObject := TJSObject(xdcResponse.Result);
DataArray := TJSArray(ResponseObject['data']);
// Load the extracted array into the dataset
xdwdsCustomers.Close; xdwdsCustomers.Close;
xdwdsCustomers.SetJsonData(DataArray); xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.Open; xdwdsCustomers.Open;
// Log record count and dataset status // Manually populate the grid
console.log('Dataset Record Count: ' + IntToStr(xdwdsCustomers.RecordCount)); PopulateGridManually;
if xdwdsCustomers.RecordCount = 0 then
console.log('Dataset is empty.')
else
console.log('Dataset loaded successfully with records.');
finally
asm
setTimeout(endSpinner, 2000);
end;
end;
end; end;
procedure TFOrderList.PopulateGridManually;
var
procedure TFOrderList.tblOrdersClickCell(Sender: TObject; ACol, ARow: Integer); RowIndex: Integer;
begin begin
asm TMSFNCGrid1.BeginUpdate;
startSpinner();
end;
try try
// Ensure the dataset is active and the row index is valid TMSFNCGrid1.Clear; // Clear any existing data
if xdwdsCustomers.Active and (ARow >= 0) and (ARow < xdwdsCustomers.RecordCount) then
// Set up column headers
TMSFNCGrid1.ColumnCount := 4;
TMSFNCGrid1.RowCount := 1;
TMSFNCGrid1.Cells[0, 0] := 'ID';
TMSFNCGrid1.Cells[1, 0] := 'Name';
TMSFNCGrid1.Cells[2, 0] := 'Short Name';
TMSFNCGrid1.Cells[3, 0] := 'Address';
// Populate the grid with data from the dataset
xdwdsCustomers.First;
RowIndex := 1;
while not xdwdsCustomers.EOF do
begin begin
xdwdsCustomers.RecNo := ARow + 1; // Set the dataset to the selected row TMSFNCGrid1.RowCount := RowIndex + 1;
// Populate the edit boxes with the dataset field values TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString;
edtCompanyName.Text := xdwdsCustomers.FieldByName('NAME').AsString; TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('NAME').AsString;
edtID.Text := xdwdsCustomers.FieldByName('ID').AsString; TMSFNCGrid1.Cells[2, RowIndex] := xdwdsCustomers.FieldByName('SHORT_NAME').AsString;
TMSFNCGrid1.Cells[3, RowIndex] := xdwdsCustomers.FieldByName('ADDRESS').AsString;
console.log('Row clicked: ARow=' + IntToStr(ARow) + ', Company=' + edtCompanyName.Text + ', ID=' + edtID.Text); Inc(RowIndex);
xdwdsCustomers.Next;
end; end;
// Auto-size columns
TMSFNCGrid1.AutoSizeColumns;
finally finally
asm TMSFNCGrid1.EndUpdate;
setTimeout(endSpinner, 2000);
end;
end; end;
end; end;
procedure TFOrderList.ApplyFilter;
procedure TFOrderList.FilterDataset;
var var
FilterTextCompany, FilterTextID: string; fd: TTMSFNCGridFilterData;
FilterCondition: string; i: Integer;
SearchText: string;
begin begin
try SearchText := Trim(edtSearch.Text);
// Get the current filter inputs
FilterTextCompany := Trim(edtCompanyName.Text); // Remove any existing filters
FilterTextID := Trim(edtID.Text); TMSFNCGrid1.RemoveFilter;
// Build the filter condition TMSFNCGrid1.Filter.Clear;
FilterCondition := '';
if FilterTextCompany <> '' then
FilterCondition := Format('NAME LIKE ''%%%s%%''', [FilterTextCompany]);
if FilterTextID <> '' then // Add a filter for each column
for i := 0 to TMSFNCGrid1.ColumnCount - 1 do
begin begin
if FilterCondition <> '' then fd := TMSFNCGrid1.Filter.Add;
FilterCondition := FilterCondition + ' AND '; fd.Column := i;
FilterCondition := FilterCondition + Format('ID LIKE ''%%%s%%''', [FilterTextID]); 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; end;
// Apply the filter condition // Apply the filters to the grid
xdwdsCustomers.Filtered := False; // Disable existing filter TMSFNCGrid1.ApplyFilter;
xdwdsCustomers.Filter := FilterCondition; // Set new filter end;
xdwdsCustomers.Filtered := True; // Enable filtering
console.log('Filter applied:', FilterCondition);
except procedure TFOrderList.btnFilterClick(Sender: TObject);
on E: Exception do begin
begin ApplyFilter;
// Handle any errors gracefully end;
console.error('Error applying filter:', E.Message);
ShowMessage('An error occurred while applying the filter. Please check your input.'); procedure TFOrderList.edtIDChange(Sender: TObject);
end; begin
end; cbWebPlate.Checked := False;
end; end;
procedure TFOrderList.cbWebPlateClick(Sender: TObject);
begin
cbCorrugatedPlate.Checked := False;
end;
procedure TFOrderList.btnConfirmClick(Sender: TObject);
begin
Close;
end;
procedure TFOrderList.edtSearchChange(Sender: TObject);
begin
ApplyFilter;
end;
end. end.
...@@ -79,7 +79,7 @@ type ...@@ -79,7 +79,7 @@ type
procedure ClearTable(); procedure ClearTable();
procedure GeneratePagination(TotalPages: Integer); procedure GeneratePagination(TotalPages: Integer);
function GenerateSearchOptions(): string; function GenerateSearchOptions(): string;
procedure orderEntry(orderInfo, mode: string); procedure orderEntry(orderInfo, customerInfo, mode: string);
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
procedure ShowOrderListForm(); procedure ShowOrderListForm();
...@@ -183,9 +183,16 @@ begin ...@@ -183,9 +183,16 @@ begin
// Create the order list form, passing the ElementID // Create the order list form, passing the ElementID
TFOrderList.CreateForm(pnlOrders.ElementID); TFOrderList.CreateForm(pnlOrders.ElementID);
// Show the panel after the form is created // used to manage Back button handling to close subform
if Assigned(OrdersPanel) then window.location.hash := 'subform';
OrdersPanel.style.setProperty('display', 'block');
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newForm.edtID.Text <> '' then
orderEntry('', newForm.edtID.Text, 'ADD');
end
);
end; end;
...@@ -212,7 +219,7 @@ begin ...@@ -212,7 +219,7 @@ begin
NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value; NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value;
NewRow.addEventListener('click', procedure NewRow.addEventListener('click', procedure
begin begin
orderEntry(NewRow.Attrs['id'], 'EDIT'); orderEntry(NewRow.Attrs['id'], '', 'EDIT');
end); end);
// Order ID Cell // Order ID Cell
...@@ -648,9 +655,9 @@ begin ...@@ -648,9 +655,9 @@ begin
ShowOrderListForm(); ShowOrderListForm();
end; end;
procedure TFViewOrders.orderEntry(orderInfo, mode: string); procedure TFViewOrders.orderEntry(orderInfo, customerInfo, mode: string);
begin begin
FViewMain.ViewOrderEntry(orderInfo, mode); FViewMain.ViewOrderEntry(orderInfo, customerInfo, mode);
end; end;
procedure TFViewOrders.btnApplyClick(Sender: TObject); procedure TFViewOrders.btnApplyClick(Sender: TObject);
...@@ -677,7 +684,7 @@ end; ...@@ -677,7 +684,7 @@ end;
procedure TFViewOrders.btnConfirmClick(Sender: TObject); procedure TFViewOrders.btnConfirmClick(Sender: TObject);
begin begin
orderEntry('', 'ADD'); //orderEntry('', 'ADD');
end; end;
procedure TFViewOrders.btnFiltersClick(Sender: TObject); procedure TFViewOrders.btnFiltersClick(Sender: TObject);
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
background-color: #fff; background-color: #fff;
} }
input[type="text"] {
min-width: 50px;
max-width: 100%;
width: auto;
padding-left: 5px;
}
.card-header { .card-header {
width: 100%; width: 100%;
......
...@@ -22,7 +22,6 @@ object AuthDatabase: TAuthDatabase ...@@ -22,7 +22,6 @@ object AuthDatabase: TAuthDatabase
SpecificOptions.Strings = ( SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy') 'PostgreSQL.Schema=envoy')
Username = 'root' Username = 'root'
Server = '192.168.75.133'
LoginPrompt = False LoginPrompt = False
Left = 69 Left = 69
Top = 131 Top = 131
......
...@@ -8,7 +8,6 @@ object FDatabaseModule: TFDatabaseModule ...@@ -8,7 +8,6 @@ object FDatabaseModule: TFDatabaseModule
SpecificOptions.Strings = ( SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy') 'PostgreSQL.Schema=envoy')
Username = 'root' Username = 'root'
Server = '192.168.75.133'
LoginPrompt = False LoginPrompt = False
Left = 75 Left = 75
Top = 139 Top = 139
......
...@@ -84,12 +84,18 @@ type ...@@ -84,12 +84,18 @@ type
data: TList<TOrderItem>; data: TList<TOrderItem>;
end; end;
TAddressItem = class
Public
ADDRESS: string;
end;
TCustomerItem = class TCustomerItem = class
Public Public
NAME: string; NAME: string;
ID: integer; ID: integer;
SHORT_NAME: string; SHORT_NAME: string;
ADDRESS: string; staff_fields_invoice_to: string;
ADDRESS_LIST: TList<TAddressItem>;
end; end;
TCustomerList = class TCustomerList = class
...@@ -202,6 +208,7 @@ type ...@@ -202,6 +208,7 @@ type
[HttpGet] function GetOrders(searchOptions: string): TOrderList; [HttpGet] function GetOrders(searchOptions: string): TOrderList;
[HttpGet] function GetOrder(orderInfo: string): TFullOrder; [HttpGet] function GetOrder(orderInfo: string): TFullOrder;
[HttpGet] function GetCustomers(): TCustomerList; [HttpGet] function GetCustomers(): TCustomerList;
[HttpGet] function GetCustomer(ID: string): TCustomerItem;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string; function AddItem(itemInfo: string): string;
......
...@@ -26,6 +26,7 @@ type ...@@ -26,6 +26,7 @@ type
function GetOrders(searchOptions: string): TOrderList; function GetOrders(searchOptions: string): TOrderList;
function GetOrder(orderInfo: string): TFullOrder; function GetOrder(orderInfo: string): TFullOrder;
function GetCustomers(): TCustomerList; function GetCustomers(): TCustomerList;
function GetCustomer(ID: string): TCustomerItem;
function EditUser(const editOptions: string): string; function EditUser(const editOptions: string): string;
function Search(phoneNum: string): TOrderList; function Search(phoneNum: string): TOrderList;
function AddUser(userInfo: string): string; function AddUser(userInfo: string): string;
...@@ -80,7 +81,7 @@ begin ...@@ -80,7 +81,7 @@ begin
customer.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString; customer.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
customer.ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger; customer.ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
customer.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString; customer.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString;
customer.ADDRESs := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString + customer.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS').AsString +
', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString + ', ' + ordersDB.UniQuery1.FieldByName('BILL_CITY').AsString +
' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString; ' ' + ordersDB.UniQuery1.FieldByName('BILL_ZIP').AsString;
result.data.Add(customer); result.data.Add(customer);
...@@ -90,6 +91,35 @@ begin ...@@ -90,6 +91,35 @@ begin
ordersDB.UniQuery1.Close; ordersDB.UniQuery1.Close;
end; end;
function TLookupService.GetCustomer(ID: string): TCustomerItem;
var
SQL: string;
ADDRESS: TAddressItem;
begin
SQL := 'SELECT c.NAME, c.SHORT_NAME, c.BILL_ADDRESS_BLOCK, s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = ' + ID;
doQuery(ordersDB.UniQuery1, SQL);
result := TCustomerItem.Create;
result.ADDRESS_LIST := TList<TAddressItem>.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( Result.ADDRESS_LIST );
result.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
result.ID := StrToInt(ID);
result.SHORT_NAME := ordersDB.UniQuery1.FieldByName('SHORT_NAME').AsString;
result.staff_fields_invoice_to := ordersDB.UniQuery1.FieldByName('BILL_ADDRESS_BLOCK').AsString;
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TAddressItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( ADDRESS );
ADDRESS.ADDRESS := ordersDB.UniQuery1.FieldByName('ship_block').AsString;
result.ADDRESS_LIST.Add(ADDRESS);
ordersDB.UniQuery1.Next;
end;
ordersDB.UniQuery1.Close;
end;
function TLookupService.Search(phoneNum: string): TOrderList; function TLookupService.Search(phoneNum: string): TOrderList;
// Searchs the database for a specific from phone number then returns a list of // Searchs the database for a specific from phone number then returns a list of
// calls from said number // calls from said number
......
[Options] [Options]
LogFileNum=226 LogFileNum=234
UpdateTimerLength=0 UpdateTimerLength=0
[Database] [Database]
--Server=192.168.159.132 --Server=192.168.159.132
--Server=192.168.102.129 --Server=192.168.102.129
Server=192.168.75.133 Server=192.168.102.130
[Twilio] [Twilio]
AccountSID=AC37aeef9c36a2cccbaecbadafc172b2ff AccountSID=AC37aeef9c36a2cccbaecbadafc172b2ff
......
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