Commit 7f19b291 by Elias Sarraf

Merge remote-tracking branch 'origin/cam'

parents e3cf4538 bfd278e3
......@@ -51,7 +51,7 @@ type
procedure ShowForm( AFormClass: TWebFormClass );
procedure EditUser( Mode, Username, Password, Name, Status, Email,
Access, Rights, Perspective, QB: string);
procedure ViewOrderEntry(orderInfo, mode: string);
procedure ViewOrderEntry(orderInfo, customerInfo, mode: string);
procedure ViewOrders(info: string);
procedure ShowUserForm(Info: string);
end;
......@@ -227,12 +227,12 @@ begin
end;
procedure TFViewMain.ViewOrderEntry(orderInfo, mode: string);
procedure TFViewMain.ViewOrderEntry(orderInfo, customerInfo, mode: string);
begin
lblAppTitle.Caption := 'Koehler-Gibson Order Entry';
if Assigned(FChildForm) then
FChildForm.Free;
FChildForm := TFOrderEntry.CreateForm(WebPanel1.ElementID, orderInfo, mode);
FChildForm := TFOrderEntry.CreateForm(WebPanel1.ElementID, orderInfo, customerInfo, mode);
end;
procedure TFViewMain.ShowUserForm(Info: string);
......
......@@ -239,13 +239,14 @@ object FOrderEntry: TFOrderEntry
object edtCompanyName: TWebDBEdit
Left = 24
Top = 92
Width = 121
Width = 260
Height = 22
AutoSize = True
ChildOrder = 79
ElementID = 'edtcompanyname'
HeightPercent = 100.000000000000000000
MaxLength = 90
WidthStyle = ssAuto
WidthPercent = 100.000000000000000000
DataField = 'NAME'
DataSource = WebDataSource1
......@@ -327,19 +328,6 @@ object FOrderEntry: TFOrderEntry
DataField = 'staff_fields_invoice_to'
DataSource = WebDataSource1
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
Left = 26
Top = 458
......@@ -965,6 +953,20 @@ object FOrderEntry: TFOrderEntry
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
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
Connection = DMConnection.ApiConnection
Left = 244
......@@ -1247,10 +1249,25 @@ object FOrderEntry: TFOrderEntry
object XDataWebDataSet1staff_fields_mount_due: TStringField
FieldName = 'staff_fields_mount_due'
end
object XDataWebDataSet1ADDRESS_LIST: TStringField
FieldName = 'ADDRESS_LIST'
end
end
object WebDataSource1: TWebDataSource
DataSet = XDataWebDataSet1
Left = 216
Top = 104
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
......@@ -38,7 +38,6 @@ type
edtQuantity: TWebDBEdit;
edtPrice: TWebDBEdit;
edtInvoiceTo: TWebDBEdit;
edtShipTo: TWebDBEdit;
edtPONumber: TWebDBEdit;
edtJobName: TWebDBEdit;
edtQuickBooksItem: TWebDBEdit;
......@@ -182,11 +181,17 @@ type
cbStickyBak: TWebCheckBox;
cbLoose: TWebCheckBox;
cbExcaliburDie: TWebCheckBox;
XDataWebDataSet1ADDRESS_LIST: TStringField;
wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet;
xdwdsShipToADDRESS: TStringField;
WebDBComboBox1: TWebDBComboBox;
procedure WebFormCreate(Sender: TObject);
procedure HideNotification();
procedure ShowNotification(Notification: string);
procedure WebFormShow(Sender: TObject);
[async] procedure getOrder(Order_ID: string);
[async] procedure getCustomer(customerID: string);
procedure tmrScrollTopTimer(Sender: TObject);
procedure WebButton1Click(Sender: TObject);
procedure addColorRow(num, Color, LPI, Size: string);
......@@ -197,10 +202,11 @@ type
FCurrentReportType: string;
FSelectProc: TSelectProc;
orderID: string;
customerID: string;
mode: string;
//FJSONProc1: TJSONProc1;
public
class function CreateForm(AElementID, orderInfo, mode: string): TWebForm;
class function CreateForm(AElementID, orderInfo, customerInfo, mode: string): TWebForm;
end;
var
......@@ -333,7 +339,7 @@ begin
[orderJSON.ToString]));
end;
class function TFOrderEntry.CreateForm(AElementID, orderInfo, mode: string): TWebForm;
class function TFOrderEntry.CreateForm(AElementID, orderInfo, customerInfo, mode: string): TWebForm;
var
localMode: string;
begin
......@@ -344,6 +350,7 @@ begin
with TFOrderEntry(AForm) do
begin
HideNotification;
TFOrderEntry(AForm).customerID := customerInfo;
TFOrderEntry(AForm).orderID := orderInfo;
TFOrderEntry(AForm).mode := localMode;
console.log(TFOrderEntry(AForm).mode);
......@@ -362,7 +369,6 @@ begin
const newRow = document.createElement('div');
newRow.className = 'row mb-2';
// Labels and inputs
const labels = ['#', 'Color', 'LPI', 'Size'];
const values = [num, Color, LPI, Size];
labels.forEach((label, index) => {
......@@ -400,7 +406,6 @@ begin
removeButtonCol.appendChild(removeButton);
newRow.appendChild(removeButtonCol);
// Add the new row to the container
container.appendChild(newRow);
end;
end;
......@@ -513,9 +518,34 @@ begin
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);
begin
getOrder(orderID);
if mode <> 'ADD' then
getOrder(orderID)
else
getCustomer(customerID);
console.log(customerID);
HideNotification();
end;
......
......@@ -31,21 +31,6 @@ object FOrderList: TFOrderList
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 = 370
Top = 558
......@@ -58,7 +43,7 @@ object FOrderList: TFOrderList
ElementFont = efCSS
ElementPosition = epRelative
Role = 'alert'
TabOrder = 1
TabOrder = 0
object lblMessage: TWebLabel
Left = 28
Top = 9
......@@ -89,40 +74,6 @@ object FOrderList: TFOrderList
WidthPercent = 100.000000000000000000
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
Left = 190
Top = 26
......@@ -180,7 +131,211 @@ object FOrderList: TFOrderList
HeightPercent = 100.000000000000000000
Text = 'edtID'
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
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
......
......@@ -3,42 +3,48 @@ 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;
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
TFOrderList = class(TWebForm)
lblEntries: TWebLabel;
lblEntries2: TWebLabel;
edtSearch: TWebEdit;
edtCompanyName: TWebEdit;
edtID: TWebEdit;
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
btnCloseNotification: TWebButton;
btnFilter: TWebButton;
XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet;
wdsCustomers: TWebDataSource;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersADDRESS: TStringField;
tblOrders: TWebDBTableControl;
TMSFNCGrid1: TTMSFNCGrid;
btnConfirm: TWebButton;
cbCorrugatedPlate: TWebCheckBox;
cbWebPlate: TWebCheckBox;
btnConfirm: TWebButton;
edtCompanyName: TWebEdit;
edtID: TWebEdit;
procedure edtIDChange(Sender: TObject);
procedure edtCompanyNameChange(Sender: TObject);
procedure tblOrdersClickCell(Sender: TObject; ACol, ARow: Integer);
procedure WebFormShow(Sender: TObject);
procedure btnFilterClick(Sender: TObject);
procedure cbCorrugatedPlateClick(Sender: TObject);
procedure cbWebPlateClick(Sender: TObject);
procedure btnConfirmClick(Sender: TObject);
procedure edtSearchChange(Sender: TObject);
private
[async] procedure GetCustomers;
procedure FilterDataset;
[async] procedure getCustomers();
procedure PopulateGridManually;
procedure ApplyFilter;
public
class function CreateForm(AElementID: string): TWebForm;
end;
var
......@@ -48,142 +54,128 @@ implementation
{$R *.dfm}
{ TFOrderList }
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);
procedure TFOrderList.WebFormShow(Sender: TObject);
begin
// FilterDataset;
console.log('Filtering data logic WIP');
getCustomers(); // Fetch and populate the grid with customer data
end;
procedure TFOrderList.edtIDChange(Sender: TObject);
begin
// FilterDataset;
console.log('Filtering data logic WIP');
end;
procedure TFOrderList.GetCustomers;
[async]
procedure TFOrderList.getCustomers();
var
xdcResponse: TXDataClientResponse;
ResponseObject: TJSObject;
DataArray: TJSArray;
customerList: TJSObject;
begin
try
asm
startSpinner();
end;
// Fetch data from the server
// Fetch data from XData service
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', []));
customerList := TJSObject(xdcResponse.Result);
// Log the raw JSON response to verify its structure
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
// Load data into TXDataWebDataset
xdwdsCustomers.Close;
xdwdsCustomers.SetJsonData(DataArray);
xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.Open;
// Log record count and dataset status
console.log('Dataset Record Count: ' + IntToStr(xdwdsCustomers.RecordCount));
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;
// Manually populate the grid
PopulateGridManually;
end;
procedure TFOrderList.tblOrdersClickCell(Sender: TObject; ACol, ARow: Integer);
procedure TFOrderList.PopulateGridManually;
var
RowIndex: Integer;
begin
asm
startSpinner();
end;
TMSFNCGrid1.BeginUpdate;
try
// Ensure the dataset is active and the row index is valid
if xdwdsCustomers.Active and (ARow >= 0) and (ARow < xdwdsCustomers.RecordCount) then
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] := '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
xdwdsCustomers.RecNo := ARow + 1; // Set the dataset to the selected row
TMSFNCGrid1.RowCount := RowIndex + 1;
// Populate the edit boxes with the dataset field values
edtCompanyName.Text := xdwdsCustomers.FieldByName('NAME').AsString;
edtID.Text := xdwdsCustomers.FieldByName('ID').AsString;
TMSFNCGrid1.Cells[0, RowIndex] := xdwdsCustomers.FieldByName('ID').AsString;
TMSFNCGrid1.Cells[1, RowIndex] := xdwdsCustomers.FieldByName('NAME').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;
// Auto-size columns
TMSFNCGrid1.AutoSizeColumns;
finally
asm
setTimeout(endSpinner, 2000);
end;
TMSFNCGrid1.EndUpdate;
end;
end;
procedure TFOrderList.FilterDataset;
procedure TFOrderList.ApplyFilter;
var
FilterTextCompany, FilterTextID: string;
FilterCondition: string;
fd: TTMSFNCGridFilterData;
i: Integer;
SearchText: string;
begin
try
// Get the current filter inputs
FilterTextCompany := Trim(edtCompanyName.Text);
FilterTextID := Trim(edtID.Text);
SearchText := Trim(edtSearch.Text);
// Remove any existing filters
TMSFNCGrid1.RemoveFilter;
// Build the filter condition
FilterCondition := '';
if FilterTextCompany <> '' then
FilterCondition := Format('NAME LIKE ''%%%s%%''', [FilterTextCompany]);
TMSFNCGrid1.Filter.Clear;
if FilterTextID <> '' then
// Add a filter for each column
for i := 0 to TMSFNCGrid1.ColumnCount - 1 do
begin
if FilterCondition <> '' then
FilterCondition := FilterCondition + ' AND ';
FilterCondition := FilterCondition + Format('ID LIKE ''%%%s%%''', [FilterTextID]);
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 filter condition
xdwdsCustomers.Filtered := False; // Disable existing filter
xdwdsCustomers.Filter := FilterCondition; // Set new filter
xdwdsCustomers.Filtered := True; // Enable filtering
// Apply the filters to the grid
TMSFNCGrid1.ApplyFilter;
end;
console.log('Filter applied:', FilterCondition);
except
on E: Exception do
begin
// Handle any errors gracefully
console.error('Error applying filter:', E.Message);
ShowMessage('An error occurred while applying the filter. Please check your input.');
end;
end;
procedure TFOrderList.btnFilterClick(Sender: TObject);
begin
ApplyFilter;
end;
procedure TFOrderList.edtIDChange(Sender: TObject);
begin
cbWebPlate.Checked := False;
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.
......@@ -79,7 +79,7 @@ type
procedure ClearTable();
procedure GeneratePagination(TotalPages: Integer);
function GenerateSearchOptions(): string;
procedure orderEntry(orderInfo, mode: string);
procedure orderEntry(orderInfo, customerInfo, mode: string);
procedure HideNotification();
procedure ShowNotification(Notification: string);
procedure ShowOrderListForm();
......@@ -183,9 +183,16 @@ begin
// Create the order list form, passing the ElementID
TFOrderList.CreateForm(pnlOrders.ElementID);
// Show the panel after the form is created
if Assigned(OrdersPanel) then
OrdersPanel.style.setProperty('display', 'block');
// used to manage Back button handling to close subform
window.location.hash := 'subform';
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newForm.edtID.Text <> '' then
orderEntry('', newForm.edtID.Text, 'ADD');
end
);
end;
......@@ -212,7 +219,7 @@ begin
NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value;
NewRow.addEventListener('click', procedure
begin
orderEntry(NewRow.Attrs['id'], 'EDIT');
orderEntry(NewRow.Attrs['id'], '', 'EDIT');
end);
// Order ID Cell
......@@ -648,9 +655,9 @@ begin
ShowOrderListForm();
end;
procedure TFViewOrders.orderEntry(orderInfo, mode: string);
procedure TFViewOrders.orderEntry(orderInfo, customerInfo, mode: string);
begin
FViewMain.ViewOrderEntry(orderInfo, mode);
FViewMain.ViewOrderEntry(orderInfo, customerInfo, mode);
end;
procedure TFViewOrders.btnApplyClick(Sender: TObject);
......@@ -677,7 +684,7 @@ end;
procedure TFViewOrders.btnConfirmClick(Sender: TObject);
begin
orderEntry('', 'ADD');
//orderEntry('', 'ADD');
end;
procedure TFViewOrders.btnFiltersClick(Sender: TObject);
......
......@@ -7,7 +7,12 @@
background-color: #fff;
}
input[type="text"] {
min-width: 50px;
max-width: 100%;
width: auto;
padding-left: 5px;
}
.card-header {
width: 100%;
......
......@@ -22,7 +22,6 @@ object AuthDatabase: TAuthDatabase
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
Username = 'root'
Server = '192.168.75.133'
LoginPrompt = False
Left = 69
Top = 131
......
......@@ -8,7 +8,6 @@ object FDatabaseModule: TFDatabaseModule
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
Username = 'root'
Server = '192.168.75.133'
LoginPrompt = False
Left = 75
Top = 139
......
......@@ -84,12 +84,18 @@ type
data: TList<TOrderItem>;
end;
TAddressItem = class
Public
ADDRESS: string;
end;
TCustomerItem = class
Public
NAME: string;
ID: integer;
SHORT_NAME: string;
ADDRESS: string;
staff_fields_invoice_to: string;
ADDRESS_LIST: TList<TAddressItem>;
end;
TCustomerList = class
......@@ -202,6 +208,7 @@ type
[HttpGet] function GetOrders(searchOptions: string): TOrderList;
[HttpGet] function GetOrder(orderInfo: string): TFullOrder;
[HttpGet] function GetCustomers(): TCustomerList;
[HttpGet] function GetCustomer(ID: string): TCustomerItem;
function AddUser(userInfo: string): string;
function AddItem(itemInfo: string): string;
......
......@@ -26,6 +26,7 @@ type
function GetOrders(searchOptions: string): TOrderList;
function GetOrder(orderInfo: string): TFullOrder;
function GetCustomers(): TCustomerList;
function GetCustomer(ID: string): TCustomerItem;
function EditUser(const editOptions: string): string;
function Search(phoneNum: string): TOrderList;
function AddUser(userInfo: string): string;
......@@ -80,7 +81,7 @@ begin
customer.NAME := ordersDB.UniQuery1.FieldByName('NAME').AsString;
customer.ID := ordersDB.UniQuery1.FieldByName('CUSTOMER_ID').AsInteger;
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_ZIP').AsString;
result.data.Add(customer);
......@@ -90,6 +91,35 @@ begin
ordersDB.UniQuery1.Close;
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;
// Searchs the database for a specific from phone number then returns a list of
// calls from said number
......
[Options]
LogFileNum=226
LogFileNum=234
UpdateTimerLength=0
[Database]
--Server=192.168.159.132
--Server=192.168.102.129
Server=192.168.75.133
Server=192.168.102.130
[Twilio]
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