Commit dc71971e by Mac Stephens

Merge remote-tracking branch 'origin/cam'

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