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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
534 additions
and
388 deletions
+534
-388
View.Orders.dfm
kgOrdersClient/View.Orders.dfm
+77
-98
View.Orders.html
kgOrdersClient/View.Orders.html
+6
-50
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
+109
-116
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+1
-1
No files found.
kgOrdersClient/View.Orders.dfm
View file @
9ddc1084
...
@@ -23,65 +23,6 @@ object FViewOrders: TFViewOrders
...
@@ -23,65 +23,6 @@ object FViewOrders: TFViewOrders
HeightPercent = 100.000000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
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
object btnAddOrder: TWebButton
Left = 59
Left = 59
Top = 79
Top = 79
...
@@ -98,12 +39,12 @@ object FViewOrders: TFViewOrders
...
@@ -98,12 +39,12 @@ object FViewOrders: TFViewOrders
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddOrderClick
OnClick = btnAddOrderClick
end
end
object btn
Filters
: TWebButton
object btn
Search
: TWebButton
Left = 462
Left = 462
Top = 79
Top = 79
Width = 96
Width = 96
Height = 25
Height = 25
Caption = 'S
how Filters
'
Caption = 'S
earch
'
ChildOrder = 6
ChildOrder = 6
ElementID = 'btnfilters'
ElementID = 'btnfilters'
ElementFont = efCSS
ElementFont = efCSS
...
@@ -112,41 +53,7 @@ object FViewOrders: TFViewOrders
...
@@ -112,41 +53,7 @@ object FViewOrders: TFViewOrders
TabOrder = 9
TabOrder = 9
TabStop = False
TabStop = False
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnFiltersClick
OnClick = btnSearchClick
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 = ''
end
end
object pnlMessage: TWebPanel
object pnlMessage: TWebPanel
Left = 82
Left = 82
...
@@ -160,7 +67,7 @@ object FViewOrders: TFViewOrders
...
@@ -160,7 +67,7 @@ object FViewOrders: TFViewOrders
ElementFont = efCSS
ElementFont = efCSS
ElementPosition = epRelative
ElementPosition = epRelative
Role = 'alert'
Role = 'alert'
TabOrder =
7
TabOrder =
2
object lblMessage: TWebLabel
object lblMessage: TWebLabel
Left = 32
Left = 32
Top = 11
Top = 11
...
@@ -273,6 +180,7 @@ object FViewOrders: TFViewOrders
...
@@ -273,6 +180,7 @@ object FViewOrders: TFViewOrders
Title = 'Order Type'
Title = 'Order Type'
end
end
item
item
ElementClassName = 'text-nowrap'
DataField = 'orderDate'
DataField = 'orderDate'
Title = 'Order Date'
Title = 'Order Date'
end
end
...
@@ -322,7 +230,7 @@ object FViewOrders: TFViewOrders
...
@@ -322,7 +230,7 @@ object FViewOrders: TFViewOrders
end
end
item
item
DataField = 'qbRefNum'
DataField = 'qbRefNum'
Title = 'Q
uickbooks Reference Number
'
Title = 'Q
B Ref Num
'
end
end
item
item
DataField = 'colors'
DataField = 'colors'
...
@@ -342,6 +250,7 @@ object FViewOrders: TFViewOrders
...
@@ -342,6 +250,7 @@ object FViewOrders: TFViewOrders
HeightPercent = 100.000000000000000000
HeightPercent = 100.000000000000000000
Text = '500'
Text = '500'
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = wcbPageSizeChange
ItemIndex = -1
ItemIndex = -1
Items.Strings = (
Items.Strings = (
'100'
'100'
...
@@ -349,6 +258,76 @@ object FViewOrders: TFViewOrders
...
@@ -349,6 +258,76 @@ object FViewOrders: TFViewOrders
'500'
'500'
'1000')
'1000')
end
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
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Connection = DMConnection.ApiConnection
Left = 28
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 -->
<!-- Alert Section -->
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"col-sm"
>
<div
class=
"col-sm"
>
...
@@ -9,38 +9,14 @@
...
@@ -9,38 +9,14 @@
</div>
</div>
</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>
</div>
<!-- Actions Row -->
<!-- Actions Row -->
<div
class=
"row mt-3 justify-content-center"
>
<div
class=
"row mt-3 justify-content-center"
>
<div
class=
"col-auto d-flex align-items-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>
<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>
<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"
>
<div
class=
"col-auto"
>
<button
id=
"btnaddorder"
class=
"btn btn-secondary mt-3"
>
Add Order
</button>
<button
id=
"btnaddorder"
class=
"btn btn-secondary mt-3"
>
Add Order
</button>
</div>
</div>
...
@@ -57,7 +33,6 @@
...
@@ -57,7 +33,6 @@
<button
id=
"btnfilters"
class=
"btn btn-secondary mt-3"
>
Filters
</button>
<button
id=
"btnfilters"
class=
"btn btn-secondary mt-3"
>
Filters
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Entries Label Section -->
<!-- Entries Label Section -->
<div
class=
"d-flex justify-content-between w-100 mt-2"
>
<div
class=
"d-flex justify-content-between w-100 mt-2"
>
...
@@ -66,8 +41,8 @@
...
@@ -66,8 +41,8 @@
<!-- Table Section -->
<!-- Table Section -->
<div
id=
"order_table_section"
class=
"overflow-auto mt-2"
<div
id=
"order_table_section"
class=
"overflow-auto mt-2"
style=
"max-height: calc(100vh -
380px); border-bottom: none; padding-bottom: 0
;"
>
style=
"max-height: calc(100vh -
250px); padding-bottom: 0; width: 100%
;"
>
<table
id=
"tblPhoneGrid"
class=
"table table-striped table-bordered"
>
<table
id=
"tblPhoneGrid"
class=
"table table-striped table-bordered"
style=
"width: 100%;"
>
<thead
class=
"sticky-top bg-light"
>
<thead
class=
"sticky-top bg-light"
>
<tr
style=
"font-size: 0.875rem;"
>
<tr
style=
"font-size: 0.875rem;"
>
<!-- Table headers are dynamically generated -->
<!-- Table headers are dynamically generated -->
...
@@ -89,22 +64,3 @@
...
@@ -89,22 +64,3 @@
</div>
</div>
</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
...
@@ -21,9 +21,6 @@ type
XDataWebClient1
:
TXDataWebClient
;
XDataWebClient1
:
TXDataWebClient
;
xdwdsOrders
:
TXDataWebDataSet
;
xdwdsOrders
:
TXDataWebDataSet
;
lblEntries
:
TWebLabel
;
lblEntries
:
TWebLabel
;
wcbSortBy
:
TWebComboBox
;
btnApply
:
TWebButton
;
edtSearch
:
TWebEdit
;
wdsOrders
:
TWebDataSource
;
wdsOrders
:
TWebDataSource
;
xdwdsOrderscompanyName
:
TStringField
;
xdwdsOrderscompanyName
:
TStringField
;
xdwdsOrdersjobName
:
TStringField
;
xdwdsOrdersjobName
:
TStringField
;
...
@@ -41,9 +38,7 @@ type
...
@@ -41,9 +38,7 @@ type
xdwdsOrdersqbRefNum
:
TStringField
;
xdwdsOrdersqbRefNum
:
TStringField
;
xdwdsOrderscolors
:
TStringField
;
xdwdsOrderscolors
:
TStringField
;
btnAddOrder
:
TWebButton
;
btnAddOrder
:
TWebButton
;
btnFilters
:
TWebButton
;
btnSearch
:
TWebButton
;
dtpStartDate
:
TWebDateTimePicker
;
dtpEndDate
:
TWebDateTimePicker
;
xdwdsOrdersplateDue
:
TStringField
;
xdwdsOrdersplateDue
:
TStringField
;
xdwdsOrdersplateDone
:
TStringField
;
xdwdsOrdersplateDone
:
TStringField
;
xdwdsOrdersorderType
:
TStringField
;
xdwdsOrdersorderType
:
TStringField
;
...
@@ -62,15 +57,16 @@ type
...
@@ -62,15 +57,16 @@ type
xdwdsSaveCURR_ID
:
TIntegerField
;
xdwdsSaveCURR_ID
:
TIntegerField
;
wdbtcOrders
:
TWebDBTableControl
;
wdbtcOrders
:
TWebDBTableControl
;
wcbPageSize
:
TWebComboBox
;
wcbPageSize
:
TWebComboBox
;
wlcbOrderBy
:
TWebLookupComboBox
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
btnApplyClick
(
Sender
:
TObject
);
procedure
btnSearchClick
(
Sender
:
TObject
);
procedure
btnAddOrderClick
(
Sender
:
TObject
);
procedure
btnAddOrderClick
(
Sender
:
TObject
);
procedure
btn
Filters
Click
(
Sender
:
TObject
);
procedure
btn
Search
Click
(
Sender
:
TObject
);
procedure
btnCloseNotificationClick
(
Sender
:
TObject
);
procedure
btnCloseNotificationClick
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
procedure
btnPDFClick
(
Sender
:
TObject
);
procedure
btnPDFClick
(
Sender
:
TObject
);
procedure
wcbPageSizeChange
(
Sender
:
TObject
);
procedure
wlcbOrderByChange
(
Sender
:
TObject
);
private
private
FChildForm
:
TWebForm
;
FChildForm
:
TWebForm
;
procedure
ClearTable
();
procedure
ClearTable
();
...
@@ -90,10 +86,24 @@ type
...
@@ -90,10 +86,24 @@ type
PageNumber
:
integer
;
PageNumber
:
integer
;
PageSize
:
integer
;
PageSize
:
integer
;
TotalPages
:
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
;
OrderBy
:
string
;
Caller
:
string
;
fieldType
:
string
;
searchString
:
string
;
orderType
:
string
;
filters
:
boolean
;
filters
:
boolean
;
info
:
string
;
info
:
string
;
public
public
...
@@ -139,18 +149,34 @@ begin
...
@@ -139,18 +149,34 @@ begin
DMConnection
.
ApiConnection
.
Connected
:=
True
;
DMConnection
.
ApiConnection
.
Connected
:=
True
;
PageNumber
:=
1
;
PageNumber
:=
1
;
TotalPages
:=
1
;
// Initial total pages
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;
//today := TDateTime.Today;
dtpStartDate
.
Date
:=
0
;
dtpEndDate
.
Date
:=
0
;
wcbPageSize
.
Text
:=
'500'
;
wcbPageSize
.
Text
:=
'500'
;
PageSize
:=
500
;
wlcbOrderBy
.
DisplayText
:=
'Order Date'
;
OrderBy
:=
'o.ORDER_DATE DESC'
;
getOrders
(
GenerateSearchOptions
());
getOrders
(
GenerateSearchOptions
());
end
;
end
;
procedure
TFViewOrders
.
WebFormShow
(
Sender
:
TObject
);
procedure
TFViewOrders
.
WebFormShow
(
Sender
:
TObject
);
begin
begin
console
.
log
(
info
);
if
info
<>
''
then
if
info
<>
''
then
ShowNotification
(
info
)
ShowNotification
(
info
)
else
else
...
@@ -158,6 +184,12 @@ begin
...
@@ -158,6 +184,12 @@ begin
end
;
end
;
procedure
TFViewOrders
.
wlcbOrderByChange
(
Sender
:
TObject
);
begin
OrderBy
:=
wlcbOrderBy
.
Value
;
getOrders
(
generateSearchOptions
());
end
;
procedure
TFViewOrders
.
getUser
();
procedure
TFViewOrders
.
getUser
();
var
var
xdcResponse
:
TXDataClientResponse
;
xdcResponse
:
TXDataClientResponse
;
...
@@ -198,7 +230,6 @@ begin
...
@@ -198,7 +230,6 @@ begin
newform
.
Caption
:=
'Select Customer and Order Type'
;
newform
.
Caption
:=
'Select Customer and Order Type'
;
newForm
.
Popup
:=
True
;
newForm
.
Popup
:=
True
;
newForm
.
Border
:=
fbDialog
;
newForm
.
Border
:=
fbDialog
;
console
.
log
(
newForm
.
GetElementHandle
);
// used to manage Back button handling to close subform
// used to manage Back button handling to close subform
window
.
location
.
hash
:=
'subform'
;
window
.
location
.
hash
:=
'subform'
;
...
@@ -221,21 +252,48 @@ begin
...
@@ -221,21 +252,48 @@ begin
newform
.
Caption
:=
'Input Search Options'
;
newform
.
Caption
:=
'Input Search Options'
;
newForm
.
Popup
:=
True
;
newForm
.
Popup
:=
True
;
newForm
.
Border
:=
fbDialog
;
newForm
.
Border
:=
fbDialog
;
console
.
log
(
newForm
.
GetElementHandle
);
// used to manage Back button handling to close subform
// used to manage Back button handling to close subform
window
.
location
.
hash
:=
'subform'
;
window
.
location
.
hash
:=
'subform'
;
newform
.
ShowModal
(
newform
.
ShowModal
(
procedure
(
AValue
:
TModalResult
)
procedure
(
AValue
:
TModalResult
)
var
searchOptions
:
string
;
begin
if
newform
.
confirm
then
begin
begin
{if newform.edtID.Text <> '' then
pageNumber
:=
1
;
orderEntry('', newForm.edtID.Text, 'ADD');}
// 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
);
);
end
;
end
;
procedure
TFViewOrders
.
wcbPageSizeChange
(
Sender
:
TObject
);
begin
PageSize
:=
StrToInt
(
wcbPageSize
.
Text
);
getOrders
(
generateSearchOptions
());
end
;
procedure
TFViewOrders
.
GeneratePagination
(
TotalPages
:
Integer
);
procedure
TFViewOrders
.
GeneratePagination
(
TotalPages
:
Integer
);
// Generates pagination for the table.
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
// TotalPages: Total amount of pages generated by the search
...
@@ -496,25 +554,6 @@ begin
...
@@ -496,25 +554,6 @@ begin
FViewMain
.
ViewOrderEntry
(
orderInfo
,
customerInfo
,
mode
);
FViewMain
.
ViewOrderEntry
(
orderInfo
,
customerInfo
,
mode
);
end
;
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
);
procedure
TFViewOrders
.
btnCloseNotificationClick
(
Sender
:
TObject
);
begin
begin
HideNotification
();
HideNotification
();
...
@@ -527,11 +566,11 @@ begin
...
@@ -527,11 +566,11 @@ begin
end
;
end
;
procedure
TFViewOrders
.
btn
Filters
Click
(
Sender
:
TObject
);
procedure
TFViewOrders
.
btn
Search
Click
(
Sender
:
TObject
);
var
var
filterSection
:
TJSHTMLElement
;
filterSection
:
TJSHTMLElement
;
begin
begin
if
btnFilters
.
Caption
=
'Show Filters'
then
{
if btnFilters.Caption = 'Show Filters' then
begin
begin
btnFilters.Caption := 'Hide Filters';
btnFilters.Caption := 'Hide Filters';
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
...
@@ -544,8 +583,8 @@ begin
...
@@ -544,8 +583,8 @@ begin
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
filterSection := TJSHTMLElement(document.getElementById('filter_info'));
if Assigned(filterSection) then
if Assigned(filterSection) then
filterSection.style.setProperty('display', 'none');
filterSection.style.setProperty('display', 'none');
end
;
end;
}
//
ShowSearchForm();
ShowSearchForm
();
end
;
end
;
...
@@ -579,14 +618,6 @@ begin
...
@@ -579,14 +618,6 @@ begin
end
;
end
;
end
;
end
;
procedure
TFViewOrders
.
btnSearchClick
(
Sender
:
TObject
);
// orders Search method
begin
Search
(
edtSearch
.
Text
);
end
;
procedure
TFViewOrders
.
ClearTable
();
procedure
TFViewOrders
.
ClearTable
();
// clears the table
// clears the table
var
var
...
@@ -602,19 +633,26 @@ function TFViewOrders.GenerateSearchOptions(): string;
...
@@ -602,19 +633,26 @@ function TFViewOrders.GenerateSearchOptions(): string;
var
var
searchOptions
:
string
;
searchOptions
:
string
;
begin
begin
//PageNumber := 1;
PageSize
:=
StrToInt
(
wcbPageSize
.
Text
);
OrderBy
:=
wcbSortBy
.
Text
;
searchOptions
:=
'&pagenumber='
+
IntToStr
(
PageNumber
)
+
searchOptions
:=
'&pagenumber='
+
IntToStr
(
PageNumber
)
+
'&pagesize='
+
IntToStr
(
PageSize
)
+
'&pagesize='
+
IntToStr
(
PageSize
)
+
'&orderby='
+
OrderBy
;
'&orderby='
+
OrderBy
+
if
btnFilters
.
Caption
=
'Hide Filters'
then
begin
//Status 1
searchOptions
:=
searchOptions
+
'&startDate1='
+
startDate1
+
'&startDate='
+
FormatDateTime
(
'yyyy/mm/dd'
,
dtpStartDate
.
Date
)
+
'&endDate1='
+
endDate1
+
'&endDate='
+
FormatDateTime
(
'yyyy/mm/dd'
,
dtpEndDate
.
Date
)
+
'&filterType1='
+
filterType1
+
'&filterType='
+
wcbSortBy
.
Text
;
'&null1='
+
BoolToStr
(
null1
)
+
end
;
// Status2
'&startDate2='
+
startDate2
+
'&endDate2='
+
endDate2
+
'&filterType2='
+
filterType2
+
'&null2='
+
BoolToStr
(
null2
)
+
'&fieldType='
+
fieldType
+
'&search='
+
searchString
+
'&orderType='
+
orderType
;
Result
:=
searchOptions
;
Result
:=
searchOptions
;
end
;
end
;
...
@@ -630,7 +668,6 @@ procedure TFViewOrders.ShowNotification(Notification: string);
...
@@ -630,7 +668,6 @@ procedure TFViewOrders.ShowNotification(Notification: string);
begin
begin
if
Notification
<>
''
then
if
Notification
<>
''
then
begin
begin
console
.
log
(
'hit'
);
lblMessage
.
Caption
:=
Notification
;
lblMessage
.
Caption
:=
Notification
;
pnlMessage
.
ElementHandle
.
hidden
:=
False
;
pnlMessage
.
ElementHandle
.
hidden
:=
False
;
end
;
end
;
...
...
kgOrdersClient/View.Search.dfm
View file @
9ddc1084
...
@@ -7,9 +7,82 @@ object FSearch: TFSearch
...
@@ -7,9 +7,82 @@ object FSearch: TFSearch
Font.Name = 'Arial'
Font.Name = 'Arial'
Font.Style = []
Font.Style = []
ParentFont = False
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
object pnlMessage: TWebPanel
Left =
24
Left =
102
Top = 5
7
Top = 5
15
Width = 121
Width = 121
Height = 33
Height = 33
ElementClassName = 'card'
ElementClassName = 'card'
...
@@ -21,8 +94,8 @@ object FSearch: TFSearch
...
@@ -21,8 +94,8 @@ object FSearch: TFSearch
Role = 'alert'
Role = 'alert'
TabOrder = 0
TabOrder = 0
object lblMessage: TWebLabel
object lblMessage: TWebLabel
Left = 2
8
Left = 2
2
Top =
9
Top =
11
Width = 44
Width = 44
Height = 14
Height = 14
Caption = 'Message'
Caption = 'Message'
...
@@ -50,9 +123,9 @@ object FSearch: TFSearch
...
@@ -50,9 +123,9 @@ object FSearch: TFSearch
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
end
end
object wcb
SortBy
: TWebComboBox
object wcb
FilterType1
: TWebComboBox
Left =
640
Left =
18
Top =
170
Top =
88
Width = 145
Width = 145
Height = 22
Height = 22
ElementFont = efCSS
ElementFont = efCSS
...
@@ -76,11 +149,11 @@ object FSearch: TFSearch
...
@@ -76,11 +149,11 @@ object FSearch: TFSearch
'SHIP DONE')
'SHIP DONE')
end
end
object btnConfirm: TWebButton
object btnConfirm: TWebButton
Left =
814
Left =
18
Top =
170
Top =
307
Width = 96
Width = 96
Height = 25
Height = 25
Caption = '
Apply
'
Caption = '
Confirm
'
ChildOrder = 7
ChildOrder = 7
ElementFont = efCSS
ElementFont = efCSS
HeightStyle = ssAuto
HeightStyle = ssAuto
...
@@ -91,8 +164,8 @@ object FSearch: TFSearch
...
@@ -91,8 +164,8 @@ object FSearch: TFSearch
OnClick = btnConfirmClick
OnClick = btnConfirmClick
end
end
object edtSearch: TWebEdit
object edtSearch: TWebEdit
Left = 1
69
Left = 1
80
Top =
170
Top =
264
Width = 121
Width = 121
Height = 22
Height = 22
HelpType = htKeyword
HelpType = htKeyword
...
@@ -106,9 +179,9 @@ object FSearch: TFSearch
...
@@ -106,9 +179,9 @@ object FSearch: TFSearch
TabOrder = 1
TabOrder = 1
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object dtpStartDate: TWebDateTimePicker
object dtpStartDate
1
: TWebDateTimePicker
Left =
444
Left =
178
Top =
170
Top =
88
Width = 85
Width = 85
Height = 22
Height = 22
HeightStyle = ssAuto
HeightStyle = ssAuto
...
@@ -122,9 +195,9 @@ object FSearch: TFSearch
...
@@ -122,9 +195,9 @@ object FSearch: TFSearch
TabStop = False
TabStop = False
Text = ''
Text = ''
end
end
object dtpEndDate: TWebDateTimePicker
object dtpEndDate
1
: TWebDateTimePicker
Left =
538
Left =
276
Top =
170
Top =
88
Width = 87
Width = 87
Height = 22
Height = 22
HeightStyle = ssAuto
HeightStyle = ssAuto
...
@@ -138,19 +211,19 @@ object FSearch: TFSearch
...
@@ -138,19 +211,19 @@ object FSearch: TFSearch
TabStop = False
TabStop = False
Text = ''
Text = ''
end
end
object cb
Empty
: TWebCheckBox
object cb
Null1
: TWebCheckBox
Left =
18
Left =
384
Top =
206
Top =
88
Width = 185
Width = 185
Height = 22
Height = 22
Caption = 'Only Show
Nonfinished Status'#39's
'
Caption = 'Only Show
Empty
'
ChildOrder = 6
ChildOrder = 6
HeightPercent = 100.000000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object wcb
SearchCategory
: TWebComboBox
object wcb
FieldType
: TWebComboBox
Left = 18
Left = 18
Top =
170
Top =
264
Width = 145
Width = 145
Height = 22
Height = 22
HeightPercent = 100.000000000000000000
HeightPercent = 100.000000000000000000
...
@@ -162,9 +235,9 @@ object FSearch: TFSearch
...
@@ -162,9 +235,9 @@ object FSearch: TFSearch
'Company Short Name'
'Company Short Name'
'Job Name')
'Job Name')
end
end
object wcb
Status
Type: TWebComboBox
object wcb
Order
Type: TWebComboBox
Left =
29
0
Left =
32
0
Top =
170
Top =
264
Width = 145
Width = 145
Height = 22
Height = 22
HeightPercent = 100.000000000000000000
HeightPercent = 100.000000000000000000
...
@@ -174,4 +247,82 @@ object FSearch: TFSearch
...
@@ -174,4 +247,82 @@ object FSearch: TFSearch
'Corrugated'
'Corrugated'
'Web')
'Web')
end
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
end
kgOrdersClient/View.Search.html
View file @
9ddc1084
<div
class=
"row"
>
<html>
<div
class=
"col-12"
>
<head>
<div
class=
"container mt-4"
>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<div
class=
"row justify-content-center"
>
<title>
TMS Web Project
</title>
<div
class=
"col-12 col-md-8"
>
<style>
<div
class=
"row"
>
</style>
<div
class=
"col-sm"
>
</head>
<div
id=
"pnl_message"
class=
"alert alert-danger"
>
<body>
<button
id=
"view.login.message.button"
type=
"button"
class=
"btn-close"
aria-label=
"Close"
></button>
</body>
<span
id=
"view.login.message.label"
></span>
</html>
</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>
kgOrdersClient/View.Search.pas
View file @
9ddc1084
...
@@ -15,19 +15,36 @@ type
...
@@ -15,19 +15,36 @@ type
pnlMessage
:
TWebPanel
;
pnlMessage
:
TWebPanel
;
lblMessage
:
TWebLabel
;
lblMessage
:
TWebLabel
;
btnCloseNotification
:
TWebButton
;
btnCloseNotification
:
TWebButton
;
wcb
SortBy
:
TWebComboBox
;
wcb
FilterType1
:
TWebComboBox
;
btnConfirm
:
TWebButton
;
btnConfirm
:
TWebButton
;
edtSearch
:
TWebEdit
;
edtSearch
:
TWebEdit
;
dtpStartDate
:
TWebDateTimePicker
;
dtpStartDate1
:
TWebDateTimePicker
;
dtpEndDate
:
TWebDateTimePicker
;
dtpEndDate1
:
TWebDateTimePicker
;
cbEmpty
:
TWebCheckBox
;
cbNull1
:
TWebCheckBox
;
wcbSearchCategory
:
TWebComboBox
;
wcbFieldType
:
TWebComboBox
;
wcbStatusType
:
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
btnConfirmClick
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnCancelClick
(
Sender
:
TObject
);
private
private
//FJSONProc: TJSONProc;
//FJSONProc: TJSONProc;
public
public
class
function
CreateForm
(
AElementID
:
string
):
TWebForm
;
class
function
CreateForm
(
AElementID
:
string
):
TWebForm
;
var
confirm
:
boolean
;
end
;
end
;
var
var
...
@@ -50,8 +67,23 @@ begin
...
@@ -50,8 +67,23 @@ begin
);
);
end
;
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
);
procedure
TFSearch
.
btnConfirmClick
(
Sender
:
TObject
);
begin
begin
confirm
:=
true
;
Close
;
Close
;
end
;
end
;
...
...
kgOrdersServer/Source/Lookup.Service.pas
View file @
9ddc1084
...
@@ -78,6 +78,21 @@ type
...
@@ -78,6 +78,21 @@ type
end
;
end
;
TStatusSearchInfo
=
class
Public
startDate
,
endDate
,
filterType
,
statusType
,
statusSuffix
,
statusTableShort
,
statusTableLong
,
altStatusTableShort
,
altStatusTableLong
:
string
;
null
:
boolean
;
end
;
TSQLQuery
=
class
TSQLQuery
=
class
Public
Public
SQL
,
SQL
,
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
9ddc1084
...
@@ -40,13 +40,16 @@ type
...
@@ -40,13 +40,16 @@ type
function
AddItem
(
itemInfo
:
string
):
string
;
function
AddItem
(
itemInfo
:
string
):
string
;
function
DelUser
(
username
:
string
):
string
;
function
DelUser
(
username
:
string
):
string
;
function
generateSelectSQL
(
filterType
,
startDate
,
endDate
:
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
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
function
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
function
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
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
;
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
AfterConstruction
;
override
;
procedure
BeforeDestruction
;
override
;
procedure
BeforeDestruction
;
override
;
end
;
end
;
...
@@ -197,34 +200,13 @@ begin
...
@@ -197,34 +200,13 @@ begin
end
;
end
;
function
TLookupService
.
generateSubQuery
(
filterType
,
statusType
,
currStatus
:
string
):
string
;
function
TLookupService
.
generateSubQuery
(
currStatus
:
string
):
string
;
var
statusSuffix
:
string
;
begin
begin
result
:=
''
;
result
:=
'(select oss.STATUS_DATE from orders_status_schedule oss '
+
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 '
+
'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
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, '
;
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
;
end
;
function
TLookupService
.
generateSearchSQL
(
FieldType
:
string
;
search
:
string
):
string
;
function
TLookupService
.
generateSearchSQL
(
FieldType
:
string
;
search
:
string
):
string
;
...
@@ -255,6 +237,75 @@ begin
...
@@ -255,6 +237,75 @@ begin
end
;
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
;
function
TLookupService
.
generateOrdersSQL
(
searchOptions
:
string
):
TSQLQuery
;
var
var
params
:
TStringList
;
params
:
TStringList
;
...
@@ -263,20 +314,19 @@ var
...
@@ -263,20 +314,19 @@ var
OrderBy
:
string
;
OrderBy
:
string
;
offset
:
string
;
offset
:
string
;
limit
:
string
;
limit
:
string
;
startDate
:
string
;
endDate
:
string
;
filterType
:
string
;
statusType
:
string
;
statusSuffix
:
string
;
SQL
:
string
;
SQL
:
string
;
whereSQL
:
string
;
whereSQL
:
string
;
statusTableShort
:
string
;
orderBySQL
:
string
;
statusTableLong
:
string
;
notFinished
:
boolean
;
// These variables apply to the first status sent from the client
altStatusTableShort
:
string
;
status1
:
TStatusSearchInfo
;
altStatusTableLong
:
string
;
// These variables apply to the second status sent from the client
status2
:
TStatusSearchInfo
;
fieldType
:
string
;
fieldType
:
string
;
search
:
string
;
search
:
string
;
orderType
:
string
;
begin
begin
result
:=
TSQLQuery
.
Create
;
result
:=
TSQLQuery
.
Create
;
params
:=
TStringList
.
Create
;
params
:=
TStringList
.
Create
;
...
@@ -285,109 +335,52 @@ begin
...
@@ -285,109 +335,52 @@ begin
params
.
Delimiter
:=
'&'
;
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
searchOptions
;
params
.
DelimitedText
:=
searchOptions
;
orderBySQL
:=
''
;
PageNum
:=
StrToInt
(
params
.
Values
[
'pagenumber'
]);
PageNum
:=
StrToInt
(
params
.
Values
[
'pagenumber'
]);
PageSize
:=
StrToInt
(
params
.
Values
[
'pagesize'
]);
PageSize
:=
StrToInt
(
params
.
Values
[
'pagesize'
]);
OrderBy
:=
params
.
Values
[
'orderby'
];
OrderBy
:=
params
.
Values
[
'orderby'
];
startDate
:=
params
.
Values
[
'startDate'
];
fieldType
:=
params
.
Values
[
'fieldType'
];
endDate
:=
params
.
Values
[
'endDate'
];
search
:=
params
.
Values
[
'search'
];
statusType
:=
''
;
orderType
:=
params
.
Values
[
'orderType'
].
ToLower
();
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
:=
'Company Short Name'
;
search
:=
'BIS'
;
// Figure out what table the status belongs to
// Search infomation for first status type
if
statusSuffix
=
'DUE'
then
status1
:=
createStatusSearchInfo
(
params
,
'1'
);
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 Information for second status type
status2
:=
createStatusSearchInfo
(
params
,
'2'
);
offset
:=
IntToStr
((
PageNum
-
1
)
*
PageSize
);
offset
:=
IntToStr
((
PageNum
-
1
)
*
PageSize
);
limit
:=
IntToStr
(
PageSize
);
limit
:=
IntToStr
(
PageSize
);
whereSQL
:=
'WHERE '
;
if
filterType
<>
''
then
SQL
:=
'SELECT o.ORDER_ID, o.LOCATION AS Loc, c.NAME AS COMPANY_NAME, o.JOB_NAME, o.ORDER_DATE, o.ORDER_TYPE, '
;
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
;
// Generate the subqueries that get the Status Dates(Due and Done)
// Generate the subqueries that get the Status Dates(Due and Done)
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'PROOF'
);
SQL
:=
SQL
+
generateSubquery
(
'PROOF'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'ART'
);
SQL
:=
SQL
+
generateSubquery
(
'ART'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'PLATE'
);
SQL
:=
SQL
+
generateSubquery
(
'PLATE'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'MOUNT'
);
SQL
:=
SQL
+
generateSubquery
(
'MOUNT'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
statusType
,
'SHIP'
);
SQL
:=
SQL
+
generateSubquery
(
'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
);
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
if
status1
.
filterType
<>
'
'
then
whereSQL
:=
whereSQL
+
' AND '
+
quotedStr
(
endDate
)
+
' >= '
+
statusTableShort
+
'.STATUS_DATE'
;
whereSQL
:=
whereSQL
+
generateStatusWhereSQL
(
status1
)
;
if
notFinished
then
if
status2
.
filterType
<>
''
then
begin
whereSQL
:=
whereSQL
+
generateStatusWhereSQL
(
status2
);
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
if
(
(
fieldType
<>
''
)
and
(
search
<>
''
)
)
then
begin
whereSQL
:=
whereSQL
+
' AND '
+
generateSearchSQL
(
fieldType
,
search
);
whereSQL
:=
whereSQL
+
' AND '
+
generateSearchSQL
(
fieldType
,
search
);
end
;
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
;
orderBySQL
:=
'ORDER BY '
+
OrderBy
;
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'
;
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
+
whereSQL
+
' '
+
orderBySQL
+
' LIMIT '
+
limit
+
' OFFSET '
+
offset
;
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
;
end
;
// send the SQL and whereSQL back. whereSQL is needed to get the total count.
// 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
// probably a way to getthe TotalCount in original SQL but it was giving me issues
...
...
kgOrdersServer/kgOrdersServer.ini
View file @
9ddc1084
[Settings]
[Settings]
MemoLogLevel
=
4
MemoLogLevel
=
4
FileLogLevel
=
5
FileLogLevel
=
5
LogFileNum
=
82
LogFileNum
=
145
webClientVersion
=
1.0.0
webClientVersion
=
1.0.0
[Database]
[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