Commit afced290 by cam

Redisigned the search page

parent 9ddc1084
......@@ -43,6 +43,8 @@ type
{ Private declarations }
public
{ Public declarations }
var
confirm: boolean;
end;
var
......@@ -60,11 +62,13 @@ end;
procedure TFAddOrder.btnConfirmClick(Sender: TObject);
begin
confirm := true;
Close;
end;
procedure TFAddOrder.WebFormShow(Sender: TObject);
begin
confirm := false;
getCustomers();
end;
......
object FViewOrders: TFViewOrders
Width = 676
Height = 480
Caption = 'edtorderid'
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
......@@ -9,6 +10,7 @@ object FViewOrders: TFViewOrders
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
Visible = True
OnCreate = WebFormCreate
OnShow = WebFormShow
object lblEntries: TWebLabel
......@@ -23,6 +25,18 @@ object FViewOrders: TFViewOrders
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblSearch: TWebLabel
Left = 594
Top = 116
Width = 47
Height = 13
Caption = 'Search = '
ElementID = 'lblsearch'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnAddOrder: TWebButton
Left = 59
Top = 79
......
......@@ -34,9 +34,14 @@
</div>
</div>
<!-- Entries Label Section -->
<div class="d-flex justify-content-between w-100 mt-2">
<label id="lblentries"></label>
<!-- Entries Label Section d-flex justify-content-between w-100 mt-2-->
<div class="row">
<div class="col text-start">
<label id="lblentries"></label>
</div>
<div class="col text-end">
<label id="lblsearch"></label>
</div>
</div>
<!-- Table Section -->
......
......@@ -58,6 +58,7 @@ type
wdbtcOrders: TWebDBTableControl;
wcbPageSize: TWebComboBox;
wlcbOrderBy: TWebLookupComboBox;
lblSearch: TWebLabel;
procedure WebFormCreate(Sender: TObject);
procedure btnAddOrderClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
......@@ -86,6 +87,10 @@ type
PageNumber: integer;
PageSize: integer;
TotalPages: integer;
OrderID: string;
CompanyID: string;
JobName: string;
orderType: string;
//Status 1
StartDate1: string;
......@@ -100,10 +105,6 @@ type
null2: boolean;
OrderBy: string;
fieldType: string;
searchString: string;
orderType: string;
filters: boolean;
info: string;
public
......@@ -162,8 +163,6 @@ begin
filterType2 := '';
null2 := false;
fieldType := '';
searchString := '';
orderType := '';
//today := TDateTime.Today;
......@@ -237,7 +236,7 @@ begin
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.edtID.Text <> '' then
if newform.confirm then
orderEntry('', newForm.edtID.Text, 'ADD');
end
);
......@@ -252,6 +251,7 @@ begin
newform.Caption := 'Input Search Options';
newForm.Popup := True;
newForm.Border := fbDialog;
newForm.searchOptions := generateSearchOptions();
// used to manage Back button handling to close subform
window.location.hash := 'subform';
......@@ -277,11 +277,14 @@ begin
filterType2 := newform.wcbFilterType2.Text;
null2 := newform.cbNull2.Checked;
fieldType := newform.wcbFieldType.Text;
searchString := newform.edtSearch.Text;
jobName := newform.edtJobName.Text;
orderID := newform.edtOrderID.Text;
companyID := newform.edtCompanyID.Text;
orderType := newform.wcbOrderType.Text;
getOrders(GenerateSearchOptions());
searchOptions := generateSearchOptions();
lblSearch.Caption := searchOptions;
getOrders(searchOptions);
end;
end
);
......@@ -650,9 +653,11 @@ begin
'&filterType2=' + filterType2 +
'&null2=' + BoolToStr(null2) +
'&fieldType=' + fieldType +
'&search=' + searchString +
'&orderType=' + orderType;
'&orderType=' + orderType +
'&jobName=' + jobName +
'&companyID=' + companyID +
'&orderID=' + orderID;
Result := searchOptions;
end;
......
......@@ -8,7 +8,10 @@ uses
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;
Vcl.Grids, VCL.TMSFNCTypes, VCL.TMSFNCUtils, VCL.TMSFNCGraphics,
VCL.TMSFNCGraphicsTypes, VCL.TMSFNCGridCell, VCL.TMSFNCGridOptions,
VCL.TMSFNCCustomControl, VCL.TMSFNCCustomScrollControl, VCL.TMSFNCGridData,
VCL.TMSFNCCustomGrid, VCL.TMSFNCGrid;
type
TFSearch = class(TWebForm)
......@@ -17,13 +20,11 @@ type
btnCloseNotification: TWebButton;
wcbFilterType1: TWebComboBox;
btnConfirm: TWebButton;
edtSearch: TWebEdit;
edtOrderID: TWebEdit;
dtpStartDate1: TWebDateTimePicker;
dtpEndDate1: TWebDateTimePicker;
cbNull1: TWebCheckBox;
wcbFieldType: TWebComboBox;
wcbOrderType: TWebComboBox;
btnCancel: TWebButton;
lblStatus1: TWebLabel;
lblType1: TWebLabel;
lblStartDate1: TWebLabel;
......@@ -36,15 +37,42 @@ type
lblType2: TWebLabel;
lblStartDate2: TWebLabel;
lblEndDate2: TWebLabel;
WebLabel1: TWebLabel;
WebLabel2: TWebLabel;
TMSFNCGrid1: TTMSFNCGrid;
edtSearch: TWebEdit;
edtCompanyID: TWebEdit;
lblCompanyID: TWebLabel;
XDataWebClient1: TXDataWebClient;
xdwdsCustomers: TXDataWebDataSet;
xdwdsCustomersID: TIntegerField;
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersADDRESS: TStringField;
wdsCustomers: TWebDataSource;
WebLabel3: TWebLabel;
edtJobName: TWebEdit;
WebLabel4: TWebLabel;
btnCancel: TWebButton;
btnClear: TWebButton;
procedure btnConfirmClick(Sender: TObject);
procedure WebFormShow(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure edtSearchChange(Sender: TObject);
procedure TMSFNCGrid1CellClick(Sender: TObject; ACol, ARow: Integer);
procedure btnClearClick(Sender: TObject);
private
//FJSONProc: TJSONProc;
[async] procedure getCustomers;
procedure PopulateGridManually;
procedure ApplyFilter;
var
temp: string;
public
class function CreateForm(AElementID: string): TWebForm;
var
confirm: boolean;
searchOptions: string;
end;
var
......@@ -67,13 +95,74 @@ begin
);
end;
procedure TFSearch.edtSearchChange(Sender: TObject);
begin
ApplyFilter;
end;
procedure TFSearch.WebFormShow(Sender: TObject);
var
params: TStringList;
DateFormatSettings: TFormatSettings;
begin
dtpStartDate1.Date := 0;
dtpEndDate1.Date := 0;
dtpStartDate1.Date := 0;
dtpEndDate1.Date := 0;
params := TStringList.Create;
params.StrictDelimiter := true;
params.Delimiter := '&';
params.DelimitedText := searchOptions;
confirm := false;
DateFormatSettings := TFormatSettings.Create;
DateFormatSettings.ShortDateFormat := 'yyyy/mm/dd';
wcbOrderType.Text := UpperCase(Copy(params.Values['orderType'], 1, 1)) + LowerCase(Copy(params.Values['orderType'], 2, MaxInt));
edtOrderID.Text := params.Values['orderID'];
edtCompanyID.Text := params.Values['companyID'];
edtJobName.Text := params.Values['jobName'];
// Status 1
if params.Values['filterType1'] <> '' then
wcbFilterType1.Text := params.Values['filterType1']
else
wcbFilterType1.Text := 'NONE';
console.log(params.Values['startDate1']);
if params.Values['startDate1'] = '' then
dtpStartDate1.Date := 0
else
begin
dtpStartDate1.Date := StrToDateTime(params.Values['startDate1'], DateFormatSettings);
end;
if params.Values['endDate1'] = '' then
dtpEndDate1.Date := 0
else
dtpEndDate1.Date := StrToDateTime(params.Values['endDate1'], DateFormatSettings);
if params.values['null1'] <> '' then
cbNull1.Checked := StrToBool(params.Values['null1']);
// Status 2
if params.Values['filterType2'] <> '' then
wcbFilterType2.Text := params.Values['filterType2']
else
wcbFilterType2.Text := 'NONE';
if params.Values['startDate2'] = '1899/12/30' then
dtpStartDate2.Date := 0
else
dtpStartDate2.Date := StrToDateTime(params.Values['startDate2'], DateFormatSettings);
if params.Values['endDate2'] = '1899/12/30' then
dtpEndDate2.Date := 0
else
dtpEndDate2.Date := StrToDateTime(params.Values['endDate2'], DateFormatSettings);
if params.values['null2'] <> '' then
cbNull1.Checked := StrToBool(params.Values['null2']);
params.Free;
getCustomers();
end;
procedure TFSearch.btnCancelClick(Sender: TObject);
......@@ -81,11 +170,123 @@ begin
Close;
end;
procedure TFSearch.btnClearClick(Sender: TObject);
begin
edtOrderID.Text := '';
edtCompanyID.Text := '';
edtSearch.Text := '';
edtJobName.Text := '';
wcbOrderType.Text := 'Any';
wcbFilterType1.Text := 'NONE';
dtpStartDate1.Date := 0;
dtpEndDate1.Date := 0;
cbNull1.Checked := False;
wcbFilterType2.Text := 'NONE';
dtpStartDate2.Date := 0;
dtpEndDate2.Date := 0;
cbNull2.Checked := false;
end;
procedure TFSearch.btnConfirmClick(Sender: TObject);
begin
confirm := true;
Close;
end;
[async] procedure TFSearch.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 TFSearch.TMSFNCGrid1CellClick(Sender: TObject; ACol, ARow: Integer);
begin
edtCompanyID.Text := TMSFNCGrid1.Cells[0, ARow];
end;
procedure TFSearch.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 TFSearch.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.
......@@ -14,6 +14,16 @@ input[type="text"] {
padding-left: 5px;
}
.input-search input {
width: 100px; /* Adjust the width of the input */
height: 35px; /* Set the height to match label height */
padding: 5px; /* Padding for input text */
font-size: 14px; /* Font size for input text */
border: 1px solid #ced4da; /* Border style */
border-radius: 5px; /* Rounded corners for the input */
box-sizing: border-box; /* Ensures padding and border are included in the element's total width and height */
}
.card-header {
width: 100%;
text-align: left; /* Align text to the left */
......
......@@ -46,7 +46,6 @@ type
function EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string;
function generateOrdersSQL(searchOptions: string): TSQLQuery;
function getColorCount(colors: string): string;
function generateSearchSQL(FieldType, search: string): string;
function generateStatusSelectSQL(statusTableShort, statusTableLong, startDate, endDate, statusType: string): string;
function generateStatusWhereSQL(status: TStatusSearchInfo): string;
function createStatusSearchInfo(params: TStringList; statusNum: string): TStatusSearchInfo;
......@@ -209,34 +208,6 @@ begin
quotedStr(currStatus) + ' order by os.STATUS_TIMESTAMP desc LIMIT 1) AS ' + currStatus + '_DONE, ';
end;
function TLookupService.generateSearchSQL(FieldType: string; search: string): string;
var
shortTable: string;
fieldName: string;
SQL: string;
comparison: string;
begin
if FieldType = 'Company Name' then
begin
SQL := 'c.NAME LIKE ' + quotedStr('%' + search + '%');
end
else if FieldType = 'Company Short Name' then
begin
SQL := 'c.SHORT_NAME LIKE ' + quotedStr('%' + search + '%');
end
else if FieldType = 'Order ID' then
begin
SQL := 'o.ORDER_ID = ' + search;
end
else if FieldType = 'Job Name' then
begin
SQL := 'o.JOB_NAME LIKE ' + quotedStr('%' + search + '%');
end;
result := SQL;
end;
function TLookupService.generateStatusSelectSQL(statusTableShort: string; statusTableLong: string; startDate: string; endDate: string; statusType: string): string;
begin
result := 'exists ( select 1 from ' + statusTableLong + ' ' +
......@@ -265,7 +236,7 @@ begin
result.statusType := '';
result.filterType := '';
result.statusSuffix := '';
if params.Values['filterType' + statusNum] <> '' then
if ( ( params.Values['filterType' + statusNum] <> '' ) and ( params.Values['filterType' + statusNum] <> 'NONE' ) ) then
begin
result.statusType := params.Values['filterType' + statusNum].Split([' '])[0];
result.statusSuffix := params.Values['filterType' + statusNum].Split([' '])[1];
......@@ -318,15 +289,17 @@ var
whereSQL: string;
orderBySQL: string;
OrderID: string;
CompanyID: string;
JobName: string;
orderType: string;
// These variables apply to the first status sent from the client
status1: TStatusSearchInfo;
// These variables apply to the second status sent from the client
status2: TStatusSearchInfo;
fieldType: string;
search: string;
orderType: string;
begin
result := TSQLQuery.Create;
params := TStringList.Create;
......@@ -339,9 +312,10 @@ begin
PageNum := StrToInt(params.Values['pagenumber']);
PageSize := StrToInt(params.Values['pagesize']);
OrderBy := params.Values['orderby'];
fieldType := params.Values['fieldType'];
search := params.Values['search'];
orderType := params.Values['orderType'].ToLower();
OrderID := params.Values['orderID'];
companyID := params.Values['companyID'];
jobName := params.Values['jobName'];
// Search infomation for first status type
status1 := createStatusSearchInfo(params, '1');
......@@ -365,18 +339,26 @@ begin
whereSQL := 'from orders o join customers c on ' +
'c.CUSTOMER_ID = o.COMPANY_ID left join qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID where 0 = 0';
if status1.filterType <> '' then
if ( ( status1.filterType <> '' ) and ( status1.filterType <> 'NONE' ) ) then
whereSQL := whereSQL + generateStatusWhereSQL(status1);
if status2.filterType <> '' then
if ( (status2.filterType <> '' ) and ( status2.filterType <> 'NONE' ) ) then
whereSQL := whereSQL + generateStatusWhereSQL(status2);
if ( (fieldType <> '') and (search <> '') ) then
whereSQL := whereSQL + ' AND ' + generateSearchSQL(fieldType, search);
if orderType <> '' then
if ( ( orderType <> '' ) and ( orderType <> 'any' ) ) then
whereSQL := whereSQL + ' AND o.ORDER_TYPE = ' + quotedStr(orderType + '_plate');
if orderID <> '' then
whereSQL := whereSQL + ' AND o.ORDER_ID = ' + orderID;
if companyID <> '' then
whereSQL := whereSQL + ' AND c.CUSTOMER_ID = ' + companyID;
if jobName <> '' then
whereSQL := whereSQL + ' AND o.JOB_NAME = ' + quotedStr(jobName);
orderBySQL := 'ORDER BY ' + OrderBy;
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ' + whereSQL + ' ' + orderBySQL + ' LIMIT ' + limit + ' OFFSET ' + offset;
......
[Settings]
MemoLogLevel=4
FileLogLevel=5
LogFileNum=145
LogFileNum=155
webClientVersion=1.0.0
[Database]
......
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