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
b2e1a1b8
Commit
b2e1a1b8
authored
Oct 31, 2024
by
cam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed SQL statements to work with new filters requested by Dave
parent
1e9dbe96
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
32 deletions
+152
-32
View.OrderEntryCorrugated.pas
kgOrdersClient/View.OrderEntryCorrugated.pas
+28
-8
View.Orders.dfm
kgOrdersClient/View.Orders.dfm
+11
-6
View.Orders.pas
kgOrdersClient/View.Orders.pas
+3
-1
Lookup.Service.pas
kgOrdersServer/Source/Lookup.Service.pas
+1
-0
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+108
-16
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+1
-1
No files found.
kgOrdersClient/View.OrderEntryCorrugated.pas
View file @
b2e1a1b8
...
...
@@ -247,11 +247,17 @@ begin
colorJSON
.
AddPair
(
header
,
value
);
end
;
colorList
.
Add
(
colorJSON
);
end
;
colorListJSON
:=
TJSONObject
.
Create
;
colorListJSON
.
AddPair
(
'items'
,
colorList
);
end
;
XDataWebDataSet1
.
Edit
;
XDataWebDataSet1colors_colors
.
Value
:=
colorListJSON
.
ToString
;
XDataWebDataSet1staff_fields_proof_date
.
Value
:=
DateTimeToStr
(
dtpProofDate
.
Date
);
XDataWebDataSet1staff_fields_ship_date
.
Value
:=
DateTimeToStr
(
dtpShipDate
.
Date
);
XDataWebDataSet1staff_fields_art_due
.
Value
:=
DateTimeToStr
(
dtpArtDue
.
Date
);
XDataWebDataSet1staff_fields_mount_due
.
Value
:=
DateTimeToStr
(
dtpMountDue
.
Date
);
XDataWebDataSet1staff_fields_plate_due
.
Value
:=
DateTimeToStr
(
dtpPlateDue
.
Date
);
XDataWebDataSet1ORDER_DATE
.
Value
:=
dtpOrderDate
.
Date
;
XDataWebDataSet1
.
Post
;
XDataWebDataSet1
.
First
;
while
not
XDataWebDataSet1
.
Eof
do
...
...
@@ -398,21 +404,35 @@ begin
end
;
end
;
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
dtpOrderDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_order_date
.
Value
);
dtpOrderDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_order_date
.
Value
)
else
dtpOrderDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_proof_date
.
AsString
=
''
)
then
dtpProofDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_proof_date
.
AsString
);
dtpProofDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_proof_date
.
AsString
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
dtpShipDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
);
dtpShipDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
)
else
dtpShipDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_art_due
.
AsString
=
''
)
then
dtpArtDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_art_due
.
AsString
);
dtpArtDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_art_due
.
AsString
)
else
dtpArtDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
=
''
)
then
dtpPlateDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
);
dtpPlateDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
)
else
dtpPlateDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_mount_due
.
AsString
=
''
)
then
dtpMountDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_mount_due
.
AsString
);
dtpMountDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_mount_due
.
AsString
)
else
dtpMountDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_approved_date
.
AsString
=
''
)
then
dtpApprovedDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_approved_date
.
AsString
)
else
dtpApprovedDate
.
Date
:=
Now
;
dtpApprovedDate
.
Date
:=
0
;
console
.
log
(
dtpApprovedDate
.
Date
);
console
.
log
(
DateTimeToStr
(
dtpApprovedDate
.
Date
));
end
;
procedure
TFOrderEntry
.
WebFormShow
(
Sender
:
TObject
);
...
...
kgOrdersClient/View.Orders.dfm
View file @
b2e1a1b8
...
...
@@ -62,15 +62,20 @@ object FViewOrders: TFViewOrders
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
Text = 'PROOF'
Text = 'PROOF
DONE
'
WidthPercent = 100.000000000000000000
ItemIndex = -1
Items.Strings = (
'PROOF'
'ART'
'PLATE'
'MOUNT'
'SHIP')
'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
...
...
kgOrdersClient/View.Orders.pas
View file @
b2e1a1b8
...
...
@@ -295,7 +295,6 @@ begin
colorObject
:=
TJSObject
(
TJSJSON
.
parse
(
XDataWebDataSet1colors
.
Value
));
colorList
:=
TJSArray
(
colorObject
[
'items'
]);
colors
:=
colorList
.
flength
;
console
.
log
(
colorList
);
Cell
.
innerText
:=
IntToStr
(
colors
);
end
;
NewRow
.
appendChild
(
Cell
);
...
...
@@ -340,6 +339,8 @@ begin
begin
for
I
:=
1
to
7
do
begin
if
I
<=
TotalPages
then
begin
PageItem
:=
TJSHTMLElement
(
document
.
createElement
(
'li'
));
PageItem
.
className
:=
'page-item'
;
if
I
=
PageNumber
then
...
...
@@ -359,6 +360,7 @@ begin
PageItem
.
appendChild
(
PageLink
);
PaginationElement
.
appendChild
(
PageItem
);
end
;
end
;
end
else
begin
...
...
kgOrdersServer/Source/Lookup.Service.pas
View file @
b2e1a1b8
...
...
@@ -193,6 +193,7 @@ type
function
DelUser
(
username
:
string
):
string
;
function
EditUser
(
const
editOptions
:
string
):
string
;
function
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
function
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
end
;
implementation
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
b2e1a1b8
...
...
@@ -31,8 +31,9 @@ type
function
AddItem
(
itemInfo
:
string
):
string
;
function
DelUser
(
username
:
string
):
string
;
function
generateSelectSQL
(
filterType
,
startDate
,
endDate
:
string
):
string
;
function
generateSubQuery
(
filterType
:
string
;
currStatus
:
string
):
string
;
function
generateSubQuery
(
filterType
,
statusType
,
currStatus
:
string
):
string
;
function
AddCorrugatedOrder
(
orderInfo
:
string
):
TJSONObject
;
function
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
procedure
AfterConstruction
;
override
;
procedure
BeforeDestruction
;
override
;
end
;
...
...
@@ -99,16 +100,34 @@ begin
end
;
function
TLookupService
.
generateSubQuery
(
filterType
:
string
;
currStatus
:
string
):
string
;
function
TLookupService
.
generateSubQuery
(
filterType
,
statusType
,
currStatus
:
string
):
string
;
var
statusSuffix
:
string
;
begin
result
:=
''
;
if
filterType
<>
currStatus
then
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,'
;
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 = '
+
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
.
GetOrders
(
searchOptions
:
string
):
TOrderList
;
...
...
@@ -122,12 +141,16 @@ var
startDate
:
string
;
endDate
:
string
;
filterType
:
string
;
statusType
:
string
;
statusSuffix
:
string
;
SQL
:
string
;
Order
:
TOrderItem
;
colors
:
string
;
ColorType
:
string
;
whereSQL
:
string
;
fromSQL
:
string
;
statusTableShort
:
string
;
statusTableLong
:
string
;
begin
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
...
...
@@ -140,7 +163,26 @@ begin
OrderBy
:=
params
.
Values
[
'orderby'
];
startDate
:=
params
.
Values
[
'startDate'
];
endDate
:=
params
.
Values
[
'endDate'
];
filterType
:=
params
.
Values
[
'filterType'
];
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
;
if
statusSuffix
=
'DUE'
then
begin
statusTableShort
:=
'oss'
;
statusTableLong
:=
'orders_status_schedule'
;
end
else
begin
statusTableShort
:=
'os'
;
statusTableLong
:=
'orders_status'
;
end
;
offset
:=
IntToStr
((
PageNum
-
1
)
*
PageSize
);
limit
:=
IntToStr
(
PageSize
);
...
...
@@ -148,28 +190,30 @@ begin
if
filterType
<>
''
then
begin
SQL
:=
'SELECT o.ORDER_ID,
oss.STATUS_DATE AS '
+
filterType
.
ToUpper
+
'_DUE'
+
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
:=
SQL
+
generateSubquery
(
filterType
,
'PROOF'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
'ART'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
'PLATE'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
'MOUNT'
);
SQL
:=
SQL
+
generateSubquery
(
filterType
,
'SHIP'
);
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'
);
if
filterType
<>
''
then
begin
whereSQL
:=
'FROM orders o join orders_status_schedule oss on oss.ORDER_ID = o.ORDER_ID join '
+
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 oss.ORDER_ID = o.ORDER_ID AND oss.ORDER_STATUS = '
+
quotedStr
(
filterType
)
+
' AND '
+
quotedStr
(
startDate
)
+
' <= oss.STATUS_DATE AND '
+
quotedStr
(
endDate
)
+
' >= oss.STATUS_DATE'
;
'WHERE '
+
statusTableShort
+
'.ORDER_ID = o.ORDER_ID AND + '
+
statusTableShort
+
'.ORDER_STATUS = '
+
quotedStr
(
statusType
)
+
' AND '
+
quotedStr
(
startDate
)
+
' <= '
+
statusTableShort
+
'.STATUS_DATE AND '
+
quotedStr
(
endDate
)
+
' >= '
+
statusTableShort
+
'.STATUS_DATE'
;
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
+
whereSQL
+
' ORDER BY '
+
filterType
+
'
_DUE
DESC LIMIT '
+
limit
+
' OFFSET '
+
offset
;
SQL
:=
SQL
+
'o.PRICE, qb.QB_REF_NUM '
+
whereSQL
+
' ORDER BY '
+
filterType
+
' DESC LIMIT '
+
limit
+
' OFFSET '
+
offset
;
end
else
begin
...
...
@@ -274,7 +318,6 @@ begin
result
.
staff_fields_art_due
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_art_due'
).
AsString
;
result
.
staff_fields_plate_due
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_plate_due'
).
AsString
;
result
.
staff_fields_price
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsString
;
if
orderType
=
'corrugated_plate_order'
then
result
.
staff_fields_mount_due
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_mount_due'
).
AsString
;
result
.
staff_fields_art_location
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_art_location'
).
AsString
;
...
...
@@ -606,6 +649,7 @@ var
Field
:
TField
;
DateFormat
:
TFormatSettings
;
CurrDate
:
TDateTime
;
ORDER_ID
:
integer
;
begin
DateFormat
:=
TFormatSettings
.
Create
;
DateFormat
.
ShortDateFormat
:=
'yyyy-mm-dd'
;
...
...
@@ -652,6 +696,22 @@ begin
ordersDB
.
UniQuery1
.
Post
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
SQL
.
Text
:=
'SELECT LAST_INSERT_ID() AS OrderID'
;
// Use database's method to get the last inserted ID
ordersDB
.
UniQuery1
.
Open
;
ORDER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'OrderID'
).
AsInteger
;
if
JSONData
.
GetValue
<
string
>(
'staff_fields_proof_date'
)
<>
''
then
AddStatusSchedule
(
'PROOF'
,
JSONData
,
ORDER_ID
);
if
JSONData
.
GetValue
<
string
>(
'staff_fields_ship_date'
)
<>
''
then
AddStatusSchedule
(
'SHIP'
,
JSONData
,
ORDER_ID
);
if
JSONData
.
GetValue
<
string
>(
'staff_fields_art_due'
)
<>
''
then
AddStatusSchedule
(
'ART'
,
JSONData
,
ORDER_ID
);
if
JSONData
.
GetValue
<
string
>(
'staff_fields_plate_due'
)
<>
''
then
AddStatusSchedule
(
'PLATE'
,
JSONData
,
ORDER_ID
);
if
JSONData
.
GetValue
<
string
>(
'staff_fields_mount_due'
)
<>
''
then
AddStatusSchedule
(
'MOUNT'
,
JSONData
,
ORDER_ID
);
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
'success'
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
except
...
...
@@ -665,6 +725,38 @@ begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
'Order Already Exists'
);
end
;
function
TLookupService
.
AddStatusSchedule
(
StatusType
:
string
;
order
:
TJSONObject
;
ORDER_ID
:
integer
):
string
;
var
SQL
:
string
;
temp
:
string
;
begin
SQL
:=
'select * from orders_status_schedule where ORDER_ID = 0 and ORDER_ID <> 0'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ordersDB
.
UniQuery1
.
Insert
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_ID'
).
AsInteger
:=
ORDER_ID
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_STATUS'
).
AsString
:=
StatusType
;
if
(
(
StatusType
=
'PROOF'
)
or
(
StatusType
=
'SHIP'
)
)
then
begin
//temp := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_date');
ordersDB
.
UniQuery1
.
FieldByName
(
'STATUS_DATE'
).
AsString
:=
order
.
GetValue
<
string
>(
'staff_fields_'
+
StatusType
.
ToLower
+
'_date'
);
ordersDB
.
UniQuery1
.
FieldByName
(
'ORIGINAL_STATUS_DATE'
).
AsString
:=
order
.
GetValue
<
string
>(
'staff_fields_'
+
StatusType
.
ToLower
+
'_date'
);
end
else
begin
//temp := order.GetValue<string>('staff_fields_'+ StatusType.ToLower +'_due');
ordersDB
.
UniQuery1
.
FieldByName
(
'STATUS_DATE'
).
AsDateTime
:=
StrToDateTime
(
order
.
GetValue
<
string
>(
'staff_fields_'
+
StatusType
.
ToLower
+
'_due'
));
ordersDB
.
UniQuery1
.
FieldByName
(
'ORIGINAL_STATUS_DATE'
).
AsDateTime
:=
StrToDateTime
(
order
.
GetValue
<
string
>(
'staff_fields_'
+
StatusType
.
ToLower
+
'_due'
));
end
;
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_ID'
).
AsString
:=
order
.
GetValue
<
string
>(
'USER_ID'
);
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_REVISION'
).
AsInteger
:=
1
;
ordersDB
.
UniQuery1
.
Post
;
Result
:=
'success'
;
end
;
function
TLookupService
.
AddUser
(
userInfo
:
string
):
string
;
var
user
:
string
;
...
...
kgOrdersServer/kgOrdersServer.ini
View file @
b2e1a1b8
[Options]
LogFileNum
=
1
68
LogFileNum
=
1
96
UpdateTimerLength
=
0
...
...
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