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
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
248 additions
and
103 deletions
+248
-103
Utils.pas
kgOrdersClient/Utils.pas
+34
-0
View.Customers.pas
kgOrdersClient/View.Customers.pas
+8
-15
View.EditUser.pas
kgOrdersClient/View.EditUser.pas
+8
-3
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
+54
-16
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
+24
-7
View.OrderEntryCuttingDie.pas
kgOrdersClient/View.OrderEntryCuttingDie.pas
+20
-3
View.OrderEntryWeb.pas
kgOrdersClient/View.OrderEntryWeb.pas
+23
-12
View.Orders.dfm
kgOrdersClient/View.Orders.dfm
+1
-0
View.Orders.pas
kgOrdersClient/View.Orders.pas
+33
-32
View.SelectCustomer.pas
kgOrdersClient/View.SelectCustomer.pas
+6
-1
View.Users.pas
kgOrdersClient/View.Users.pas
+8
-2
webKGOrders.dproj
kgOrdersClient/webKGOrders.dproj
+1
-2
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+0
-0
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+3
-3
No files found.
kgOrdersClient/Utils.pas
View file @
42f8e3e6
...
...
@@ -9,6 +9,7 @@ procedure ShowStatusMessage(const AMessage, AClass: string; const AElementId: st
procedure
HideStatusMessage
(
const
AElementId
:
string
);
procedure
ShowSpinner
(
SpinnerID
:
string
);
procedure
HideSpinner
(
SpinnerID
:
string
);
procedure
ShowErrorModal
(
const
msg
:
string
);
function
CalculateAge
(
DateOfBirth
:
TDateTime
):
Integer
;
function
FormatPhoneNumber
(
PhoneNumber
:
string
):
string
;
procedure
ApplyReportTitle
(
CurrentReportType
:
string
);
...
...
@@ -82,6 +83,39 @@ begin
end
;
end
;
// The $IFNDEF WIN32 was recommended by Holger to deal with any modal issues
procedure
ShowErrorModal
(
const
msg
:
string
);
begin
{$IFNDEF WIN32}
asm
var
modal
=
document
.
getElementById
(
'main_errormodal'
);
var
label
=
document
.
getElementById
(
'main_lblmodal_body'
);
var
reloadBtn
=
document
.
getElementById
(
'btn_modal_restart'
);
if
(
label
)
label
.
innerText
=
msg
;
// Ensure modal is a direct child of <body>
if
(
modal
&&
modal
.
parentNode
!==
document
.
body
)
{
document.body.appendChild(modal);
}
// Bind hard reload to button
if
(
reloadBtn
)
{
reloadBtn.onclick = function () {
window.location.reload(true); // hard reload, bypass cache
}
;
}
// Show the Bootstrap modal
var
bsModal
=
new
bootstrap
.
Modal
(
modal
,
{ keyboard: false }
);
bsModal
.
show
();
end
;
{$ENDIF}
end
;
function
CalculateAge
(
DateOfBirth
:
TDateTime
):
Integer
;
var
...
...
kgOrdersClient/View.Customers.pas
View file @
42f8e3e6
...
...
@@ -125,39 +125,32 @@ begin
if
PageNumber
>
0
then
begin
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomers'
,
[
searchOptions
]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
// Load data into the dataset
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
[
'data'
]);
xdwdsCustomers
.
Open
;
Utils
.
HideSpinner
(
'spinner'
);
customerListLength
:=
integer
(
customerList
[
'count'
]);
TotalPages
:=
(
(
customerListLength
+
PageSize
-
1
)
div
PageSize
);
if
customerListLength
=
0
then
begin
lblEntries
.
Caption
:=
'No entries found'
;
end
lblEntries
.
Caption
:=
'No entries found'
else
if
(
PageNumber
*
PageSize
)
<
customerListLength
then
// Currently these do the same thing. If you want to limit the number of entries
// You will need to edit the server side, and then change this if statement so the label
// Correctly displayes. I believe it is IntToStr(PageSize * PageNum)
begin
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
customerListLength
)
+
' of '
+
IntToStr
(
customerListLength
);
end
else
if
(
PageNumber
*
PageSize
)
>=
customerListLength
then
begin
' of '
+
IntToStr
(
customerListLength
)
else
lblEntries
.
Caption
:=
'Showing entries '
+
IntToStr
((
PageNumber
-
1
)
*
PageSize
+
1
)
+
' - '
+
IntToStr
(
customerListLength
)
+
' of '
+
IntToStr
(
customerListLength
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve customers: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
...
...
kgOrdersClient/View.EditUser.pas
View file @
42f8e3e6
...
...
@@ -103,7 +103,7 @@ begin
Utils
.
ShowSpinner
(
'spinner'
);
end
;
function
TFViewEditUser
.
AddUser
()
:
string
;
function
TFViewEditUser
.
AddUser
:
string
;
// Sends UserInfo over to the server so it can be added to the database
var
userInfo
:
string
;
...
...
@@ -120,12 +120,17 @@ begin
'&rights='
+
edtRights
.
Text
+
'&QB='
+
edtQB
.
Text
;
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddUser'
,
[
userInfo
]));
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddUser'
,
[
userInfo
]));
responseString
:=
TJSObject
(
xdcResponse
.
Result
);
Info
:=
string
(
responseString
[
'value'
]);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not add user: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFViewEditUser
.
HideNotification
;
begin
pnlMessage
.
ElementHandle
.
hidden
:=
True
;
...
...
kgOrdersClient/View.Items.dfm
View file @
42f8e3e6
...
...
@@ -48,7 +48,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Add'
ChildOrder = 7
ElementClassName = 'btn btn-light'
ElementID = 'btnadd'
ElementFont = efCSS
HeightStyle = ssAuto
...
...
@@ -110,6 +109,7 @@ object FViewItems: TFViewItems
ElementPosition = epRelative
Role = 'null'
TabOrder = 5
Visible = False
object lblMessage: TWebLabel
Left = 28
Top = 9
...
...
@@ -148,7 +148,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Save'
ChildOrder = 79
ElementClassName = 'btn btn-light'
ElementID = 'btnconfirm'
ElementFont = efCSS
ElementPosition = epRelative
...
...
@@ -160,12 +159,11 @@ object FViewItems: TFViewItems
end
object btnCancel: TWebButton
Left = 565
Top = 25
9
Top = 25
6
Width = 96
Height = 25
Caption = 'Cancel'
ChildOrder = 79
ElementClassName = 'btn btn-light'
ElementID = 'btncancel'
ElementFont = efCSS
ElementPosition = epRelative
...
...
@@ -182,7 +180,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Delete'
ChildOrder = 79
ElementClassName = 'btn btn-light'
ElementID = 'btndelete'
ElementFont = efCSS
HeightStyle = ssAuto
...
...
@@ -197,7 +194,6 @@ object FViewItems: TFViewItems
Height = 25
Caption = 'Edit'
ChildOrder = 83
ElementClassName = 'btn btn-light'
ElementID = 'btnedit'
ElementFont = efCSS
HeightStyle = ssAuto
...
...
kgOrdersClient/View.Items.html
View file @
42f8e3e6
...
...
@@ -62,7 +62,7 @@
</div>
</form>
<table
class=
"table table-responsive table-striped table-bordered"
id=
"tblPhoneGrid"
>
<table
class=
"table table-responsive table-striped table-
hover table-
bordered"
id=
"tblPhoneGrid"
>
<thead
class=
"thead-dark"
>
<tr>
<th
scope=
"col"
>
ID
</th>
...
...
kgOrdersClient/View.Items.pas
View file @
42f8e3e6
...
...
@@ -2,7 +2,7 @@
// to sort the entries, filter their search, and search for a specific person.
// Authors:
// Cameron Hayes
// Mac
...
// Mac
Stephens
unit
View
.
Items
;
...
...
@@ -115,46 +115,74 @@ begin
cbStatus
.
enabled
:=
true
;
end
;
procedure
TFViewItems
.
AddRowToTable
(
ID
,
Name
,
Description
,
Status
:
string
);
// Adds rows to the table
// ID: item ID
// Name: item name
// Description: item description
// Status: inactive or active
// Adds one row to #tblPhoneGrid and lets Bootstrap 5.3 highlight the row
// with its built-in `table-active` class when the user clicks it.
var
NewRow
,
Cell
,
P
,
Button
,
Audio
:
TJSHTMLElement
;
NewRow
,
Cell
:
TJSHTMLElement
;
begin
NewRow
:=
TJSHTMLElement
(
document
.
createElement
(
'tr'
));
// Item ID Cell
// Row-select click handler
NewRow
.
addEventListener
(
'click'
,
procedure
(
Event
:
TJSMouseEvent
)
var
TBody
:
TJSHTMLElement
;
Rows
:
TJSHTMLCollection
;
I
:
Integer
;
RowElem
:
TJSHTMLElement
;
begin
// Grab the <tbody> once and cast it
TBody
:=
TJSHTMLElement
(
(
document
.
getElementById
(
'tblPhoneGrid'
)
as
TJSHTMLElement
)
.
getElementsByTagName
(
'tbody'
)[
0
]
);
// Remove 'table-active' from every existing row
Rows
:=
TBody
.
children
;
for
I
:=
0
to
Rows
.
length
-
1
do
begin
RowElem
:=
TJSHTMLElement
(
Rows
.
item
(
I
));
// ? cast Node ? HTMLElement
RowElem
.
classList
.
remove
(
'table-primary'
);
end
;
// Add highlight to the clicked row
TJSHTMLElement
(
Event
.
currentTarget
).
classList
.
add
(
'table-primary'
);
end
);
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Item ID'
);
Cell
.
innerText
:=
ID
;
NewRow
.
appendChild
(
Cell
);
// Name Cell
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Name'
);
Cell
.
innerText
:=
Name
;
NewRow
.
appendChild
(
Cell
);
// Description Cell
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Description'
);
Cell
.
innerText
:=
Description
;
NewRow
.
appendChild
(
Cell
);
// Status Cell
Cell
:=
TJSHTMLElement
(
document
.
createElement
(
'td'
));
Cell
.
setAttribute
(
'data-label'
,
'Status'
);
Cell
.
innerText
:=
Status
;
NewRow
.
appendChild
(
Cell
);
// Appends new rows to the table body
TJSHTMLElement
(
document
.
getElementById
(
'tblPhoneGrid'
).
getElementsByTagName
(
'tbody'
)[
0
]).
appendChild
(
NewRow
);
TJSHTMLElement
(
(
document
.
getElementById
(
'tblPhoneGrid'
)
as
TJSHTMLElement
)
.
getElementsByTagName
(
'tbody'
)[
0
]
).
appendChild
(
NewRow
);
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFViewItems
.
GeneratePagination
(
TotalPages
:
Integer
);
// Generates pagination for the table.
// TotalPages: Total amount of pages generated by the search
...
...
@@ -339,13 +367,13 @@ begin
if
PageNumber
>
0
then
begin
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetItems'
,
[
searchOptions
]));
itemList
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
itemList
[
'data'
]);
itemListLength
:=
integer
(
itemList
[
'count'
]);
ClearTable
();
Utils
.
HideSpinner
(
'Spinner'
);
for
i
:=
0
to
data
.
Length
-
1
do
begin
item
:=
TJSObject
(
data
[
i
]);
...
...
@@ -366,6 +394,11 @@ begin
' of '
+
IntToStr
(
itemListLength
);
end
;
GeneratePagination
(
TotalPages
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve items: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
...
...
@@ -466,11 +499,16 @@ procedure TFViewItems.AddItem(itemOptions: string);
var
xdcResponse
:
TXDataClientResponse
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddItem'
,
[
itemOptions
]));
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddItem'
,
[
itemOptions
]));
getItems
(
GenerateSearchOptions
());
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not add item: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFViewItems
.
wcbPageSizeChange
(
Sender
:
TObject
);
// gets a new amount of items based when the page size is changed
begin
...
...
kgOrdersClient/View.Main.html
View file @
42f8e3e6
...
...
@@ -69,6 +69,27 @@
</div>
</div>
<div
class=
"modal fade"
id=
"main_errormodal"
tabindex=
"-1"
aria-labelledby=
"main_lblmodal"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content shadow-lg"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"main_lblmodal"
>
Error
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
<div
class=
"modal-body fs-6 fw-bold"
id=
"main_lblmodal_body"
>
Please contact EMSystems to solve the issue.
</div>
<div
class=
"modal-footer justify-content-center"
>
<button
type=
"button"
id=
"btn_modal_restart"
class=
"btn btn-primary"
>
Restart WebApp
</button>
</div>
</div>
</div>
</div>
kgOrdersClient/View.Main.pas
View file @
42f8e3e6
...
...
@@ -315,4 +315,5 @@ begin
FChildForm
:=
TFViewUsers
.
CreateForm
(
WebPanel1
.
ElementID
,
Info
);
end
;
end
.
kgOrdersClient/View.OrderEntryCorrugated.pas
View file @
42f8e3e6
...
...
@@ -553,7 +553,7 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
try
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderCorrugatedPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
...
...
@@ -562,8 +562,13 @@ begin
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate corrugated PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCorrugated
.
AddCorrugatedOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
...
...
@@ -585,10 +590,16 @@ procedure TFOrderEntryCorrugated.DelOrder();
var
Response
:
TXDataClientResponse
;
begin
try
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.DelOrder'
,
[
OrderID
,
'corrugated'
,
JS
.
toString
(
AuthService
.
TokenPayload
.
Properties
[
'user_id'
])]));
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not delete order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
class
function
TFOrderEntryCorrugated
.
CreateForm
(
AElementID
,
orderInfo
,
customerInfo
,
mode
,
info
:
string
):
TWebForm
;
var
localMode
:
string
;
...
...
@@ -606,7 +617,6 @@ begin
end
;
end
);
end
;
procedure
TFOrderEntryCorrugated
.
addColorRow
(
num
:
string
;
Color
:
string
;
LPI
:
string
;
Size
:
string
);
...
...
@@ -821,8 +831,8 @@ var
colorListJSON
:
TJSONArray
;
items
:
TJSObject
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrder'
,
[
Order_ID
]));
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
data
:=
TJSArray
(
order
[
'data'
]);
XDataWebDataSet1
.
Close
;
...
...
@@ -953,7 +963,10 @@ begin
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCorrugated
.
getCustomer
(
customerID
:
string
);
...
...
@@ -964,8 +977,8 @@ var
address
:
string
;
items
:
TJSObject
;
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomer'
,
[
customerID
]));
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCustomer'
,
[
customerID
]));
customer
:=
TJSObject
(
xdcResponse
.
Result
);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
customer
);
...
...
@@ -989,6 +1002,10 @@ begin
dtpMountDue
.
Date
:=
0
;
dtpShipDate
.
Date
:=
0
;
dtpApprovedDate
.
Date
:=
0
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve customer: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCorrugated
.
WebFormShow
(
Sender
:
TObject
);
...
...
kgOrdersClient/View.OrderEntryCuttingDie.pas
View file @
42f8e3e6
...
...
@@ -394,7 +394,7 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
try
// Call the server method to generate the PDF
console
.
log
(
orderID
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderCuttingPDF'
,
[
orderID
]));
...
...
@@ -404,22 +404,33 @@ begin
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate cutting die PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryCuttingDie
.
AddCuttingDieOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
Response
:
TXDataClientResponse
;
jsObj
:
TJSObject
;
begin
try
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddCuttingDieOrder'
,
[
orderJSON
.
ToString
]));
jsObj
:=
JS
.
TJSObject
(
Response
.
Result
);
if
mode
=
'ADD'
then
OrderID
:=
String
(
jsObj
.
Properties
[
'OrderID'
]);
mode
:=
'EDIT'
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not save cutting die order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
class
function
TFOrderEntryCuttingDie
.
CreateForm
(
AElementID
,
orderInfo
,
customerInfo
,
mode
,
info
:
string
):
TWebForm
;
var
localMode
:
string
;
...
...
@@ -438,7 +449,6 @@ begin
end
;
end
);
end
;
procedure
TFOrderEntryCuttingDie
.
btnAddClick
(
Sender
:
TObject
);
...
...
@@ -513,6 +523,8 @@ var
data
:
TJSArray
;
order
,
items
:
TJSObject
;
begin
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetCuttingDieOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
...
...
@@ -522,7 +534,6 @@ begin
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
...
...
@@ -555,8 +566,14 @@ begin
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFOrderEntryCuttingDie
.
getCustomer
(
customerID
:
string
);
// gets a customer from the database then loads the appropiate fields
var
...
...
kgOrdersClient/View.OrderEntryWeb.pas
View file @
42f8e3e6
...
...
@@ -593,7 +593,7 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
try
// Call the server method to generate the PDF
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GenerateOrderWebPDF'
,
[
orderID
]));
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
...
...
@@ -602,23 +602,33 @@ begin
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
window
.
open
(
pdfURL
,
'_blank'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate web order PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFOrderEntryWeb
.
AddWebOrder
(
orderJSON
:
TJSONObject
);
// sends the order JSON object to the server
var
Response
:
TXDataClientResponse
;
jsObj
:
TJSObject
;
begin
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddWebOrder'
,
[
orderJSON
.
ToString
]));
try
Response
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.AddWebOrder'
,
[
orderJSON
.
ToString
]));
jsObj
:=
JS
.
TJSObject
(
Response
.
Result
);
if
mode
=
'ADD'
then
OrderID
:=
String
(
jsObj
.
Properties
[
'OrderID'
]);
console
.
log
(
OrderID
);
mode
:=
'EDIT'
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not save web order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
class
function
TFOrderEntryWeb
.
CreateForm
(
AElementID
,
orderInfo
,
customerInfo
,
mode
,
info
:
string
):
TWebForm
;
var
localMode
:
string
;
...
...
@@ -784,6 +794,8 @@ var
colorListJSON
:
TJSONArray
;
items
:
TJSObject
;
begin
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetWebOrder'
,
[
Order_ID
]));
order
:=
TJSObject
(
xdcResponse
.
Result
);
...
...
@@ -791,6 +803,7 @@ begin
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
order
);
XDataWebDataSet1
.
Open
;
if
XDataWebDataSet1quantity_and_colors_qty_colors
.
Value
<>
''
then
begin
colorObject
:=
TJSObject
(
TJSJSON
.
parse
(
XDataWebDataSet1quantity_and_colors_qty_colors
.
Value
));
...
...
@@ -803,7 +816,6 @@ begin
end
;
// Dates need to be manually set
if
not
(
XDataWebDataSet1staff_fields_order_date
.
AsString
=
''
)
then
dtpOrderDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1staff_fields_order_date
.
Value
)
else
...
...
@@ -829,12 +841,10 @@ begin
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
...
...
@@ -844,12 +854,10 @@ begin
dtpInkJetDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_1
.
Value
)
else
dtpInkJetDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_2
.
AsString
=
''
)
then
dtpInkJetDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_2
.
Value
)
else
dtpInkJetDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_ink_jet_date_3
.
AsString
=
''
)
then
dtpInkJetDate3
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_ink_jet_date_3
.
Value
)
else
...
...
@@ -859,18 +867,15 @@ begin
dtpColorContractDate1
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_color_contrac_date_1
.
Value
)
else
dtpColorContractDate1
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_color_contrac_date_2
.
AsString
=
''
)
then
dtpColorContractDate2
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_color_contrac_date_2
.
Value
)
else
dtpColorContractDate2
.
Date
:=
0
;
if
not
(
XDataWebDataSet1proofing_digital_color_date_1
.
AsString
=
''
)
then
dtpDigitalColorDate
.
Date
:=
StrToDateTime
(
XDataWebDataSet1proofing_digital_color_date_1
.
Value
)
else
dtpDigitalColorDate
.
Date
:=
0
;
if
mode
=
'EDIT'
then
begin
CustomerID
:=
XDataWebDataSet1COMPANY_ID
.
AsString
;
...
...
@@ -883,9 +888,15 @@ begin
items
:=
TJSObject
(
order
[
'ITEMS'
]);
xdwdsQBItem
.
SetJsonData
(
items
[
'data'
]);
xdwdsQBITEM
.
Open
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve order: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFOrderEntryWeb
.
getCustomer
(
customerID
:
string
);
// gets a customer from the database then loads the appropiate fields
var
...
...
kgOrdersClient/View.Orders.dfm
View file @
42f8e3e6
object FViewOrders: TFViewOrders
Width = 676
Height = 480
Caption = 'main.errorpanel'
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
...
...
kgOrdersClient/View.Orders.pas
View file @
42f8e3e6
...
...
@@ -13,7 +13,7 @@ uses
WEBLib
.
Forms
,
WEBLib
.
Dialogs
,
WEBLib
.
Menus
,
WEBLib
.
ExtCtrls
,
WEBLib
.
StdCtrls
,
WEBLib
.
JSON
,
Auth
.
Service
,
XData
.
Web
.
Client
,
WebLib
.
Storage
,
ConnectionModule
,
App
.
Types
,
Vcl
.
StdCtrls
,
Vcl
.
Controls
,
WEBLib
.
DBCtrls
,
XData
.
Web
.
JsonDataset
,
WEBLib
.
DB
,
Data
.
DB
,
XData
.
Web
.
Dataset
,
XData
.
Web
.
JsonDataset
,
WEBLib
.
DB
,
Data
.
DB
,
XData
.
Web
.
Dataset
,
XData
.
Web
.
DatasetCommon
,
WEBLib
.
Grids
;
type
...
...
@@ -156,6 +156,8 @@ var
searchOptions
,
pdfURL
:
string
;
jsObject
:
TJSObject
;
begin
Utils
.
ShowSpinner
(
'spinner'
);
try
searchOptions
:=
edtSearch
.
Text
;
// Call the server method to generate the PDF
...
...
@@ -163,16 +165,16 @@ begin
jsObject
:=
JS
.
TJSObject
(
xdcResponse
.
Result
);
pdfURL
:=
JS
.
toString
(
jsObject
.
Properties
[
'value'
]);
// Open the PDF in a new browser tab without needing a different form
// This method is much faster too, even for large datasets
// Open the PDF in a new browser tab
window
.
open
(
pdfURL
,
'_blank'
);
begin
Utils
.
HideSpinner
(
'Spinner'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not generate report PDF: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFViewOrders
.
WebButton1Click
(
Sender
:
TObject
);
begin
if
OrderID
<>
''
then
...
...
@@ -651,57 +653,56 @@ begin
end
);
PageItem
.
appendChild
(
PageLink
);
PaginationElement
.
appendChild
(
PageItem
);
end
;
procedure
TFViewOrders
.
GetOrders
(
searchOptions
:
string
);
// retrieves a list of orders that fit a given search criteria
// searchOptions: search info to be sent to the server
var
xdcResponse
:
TXDataClientResponse
;
orderList
:
TJSObject
;
orderListLength
:
integer
;
TotalPages
:
integer
;
orderListLength
,
TotalPages
:
Integer
;
begin
Utils
.
ShowSpinner
(
'spinner'
);
if
PageNumber
>
0
then
try
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrders'
,
[
searchOptions
]));
if
Assigned
(
xdcResponse
.
Result
)
then
begin
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetOrders'
,
[
searchOptions
]));
orderList
:=
TJSObject
(
xdcResponse
.
Result
);
// Load data into the dataset
xdwdsOrders
.
Close
;
xdwdsOrders
.
SetJsonData
(
orderList
[
'data'
]);
xdwdsOrders
.
Open
;
orderListLength
:=
integer
(
orderList
[
'count'
]);
TotalPages
:=
(
(
orderListLength
+
PageSize
-
1
)
div
PageSize
);
orderListLength
:=
Integer
(
orderList
[
'count'
]);
TotalPages
:=
(
orderListLength
+
PageSize
-
1
)
div
PageSize
;
GeneratePagination
(
TotalPages
);
// Update label
if
orderListLength
=
0
then
begin
lblEntries
.
Caption
:=
'No entries found'
;
end
lblEntries
.
Caption
:=
'No entries found'
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
);
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
;
// Optional: Continue using pagination if needed
GeneratePagination
(
TotalPages
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve orders: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
finally
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
procedure
TFViewOrders
.
btnAddOrderClick
(
Sender
:
TObject
);
begin
ShowAddOrderForm
();
...
...
kgOrdersClient/View.SelectCustomer.pas
View file @
42f8e3e6
...
...
@@ -97,21 +97,26 @@ var
customerList
:
TJSObject
;
i
:
integer
;
begin
try
// Fetch data from XData service
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.getQBCustomers'
,
[]));
customerList
:=
TJSObject
(
xdcResponse
.
Result
);
// Load data into TXDataWebDataset
xdwdsCustomers
.
Close
;
xdwdsCustomers
.
SetJsonData
(
customerList
);
xdwdsCustomers
.
Open
;
// Manually populate the grid
PopulateGridManually
;
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve QuickBooks customers: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
procedure
TFSelectCustomer
.
PopulateGridManually
;
// populates the grid with customers manually.
var
...
...
kgOrdersClient/View.Users.pas
View file @
42f8e3e6
...
...
@@ -6,7 +6,7 @@ uses
System
.
SysUtils
,
System
.
Classes
,
Web
,
WEBLib
.
Graphics
,
WEBLib
.
Forms
,
WEBLib
.
Dialogs
,
Vcl
.
Controls
,
Vcl
.
StdCtrls
,
WEBLib
.
StdCtrls
,
WEBLib
.
Controls
,
WEBLib
.
Grids
,
WebLib
.
Lists
,
XData
.
Web
.
Client
,
WEBLib
.
ExtCtrls
,
DB
,
XData
.
Web
.
JsonDataset
,
XData
.
Web
.
Dataset
,
XData
.
Web
.
Connection
,
Vcl
.
Forms
,
WEBLib
.
DBCtrls
,
JS
;
XData
.
Web
.
Dataset
,
XData
.
Web
.
Connection
,
Vcl
.
Forms
,
WEBLib
.
DBCtrls
,
JS
,
Utils
;
type
TFViewUsers
=
class
(
TWebForm
)
...
...
@@ -330,10 +330,11 @@ var
data
:
TJSArray
;
user
:
TJSObject
;
userListLength
:
integer
;
begin
if
PageNumber
>
0
then
begin
Utils
.
ShowSpinner
(
'spinner'
);
try
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.GetUsers'
,
[
searchOptions
]));
...
...
@@ -368,6 +369,11 @@ begin
' of '
+
IntToStr
(
userListLength
);
end
;
GeneratePagination
(
TotalPages
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
'Could not retrieve users: '
+
E
.
ErrorResult
.
ErrorMessage
);
end
;
Utils
.
HideSpinner
(
'spinner'
);
end
;
end
;
...
...
kgOrdersClient/webKGOrders.dproj
View file @
42f8e3e6
...
...
@@ -5,7 +5,7 @@
<FrameworkType>VCL</FrameworkType>
<MainSource>webKGOrders.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">
Release
</Config>
<Config Condition="'$(Config)'==''">
Debug
</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>1</TargetedPlatforms>
<AppType>Application</AppType>
...
...
@@ -208,7 +208,6 @@
<DCCReference Include="Utils.pas"/>
<DCCReference Include="View.AddItem.pas">
<Form>fViewAddItem</Form>
<FormType>dfm</FormType>
<DesignClass>TWebForm</DesignClass>
</DCCReference>
<None Include="index.html"/>
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
42f8e3e6
This diff is collapsed.
Click to expand it.
kgOrdersServer/kgOrdersServer.ini
View file @
42f8e3e6
...
...
@@ -2,11 +2,11 @@
MemoLogLevel
=
3
FileLogLevel
=
5
webClientVersion
=
0.9.4
LogFileNum
=
7
10
LogFileNum
=
7
21
[Database]
Server
=
192.168.159.131
--
Server
=
192.168.102.130
--
Server
=
192.168.159.131
Server
=
192.168.102.130
--Server
=
192.168.75.133
Database
=
kg_order_entry
Username
=
root
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment