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
42f8e3e6
Commit
42f8e3e6
authored
Jun 17, 2025
by
Cam Hayes
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/mac3' into cam3
parents
284ccb7b
facf79ff
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1520 additions
and
1264 deletions
+1520
-1264
Utils.pas
kgOrdersClient/Utils.pas
+34
-0
View.Customers.pas
kgOrdersClient/View.Customers.pas
+25
-32
View.EditUser.pas
kgOrdersClient/View.EditUser.pas
+19
-14
View.Items.dfm
kgOrdersClient/View.Items.dfm
+2
-6
View.Items.html
kgOrdersClient/View.Items.html
+1
-1
View.Items.pas
kgOrdersClient/View.Items.pas
+81
-43
View.Main.html
kgOrdersClient/View.Main.html
+21
-0
View.Main.pas
kgOrdersClient/View.Main.pas
+1
-0
View.OrderEntryCorrugated.pas
kgOrdersClient/View.OrderEntryCorrugated.pas
+162
-145
View.OrderEntryCuttingDie.pas
kgOrdersClient/View.OrderEntryCuttingDie.pas
+71
-54
View.OrderEntryWeb.pas
kgOrdersClient/View.OrderEntryWeb.pas
+117
-106
View.Orders.dfm
kgOrdersClient/View.Orders.dfm
+1
-0
View.Orders.pas
kgOrdersClient/View.Orders.pas
+49
-48
View.SelectCustomer.pas
kgOrdersClient/View.SelectCustomer.pas
+17
-12
View.Users.pas
kgOrdersClient/View.Users.pas
+41
-35
webKGOrders.dproj
kgOrdersClient/webKGOrders.dproj
+1
-2
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+874
-763
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+3
-3
No files found.
kgOrdersClient/Utils.pas
View file @
42f8e3e6
...
...
@@ -9,6 +9,7 @@ procedure ShowStatusMessage(const AMessage, AClass: string; const AElementId: st
procedure
HideStatusMessage
(
const
AElementId
:
string
);
procedure
ShowSpinner
(
SpinnerID
:
string
);
procedure
HideSpinner
(
SpinnerID
:
string
);
procedure
ShowErrorModal
(
const
msg
:
string
);
function
CalculateAge
(
DateOfBirth
:
TDateTime
):
Integer
;
function
FormatPhoneNumber
(
PhoneNumber
:
string
):
string
;
procedure
ApplyReportTitle
(
CurrentReportType
:
string
);
...
...
@@ -82,6 +83,39 @@ begin
end
;
end
;
// The $IFNDEF WIN32 was recommended by Holger to deal with any modal issues
procedure
ShowErrorModal
(
const
msg
:
string
);
begin
{$IFNDEF WIN32}
asm
var
modal
=
document
.
getElementById
(
'main_errormodal'
);
var
label
=
document
.
getElementById
(
'main_lblmodal_body'
);
var
reloadBtn
=
document
.
getElementById
(
'btn_modal_restart'
);
if
(
label
)
label
.
innerText
=
msg
;
// Ensure modal is a direct child of <body>
if
(
modal
&&
modal
.
parentNode
!==
document
.
body
)
{
document.body.appendChild(modal);
}
// Bind hard reload to button
if
(
reloadBtn
)
{
reloadBtn.onclick = function () {
window.location.reload(true); // hard reload, bypass cache
}
;
}
// Show the Bootstrap modal
var
bsModal
=
new
bootstrap
.
Modal
(
modal
,
{ keyboard: false }
);
bsModal
.
show
();
end
;
{$ENDIF}
end
;
function
CalculateAge
(
DateOfBirth
:
TDateTime
):
Integer
;
var
...
...
kgOrdersClient/View.Customers.pas
View file @
42f8e3e6
...
...
@@ -125,39 +125,32 @@ begin
if
PageNumber
>
0
then
begin
Utils
.
ShowSpinner
(
'spinner'
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomers'
,
[
searchOptions
]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
// Load data into the dataset
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
[
'data'
]);
xdwdsCustomers
.
Open
;
Utils
.
HideSpinner
(
'spinner'
);
customerListLength
:=
integer
(
customerList
[
'count'
]);
TotalPages
:=
(
(
customerListLength
+
PageSize
-
1
)
div
PageSize
);
if
customerListLength
=
0
then
begin
lblEntries
.
Caption
:=
'No entries found'
;
end
else
if
(
PageNumber
*
PageSize
)
<
customerListLength
then
// Currently these do the same thing. If you want to limit the number of entries
// You will need to edit the server side, and then change this if statement so the label
// Correctly displayes. I believe it is IntToStr(PageSize * PageNum)
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
customerListLength
)
+
' of '
+
IntToStr
(
customerListLength
);
end
else
if
(
PageNumber
*
PageSize
)
>=
customerListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
customerListLength
)
+
' of '
+
IntToStr
(
customerListLength
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomers'
,
[
searchOptions
]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
[
'data'
]);
xdwdsCustomers
.
Open
;
customerListLength
:=
integer
(
customerList
[
'count'
]);
TotalPages
:=
(
(
customerListLength
+
PageSize
-
1
)
div
PageSize
);
if
customerListLength
=
0
then
lblEntries
.
Caption
:=
'No entries found'
else
if
(
PageNumber
*
PageSize
)
<
customerListLength
then
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
customerListLength
)
+
' of '
+
IntToStr
(
customerListLength
)
else
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
customerListLength
)
+
' of '
+
IntToStr
(
customerListLength
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve customers: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
...
...
kgOrdersClient/View.EditUser.pas
View file @
42f8e3e6
...
...
@@ -103,7 +103,7 @@ begin
Utils
.
ShowSpinner
(
'spinner'
);
end
;
function
TFViewEditUser
.
AddUser
()
:
string
;
function
TFViewEditUser
.
AddUser
:
string
;
// Sends UserInfo over to the server so it can be added to the database
var
userInfo
:
string
;
...
...
@@ -111,21 +111,26 @@ var
responseString
:
TJSObject
;
begin
userInfo
:=
'&username='
+
edtUsername
.
Text
+
'&fullname='
+
edtFullName
.
Text
+
'&password='
+
edtPassword
.
Text
+
'&status='
+
BoolToStr
(
cbStatus
.
Checked
)
+
'&email='
+
edtEmail
.
Text
+
'&access='
+
cbAccess
.
Text
+
'&newuser='
+
edtUsername
.
Text
+
'&rights='
+
edtRights
.
Text
+
'&QB='
+
edtQB
.
Text
;
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddUser'
,
[
userInfo
]));
responseString
:=
TJSObject
(
xdcResponse
.
Result
);
Info
:=
string
(
responseString
[
'value'
]);
'&fullname='
+
edtFullName
.
Text
+
'&password='
+
edtPassword
.
Text
+
'&status='
+
BoolToStr
(
cbStatus
.
Checked
)
+
'&email='
+
edtEmail
.
Text
+
'&access='
+
cbAccess
.
Text
+
'&newuser='
+
edtUsername
.
Text
+
'&rights='
+
edtRights
.
Text
+
'&QB='
+
edtQB
.
Text
;
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddUser'
,
[
userInfo
]));
responseString
:=
TJSObject
(
xdcResponse
.
Result
);
Info
:=
string
(
responseString
[
'value'
]);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not add user: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFViewEditUser
.
HideNotification
;
begin
pnlMessage
.
ElementHandle
.
hidden
:=
True
;
...
...
kgOrdersClient/View.Items.dfm
View file @
42f8e3e6
...
...
@@ -48,7 +48,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Add'
ChildOrder = 7
ElementClassName = 'btn btn-light'
ElementID = 'btnadd'
ElementFont = efCSS
HeightStyle = ssAuto
...
...
@@ -110,6 +109,7 @@ object FViewItems: TFViewItems
ElementPosition = epRelative
Role = 'null'
TabOrder = 5
Visible = False
object lblMessage: TWebLabel
Left = 28
Top = 9
...
...
@@ -148,7 +148,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Save'
ChildOrder = 79
ElementClassName = 'btn btn-light'
ElementID = 'btnconfirm'
ElementFont = efCSS
ElementPosition = epRelative
...
...
@@ -160,12 +159,11 @@ object FViewItems: TFViewItems
end
object btnCancel: TWebButton
Left = 565
Top = 25
9
Top = 25
6
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 79
ElementClassName = 'btn btn-light'
ElementID = 'btncancel'
ElementFont = efCSS
ElementPosition = epRelative
...
...
@@ -182,7 +180,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Delete'
ChildOrder = 79
ElementClassName = 'btn btn-light'
ElementID = 'btndelete'
ElementFont = efCSS
HeightStyle = ssAuto
...
...
@@ -197,7 +194,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Edit'
ChildOrder = 83
ElementClassName = 'btn btn-light'
ElementID = 'btnedit'
ElementFont = efCSS
HeightStyle = ssAuto
...
...
kgOrdersClient/View.Items.html
View file @
42f8e3e6
...
...
@@ -62,7 +62,7 @@
</div>
</form>
<table
class=
"table table-responsive table-striped table-bordered"
id=
"tblPhoneGrid"
>
<table
class=
"table table-responsive table-striped table-
hover table-
bordered"
id=
"tblPhoneGrid"
>
<thead
class=
"thead-dark"
>
<tr>
<th
scope=
"col"
>
ID
</th>
...
...
kgOrdersClient/View.Items.pas
View file @
42f8e3e6
...
...
@@ -2,7 +2,7 @@
// to sort the entries, filter their search, and search for a specific person.
// Authors:
// Cameron Hayes
// Mac
...
// Mac
Stephens
unit
View
.
Items
;
...
...
@@ -115,46 +115,74 @@ begin
cbStatus
.
enabled
:=
true
;
end
;
procedure
TFViewItems
.
AddRowToTable
(
ID
,
Name
,
Description
,
Status
:
string
);
// Adds rows to the table
// ID: item ID
// Name: item name
// Description: item description
// Status: inactive or active
// Adds one row to #tblPhoneGrid and lets Bootstrap 5.3 highlight the row
// with its built-in `table-active` class when the user clicks it.
var
NewRow
,
Cell
,
P
,
Button
,
Audio
:
TJSHTMLElement
;
NewRow
,
Cell
:
TJSHTMLElement
;
begin
NewRow
:=
TJSHTMLElement
(
document
.
createElement
(
'tr'
));
// Item ID Cell
// Row-select click handler
NewRow
.
addEventListener
(
'click'
,
procedure
(
Event
:
TJSMouseEvent
)
var
TBody
:
TJSHTMLElement
;
Rows
:
TJSHTMLCollection
;
I
:
Integer
;
RowElem
:
TJSHTMLElement
;
begin
// Grab the <tbody> once and cast it
TBody
:=
TJSHTMLElement
(
(
document
.
getElementById
(
'tblPhoneGrid'
)
as
TJSHTMLElement
)
.
getElementsByTagName
(
'tbody'
)[
0
]
);
// Remove 'table-active' from every existing row
Rows
:=
TBody
.
children
;
for
I
:=
0
to
Rows
.
length
-
1
do
begin
RowElem
:=
TJSHTMLElement
(
Rows
.
item
(
I
));
// ? cast Node ? HTMLElement
RowElem
.
classList
.
remove
(
'table-primary'
);
end
;
// Add highlight to the clicked row
TJSHTMLElement
(
Event
.
currentTarget
).
classList
.
add
(
'table-primary'
);
end
);
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Item ID'
);
Cell
.
innerText
:=
ID
;
NewRow
.
appendChild
(
Cell
);
// Name Cell
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Name'
);
Cell
.
innerText
:=
Name
;
NewRow
.
appendChild
(
Cell
);
// Description Cell
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Description'
);
Cell
.
innerText
:=
Description
;
NewRow
.
appendChild
(
Cell
);
// Status Cell
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Status'
);
Cell
.
innerText
:=
Status
;
NewRow
.
appendChild
(
Cell
);
// Appends new rows to the table body
TJSHTMLElement
(
document
.
getElementById
(
'tblPhoneGrid'
).
getElementsByTagName
(
'tbody'
)[
0
]).
appendChild
(
NewRow
);
TJSHTMLElement
(
(
document
.
getElementById
(
'tblPhoneGrid'
)
as
TJSHTMLElement
)
.
getElementsByTagName
(
'tbody'
)[
0
]
).
appendChild
(
NewRow
);
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFViewItems
.
GeneratePagination
(
TotalPages
:
Integer
);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
...
...
@@ -336,36 +364,41 @@ var
itemListLength
:
integer
;
begin
console
.
log
(
'correct'
);
if
PageNumber
>
0
then
if
PageNumber
>
0
then
begin
Utils
.
ShowSpinner
(
'spinner'
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetItems'
,
[
searchOptions
]));
itemList
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
itemList
[
'data'
]);
itemListLength
:=
integer
(
itemList
[
'count'
]);
ClearTable
();
Utils
.
HideSpinner
(
'Spinner'
);
for
i
:=
0
to
data
.
Length
-
1
do
begin
item
:=
TJSObject
(
data
[
i
]);
AddRowToTable
(
string
(
item
[
'ID'
]),
string
(
item
[
'name'
]),
string
(
item
[
'description'
]),
string
(
item
[
'status'
]));
end
;
TotalPages
:=
(
itemListLength
+
PageSize
-
1
)
div
PageSize
;
if
(
PageNumber
*
PageSize
)
<
itemListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
PageNumber
*
PageSize
)
+
' of '
+
IntToStr
(
itemListLength
);
end
else
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
itemListLength
)
+
' of '
+
IntToStr
(
itemListLength
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetItems'
,
[
searchOptions
]));
itemList
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
itemList
[
'data'
]);
itemListLength
:=
integer
(
itemList
[
'count'
]);
ClearTable
();
for
i
:=
0
to
data
.
Length
-
1
do
begin
item
:=
TJSObject
(
data
[
i
]);
AddRowToTable
(
string
(
item
[
'ID'
]),
string
(
item
[
'name'
]),
string
(
item
[
'description'
]),
string
(
item
[
'status'
]));
end
;
TotalPages
:=
(
itemListLength
+
PageSize
-
1
)
div
PageSize
;
if
(
PageNumber
*
PageSize
)
<
itemListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
PageNumber
*
PageSize
)
+
' of '
+
IntToStr
(
itemListLength
);
end
else
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
itemListLength
)
+
' of '
+
IntToStr
(
itemListLength
);
end
;
GeneratePagination
(
TotalPages
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve items: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
GeneratePagination
(
TotalPages
);
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
...
...
@@ -466,11 +499,16 @@ procedure TFViewItems.AddItem(itemOptions: string);
var
xdcResponse
:
TXDataClientResponse
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddItem'
,
[
itemOptions
]));
getItems
(
GenerateSearchOptions
());
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddItem'
,
[
itemOptions
]));
getItems
(
GenerateSearchOptions
());
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not add item: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFViewItems
.
wcbPageSizeChange
(
Sender
:
TObject
);
// gets a new amount of items based when the page size is changed
begin
...
...
kgOrdersClient/View.Main.html
View file @
42f8e3e6
...
...
@@ -69,6 +69,27 @@
</div>
</div>
<div
class=
"modal fade"
id=
"main_errormodal"
tabindex=
"-1"
aria-labelledby=
"main_lblmodal"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content shadow-lg"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"main_lblmodal"
>
Error
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
<div
class=
"modal-body fs-6 fw-bold"
id=
"main_lblmodal_body"
>
Please contact EMSystems to solve the issue.
</div>
<div
class=
"modal-footer justify-content-center"
>
<button
type=
"button"
id=
"btn_modal_restart"
class=
"btn btn-primary"
>
Restart WebApp
</button>
</div>
</div>
</div>
</div>
kgOrdersClient/View.Main.pas
View file @
42f8e3e6
...
...
@@ -315,4 +315,5 @@ begin
FChildForm
:=
TFViewUsers
.
CreateForm
(
WebPanel1
.
ElementID
,
Info
);
end
;
end
.
kgOrdersClient/View.OrderEntryCorrugated.pas
View file @
42f8e3e6
...
...
@@ -553,17 +553,22 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderCorrugatedPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
try
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderCorrugatedPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate corrugated PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCorrugated
.
AddCorrugatedOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
...
...
@@ -585,10 +590,16 @@ procedure TFOrderEntryCorrugated.DelOrder();
var
Response
:
TXDataClientResponse
;
begin
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.DelOrder'
,
[
OrderID
,
'corrugated'
,
JS
.
toString
(
AuthService
.
TokenPayload
.
Properties
[
'user_id'
])]));
try
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.DelOrder'
,
[
OrderID
,
'corrugated'
,
JS
.
toString
(
AuthService
.
TokenPayload
.
Properties
[
'user_id'
])]));
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not delete order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
class
function
TFOrderEntryCorrugated
.
CreateForm
(
AElementID
,
orderInfo
,
customerInfo
,
mode
,
info
:
string
):
TWebForm
;
var
localMode
:
string
;
...
...
@@ -606,7 +617,6 @@ begin
end
;
end
);
end
;
procedure
TFOrderEntryCorrugated
.
addColorRow
(
num
:
string
;
Color
:
string
;
LPI
:
string
;
Size
:
string
);
...
...
@@ -821,139 +831,142 @@ var
colorListJSON
:
TJSONArray
;
items
:
TJSObject
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
if
XDataWebDataSet1colors_colors
.
Value
<>
''
then
begin
colorObject
:=
TJSObject
(
TJSJSON
.
parse
(
XDataWebDataSet1colors_colors
.
Value
));
colorList
:=
TJSArray
(
colorObject
[
'items'
]);
for
I
:=
0
to
colorList
.
length
-
1
do
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
if
XDataWebDataSet1colors_colors
.
Value
<>
''
then
begin
color
:=
TJSObject
(
colorList
[
i
]);
addColorRow
(
String
(
color
[
'#'
]),
string
(
color
[
'Color'
]),
string
(
color
[
'LPI'
]),
string
(
color
[
'Size'
]));
colorObject
:=
TJSObject
(
TJSJSON
.
parse
(
XDataWebDataSet1colors_colors
.
Value
));
colorList
:=
TJSArray
(
colorObject
[
'items'
]);
for
I
:=
0
to
colorList
.
length
-
1
do
begin
color
:=
TJSObject
(
colorList
[
i
]);
addColorRow
(
String
(
color
[
'#'
]),
string
(
color
[
'Color'
]),
string
(
color
[
'LPI'
]),
string
(
color
[
'Size'
]));
end
;
end
;
end
;
// Check boxes and dates need to be manually set
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
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
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
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
)
else
dtpArtDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
=
''
)
then
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
)
else
dtpMountDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_approved_date
.
AsString
=
''
)
then
dtpApprovedDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_approved_date
.
AsString
)
else
dtpApprovedDate
.
Date
:=
0
;
// Check boxes and dates need to be manually set
if
XDataWebDataSet1supplied_by_customer_existing_
.
AsString
=
'T'
then
cbExistingCuttingDie
.
Checked
:=
true
else
cbExistingCuttingDie
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_ref_art_a
.
AsString
=
'T'
then
cbRefArtAPDF
.
Checked
:=
true
else
cbRefArtAPDF
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_ref_art_p
.
AsString
=
'T'
then
cbRefArtPrintCard
.
Checked
:=
true
else
cbRefArtPrintCard
.
Checked
:=
false
;
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
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
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
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
)
else
dtpArtDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
=
''
)
then
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
)
else
dtpMountDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_approved_date
.
AsString
=
''
)
then
dtpApprovedDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_approved_date
.
AsString
)
else
dtpApprovedDate
.
Date
:=
0
;
// Supplied by customers check boxes
if
XDataWebDataSet1supplied_by_customer_existing_
.
AsString
=
'T'
then
cbExistingCuttingDie
.
Checked
:=
true
else
cbExistingCuttingDie
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_ref_art_a
.
AsString
=
'T'
then
cbRefArtAPDF
.
Checked
:=
true
else
cbRefArtAPDF
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_ref_art_p
.
AsString
=
'T'
then
cbRefArtPrintCard
.
Checked
:=
true
else
cbRefArtPrintCard
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_color_copy
.
AsBoolean
then
cbColorCopy
.
Checked
:=
true
else
cbColorCopy
.
checked
:=
false
;
// Supplied by customers check boxes
if
XDataWebDataSet1supplied_by_customer_ftp
.
AsString
<>
''
then
begin
cbFTP
.
Checked
:=
true
;
end
else
cbFTP
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_color_copy
.
AsBoolean
then
cbColorCopy
.
Checked
:=
true
else
cbColorCopy
.
checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_plates
.
AsBoolean
then
cbPlates
.
Checked
:=
true
else
cbPlates
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_ftp
.
AsString
<>
''
then
begin
cbFTP
.
Checked
:=
true
;
end
else
cbFTP
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_sample_ca
.
AsBoolean
then
cbSampleCarton
.
Checked
:=
true
else
cbSampleCarton
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_plates
.
AsBoolean
then
cbPlates
.
Checked
:=
true
else
cbPlates
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_e_mail
.
AsBoolean
then
cbEmail
.
Checked
:=
true
else
cbSampleCarton
.
Checked
:=
false
;
if
XDataWebDataSet1supplied_by_customer_sample_ca
.
AsBoolean
then
cbSampleCarton
.
Checked
:=
true
else
cbSampleCarton
.
Checked
:=
false
;
// layout
if
XDataWebDataSet1supplied_by_customer_e_mail
.
AsBoolean
then
cbEmail
.
Checked
:=
true
else
cbSampleCarton
.
Checked
:=
false
;
if
XDataWebDataSet1layout_excalibur_die
.
AsBoolean
then
cbExcaliburDie
.
Checked
:=
true
else
cbExcaliburDie
.
Checked
:=
false
;
// layout
if
XDataWebDataSet1layout_excalibur_die
.
AsBoolean
then
cbExcaliburDie
.
Checked
:=
true
else
cbExcaliburDie
.
Checked
:=
false
;
// Mounting check boxes
if
XDataWebDataSet1mounting_loose
.
AsString
<>
''
then
cbLoose
.
Checked
:=
true
else
cbLoose
.
Checked
:=
false
;
if
XDataWebDataSet1mounting_sticky_bak
.
AsString
<>
''
then
cbStickyBak
.
Checked
:=
true
else
cbStickyBak
.
Checked
:=
false
;
// Mounting check boxes
if
XDataWebDataSet1mounting_loose
.
AsString
<>
''
then
cbLoose
.
Checked
:=
true
else
cbLoose
.
Checked
:=
false
;
if
XDataWebDataSet1mounting_full_mount
.
AsString
<>
''
then
cbFullMount
.
Checked
:=
true
else
cbFullMount
.
Checked
:=
false
;
if
XDataWebDataSet1mounting_sticky_bak
.
AsString
<>
''
then
cbStickyBak
.
Checked
:=
true
else
cbStickyBak
.
Checked
:=
false
;
if
XDataWebDataSet1mounting_strip
_mount
.
AsString
<>
''
then
cbStrip
Mount
.
Checked
:=
true
else
cbStrip
Mount
.
Checked
:=
false
;
if
XDataWebDataSet1mounting_full
_mount
.
AsString
<>
''
then
cbFull
Mount
.
Checked
:=
true
else
cbFull
Mount
.
Checked
:=
false
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
order
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
end
;
if
XDataWebDataSet1mounting_strip_mount
.
AsString
<>
''
then
cbStripMount
.
Checked
:=
true
else
cbStripMount
.
Checked
:=
false
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
order
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
end
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCorrugated
.
getCustomer
(
customerID
:
string
);
...
...
@@ -964,31 +977,35 @@ var
address
:
string
;
items
:
TJSObject
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomer'
,
[
customerID
]));
customer
:=
TJSObject
(
xdcResponse
.
Result
);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
customer
);
XDataWebDataSet1
.
Open
;
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomer'
,
[
customerID
]));
customer
:=
TJSObject
(
xdcResponse
.
Result
);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
customer
);
XDataWebDataSet1
.
Open
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
customer
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
customer
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
customer
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
customer
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
dtpOrderDate
.
Date
:=
0
;
dtpProofDate
.
Date
:=
0
;
dtpArtDue
.
Date
:=
0
;
dtpPlateDue
.
Date
:=
0
;
dtpMountDue
.
Date
:=
0
;
dtpShipDate
.
Date
:=
0
;
dtpApprovedDate
.
Date
:=
0
;
dtpOrderDate
.
Date
:=
0
;
dtpProofDate
.
Date
:=
0
;
dtpArtDue
.
Date
:=
0
;
dtpPlateDue
.
Date
:=
0
;
dtpMountDue
.
Date
:=
0
;
dtpShipDate
.
Date
:=
0
;
dtpApprovedDate
.
Date
:=
0
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve customer: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCorrugated
.
WebFormShow
(
Sender
:
TObject
);
...
...
kgOrdersClient/View.OrderEntryCuttingDie.pas
View file @
42f8e3e6
...
...
@@ -394,32 +394,43 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
// Call the server method to generate the PDF
console
.
log
(
orderID
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderCuttingPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
try
// Call the server method to generate the PDF
console
.
log
(
orderID
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderCuttingPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate cutting die PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCuttingDie
.
AddCuttingDieOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
Response
:
TXDataClientResponse
;
jsObj
:
TJSObject
;
begin
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddCuttingDieOrder'
,
[
orderJSON
.
ToString
]));
jsObj
:=
JS
.
TJSObject
(
Response
.
Result
);
if
mode
=
'ADD'
then
OrderID
:=
String
(
jsObj
.
Properties
[
'OrderID'
]);
mode
:=
'EDIT'
;
try
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddCuttingDieOrder'
,
[
orderJSON
.
ToString
]));
jsObj
:=
JS
.
TJSObject
(
Response
.
Result
);
if
mode
=
'ADD'
then
OrderID
:=
String
(
jsObj
.
Properties
[
'OrderID'
]);
mode
:=
'EDIT'
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not save cutting die order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
class
function
TFOrderEntryCuttingDie
.
CreateForm
(
AElementID
,
orderInfo
,
customerInfo
,
mode
,
info
:
string
):
TWebForm
;
var
localMode
:
string
;
...
...
@@ -438,7 +449,6 @@ begin
end
;
end
);
end
;
procedure
TFOrderEntryCuttingDie
.
btnAddClick
(
Sender
:
TObject
);
...
...
@@ -513,50 +523,57 @@ var
data
:
TJSArray
;
order
,
items
:
TJSObject
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCuttingDieOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCuttingDieOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
// Check boxes and dates need to be manually set
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
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
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
dtpShipDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
)
else
dtpShipDate
.
Date
:=
0
;
// Check boxes and dates need to be manually set
console
.
log
(
mode
);
console
.
log
(
XDataWebDataSet1COMPANY_ID
.
AsString
);
if
mode
=
'EDIT'
then
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
console
.
log
(
CustomerID
);
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
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
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
dtpShipDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
)
else
dtpShipDate
.
Date
:=
0
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
order
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
end
;
console
.
log
(
mode
);
console
.
log
(
XDataWebDataSet1COMPANY_ID
.
AsString
);
if
mode
=
'EDIT'
then
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
console
.
log
(
CustomerID
);
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
order
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFOrderEntryCuttingDie
.
getCustomer
(
customerID
:
string
);
// gets a customer from the database then loads the appropiate fields
var
...
...
kgOrdersClient/View.OrderEntryWeb.pas
View file @
42f8e3e6
...
...
@@ -593,32 +593,42 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderWebPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
try
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderWebPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate web order PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryWeb
.
AddWebOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
Response
:
TXDataClientResponse
;
jsObj
:
TJSObject
;
begin
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddWebOrder'
,
[
orderJSON
.
ToString
]));
jsObj
:=
JS
.
TJSObject
(
Response
.
Result
);
if
mode
=
'ADD'
then
OrderID
:=
String
(
jsObj
.
Properties
[
'OrderID'
]);
console
.
log
(
OrderID
);
mode
:=
'EDIT'
;
try
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddWebOrder'
,
[
orderJSON
.
ToString
]));
jsObj
:=
JS
.
TJSObject
(
Response
.
Result
);
if
mode
=
'ADD'
then
OrderID
:=
String
(
jsObj
.
Properties
[
'OrderID'
]);
console
.
log
(
OrderID
);
mode
:=
'EDIT'
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not save web order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
class
function
TFOrderEntryWeb
.
CreateForm
(
AElementID
,
orderInfo
,
customerInfo
,
mode
,
info
:
string
):
TWebForm
;
var
localMode
:
string
;
...
...
@@ -784,107 +794,108 @@ var
colorListJSON
:
TJSONArray
;
items
:
TJSObject
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetWebOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
if
XDataWebDataSet1quantity_and_colors_qty_colors
.
Value
<>
''
then
begin
colorObject
:=
TJSObject
(
TJSJSON
.
parse
(
XDataWebDataSet1quantity_and_colors_qty_colors
.
Value
));
colorList
:=
TJSArray
(
colorObject
[
'items'
]);
for
I
:=
0
to
colorList
.
length
-
1
do
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetWebOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
if
XDataWebDataSet1quantity_and_colors_qty_colors
.
Value
<>
''
then
begin
color
:=
TJSObject
(
colorList
[
i
]);
addColorRow
(
String
(
color
[
'#'
]),
string
(
color
[
'Color'
]),
string
(
color
[
'LPI'
]),
string
(
color
[
'Size'
]));
colorObject
:=
TJSObject
(
TJSJSON
.
parse
(
XDataWebDataSet1quantity_and_colors_qty_colors
.
Value
));
colorList
:=
TJSArray
(
colorObject
[
'items'
]);
for
I
:=
0
to
colorList
.
length
-
1
do
begin
color
:=
TJSObject
(
colorList
[
i
]);
addColorRow
(
String
(
color
[
'#'
]),
string
(
color
[
'Color'
]),
string
(
color
[
'LPI'
]),
string
(
color
[
'Size'
]));
end
;
end
;
end
;
// Dates need to be manually set
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
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
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
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
)
else
dtpArtDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
=
''
)
then
dtpPlateDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
)
else
dtpPlateDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_pdf_date_1
.
AsString
=
''
)
then
dtpPDFDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_pdf_date_1
.
Value
)
else
dtpPDFDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_pdf_date_2
.
AsString
=
''
)
then
dtpPDFDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_pdf_date_2
.
Value
)
else
dtpPDFDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_pdf_date_3
.
AsString
=
''
)
then
dtpPDFDate3
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_pdf_date_3
.
Value
)
else
dtpPDFDate3
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_1
.
AsString
=
''
)
then
dtpInkJetDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_1
.
Value
)
else
dtpInkJetDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_2
.
AsString
=
''
)
then
dtpInkJetDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_2
.
Value
)
else
dtpInkJetDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_3
.
AsString
=
''
)
then
dtpInkJetDate3
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_3
.
Value
)
else
dtpInkJetDate3
.
Date
:=
0
;
// Dates need to be manually set
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
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
)
else
dtpProofDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_ship_date
.
AsString
=
''
)
then
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
)
else
dtpArtDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
=
''
)
then
dtpPlateDue
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_plate_due
.
AsString
)
else
dtpPlateDue
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_color_contrac_date_1
.
AsString
=
''
)
then
dtpColorContractDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_color_contrac_date_1
.
Value
)
else
dtpColorContractDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_pdf_date_1
.
AsString
=
''
)
then
dtpPDFDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_pdf_date_1
.
Value
)
else
dtpPDFDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_pdf_date_2
.
AsString
=
''
)
then
dtpPDFDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_pdf_date_2
.
Value
)
else
dtpPDFDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_pdf_date_3
.
AsString
=
''
)
then
dtpPDFDate3
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_pdf_date_3
.
Value
)
else
dtpPDFDate3
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_color_contrac_date_2
.
AsString
=
''
)
then
dtpColorContractDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_color_contrac_date_2
.
Value
)
else
dtpColorContractDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_1
.
AsString
=
''
)
then
dtpInkJetDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_1
.
Value
)
else
dtpInkJetDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_2
.
AsString
=
''
)
then
dtpInkJetDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_2
.
Value
)
else
dtpInkJetDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_3
.
AsString
=
''
)
then
dtpInkJetDate3
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_3
.
Value
)
else
dtpInkJetDate3
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_digital_color_date_1
.
AsString
=
''
)
then
dtpDigitalColorDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_digital_color_date_1
.
Value
)
else
dtpDigitalColorDate
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_color_contrac_date_1
.
AsString
=
''
)
then
dtpColorContractDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_color_contrac_date_1
.
Value
)
else
dtpColorContractDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_color_contrac_date_2
.
AsString
=
''
)
then
dtpColorContractDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_color_contrac_date_2
.
Value
)
else
dtpColorContractDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_digital_color_date_1
.
AsString
=
''
)
then
dtpDigitalColorDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_digital_color_date_1
.
Value
)
else
dtpDigitalColorDate
.
Date
:=
0
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
order
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
end
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
xdwdsShipTo
.
Close
;
xdwdsShipTo
.
SetJSONData
(
order
[
'ADDRESS_LIST'
]);
xdwdsShipTo
.
Open
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
xdwdsQBItem
.
Close
;
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
end
;
procedure
TFOrderEntryWeb
.
getCustomer
(
customerID
:
string
);
// gets a customer from the database then loads the appropiate fields
...
...
kgOrdersClient/View.Orders.dfm
View file @
42f8e3e6
object FViewOrders: TFViewOrders
Width = 676
Height = 480
Caption = 'main.errorpanel'
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
...
...
kgOrdersClient/View.Orders.pas
View file @
42f8e3e6
...
...
@@ -13,7 +13,7 @@ uses
WEBLib
.
Forms
,
WEBLib
.
Dialogs
,
WEBLib
.
Menus
,
WEBLib
.
ExtCtrls
,
WEBLib
.
StdCtrls
,
WEBLib
.
JSON
,
Auth
.
Service
,
XData
.
Web
.
Client
,
WebLib
.
Storage
,
ConnectionModule
,
App
.
Types
,
Vcl
.
StdCtrls
,
Vcl
.
Controls
,
WEBLib
.
DBCtrls
,
XData
.
Web
.
JsonDataset
,
WEBLib
.
DB
,
Data
.
DB
,
XData
.
Web
.
Dataset
,
XData
.
Web
.
JsonDataset
,
WEBLib
.
DB
,
Data
.
DB
,
XData
.
Web
.
Dataset
,
XData
.
Web
.
DatasetCommon
,
WEBLib
.
Grids
;
type
...
...
@@ -156,23 +156,25 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
searchOptions
:=
edtSearch
.
Text
;
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderListPDF'
,
[
searchOptions
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
begin
Utils
.
HideSpinner
(
'Spinner'
);
Utils
.
ShowSpinner
(
'spinner'
);
try
searchOptions
:=
edtSearch
.
Text
;
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderListPDF'
,
[
searchOptions
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate report PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFViewOrders
.
WebButton1Click
(
Sender
:
TObject
);
begin
if
OrderID
<>
''
then
...
...
@@ -651,57 +653,56 @@ begin
end
);
PageItem
.
appendChild
(
PageLink
);
PaginationElement
.
appendChild
(
PageItem
);
end
;
procedure
TFViewOrders
.
GetOrders
(
searchOptions
:
string
);
// retrieves a list of orders that fit a given search criteria
// searchOptions: search info to be sent to the server
var
xdcResponse
:
TXDataClientResponse
;
orderList
:
TJSObject
;
orderListLength
:
integer
;
TotalPages
:
integer
;
orderListLength
,
TotalPages
:
Integer
;
begin
Utils
.
ShowSpinner
(
'spinner'
);
if
PageNumber
>
0
then
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrders'
,
[
searchOptions
]));
orderList
:=
TJSObject
(
xdcResponse
.
Result
);
try
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrders'
,
[
searchOptions
])
);
// Load data into the dataset
xdwdsOrders
.
Close
;
xdwdsOrders
.
SetJsonData
(
orderList
[
'data'
]);
xdwdsOrders
.
Open
;
orderListLength
:=
integer
(
orderList
[
'count'
]);
TotalPages
:=
(
(
orderListLength
+
PageSize
-
1
)
div
PageSize
);
if
Assigned
(
xdcResponse
.
Result
)
then
begin
orderList
:=
TJSObject
(
xdcResponse
.
Result
);
xdwdsOrders
.
Close
;
xdwdsOrders
.
SetJsonData
(
orderList
[
'data'
]);
xdwdsOrders
.
Open
;
orderListLength
:=
Integer
(
orderList
[
'count'
]);
TotalPages
:=
(
orderListLength
+
PageSize
-
1
)
div
PageSize
;
GeneratePagination
(
TotalPages
);
// Update label
if
orderListLength
=
0
then
lblEntries
.
Caption
:=
'No entries found'
else
if
(
PageNumber
*
PageSize
)
<
orderListLength
then
lblEntries
.
Caption
:=
Format
(
'Showing entries %d - %d of %d'
,
[(
PageNumber
-
1
)
*
PageSize
+
1
,
PageNumber
*
PageSize
,
orderListLength
])
else
lblEntries
.
Caption
:=
Format
(
'Showing entries %d - %d of %d'
,
[(
PageNumber
-
1
)
*
PageSize
+
1
,
orderListLength
,
orderListLength
]);
end
;
if
orderListLength
=
0
then
begin
lblEntries
.
Caption
:=
'No entries found'
;
end
else
if
(
PageNumber
*
PageSize
)
<
orderListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
PageNumber
*
PageSize
)
+
' of '
+
IntToStr
(
orderListLength
);
end
else
if
(
PageNumber
*
PageSize
)
>=
orderListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
orderListLength
)
+
' of '
+
IntToStr
(
orderListLength
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve orders: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
// Optional: Continue using pagination if needed
GeneratePagination
(
TotalPages
);
finally
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
procedure
TFViewOrders
.
btnAddOrderClick
(
Sender
:
TObject
);
begin
ShowAddOrderForm
();
...
...
kgOrdersClient/View.SelectCustomer.pas
View file @
42f8e3e6
...
...
@@ -97,21 +97,26 @@ var
customerList
:
TJSObject
;
i
:
integer
;
begin
// Fetch data from XData service
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.getQBCustomers'
,
[]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
// Load data into TXDataWebDataset
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
);
xdwdsCustomers
.
Open
;
// Manually populate the grid
PopulateGridManually
;
try
// Fetch data from XData service
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.getQBCustomers'
,
[]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
// Load data into TXDataWebDataset
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
);
xdwdsCustomers
.
Open
;
// Manually populate the grid
PopulateGridManually
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve QuickBooks customers: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFSelectCustomer
.
PopulateGridManually
;
// populates the grid with customers manually.
var
...
...
kgOrdersClient/View.Users.pas
View file @
42f8e3e6
...
...
@@ -6,7 +6,7 @@ uses
System
.
SysUtils
,
System
.
Classes
,
Web
,
WEBLib
.
Graphics
,
WEBLib
.
Forms
,
WEBLib
.
Dialogs
,
Vcl
.
Controls
,
Vcl
.
StdCtrls
,
WEBLib
.
StdCtrls
,
WEBLib
.
Controls
,
WEBLib
.
Grids
,
WebLib
.
Lists
,
XData
.
Web
.
Client
,
WEBLib
.
ExtCtrls
,
DB
,
XData
.
Web
.
JsonDataset
,
XData
.
Web
.
Dataset
,
XData
.
Web
.
Connection
,
Vcl
.
Forms
,
WEBLib
.
DBCtrls
,
JS
;
XData
.
Web
.
Dataset
,
XData
.
Web
.
Connection
,
Vcl
.
Forms
,
WEBLib
.
DBCtrls
,
JS
,
Utils
;
type
TFViewUsers
=
class
(
TWebForm
)
...
...
@@ -330,44 +330,50 @@ var
data
:
TJSArray
;
user
:
TJSObject
;
userListLength
:
integer
;
begin
if
PageNumber
>
0
then
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetUsers'
,
[
searchOptions
]));
userList
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
userList
[
'data'
]);
userListLength
:=
integer
(
userList
[
'count'
]);
ClearTable
();
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
userList
[
'data'
]);
XDataWebDataSet1
.
Open
;
for
i
:=
0
to
data
.
Length
-
1
do
begin
user
:=
TJSObject
(
data
[
i
]);
AddRowToTable
(
XDataWebDataSet1userID
.
AsString
,
XDataWebDataSet1username
.
AsString
,
XDataWebDataSet1password
.
AsString
,
XDataWebDataSet1full_name
.
AsString
,
XDataWebDataSet1status
.
AsString
,
XDataWebDataSet1email_address
.
AsString
,
XDataWebDataSet1Atype
.
AsString
,
XDataWebDataSet1perspectiveID
.
AsString
,
XDataWebDataSet1QBID
.
AsString
,
XDataWebDataSet1rights
.
AsInteger
);
XDataWebDataSet1
.
Next
;
end
;
TotalPages
:=
(
userListLength
+
PageSize
-
1
)
div
PageSize
;
if
(
PageNumber
*
PageSize
)
<
userListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
PageNumber
*
PageSize
)
+
' of '
+
IntToStr
(
userListLength
);
end
else
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
userListLength
)
+
' of '
+
IntToStr
(
userListLength
);
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetUsers'
,
[
searchOptions
]));
userList
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
userList
[
'data'
]);
userListLength
:=
integer
(
userList
[
'count'
]);
ClearTable
();
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
userList
[
'data'
]);
XDataWebDataSet1
.
Open
;
for
i
:=
0
to
data
.
Length
-
1
do
begin
user
:=
TJSObject
(
data
[
i
]);
AddRowToTable
(
XDataWebDataSet1userID
.
AsString
,
XDataWebDataSet1username
.
AsString
,
XDataWebDataSet1password
.
AsString
,
XDataWebDataSet1full_name
.
AsString
,
XDataWebDataSet1status
.
AsString
,
XDataWebDataSet1email_address
.
AsString
,
XDataWebDataSet1Atype
.
AsString
,
XDataWebDataSet1perspectiveID
.
AsString
,
XDataWebDataSet1QBID
.
AsString
,
XDataWebDataSet1rights
.
AsInteger
);
XDataWebDataSet1
.
Next
;
end
;
TotalPages
:=
(
userListLength
+
PageSize
-
1
)
div
PageSize
;
if
(
PageNumber
*
PageSize
)
<
userListLength
then
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
PageNumber
*
PageSize
)
+
' of '
+
IntToStr
(
userListLength
);
end
else
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
userListLength
)
+
' of '
+
IntToStr
(
userListLength
);
end
;
GeneratePagination
(
TotalPages
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve users: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
GeneratePagination
(
TotalPages
);
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
...
...
kgOrdersClient/webKGOrders.dproj
View file @
42f8e3e6
...
...
@@ -5,7 +5,7 @@
<FrameworkType>VCL</FrameworkType>
<MainSource>webKGOrders.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">
Release
</Config>
<Config Condition="'$(Config)'==''">
Debug
</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType>
...
...
@@ -208,7 +208,6 @@
<DCCReference Include="Utils.pas"/>
<DCCReference Include="View.AddItem.pas">
<Form>fViewAddItem</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/>
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
42f8e3e6
...
...
@@ -139,35 +139,44 @@ var
SQL
:
string
;
customer
:
TCustomerItem
;
begin
SQL
:=
'select * from customers'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
SQL
:=
'select * from customers'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
:=
TCustomerList
.
Create
;
Result
.
data
:=
TList
<
TCustomerItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
result
.
count
:=
0
;
result
:=
TCustomerList
.
Create
;
Result
.
data
:=
TList
<
TCustomerItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
result
.
count
:=
0
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
customer
:=
TCustomerItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
customer
);
customer
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
customer
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
customer
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
customer
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ADDRESS'
).
AsString
+
', '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_CITY'
).
AsString
+
', '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_STATE'
).
AsString
+
' '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ZIP'
).
AsString
;
customer
.
START_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'START_DATE'
).
AsString
;
result
.
data
.
Add
(
customer
);
result
.
count
:=
result
.
count
+
1
;
ordersDB
.
UniQuery1
.
Next
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
customer
:=
TCustomerItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
customer
);
customer
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
customer
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
customer
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
customer
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ADDRESS'
).
AsString
+
', '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_CITY'
).
AsString
+
', '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_STATE'
).
AsString
+
' '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ZIP'
).
AsString
;
customer
.
START_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'START_DATE'
).
AsString
;
result
.
data
.
Add
(
customer
);
result
.
count
:=
result
.
count
+
1
;
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in GetCustomers: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve customer list: '
+
E
.
Message
);
end
;
end
;
ordersDB
.
UniQuery1
.
Close
;
end
;
function
TLookupService
.
GetCustomer
(
ID
:
string
):
TCustomerItem
;
// Gets one specific customer from the ID given by the client. This is used for
// the OrderEntry forms.
...
...
@@ -176,67 +185,74 @@ var
ADDRESS
:
TAddressItem
;
USER
:
TUserItem
;
begin
if
ID
=
''
then
SQL
:=
'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = -1'
else
SQL
:=
'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
ID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
:=
TCustomerItem
.
Create
;
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
ADDRESS_LIST
);
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ADDRESS_BLOCK'
).
AsString
;
result
.
START_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'START_DATE'
).
AsString
;
result
.
BILL_ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ADDRESS'
).
AsString
;
result
.
BILL_CITY
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_CITY'
).
AsString
;
result
.
BILL_STATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_STATE'
).
AsString
;
result
.
BILL_ZIP
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ZIP'
).
AsString
;
result
.
START_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'START_DATE'
).
AsString
;
result
.
BILL_CONTACT
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_CONTACT'
).
AsString
;
result
.
PHONE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PHONE'
).
AsString
;
result
.
END_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'END_DATE'
).
AsString
;
result
.
QB_LIST_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_LIST_ID'
).
AsString
;
result
.
FFAX
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'FAX'
).
AsString
;
result
.
REP_USER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'REP_USER_ID'
).
AsString
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
ADDRESS
.
shipping_address
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'address'
).
AsString
;
ADDRESS
.
city
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'city'
).
AsString
;
ADDRESS
.
state
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'state'
).
AsString
;
ADDRESS
.
zip
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'zip'
).
AsString
;
ADDRESS
.
contact
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'contact'
).
AsString
;
ADDRESS
.
ship_id
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'customer_ship_id'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
try
if
ID
=
''
then
SQL
:=
'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = -1'
else
SQL
:=
'select * FROM customers c LEFT JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
ID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
:=
TCustomerItem
.
Create
;
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
ADDRESS_LIST
);
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ADDRESS_BLOCK'
).
AsString
;
result
.
START_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'START_DATE'
).
AsString
;
result
.
BILL_ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ADDRESS'
).
AsString
;
result
.
BILL_CITY
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_CITY'
).
AsString
;
result
.
BILL_STATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_STATE'
).
AsString
;
result
.
BILL_ZIP
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_ZIP'
).
AsString
;
result
.
START_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'START_DATE'
).
AsString
;
result
.
BILL_CONTACT
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'BILL_CONTACT'
).
AsString
;
result
.
PHONE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PHONE'
).
AsString
;
result
.
END_DATE
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'END_DATE'
).
AsString
;
result
.
QB_LIST_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_LIST_ID'
).
AsString
;
result
.
FFAX
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'FAX'
).
AsString
;
result
.
REP_USER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'REP_USER_ID'
).
AsString
;
result
.
ITEMS
:=
GetItems
(
''
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
ADDRESS
.
shipping_address
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'address'
).
AsString
;
ADDRESS
.
city
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'city'
).
AsString
;
ADDRESS
.
state
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'state'
).
AsString
;
ADDRESS
.
zip
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'zip'
).
AsString
;
ADDRESS
.
contact
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'contact'
).
AsString
;
ADDRESS
.
ship_id
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'customer_ship_id'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
SQL
:=
'SELECT USER_ID, NAME from users where QB_ID IS NOT NULL AND QB_ID <> '
+
quotedStr
(
''
);
result
.
USERS
:=
TList
<
TUserItem
>.
Create
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
USER
:=
TUserItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
USER
);
USER
.
userID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_ID'
).
AsString
;
USER
.
full_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
USERS
.
Add
(
USER
);
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
result
.
ITEMS
:=
GetItems
(
''
);
SQL
:=
'SELECT USER_ID, NAME from users where QB_ID IS NOT NULL AND QB_ID <> '
+
quotedStr
(
''
);
result
.
USERS
:=
TList
<
TUserItem
>.
Create
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
USER
:=
TUserItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
USER
);
USER
.
userID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_ID'
).
AsString
;
USER
.
full_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
USERS
.
Add
(
USER
);
ordersDB
.
UniQuery1
.
Next
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in GetCustomer: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve customer: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
GenerateOrderListPDF
(
searchOptions
:
string
):
string
;
// Generates a report pdf based on the last search (if any) Linked to rOrders
// file which does most of the work.
...
...
@@ -248,33 +264,37 @@ var
begin
rptOrderList
:=
TrptOrderList
.
Create
(
nil
);
try
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
// parse the searchOptions
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
searchOptions
;
companyID
:=
params
.
Values
[
'companyID'
];
if
companyID
<>
''
then
begin
SQL
:=
'Select NAME from customers c where CUSTOMER_ID = '
+
companyID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
CompanyName
:=
'Company: '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
end
else
CompanyName
:=
''
;
SQL
:=
GenerateOrdersSQL
(
searchOptions
).
SQL
;
result
:=
rptOrderList
.
PrepareReport
(
SQL
,
CompanyName
);
try
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
// parse the searchOptions
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
searchOptions
;
companyID
:=
params
.
Values
[
'companyID'
];
if
companyID
<>
''
then
begin
SQL
:=
'Select NAME from customers c where CUSTOMER_ID = '
+
companyID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
CompanyName
:=
'Company: '
+
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
end
else
CompanyName
:=
''
;
//rptOrderList.GeneratePDF;
SQL
:=
GenerateOrdersSQL
(
searchOptions
).
SQL
;
result
:=
rptOrderList
.
PrepareReport
(
SQL
,
CompanyName
);
// Optionally, log success
Logger
.
log
(
5
,
'PDF Report successfully generated for searchOptions: '
+
searchOptions
);
// Optionally, log success
Logger
.
log
(
5
,
'PDF Report successfully generated for searchOptions: '
+
searchOptions
);
except
on
E
:
Exception
do
raise
EXDataHttpException
.
Create
(
500
,
'Failed to generate PDF: '
+
E
.
Message
);
end
;
finally
rptOrderList
.
Free
;
end
;
end
;
function
TLookupService
.
AddShippingAddress
(
AddressInfo
:
string
):
TJSONObject
;
var
JSONData
:
TJSONObject
;
...
...
@@ -481,7 +501,7 @@ begin
end
;
end
else
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
'Failure:Company Account Name Must Be Unique'
);
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
'Failure:
Company Account Name Must Be Unique'
);
end
;
function
TLookupService
.
GenerateOrderCorrugatedPDF
(
orderID
:
string
):
string
;
...
...
@@ -491,14 +511,22 @@ var
begin
rptOrderCorrugated
:=
TrptOrderCorrugated
.
Create
(
nil
);
try
// Generate SQL query for a single order
SQL
:=
'SELECT * FROM corrugated_plate_orders WHERE ORDER_ID = '
+
orderID
;
try
// Generate SQL query for a single order
SQL
:=
'SELECT * FROM corrugated_plate_orders WHERE ORDER_ID = '
+
orderID
;
// Prepare the report with the query
Result
:=
rptOrderCorrugated
.
PrepareReport
(
SQL
);
// Prepare the report with the query
Result
:=
rptOrderCorrugated
.
PrepareReport
(
SQL
);
// Optionally log success
Logger
.
Log
(
5
,
'PDF Report successfully generated for order ID: '
+
orderID
);
// Optionally log success
Logger
.
Log
(
5
,
'PDF Report successfully generated for order ID: '
+
orderID
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
1
,
'Error generating corrugated PDF: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Error generating corrugated PDF: '
+
E
.
Message
);
end
;
end
;
finally
rptOrderCorrugated
.
Free
;
end
;
...
...
@@ -511,15 +539,23 @@ var
begin
rptOrderWeb
:=
TrptOrderWeb
.
Create
(
nil
);
try
// Generate SQL query for a single order
//SQL := 'SELECT * FROM web_plate_orders w WHERE w.ORDER_ID = ' + orderID ;
SQL
:=
'SELECT * FROM web_plate_orders w LEFT JOIN qb_sales_orders q ON w.ORDER_ID = q.ORDER_ID WHERE w.ORDER_ID = '
+
orderID
;
try
// Generate SQL query for a single order
//SQL := 'SELECT * FROM web_plate_orders w WHERE w.ORDER_ID = ' + orderID ;
SQL
:=
'SELECT * FROM web_plate_orders w LEFT JOIN qb_sales_orders q ON w.ORDER_ID = q.ORDER_ID WHERE w.ORDER_ID = '
+
orderID
;
// Prepare the report with the query
Result
:=
rptOrderWeb
.
PrepareReport
(
SQL
);
// Prepare the report with the query
Result
:=
rptOrderWeb
.
PrepareReport
(
SQL
);
// Optionally log success
Logger
.
Log
(
5
,
'PDF Report successfully generated for order ID: '
+
orderID
);
// Optionally log success
Logger
.
Log
(
5
,
'PDF Report successfully generated for order ID: '
+
orderID
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
1
,
'Error generating web PDF: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Error generating web PDF: '
+
E
.
Message
);
end
;
end
;
finally
rptOrderWeb
.
Free
;
end
;
...
...
@@ -532,20 +568,29 @@ var
begin
rptOrderCutting
:=
TrptOrderCutting
.
Create
(
nil
);
try
// Generate SQL query for a single order
SQL
:=
'SELECT * FROM cutting_die_orders WHERE ORDER_ID = '
+
orderID
;
try
// Generate SQL query for a single order
SQL
:=
'SELECT * FROM cutting_die_orders WHERE ORDER_ID = '
+
orderID
;
// Prepare the report with the query
Result
:=
rptOrderCutting
.
PrepareReport
(
SQL
);
// Prepare the report with the query
Result
:=
rptOrderCutting
.
PrepareReport
(
SQL
);
// Optionally log success
Logger
.
Log
(
5
,
'PDF Report successfully generated for order ID: '
+
orderID
);
// Optionally log success
Logger
.
Log
(
5
,
'PDF Report successfully generated for order ID: '
+
orderID
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
1
,
'Error generating cutting die PDF: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Error generating cutting die PDF: '
+
E
.
Message
);
end
;
end
;
finally
rptOrderCutting
.
Free
;
end
;
end
;
function
TLookupService
.
generateSubQuery
(
currStatus
:
string
):
string
;
// Generates the subquery in order to retrieve all the status due/done dates
// This must be a subquery because there are at most 5 different entries which
...
...
@@ -818,13 +863,14 @@ var
SQLQuery
:
TSQLQuery
;
begin
SQLQuery
:=
generateOrdersSQL
(
searchOptions
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
SQLQuery
);
// Added SQLQuery to ManagedObjects
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
SQLQuery
);
Result
:=
TOrderList
.
Create
;
try
Result
.
data
:=
TList
<
TOrderItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
Result
.
data
:=
TList
<
TOrderItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
try
SQL
:=
SQLQuery
.
SQL
;
whereSQL
:=
SQLQuery
.
whereSQL
;
...
...
@@ -836,24 +882,27 @@ begin
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Order
);
Result
.
data
.
Add
(
Order
);
Order
.
DBID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_ID'
).
AsString
;
Order
.
ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
Order
.
companyName
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_NAME'
).
AsString
;
Order
.
jobName
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'JOB_NAME'
).
AsString
;
Order
.
orderDate
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_DATE'
).
AsString
;
Order
.
proofDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PROOF_DUE'
).
AsString
;
Order
.
proofDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PROOF_DONE'
).
AsString
;
Order
.
artDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ART_DUE'
).
AsString
;
Order
.
artDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ART_DONE'
).
AsString
;
Order
.
plateDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PLATE_DUE'
).
AsString
;
Order
.
plateDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PLATE_DONE'
).
AsString
;
Order
.
mountDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'MOUNT_DUE'
).
AsString
;
Order
.
mountDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'MOUNT_DONE'
).
AsString
;
Order
.
shipDue
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHIP_DUE'
).
AsString
;
Order
.
shipDone
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHIP_DONE'
).
AsString
;
Order
.
price
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PRICE'
).
AsString
;
Order
.
qbRefNum
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_REF_NUM'
).
AsString
;
Order
.
orderType
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
.
Replace
(
'_'
,
' '
);
with
ordersDB
.
UniQuery1
do
begin
Order
.
DBID
:=
FieldByName
(
'ORDER_ID'
).
AsString
;
Order
.
ID
:=
FieldByName
(
'SHORT_NAME'
).
AsString
;
Order
.
companyName
:=
FieldByName
(
'COMPANY_NAME'
).
AsString
;
Order
.
jobName
:=
FieldByName
(
'JOB_NAME'
).
AsString
;
Order
.
orderDate
:=
FieldByName
(
'ORDER_DATE'
).
AsString
;
Order
.
proofDue
:=
FieldByName
(
'PROOF_DUE'
).
AsString
;
Order
.
proofDone
:=
FieldByName
(
'PROOF_DONE'
).
AsString
;
Order
.
artDue
:=
FieldByName
(
'ART_DUE'
).
AsString
;
Order
.
artDone
:=
FieldByName
(
'ART_DONE'
).
AsString
;
Order
.
plateDue
:=
FieldByName
(
'PLATE_DUE'
).
AsString
;
Order
.
plateDone
:=
FieldByName
(
'PLATE_DONE'
).
AsString
;
Order
.
mountDue
:=
FieldByName
(
'MOUNT_DUE'
).
AsString
;
Order
.
mountDone
:=
FieldByName
(
'MOUNT_DONE'
).
AsString
;
Order
.
shipDue
:=
FieldByName
(
'SHIP_DUE'
).
AsString
;
Order
.
shipDone
:=
FieldByName
(
'SHIP_DONE'
).
AsString
;
Order
.
price
:=
FieldByName
(
'PRICE'
).
AsString
;
Order
.
qbRefNum
:=
FieldByName
(
'QB_REF_NUM'
).
AsString
;
Order
.
orderType
:=
FieldByName
(
'ORDER_TYPE'
).
AsString
.
Replace
(
'_'
,
' '
);
end
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
=
'web_plate'
then
begin
...
...
@@ -878,10 +927,14 @@ begin
SQL
:=
'SELECT COUNT(*) AS total_count '
+
whereSQL
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
.
count
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'total_count'
).
AsInteger
;
ordersDB
.
UniQuery1
.
Close
;
except
Result
.
Free
;
// Cleaned up memory in case of exceptions
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in GetOrders: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve order list: '
+
E
.
Message
);
end
;
end
;
end
;
...
...
@@ -898,198 +951,207 @@ var
ADDRESS
:
TAddressItem
;
begin
orderID
:=
orderInfo
;
SQL
:=
'select ORDER_TYPE from orders where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
orderType
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
;
if
orderType
=
'web_plate'
then
table
:=
'web_plate_orders'
else
table
:=
'corrugated_plate_orders'
;
SQL
:=
'select * from '
+
table
+
' o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
:=
TFullOrder
.
Create
;
// Company
result
.
COMPANY_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_ID'
).
AsInteger
;
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
inQuickBooks
:=
'?'
;
// Staff Fields
result
.
staff_fields_order_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_order_date'
).
AsString
;
result
.
staff_fields_proof_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_proof_date'
).
AsString
;
result
.
staff_fields_ship_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_date'
).
AsString
;
result
.
staff_fields_ship_via
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_via'
).
AsString
;
result
.
staff_fields_quantity
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
;
result
.
staff_fields_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_to'
).
AsString
;
result
.
staff_fields_po_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_po_number'
).
AsString
;
result
.
staff_fields_job_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_job_name'
).
AsString
;
result
.
staff_fields_quickbooks_item
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quickbooks_item'
).
AsString
;
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
;
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
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_invoice_to'
).
AsString
;
// Supplied by Customer
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_b_w_copy'
).
AsString
=
'T'
then
result
.
supplied_by_customer_b_w_copy
:=
true
else
result
.
supplied_by_customer_b_w_copy
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_color_copy'
).
AsString
=
'T'
then
result
.
supplied_by_customer_color_copy
:=
true
else
result
.
supplied_by_customer_color_copy
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_plates'
).
AsString
=
'T'
then
result
.
supplied_by_customer_plates
:=
true
else
result
.
supplied_by_customer_plates
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_sample_ca'
).
AsString
=
'T'
then
result
.
supplied_by_customer_sample_ca
:=
true
else
result
.
supplied_by_customer_sample_ca
:=
false
;
result
.
supplied_by_customer_dimension
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_dimension'
).
AsString
;
if
orderType
=
'web_plate'
then
begin
{if ordersDB.UniQuery1.FieldByName('supplied_by_customer_disk').AsString = 'T' then
result.diskOrCD := true
else
result.diskOrCD := false;}
end
else
begin
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_disk_or_cd'
).
AsString
=
'T'
then
result
.
supplied_by_customer_disk_or_cd
:=
true
else
result
.
supplied_by_customer_disk_or_cd
:=
false
;
end
;
result
.
supplied_by_customer_e_mail
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_e_mail'
).
AsString
;
result
.
supplied_by_customer_ftp
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ftp'
).
AsString
;
result
.
supplied_by_customer_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_other'
).
AsString
;
if
orderType
=
'corrugated_plate'
then
begin
result
.
supplied_by_customer_existing_
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_existing_'
).
AsString
;
result
.
supplied_by_customer_ref_art_p
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ref_art_p'
).
AsString
;
result
.
supplied_by_customer_ref_art_a
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ref_art_a'
).
AsString
;
end
;
// Layout
if
orderType
=
'corrugated_plate'
then
begin
result
.
layout_rsc_l
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rsc_l'
).
AsString
;
result
.
layout_rcs_w
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rcs_w'
).
AsString
;
result
.
layout_rcs_d
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rcs_d'
).
AsString
;
result
.
layout_die_cut_no
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_die_cut_no'
).
AsString
;
result
.
layout_accross_no
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_accross_no'
).
AsString
;
result
.
layout_around_no
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_around_no'
).
AsString
;
result
.
layout_cad_file
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cad_file'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_excalibur_die'
).
AsString
=
'T'
then
result
.
layout_excalibur_die
:=
true
try
SQL
:=
'select ORDER_TYPE from orders where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
orderType
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_TYPE'
).
AsString
;
if
orderType
=
'web_plate'
then
table
:=
'web_plate_orders'
else
result
.
layout_excalibur_die
:=
false
;
result
.
layout_rsc_style
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rsc_style'
).
AsString
;
end
else
begin
//result.acrossNo := ordersDB.UniQuery1.FieldByName('layout_accross').AsString;
//result.aroundNo := ordersDB.UniQuery1.FieldByName('layout_around').AsString;
end
;
table
:=
'corrugated_plate_orders'
;
SQL
:=
'select * from '
+
table
+
' o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
// Mounting & Colors & Proofing
if
orderType
=
'corrugated_plate'
then
begin
result
.
mounting_loose
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_loose'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_sticky_bak'
).
AsString
=
'T'
then
result
.
mounting_sticky_bak
:=
true
result
:=
TFullOrder
.
Create
;
// Company
result
.
COMPANY_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_ID'
).
AsInteger
;
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
inQuickBooks
:=
'?'
;
// Staff Fields
result
.
staff_fields_order_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_order_date'
).
AsString
;
result
.
staff_fields_proof_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_proof_date'
).
AsString
;
result
.
staff_fields_ship_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_date'
).
AsString
;
result
.
staff_fields_ship_via
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_via'
).
AsString
;
result
.
staff_fields_quantity
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
;
result
.
staff_fields_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_to'
).
AsString
;
result
.
staff_fields_po_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_po_number'
).
AsString
;
result
.
staff_fields_job_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_job_name'
).
AsString
;
result
.
staff_fields_quickbooks_item
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quickbooks_item'
).
AsString
;
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
;
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
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_invoice_to'
).
AsString
;
// Supplied by Customer
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_b_w_copy'
).
AsString
=
'T'
then
result
.
supplied_by_customer_b_w_copy
:=
true
else
result
.
mounting_sticky_bak
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'
mounting_full_mount
'
).
AsString
=
'T'
then
result
.
mounting_full_mount
:=
true
result
.
supplied_by_customer_b_w_copy
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'
supplied_by_customer_color_copy
'
).
AsString
=
'T'
then
result
.
supplied_by_customer_color_copy
:=
true
else
result
.
mounting_full_mount
:=
false
;
result
.
mounting_strip_mount
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_strip_mount'
).
AsString
;
result
.
mounting_standard_setup
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_standard_setup'
).
AsString
;
result
.
mounting_custom_backing
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_custom_backing'
).
AsString
;
result
.
mounting_custom_adhesive
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_custom_adhesive'
).
AsString
;
result
.
colors_cylinder_size
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_cylinder_size'
).
AsString
;
result
.
colors_machine_ident
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_machine_ident'
).
AsString
;
result
.
colors_cross_hairs
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_cross_hairs'
).
AsString
;
result
.
colors_clemson
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_clemson'
).
AsString
;
result
.
colors_colors
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_colors'
).
AsString
;
result
.
proofing_fax
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_fax'
).
AsString
;
result
.
proofing_fax_attn
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_fax_attn'
).
AsString
;
result
.
proofing_e_mail
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_e_mail'
).
AsString
;
result
.
proofing_e_mail_attn
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_e_mail_attn'
).
AsString
;
result
.
proofing_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ship_to'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_full_size_panel'
).
AsString
=
'T'
then
result
.
proofing_full_size_panel
:=
true
result
.
supplied_by_customer_color_copy
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_plates'
).
AsString
=
'T'
then
result
.
supplied_by_customer_plates
:=
true
else
result
.
proofing_full_size_panel
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'
proofing_print_card'
).
AsString
=
'T'
then
result
.
proofing_print_card
:=
true
result
.
supplied_by_customer_plates
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'
supplied_by_customer_sample_ca'
).
AsString
=
'T'
then
result
.
supplied_by_customer_sample_ca
:=
true
else
result
.
proofing_print_card
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_wide_format'
).
AsString
=
'T'
then
result
.
proofing_wide_format
:=
true
else
result
.
proofing_wide_format
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_file'
).
AsString
=
'T'
then
result
.
proofing_pdf_file
:=
true
result
.
supplied_by_customer_sample_ca
:=
false
;
result
.
supplied_by_customer_dimension
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_dimension'
).
AsString
;
if
orderType
=
'web_plate'
then
begin
{if ordersDB.UniQuery1.FieldByName('supplied_by_customer_disk').AsString = 'T' then
result.diskOrCD := true
else
result.diskOrCD := false;}
end
else
result
.
proofing_pdf_file
:=
false
;
result
.
proofing_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_other'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_art_approved_as_is'
).
AsString
=
'T'
then
result
.
proofing_art_approved_as_is
:=
true
begin
if
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_disk_or_cd'
).
AsString
=
'T'
then
result
.
supplied_by_customer_disk_or_cd
:=
true
else
result
.
supplied_by_customer_disk_or_cd
:=
false
;
end
;
result
.
supplied_by_customer_e_mail
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_e_mail'
).
AsString
;
result
.
supplied_by_customer_ftp
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ftp'
).
AsString
;
result
.
supplied_by_customer_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_other'
).
AsString
;
if
orderType
=
'corrugated_plate'
then
begin
result
.
supplied_by_customer_existing_
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_existing_'
).
AsString
;
result
.
supplied_by_customer_ref_art_p
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ref_art_p'
).
AsString
;
result
.
supplied_by_customer_ref_art_a
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ref_art_a'
).
AsString
;
end
;
// Layout
if
orderType
=
'corrugated_plate'
then
begin
result
.
layout_rsc_l
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rsc_l'
).
AsString
;
result
.
layout_rcs_w
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rcs_w'
).
AsString
;
result
.
layout_rcs_d
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rcs_d'
).
AsString
;
result
.
layout_die_cut_no
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_die_cut_no'
).
AsString
;
result
.
layout_accross_no
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_accross_no'
).
AsString
;
result
.
layout_around_no
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_around_no'
).
AsString
;
result
.
layout_cad_file
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cad_file'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_excalibur_die'
).
AsString
=
'T'
then
result
.
layout_excalibur_die
:=
true
else
result
.
layout_excalibur_die
:=
false
;
result
.
layout_rsc_style
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_rsc_style'
).
AsString
;
end
else
result
.
proofing_art_approved_as_is
:=
false
;
result
.
proofing_approved_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_approved_date'
).
AsString
;
end
else
begin
{result.colors := ordersDB.UniQuery1.FieldByName('quatity_and_colors_qty_colors').AsString;
if ordersDB.UniQuery1.FieldByName('proofing_pdf').AsString = 'T'then
result.pdfFile := true
begin
//result.acrossNo := ordersDB.UniQuery1.FieldByName('layout_accross').AsString;
//result.aroundNo := ordersDB.UniQuery1.FieldByName('layout_around').AsString;
end
;
// Mounting & Colors & Proofing
if
orderType
=
'corrugated_plate'
then
begin
result
.
mounting_loose
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_loose'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_sticky_bak'
).
AsString
=
'T'
then
result
.
mounting_sticky_bak
:=
true
else
result
.
mounting_sticky_bak
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_full_mount'
).
AsString
=
'T'
then
result
.
mounting_full_mount
:=
true
else
result
.
mounting_full_mount
:=
false
;
result
.
mounting_strip_mount
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_strip_mount'
).
AsString
;
result
.
mounting_standard_setup
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_standard_setup'
).
AsString
;
result
.
mounting_custom_backing
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_custom_backing'
).
AsString
;
result
.
mounting_custom_adhesive
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'mounting_custom_adhesive'
).
AsString
;
result
.
colors_cylinder_size
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_cylinder_size'
).
AsString
;
result
.
colors_machine_ident
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_machine_ident'
).
AsString
;
result
.
colors_cross_hairs
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_cross_hairs'
).
AsString
;
result
.
colors_clemson
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_clemson'
).
AsString
;
result
.
colors_colors
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'colors_colors'
).
AsString
;
result
.
proofing_fax
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_fax'
).
AsString
;
result
.
proofing_fax_attn
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_fax_attn'
).
AsString
;
result
.
proofing_e_mail
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_e_mail'
).
AsString
;
result
.
proofing_e_mail_attn
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_e_mail_attn'
).
AsString
;
result
.
proofing_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ship_to'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_full_size_panel'
).
AsString
=
'T'
then
result
.
proofing_full_size_panel
:=
true
else
result
.
proofing_full_size_panel
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_print_card'
).
AsString
=
'T'
then
result
.
proofing_print_card
:=
true
else
result
.
proofing_print_card
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_wide_format'
).
AsString
=
'T'
then
result
.
proofing_wide_format
:=
true
else
result
.
proofing_wide_format
:=
false
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_file'
).
AsString
=
'T'
then
result
.
proofing_pdf_file
:=
true
else
result
.
proofing_pdf_file
:=
false
;
result
.
proofing_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_other'
).
AsString
;
if
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_art_approved_as_is'
).
AsString
=
'T'
then
result
.
proofing_art_approved_as_is
:=
true
else
result
.
proofing_art_approved_as_is
:=
false
;
result
.
proofing_approved_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_approved_date'
).
AsString
;
end
else
result.pdfFile := false;}
end
;
begin
{result.colors := ordersDB.UniQuery1.FieldByName('quatity_and_colors_qty_colors').AsString;
if ordersDB.UniQuery1.FieldByName('proofing_pdf').AsString = 'T'then
result.pdfFile := true
else
result.pdfFile := false;}
end
;
// Plates
result
.
plates_thickness
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_thickness'
).
AsString
;
result
.
plates_plate_material
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_plate_material'
).
AsString
;
result
.
plates_job_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_job_number'
).
AsString
;
// Plates
result
.
plates_thickness
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_thickness'
).
AsString
;
result
.
plates_plate_material
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_plate_material'
).
AsString
;
result
.
plates_job_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_job_number'
).
AsString
;
// General
if
orderType
=
'corrugated_plate'
then
result
.
general_special_instructions
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
else
//result.specialInstructions := ordersDB.UniQuery1.FieldByName('general_comments').AsString
// General
if
orderType
=
'corrugated_plate'
then
result
.
general_special_instructions
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
else
//result.specialInstructions := ordersDB.UniQuery1.FieldByName('general_comments').AsString
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
IntToStr
(
result
.
COMPANY_ID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
ADDRESS_LIST
);
SQL
:=
'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
IntToStr
(
result
.
COMPANY_ID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
ADDRESS_LIST
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
result
.
ITEMS
:=
GetItems
(
''
);
result
.
ITEMS
:=
GetItems
(
''
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in GetOrder: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve order: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
GetWebOrder
(
orderInfo
:
string
):
TWebOrder
;
var
orderType
:
string
;
...
...
@@ -1097,136 +1159,142 @@ var
SQL
:
string
;
ADDRESS
:
TAddressItem
;
begin
orderID
:=
orderInfo
;
SQL
:=
'select * from web_plate_orders o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
:=
TWebOrder
.
Create
;
// Company
result
.
COMPANY_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_ID'
).
AsInteger
;
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
inQuickBooks
:=
'?'
;
// Staff Fields
result
.
staff_fields_order_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_order_date'
).
AsString
;
result
.
staff_fields_proof_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_proof_date'
).
AsString
;
result
.
staff_fields_ship_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_date'
).
AsString
;
result
.
staff_fields_ship_via
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_via'
).
AsString
;
result
.
staff_fields_quantity
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
;
result
.
staff_fields_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_to'
).
AsString
;
result
.
staff_fields_po_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_po_number'
).
AsString
;
result
.
staff_fields_job_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_job_name'
).
AsString
;
result
.
staff_fields_quickbooks_item
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quickbooks_item'
).
AsString
;
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
;
result
.
staff_fields_art_location
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_art_location'
).
AsString
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_invoice_to'
).
AsString
;
// Supplied by Customer
result
.
supplied_by_customer_b_w_or_co
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_b_w_or_co'
).
AsString
;
result
.
supplied_by_customer_plates
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_plates'
).
AsString
;
result
.
supplied_by_customer_sample
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_sample'
).
AsString
;
result
.
supplied_by_customer_dimension
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_dimension'
).
AsString
;
result
.
supplied_by_customer_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_other'
).
AsString
;
result
.
supplied_by_customer_disk
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_disk'
).
AsString
;
result
.
supplied_by_customer_e_mail
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_e_mail'
).
AsString
;
result
.
supplied_by_customer_ftp
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ftp'
).
AsString
;
result
.
supplied_by_customer_total_inc
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_total_inc'
).
AsString
;
result
.
supplied_by_customer_sheets_us
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_sheets_us'
).
AsString
;
result
.
supplied_by_customer_initials
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_initials'
).
AsString
;
// Proofing
result
.
proofing_pdf
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf'
).
AsBoolean
;
result
.
proofing_pdf_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_to'
).
AsString
;
result
.
proofing_pdf_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_date_1'
).
AsString
;
result
.
proofing_pdf_date_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_date_2'
).
AsString
;
result
.
proofing_pdf_date_3
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_date_3'
).
AsString
;
result
.
proofing_full_size_ink_jet_for
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_full_size_ink_jet_for'
).
AsBoolean
;
result
.
proofing_ink_jet_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_to'
).
AsString
;
result
.
proofing_ink_jet_to_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_to'
).
AsString
;
result
.
proofing_ink_jet_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_date_1'
).
AsString
;
result
.
proofing_ink_jet_date_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_date_2'
).
AsString
;
result
.
proofing_color_contract
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contract'
).
AsString
;
result
.
proofing_color_contrac_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contrac_to'
).
AsString
;
result
.
proofing_color_contrac_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contrac_date_1'
).
AsString
;
result
.
proofing_color_contrac_date_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contrac_date_2'
).
AsString
;
result
.
proofing_digital_color_key
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_digital_color_key'
).
AsString
;
result
.
proofing_digital_color_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_digital_color_to'
).
AsString
;
result
.
proofing_digital_color_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_digital_color_date_1'
).
AsString
;
// Colors
result
.
quantity_and_colors_press_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'quantity_and_colors_press_name'
).
AsString
;
result
.
quantity_and_colors_anilox_info
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'quantity_and_colors_anilox_info'
).
AsString
;
result
.
quantity_and_colors_qty_colors
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'quantity_and_colors_qty_colors'
).
AsString
;
// Plate Marks
result
.
plate_marks_microdots
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_microdots'
).
AsString
;
result
.
plate_marks_microdots_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_microdots_comments'
).
AsString
;
result
.
plate_marks_crosshairs
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_crosshairs'
).
AsString
;
result
.
plate_marks_crosshairs_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_crosshairs'
).
AsString
;
result
.
plate_marks_color_bars
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_color_bars'
).
AsString
;
result
.
plate_marks_color_bars_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_color_bars_comments'
).
AsString
;
result
.
plate_marks_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_other'
).
AsString
;
result
.
plate_marks_other_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_other_comments'
).
AsString
;
// Print Orientation
result
.
print_orientation_print_orient
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'print_orientation_print_orient'
).
AsString
;
// Plate
result
.
plates_plate_material
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_plate_material'
).
AsString
;
result
.
plates_thickness
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_thickness'
).
AsString
;
result
.
plates_job_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_job_number'
).
AsString
;
// Layout
result
.
layout_around
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_around'
).
AsString
;
result
.
layout_accross
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_accross'
).
AsString
;
result
.
layout_surface_print
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_surface_print'
).
AsString
;
result
.
layout_reverse_print
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_reverse_print'
).
AsString
;
result
.
layout_cylinder_repeat
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cylinder_repeat'
).
AsString
;
result
.
layout_cutoff_dimension
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cutoff_dimension'
).
AsString
;
result
.
layout_pitch
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_pitch'
).
AsString
;
result
.
layout_teeth
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_teeth'
).
AsString
;
result
.
layout_bleed
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_bleed'
).
AsString
;
result
.
layout_cutback
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cutback'
).
AsString
;
result
.
layout_minimum_trap_dim
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_minimum_trap_dim'
).
AsString
;
result
.
layout_maximum_trap_dim
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_maximum_trap_dim'
).
AsString
;
// UPC
result
.
upc_size
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_size'
).
AsString
;
result
.
upc_bar_width_reduction
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_bar_width_reduction'
).
AsString
;
result
.
upc_distortion_percent
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_distortion_percent'
).
AsString
;
result
.
upc_distortion_amount
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_distortion_amount'
).
AsString
;
// General
result
.
general_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'general_comments'
).
AsString
;
try
orderID
:=
orderInfo
;
SQL
:=
'select * from web_plate_orders o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ordersDB
.
UniQuery1
.
Close
;
result
:=
TWebOrder
.
Create
;
// Company
result
.
COMPANY_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_ID'
).
AsInteger
;
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
inQuickBooks
:=
'?'
;
// Staff Fields
result
.
staff_fields_order_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_order_date'
).
AsString
;
result
.
staff_fields_proof_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_proof_date'
).
AsString
;
result
.
staff_fields_ship_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_date'
).
AsString
;
result
.
staff_fields_ship_via
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_via'
).
AsString
;
result
.
staff_fields_quantity
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
;
result
.
staff_fields_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_to'
).
AsString
;
result
.
staff_fields_po_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_po_number'
).
AsString
;
result
.
staff_fields_job_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_job_name'
).
AsString
;
result
.
staff_fields_quickbooks_item
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quickbooks_item'
).
AsString
;
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
;
result
.
staff_fields_art_location
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_art_location'
).
AsString
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_invoice_to'
).
AsString
;
// Supplied by Customer
result
.
supplied_by_customer_b_w_or_co
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_b_w_or_co'
).
AsString
;
result
.
supplied_by_customer_plates
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_plates'
).
AsString
;
result
.
supplied_by_customer_sample
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_sample'
).
AsString
;
result
.
supplied_by_customer_dimension
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_dimension'
).
AsString
;
result
.
supplied_by_customer_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_other'
).
AsString
;
result
.
supplied_by_customer_disk
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_disk'
).
AsString
;
result
.
supplied_by_customer_e_mail
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_e_mail'
).
AsString
;
result
.
supplied_by_customer_ftp
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_ftp'
).
AsString
;
result
.
supplied_by_customer_total_inc
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_total_inc'
).
AsString
;
result
.
supplied_by_customer_sheets_us
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_sheets_us'
).
AsString
;
result
.
supplied_by_customer_initials
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'supplied_by_customer_initials'
).
AsString
;
// Proofing
result
.
proofing_pdf
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf'
).
AsBoolean
;
result
.
proofing_pdf_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_to'
).
AsString
;
result
.
proofing_pdf_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_date_1'
).
AsString
;
result
.
proofing_pdf_date_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_date_2'
).
AsString
;
result
.
proofing_pdf_date_3
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_pdf_date_3'
).
AsString
;
result
.
proofing_full_size_ink_jet_for
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_full_size_ink_jet_for'
).
AsBoolean
;
result
.
proofing_ink_jet_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_to'
).
AsString
;
result
.
proofing_ink_jet_to_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_to'
).
AsString
;
result
.
proofing_ink_jet_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_date_1'
).
AsString
;
result
.
proofing_ink_jet_date_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_ink_jet_date_2'
).
AsString
;
result
.
proofing_color_contract
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contract'
).
AsString
;
result
.
proofing_color_contrac_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contrac_to'
).
AsString
;
result
.
proofing_color_contrac_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contrac_date_1'
).
AsString
;
result
.
proofing_color_contrac_date_2
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_color_contrac_date_2'
).
AsString
;
result
.
proofing_digital_color_key
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_digital_color_key'
).
AsString
;
result
.
proofing_digital_color_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_digital_color_to'
).
AsString
;
result
.
proofing_digital_color_date_1
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'proofing_digital_color_date_1'
).
AsString
;
// Colors
result
.
quantity_and_colors_press_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'quantity_and_colors_press_name'
).
AsString
;
result
.
quantity_and_colors_anilox_info
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'quantity_and_colors_anilox_info'
).
AsString
;
result
.
quantity_and_colors_qty_colors
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'quantity_and_colors_qty_colors'
).
AsString
;
// Plate Marks
result
.
plate_marks_microdots
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_microdots'
).
AsString
;
result
.
plate_marks_microdots_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_microdots_comments'
).
AsString
;
result
.
plate_marks_crosshairs
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_crosshairs'
).
AsString
;
result
.
plate_marks_crosshairs_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_crosshairs'
).
AsString
;
result
.
plate_marks_color_bars
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_color_bars'
).
AsString
;
result
.
plate_marks_color_bars_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_color_bars_comments'
).
AsString
;
result
.
plate_marks_other
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_other'
).
AsString
;
result
.
plate_marks_other_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plate_marks_other_comments'
).
AsString
;
// Print Orientation
result
.
print_orientation_print_orient
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'print_orientation_print_orient'
).
AsString
;
// Plate
result
.
plates_plate_material
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_plate_material'
).
AsString
;
result
.
plates_thickness
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_thickness'
).
AsString
;
result
.
plates_job_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'plates_job_number'
).
AsString
;
// Layout
result
.
layout_around
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_around'
).
AsString
;
result
.
layout_accross
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_accross'
).
AsString
;
result
.
layout_surface_print
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_surface_print'
).
AsString
;
result
.
layout_reverse_print
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_reverse_print'
).
AsString
;
result
.
layout_cylinder_repeat
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cylinder_repeat'
).
AsString
;
result
.
layout_cutoff_dimension
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cutoff_dimension'
).
AsString
;
result
.
layout_pitch
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_pitch'
).
AsString
;
result
.
layout_teeth
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_teeth'
).
AsString
;
result
.
layout_bleed
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_bleed'
).
AsString
;
result
.
layout_cutback
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_cutback'
).
AsString
;
result
.
layout_minimum_trap_dim
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_minimum_trap_dim'
).
AsString
;
result
.
layout_maximum_trap_dim
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'layout_maximum_trap_dim'
).
AsString
;
// UPC
result
.
upc_size
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_size'
).
AsString
;
result
.
upc_bar_width_reduction
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_bar_width_reduction'
).
AsString
;
result
.
upc_distortion_percent
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_distortion_percent'
).
AsString
;
result
.
upc_distortion_amount
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'upc_distortion_amount'
).
AsString
;
// General
result
.
general_comments
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'general_comments'
).
AsString
;
SQL
:=
'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
IntToStr
(
result
.
COMPANY_ID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
ADDRESS_LIST
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
IntToStr
(
result
.
COMPANY_ID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
result
.
ADDRESS_LIST
);
result
.
ITEMS
:=
GetItems
(
''
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
result
.
ITEMS
:=
GetItems
(
''
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in GetWebOrder: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve web order: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
GetCuttingDieOrder
(
orderInfo
:
string
):
TCuttingDie
;
var
orderType
:
string
;
...
...
@@ -1234,56 +1302,64 @@ var
SQL
:
string
;
ADDRESS
:
TAddressItem
;
begin
orderID
:=
orderInfo
;
SQL
:=
'select * from cutting_die_orders o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
orderID
:=
orderInfo
;
SQL
:=
'select * from cutting_die_orders o JOIN customers c ON c.CUSTOMER_ID = o.COMPANY_ID where ORDER_ID = '
+
quotedStr
(
orderID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
:=
TCuttingDie
.
Create
;
// Company
result
.
COMPANY_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_ID'
).
AsInteger
;
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
inQuickBooks
:=
'?'
;
// Staff Fields
result
.
staff_fields_order_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_order_date'
).
AsString
;
result
.
staff_fields_proof_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_proof_date'
).
AsString
;
result
.
staff_fields_ship_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_date'
).
AsString
;
result
.
staff_fields_ship_via
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_via'
).
AsString
;
result
.
staff_fields_quantity
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
;
result
.
staff_fields_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_to'
).
AsString
;
result
.
staff_fields_po_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_po_number'
).
AsString
;
result
.
staff_fields_job_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_job_name'
).
AsString
;
result
.
staff_fields_quickbooks_item
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quickbooks_item'
).
AsString
;
result
.
staff_fields_price
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsString
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_invoice_to'
).
AsString
;
result
.
general_special_instructions
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
;
result
:=
TCuttingDie
.
Create
;
// Company
result
.
COMPANY_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'COMPANY_ID'
).
AsInteger
;
result
.
NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
;
result
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
result
.
inQuickBooks
:=
'?'
;
// Staff Fields
result
.
staff_fields_order_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_order_date'
).
AsString
;
result
.
staff_fields_proof_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_proof_date'
).
AsString
;
result
.
staff_fields_ship_date
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_date'
).
AsString
;
result
.
staff_fields_ship_via
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_via'
).
AsString
;
result
.
staff_fields_quantity
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quantity'
).
AsString
;
result
.
staff_fields_ship_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_ship_to'
).
AsString
;
result
.
staff_fields_po_number
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_po_number'
).
AsString
;
result
.
staff_fields_job_name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_job_name'
).
AsString
;
result
.
staff_fields_quickbooks_item
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_quickbooks_item'
).
AsString
;
result
.
staff_fields_price
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_price'
).
AsString
;
result
.
staff_fields_invoice_to
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'staff_fields_invoice_to'
).
AsString
;
result
.
general_special_instructions
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'general_special_instructions'
).
AsString
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
IntToStr
(
result
.
COMPANY_ID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
R
esult
.
ADDRESS_LIST
);
SQL
:=
'SELECT s.ship_block FROM customers c JOIN customers_ship s ON c.CUSTOMER_ID = s.customer_id WHERE c.CUSTOMER_ID = '
+
IntToStr
(
result
.
COMPANY_ID
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ADDRESS_LIST
:=
TList
<
TAddressItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
r
esult
.
ADDRESS_LIST
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
ADDRESS
:=
TAddressItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
ADDRESS
);
ADDRESS
.
ADDRESS
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'ship_block'
).
AsString
;
result
.
ADDRESS_LIST
.
Add
(
ADDRESS
);
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
Close
;
result
.
ITEMS
:=
GetItems
(
''
);
result
.
ITEMS
:=
GetItems
(
''
);
except
on
E
:
Exception
do
begin
raise
EXDataHttpException
.
Create
(
500
,
'Could not retrieve cutting die order: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
GetItems
(
searchOptions
:
string
):
TItemList
;
// retr
u
eves all the quickbooks items for the items page on client.
// retr
i
eves all the quickbooks items for the items page on client.
// searchOptions: probably not needed but adds limits to the page to prevent
// table on client side from getting too long. This table currently has about 27
// entries so probably not needed.
...
...
@@ -1297,50 +1373,56 @@ var
SQL
:
string
;
item
:
TItemItem
;
begin
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
// parse the searchOptions
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
searchOptions
;
SQL
:=
'select * from qb_items order by qb_item_name asc'
;
try
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
// parse the searchOptions
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
searchOptions
;
if
(
(
params
.
Values
[
'pagenumber'
]
<>
''
)
and
(
params
.
Values
[
'pagesize'
]
<>
''
)
)
then
begin
pageNum
:=
StrToInt
(
params
.
Values
[
'pagenumber'
]);
PageSize
:=
StrToInt
(
params
.
Values
[
'pagesize'
]);
OrderBy
:=
params
.
Values
[
'orderby'
];
SQL
:=
'select * from qb_items order by qb_item_name asc'
;
if
(
(
params
.
Values
[
'pagenumber'
]
<>
''
)
and
(
params
.
Values
[
'pagesize'
]
<>
''
)
)
then
begin
pageNum
:=
StrToInt
(
params
.
Values
[
'pagenumber'
]);
PageSize
:=
StrToInt
(
params
.
Values
[
'pagesize'
]);
OrderBy
:=
params
.
Values
[
'orderby'
];
limit
:=
IntToStr
(
PageSize
);
offset
:=
IntToStr
((
PageNum
-
1
)
*
PageSize
);
SQL
:=
SQL
+
' limit '
+
limit
+
' offset '
+
offset
;
end
;
limit
:=
IntToStr
(
PageSize
);
offset
:=
IntToStr
((
PageNum
-
1
)
*
PageSize
);
SQL
:=
SQL
+
' limit '
+
limit
+
' offset '
+
offset
;
end
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
:=
TItemList
.
Create
;
Result
.
data
:=
TList
<
TItemItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
Result
:=
TItemList
.
Create
;
Result
.
data
:=
TList
<
TItemItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
item
:=
TItemItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
item
);
Result
.
data
.
Add
(
item
);
item
.
ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_id'
).
AsString
;
item
.
name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_item_name'
).
AsString
;
item
.
description
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'item_desc'
).
AsString
;
item
.
status
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'status'
).
AsString
;
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
item
:=
TItemItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
item
);
Result
.
data
.
Add
(
item
);
item
.
ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_id'
).
AsString
;
item
.
name
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_item_name'
).
AsString
;
item
.
description
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'item_desc'
).
AsString
;
item
.
status
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'status'
).
AsString
;
ordersDB
.
UniQuery1
.
Next
;
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'select count(*) as total_count from qb_items'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
.
count
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'total_count'
).
AsInteger
;
ordersDB
.
UniQuery1
.
Close
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in GetItems: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve item list: '
+
E
.
Message
);
end
;
end
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'select count(*) as total_count from qb_items'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
.
count
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'total_count'
).
AsInteger
;
ordersDB
.
UniQuery1
.
Close
;
end
;
function
TLookupService
.
GetUsers
(
searchOptions
:
string
):
TUserList
;
...
...
@@ -1351,21 +1433,22 @@ var
SQL
:
string
;
user
:
TUserItem
;
begin
if
searchOptions
=
''
then
SQL
:=
'select * from users order by NAME ASC'
else
SQL
:=
'select * from users where username='
+
quotedStr
(
searchOptions
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
if
searchOptions
=
''
then
SQL
:=
'select * from users order by NAME ASC'
else
SQL
:=
'select * from users where username='
+
quotedStr
(
searchOptions
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
:=
TUserList
.
Create
;
Result
.
data
:=
TList
<
TUserItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
Result
:=
TUserList
.
Create
;
Result
.
data
:=
TList
<
TUserItem
>.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
.
data
);
while
not
ordersDB
.
UniQuery1
.
Eof
do
while
not
ordersDB
.
UniQuery1
.
Eof
do
begin
user
:=
TUserItem
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
user
);
Result
.
data
.
Add
(
user
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
user
);
Result
.
data
.
Add
(
user
);
user
.
userID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_ID'
).
AsString
;
user
.
username
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_NAME'
).
AsString
;
user
.
password
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'PASSWORD'
).
AsString
;
...
...
@@ -1379,10 +1462,17 @@ begin
ordersDB
.
UniQuery1
.
Next
;
end
;
ordersDB
.
UniQuery1
.
Close
;
SQL
:=
'select count(*) as total_count from users'
;
SQL
:=
'select count(*) as total_count from users'
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
Result
.
count
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'total_count'
).
AsInteger
;
ordersDB
.
UniQuery1
.
Close
;
except
on
E
:
Exception
do
begin
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve users: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
EditUser
(
const
editOptions
:
string
):
string
;
...
...
@@ -1468,7 +1558,7 @@ begin
end;}
ordersDB
.
UniQuery1
.
Post
;
Result
:=
'Success:Edit Successful'
;
Result
:=
'Success:
Edit Successful'
;
end
;
ordersDB
.
UniQuery1
.
Close
;
end
;
...
...
@@ -1790,13 +1880,11 @@ begin
OrdersDB
.
UniQuery1
.
FieldByName
(
StatusField
).
AsString
:=
Date
;
OrdersDB
.
UniQuery1
.
Post
;
finally
order
.
Free
;
end
;
end
;
result
:=
'success'
;
except
on
E
:
Exception
do
...
...
@@ -1805,7 +1893,7 @@ begin
end
;
function
TLookupService
.
AddUser
(
userInfo
:
string
):
string
;
function
TLookupService
.
AddUser
(
userInfo
:
string
):
string
;
// Adds a user to the database
// userInfo - user information being added
var
...
...
@@ -1824,54 +1912,59 @@ var
hashPW
:
string
;
params
:
TStringList
;
begin
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
// parse the searchOptions
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
userInfo
;
dateCreated
:=
now
;
user
:=
params
.
Values
[
'username'
];
password
:=
params
.
Values
[
'password'
];
full_name
:=
params
.
Values
[
'fullname'
];
status
:=
params
.
Values
[
'status'
];
email
:=
params
.
Values
[
'email'
];
access
:=
params
.
Values
[
'access'
];
rights
:=
params
.
Values
[
'rights'
];
perspective
:=
params
.
Values
[
'perspective'
];
QB
:=
params
.
Values
[
'QB'
];
//newUser := params.Values['newuser'];
//hashString := DateTimeToStr(dateCreated) + params.Values['password'];
//hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
SQL
:=
'select * from users where USER_NAME = '
+
QuotedStr
(
params
.
Values
[
'username'
].
toLower
);
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
ordersDB
.
UniQuery1
.
Open
;
if
ordersDB
.
UniQuery1
.
IsEmpty
then
begin
ordersDB
.
UniQuery1
.
Insert
;
try
params
:=
TStringList
.
Create
;
params
.
StrictDelimiter
:=
true
;
// parse the searchOptions
params
.
Delimiter
:=
'&'
;
params
.
DelimitedText
:=
userInfo
;
dateCreated
:=
now
;
user
:=
params
.
Values
[
'username'
];
password
:=
params
.
Values
[
'password'
];
full_name
:=
params
.
Values
[
'fullname'
];
status
:=
params
.
Values
[
'status'
];
email
:=
params
.
Values
[
'email'
];
access
:=
params
.
Values
[
'access'
];
rights
:=
params
.
Values
[
'rights'
];
perspective
:=
params
.
Values
[
'perspective'
];
QB
:=
params
.
Values
[
'QB'
];
//newUser := params.Values['newuser'];
//hashString := DateTimeToStr(dateCreated) + params.Values['password'];
//hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
SQL
:=
'select * from users where USER_NAME = '
+
QuotedStr
(
params
.
Values
[
'username'
].
toLower
);
ordersDB
.
UniQuery1
.
Close
;
ordersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
ordersDB
.
UniQuery1
.
Open
;
if
ordersDB
.
UniQuery1
.
IsEmpty
then
begin
ordersDB
.
UniQuery1
.
Insert
;
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_NAME'
).
AsString
:=
user
;
ordersDB
.
UniQuery1
.
FieldByName
(
'PASSWORD'
).
AsString
:=
password
;
//THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
//ordersDB.UniQuery1.FieldByName('date_created').AsString := DateTimeToStr(dateCreated);
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
:=
full_name
;
ordersDB
.
UniQuery1
.
FieldByName
(
'USER_NAME'
).
AsString
:=
user
;
ordersDB
.
UniQuery1
.
FieldByName
(
'PASSWORD'
).
AsString
:=
password
;
//THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
//ordersDB.UniQuery1.FieldByName('date_created').AsString := DateTimeToStr(dateCreated);
ordersDB
.
UniQuery1
.
FieldByName
(
'NAME'
).
AsString
:=
full_name
;
if
(
StrToBool
(
status
)
)
then
ordersDB
.
UniQuery1
.
FieldByName
(
'STATUS'
).
AsString
:=
'ACTIVE'
else
ordersDB
.
UniQuery1
.
FieldByName
(
'STATUS'
).
AsString
:=
'INACTIVE'
;
if
(
StrToBool
(
status
)
)
then
ordersDB
.
UniQuery1
.
FieldByName
(
'STATUS'
).
AsString
:=
'ACTIVE'
else
ordersDB
.
UniQuery1
.
FieldByName
(
'STATUS'
).
AsString
:=
'INACTIVE'
;
ordersDB
.
UniQuery1
.
FieldByName
(
'EMAIL'
).
AsString
:=
email
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ACCESS_TYPE'
).
AsString
:=
Access
;
ordersDB
.
UniQuery1
.
FieldByName
(
'SYSTEM_RIGHTS'
).
AsInteger
:=
StrToInt
(
rights
);
ordersDB
.
UniQuery1
.
FieldByName
(
'PERSPECTIVE_ID'
).
AsString
:=
perspective
;
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_ID'
).
AsString
:=
QB
;
ordersDB
.
UniQuery1
.
FieldByName
(
'EMAIL'
).
AsString
:=
email
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ACCESS_TYPE'
).
AsString
:=
Access
;
ordersDB
.
UniQuery1
.
FieldByName
(
'SYSTEM_RIGHTS'
).
AsInteger
:=
StrToInt
(
rights
);
ordersDB
.
UniQuery1
.
FieldByName
(
'PERSPECTIVE_ID'
).
AsString
:=
perspective
;
ordersDB
.
UniQuery1
.
FieldByName
(
'QB_ID'
).
AsString
:=
QB
;
ordersDB
.
UniQuery1
.
Post
;
Result
:=
'Success:User successfully added'
;
end
else
Result
:=
'Failure:Username already taken'
;
ordersDB
.
UniQuery1
.
Post
;
Result
:=
'Success:User successfully added'
;
end
else
Result
:=
'Failure:Username already taken'
;
except
on
E
:
Exception
do
raise
EXDataHttpException
.
Create
(
500
,
'AddUser failed: '
+
E
.
Message
);
end
;
end
;
function
TLookupService
.
AddItem
(
itemInfo
:
string
):
TJSONObject
;
...
...
@@ -1895,7 +1988,7 @@ begin
Description
:=
JSONData
.
GetValue
<
string
>(
'item_desc'
);
Status
:=
StrToBool
(
JSONData
.
GetValue
<
string
>(
'status'
));
SQL
:=
'select * from qb_items where qb_item_name = '
+
QuotedStr
(
Name
);
SQL
:=
'select * from qb_items where qb_item_name = '
+
QuotedStr
(
Name
);
if
mode
=
'ADD'
then
begin
...
...
@@ -1919,6 +2012,7 @@ begin
end
;
end
;
function
TLookupService
.
DelUser
(
username
:
string
):
string
;
// deletes a user. not currently implemented definitely needs touching up to avoid
// deleting users prematurely.
...
...
@@ -1944,7 +2038,6 @@ begin
end
;
end
;
function
TLookupService
.
AddWebOrder
(
orderInfo
:
string
):
TJSONObject
;
// Adds corrugated order to the database. This process is done in 3 different
// tables so if any changes are made make sure to check orders, corrugated_plate_orders
...
...
@@ -1985,8 +2078,10 @@ begin
ORDER_ID
:=
JSONData
.
GetValue
<
integer
>(
'ORDER_ID'
);
SQL
:=
'select * from web_plate_orders where ORDER_ID = '
+
IntToStr
(
ORDER_ID
);
end
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
if
mode
=
'ADD'
then
ordersDB
.
UniQuery1
.
Insert
else
...
...
@@ -1997,13 +2092,13 @@ begin
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
// Checks if the field exists in the dataset
if
Assigned
(
Field
)
then
begin
// handles any dates or datetimes
// handles any dates or datetimes
if
(
Field
is
TDateTimeField
)
then
begin
if
(
Pair
.
JsonValue
.
Value
=
''
)
or
(
Pair
.
JsonValue
.
Value
=
'null'
)
or
(
Pair
.
JsonValue
.
Value
=
'12/30/1899'
)
then
Field
.
Clear
// This sets the field to NULL (empty)
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
);
if
(
Pair
.
JsonValue
.
Value
=
''
)
or
(
Pair
.
JsonValue
.
Value
=
'null'
)
or
(
Pair
.
JsonValue
.
Value
=
'12/30/1899'
)
then
Field
.
Clear
// This sets the field to NULL (empty)
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
);
end
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
...
...
@@ -2034,14 +2129,16 @@ begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
msg
);
Result
.
AddPair
(
'OrderID'
,
ORDER_ID
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
except
except
on
E
:
Exception
do
begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
E
.
Message
);
end
Logger
.
Log
(
2
,
'Error in AddWebOrder: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to add or edit web order: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
AddCuttingDieOrder
(
orderInfo
:
string
):
TJSONObject
;
var
JSONData
,
ResponseData
:
TJSONObject
;
...
...
@@ -2123,14 +2220,16 @@ begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
msg
);
Result
.
AddPair
(
'OrderID'
,
ORDER_ID
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
except
except
on
E
:
Exception
do
begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
E
.
Message
);
end
Logger
.
Log
(
2
,
'Error in AddCuttingDieOrder: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to add cutting die order: '
+
E
.
Message
);
end
;
end
;
end
;
function
TLookupService
.
delOrder
(
OrderID
,
orderType
,
UserID
:
string
):
TJSONObject
;
var
table
:
string
;
...
...
@@ -2151,115 +2250,124 @@ var
JSONObject
:
TJSONObject
;
DataObject
:
TJSONObject
;
begin
if
orderType
=
'corrugated'
then
begin
table
:=
'corrugated_plate_orders'
;
table2
:=
'corrugated_plate_orders_revisions'
;
end
else
if
orderType
=
'web'
then
begin
table
:=
'web_plate_orders'
;
table2
:=
'web_plate_orders_revisions'
;
end
else
begin
table
:=
'cutting_die_orders'
;
table2
:=
'cutting_die_orders_revisions'
;
end
;
try
if
orderType
=
'corrugated'
then
begin
table
:=
'corrugated_plate_orders'
;
table2
:=
'corrugated_plate_orders_revisions'
;
end
else
if
orderType
=
'web'
then
begin
table
:=
'web_plate_orders'
;
table2
:=
'web_plate_orders_revisions'
;
end
else
begin
table
:=
'cutting_die_orders'
;
table2
:=
'cutting_die_orders_revisions'
;
end
;
stream
:=
TStringStream
.
Create
(
''
,
TEncoding
.
UTF8
);
DateFormat
:=
TFormatSettings
.
Create
;
DateFormat
.
ShortDateFormat
:=
'yyyy-mm-dd'
;
DateFormat
.
DateSeparator
:=
'-'
;
stream
:=
TStringStream
.
Create
(
''
,
TEncoding
.
UTF8
);
DateFormat
:=
TFormatSettings
.
Create
;
DateFormat
.
ShortDateFormat
:=
'yyyy-mm-dd'
;
DateFormat
.
DateSeparator
:=
'-'
;
//Update RevisionID
SQL
:=
'UPDATE idfield set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = '
+
quotedStr
(
'GEN_ORDER_REVISION_ID'
);
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
//Update RevisionID
SQL
:=
'UPDATE idfield set KEYVALUE = KEYVALUE + 1 WHERE KEYNAME = '
+
quotedStr
(
'GEN_ORDER_REVISION_ID'
);
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
//Retrieve updated RevisionID
SQL
:=
'select KEYVALUE from idfield where KEYNAME = '
+
quotedStr
(
'GEN_ORDER_REVISION_ID'
);
doQuery
(
OrdersDB
.
UniQuery1
,
SQL
);
RevisionID
:=
OrdersDB
.
UniQuery1
.
FieldByName
(
'KEYVALUE'
).
AsInteger
;
//Retrieve updated RevisionID
SQL
:=
'select KEYVALUE from idfield where KEYNAME = '
+
quotedStr
(
'GEN_ORDER_REVISION_ID'
);
doQuery
(
OrdersDB
.
UniQuery1
,
SQL
);
RevisionID
:=
OrdersDB
.
UniQuery1
.
FieldByName
(
'KEYVALUE'
).
AsInteger
;
// Convert Order into JSON
SQL
:=
'select * from '
+
table
+
' where ORDER_ID = '
+
OrderID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
// Convert Order into JSON
SQL
:=
'select * from '
+
table
+
' where ORDER_ID = '
+
OrderID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ordersDB
.
UniQuery1
.
SaveToJSON
(
stream
);
stream
.
Position
:=
0
;
JSONValue
:=
TJSONObject
.
ParseJSONValue
(
Stream
.
DataString
);
ordersDB
.
UniQuery1
.
SaveToJSON
(
stream
);
stream
.
Position
:=
0
;
JSONValue
:=
TJSONObject
.
ParseJSONValue
(
Stream
.
DataString
);
if
not
Assigned
(
JSONValue
)
then
raise
Exception
.
Create
(
'Invalid JSON content'
);
if
not
Assigned
(
JSONValue
)
then
raise
Exception
.
Create
(
'Invalid JSON content'
);
try
if
not
(
JSONValue
is
TJSONObject
)
then
raise
Exception
.
Create
(
'Expected JSON object'
);
try
if
not
(
JSONValue
is
TJSONObject
)
then
raise
Exception
.
Create
(
'Expected JSON object'
);
JSONObject
:=
TJSONObject
(
JSONValue
);
JSONObject
:=
TJSONObject
(
JSONValue
);
// Get the "data" object
if
not
JSONObject
.
TryGetValue
(
'data'
,
DataObject
)
then
raise
Exception
.
Create
(
'Missing "data" object in JSON'
);
// Get the "data" object
if
not
JSONObject
.
TryGetValue
(
'data'
,
DataObject
)
then
raise
Exception
.
Create
(
'Missing "data" object in JSON'
);
// Get the "rows" array
if
not
DataObject
.
TryGetValue
(
'rows'
,
JSONArray
)
then
raise
Exception
.
Create
(
'Missing "rows" array in JSON data'
);
// Get the "rows" array
if
not
DataObject
.
TryGetValue
(
'rows'
,
JSONArray
)
then
raise
Exception
.
Create
(
'Missing "rows" array in JSON data'
);
JSONData
:=
JSONArray
.
Items
[
0
]
as
TJSONObject
;
JSONData
:=
JSONArray
.
Items
[
0
]
as
TJSONObject
;
SQL
:=
'select max(REVISION_NUMBER) as rev_num from '
+
table2
+
' where ORDER_ID = '
+
orderID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
rev_num
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'rev_num'
).
AsInteger
+
1
;
SQL
:=
'select max(REVISION_NUMBER) as rev_num from '
+
table2
+
' where ORDER_ID = '
+
orderID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
rev_num
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'rev_num'
).
AsInteger
+
1
;
SQL
:=
'select * from '
+
table2
+
' where ORDER_ID = '
+
orderID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
SQL
:=
'select * from '
+
table2
+
' where ORDER_ID = '
+
orderID
;
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
ordersDB
.
UniQuery1
.
Insert
;
for
Pair
in
JSONData
do
begin
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
// Checks if the field exists in the dataset
if
Assigned
(
Field
)
then
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
try
ordersDB
.
UniQuery1
.
Insert
;
for
Pair
in
JSONData
do
begin
// handles any dates or datetimes
if
(
Field
is
TDateTimeField
)
and
(
Pair
.
JsonValue
.
Value
<>
''
)
then
TDateTimeField
(
Field
).
AsDateTime
:=
ISO8601ToDate
(
Pair
.
JsonValue
.
Value
,
False
)
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
Field
:=
ordersDB
.
UniQuery1
.
FindField
(
Pair
.
JsonString
.
Value
);
// Checks if the field exists in the dataset
if
Assigned
(
Field
)
then
begin
// handles any dates or datetimes
if
(
Field
is
TDateTimeField
)
and
(
Pair
.
JsonValue
.
Value
<>
''
)
then
TDateTimeField
(
Field
).
AsDateTime
:=
ISO8601ToDate
(
Pair
.
JsonValue
.
Value
,
False
)
else
if
Pair
.
JsonValue
.
Value
<>
''
then
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
end
;
end
;
end
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_ID'
).
AsString
:=
OrderID
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_STATUS'
).
AsString
:=
'DELETED'
;
ordersDB
.
UniQuery1
.
FieldByName
(
'REVISION_NUMBER'
).
AsInteger
:=
1
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_REVISION_ID'
).
AsInteger
:=
RevisionID
;
ordersDB
.
UniQuery1
.
FieldByName
(
'REVISION_USER_ID'
).
AsString
:=
UserID
;
// Post the record to the database
ordersDB
.
UniQuery1
.
Post
;
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
'success'
);
Result
.
AddPair
(
'OrderID'
,
OrderID
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_ID'
).
AsString
:=
OrderID
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_STATUS'
).
AsString
:=
'DELETED'
;
ordersDB
.
UniQuery1
.
FieldByName
(
'REVISION_NUMBER'
).
AsInteger
:=
1
;
ordersDB
.
UniQuery1
.
FieldByName
(
'ORDER_REVISION_ID'
).
AsInteger
:=
RevisionID
;
ordersDB
.
UniQuery1
.
FieldByName
(
'REVISION_USER_ID'
).
AsString
:=
UserID
;
// Post the record to the database
ordersDB
.
UniQuery1
.
Post
;
Result
:=
TJSONObject
.
Create
.
AddPair
(
'status'
,
'success'
);
Result
.
AddPair
(
'OrderID'
,
OrderID
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
except
on
E
:
Exception
do
begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
E
.
Message
);
end
on
E
:
Exception
do
begin
Result
:=
TJSONObject
.
Create
.
AddPair
(
'error'
,
E
.
Message
);
end
end
;
finally
JSONData
.
Free
;
end
;
sql
:=
'delete from '
+
table
+
' where ORDER_ID = '
+
OrderID
;
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
sql
:=
'delete from orders where ORDER_ID = '
+
OrderID
;
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in delOrder: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to delete order: '
+
E
.
Message
);
end
;
finally
JSONData
.
Free
;
end
;
sql
:=
'delete from '
+
table
+
' where ORDER_ID = '
+
OrderID
;
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
sql
:=
'delete from orders where ORDER_ID = '
+
OrderID
;
OrdersDB
.
UniQuery1
.
SQL
.
Text
:=
SQL
;
OrdersDB
.
UniQuery1
.
ExecSQL
;
end
;
procedure
TLookupService
.
AddToRevisionsTable
(
OrderID
:
string
;
table
:
string
;
order
:
TJSONObject
);
var
SQL
,
UserID
:
string
;
...
...
@@ -2314,7 +2422,6 @@ begin
ordersDB
.
UniQuery1
.
FieldByName
(
'REVISION_USER_ID'
).
AsString
:=
order
.
GetValue
<
string
>(
'USER_ID'
);
// Post the record to the database
ordersDB
.
UniQuery1
.
Post
;
end
;
function
TLookupService
.
getQBCustomers
:
TJSONArray
;
...
...
@@ -2341,109 +2448,113 @@ begin
restResponse
:=
TRESTResponse
.
Create
(
nil
);
try
restRequest
.
Client
:=
restClient
;
restRequest
.
Response
:=
restResponse
;
if
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
)
=
''
then
LastRefresh
:=
0
else
LastRefresh
:=
StrToDateTime
(
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
));
if
MinutesBetween
(
Now
,
LastRefresh
)
>
58
then
RefreshAccessToken
();
try
restRequest
.
Client
:=
restClient
;
restRequest
.
Response
:=
restResponse
;
Client
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
);
Secret
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientSecret'
,
''
);
CompanyID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
);
RefreshToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RefreshToken'
,
''
);
AccessToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'AccessToken'
,
''
);
if
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
)
=
''
then
LastRefresh
:=
0
else
LastRefresh
:=
StrToDateTime
(
iniFile
.
ReadString
(
'Quickbooks'
,
'LastRefresh'
,
''
));
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restRequest
.
Method
:=
rmGET
;
res
:=
'/v3/company/'
+
CompanyID
+
'/query?query=select * from Customer&minorversion=75'
;
restRequest
.
Resource
:=
res
;
if
MinutesBetween
(
Now
,
LastRefresh
)
>
58
then
RefreshAccessToken
();
param
:=
restRequest
.
Params
.
AddItem
;
param
.
Name
:=
'Authorization'
;
param
.
Kind
:=
pkHTTPHEADER
;
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
]
;
param
.
Value
:=
'Bearer '
+
AccessToken
;
Client
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientID'
,
''
)
;
Secret
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientSecret'
,
''
)
;
CompanyID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
)
;
RefreshToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RefreshToken'
,
''
)
;
AccessToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'AccessToken'
,
''
)
;
restRequest
.
Execute
;
restClient
.
BaseURL
:=
'https://sandbox-quickbooks.api.intuit.com'
;
restRequest
.
Method
:=
rmGET
;
res
:=
'/v3/company/'
+
CompanyID
+
'/query?query=select * from Customer&minorversion=75'
;
restRequest
.
Resource
:=
res
;
jsValue
:=
restResponse
.
JSONValue
;
if
not
Assigned
(
jsValue
)
then
Exit
;
param
:=
restRequest
.
Params
.
AddItem
;
param
.
Name
:=
'Authorization'
;
param
.
Kind
:=
pkHTTPHEADER
;
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Value
:=
'Bearer '
+
AccessToken
;
jsObj
:=
jsValue
as
TJSONObject
;
if
not
Assigned
(
jsObj
)
then
Exit
;
restRequest
.
Execute
;
CustomerList
:=
jsObj
.
GetValue
<
TJSONArray
>(
'QueryResponse.Customer'
)
;
if
not
Assigned
(
CustomerList
)
then
Exit
;
jsValue
:=
restResponse
.
JSONValue
;
if
not
Assigned
(
jsValue
)
then
Exit
;
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
jsObj
:=
jsValue
as
TJSONObject
;
if
not
Assigned
(
jsObj
)
then
Exit
;
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
ParsedCustomer
:=
TJSONObject
.
Create
;
CustomerList
:=
jsObj
.
GetValue
<
TJSONArray
>(
'QueryResponse.Customer'
);
if
not
Assigned
(
CustomerList
)
then
Exit
;
sql
:=
'select CUSTOMER_ID from customers where QB_LIST_ID = '
+
Customer
.
GetValue
<
string
>(
'Id'
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
for
I
:=
0
to
CustomerList
.
Count
-
1
do
begin
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
ParsedCustomer
:=
TJSONObject
.
Create
;
try
ParsedCustomer
.
AddPair
(
'In KGOrders'
,
not
(
ordersDB
.
UniQuery1
.
IsEmpty
)
);
sql
:=
'select CUSTOMER_ID from customers where QB_LIST_ID = '
+
Customer
.
GetValue
<
string
>(
'Id'
);
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
ParsedCustomer
.
AddPair
(
'Id'
,
Customer
.
GetValue
<
string
>(
'Id'
));
ParsedCustomer
.
AddPair
(
'CompanyName'
,
Customer
.
GetValue
<
string
>(
'DisplayName'
));
try
ParsedCustomer
.
AddPair
(
'In KGOrders'
,
not
(
ordersDB
.
UniQuery1
.
IsEmpty
));
ParsedCustomer
.
AddPair
(
'Id'
,
Customer
.
GetValue
<
string
>(
'Id'
));
ParsedCustomer
.
AddPair
(
'CompanyName'
,
Customer
.
GetValue
<
string
>(
'DisplayName'
));
// Handle Bill Address
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'BillAddr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'BillAddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'BillAddr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
// Handle Bill
Address
if
Customer
.
GetValue
(
'Bill
Addr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'Bill
Addr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'Bill
AddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
AddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
AddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
AddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Bill
Addr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
// Handle Ship
Address
if
Customer
.
GetValue
(
'Ship
Addr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'Ship
Addr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'Ship
AddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
AddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
AddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
AddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'Ship
Addr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
end
;
// Handle Ship Address
if
Customer
.
GetValue
(
'ShipAddr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'ShipAddr'
)
as
TJSONObject
;
ParsedCustomer
.
AddPair
(
'ShipAddrLine1'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddrCity'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'City'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddrState'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'CountrySubDivisionCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'ShipAddr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
','
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
BillAddr
.
GetValue
(
'CountrySubDivisionCode'
,
''
)
+
' '
+
BillAddr
.
GetValue
(
'PostalCode'
,
''
)
)
);
Result
.
AddElement
(
ParsedCustomer
);
except
ParsedCustomer
.
Free
;
raise
;
end
;
Result
.
AddElement
(
ParsedCustomer
);
except
ParsedCustomer
.
Free
;
raise
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in getQBCustomers: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks customers: '
+
E
.
Message
);
end
;
end
;
finally
iniFile
.
Free
;
restClient
.
Free
;
...
...
kgOrdersServer/kgOrdersServer.ini
View file @
42f8e3e6
...
...
@@ -2,11 +2,11 @@
MemoLogLevel
=
3
FileLogLevel
=
5
webClientVersion
=
0.9.4
LogFileNum
=
7
10
LogFileNum
=
7
21
[Database]
Server
=
192.168.159.131
--
Server
=
192.168.102.130
--
Server
=
192.168.159.131
Server
=
192.168.102.130
--Server
=
192.168.75.133
Database
=
kg_order_entry
Username
=
root
...
...
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