Commit 1f4ba8ce by Cam Hayes

fixed drop down, limited sales user to only access their customers and only…

fixed drop down, limited sales user to only access their customers and only admins can access the customer page
parent 64f087b4
...@@ -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 = 280
Top = 8 Top = 8
Width = 56 Width = 56
Height = 15 Height = 15
...@@ -36,8 +36,8 @@ object FViewEditUser: TFViewEditUser ...@@ -36,8 +36,8 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object WebLabel6: TWebLabel object WebLabel6: TWebLabel
Left = 240 Left = 236
Top = 41 Top = 37
Width = 100 Width = 100
Height = 15 Height = 15
Caption = 'Confirm Password:' Caption = 'Confirm Password:'
...@@ -79,8 +79,8 @@ object FViewEditUser: TFViewEditUser ...@@ -79,8 +79,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:'
...@@ -100,7 +100,7 @@ object FViewEditUser: TFViewEditUser ...@@ -100,7 +100,7 @@ object FViewEditUser: TFViewEditUser
WidthPercent = 100.000000000000000000 WidthPercent = 100.000000000000000000
end end
object edtConfirmPassword: TWebEdit object edtConfirmPassword: TWebEdit
Left = 348 Left = 346
Top = 34 Top = 34
Width = 121 Width = 121
Height = 22 Height = 22
...@@ -136,7 +136,7 @@ object FViewEditUser: TFViewEditUser ...@@ -136,7 +136,7 @@ object FViewEditUser: TFViewEditUser
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'
...@@ -217,7 +217,7 @@ object FViewEditUser: TFViewEditUser ...@@ -217,7 +217,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 +226,9 @@ object FViewEditUser: TFViewEditUser ...@@ -226,12 +226,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 +242,14 @@ object FViewEditUser: TFViewEditUser ...@@ -245,14 +242,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
...@@ -51,7 +51,6 @@ type ...@@ -51,7 +51,6 @@ 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;
...@@ -60,7 +59,7 @@ type ...@@ -60,7 +59,7 @@ type
{ 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
...@@ -150,7 +149,7 @@ begin ...@@ -150,7 +149,7 @@ begin
end; 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 +160,6 @@ class function TFViewEditUser.CreateForm(AElementID, Mode, Username, Password, N ...@@ -161,7 +160,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;
......
...@@ -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);
...@@ -96,7 +96,10 @@ begin ...@@ -96,7 +96,10 @@ begin
change := false; change := false;
console.log(JS.toBoolean(AuthService.TokenPayload.Properties['user_access_type'])); console.log(JS.toBoolean(AuthService.TokenPayload.Properties['user_access_type']));
if (not (JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN')) then 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';
...@@ -275,12 +278,12 @@ begin ...@@ -275,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);
......
...@@ -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,8 @@ object ApiDatabase: TApiDatabase ...@@ -6,7 +6,8 @@ object ApiDatabase: TApiDatabase
ProviderName = 'MySQL' ProviderName = 'MySQL'
Database = 'kg_order_entry' Database = 'kg_order_entry'
Username = 'root' Username = 'root'
Server = '192.168.159.158' Server = '192.168.159.10'
Connected = True
LoginPrompt = False LoginPrompt = False
Left = 75 Left = 75
Top = 65 Top = 65
...@@ -408,4 +409,29 @@ object ApiDatabase: TApiDatabase ...@@ -408,4 +409,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.
...@@ -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
......
...@@ -528,17 +528,18 @@ var ...@@ -528,17 +528,18 @@ var
SQL: string; SQL: string;
begin begin
Logger.Log(3, 'TLookupService.GetRepUsers'); Logger.Log(3, 'TLookupService.GetRepUsers');
SQL := 'SELECT USER_ID, NAME from users where QB_ID IS NOT NULL AND QB_ID <> ' + quotedStr(''); SQL := 'SELECT USER_ID, NAME, STATUS from users ORDER BY NAME';
result := TList<TUserItem>.Create; result := TList<TUserItem>.Create;
doQuery(ordersDB.UniQuery1, SQL); doQuery(ordersDB.uqUsers, SQL);
while not ordersDB.UniQuery1.Eof do while not ordersDB.uqUsers.Eof do
begin begin
USER := TUserItem.Create; USER := TUserItem.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add( USER ); TXDataOperationContext.Current.Handler.ManagedObjects.Add( USER );
USER.userID := ordersDB.UniQuery1.FieldByName('USER_ID').AsString; USER.userID := ordersDB.uqUsersUSER_ID.AsString;
USER.full_name := ordersDB.UniQuery1.FieldByName('NAME').AsString; USER.full_name := ordersDB.uqUsersNAME.AsString;
USER.representative := ordersDB.uqUsersREPRESENTATIVE.AsString;
result.Add(USER); result.Add(USER);
ordersDB.UniQuery1.Next; ordersDB.uqUsers.Next;
end; end;
end; end;
...@@ -1736,12 +1737,12 @@ begin ...@@ -1736,12 +1737,12 @@ begin
if not QB.IsEmpty then if not QB.IsEmpty then
ordersDB.UniQuery1.FieldByName('QB_ID').AsString := QB; ordersDB.UniQuery1.FieldByName('QB_ID').AsString := QB;
{if((not (Password = 'hidden')) and (not (Password.IsEmpty))) then if((not (Password = 'hidden')) and (not (Password.IsEmpty))) then
begin begin
hashString := ordersDB.UniQuery1.FieldByName('date_created').AsString + password; hashString := ordersDB.UniQuery1.FieldByName('NAME').AsString + password;
hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper; hashPW := THashSHA2.GetHashString(hashString, THashSHA2.TSHA2Version.SHA512).ToUpper;
ordersDB.UniQuery1.FieldByName('password').AsString := hashPW; ordersDB.UniQuery1.FieldByName('password').AsString := hashPW;
end;} end;
ordersDB.UniQuery1.Post; ordersDB.UniQuery1.Post;
Result := 'Success: User Successfully Edited'; Result := 'Success: User Successfully Edited';
......
...@@ -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
......
...@@ -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=129 LogFileNum=137
[Database] [Database]
--Server=192.168.116.138 --Server=192.168.116.138
......
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