Commit b1c171ac by cam

Server search functionality finished and tested. Client side started.

parent 5680ee7c
...@@ -13,7 +13,7 @@ uses ...@@ -13,7 +13,7 @@ uses
WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls, WEBLib.Forms, WEBLib.Dialogs, WEBLib.Menus, WEBLib.ExtCtrls, WEBLib.StdCtrls,
WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage, WEBLib.JSON, Auth.Service, XData.Web.Client, WebLib.Storage,
ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls, ConnectionModule, App.Types, Vcl.StdCtrls, Vcl.Controls, WEBLib.DBCtrls,
XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset, View.AddOrder, XData.Web.JsonDataset, WEBLib.DB, Data.DB, XData.Web.Dataset,
WEBLib.Grids; WEBLib.Grids;
type type
...@@ -80,6 +80,7 @@ type ...@@ -80,6 +80,7 @@ type
procedure HideNotification(); procedure HideNotification();
procedure ShowNotification(Notification: string); procedure ShowNotification(Notification: string);
procedure ShowAddOrderForm(); procedure ShowAddOrderForm();
procedure ShowSearchForm();
[async] procedure Search(searchOptions: string); [async] procedure Search(searchOptions: string);
[async] procedure GetOrders(searchOptions: string); [async] procedure GetOrders(searchOptions: string);
[async] procedure getUser(); [async] procedure getUser();
...@@ -106,7 +107,7 @@ var ...@@ -106,7 +107,7 @@ var
implementation implementation
uses uses
XData.Model.Classes, View.Main; XData.Model.Classes, View.Main, View.AddOrder, View.Search;
{$R *.dfm} {$R *.dfm}
...@@ -211,6 +212,29 @@ begin ...@@ -211,6 +212,29 @@ begin
); );
end; end;
procedure TFViewOrders.ShowSearchForm();
var
newform: TFSearch;
begin
newform := TFSearch.CreateNew;
newform.Caption := 'Input Search Options';
newForm.Popup := True;
newForm.Border := fbDialog;
console.log(newForm.GetElementHandle);
// 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;
procedure TFViewOrders.GeneratePagination(TotalPages: Integer); procedure TFViewOrders.GeneratePagination(TotalPages: Integer);
// Generates pagination for the table. // Generates pagination for the table.
...@@ -521,6 +545,7 @@ begin ...@@ -521,6 +545,7 @@ begin
if Assigned(filterSection) then if Assigned(filterSection) then
filterSection.style.setProperty('display', 'none'); filterSection.style.setProperty('display', 'none');
end; end;
//ShowSearchForm();
end; end;
......
object FSearch: TFSearch
Width = 1016
Height = 683
Font.Charset = ANSI_CHARSET
Font.Color = clBlack
Font.Height = -11
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
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 = 0
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 wcbSortBy: TWebComboBox
Left = 640
Top = 170
Width = 145
Height = 22
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 4
TabStop = False
Text = 'PROOF DONE'
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'PROOF DUE'
'PROOF DONE'
'ART DUE'
'ART DONE'
'PLATE DUE'
'PLATE DONE'
'MOUNT DUE'
'MOUNT DONE'
'SHIP DUE'
'SHIP DONE')
end
object btnConfirm: TWebButton
Left = 814
Top = 170
Width = 96
Height = 25
Caption = 'Apply'
ChildOrder = 7
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 5
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object edtSearch: TWebEdit
Left = 169
Top = 170
Width = 121
Height = 22
HelpType = htKeyword
TabStop = False
ChildOrder = 8
ElementClassName = 'form-control'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
HideSelection = False
TabOrder = 1
WidthPercent = 100.000000000000000000
end
object dtpStartDate: TWebDateTimePicker
Left = 444
Top = 170
Width = 85
Height = 22
HeightStyle = ssAuto
BorderStyle = bsSingle
ChildOrder = 7
Color = clWhite
Date = 45553.505972858790000000
ElementFont = efCSS
Role = ''
TabOrder = 2
TabStop = False
Text = ''
end
object dtpEndDate: TWebDateTimePicker
Left = 538
Top = 170
Width = 87
Height = 22
HeightStyle = ssAuto
BorderStyle = bsSingle
ChildOrder = 7
Color = clWhite
Date = 45553.505972858790000000
ElementFont = efCSS
Role = ''
TabOrder = 3
TabStop = False
Text = ''
end
object cbEmpty: TWebCheckBox
Left = 18
Top = 206
Width = 185
Height = 22
Caption = 'Only Show Nonfinished Status'#39's'
ChildOrder = 6
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wcbSearchCategory: TWebComboBox
Left = 18
Top = 170
Width = 145
Height = 22
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'Order ID'
'Company Name'
'Company Short Name'
'Job Name')
end
object wcbStatusType: TWebComboBox
Left = 290
Top = 170
Width = 145
Height = 22
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'Corrugated'
'Web')
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.Search;
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
TFSearch = class(TWebForm)
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
btnCloseNotification: TWebButton;
wcbSortBy: TWebComboBox;
btnConfirm: TWebButton;
edtSearch: TWebEdit;
dtpStartDate: TWebDateTimePicker;
dtpEndDate: TWebDateTimePicker;
cbEmpty: TWebCheckBox;
wcbSearchCategory: TWebComboBox;
wcbStatusType: TWebComboBox;
procedure btnConfirmClick(Sender: TObject);
private
//FJSONProc: TJSONProc;
public
class function CreateForm(AElementID: string): TWebForm;
end;
var
FSearch: TFSearch;
implementation
{$R *.dfm}
class function TFSearch.CreateForm(AElementID: string): TWebForm;
begin
Application.CreateForm(TFSearch, AElementID, Result,
procedure(AForm: TObject)
begin
with TFSearch(AForm) do
begin
end;
end
);
end;
procedure TFSearch.btnConfirmClick(Sender: TObject);
begin
Close;
end;
end.
...@@ -18,7 +18,8 @@ uses ...@@ -18,7 +18,8 @@ uses
View.EditUser in 'View.EditUser.pas' {FViewEditUser: TWebForm} {*.html}, View.EditUser in 'View.EditUser.pas' {FViewEditUser: TWebForm} {*.html},
View.Orders in 'View.Orders.pas' {FViewOrders: TWebForm} {*.html}, View.Orders in 'View.Orders.pas' {FViewOrders: TWebForm} {*.html},
View.OrderEntryCorrugated in 'View.OrderEntryCorrugated.pas' {FOrderEntry: TWebForm} {*.html}, View.OrderEntryCorrugated in 'View.OrderEntryCorrugated.pas' {FOrderEntry: TWebForm} {*.html},
View.AddOrder in 'View.AddOrder.pas' {FAddOrder: TWebForm} {*.html}; View.AddOrder in 'View.AddOrder.pas' {FAddOrder: TWebForm} {*.html},
View.Search in 'View.Search.pas' {FSearch: TWebForm} {*.html};
{$R *.res} {$R *.res}
......
...@@ -175,6 +175,11 @@ ...@@ -175,6 +175,11 @@
<FormType>dfm</FormType> <FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass> <DesignClass>TWebForm</DesignClass>
</DCCReference> </DCCReference>
<DCCReference Include="View.Search.pas">
<Form>FSearch</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/> <None Include="index.html"/>
<None Include="css\app.css"/> <None Include="css\app.css"/>
<None Include="config\config.json"/> <None Include="config\config.json"/>
......
...@@ -46,6 +46,7 @@ type ...@@ -46,6 +46,7 @@ type
function EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string; function EditStatusSchedule(StatusType: string; order: TJSONObject; ORDER_ID: string): string;
function generateOrdersSQL(searchOptions: string): TSQLQuery; function generateOrdersSQL(searchOptions: string): TSQLQuery;
function getColorCount(colors: string): string; function getColorCount(colors: string): string;
function generateSearchSQL(FieldType, search: string): string;
procedure AfterConstruction; override; procedure AfterConstruction; override;
procedure BeforeDestruction; override; procedure BeforeDestruction; override;
end; end;
...@@ -226,6 +227,34 @@ begin ...@@ -226,6 +227,34 @@ begin
'where oss.ORDER_ID = o.ORDER_ID and oss.ORDER_STATUS = ' + quotedStr(currStatus) + ') AS '+ currStatus + '_DUE,'; 'where oss.ORDER_ID = o.ORDER_ID and oss.ORDER_STATUS = ' + quotedStr(currStatus) + ') AS '+ currStatus + '_DUE,';
end; 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.generateOrdersSQL(searchOptions: string): TSQLQuery; function TLookupService.generateOrdersSQL(searchOptions: string): TSQLQuery;
var var
params: TStringList; params: TStringList;
...@@ -243,6 +272,11 @@ var ...@@ -243,6 +272,11 @@ var
whereSQL: string; whereSQL: string;
statusTableShort: string; statusTableShort: string;
statusTableLong: string; statusTableLong: string;
notFinished: boolean;
altStatusTableShort: string;
altStatusTableLong: string;
fieldType: string;
search: string;
begin begin
result := TSQLQuery.Create; result := TSQLQuery.Create;
params := TStringList.Create; params := TStringList.Create;
...@@ -266,16 +300,23 @@ begin ...@@ -266,16 +300,23 @@ begin
filterType := params.Values['filterType'].Split([' '])[0] + '_' + params.Values['filterType'].Split([' '])[1]; filterType := params.Values['filterType'].Split([' '])[0] + '_' + params.Values['filterType'].Split([' '])[1];
end; end;
fieldType := 'Company Short Name';
search := 'BIS';
// Figure out what table the status belongs to // Figure out what table the status belongs to
if statusSuffix = 'DUE' then if statusSuffix = 'DUE' then
begin begin
statusTableShort := 'oss'; statusTableShort := 'oss';
statusTableLong := 'orders_status_schedule'; statusTableLong := 'orders_status_schedule';
altStatusTableShort := 'os';
altStatusTableLong := 'orders_status';
end end
else else
begin begin
statusTableShort := 'os'; statusTableShort := 'os';
statusTableLong := 'orders_status'; statusTableLong := 'orders_status';
altStatusTableShort := 'oss';
altStatusTableLong := 'orders_status_schedule';
end; end;
...@@ -308,17 +349,43 @@ begin ...@@ -308,17 +349,43 @@ begin
'customers c on c.CUSTOMER_ID = o.COMPANY_ID left join ' + 'customers c on c.CUSTOMER_ID = o.COMPANY_ID left join ' +
'qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID ' + 'qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID ' +
'WHERE ' + statusTableShort + '.ORDER_ID = o.ORDER_ID AND + ' + 'WHERE ' + statusTableShort + '.ORDER_ID = o.ORDER_ID AND + ' +
statusTableShort + '.ORDER_STATUS = ' + quotedStr(statusType) + statusTableShort + '.ORDER_STATUS = '+ quotedStr(statusType);
' AND ' + quotedStr(startDate) + ' <= '+ statusTableShort + '.STATUS_DATE AND ' +
quotedStr(endDate) + ' >= ' + statusTableShort + '.STATUS_DATE'; whereSQL := whereSQL + ' AND ' + quotedStr(startDate) + ' <= ' + statusTableShort + '.STATUS_DATE';
if endDate <> '1899/12/30' then
whereSQL := whereSQL + ' AND ' + quotedStr(endDate) + ' >= ' + statusTableShort + '.STATUS_DATE';
if notFinished then
begin
whereSQL := whereSQL + ' AND NOT EXISTS (SELECT 1 from ' + altStatusTableLong +
' ' + altStatusTableShort + ' WHERE ' + altStatusTableShort +
'.ORDER_ID = o.ORDER_ID AND + ' + altStatusTableShort +
'.ORDER_STATUS = ' + quotedStr(statusType) + ')';
end;
if ( (fieldType <> '') and (search <> '') ) then
begin
whereSQL := whereSQL + ' AND ' + generateSearchSQL(fieldType, search);
end;
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ' + whereSQL + ' ORDER BY ' + filterType + ' DESC LIMIT ' + limit + ' OFFSET ' + offset; SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ' + whereSQL + ' ORDER BY ' + filterType + ' DESC LIMIT ' + limit + ' OFFSET ' + offset;
end end
else else
begin begin
whereSQL := 'from orders o join customers c on ' + 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 ' + 'c.CUSTOMER_ID = o.COMPANY_ID left join qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID';
'ORDER BY o.ORDER_DATE DESC';
if ( (fieldType <> '') and (search <> '') ) then
begin
whereSQL := whereSQL + ' WHERE ' + generateSearchSQL(fieldType, search);
end;
whereSQL := whereSQL + ' ORDER BY o.ORDER_DATE DESC';
SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ' + whereSQL + ' LIMIT ' + limit + ' OFFSET ' + offset; SQL := SQL + 'o.PRICE, qb.QB_REF_NUM ' + whereSQL + ' LIMIT ' + limit + ' OFFSET ' + offset;
end; end;
......
[Settings] [Settings]
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=5 FileLogLevel=5
LogFileNum=50 LogFileNum=82
webClientVersion=1.0.0 webClientVersion=1.0.0
[Database] [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