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