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
85750ff1
Commit
85750ff1
authored
Mar 19, 2026
by
Cam Hayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Items to be more similar to customers with the update button.
parent
ec0623e0
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
315 additions
and
125 deletions
+315
-125
View.Customer.Add.dfm
kgOrdersClient/View.Customer.Add.dfm
+2
-13
View.Customer.Add.html
kgOrdersClient/View.Customer.Add.html
+1
-4
View.Customer.Add.pas
kgOrdersClient/View.Customer.Add.pas
+113
-76
View.Customer.Select.dfm
kgOrdersClient/View.Customer.Select.dfm
+6
-0
View.Customer.Select.pas
kgOrdersClient/View.Customer.Select.pas
+5
-0
View.Items.pas
kgOrdersClient/View.Items.pas
+67
-26
app.css
kgOrdersClient/css/app.css
+12
-1
Lookup.Service.pas
kgOrdersServer/Source/Lookup.Service.pas
+1
-0
Lookup.ServiceImpl.pas
kgOrdersServer/Source/Lookup.ServiceImpl.pas
+108
-5
No files found.
kgOrdersClient/View.Customer.Add.dfm
View file @
85750ff1
...
...
@@ -19,9 +19,9 @@ object FViewAddCustomer: TFViewAddCustomer
Height = 22
ChildOrder = 12
ElementID = 'edtcompanyaccountname'
Enabled = False
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtShortNameChange
DataField = 'SHORT_NAME'
DataSource = WebDataSource1
end
...
...
@@ -155,18 +155,6 @@ object FViewAddCustomer: TFViewAddCustomer
WidthPercent = 100.000000000000000000
OnClick = btnCloseClick
end
object btnEdit: TWebButton
Left = 19
Top = 504
Width = 96
Height = 25
Caption = 'Edit'
ChildOrder = 83
ElementID = 'btnedit'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnEditClick
end
object edtCustomerID: TWebDBEdit
Left = 151
Top = 12
...
...
@@ -419,6 +407,7 @@ object FViewAddCustomer: TFViewAddCustomer
ElementID = 'wdblcbrep'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = wdblcbRepChange
DataField = 'REP_USER_ID'
DataSource = WebDataSource1
KeyField = 'userID'
...
...
kgOrdersClient/View.Customer.Add.html
View file @
85750ff1
...
...
@@ -12,11 +12,8 @@
<li
class=
"nav-item pe-2"
>
<button
id=
"btnadd"
class=
"btn btn-primary btn-sm"
>
Add
</button>
</li>
<li
class=
"nav-item pe-2"
>
<button
id=
"btnedit"
class=
"btn btn-primary btn-sm"
>
Edit
</button>
</li>
<li
class=
"nav-item pe-2"
>
<button
id=
"btnupdate"
class=
"btn btn-primary btn-sm"
>
Edit
</button>
<button
id=
"btnupdate"
class=
"btn btn-primary btn-sm"
>
Update
</button>
</li>
<li
class=
"nav-item pe-2"
>
<button
id=
"btnlink"
class=
"btn btn-primary btn-sm"
>
Link
</button>
...
...
kgOrdersClient/View.Customer.Add.pas
View file @
85750ff1
...
...
@@ -24,7 +24,6 @@ type
btnCancel
:
TWebButton
;
btnDelete
:
TWebButton
;
btnClose
:
TWebButton
;
btnEdit
:
TWebButton
;
XDataWebClient1
:
TXDataWebClient
;
WebDataSource1
:
TWebDataSource
;
XDataWebDataSet1
:
TXDataWebDataSet
;
...
...
@@ -96,6 +95,8 @@ type
procedure
btnShipCancelClick
(
Sender
:
TObject
);
procedure
btnLinkClic
(
Sender
:
TObject
);
procedure
btnUpdateClick
(
Sender
:
TObject
);
procedure
wdblcbRepChange
(
Sender
:
TObject
);
procedure
edtShortNameChange
(
Sender
:
TObject
);
private
{ Private declarations }
procedure
ViewMode
();
...
...
@@ -150,7 +151,8 @@ end;
[
async
]
procedure
TFViewAddCustomer
.
InitializeForm
;
var
JSONObj
:
TJSONObject
;
JSONObj
,
obj
:
TJSONObject
;
arr
:
TJSONArray
;
begin
if
customerID
=
''
then
begin
...
...
@@ -166,6 +168,7 @@ begin
XDataWebDataSet1
.
FieldByName
(
'BILL_CITY'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_CITY'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_STATE'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_STATE'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_ZIP'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_ZIP'
).
Value
;
XDataWebDataSet1
.
FieldByName
(
'BILL_CONTACT'
).
AsString
:=
JSONObj
.
GetValue
(
'BILL_CONTACT'
).
Value
;
//XDataWebDataSet1.FieldByName('BILL_ADDRESS_BLOCK').AsString := JSONObj.GetValue('BILL_ADDRESS_BLOCK').Value;
XDataWebDataSet1
.
Post
;
...
...
@@ -175,10 +178,10 @@ begin
xdwdsShipTo
.
FieldByName
(
'city'
).
AsString
:=
JSONObj
.
GetValue
(
'city'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'state'
).
AsString
:=
JSONObj
.
GetValue
(
'state'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'zip'
).
AsString
:=
JSONObj
.
GetValue
(
'zip'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'ADDRESS'
).
AsString
:=
JSONObj
.
GetValue
(
'ship_block'
).
Value
;
xdwdsShipTo
.
FieldByName
(
'contact'
).
AsString
:=
JSONObj
.
GetValue
(
'contact'
).
Value
;
xdwdsShipTo
.
Post
;
//XDataWebDataSet1.FieldByName('SHIP_BLOCK').AsString := JSONObj.GetValue('ship_block').Value;
xdwdsShipTo
.
First
;
EditMode
();
finally
...
...
@@ -186,14 +189,11 @@ begin
end
;
end
else
begin
mode
:=
'EDIT'
;
if
mode
=
'ADD'
then
EditMode
()
else
await
(
GetCustomer
);
ViewMode
();
await
(
GetCustomer
);
end
;
end
;
procedure
TFViewAddCustomer
.
Clear
();
...
...
@@ -305,6 +305,11 @@ begin
if
confirmed
then
begin
FViewMain
.
change
:=
false
;
TJSHTMLInputElement
(
document
.
getElementById
(
'edtcompanyname'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingaddress'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingcity'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingstate'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingzip'
)).
classList
.
remove
(
'changed-field'
);
if
CustomerID
<>
''
then
FViewMain
.
ViewAddCustomer
(
CustomerID
,
'Failure: Changes Discarded'
)
else
...
...
@@ -377,6 +382,18 @@ begin
end
;
procedure
TFViewAddCustomer
.
edtShortNameChange
(
Sender
:
TObject
);
begin
if
lblFormState
.
Caption
<>
'Edit Mode'
then
EditMode
();
end
;
procedure
TFViewAddCustomer
.
wdblcbRepChange
(
Sender
:
TObject
);
begin
if
lblFormState
.
Caption
<>
'Edit Mode'
then
EditMode
();
end
;
procedure
TFViewAddCustomer
.
wdbtcAddressesDblClickCell
(
Sender
:
TObject
;
ACol
,
ARow
:
Integer
);
// Retrieves the shipping address allowing it to be edited.
...
...
@@ -394,9 +411,6 @@ begin
edtFirstLine
.
Text
:=
memoShipBlock
.
Lines
[
0
]
else
edtFirstLine
.
Text
:=
''
;
btnShipEdit
.
Enabled
:=
true
;
btnShipDelete
.
Enabled
:=
true
;
end
;
procedure
TFViewAddCustomer
.
btnUpdateClick
(
Sender
:
TObject
);
...
...
@@ -411,63 +425,78 @@ procedure TFViewAddCustomer.UpdateCustomer;
var
customer
:
TJSObject
;
xdcResponse
:
TXDataClientResponse
;
msg
:
string
;
count
:
integer
;
begin
Utils
.
ShowSpinner
(
'spinner'
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.UpdateCustomer'
,
[
XDataWebDataSet1QB_LIST_ID
.
AsString
]));
customer
:=
TJSObject
(
xdcResponse
.
Result
);
msg
:=
'The following fields have been updated:'
+
#
13
#
10
;
count
:=
0
;
if
string
(
customer
[
'NAME'
])
<>
XDataWebDataSet1NAME
.
AsString
then
begin
msg
:=
msg
+
'Company Name'
+
#
13
#
10
;
count
:=
count
+
1
;
end
;
if
string
(
customer
[
'BILL_ADDRESS'
])
<>
XDataWebDataSet1BILL_ADDRESS
.
AsString
then
begin
count
:=
count
+
1
;
msg
:=
msg
+
'Billing Address'
+
#
13
#
10
;
end
;
msg
,
temp
:
string
;
change
:
boolean
;
input
:
TJSHTMLInputElement
;
begin
try
Utils
.
ShowSpinner
(
'spinner'
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.UpdateCustomer'
,
[
XDataWebDataSet1QB_LIST_ID
.
AsString
]));
customer
:=
TJSObject
(
xdcResponse
.
Result
);
change
:=
false
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtcompanyname'
));
if
string
(
customer
[
'NAME'
])
<>
XDataWebDataSet1NAME
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
if
string
(
customer
[
'BILL_CITY'
])
<>
XDataWebDataSet1BILL_CITY
.
AsString
then
begin
count
:=
count
+
1
;
if
count
>
2
then
msg
:=
msg
+
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
;
msg
:=
msg
+
'Billing City'
+
#
13
#
10
;
end
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingaddress'
));
if
string
(
customer
[
'BILL_ADDRESS'
])
<>
XDataWebDataSet1BILL_ADDRESS
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
if
string
(
customer
[
'BILL_STATE'
])
<>
XDataWebDataSet1BILL_STATE
.
AsString
then
begin
count
:=
count
+
1
;
if
count
>
2
then
msg
:=
msg
+
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
;
msg
:=
msg
+
'Billing State'
+
#
13
#
10
;
end
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingcity'
));
if
string
(
customer
[
'BILL_CITY'
])
<>
XDataWebDataSet1BILL_CITY
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
if
string
(
customer
[
'BILL_ZIP'
])
<>
XDataWebDataSet1BILL_ZIP
.
AsString
then
begin
count
:=
count
+
1
;
if
count
>
2
then
msg
:=
msg
+
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
#
160
;
msg
:=
msg
+
'Billing Zip'
+
#
13
#
10
;
end
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingstate'
));
if
string
(
customer
[
'BILL_STATE'
])
<>
XDataWebDataSet1BILL_STATE
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
if
msg
=
'The following fields have been updated:'
+
#
13
#
10
then
msg
:=
'No fields needed to be updated'
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingzip'
));
if
string
(
customer
[
'BILL_ZIP'
])
<>
XDataWebDataSet1BILL_ZIP
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
customer
);
XDataWebDataSet1
.
Open
;
XDataWebDataSet1
.
Close
;
XDataWebDataSet1
.
SetJsonData
(
customer
);
XDataWebDataSet1
.
Open
;
memoAddressBlock
.
Text
:=
string
(
customer
[
'staff_fields_invoice_to'
]);
Utils
.
HideSpinner
(
'spinner'
);
if
msg
<>
'No fields needed to be updated'
then
EditMode
;
ShowMessage
(
msg
);
memoAddressBlock
.
Text
:=
string
(
customer
[
'staff_fields_invoice_to'
]);
Utils
.
HideSpinner
(
'spinner'
);
if
change
then
begin
EditMode
;
ShowToast
(
'Update successful. Changes have been highlighted'
);
end
else
ShowToast
(
'Update successful. No Changes needed'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFViewAddCustomer
.
SendCustomerToServer
();
...
...
@@ -543,6 +572,14 @@ begin
input
.
classList
.
add
(
'is-invalid'
);
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'shortnamefeedback'
));
input
.
innerHTML
:=
'Company Account Name must be Unique.'
;
end
else
begin
TJSHTMLInputElement
(
document
.
getElementById
(
'edtcompanyname'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingaddress'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingcity'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingstate'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtbillingzip'
)).
classList
.
remove
(
'changed-field'
);
end
;
end
;
...
...
@@ -703,14 +740,14 @@ begin
input
.
classList
.
remove
(
'is-invalid'
);
//
input := TJSHTMLInputElement(document.getElementById('edtcompanyaccountname'));
//
if edtShortName.Text = '' then
//
begin
//
input.classList.add('is-invalid');
//
result := false;
//
end
//
else
//
input.classList.remove('is-invalid');
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtcompanyaccountname'
));
if
edtShortName
.
Text
=
''
then
begin
input
.
classList
.
add
(
'is-invalid'
);
result
:=
false
;
end
else
input
.
classList
.
remove
(
'is-invalid'
);
// Billing Information Verification
...
...
@@ -832,8 +869,8 @@ begin
btnClose
.
Enabled
:=
false
;
btnSave
.
Enabled
:=
true
;
btnCancel
.
Enabled
:=
True
;
btnEdit
.
Enabled
:=
false
;
btnLink
.
Enabled
:=
false
;
btnUpdate
.
Enabled
:=
false
;
// Disable Shipping Address Editting
edtShippingAddress
.
Enabled
:=
false
;
...
...
@@ -863,9 +900,9 @@ begin
btnClose
.
Enabled
:=
false
;
btnSave
.
Enabled
:=
false
;
btnCancel
.
Enabled
:=
false
;
btnEdit
.
Enabled
:=
false
;
btnAdd
.
Enabled
:=
false
;
btnLink
.
Enabled
:=
false
;
btnUpdate
.
Enabled
:=
false
;
btnShipDelete
.
Enabled
:=
false
;
btnShipSave
.
Enabled
:=
true
;
...
...
@@ -896,8 +933,8 @@ begin
btnClose
.
Enabled
:=
true
;
btnSave
.
Enabled
:=
false
;
btnCancel
.
Enabled
:=
false
;
btnEdit
.
Enabled
:=
true
;
btnLink
.
Enabled
:=
true
;
btnUpdate
.
Enabled
:=
true
;
FViewMain
.
change
:=
false
;
btnShipAdd
.
Enabled
:=
true
;
...
...
kgOrdersClient/View.Customer.Select.dfm
View file @
85750ff1
...
...
@@ -290,6 +290,12 @@ object FSelectCustomer: TFSelectCustomer
object xdwdsCustomersInKGOrders: TBooleanField
FieldName = 'In KGOrders'
end
object xdwdsCustomersBillAddrContact: TStringField
FieldName = 'BillAddrContact'
end
object xdwdsCustomersShipAddrContact: TStringField
FieldName = 'ShipAddrContact'
end
end
object wdsCustomers: TWebDataSource
DataSet = xdwdsCustomers
...
...
kgOrdersClient/View.Customer.Select.pas
View file @
85750ff1
...
...
@@ -40,6 +40,8 @@ type
WebLabel3
:
TWebLabel
;
edtID
:
TWebEdit
;
xdwdsCustomersInKGOrders
:
TBooleanField
;
xdwdsCustomersBillAddrContact
:
TStringField
;
xdwdsCustomersShipAddrContact
:
TStringField
;
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormShow
(
Sender
:
TObject
);
procedure
btnConfirmClick
(
Sender
:
TObject
);
...
...
@@ -119,12 +121,15 @@ begin
CustomerJSON
.
AddPair
(
'BILL_STATE'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrState'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ZIP'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrZip'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_ADDRESS_BLOCK'
,
xdwdsCustomers
.
FieldByName
(
'BillAddr'
).
AsString
);
CustomerJSON
.
AddPair
(
'BILL_CONTACT'
,
xdwdsCustomers
.
FieldByName
(
'BillAddrContact'
).
AsString
);
CustomerJSON
.
AddPair
(
'address'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrLine1'
).
AsString
);
CustomerJSON
.
AddPair
(
'city'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrCity'
).
AsString
);
CustomerJSON
.
AddPair
(
'state'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrState'
).
AsString
);
CustomerJSON
.
AddPair
(
'zip'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrZip'
).
AsString
);
CustomerJSON
.
AddPair
(
'ship_block'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddr'
).
AsString
);
CustomerJSON
.
AddPair
(
'contact'
,
xdwdsCustomers
.
FieldByName
(
'ShipAddrContact'
).
AsString
);
CustomerJSON
.
AddPair
(
'name'
,
xdwdsCustomers
.
FieldByName
(
'CompanyName'
).
AsString
);
CustomerJSON
.
AddPair
(
'mode'
,
'ADD'
);
...
...
kgOrdersClient/View.Items.pas
View file @
85750ff1
...
...
@@ -53,6 +53,7 @@ type
procedure
EditMode
();
procedure
DisablePagination
();
procedure
EnablePagination
();
[
async
]
procedure
UpdateItem
();
[
async
]
procedure
GetItems
(
searchOptions
:
string
);
[
async
]
procedure
AddItem
();
[
async
]
procedure
InitializeForm
;
...
...
@@ -491,6 +492,9 @@ begin
FViewMain
.
change
:=
false
;
ViewMode
();
ShowToast
(
'failure:Changes Discarded'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtname'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtdescription'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'lblactive'
)).
classList
.
remove
(
'changed-field-label'
);
xdwdsItems
.
Cancel
;
xdwdsItems
.
First
;
getItems
(
GenerateSearchOptions
());
...
...
@@ -511,37 +515,71 @@ var
begin
if
AuthService
.
TokenPayload
.
Properties
[
'qb_enabled'
]
then
begin
newform
:=
TFViewAddItem
.
CreateNew
;
UpdateItem
();
end
else
ShowNotificationModal
(
'QuickBooks interface is not currently active.'
);
end
;
newform
.
Caption
:=
'Select Item to Update'
;
newForm
.
Popup
:=
True
;
newForm
.
position
:=
poScreenCenter
;
newForm
.
Border
:=
fbDialog
;
procedure
TFViewItems
.
UpdateItem
();
var
item
:
TJSObject
;
xdcResponse
:
TXDataClientResponse
;
msg
,
temp
:
string
;
change
:
boolean
;
input
:
TJSHTMLInputElement
;
begin
try
Utils
.
ShowSpinner
(
'spinner'
);
xdcResponse
:=
await
(
XDataWebClient1
.
RawInvokeAsync
(
'ILookupService.UpdateItem'
,
[
xdwdsItemsname
.
AsString
]));
item
:=
TJSObject
(
xdcResponse
.
Result
);
change
:=
false
;
xdwdsItems
.
Edit
;
// used to manage Back button handling to close subform
window
.
location
.
hash
:=
'subform'
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtname'
));
if
string
(
item
[
'name'
])
<>
xdwdsItemsname
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
xdwdsItemsname
.
AsString
:=
string
(
item
[
'name'
]);
newform
.
ShowModal
(
procedure
(
AValue
:
TModalResult
)
begin
if
newform
.
confirm
then
begin
xdwdsItems
.
Edit
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'edtdescription'
));
if
string
(
item
[
'description'
])
<>
xdwdsItemsdescription
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field'
);
xdwdsItemsdescription
.
AsString
:=
string
(
item
[
'description'
]);
xdwdsItems
.
FieldByName
(
'QB_ID'
).
AsString
:=
newform
.
QB_ID
;
xdwdsItems
.
FieldByName
(
'name'
).
AsString
:=
newform
.
name
;
xdwdsItems
.
FieldByName
(
'description'
).
AsString
:=
newform
.
description
;
xdwdsItems
.
FieldByName
(
'status'
).
AsString
:=
newform
.
status
;
input
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'lblactive'
));
if
string
(
item
[
'status'
])
<>
xdwdsItemsstatus
.
AsString
then
begin
input
.
classList
.
add
(
'changed-field-label'
);
change
:=
true
;
end
else
input
.
classList
.
remove
(
'changed-field-label'
);
xdwdsItemsstatus
.
AsString
:=
string
(
item
[
'status'
]);
xdwdsItemsQB_ID
.
AsString
:=
string
(
item
[
'QB_ID'
]);
xdwdsItems
.
Post
;
EditMode
();
lblFormState
.
Caption
:=
'Edit Mode'
;
end
;
end
);
end
else
ShowNotificationModal
(
'QuickBooks interface is not currently active.'
);
xdwdsItems
.
Post
;
Utils
.
HideSpinner
(
'spinner'
);
if
change
then
begin
EditMode
;
ShowToast
(
'Update successful. Changes have been highlighted'
);
end
else
ShowToast
(
'Update successful. No Changes needed'
);
except
on
E
:
EXDataClientRequestException
do
Utils
.
ShowErrorModal
(
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
procedure
TFViewItems
.
btnSaveClick
(
Sender
:
TObject
);
...
...
@@ -578,6 +616,9 @@ begin
getItems
(
GenerateSearchOptions
());
item
:=
TJSObject
(
xdcResponse
.
Result
);
showToast
(
string
(
item
[
'msg'
]));
TJSHTMLInputElement
(
document
.
getElementById
(
'edtname'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'edtdescription'
)).
classList
.
remove
(
'changed-field'
);
TJSHTMLInputElement
(
document
.
getElementById
(
'lblactive'
)).
classList
.
remove
(
'changed-field-label'
);
except
on
E
:
EXDataClientRequestException
do
...
...
kgOrdersClient/css/app.css
View file @
85750ff1
...
...
@@ -30,7 +30,18 @@ input[type=number] {
-moz-appearance
:
textfield
;
}
is-invalid
.form-check-input
{
.changed-field
{
border
:
1px
solid
#ffc107
!important
;
}
.changed-field-label
{
background-color
:
#fff3cd
;
border-radius
:
4px
;
padding
:
2px
6px
;
}
.is-invalid
.form-check-input
{
border
:
1px
solid
#dc3545
!important
;
}
...
...
kgOrdersServer/Source/Lookup.Service.pas
View file @
85750ff1
...
...
@@ -488,6 +488,7 @@ type
[
HttpGet
]
function
getQBItems
():
TJSONArray
;
[
HttpGet
]
function
GetRepUsers
():
TList
<
TUserItem
>;
[
HttpGet
]
function
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
[
HttpGet
]
function
UpdateItem
(
itemName
:
string
):
TItemItem
;
function
AddUser
(
userInfo
:
string
):
string
;
...
...
kgOrdersServer/Source/Lookup.ServiceImpl.pas
View file @
85750ff1
...
...
@@ -40,6 +40,7 @@ type
function
GetQBItems
:
TJSONArray
;
function
GetRepUsers
():
TList
<
TUserItem
>;
function
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
function
UpdateItem
(
itemName
:
string
):
TItemItem
;
function
EditUser
(
const
editOptions
:
string
):
string
;
...
...
@@ -810,7 +811,7 @@ begin
else
TDateTimeField
(
Field
).
AsDateTime
:=
StrToDate
(
Pair
.
JsonValue
.
Value
);
end
else
if
Pair
.
JsonValue
.
Value
<>
''
then
else
Field
.
AsString
:=
Pair
.
JsonValue
.
Value
;
end
;
end
;
...
...
@@ -2821,6 +2822,7 @@ begin
else
begin
ParsedCustomer
.
AddPair
(
'BillAddrLine1'
,
TJSONString
.
Create
(
Line1
));
ParsedCustomer
.
AddPair
(
'BillAddrContact'
,
''
);
ParsedCustomer
.
AddPair
(
'BillAddr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
...
...
@@ -2837,14 +2839,14 @@ begin
// Handle Ship Address
if
Customer
.
GetValue
(
'ShipAddr'
)
is
TJSONObject
then
begin
BillAddr
:=
Customer
.
GetValue
(
'
Bill
Addr'
)
as
TJSONObject
;
BillAddr
:=
Customer
.
GetValue
(
'
Ship
Addr'
)
as
TJSONObject
;
Line1
:=
BillAddr
.
GetValue
<
string
>(
'Line1'
,
''
);
Line2
:=
BillAddr
.
GetValue
<
string
>(
'Line2'
,
''
);
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
(
'
Bill
AddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
ParsedCustomer
.
AddPair
(
'
Ship
AddrZip'
,
TJSONString
.
Create
(
BillAddr
.
GetValue
<
string
>(
'PostalCode'
,
''
)));
if
Line2
<>
''
then
begin
...
...
@@ -2864,6 +2866,7 @@ begin
else
begin
ParsedCustomer
.
AddPair
(
'ShipAddrLine1'
,
TJSONString
.
Create
(
Line1
));
ParsedCustomer
.
AddPair
(
'ShipAddrContact'
,
''
);
ParsedCustomer
.
AddPair
(
'ShipAddr'
,
TJSONString
.
Create
(
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
...
...
@@ -2984,7 +2987,7 @@ begin
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in getQB
Customer
s: '
+
E
.
Message
);
Logger
.
Log
(
2
,
'Error in getQB
Item
s: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks Items: A QuickBooks interface error has occurred!'
);
end
;
end
;
...
...
@@ -2997,6 +3000,105 @@ begin
end
;
end
;
function
TLookupService
.
UpdateItem
(
itemName
:
string
):
TItemItem
;
var
restClient
:
TRESTClient
;
restRequest
:
TRESTRequest
;
restResponse
:
TRESTResponse
;
param
:
TRESTRequestParameter
;
res
:
string
;
jsValue
:
TJSONValue
;
jsObj
:
TJSONObject
;
ItemList
:
TJSONArray
;
ParsedItem
,
Item
:
TJSONObject
;
I
:
integer
;
AccessToken
,
RefreshToken
,
CompanyID
,
Client
,
Secret
,
SQL
,
desc
,
BaseUrl
:
string
;
LastRefresh
:
TDateTime
;
iniFile
:
TIniFile
;
begin
logger
.
Log
(
3
,
'TLookupService.UpdateItem - start'
);
iniFile
:=
nil
;
restClient
:=
nil
;
restRequest
:=
nil
;
restResponse
:=
nil
;
try
try
Result
:=
TItemItem
.
Create
;
iniFile
:=
TIniFile
.
Create
(
ExtractFilePath
(
Application
.
ExeName
)
+
'kgOrdersServer.ini'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restResponse
:=
TRESTResponse
.
Create
(
nil
);
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'
,
''
);
Secret
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'ClientSecret'
,
''
);
CompanyID
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'CompanyID'
,
''
);
RefreshToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'RefreshToken'
,
''
);
AccessToken
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'AccessToken'
,
''
);
BaseUrl
:=
iniFile
.
ReadString
(
'Quickbooks'
,
'BaseUrl'
,
''
);
restClient
.
BaseURL
:=
BaseUrl
;
restRequest
.
Method
:=
rmGET
;
res
:=
'/v3/company/'
+
companyID
+
'/query?query=select * from Item where Name = '
+
quotedStr
(
itemName
)
+
'&minorversion=75'
;
restRequest
.
Resource
:=
res
;
param
:=
restRequest
.
Params
.
AddItem
;
param
.
Name
:=
'Authorization'
;
param
.
Kind
:=
pkHTTPHEADER
;
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Value
:=
'Bearer '
+
AccessToken
;
restRequest
.
Execute
;
jsValue
:=
restResponse
.
JSONValue
;
jsObj
:=
TJSONObject
(
jsValue
);
ItemList
:=
TJSONArray
(
TJSONObject
(
jsObj
.
GetValue
(
'QueryResponse'
)).
GetValue
(
'Item'
));
Item
:=
ItemList
.
Items
[
0
]
as
TJSONObject
;
ParsedItem
:=
TJSONObject
.
Create
;
SQL
:=
'select qb_items_id from qb_items where qb_item_name = '
+
QuotedStr
(
Item
.
GetValue
<
string
>(
'Name'
));
doQuery
(
ordersDB
.
UniQuery1
,
SQL
);
result
.
ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'qb_items_id'
).
AsString
;
result
.
name
:=
Item
.
GetValue
<
string
>(
'Name'
);
if
Item
.
TryGetValue
<
string
>(
'Description'
,
desc
)
then
result
.
description
:=
desc
else
result
.
description
:=
'N/A'
;
result
.
status
:=
Item
.
GetValue
<
string
>(
'Active'
);
if
StrToBool
(
Item
.
GetValue
<
string
>(
'Active'
))
then
result
.
status
:=
'ACTIVE'
else
result
.
status
:=
'INACTIV'
;
result
.
QB_ID
:=
Item
.
GetValue
<
string
>(
'Id'
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'Error in UpdateItem: '
+
E
.
Message
);
raise
EXDataHttpException
.
Create
(
500
,
'Unable to retrieve QuickBooks Items: A QuickBooks interface error has occurred!'
);
end
;
end
;
finally
iniFile
.
Free
;
restClient
.
Free
;
restRequest
.
Free
;
restResponse
.
Free
;
end
;
logger
.
Log
(
3
,
'TLookupService.UpdateItem - end'
);
end
;
function
TLookupService
.
UpdateCustomer
(
QB_ID
:
string
):
TCustomerItem
;
var
iniFile
:
TIniFile
;
...
...
@@ -3068,6 +3170,7 @@ begin
Exit
;
Customer
:=
CustomerList
.
Items
[
I
]
as
TJSONObject
;
logger
.
Log
(
3
,
'Customer JSON recieved from QB: '
+
Customer
.
ToJSON
);
ParsedCustomer
:=
TJSONObject
.
Create
;
custItem
:=
TCustomerItem
.
Create
;
...
...
@@ -3080,7 +3183,6 @@ begin
custItem
.
CUSTOMER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'CUSTOMER_ID'
).
AsInteger
;
custItem
.
SHORT_NAME
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'SHORT_NAME'
).
AsString
;
custItem
.
REP_USER_ID
:=
ordersDB
.
UniQuery1
.
FieldByName
(
'REP_USER_ID'
).
AsString
;
// Handle Bill Address
if
Customer
.
GetValue
(
'BillAddr'
)
is
TJSONObject
then
begin
...
...
@@ -3105,6 +3207,7 @@ begin
else
begin
custItem
.
BILL_ADDRESS
:=
Line1
;
custItem
.
BILL_CONTACT
:=
''
;
custItem
.
staff_fields_invoice_to
:=
Customer
.
GetValue
<
string
>(
'DisplayName'
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'Line1'
,
''
)
+
sLineBreak
+
BillAddr
.
GetValue
(
'City'
,
''
)
+
', '
+
...
...
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