Commit dc71971e by Mac Stephens

Merge remote-tracking branch 'origin/cam'

parents bb24c447 e9209347
...@@ -465,7 +465,7 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -465,7 +465,7 @@ object FViewAddCustomer: TFViewAddCustomer
DataField = 'REP_USER_ID' DataField = 'REP_USER_ID'
DataSource = WebDataSource1 DataSource = WebDataSource1
KeyField = 'userID' KeyField = 'userID'
ListField = 'full_name' ListField = 'representative'
ListSource = wdsUsers ListSource = wdsUsers
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
...@@ -579,5 +579,9 @@ object FViewAddCustomer: TFViewAddCustomer ...@@ -579,5 +579,9 @@ object FViewAddCustomer: TFViewAddCustomer
FieldName = 'full_name' FieldName = 'full_name'
Size = 0 Size = 0
end end
object xdwdsUsersrepresentative: TStringField
FieldName = 'representative'
Size = 0
end
end end
end end
...@@ -79,7 +79,8 @@ type ...@@ -79,7 +79,8 @@ type
XDataWebDataSet1REP_USER_ID: TStringField; XDataWebDataSet1REP_USER_ID: TStringField;
xdwdsUsersfull_name: TStringField; xdwdsUsersfull_name: TStringField;
lblFormState: TWebLabel; lblFormState: TWebLabel;
[async] procedure btnSaveClick(Sender: TObject); [async]
xdwdsUsersrepresentative: TStringField; procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject); procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject); procedure btnEditClick(Sender: TObject);
...@@ -103,6 +104,7 @@ type ...@@ -103,6 +104,7 @@ type
[async] procedure SendCustomerToServer(); [async] procedure SendCustomerToServer();
[async] procedure SendAddressToServer(); [async] procedure SendAddressToServer();
[async] procedure DelAddress(); [async] procedure DelAddress();
[async] procedure Save();
function VerifyCustomer(): boolean; function VerifyCustomer(): boolean;
function VerifyAddress(): boolean; function VerifyAddress(): boolean;
procedure Clear(); procedure Clear();
...@@ -425,12 +427,17 @@ procedure TFViewAddCustomer.btnSaveClick(Sender: TObject); ...@@ -425,12 +427,17 @@ procedure TFViewAddCustomer.btnSaveClick(Sender: TObject);
begin begin
if VerifyCustomer() then if VerifyCustomer() then
begin begin
await(sendCustomerToServer()); Save();
await(GetCustomer());
ViewMode();
end; end;
end; end;
procedure TFViewAddCustomer.Save;
begin
await(sendCustomerToServer());
await(GetCustomer());
ViewMode();
end;
procedure TFViewAddCustomer.btnShipAddClick(Sender: TObject); procedure TFViewAddCustomer.btnShipAddClick(Sender: TObject);
// Sets the form to address edit mode and allows the user to add a shipping address. // Sets the form to address edit mode and allows the user to add a shipping address.
begin begin
......
...@@ -181,7 +181,10 @@ end; ...@@ -181,7 +181,10 @@ end;
procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject); procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject);
begin begin
ShowSelectCustomerForm(); if AuthService.TokenPayload.Properties['qb_enabled'] then
ShowSelectCustomerForm()
else
ShowToast('QB interface not currently active', 'info');
end; end;
procedure TFViewCustomers.edtFilterChange(Sender: TObject); procedure TFViewCustomers.edtFilterChange(Sender: TObject);
......
...@@ -3,8 +3,8 @@ object FViewEditUser: TFViewEditUser ...@@ -3,8 +3,8 @@ object FViewEditUser: TFViewEditUser
Height = 480 Height = 480
OnShow = WebFormCreate OnShow = WebFormCreate
object WebLabel2: TWebLabel object WebLabel2: TWebLabel
Left = 16 Left = 33
Top = 8 Top = 33
Width = 57 Width = 57
Height = 15 Height = 15
Caption = 'Full Name:' Caption = 'Full Name:'
...@@ -14,8 +14,8 @@ object FViewEditUser: TFViewEditUser ...@@ -14,8 +14,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel3: TWebLabel object WebLabel3: TWebLabel
Left = 14 Left = 283
Top = 37 Top = 8
Width = 53 Width = 53
Height = 15 Height = 15
Caption = 'Password:' Caption = 'Password:'
...@@ -25,7 +25,7 @@ object FViewEditUser: TFViewEditUser ...@@ -25,7 +25,7 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel5: TWebLabel object WebLabel5: TWebLabel
Left = 284 Left = 34
Top = 8 Top = 8
Width = 56 Width = 56
Height = 15 Height = 15
...@@ -35,19 +35,8 @@ object FViewEditUser: TFViewEditUser ...@@ -35,19 +35,8 @@ object FViewEditUser: TFViewEditUser
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel6: TWebLabel
Left = 240
Top = 41
Width = 100
Height = 15
Caption = 'Confirm Password:'
Color = clBtnFace
ElementID = 'lblconfirm'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel7: TWebLabel object WebLabel7: TWebLabel
Left = 35 Left = 58
Top = 62 Top = 62
Width = 32 Width = 32
Height = 15 Height = 15
...@@ -58,8 +47,8 @@ object FViewEditUser: TFViewEditUser ...@@ -58,8 +47,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object lblactive: TWebLabel object lblactive: TWebLabel
Left = 45 Left = 298
Top = 163 Top = 36
Width = 38 Width = 38
Height = 15 Height = 15
Caption = 'Active?' Caption = 'Active?'
...@@ -79,8 +68,8 @@ object FViewEditUser: TFViewEditUser ...@@ -79,8 +68,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object lblAccess: TWebLabel object lblAccess: TWebLabel
Left = 272 Left = 269
Top = 96 Top = 93
Width = 67 Width = 67
Height = 15 Height = 15
Caption = 'Access Type:' Caption = 'Access Type:'
...@@ -99,17 +88,6 @@ object FViewEditUser: TFViewEditUser ...@@ -99,17 +88,6 @@ object FViewEditUser: TFViewEditUser
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object edtConfirmPassword: TWebEdit
Left = 348
Top = 34
Width = 121
Height = 22
ChildOrder = 7
ElementID = 'edtconfirmpassword'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtConfirmPasswordChange
end
object edtEmail: TWebEdit object edtEmail: TWebEdit
Left = 96 Left = 96
Top = 62 Top = 62
...@@ -129,14 +107,13 @@ object FViewEditUser: TFViewEditUser ...@@ -129,14 +107,13 @@ object FViewEditUser: TFViewEditUser
ElementID = 'edtpassword' ElementID = 'edtpassword'
HeightPercent = 100.000000000000000000 HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
OnChange = edtPasswordChange
end end
object btnConfirm: TWebButton object btnConfirm: TWebButton
Left = 96 Left = 96
Top = 200 Top = 200
Width = 96 Width = 96
Height = 25 Height = 25
Caption = 'Confirm' Caption = 'Save'
ChildOrder = 9 ChildOrder = 9
ElementClassName = 'btn btn-light' ElementClassName = 'btn btn-light'
ElementID = 'btnconfirm' ElementID = 'btnconfirm'
...@@ -151,8 +128,8 @@ object FViewEditUser: TFViewEditUser ...@@ -151,8 +128,8 @@ object FViewEditUser: TFViewEditUser
OnClick = btnConfirmClick OnClick = btnConfirmClick
end end
object edtFullname: TWebEdit object edtFullname: TWebEdit
Left = 96 Left = 346
Top = 4 Top = 5
Width = 121 Width = 121
Height = 22 Height = 22
ChildOrder = 14 ChildOrder = 14
...@@ -161,8 +138,8 @@ object FViewEditUser: TFViewEditUser ...@@ -161,8 +138,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object edtUsername: TWebEdit object edtUsername: TWebEdit
Left = 346 Left = 96
Top = 4 Top = 6
Width = 121 Width = 121
Height = 22 Height = 22
ChildOrder = 14 ChildOrder = 14
...@@ -190,8 +167,8 @@ object FViewEditUser: TFViewEditUser ...@@ -190,8 +167,8 @@ object FViewEditUser: TFViewEditUser
OnClick = btnCancelClick OnClick = btnCancelClick
end end
object cbStatus: TWebCheckBox object cbStatus: TWebCheckBox
Left = 96 Left = 346
Top = 162 Top = 33
Width = 107 Width = 107
Height = 20 Height = 20
Caption = 'Active?' Caption = 'Active?'
...@@ -217,7 +194,7 @@ object FViewEditUser: TFViewEditUser ...@@ -217,7 +194,7 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object cbAccess: TWebComboBox object cbAccess: TWebComboBox
Left = 352 Left = 346
Top = 90 Top = 90
Width = 145 Width = 145
Height = 23 Height = 23
...@@ -226,12 +203,9 @@ object FViewEditUser: TFViewEditUser ...@@ -226,12 +203,9 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
ItemIndex = -1 ItemIndex = -1
Items.Strings = ( Items.Strings = (
'PLATE' 'SALES'
'MOUNT' 'USER'
'SHIP' 'ADMIN')
'ART'
'ALL'
'ACTIVE')
end end
object edtQB: TWebEdit object edtQB: TWebEdit
Left = 346 Left = 346
...@@ -245,14 +219,14 @@ object FViewEditUser: TFViewEditUser ...@@ -245,14 +219,14 @@ object FViewEditUser: TFViewEditUser
end end
object XDataWebClient1: TXDataWebClient object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection Connection = DMConnection.ApiConnection
Left = 556 Left = 514
Top = 416 Top = 304
end end
object WebTimer1: TWebTimer object WebTimer1: TWebTimer
Enabled = False Enabled = False
Interval = 500 Interval = 500
OnTimer = WebTimer1Timer OnTimer = WebTimer1Timer
Left = 430 Left = 428
Top = 382 Top = 304
end end
end end
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
<form id="edituserform" class="row g-3 needs-validation" novalidate> <form id="edituserform" class="row g-3 needs-validation" novalidate>
<div class="col-md-6"> <div class="col-md-6">
<label id="lblfullname" for="edtfullname" class="form-label">Full&nbsp;Name</label>
<input id="edtfullname" class="form-control" required>
<div class="invalid-feedback">Full Name is required.</div>
</div>
<div class="col-md-6">
<label id="lblusername" for="edtusername" class="form-label">Username</label> <label id="lblusername" for="edtusername" class="form-label">Username</label>
<input id="edtusername" class="form-control" required> <input id="edtusername" class="form-control" required>
<div class="invalid-feedback">Username is required.</div> <div class="invalid-feedback">Username is required.</div>
...@@ -20,19 +14,26 @@ ...@@ -20,19 +14,26 @@
<div class="col-md-6"> <div class="col-md-6">
<label id="lblpassword" for="edtpassword" class="form-label">Password</label> <label id="lblpassword" for="edtpassword" class="form-label">Password</label>
<input id="edtpassword" type="password" class="form-control" required> <input id="edtpassword" type="password" class="form-control" required>
<div class="invalid-feedback">Passwords must match.</div> <div class="invalid-feedback">Passwords is required.</div>
</div>
<div class="col-md-6">
<label id="lblfullname" for="edtfullname" class="form-label">Full&nbsp;Name</label>
<input id="edtfullname" class="form-control" required>
<div class="invalid-feedback">Full Name is required.</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label id="lblconfirm" for="edtconfirmpassword" class="form-label">Confirm&nbsp;Password</label> <label id="lblactive" for="cbstatus" class="form-label">Active</label>
<input id="edtconfirmpassword" type="password" class="form-control" required disabled> <div class="form-check mt-1">
<div class="invalid-feedback">Passwords must match.</div> <input id="cbstatus" class="form-check-input" type="checkbox" style="width: 1.5em; height: 1.5em;">
</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<label id="lblemail" for="edtemail" class="form-label">Email&nbsp;Address</label> <label id="lblemail" for="edtemail" class="form-label">Email&nbsp;Address</label>
<input id="edtemail" type="email" class="form-control" required> <input id="edtemail" type="email" class="form-control">
<div class="invalid-feedback">Valid email is required.</div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
...@@ -47,19 +48,8 @@ ...@@ -47,19 +48,8 @@
<div class="col-md-6"> <div class="col-md-6">
<label id="lblaccess" for="cbaccess" class="form-label">Access&nbsp;Type</label> <label id="lblaccess" for="cbaccess" class="form-label">Access&nbsp;Type</label>
<select id="cbaccess" class="form-select" required> <select id="cbaccess" class="form-select">
<option selected disabled value="">Choose...</option>
<option value="ALL">All</option>
<option value="LIMITED">Limited</option>
</select> </select>
<div class="invalid-feedback">Please select an access type.</div>
</div>
<div class="col-md-6">
<div class="form-check pt-2">
<input id="cbstatus" class="form-check-input" type="checkbox">
<label id="lblactive" for="cbstatus" class="form-check-label">Active</label>
</div>
</div> </div>
<div class="d-flex gap-2 mt-4"> <div class="d-flex gap-2 mt-4">
......
...@@ -15,9 +15,7 @@ type ...@@ -15,9 +15,7 @@ type
WebLabel2: TWebLabel; WebLabel2: TWebLabel;
WebLabel3: TWebLabel; WebLabel3: TWebLabel;
WebLabel5: TWebLabel; WebLabel5: TWebLabel;
WebLabel6: TWebLabel;
WebLabel7: TWebLabel; WebLabel7: TWebLabel;
edtConfirmPassword: TWebEdit;
edtEmail: TWebEdit; edtEmail: TWebEdit;
edtPassword: TWebEdit; edtPassword: TWebEdit;
btnConfirm: TWebButton; btnConfirm: TWebButton;
...@@ -38,8 +36,6 @@ type ...@@ -38,8 +36,6 @@ type
procedure btnConfirmClick(Sender: TObject); procedure btnConfirmClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject); procedure btnCancelClick(Sender: TObject);
procedure WebTimer1Timer(Sender: TObject); procedure WebTimer1Timer(Sender: TObject);
procedure edtPasswordChange(Sender: TObject);
procedure edtConfirmPasswordChange(Sender: TObject);
private private
{ Private declarations } { Private declarations }
FMessage: string; FMessage: string;
...@@ -51,16 +47,14 @@ type ...@@ -51,16 +47,14 @@ type
Email: string; Email: string;
Access: string; Access: string;
Rights: string; Rights: string;
Perspective: string;
QB: string; QB: string;
[async] procedure EditUser(); [async] procedure EditUser();
[async] function AddUser(): string; [async] function AddUser(): string;
procedure ValidatePasswords;
public public
{ Public declarations } { Public declarations }
Info: string; Info: string;
class function CreateForm(AElementID, Mode, Username, Password, Name, Status, Email, class function CreateForm(AElementID, Mode, Username, Password, Name, Status, Email,
Access, Rights, Perspective, QB: string): TWebForm; Access, Rights, QB: string): TWebForm;
end; end;
var var
...@@ -139,18 +133,8 @@ begin ...@@ -139,18 +133,8 @@ begin
end; end;
procedure TFViewEditUser.edtConfirmPasswordChange(Sender: TObject);
begin
ValidatePasswords;
end;
procedure TFViewEditUser.edtPasswordChange(Sender: TObject);
begin
ValidatePasswords;
end;
class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, Name, Status, Email, class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, Name, Status, Email,
Access, Rights, Perspective, QB: string): TWebForm; Access, Rights, QB: string): TWebForm;
// Autofills known information about a user on create // Autofills known information about a user on create
procedure AfterCreate(AForm: TObject); procedure AfterCreate(AForm: TObject);
begin begin
...@@ -161,7 +145,6 @@ class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, N ...@@ -161,7 +145,6 @@ class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, N
TFViewEditUser(AForm).Email := Email; TFViewEditUser(AForm).Email := Email;
TFViewEditUser(AForm).Access := Access; TFViewEditUser(AForm).Access := Access;
TFViewEditUser(AForm).Rights := Rights; TFViewEditUser(AForm).Rights := Rights;
TFViewEditUser(AForm).Perspective := Perspective;
TFViewEditUser(AForm).QB := QB; TFViewEditUser(AForm).QB := QB;
end; end;
...@@ -182,7 +165,6 @@ begin ...@@ -182,7 +165,6 @@ begin
if Mode = 'Edit' then if Mode = 'Edit' then
begin begin
edtPassword.Text := 'hidden'; edtPassword.Text := 'hidden';
edtConfirmPassword.Text := 'hidden';
end; end;
edtEmail.Text := Email; edtEmail.Text := Email;
cbAccess.Text := Access; cbAccess.Text := Access;
...@@ -228,52 +210,4 @@ begin ...@@ -228,52 +210,4 @@ begin
WebTimer1.Enabled := True; WebTimer1.Enabled := True;
end; end;
procedure TFViewEditUser.ValidatePasswords;
var
Pwd, Confirm: string;
PwdInput, ConfirmInput: TJSHTMLInputElement;
begin
PwdInput := TJSHTMLInputElement(edtPassword.ElementHandle);
ConfirmInput := TJSHTMLInputElement(edtConfirmPassword.ElementHandle);
Pwd := PwdInput.value.Trim;
Confirm := ConfirmInput.value.Trim;
// Disable confirm until password exists
if Pwd = '' then
begin
ConfirmInput.disabled := True;
ConfirmInput.value := '';
ConfirmInput.setCustomValidity('');
ConfirmInput.classList.remove('is-invalid');
ConfirmInput.classList.remove('is-valid');
end
else
begin
ConfirmInput.disabled := False;
// Live match check
if Confirm = '' then
begin
ConfirmInput.setCustomValidity('');
ConfirmInput.classList.remove('is-invalid');
ConfirmInput.classList.remove('is-valid');
end
else if Confirm = Pwd then
begin
ConfirmInput.setCustomValidity('');
ConfirmInput.classList.add('is-valid');
ConfirmInput.classList.remove('is-invalid');
end
else
begin
ConfirmInput.setCustomValidity('Passwords must match');
ConfirmInput.classList.add('is-invalid');
ConfirmInput.classList.remove('is-valid');
end;
end;
end;
end. end.
...@@ -444,34 +444,40 @@ var ...@@ -444,34 +444,40 @@ var
itemOptions: string; itemOptions: string;
newform: TFViewAddItem; newform: TFViewAddItem;
begin begin
newform := TFViewAddItem.CreateNew; console.log(AuthService.TokenPayload.Properties['qb_enabled']);
if AuthService.TokenPayload.Properties['qb_enabled'] then
begin
newform := TFViewAddItem.CreateNew;
newform.Caption := 'Select Item to Add'; newform.Caption := 'Select Item to Add';
newForm.Popup := True; newForm.Popup := True;
newForm.position:= poScreenCenter; newForm.position:= poScreenCenter;
newForm.Border := fbDialog; newForm.Border := fbDialog;
// used to manage Back button handling to close subform // used to manage Back button handling to close subform
window.location.hash := 'subform'; window.location.hash := 'subform';
newform.ShowModal( newform.ShowModal(
procedure(AValue: TModalResult) procedure(AValue: TModalResult)
begin
if newform.confirm then
begin begin
xdwdsItems.Append; if newform.confirm then
begin
xdwdsItems.Append;
xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID; xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID;
xdwdsItems.FieldByName('name').AsString := newform.name; xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description; xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status; xdwdsItems.FieldByName('status').AsString := newform.status;
xdwdsItems.Post; xdwdsItems.Post;
EditMode(); EditMode();
lblFormState.Caption := 'Add Mode'; lblFormState.Caption := 'Add Mode';
end; end;
end end
); );
end
else
ShowToast('QB interface not currently active', 'info');
end; end;
procedure TFViewItems.btnCancelClick(Sender: TObject); procedure TFViewItems.btnCancelClick(Sender: TObject);
......
...@@ -50,7 +50,7 @@ type ...@@ -50,7 +50,7 @@ type
{ Public declarations } { Public declarations }
class procedure Display(LogoutProc: TLogoutProc); class procedure Display(LogoutProc: TLogoutProc);
procedure ShowForm( AFormClass: TWebFormClass ); procedure ShowForm( AFormClass: TWebFormClass );
procedure EditUser( Mode, Username, Password, Name, Status, Email, Access, Rights, Perspective, QB: string); procedure EditUser( Mode, Username, Password, Name, Status, Email, Access, Rights, QB: string);
procedure ViewOrderEntryCorrugated(orderInfo, customerInfo, mode, info: string); procedure ViewOrderEntryCorrugated(orderInfo, customerInfo, mode, info: string);
procedure ViewOrderEntryWeb(orderInfo, customerInfo, mode, info: string); procedure ViewOrderEntryWeb(orderInfo, customerInfo, mode, info: string);
procedure ViewOrderEntryCuttingDie(orderInfo, customerInfo, mode, info: string); procedure ViewOrderEntryCuttingDie(orderInfo, customerInfo, mode, info: string);
...@@ -94,8 +94,12 @@ begin ...@@ -94,8 +94,12 @@ begin
lblUsername.Caption := ' ' + userName.ToLower + ' '; lblUsername.Caption := ' ' + userName.ToLower + ' ';
FChildForm := nil; FChildForm := nil;
change := false; change := false;
if (not (JS.toBoolean(AuthService.TokenPayload.Properties['user_admin']))) then console.log(JS.toBoolean(AuthService.TokenPayload.Properties['user_access_type']));
if (not (JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN')) then
begin
lblUsers.enabled := false; lblUsers.enabled := false;
lblCustomers.Enabled := false;
end;
ShowForm(TFViewOrders); ShowForm(TFViewOrders);
lblAppTitle.Caption := 'Koehler-Gibson Orders'; lblAppTitle.Caption := 'Koehler-Gibson Orders';
...@@ -274,12 +278,12 @@ begin ...@@ -274,12 +278,12 @@ begin
end; end;
procedure TFViewMain.EditUser(Mode, Username, Password, Name, Status, Email, procedure TFViewMain.EditUser(Mode, Username, Password, Name, Status, Email,
Access, Rights, Perspective, QB: string); Access, Rights, QB: string);
begin begin
if Assigned(FChildForm) then if Assigned(FChildForm) then
FChildForm.Free; FChildForm.Free;
FChildForm := TFViewEditUser.CreateForm(WebPanel1.ElementID, Mode, Username, FChildForm := TFViewEditUser.CreateForm(WebPanel1.ElementID, Mode, Username,
Password, Name, Status, Email, Access, Rights, Perspective, QB); Password, Name, Status, Email, Access, Rights, QB);
end; end;
procedure TFViewMain.ViewOrders(info: string); procedure TFViewMain.ViewOrders(info: string);
......
...@@ -389,24 +389,31 @@ procedure TFOrderEntryCorrugated.btnQBClick(Sender: TObject); ...@@ -389,24 +389,31 @@ procedure TFOrderEntryCorrugated.btnQBClick(Sender: TObject);
var var
orderJSON: TJSONObject; orderJSON: TJSONObject;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then if AuthService.TokenPayload.Properties['qb_enabled'] then
begin begin
if ( VerifyQBOrder() )then
begin begin
if wdbcbINQB.Checked = false then if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin begin
Utils.ShowSpinner('spinner'); if ( VerifyQBOrder() )then
orderJSON := TJSONObject.Create; begin
orderJSON.AddPair('ORDER_ID', xdwdsOrder.FieldByName('ORDER_ID').AsString); if wdbcbINQB.Checked = false then
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id'])); begin
addEstimate(orderJSON.ToString); Utils.ShowSpinner('spinner');
orderJSON := TJSONObject.Create;
orderJSON.AddPair('ORDER_ID', xdwdsOrder.FieldByName('ORDER_ID').AsString);
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id']));
addEstimate(orderJSON.ToString);
end
else
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure');
end;
end end
else else
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure'); ShowToast('Failure:User not authorized to add to QuickBooks', 'failure');
end; end
end end
else else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure'); ShowToast('QB interface not currently active', 'info');
end; end;
[async] procedure TFOrderEntryCorrugated.GenerateReportPDF; [async] procedure TFOrderEntryCorrugated.GenerateReportPDF;
......
...@@ -193,24 +193,29 @@ procedure TFOrderEntryCuttingDie.btnQBClick(Sender: TObject); ...@@ -193,24 +193,29 @@ procedure TFOrderEntryCuttingDie.btnQBClick(Sender: TObject);
var var
orderJSON: TJSONObject; orderJSON: TJSONObject;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then if AuthService.TokenPayload.Properties['qb_enabled'] then
begin begin
if ( VerifyQBOrder() )then if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin begin
if wdbcbINQB.Checked = false then if ( VerifyQBOrder() )then
begin begin
Utils.ShowSpinner('spinner'); if wdbcbINQB.Checked = false then
orderJSON := TJSONObject.Create; begin
orderJSON.AddPair('ORDER_ID', xdwdsOrder.FieldByName('ORDER_ID').AsString); Utils.ShowSpinner('spinner');
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id'])); orderJSON := TJSONObject.Create;
addEstimate(orderJSON.ToString); orderJSON.AddPair('ORDER_ID', xdwdsOrder.FieldByName('ORDER_ID').AsString);
end orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id']));
else addEstimate(orderJSON.ToString);
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure'); end
end; else
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure');
end;
end
else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure');
end end
else else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure'); ShowToast('QB interface not currently active', 'info');
end; end;
procedure TFOrderEntryCuttingDie.WebButton2Click(Sender: TObject); procedure TFOrderEntryCuttingDie.WebButton2Click(Sender: TObject);
......
...@@ -454,24 +454,29 @@ procedure TFOrderEntryWeb.btnQBClick(Sender: TObject); ...@@ -454,24 +454,29 @@ procedure TFOrderEntryWeb.btnQBClick(Sender: TObject);
var var
orderJSON: TJSONObject; orderJSON: TJSONObject;
begin begin
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then if AuthService.TokenPayload.Properties['qb_enabled'] then
begin begin
if ( VerifyQBOrder() )then if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin begin
if wdbcbINQB.Checked = false then if ( VerifyQBOrder() )then
begin begin
Utils.ShowSpinner('spinner'); if wdbcbINQB.Checked = false then
orderJSON := TJSONObject.Create; begin
orderJSON.AddPair('ORDER_ID', xdwdsOrder.FieldByName('ORDER_ID').AsString); Utils.ShowSpinner('spinner');
orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id'])); orderJSON := TJSONObject.Create;
addEstimate(orderJSON.ToString); orderJSON.AddPair('ORDER_ID', xdwdsOrder.FieldByName('ORDER_ID').AsString);
end orderJSON.AddPair('USER_ID', JS.toString(AuthService.TokenPayload.Properties['user_id']));
else addEstimate(orderJSON.ToString);
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure'); end
end; else
ShowToast('Failure:Cannot submit orders already in QuickBooks', 'failure');
end;
end
else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure');
end end
else else
ShowToast('Failure:User not authorized to add to QuickBooks', 'failure'); ShowToast('QB interface not currently active', 'info');
end; end;
procedure TFOrderEntryWeb.AddEstimate(orderID: string); procedure TFOrderEntryWeb.AddEstimate(orderID: string);
......
...@@ -848,7 +848,9 @@ begin ...@@ -848,7 +848,9 @@ begin
searchOptions := '&pagenumber=' + IntToStr(PageNumber) + searchOptions := '&pagenumber=' + IntToStr(PageNumber) +
'&pagesize=' + IntToStr(PageSize) + '&pagesize=' + IntToStr(PageSize) +
'&orderby=' + OrderBy + '&orderby=' + OrderBy +
'&direction=' + direction; '&direction=' + direction +
'&accessRights=' + JS.toString(AuthService.TokenPayload.Properties['user_access_type']) +
'&userID=' + JS.toString(AuthService.TokenPayload.Properties['user_id']);
//Status 1 //Status 1
if ( (filterType1 <> '') and (filterType1 <> 'NONE') ) then if ( (filterType1 <> '') and (filterType1 <> 'NONE') ) then
......
...@@ -117,7 +117,6 @@ var ...@@ -117,7 +117,6 @@ var
Email: TJSNode; Email: TJSNode;
Access: TJSNode; Access: TJSNode;
Rights: TJSNode; Rights: TJSNode;
Perspective: TJSNode;
QB: TJSNode; QB: TJSNode;
isAdmin: boolean; isAdmin: boolean;
isActive: boolean; isActive: boolean;
...@@ -139,12 +138,11 @@ begin ...@@ -139,12 +138,11 @@ begin
Email := cells[5]; Email := cells[5];
Access := cells[6]; Access := cells[6];
Rights := cells[7]; Rights := cells[7];
Perspective := cells[8]; QB := cells[8];
QB := cells[9];
FViewMain.EditUser('Edit', Username.innerText, Password.innerText, FullName.innerText, FViewMain.EditUser('Edit', Username.innerText, Password.innerText, FullName.innerText,
Status.innerText, Email.innerText, Access.innerText, Status.innerText, Email.innerText, Access.innerText,
Rights.innerText, Perspective.innerText, QB.innerText); Rights.innerText, QB.innerText);
end; end;
...@@ -455,7 +453,7 @@ end; ...@@ -455,7 +453,7 @@ end;
procedure TFViewUsers.btnAddUserClick(Sender: TObject); procedure TFViewUsers.btnAddUserClick(Sender: TObject);
begin begin
//Info := ''; //Info := '';
FViewMain.EditUser('Add', '', '', '', '', '', '', '', '', ''); FViewMain.EditUser('Add', '', '', '', '', '', '', '', '');
end; end;
......
...@@ -6,7 +6,6 @@ object ApiDatabase: TApiDatabase ...@@ -6,7 +6,6 @@ object ApiDatabase: TApiDatabase
ProviderName = 'MySQL' ProviderName = 'MySQL'
Database = 'kg_order_entry' Database = 'kg_order_entry'
Username = 'root' Username = 'root'
Server = '192.168.159.158'
LoginPrompt = False LoginPrompt = False
Left = 75 Left = 75
Top = 65 Top = 65
...@@ -408,4 +407,29 @@ object ApiDatabase: TApiDatabase ...@@ -408,4 +407,29 @@ object ApiDatabase: TApiDatabase
Required = True Required = True
end end
end end
object uqUsers: TUniQuery
Connection = ucKG
SQL.Strings = (
'SELECT USER_ID, NAME, STATUS from users ORDER BY NAME')
OnCalcFields = uqUsersCalcFields
Left = 318
Top = 252
object uqUsersUSER_ID: TIntegerField
FieldName = 'USER_ID'
Required = True
end
object uqUsersNAME: TStringField
FieldName = 'NAME'
Size = 40
end
object uqUsersSTATUS: TStringField
FieldName = 'STATUS'
Size = 7
end
object uqUsersREPRESENTATIVE: TStringField
FieldKind = fkCalculated
FieldName = 'REPRESENTATIVE'
Calculated = True
end
end
end end
...@@ -112,7 +112,13 @@ type ...@@ -112,7 +112,13 @@ type
uqOrdersStatusScheduleORIGINAL_STATUS_DATE: TDateField; uqOrdersStatusScheduleORIGINAL_STATUS_DATE: TDateField;
uqOrdersStatusScheduleUSER_ID: TLongWordField; uqOrdersStatusScheduleUSER_ID: TLongWordField;
uqOrdersStatusScheduleORDER_REVISION: TLongWordField; uqOrdersStatusScheduleORDER_REVISION: TLongWordField;
uqUsers: TUniQuery;
uqUsersUSER_ID: TIntegerField;
uqUsersNAME: TStringField;
uqUsersSTATUS: TStringField;
uqUsersREPRESENTATIVE: TStringField;
procedure DataModuleCreate(Sender: TObject); procedure DataModuleCreate(Sender: TObject);
procedure uqUsersCalcFields(DataSet: TDataSet);
private private
{ Private declarations } { Private declarations }
public public
...@@ -158,4 +164,9 @@ begin ...@@ -158,4 +164,9 @@ begin
end; end;
end; end;
procedure TApiDatabase.uqUsersCalcFields(DataSet: TDataSet);
begin
uqUsersREPRESENTATIVE.AsString := uqUsersNAME.AsString + '(' + uqUsersSTATUS.AsString + ')';
end;
end. end.
...@@ -27,9 +27,9 @@ type ...@@ -27,9 +27,9 @@ type
userAccessType: string; userAccessType: string;
userEmail: string; userEmail: string;
userStatus: string; userStatus: string;
qbEnabled: boolean;
procedure AfterConstruction; override; procedure AfterConstruction; override;
procedure BeforeDestruction; override; procedure BeforeDestruction; override;
property Query: TUniQuery read GetQuery;
function CheckUser(const user, password: string): Integer; function CheckUser(const user, password: string): Integer;
public public
function Login(const user, password: string): string; function Login(const user, password: string): string;
...@@ -55,7 +55,15 @@ uses ...@@ -55,7 +55,15 @@ uses
procedure TAuthService.AfterConstruction; procedure TAuthService.AfterConstruction;
begin begin
inherited; inherited;
authDB := TAuthDatabase.Create(nil); try
authDB := TAuthDatabase.Create(nil);
except
on E: Exception do
begin
Logger.Log(1, 'Error when creating the Auth database: ' + E.Message);
raise EXDataHttpException.Create(500, 'Unable to create Auth database: A KGOrders Server Error has occured!');
end;
end;
end; end;
procedure TAuthService.BeforeDestruction; procedure TAuthService.BeforeDestruction;
...@@ -81,6 +89,7 @@ begin ...@@ -81,6 +89,7 @@ begin
try try
webClientVersion := iniFile.ReadString('Settings', 'webClientVersion', ''); webClientVersion := iniFile.ReadString('Settings', 'webClientVersion', '');
Result.AddPair('webClientVersion', webClientVersion); Result.AddPair('webClientVersion', webClientVersion);
qbEnabled := iniFile.ReadBool('Quickbooks', 'Enabled', false);
if webClientVersion = '' then if webClientVersion = '' then
begin begin
...@@ -102,6 +111,7 @@ end; ...@@ -102,6 +111,7 @@ end;
function TAuthService.Login(const user, password: string): string; function TAuthService.Login(const user, password: string): string;
var var
userState: Integer; userState: Integer;
iniFile: TIniFile;
JWT: TJWT; JWT: TJWT;
begin begin
Logger.Log(3, Format( 'AuthService.Login - User: "%s"', [User])); Logger.Log(3, Format( 'AuthService.Login - User: "%s"', [User]));
...@@ -128,8 +138,18 @@ begin ...@@ -128,8 +138,18 @@ begin
logger.Log(2, 'Login Error: User does not exist!'); logger.Log(2, 'Login Error: User does not exist!');
end end
else if userState = 2 then else if userState = 2 then
begin
raise EXDataHttpUnauthorized.Create('User not active!'); raise EXDataHttpUnauthorized.Create('User not active!');
logger.Log(2, 'Login Error: User not active!'); logger.Log(2, 'Login Error: User not active!');
end;
iniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
try
qbEnabled := iniFile.ReadBool('Quickbooks', 'Enabled', false);
finally
iniFile.Free;
end;
JWT := TJWT.Create; JWT := TJWT.Create;
try try
...@@ -144,7 +164,7 @@ begin ...@@ -144,7 +164,7 @@ begin
JWT.Claims.SetClaimOfType<string>('user_email', userEmail); JWT.Claims.SetClaimOfType<string>('user_email', userEmail);
JWT.Claims.SetClaimOfType<string>('user_qb_id', userQBID); JWT.Claims.SetClaimOfType<string>('user_qb_id', userQBID);
JWT.Claims.SetClaimOfType<string>('user_access_type', userAccessType); JWT.Claims.SetClaimOfType<string>('user_access_type', userAccessType);
JWT.Claims.SetClaimOfType<string>('user_admin', LowerCase(BoolToStr(SameText(userAccessType, 'ADMIN'), True))); JWT.Claims.SetClaimOfType<boolean>('qb_enabled', qbEnabled);
Result := TJOSE.SHA256CompactToken(serverConfig.jwtTokenSecret, JWT); Result := TJOSE.SHA256CompactToken(serverConfig.jwtTokenSecret, JWT);
finally finally
......
...@@ -33,6 +33,7 @@ type ...@@ -33,6 +33,7 @@ type
rights: integer; rights: integer;
perspectiveID: string; perspectiveID: string;
QBID: string; QBID: string;
representative: string;
end; end;
TUserList = class TUserList = class
......
...@@ -98,7 +98,6 @@ var ...@@ -98,7 +98,6 @@ var
f: TStringList; f: TStringList;
fi: string; fi: string;
JSObj: TJSONObject; JSObj: TJSONObject;
iniFile: TIniFile;
Encoder: TBase64Encoding; Encoder: TBase64Encoding;
begin begin
// 1. Encode credentials (same as working Postman request) // 1. Encode credentials (same as working Postman request)
...@@ -129,7 +128,7 @@ begin ...@@ -129,7 +128,7 @@ begin
SSLIO.SSLOptions.SSLVersions := [sslvTLSv1_2]; SSLIO.SSLOptions.SSLVersions := [sslvTLSv1_2];
IdHTTP.IOHandler := SSLIO; IdHTTP.IOHandler := SSLIO;
// Set headers (EXACT match with Postman) // Set headers
IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded'; IdHTTP.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP.Request.Accept := 'application/json'; IdHTTP.Request.Accept := 'application/json';
IdHTTP.Request.CustomHeaders.AddValue('Authorization', 'Basic ' + EncodedAuth); IdHTTP.Request.CustomHeaders.AddValue('Authorization', 'Basic ' + EncodedAuth);
...@@ -162,7 +161,6 @@ end; ...@@ -162,7 +161,6 @@ end;
procedure TQBService.SaveTokens(AccessToken, RefreshToken: string); procedure TQBService.SaveTokens(AccessToken, RefreshToken: string);
var var
f: TStringList; f: TStringList;
iniStr, line: string;
iniFile: TIniFile; iniFile: TIniFile;
begin begin
iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' ); iniFile := TIniFile.Create( ExtractFilePath(Application.ExeName) + 'kgOrdersServer.ini' );
......
...@@ -148,7 +148,7 @@ object fQB: TfQB ...@@ -148,7 +148,7 @@ object fQB: TfQB
OnClick = Button12Click OnClick = Button12Click
end end
object Button15: TButton object Button15: TButton
Left = 646 Left = 631
Top = 32 Top = 32
Width = 137 Width = 137
Height = 25 Height = 25
......
...@@ -7,7 +7,6 @@ object rptOrderCutting: TrptOrderCutting ...@@ -7,7 +7,6 @@ object rptOrderCutting: TrptOrderCutting
Database = 'kg_order_entry' Database = 'kg_order_entry'
Username = 'root' Username = 'root'
Server = '192.168.159.10' Server = '192.168.159.10'
Connected = True
LoginPrompt = False LoginPrompt = False
Left = 289 Left = 289
Top = 119 Top = 119
...@@ -53,134 +52,6 @@ object rptOrderCutting: TrptOrderCutting ...@@ -53,134 +52,6 @@ object rptOrderCutting: TrptOrderCutting
DataSetOptions = [] DataSetOptions = []
Left = 444 Left = 444
Top = 206 Top = 206
FieldDefs = <
item
FieldName = 'ORDER_ID'
end
item
FieldName = 'COMPANY_ID'
end
item
FieldName = 'USER_ID'
end
item
FieldName = 'ORDER_DATE'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_order_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_proof_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_ship_date'
FieldType = fftDateTime
end
item
FieldName = 'staff_fields_ship_via'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quantity'
FieldType = fftString
end
item
FieldName = 'staff_fields_price'
FieldType = fftString
end
item
FieldName = 'staff_fields_invoice_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_ship_to'
FieldType = fftString
Size = 128
end
item
FieldName = 'staff_fields_po_number'
FieldType = fftString
Size = 16
end
item
FieldName = 'staff_fields_job_name'
FieldType = fftString
Size = 45
end
item
FieldName = 'staff_fields_quickbooks_item'
FieldType = fftString
Size = 45
end
item
FieldName = 'general_special_instructions'
FieldType = fftString
Size = 2048
end
item
FieldName = 'ORDER_STATUS'
FieldType = fftString
Size = 50
end
item
FieldName = 'ORDER_ID_1'
end
item
FieldName = 'COMPANY_ID_1'
end
item
FieldName = 'ORDER_TYPE'
FieldType = fftString
Size = 45
end
item
FieldName = 'ORDER_DATE_1'
FieldType = fftDateTime
end
item
FieldName = 'PRICE'
end
item
FieldName = 'JOB_NAME'
FieldType = fftString
Size = 128
end
item
FieldName = 'USER_ID_1'
end
item
FieldName = 'LOCATION'
FieldType = fftString
Size = 16
end
item
FieldName = 'IN_QB'
FieldType = fftString
end
item
FieldName = 'QB_ORDER_NUM'
FieldType = fftString
Size = 30
end
item
FieldName = 'QB_ESTIMATE_ID'
FieldType = fftString
Size = 30
end
item
FieldName = 'QB_ORDER_USER'
FieldType = fftString
Size = 60
end
item
FieldName = 'QB_CREATE_DATE'
FieldType = fftDateTime
end>
end end
object frxOrderCutting: TfrxReport object frxOrderCutting: TfrxReport
Version = '2025.2.4' Version = '2025.2.4'
...@@ -1782,7 +1653,6 @@ object rptOrderCutting: TrptOrderCutting ...@@ -1782,7 +1653,6 @@ object rptOrderCutting: TrptOrderCutting
'select * from cutting_die_orders c join orders o on c.ORDER_ID =' + 'select * from cutting_die_orders c join orders o on c.ORDER_ID =' +
' o.ORDER_ID where c.ORDER_ID = 20649') ' o.ORDER_ID where c.ORDER_ID = 20649')
Active = True
Left = 457 Left = 457
Top = 106 Top = 106
object uqOrderCuttingORDER_ID: TIntegerField object uqOrderCuttingORDER_ID: TIntegerField
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
MemoLogLevel=4 MemoLogLevel=4
FileLogLevel=4 FileLogLevel=4
webClientVersion=1.0.0 webClientVersion=1.0.0
LogFileNum=126 LogFileNum=158
[Database] [Database]
--Server=192.168.116.138 --Server=192.168.116.138
...@@ -15,6 +15,7 @@ Password=emsys01 ...@@ -15,6 +15,7 @@ Password=emsys01
--Password=emsys!012 --Password=emsys!012
[Quickbooks] [Quickbooks]
Enabled=0
CompanyID=9341454336461805 CompanyID=9341454336461805
ClientID=ABYqlDx1EsacZYXvHIJ7RDB7zmnQdwABU3fwQLIZPmBgU0VW1P ClientID=ABYqlDx1EsacZYXvHIJ7RDB7zmnQdwABU3fwQLIZPmBgU0VW1P
ClientSecret=PM7OnvQWsgOqjWfDpZAnyRttDN9446Am6d85pDxr ClientSecret=PM7OnvQWsgOqjWfDpZAnyRttDN9446Am6d85pDxr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment