Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KGOrders
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cam Hayes
KGOrders
Commits
9ddc1084
Commit
9ddc1084
authored
Dec 20, 2024
by
cam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made SQL generation substantially simpler. Search is finished and tested
Client Side search page will need touching up
parent
b1c171ac
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
554 additions
and
408 deletions
+554
-408
View.Orders.dfm
kgOrdersClient/View.Orders.dfm
+77
-98
View.Orders.html
kgOrdersClient/View.Orders.html
+23
-67
View.Orders.pas
kgOrdersClient/View.Orders.pas
+100
-63
View.Search.dfm
kgOrdersClient/View.Search.dfm
+178
-27
View.Search.html
kgOrdersClient/View.Search.html
+10
-27
View.Search.pas
kgOrdersClient/View.Search.pas
+38
-6
Lookup.Service.pas
kgOrdersServer/Source/Lookup.Service.pas
+15
-0
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+112
-119
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+1
-1
No files found.
kgOrdersClient/View.Orders.dfm
View file @
9ddc1084
...
...
@@ -23,65 +23,6 @@ object FViewOrders: TFViewOrders
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wcbSortBy: TWebComboBox
Left = 368
Top = 16
Width = 145
Height = 21
ElementID = 'wcbsortby'
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 btnApply: TWebButton
Left = 542
Top = 16
Width = 96
Height = 25
Caption = 'Apply'
ChildOrder = 7
ElementID = 'btnapply'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
TabOrder = 5
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnApplyClick
end
object edtSearch: TWebEdit
Left = 35
Top = 16
Width = 121
Height = 22
HelpType = htKeyword
TabStop = False
ChildOrder = 8
ElementClassName = 'form-control'
ElementID = 'edtsearch'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
HideSelection = False
TabOrder = 1
WidthPercent = 100.000000000000000000
end
object btnAddOrder: TWebButton
Left = 59
Top = 79
...
...
@@ -98,12 +39,12 @@ object FViewOrders: TFViewOrders
WidthPercent = 100.000000000000000000
OnClick = btnAddOrderClick
end
object btn
Filters
: TWebButton
object btn
Search
: TWebButton
Left = 462
Top = 79
Width = 96
Height = 25
Caption = 'S
how Filters
'
Caption = 'S
earch
'
ChildOrder = 6
ElementID = 'btnfilters'
ElementFont = efCSS
...
...
@@ -112,41 +53,7 @@ object FViewOrders: TFViewOrders
TabOrder = 9
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnFiltersClick
end
object dtpStartDate: TWebDateTimePicker
Left = 168
Top = 16
Width = 85
Height = 22
ElementID = 'dtpstartdate'
HeightStyle = ssAuto
BorderStyle = bsSingle
ChildOrder = 7
Color = clWhite
Date = 45553.505972858790000000
ElementFont = efCSS
Role = ''
TabOrder = 2
TabStop = False
Text = ''
end
object dtpEndDate: TWebDateTimePicker
Left = 266
Top = 16
Width = 87
Height = 22
ElementID = 'dtpenddate'
HeightStyle = ssAuto
BorderStyle = bsSingle
ChildOrder = 7
Color = clWhite
Date = 45553.505972858790000000
ElementFont = efCSS
Role = ''
TabOrder = 3
TabStop = False
Text = ''
OnClick = btnSearchClick
end
object pnlMessage: TWebPanel
Left = 82
...
...
@@ -160,7 +67,7 @@ object FViewOrders: TFViewOrders
ElementFont = efCSS
ElementPosition = epRelative
Role = 'alert'
TabOrder =
7
TabOrder =
2
object lblMessage: TWebLabel
Left = 32
Top = 11
...
...
@@ -273,6 +180,7 @@ object FViewOrders: TFViewOrders
Title = 'Order Type'
end
item
ElementClassName = 'text-nowrap'
DataField = 'orderDate'
Title = 'Order Date'
end
...
...
@@ -322,7 +230,7 @@ object FViewOrders: TFViewOrders
end
item
DataField = 'qbRefNum'
Title = 'Q
uickbooks Reference Number
'
Title = 'Q
B Ref Num
'
end
item
DataField = 'colors'
...
...
@@ -342,6 +250,7 @@ object FViewOrders: TFViewOrders
HeightPercent = 100.000000000000000000
Text = '500'
WidthPercent = 100.000000000000000000
OnChange = wcbPageSizeChange
ItemIndex = -1
Items.Strings = (
'100'
...
...
@@ -349,6 +258,76 @@ object FViewOrders: TFViewOrders
'500'
'1000')
end
object wlcbOrderBy: TWebLookupComboBox
Left = 188
Top = 52
Width = 145
Height = 22
ElementClassName = 'custom-select'
ElementID = 'wlcborderby'
ElementFont = efCSS
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = wlcbOrderByChange
ItemIndex = -1
LookupValues = <
item
Value = 'o.ORDER_ID DESC'
DisplayText = 'ID'
end
item
Value = 'c.NAME ASC'
DisplayText = 'Company Name'
end
item
Value = 'o.JOB_NAME ASC'
DisplayText = 'Job Name'
end
item
Value = 'o.ORDER_DATE DESC'
DisplayText = 'Order Date'
end
item
Value = 'PROOF_DUE DESC'
DisplayText = 'Proof Due'
end
item
Value = 'PROOF_DONE DESC'
DisplayText = 'Proof Done'
end
item
Value = 'ART_DUE DESC'
DisplayText = 'Art Due'
end
item
Value = 'ART_DONE DESC'
DisplayText = 'Art Done'
end
item
Value = 'PLATE_DUE DESC'
DisplayText = 'Plate Due'
end
item
Value = 'PLATE_DONE DESC'
DisplayText = 'Plate Done'
end
item
Value = 'MOUNT_DUE DESC'
DisplayText = 'Mount Due'
end
item
Value = 'MOUNT_DONE DESC'
DisplayText = 'Mount Done'
end
item
Value = 'SHIP_DUE DESC'
DisplayText = 'Ship Due'
end
item
Value = 'SHIP_DONE DESC'
DisplayText = 'Ship Done'
end>
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 28
...
...
kgOrdersClient/View.Orders.html
View file @
9ddc1084
<div
class=
"container h-100 d-flex flex-column mt-0"
style=
"max-width: 100%;"
>
<div
class=
"container h-100 d-flex flex-column mt-0"
style=
"max-width: 100%;
padding-bottom: 0;
"
>
<!-- Alert Section -->
<div
class=
"row"
>
<div
class=
"col-sm"
>
...
...
@@ -9,54 +9,29 @@
</div>
</div>
<!-- Filters Section -->
<div
class=
"container mb-3"
>
<!-- Filters Row (Hidden Initially) -->
<div
id=
"filter_info"
style=
"display: none;"
>
<div
class=
"row justify-content-center"
>
<div
class=
"col-auto"
>
<label
for=
"edtsearch"
class=
"fw-bold"
>
Search:
</label>
<input
type=
"text"
id=
"edtsearch"
class=
"form-control"
>
</div>
<div
class=
"col-auto"
>
<label
for=
"dtpstartdate"
class=
"fw-bold"
>
Start Date:
</label>
<input
type=
"date"
id=
"dtpstartdate"
class=
"form-control"
>
</div>
<div
class=
"col-auto"
>
<label
for=
"dtpenddate"
class=
"fw-bold"
>
End Date:
</label>
<input
type=
"date"
id=
"dtpenddate"
class=
"form-control"
>
</div>
<div
class=
"col-auto"
>
<label
for=
"wcbsortby"
class=
"fw-bold"
>
Property Type*
</label>
<select
class=
"form-select"
id=
"wcbsortby"
></select>
</div>
<div
class=
"col-auto d-flex align-items-end"
>
<button
id=
"btnapply"
class=
"btn btn-primary"
>
Apply
</button>
</div>
</div>
<!-- Actions Row -->
<div
class=
"row mt-3 justify-content-center"
>
<div
class=
"col-auto d-flex align-items-center"
>
<label
class=
"mt-3"
style=
"font-weight: 700;"
>
Show
<select
class=
"custom-select"
id=
"wcbpagesize"
style=
"font-size: 1.00rem;"
></select>
entries
</label>
</div>
<!-- Actions Row -->
<div
class=
"row mt-3 justify-content-center"
>
<div
class=
"col-auto d-flex align-items-center"
>
<label
class=
"mt-3"
style=
"font-weight: 700;"
>
Show
<select
class=
"custom-select"
id=
"wcbpagesize"
style=
"font-size: 1.00rem;"
></select>
entries
</label>
</div>
<div
class=
"col-auto"
>
<button
id=
"btnaddorder"
class=
"btn btn-secondary mt-3"
>
Add Order
</button>
</div>
<div
class=
"col-auto"
>
<button
id=
"btnsetstatus"
class=
"btn btn-secondary mt-3"
>
Set Status
</button>
</div>
<div
class=
"col-auto"
>
<button
id=
"btngeneratepdf"
class=
"btn btn-secondary mt-3"
type=
"button"
>
Generate PDF
</button>
<div
class=
"invalid-feedback"
>
No order selected. Please select an order to generate a PDF.
</div>
</div>
<div
class=
"col-auto"
>
<button
id=
"btnfilters"
class=
"btn btn-secondary mt-3"
>
Filters
</button>
<div
class=
"col-auto d-flex align-items-center"
>
<label
class=
"mt-3"
style=
"font-weight: 700;"
>
Order By:
<select
class=
"custom-select"
id=
"wlcborderby"
style=
"font-size: 1.00rem;"
></select></label>
</div>
<div
class=
"col-auto"
>
<button
id=
"btnaddorder"
class=
"btn btn-secondary mt-3"
>
Add Order
</button>
</div>
<div
class=
"col-auto"
>
<button
id=
"btnsetstatus"
class=
"btn btn-secondary mt-3"
>
Set Status
</button>
</div>
<div
class=
"col-auto"
>
<button
id=
"btngeneratepdf"
class=
"btn btn-secondary mt-3"
type=
"button"
>
Generate PDF
</button>
<div
class=
"invalid-feedback"
>
No order selected. Please select an order to generate a PDF.
</div>
</div>
<div
class=
"col-auto"
>
<button
id=
"btnfilters"
class=
"btn btn-secondary mt-3"
>
Filters
</button>
</div>
</div>
<!-- Entries Label Section -->
...
...
@@ -66,8 +41,8 @@
<!-- Table Section -->
<div
id=
"order_table_section"
class=
"overflow-auto mt-2"
style=
"max-height: calc(100vh -
380px); border-bottom: none; padding-bottom: 0
;"
>
<table
id=
"tblPhoneGrid"
class=
"table table-striped table-bordered"
>
style=
"max-height: calc(100vh -
250px); padding-bottom: 0; width: 100%
;"
>
<table
id=
"tblPhoneGrid"
class=
"table table-striped table-bordered"
style=
"width: 100%;"
>
<thead
class=
"sticky-top bg-light"
>
<tr
style=
"font-size: 0.875rem;"
>
<!-- Table headers are dynamically generated -->
...
...
@@ -89,22 +64,3 @@
</div>
</div>
<!-- Confirmation Modal -->
<div
id=
"confirmation_modal"
class=
"modal fade"
tabindex=
"-1"
aria-labelledby=
"confirmation_modal_label"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
<div
class=
"modal-header"
>
<h5
id=
"confirmation_modal_label"
class=
"modal-title"
>
Select Customer
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
<div
class=
"modal-body"
>
<select
id=
"wcbcustomer"
class=
"form-control input-sm"
></select>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-secondary"
data-bs-dismiss=
"modal"
>
Cancel
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-bs-dismiss=
"modal"
id=
"btn_confirm_order"
>
Confirm
</button>
</div>
</div>
</div>
</div>
kgOrdersClient/View.Orders.pas
View file @
9ddc1084
...
...
@@ -21,9 +21,6 @@ type
XDataWebClient1
:
TXDataWebClient
;
xdwdsOrders
:
TXDataWebDataSet
;
lblEntries
:
TWebLabel
;
wcbSortBy
:
TWebComboBox
;
btnApply
:
TWebButton
;
edtSearch
:
TWebEdit
;
wdsOrders
:
TWebDataSource
;
xdwdsOrderscompanyName
:
TStringField
;
xdwdsOrdersjobName
:
TStringField
;
...
...
@@ -41,9 +38,7 @@ type
xdwdsOrdersqbRefNum
:
TStringField
;
xdwdsOrderscolors
:
TStringField
;
btnAddOrder
:
TWebButton
;
btnFilters
:
TWebButton
;
dtpStartDate
:
TWebDateTimePicker
;
dtpEndDate
:
TWebDateTimePicker
;
btnSearch
:
TWebButton
;
xdwdsOrdersplateDue
:
TStringField
;
xdwdsOrdersplateDone
:
TStringField
;
xdwdsOrdersorderType
:
TStringField
;
...
...
@@ -62,15 +57,16 @@ type
xdwdsSaveCURR_ID
:
TIntegerField
;
wdbtcOrders
:
TWebDBTableControl
;
wcbPageSize
:
TWebComboBox
;
wlcbOrderBy
:
TWebLookupComboBox
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
btnApplyClick
(
Sender
:
TObject
);
procedure
btnSearchClick
(
Sender
:
TObject
);
procedure
btnAddOrderClick
(
Sender
:
TObject
);
procedure
btn
Filters
Click
(
Sender
:
TObject
);
procedure
btn
Search
Click
(
Sender
:
TObject
);
procedure
btnCloseNotificationClick
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
btnPDFClick
(
Sender
:
TObject
);
procedure
wcbPageSizeChange
(
Sender
:
TObject
);
procedure
wlcbOrderByChange
(
Sender
:
TObject
);
private
FChildForm
:
TWebForm
;
procedure
ClearTable
();
...
...
@@ -90,10 +86,24 @@ type
PageNumber
:
integer
;
PageSize
:
integer
;
TotalPages
:
integer
;
StartDate
:
string
;
EndDate
:
string
;
//Status 1
StartDate1
:
string
;
EndDate1
:
string
;
filterType1
:
string
;
null1
:
boolean
;
//Status 2
StartDate2
:
string
;
EndDate2
:
string
;
filterType2
:
string
;
null2
:
boolean
;
OrderBy
:
string
;
Caller
:
string
;
fieldType
:
string
;
searchString
:
string
;
orderType
:
string
;
filters
:
boolean
;
info
:
string
;
public
...
...
@@ -139,18 +149,34 @@ begin
DMConnection
.
ApiConnection
.
Connected
:=
True
;
PageNumber
:=
1
;
TotalPages
:=
1
;
// Initial total pages
wcbSortBy
.
Text
:=
'PROOF'
;
//Status 1
startDate1
:=
FormatDateTime
(
'yyyy/mm/dd'
,
0
);
endDate1
:=
FormatDateTime
(
'yyyy/mm/dd'
,
0
);
filterType1
:=
''
;
null1
:=
false
;
//Status 2
startDate2
:=
FormatDateTime
(
'yyyy/mm/dd'
,
0
);
endDate2
:=
FormatDateTime
(
'yyyy/mm/dd'
,
0
);
filterType2
:=
''
;
null2
:=
false
;
fieldType
:=
''
;
searchString
:=
''
;
orderType
:=
''
;
//today := TDateTime.Today;
dtpStartDate
.
Date
:=
0
;
dtpEndDate
.
Date
:=
0
;
wcbPageSize
.
Text
:=
'500'
;
PageSize
:=
500
;
wlcbOrderBy
.
DisplayText
:=
'Order Date'
;
OrderBy
:=
'o.ORDER_DATE DESC'
;
getOrders
(
GenerateSearchOptions
());
end
;
procedure
TFViewOrders
.
WebFormShow
(
Sender
:
TObject
);
begin
console
.
log
(
info
);
if
info
<>
''
then
ShowNotification
(
info
)
else
...
...
@@ -158,6 +184,12 @@ begin
end
;
procedure
TFViewOrders
.
wlcbOrderByChange
(
Sender
:
TObject
);
begin
OrderBy
:=
wlcbOrderBy
.
Value
;
getOrders
(
generateSearchOptions
());
end
;
procedure
TFViewOrders
.
getUser
();
var
xdcResponse
:
TXDataClientResponse
;
...
...
@@ -198,7 +230,6 @@ begin
newform
.
Caption
:=
'Select Customer and Order Type'
;
newForm
.
Popup
:=
True
;
newForm
.
Border
:=
fbDialog
;
console
.
log
(
newForm
.
GetElementHandle
);
// used to manage Back button handling to close subform
window
.
location
.
hash
:=
'subform'
;
...
...
@@ -221,21 +252,48 @@ begin
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
)
var
searchOptions
:
string
;
begin
{if newform.edtID.Text <> '' then
orderEntry('', newForm.edtID.Text, 'ADD');}
if
newform
.
confirm
then
begin
pageNumber
:=
1
;
// Status 1
startDate1
:=
FormatDateTime
(
'yyyy/mm/dd'
,
newform
.
dtpStartDate1
.
Date
);
endDate1
:=
FormatDateTime
(
'yyyy/mm/dd'
,
newform
.
dtpEndDate1
.
Date
);
filterType1
:=
newform
.
wcbFilterType1
.
Text
;
null1
:=
newform
.
cbNull1
.
Checked
;
// Status 2
startDate2
:=
FormatDateTime
(
'yyyy/mm/dd'
,
newform
.
dtpStartDate2
.
Date
);
endDate2
:=
FormatDateTime
(
'yyyy/mm/dd'
,
newform
.
dtpEndDate2
.
Date
);
filterType2
:=
newform
.
wcbFilterType2
.
Text
;
null2
:=
newform
.
cbNull2
.
Checked
;
fieldType
:=
newform
.
wcbFieldType
.
Text
;
searchString
:=
newform
.
edtSearch
.
Text
;
orderType
:=
newform
.
wcbOrderType
.
Text
;
getOrders
(
GenerateSearchOptions
());
end
;
end
);
end
;
procedure
TFViewOrders
.
wcbPageSizeChange
(
Sender
:
TObject
);
begin
PageSize
:=
StrToInt
(
wcbPageSize
.
Text
);
getOrders
(
generateSearchOptions
());
end
;
procedure
TFViewOrders
.
GeneratePagination
(
TotalPages
:
Integer
);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
...
...
@@ -496,25 +554,6 @@ begin
FViewMain
.
ViewOrderEntry
(
orderInfo
,
customerInfo
,
mode
);
end
;
procedure
TFViewOrders
.
btnApplyClick
(
Sender
:
TObject
);
// Button that effectively functions as a GetOrders() button
var
searchOptions
:
string
;
begin
PageNumber
:=
1
;
PageSize
:=
50
;
OrderBy
:=
wcbSortBy
.
Text
;
searchOptions
:=
'&pagenumber='
+
IntToStr
(
PageNumber
)
+
'&pagesize='
+
IntToStr
(
PageSize
)
+
'&orderby='
+
OrderBy
+
'&startDate='
+
FormatDateTime
(
'yyyy/mm/dd'
,
dtpStartDate
.
Date
)
+
'&endDate='
+
FormatDateTime
(
'yyyy/mm/dd'
,
dtpEndDate
.
Date
)
+
'&filterType='
+
wcbSortBy
.
Text
;
GetOrders
(
searchOptions
);
end
;
procedure
TFViewOrders
.
btnCloseNotificationClick
(
Sender
:
TObject
);
begin
HideNotification
();
...
...
@@ -527,11 +566,11 @@ begin
end
;
procedure
TFViewOrders
.
btn
Filters
Click
(
Sender
:
TObject
);
procedure
TFViewOrders
.
btn
Search
Click
(
Sender
:
TObject
);
var
filterSection
:
TJSHTMLElement
;
begin
if
btnFilters
.
Caption
=
'Show Filters'
then
{
if btnFilters.Caption = 'Show Filters' then
begin
btnFilters.Caption := 'Hide Filters';
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
...
...
@@ -544,8 +583,8 @@ begin
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
if Assigned(filterSection) then
filterSection.style.setProperty('display', 'none');
end
;
//
ShowSearchForm();
end;
}
ShowSearchForm
();
end
;
...
...
@@ -579,14 +618,6 @@ begin
end
;
end
;
procedure
TFViewOrders
.
btnSearchClick
(
Sender
:
TObject
);
// orders Search method
begin
Search
(
edtSearch
.
Text
);
end
;
procedure
TFViewOrders
.
ClearTable
();
// clears the table
var
...
...
@@ -602,19 +633,26 @@ function TFViewOrders.GenerateSearchOptions(): string;
var
searchOptions
:
string
;
begin
//PageNumber := 1;
PageSize
:=
StrToInt
(
wcbPageSize
.
Text
);
OrderBy
:=
wcbSortBy
.
Text
;
searchOptions
:=
'&pagenumber='
+
IntToStr
(
PageNumber
)
+
'&pagesize='
+
IntToStr
(
PageSize
)
+
'&orderby='
+
OrderBy
;
if
btnFilters
.
Caption
=
'Hide Filters'
then
begin
searchOptions
:=
searchOptions
+
'&startDate='
+
FormatDateTime
(
'yyyy/mm/dd'
,
dtpStartDate
.
Date
)
+
'&endDate='
+
FormatDateTime
(
'yyyy/mm/dd'
,
dtpEndDate
.
Date
)
+
'&filterType='
+
wcbSortBy
.
Text
;
end
;
'&orderby='
+
OrderBy
+
//Status 1
'&startDate1='
+
startDate1
+
'&endDate1='
+
endDate1
+
'&filterType1='
+
filterType1
+
'&null1='
+
BoolToStr
(
null1
)
+
// Status2
'&startDate2='
+
startDate2
+
'&endDate2='
+
endDate2
+
'&filterType2='
+
filterType2
+
'&null2='
+
BoolToStr
(
null2
)
+
'&fieldType='
+
fieldType
+
'&search='
+
searchString
+
'&orderType='
+
orderType
;
Result
:=
searchOptions
;
end
;
...
...
@@ -630,7 +668,6 @@ procedure TFViewOrders.ShowNotification(Notification: string);
begin
if
Notification
<>
''
then
begin
console
.
log
(
'hit'
);
lblMessage
.
Caption
:=
Notification
;
pnlMessage
.
ElementHandle
.
hidden
:=
False
;
end
;
...
...
kgOrdersClient/View.Search.dfm
View file @
9ddc1084
...
...
@@ -7,9 +7,82 @@ object FSearch: TFSearch
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
OnShow = WebFormShow
object lblStatus1: TWebLabel
Left = 18
Top = 44
Width = 43
Height = 14
Caption = 'Status 1:'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblType1: TWebLabel
Left = 18
Top = 64
Width = 26
Height = 14
Caption = 'Type:'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblStartDate1: TWebLabel
Left = 178
Top = 64
Width = 51
Height = 14
Caption = 'Start Date:'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblEndDate1: TWebLabel
Left = 276
Top = 64
Width = 43
Height = 14
Caption = 'End Date'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblStatus2: TWebLabel
Left = 18
Top = 132
Width = 43
Height = 14
Caption = 'Status 2:'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblType2: TWebLabel
Left = 18
Top = 158
Width = 26
Height = 14
Caption = 'Type:'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblStartDate2: TWebLabel
Left = 178
Top = 158
Width = 51
Height = 14
Caption = 'Start Date:'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object lblEndDate2: TWebLabel
Left = 276
Top = 158
Width = 43
Height = 14
Caption = 'End Date'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object pnlMessage: TWebPanel
Left =
24
Top = 5
7
Left =
102
Top = 5
15
Width = 121
Height = 33
ElementClassName = 'card'
...
...
@@ -21,8 +94,8 @@ object FSearch: TFSearch
Role = 'alert'
TabOrder = 0
object lblMessage: TWebLabel
Left = 2
8
Top =
9
Left = 2
2
Top =
11
Width = 44
Height = 14
Caption = 'Message'
...
...
@@ -50,9 +123,9 @@ object FSearch: TFSearch
WidthPercent = 100.000000000000000000
end
end
object wcb
SortBy
: TWebComboBox
Left =
640
Top =
170
object wcb
FilterType1
: TWebComboBox
Left =
18
Top =
88
Width = 145
Height = 22
ElementFont = efCSS
...
...
@@ -76,11 +149,11 @@ object FSearch: TFSearch
'SHIP DONE')
end
object btnConfirm: TWebButton
Left =
814
Top =
170
Left =
18
Top =
307
Width = 96
Height = 25
Caption = '
Apply
'
Caption = '
Confirm
'
ChildOrder = 7
ElementFont = efCSS
HeightStyle = ssAuto
...
...
@@ -91,8 +164,8 @@ object FSearch: TFSearch
OnClick = btnConfirmClick
end
object edtSearch: TWebEdit
Left = 1
69
Top =
170
Left = 1
80
Top =
264
Width = 121
Height = 22
HelpType = htKeyword
...
...
@@ -106,9 +179,9 @@ object FSearch: TFSearch
TabOrder = 1
WidthPercent = 100.000000000000000000
end
object dtpStartDate: TWebDateTimePicker
Left =
444
Top =
170
object dtpStartDate
1
: TWebDateTimePicker
Left =
178
Top =
88
Width = 85
Height = 22
HeightStyle = ssAuto
...
...
@@ -122,9 +195,9 @@ object FSearch: TFSearch
TabStop = False
Text = ''
end
object dtpEndDate: TWebDateTimePicker
Left =
538
Top =
170
object dtpEndDate
1
: TWebDateTimePicker
Left =
276
Top =
88
Width = 87
Height = 22
HeightStyle = ssAuto
...
...
@@ -138,19 +211,19 @@ object FSearch: TFSearch
TabStop = False
Text = ''
end
object cb
Empty
: TWebCheckBox
Left =
18
Top =
206
object cb
Null1
: TWebCheckBox
Left =
384
Top =
88
Width = 185
Height = 22
Caption = 'Only Show
Nonfinished Status'#39's
'
Caption = 'Only Show
Empty
'
ChildOrder = 6
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object wcb
SearchCategory
: TWebComboBox
object wcb
FieldType
: TWebComboBox
Left = 18
Top =
170
Top =
264
Width = 145
Height = 22
HeightPercent = 100.000000000000000000
...
...
@@ -162,9 +235,9 @@ object FSearch: TFSearch
'Company Short Name'
'Job Name')
end
object wcb
Status
Type: TWebComboBox
Left =
29
0
Top =
170
object wcb
Order
Type: TWebComboBox
Left =
32
0
Top =
264
Width = 145
Height = 22
HeightPercent = 100.000000000000000000
...
...
@@ -174,4 +247,82 @@ object FSearch: TFSearch
'Corrugated'
'Web')
end
object btnCancel: TWebButton
Left = 144
Top = 307
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 5
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object wcbFilterType2: TWebComboBox
Left = 18
Top = 194
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 dtpStartDate2: TWebDateTimePicker
Left = 178
Top = 194
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 dtpEndDate2: TWebDateTimePicker
Left = 276
Top = 194
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 cbNull2: TWebCheckBox
Left = 384
Top = 194
Width = 185
Height = 22
Caption = 'Only Show Empty'
ChildOrder = 6
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
kgOrdersClient/View.Search.html
View file @
9ddc1084
<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>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<title>
TMS Web Project
</title>
<style>
</style>
</head>
<body>
</body>
</html>
kgOrdersClient/View.Search.pas
View file @
9ddc1084
...
...
@@ -15,19 +15,36 @@ type
pnlMessage
:
TWebPanel
;
lblMessage
:
TWebLabel
;
btnCloseNotification
:
TWebButton
;
wcb
SortBy
:
TWebComboBox
;
wcb
FilterType1
:
TWebComboBox
;
btnConfirm
:
TWebButton
;
edtSearch
:
TWebEdit
;
dtpStartDate
:
TWebDateTimePicker
;
dtpEndDate
:
TWebDateTimePicker
;
cbEmpty
:
TWebCheckBox
;
wcbSearchCategory
:
TWebComboBox
;
wcbStatusType
:
TWebComboBox
;
dtpStartDate1
:
TWebDateTimePicker
;
dtpEndDate1
:
TWebDateTimePicker
;
cbNull1
:
TWebCheckBox
;
wcbFieldType
:
TWebComboBox
;
wcbOrderType
:
TWebComboBox
;
btnCancel
:
TWebButton
;
lblStatus1
:
TWebLabel
;
lblType1
:
TWebLabel
;
lblStartDate1
:
TWebLabel
;
lblEndDate1
:
TWebLabel
;
wcbFilterType2
:
TWebComboBox
;
dtpStartDate2
:
TWebDateTimePicker
;
dtpEndDate2
:
TWebDateTimePicker
;
cbNull2
:
TWebCheckBox
;
lblStatus2
:
TWebLabel
;
lblType2
:
TWebLabel
;
lblStartDate2
:
TWebLabel
;
lblEndDate2
:
TWebLabel
;
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnCancelClick
(
Sender
:
TObject
);
private
//FJSONProc: TJSONProc;
public
class
function
CreateForm
(
AElementID
:
string
):
TWebForm
;
var
confirm
:
boolean
;
end
;
var
...
...
@@ -50,8 +67,23 @@ begin
);
end
;
procedure
TFSearch
.
WebFormShow
(
Sender
:
TObject
);
begin
dtpStartDate1
.
Date
:=
0
;
dtpEndDate1
.
Date
:=
0
;
dtpStartDate1
.
Date
:=
0
;
dtpEndDate1
.
Date
:=
0
;
confirm
:=
false
;
end
;
procedure
TFSearch
.
btnCancelClick
(
Sender
:
TObject
);
begin
Close
;
end
;
procedure
TFSearch
.
btnConfirmClick
(
Sender
:
TObject
);
begin
confirm
:=
true
;
Close
;
end
;
...
...
kgOrdersServer/Source/Lookup.Service.pas
View file @
9ddc1084
...
...
@@ -78,6 +78,21 @@ type
end
;
TStatusSearchInfo
=
class
Public
startDate
,
endDate
,
filterType
,
statusType
,
statusSuffix
,
statusTableShort
,
statusTableLong
,
altStatusTableShort
,
altStatusTableLong
:
string
;
null
:
boolean
;
end
;
TSQLQuery
=
class
Public
SQL
,
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
9ddc1084
...
...
@@ -40,13 +40,16 @@ type
function
AddItem
(
itemInfo
:
string
):
string
;
function
DelUser
(
username
:
string
):
string
;
function
generateSelectSQL
(
filterType
,
startDate
,
endDate
:
string
):
string
;
function
generateSubQuery
(
filterType
,
statusType
,
currStatus
:
string
):
string
;
function
generateSubQuery
(
currStatus
:
string
):
string
;
function
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
function
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
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
;
procedure
AfterConstruction
;
override
;
procedure
BeforeDestruction
;
override
;
end
;
...
...
@@ -197,34 +200,13 @@ begin
end
;
function
TLookupService
.
generateSubQuery
(
filterType
,
statusType
,
currStatus
:
string
):
string
;
var
statusSuffix
:
string
;
function
TLookupService
.
generateSubQuery
(
currStatus
:
string
):
string
;
begin
result
:=
''
;
statusSuffix
:=
''
;
if
filterType
<>
''
then
statusSuffix
:=
filterType
.
Split
([
'_'
])[
1
];
if
statusType
<>
currStatus
then
begin
if
(
statusSuffix
=
'DUE'
)
or
(
statusSuffix
=
''
)
then
begin
result
:=
result
+
'(select oss.STATUS_DATE from orders_status_schedule oss '
+
result
:=
'(select oss.STATUS_DATE from orders_status_schedule oss '
+
'where oss.ORDER_ID = o.ORDER_ID and oss.ORDER_STATUS = '
+
quotedStr
(
currStatus
)
+
') AS '
+
currStatus
+
'_DUE,'
;
end
else
result
:=
result
+
'(select os.STATUS_TIMESTAMP from orders_status os where os.ORDER_ID = o.ORDER_ID and os.ORDER_STATUS = '
+
quotedStr
(
currStatus
)
+
' order by os.STATUS_TIMESTAMP desc LIMIT 1) AS '
+
currStatus
+
'_DONE, '
;
end
;
if
(
statusSuffix
=
'DUE'
)
or
(
statusSuffix
=
''
)
then
begin
result
:=
result
+
'(select os.STATUS_TIMESTAMP from orders_status os where os.ORDER_ID = o.ORDER_ID and os.ORDER_STATUS = '
+
result
:=
result
+
'(select os.STATUS_TIMESTAMP from orders_status os where os.ORDER_ID = o.ORDER_ID and os.ORDER_STATUS = '
+
quotedStr
(
currStatus
)
+
' order by os.STATUS_TIMESTAMP desc LIMIT 1) AS '
+
currStatus
+
'_DONE, '
;
end
else
result
:=
result
+
'(select oss.STATUS_DATE from orders_status_schedule oss '
+
'where oss.ORDER_ID = o.ORDER_ID and oss.ORDER_STATUS = '
+
quotedStr
(
currStatus
)
+
') AS '
+
currStatus
+
'_DUE,'
;
end
;
function
TLookupService
.
generateSearchSQL
(
FieldType
:
string
;
search
:
string
):
string
;
...
...
@@ -255,6 +237,75 @@ begin
end
;
function
TLookupService
.
generateStatusSelectSQL
(
statusTableShort
:
string
;
statusTableLong
:
string
;
startDate
:
string
;
endDate
:
string
;
statusType
:
string
):
string
;
begin
result
:=
'exists ( select 1 from '
+
statusTableLong
+
' '
+
statusTableShort
+
' where '
+
statusTableShort
+
'.ORDER_ID = '
+
'o.ORDER_ID AND '
+
statusTableShort
+
'.ORDER_STATUS = '
+
quotedStr
(
statusType
)
+
' AND '
+
quotedStr
(
startDate
)
+
' <= STATUS_DATE'
;
if
endDate
<>
'1899/12/30'
then
begin
result
:=
result
+
' AND '
+
quotedStr
(
endDate
)
+
' >= STATUS_DATE'
;
end
;
result
:=
result
+
' AND STATUS_DATE IS NOT NULL)'
;
end
;
function
TLookupService
.
createStatusSearchInfo
(
params
:
TStringList
;
statusNum
:
string
):
TStatusSearchInfo
;
var
statusType
:
string
;
begin
result
:=
TStatusSearchInfo
.
Create
;
result
.
startDate
:=
params
.
Values
[
'startDate'
+
statusNum
];
result
.
endDate
:=
params
.
Values
[
'endDate'
+
statusNum
];
result
.
null
:=
StrToBool
(
params
.
Values
[
'null'
+
statusNum
]);
result
.
statusType
:=
''
;
result
.
filterType
:=
''
;
result
.
statusSuffix
:=
''
;
if
params
.
Values
[
'filterType'
+
statusNum
]
<>
''
then
begin
result
.
statusType
:=
params
.
Values
[
'filterType'
+
statusNum
].
Split
([
' '
])[
0
];
result
.
statusSuffix
:=
params
.
Values
[
'filterType'
+
statusNum
].
Split
([
' '
])[
1
];
result
.
filterType
:=
result
.
statusType
+
'_'
+
result
.
statusSuffix
;
end
;
// Figure out what table the status belongs to
if
result
.
statusSuffix
=
'DUE'
then
begin
result
.
statusTableShort
:=
'oss'
;
result
.
statusTableLong
:=
'orders_status_schedule'
;
result
.
altStatusTableShort
:=
'os'
;
result
.
altStatusTableLong
:=
'orders_status'
;
end
else
begin
result
.
statusTableShort
:=
'os'
;
result
.
statusTableLong
:=
'orders_status'
;
result
.
altStatusTableShort
:=
'oss'
;
result
.
altStatusTableLong
:=
'orders_status_schedule'
;
end
;
end
;
function
TLookupService
.
generateStatusWhereSQL
(
status
:
TStatusSearchInfo
):
string
;
begin
result
:=
' AND '
;
if
status
.
null
then
begin
result
:=
result
+
'not exists (select 1 from '
+
status
.
statusTableLong
+
' '
+
status
.
statusTableShort
+
' where '
+
status
.
statusTableShort
+
'.ORDER_ID = o.ORDER_ID '
+
'AND '
+
status
.
statusTableShort
+
'.ORDER_STATUS = '
+
quotedStr
(
status
.
statusType
)
+
') AND '
+
generateStatusSelectSQL
(
status
.
altStatusTableShort
,
status
.
altStatusTableLong
,
status
.
startDate
,
status
.
endDate
,
status
.
statusType
);
end
else
result
:=
result
+
generateStatusSelectSQL
(
status
.
statusTableShort
,
status
.
statusTableLong
,
status
.
startDate
,
status
.
endDate
,
status
.
statusType
);
end
;
function
TLookupService
.
generateOrdersSQL
(
searchOptions
:
string
):
TSQLQuery
;
var
params
:
TStringList
;
...
...
@@ -263,20 +314,19 @@ var
OrderBy
:
string
;
offset
:
string
;
limit
:
string
;
startDate
:
string
;
endDate
:
string
;
filterType
:
string
;
statusType
:
string
;
statusSuffix
:
string
;
SQL
:
string
;
whereSQL
:
string
;
statusTableShort
:
string
;
statusTableLong
:
string
;
notFinished
:
boolean
;
altStatusTableShort
:
string
;
altStatusTableLong
:
string
;
orderBySQL
:
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
;
...
...
@@ -285,110 +335,53 @@ begin
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
searchOptions
;
orderBySQL
:=
''
;
PageNum
:=
StrToInt
(
params
.
Values
[
'pagenumber'
]);
PageSize
:=
StrToInt
(
params
.
Values
[
'pagesize'
]);
OrderBy
:=
params
.
Values
[
'orderby'
];
startDate
:=
params
.
Values
[
'startDate'
];
endDate
:=
params
.
Values
[
'endDate'
];
statusType
:=
''
;
filterType
:=
''
;
statusSuffix
:=
''
;
if
params
.
Values
[
'filterType'
]
<>
''
then
begin
statusType
:=
params
.
Values
[
'filterType'
].
Split
([
' '
])[
0
];
statusSuffix
:=
params
.
Values
[
'filterType'
].
Split
([
' '
])[
1
];
filterType
:=
params
.
Values
[
'filterType'
].
Split
([
' '
])[
0
]
+
'_'
+
params
.
Values
[
'filterType'
].
Split
([
' '
])[
1
];
end
;
fieldType
:=
params
.
Values
[
'fieldType'
];
search
:=
params
.
Values
[
'search'
];
orderType
:=
params
.
Values
[
'orderType'
].
ToLower
();
fieldType
:=
'Company Short Name'
;
search
:=
'BIS'
;
// Figure out what table the status belongs to
if
statusSuffix
=
'DUE'
then
begin
statusTableShort
:=
'oss'
;
statusTableLong
:=
'orders_status_schedule'
;
altStatusTableShort
:=
'os'
;
altStatusTableLong
:=
'orders_status'
;
end
else
begin
statusTableShort
:=
'os'
;
statusTableLong
:=
'orders_status'
;
altStatusTableShort
:=
'oss'
;
altStatusTableLong
:=
'orders_status_schedule'
;
end
;
// Search infomation for first status type
status1
:=
createStatusSearchInfo
(
params
,
'1'
);
// Search Information for second status type
status2
:=
createStatusSearchInfo
(
params
,
'2'
);
offset
:=
IntToStr
((
PageNum
-
1
)
*
PageSize
);
limit
:=
IntToStr
(
PageSize
);
whereSQL
:=
'WHERE '
;
if
filterType
<>
''
then
begin
SQL
:=
'SELECT o.ORDER_ID, '
+
statusTableShort
+
'.STATUS_DATE AS '
+
filterType
.
ToUpper
+
', o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '
;
end
else
begin
SQL
:=
'SELECT o.ORDER_ID, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '
end
;
SQL
:=
'SELECT o.ORDER_ID, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '
;
// Generate the subqueries that get the Status Dates(Due and Done)
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'PROOF'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'ART'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'PLATE'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'MOUNT'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'SHIP'
);
// Generate the Where SQL based on if there is a filter applied or not
if
filterType
<>
''
then
begin
whereSQL
:=
'FROM orders o join '
+
statusTableLong
+
' '
+
statusTableShort
+
' on '
+
statusTableShort
+
'.ORDER_ID = o.ORDER_ID join '
+
'customers c on c.CUSTOMER_ID = o.COMPANY_ID left join '
+
'qb_sales_orders qb on qb.ORDER_ID = o.ORDER_ID '
+
'WHERE '
+
statusTableShort
+
'.ORDER_ID = o.ORDER_ID AND + '
+
statusTableShort
+
'.ORDER_STATUS = '
+
quotedStr
(
statusType
);
SQL
:=
SQL
+
generateSubquery
(
'PROOF'
);
SQL
:=
SQL
+
generateSubquery
(
'ART'
);
SQL
:=
SQL
+
generateSubquery
(
'PLATE'
);
SQL
:=
SQL
+
generateSubquery
(
'MOUNT'
);
SQL
:=
SQL
+
generateSubquery
(
'SHIP'
);
whereSQL
:=
whereSQL
+
' AND '
+
quotedStr
(
startDate
)
+
' <= '
+
statusTableShort
+
'.STATUS_DATE'
;
// Generate the Where SQL based on if there is a status filter applied or not
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
endDate
<>
'1899/12/30
'
then
whereSQL
:=
whereSQL
+
' AND '
+
quotedStr
(
endDate
)
+
' >= '
+
statusTableShort
+
'.STATUS_DATE'
;
if
status1
.
filterType
<>
'
'
then
whereSQL
:=
whereSQL
+
generateStatusWhereSQL
(
status1
)
;
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
status2
.
filterType
<>
''
then
whereSQL
:=
whereSQL
+
generateStatusWhereSQL
(
status2
);
if
(
(
fieldType
<>
''
)
and
(
search
<>
''
)
)
then
begin
whereSQL
:=
whereSQL
+
' AND '
+
generateSearchSQL
(
fieldType
,
search
);
end
;
if
(
(
fieldType
<>
''
)
and
(
search
<>
''
)
)
then
whereSQL
:=
whereSQL
+
' AND '
+
generateSearchSQL
(
fieldType
,
search
);
if
orderType
<>
''
then
whereSQL
:=
whereSQL
+
' AND o.ORDER_TYPE = '
+
quotedStr
(
orderType
+
'_plate'
);
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
+
whereSQL
+
' ORDER BY '
+
filterType
+
' DESC LIMIT '
+
limit
+
' OFFSET '
+
offset
;
end
else
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'
;
if
(
(
fieldType
<>
''
)
and
(
search
<>
''
)
)
then
begin
whereSQL
:=
whereSQL
+
' WHERE '
+
generateSearchSQL
(
fieldType
,
search
);
end
;
orderBySQL
:=
'ORDER BY '
+
OrderBy
;
whereSQL
:=
whereSQL
+
' ORDER BY o.ORDER_DATE DESC'
;
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
+
whereSQL
+
' '
+
orderBySQL
+
' LIMIT '
+
limit
+
' OFFSET '
+
offset
;
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
+
whereSQL
+
' LIMIT '
+
limit
+
' OFFSET '
+
offset
;
end
;
// send the SQL and whereSQL back. whereSQL is needed to get the total count.
// probably a way to getthe TotalCount in original SQL but it was giving me issues
result
.
SQL
:=
SQL
;
...
...
kgOrdersServer/kgOrdersServer.ini
View file @
9ddc1084
[Settings]
MemoLogLevel
=
4
FileLogLevel
=
5
LogFileNum
=
82
LogFileNum
=
145
webClientVersion
=
1.0.0
[Database]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment